juaribe
Hello,
 
I have a problem when I try to transfer a program with several parts, one in LD and another in SFC. May be the problem can be because a bad use of Global Variables. The global vars that I have been using are Roig, Ambar i Verd.
 
The fact that I have been like this is because I'm now learning OpenPLC and I'm trying all the possibilities.
 
My SFC is:
 
Captura de pantalla 2025-05-03 a las 13.27.01.png
 
My LD is:
 
Captura de pantalla 2025-05-03 a las 13.27.09.png
 
And the declaration of Global Vars is:
 
Captura de pantalla 2025-05-03 a las 13.27.20.png
 
When I try to transfer the errors are those:
 
C:\Users\juan\OpenPLC_Editor\editor\arduino\src\lib/accessor.h:71:30: error: implicit declaration of function '__GET_GLOBAL_ROIG' [-Wimplicit-function-declaration]
71 | name.value = __GET_GLOBAL_##global();\
| ^~~~~~~~~~~~~
C:\Users\juan\OpenPLC_Editor\editor\arduino\src\POUS.c:7:3: note: in expansion of macro '__INIT_EXTERNAL'
7 | __INIT_EXTERNAL(BOOL,ROIG,data__->ROIG,retain)
| ^~~~~~~~~~~~~~~
C:\Users\juan\OpenPLC_Editor\editor\arduino\src\lib/accessor.h:71:28: error: assignment to 'IEC_BOOL *' {aka 'unsigned char *'} from 'int' makes pointer from integer without a cast [-Wint-conversion]
71 | name.value = __GET_GLOBAL_##global();\
| ^
C:\Users\juan\OpenPLC_Editor\editor\arduino\src\POUS.c:7:3: note: in expansion of macro '__INIT_EXTERNAL'
7 | __INIT_EXTERNAL(BOOL,ROIG,data__->ROIG,retain)
| ^~~~~~~~~~~~~~~
C:\Users\juan\OpenPLC_Editor\editor\arduino\src\lib/accessor.h:71:30: error: implicit declaration of function '__GET_GLOBAL_AMBAR' [-Wimplicit-function-declaration]
71 | name.value = __GET_GLOBAL_##global();\
| ^~~~~~~~~~~~~
C:\Users\juan\OpenPLC_Editor\editor\arduino\src\POUS.c:8:3: note: in expansion of macro '__INIT_EXTERNAL'
8 | __INIT_EXTERNAL(BOOL,AMBAR,data__->AMBAR,retain)
| ^~~~~~~~~~~~~~~
C:\Users\juan\OpenPLC_Editor\editor\arduino\src\lib/accessor.h:71:28: error: assignment to 'IEC_BOOL *' {aka 'unsigned char *'} from 'int' makes pointer from integer without a cast [-Wint-conversion]
71 | name.value = __GET_GLOBAL_##global();\
| ^
C:\Users\juan\OpenPLC_Editor\editor\arduino\src\POUS.c:8:3: note: in expansion of macro '__INIT_EXTERNAL'
8 | __INIT_EXTERNAL(BOOL,AMBAR,data__->AMBAR,retain)
| ^~~~~~~~~~~~~~~
C:\Users\juan\OpenPLC_Editor\editor\arduino\src\lib/accessor.h:71:30: error: implicit declaration of function '__GET_GLOBAL_VERD' [-Wimplicit-function-declaration]
71 | name.value = __GET_GLOBAL_##global();\
| ^~~~~~~~~~~~~
C:\Users\juan\OpenPLC_Editor\editor\arduino\src\POUS.c:9:3: note: in expansion of macro '__INIT_EXTERNAL'
9 | __INIT_EXTERNAL(BOOL,VERD,data__->VERD,retain)
| ^~~~~~~~~~~~~~~
C:\Users\juan\OpenPLC_Editor\editor\arduino\src\lib/accessor.h:71:28: error: assignment to 'IEC_BOOL *' {aka 'unsigned char *'} from 'int' makes pointer from integer without a cast [-Wint-conversion]
71 | name.value = __GET_GLOBAL_##global();\
| ^
C:\Users\juan\OpenPLC_Editor\editor\arduino\src\POUS.c:9:3: note: in expansion of macro '__INIT_EXTERNAL'
9 | __INIT_EXTERNAL(BOOL,VERD,data__->VERD,retain)
| ^~~~~~~~~~~~~~~
C:\Users\juan\OpenPLC_Editor\editor\arduino\src\POUS.c: In function 'LADDER_init__':
C:\Users\juan\OpenPLC_Editor\editor\arduino\src\lib/accessor.h:71:28: error: assignment to 'IEC_BOOL *' {aka 'unsigned char *'} from 'int' makes pointer from integer without a cast [-Wint-conversion]
71 | name.value = __GET_GLOBAL_##global();\
| ^
C:\Users\juan\OpenPLC_Editor\editor\arduino\src\POUS.c:396:3: note: in expansion of macro '__INIT_EXTERNAL'
396 | __INIT_EXTERNAL(BOOL,ROIG,data__->ROIG,retain)
| ^~~~~~~~~~~~~~~
C:\Users\juan\OpenPLC_Editor\editor\arduino\src\lib/accessor.h:71:28: error: assignment to 'IEC_BOOL *' {aka 'unsigned char *'} from 'int' makes pointer from integer without a cast [-Wint-conversion]
71 | name.value = __GET_GLOBAL_##global();\
| ^
C:\Users\juan\OpenPLC_Editor\editor\arduino\src\POUS.c:397:3: note: in expansion of macro '__INIT_EXTERNAL'
397 | __INIT_EXTERNAL(BOOL,AMBAR,data__->AMBAR,retain)
| ^~~~~~~~~~~~~~~
C:\Users\juan\OpenPLC_Editor\editor\arduino\src\lib/accessor.h:71:28: error: assignment to 'IEC_BOOL *' {aka 'unsigned char *'} from 'int' makes pointer from integer without a cast [-Wint-conversion]
71 | name.value = __GET_GLOBAL_##global();\
| ^
C:\Users\juan\OpenPLC_Editor\editor\arduino\src\POUS.c:398:3: note: in expansion of macro '__INIT_EXTERNAL'
398 | __INIT_EXTERNAL(BOOL,VERD,data__->VERD,retain)
| ^~~~~~~~~~~~~~~
Se encontraron varias bibliotecas para "WiFi.h"
Usado: C:\Users\juan\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\libraries\WiFi
No utilizado: C:\Users\juan\Documents\Arduino\libraries\WiFiNINA
Utilizando biblioteca src en carpeta: C:\Users\juan\OpenPLC_Editor\editor\arduino\src (legado)
Usando librería WiFi con versión 3.2.0 en la carpeta: C:\Users\juan\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\libraries\WiFi
Usando librería Networking con versión 3.2.0 en la carpeta: C:\Users\juan\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\libraries\Network
Utilizando biblioteca lib en carpeta: C:\Users\juan\OpenPLC_Editor\editor\arduino\src\lib (legado)
Used library Version Path
src C:\Users\juan\OpenPLC_Editor\editor\arduino\src
WiFi 3.2.0 C:\Users\juan\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\libraries\WiFi
Networking 3.2.0 C:\Users\juan\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\libraries\Network
lib C:\Users\juan\OpenPLC_Editor\editor\arduino\src\lib
Used platform Version Path
esp32:esp32 3.2.0 C:\Users\juan\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0
Error during build: exit status 1
$? = 1
Build phase <function build.<locals>.build_project at 0x000001D12BF1A0D0> failed
 
Whats the problem? Sorry for my english!!!
 
Best regards and thanks
Reply 0 0
thiagoralves
Update your editor and it will work
Reply 0 0
juaribe
Update your editor and it will work
I did this just before sending the issues to the forum and it didn't worked. Also I deleted the folder Arduino15. Nothin works. The program run properly when I erase the ladder program and the global variables. I still thinking that the problem is the bad use of the global variables or a bad configuration. Do you think that I did the program well? Do yo have an example of use of global variables in several parts of the program? It will help me a lot. I didn't found one example at the documentation.
 
Thanks
Reply 0 0
thiagoralves
What is the release version of your editor? You can see it on the about screen.
Reply 0 0
juaribe
I have the most recent versión. In fact, I tried to compile with my Mac and with virtual machine W11, both versions of OpenPLC are the same. In both cases the same error. I have to say that my mac has a cpu apple silicon M4. It's possible that OpenPLC can't run properly in this cpu?
 
I'm going to attach the program. If you want, you can try to compile that program.
 
Captura de pantalla 2025-05-03 a las 20.45.02.png
What is the release version of your editor? You can see it on the about screen.
I have the most recent versión. In fact, I tried to compile with my Mac and with virtual machine W11, both versions of OpenPLC are the same. In both cases the same error. I have to say that my mac has a cpu apple silicon M4. It's possible that OpenPLC can't run properly in this cpu?
 
I'm going to attach the program. If you want, you can try to compile that program.
Reply 0 0
thiagoralves
Try moving your global variables to your project (in your case Sin nombre) instead of declaring them in Res0 and see if that works.
Reply 0 0
juaribe
Try moving your global variables to your project (in your case Sin nombre) instead of declaring them in Res0 and see if that works.
It works!!!
 
Thanks. Obiusly I was doing something wrong. I didn't known that the global vars had to be declared in that place.
 
Thanks a lot.
Reply 0 0
mrea
@thiagoralves this also solved my global variables issues with ESP32 by moving them from res to project. Does the RES0 no longer support global variables or a bug? Whats' the difference declaring them in RES0 or Project Properties?
Reply 0 0
thiagoralves
It is essentially the same thing, just the order in which the variables are declared. Some compilers complain about Res0 because it declared the variables in a separate file.
Reply 0 0
juaribe
I have added the same variables to an "Arduino extesion" and the program fails again when complie. I really don't understend how to manage global variable with several subroutines. I have declared the variables on the project and as external variables at the rest of the subroutines except on the Arduin extension, when I've declared the variables only with his type of data because there is imposible declare them like External. Is there any documentation that explain how to mange global variables?
Reply 0 0
thiagoralves
You don't have to declare Arduino variables again as globals in the project. If you do, you'll be essentially declaring the same variable twice, hence the compilation error. Arduino variables are also globals. You define them on the Arduino extension and then can use anywhere as externals.
Reply 0 0
juaribe
You don't have to declare Arduino variables again as globals in the project. If you do, you'll be essentially declaring the same variable twice, hence the compilation error. Arduino variables are also globals. You define them on the Arduino extension and then can use anywhere as externals.
It works. Thank you. Now I beter understan global vars when I use Arduino extensión. I was driving myself crazy.
Reply 0 0
Write a reply...
Reply