Jump to content
OMRON Forums

Output by structure doesn't work (bgcplc0)


RomanSolonto
 Share

Recommended Posts

Good day.

 

// Local variables:

#define adrMvar 3000

int modAdr = 0xFFF000FF; // Template variable

int adr = 0;

 

// Create a pointer to a structure:

int MyFirstICAdr;

int *MyFirstICGpioData;

MyFirstICAdr = pshm->OffsetGate3[0]; // Gate3[0]

MyFirstICGpioData = (int *) piom + ((MyFirstICAdr + 0x250) >> 2); // Defined pointer on Gate3[0].GpioData[0]

 

// Read the value of the M-variable with a type cast and mask overlay:

adr = ((int) GetPtrVar(adrMvar)) & 0x0000000F;

 

// Modify a variable and pass it to the registry I/O Gate3[0].GpioData[0]:

modAdr |= (adr << 16); // The result will be the following, when adr=0xf (for example): adr<<16 = 0xf<<16 = 0xf0000; modAdr = modAdr | 0xf0000 = 0xFFF000FF | 0xf0000 = 0xFFFf00FF

pshm->Gate3PartData[0].GpioOutData[0] &= modAdr;

*MyFirstICGpioData = pshm->Gate3PartData[0].GpioOutData[0];

 

// As a result, the outputs of MO1, MO2, MO3, MO4 (it Gate3[0].GpioData[0].16.4) must appear, but it does not appear

Link to comment
Share on other sites

  • Replies 6
  • Created
  • Last Reply

Top Posters In This Topic

Ok, I corrected the variable types:

 

// Local variables:

#define adrMvar 3000

unsigned int modAdr = 0xFFF000FF; // Template variable

unsigned int adr = 0;

 

// Create a pointer to a structure:

volatile unsigned int MyFirstICAdr;

volatile unsigned int *MyFirstICGpioData;

MyFirstICAdr = pshm->OffsetGate3[0]; // Gate3[0]

MyFirstICGpioData = (int *) piom + ((MyFirstICAdr + 0x250) >> 2); // Defined pointer on Gate3[0].GpioData[0]

 

// Read the value of the M-variable with a type cast and mask overlay:

adr = ((int) GetPtrVar(adrMvar)) & 0x0000000F;

 

// Modify a variable and pass it to the registry I/O Gate3[0].GpioData[0]:

modAdr |= (adr << 16); // The result will be the following, when adr=0xf (for example): adr<<16 = 0xf<<16 = 0xf0000; modAdr = modAdr | 0xf0000 = 0xFFF000FF | 0xf0000 = 0xFFFf00FF

pshm->Gate3PartData[0].GpioOutData[0] &= modAdr;

*MyFirstICGpioData = pshm->Gate3PartData[0].GpioOutData[0];

 

But the result is not changed - on the output port has no signal.

Includes the following files:

#include

#include

#include

#define _PPScriptMode_ // uncomment for Pmac Script type access

#define _EnumMode_ // uncomment for Pmac enum data type checking on Set & Get global functions

#include "../../Include/pp_proj.h"

#include

Need to connect something else?

Link to comment
Share on other sites

Tried PPScriptMode and EnumMode:

1. // #define _PPScriptMode_

#define _EnumMode_

2. #define _PPScriptMode_

// #define _EnumMode_

But the result is not changed - on the output port has no signal.

What else could prevent the loading of a number in a variable Gate3[0].GpioData[0]?

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share


×
×
  • Create New...