dorma
First of all, I'm very happy to study for OpenPLC with M-Duino21(Arduino Mega 2560 based) Kit.
 
I want to get the sensor value from the OpenPLC Ladder Logic for my first project.
 
Using M-Duino21, I have wired MQ-135 sensor to %IW4 pin(A4 pin on Arduino Mega 2560) and I tried to get the sensor value from serial output port.
 
By Arduino IDE, It was succesfully done.
 
So now, I want to use the OpenPLC for the same operation, But it is little bit hard for me.
 
Is there any Ladder Logic example for above task?
 
Thank you so much.
Reply 0 0
thiagoralves
  1. Create a variable located at %IW4. This variable will automatically contain the value read from the analog input scaled to 16-bit (0-65535)
  2. Write any logic for that measurement. Something as simple as putting a GT block to compare the variable with a constant to turn a LED on would work
  3. Enable Modbus RTU on the upload dialog and upload your code to the Arduino board
  4. Launch the debugger (blue bug icon on the toolbar), connect to the board over serial and then launch the debug instance by clicking on the glasses at the left panel
  5. You will be able to see the measurements in your %IW4 variable in real time on the debugger
Reply 0 0
dorma
 
Thank you so much for your response! 🙂
I got the real time sensor value from the debugger like the below picture.
[203128%2F8973533%2Fmceclip0]
 
So, I want to go to the next step, which is getting sensor value by another node (e.g., server connected with M-duino 21)
 
Is there any way to send the sensor value through outside of M-duino21 ?
 
If I want to put the Function block to send the sensor value, which block can be used ? (instead of blink_led block in above picture)
 
Thank you for your help.
Reply 0 0
thiagoralves
OpenPLC talks Modbus, so anything that can talk Modbus can be used to read the sensor value. Since you placed it on a %IW4 location, this value is available on Modbus Input Register 4 (see mapping table here: https://autonomylogic.com/docs/2-5-modbus-addressing/ )
Reply 0 0
Reply