mverdia
Hi,  i wold like to know how to declare arrays   like  this   NameOfArray WORD[8] in variable pane of arduino extension, because array type is not present.
Arduino extension cant use global variables defined in res0 because external is not allowed.
Defining a  a type derived from array base type word is show in variables pane but fail compilation .
Thanks in advance.
Reply 0 0
mverdia
Hi all , dont care about my question, i mapped static vars defined in variable pane of extension.
Reply 0 0
richw
I asked the same question 15 days ago without any reply
Reply 0 0
mverdia
my workaround is  a function that map  pointer to static declared vars in  a device struct instead :
***********
cant use this from openplc code :
WORD CTRL[8];
WORD IOREG[8];
BOOL ERROR[8];
 
******************
 
 
**************
Workaround:
 
void SetOPENPLCSharedPTR(BYTE dev)
{
 
Device * a = &Devices[dev];
if (Serial)Serial.println("Setting vars address");
 
switch (dev)
{
case 0:
a->ioreg = (WORD *) &IOREG0;
// a->pnpIO = &PNPIO0;
a->ctrl = (WORD*) &CTRL0;
a->error =(BOOL *)  &ERROR0;
break;
case 1:
a->ioreg = &IOREG1;
//a->pnpIO = &PNPIO0;
a->ctrl = &CTRL1;
a->error = &ERROR1;
 
break;
case 2:
a->ioreg = &IOREG2;
//a->pnpIO = &PNPIO0;
a->ctrl = &CTRL2;
a->error = &ERROR2;
 
break;
 
 
case 3:
a->ioreg = &IOREG3;
//a->pnpIO = &PNPIO0;
a->ctrl = &CTRL3;
a->error = &ERROR3;
 
break;
 
case 4:
a->ioreg = &IOREG4;
//a->pnpIO = &PNPIO0;
a->ctrl = &CTRL4;
a->error = &ERROR4;
 
break;
 
case 5:
a->ioreg = &IOREG5;
//a->pnpIO = &PNPIO0;
a->ctrl = &CTRL5;
a->error = &ERROR5;
 
break;
 
 
case 6:
a->ioreg = &IOREG6;
//a->pnpIO = &PNPIO0;
a->ctrl = &CTRL6;
a->error = &ERROR6;
 
break;
 
case 7:
a->ioreg = &IOREG7;
//a->pnpIO = &PNPIO0;
a->ctrl = &CTRL7;
a->error = &ERROR7;
 
break;
 
}
}
Reply 0 0
thiagoralves
Unfortunately you can’t have arrays declared in the shared variable pane of the Arduino Extension. This is another feature that needs to be added to the IDE. The pointers workaround that @mverdia proposed, although not simple to use, is a good alternative if you really need some form of array being shared between the Arduino and PLC sides.
Reply 0 0
Reply