xiaohh
Hi thiagoralves
 
I'm playing with OpenPLC in Arduino. I want to share variable & function between Arduino extension and PLC, I read this post Adding Arduino Library's and defining additional IO mappings and Modbus Master - OpenPLC Forum, but so far this is still not very successful, can you help?
I have my test project attached, so far, I can only read Arduino extension variables from PLC, but not from the other direction since there is no external attribute in the Arduino Extension variables.
I tried to call Arduino extension function from PLC by put the function name in { }, but it does not work.
I tried to call PLC functions / function blocks from Arduino extension, it failed also.
Reply 0 0
thiagoralves
As I said in the post you referenced, Arduino and PLC code run in different worlds. Arduino is C++ and PLC code is C, so an interaction between them is a bit more complicated. You cannot call Arduino functions from the PLC side. The only thing you have is shared variables. Variables declared in the table on the Arduino side are shared/global by definition. You don’t have to declare them as external. If you write to an Arduino variable from the PLC side, you will be able to read that from the Arduino side and vice-versa.
Reply 1 0
xiaohh
Thanks for the fast and precise answer.
Reply 0 0
Reply