GregC
Hi, I have an Arduino Nano connected to a Raspberry Pi as a slave so I can read 0-5v pressure transducer analog inputs.
I have the Nano and Raspberry Pi operating following video 5
Is there any sample code or examples of how I can read the analog inputs in LD or FBD that I can copy or modify to get me started?
Reply 0 0
Raj Iyer
You have to connect the Raspberry-Pi to the Nano on a modbus -serial link. The Nano has to be a modbus-RTU slave.  If you look in the Arduino -Nano section there is a version of the OpenPLC runtime that configures the Nano as a remote slave so as to extend the IOs of the R-pi., . There, on the Pi, you'll have to put the OpenPLC Runtime for writing your logic.
 
Here, the modbus registers have a fixed space of 100 words for each slave. I think the Slave no. 1's analog inputs will be from Modbus Registers 30101, and so also the 1st slave's analog outputs will start from 40101. In a similar way the AIs/AOs of the Slave-no 2 has fixed addresses starting from 30201 & 40201 respectively. Kindly see the forum for "Modbus"
Raj
Reply 0 0
Raj Iyer
Thiagor Alves has himself explained how to do this on the OPenPLC YouTube Channel  https://www.youtube.com/watch?v=dQ8GcfpGDuA
Raj
Reply 1 0
GregC
Thanks for that RaJ. I worked out all I had to do was to create a variable without even having to add it into a ladder program and it shows up Raspberry Pi Runtime and reads the analog input as raw data.
 
I've programed in ladder and FBD in the past with Schnieder PLC's but only ever with digital so this is a good learning curve for me with analog inputs and a new program.
 
I have now wired a pot to the Arduino Nano A0 which controls the relays on a two RS485 relay boards which are connected to the Raspberry Pi. As I turn the pot the relays turn on and off, so now I'm making some progress.
 
[203128%2F8753264%2Fmceclip0]
Reply 0 0
Reply