engralimirza
Hi, I want to write a code in C for ESP32. My task is
1. Connect main ESP32 as Main Controller
2. Main controller ESP32 is connected to two slave ESP32 via SPI Protocol

So it will work like Master ESP32 will be blinking GPIO LED and at the same it will send signal/commands to slave devices too for blinking LED on Slave devices too.

Right now I wrote a code in Arduino extension but not in Ladder Logic program but I'm not getting anything how to burn that Arduino extension code on ESP32? or maybe I should not use Arduino extension for writing C code?
Reply 0 0
thiagoralves
When you upload your program as usual on the orange circuit icon, the Arduino extension code goes with it. You just need to be careful with your pin mappings. If you are trying to write to GPIO pins from the extension, but those pins are also defined in the I/O Config of the PLC runtime, then you will cause a conflict and the code won’t work. You must remove all pins you’re using explicitly in the extension from the I/O Config list
Reply 0 0
engralimirza
When you upload your program as usual on the orange circuit icon, the Arduino extension code goes with it. You just need to be careful with your pin mappings. If you are trying to write to GPIO pins from the extension, but those pins are also defined in the I/O Config of the PLC runtime, then you will cause a conflict and the code won’t work. You must remove all pins you’re using explicitly in the extension from the I/O Config list
Yes, I tried that. I only wrote code in Arduino extension. But when I try to burn the code on controller it gives me this error.

exited with status 1 (pid 5724)
D:\OpenPLC\1. Projects\3. C Code Blink LED\build\plc.st:32-36..32-43: error: invalid program type name after ':' in program configuration.
In section: CONFIGURATION Config0
0032: PROGRAM instance0 WITH task0 : BlinkLED;
1 error(s) found. Bailing out!
Error : IEC to C compiler returned 1
PLC code generation failed !


Test1.png
Reply 0 0
fg71
You couldn't use delay() in Arduino extension you need to use millis() instead
Reply 0 0
thiagoralves
You need to have at least one PLC program in your project, even if it is not doing anything. It cannot be blank, so just setting a dummy variable to a value is enough. Also, your Arduino code is incorrect. LED is a variable, not a pin number.
Reply 0 0
engralimirza
You need to have at least one PLC program in your project, even if it is not doing anything. It cannot be blank, so just setting a dummy variable to a value is enough. Also, your Arduino code is incorrect. LED is a variable, not a pin number.
Thanks, let me try that now.
Reply 0 0
engralimirza
Also, your Arduino code is incorrect. LED is a variable, not a pin number.
So, I've to define LED as Pin Number which we define in Ladder Language too right?
Reply 0 0
thiagoralves
No, if you’re only using the Arduino extension, you define it the same way you would in the Arduino ide. You must also delete all pin numbers from the I/O Config otherwise the PLC runtime will try to use them
Reply 0 0
engralimirza
No, if you’re only using the Arduino extension, you define it the same way you would in the Arduino ide. You must also delete all pin numbers from the I/O Config otherwise the PLC runtime will try to use them
Got it, Thanks for your time.
Reply 0 0
fg71
The idea with Arduino extension is to include Arduino logic or low level programming C/C++ with IEC-61131-3 programming.
Reply 0 0
Reply