openSteff
Hallo zusammen,
ich möchte einen Analogwert mit dem Raspberry Pi und der Analogkarte KY-053 auslesen. Dafür nutze ich ein Python-Skript, das den Wert ausliest und in das Holding Register 100 schreibt. Mit dem Tool Radzio kann ich bestätigen, dass der Wert korrekt im Register ankommt.
Wenn ich in OpenPLC einen Slave Device mit der passenden IP-Adresse anlege, funktioniert die Kommunikation auch. Das Problem ist jedoch, dass nach dem Übertragen des Programms aus dem OpenPLC Editor und dem Start im OpenPLC Webinterface der Wert im Monitoring nicht angezeigt wird.
Kann mir jemand sagen, ob ich auf dem richtigen Weg bin? Und wie ich den analogen Wert korrekt in OpenPLC bekomme, um ihn dort weiterverarbeiten zu können?
In der angehängten PDF findet ihr meine bisherigen Schritte.
 
Hello everyone,
I want to read an analog value using a Raspberry Pi and the KY-053 analog board. For this, I use a Python script that reads the value and writes it into holding register 100. I can verify with the tool Radzio that the value is correctly written to the register.
When I create a slave device in OpenPLC with the correct IP address, the communication works. However, the problem is that after uploading the program from the OpenPLC Editor and starting it via the OpenPLC web interface, the value is not shown in the monitoring.
Can someone tell me if I am on the right track? And how can I get the analog value into OpenPLC so I can process it there?
You can find my current steps in the attached PDF.
Reply 0 0
thiagoralves
You don't have to add a slave device because there is no slave to be added in the first place. From your Python code, it seems that you're trying to write directly to OpenPLC runtime, which is fine. If you're writing to holding register 100, then you will capture it on the OpenPLC side at %QW100, not %MW100. Check the Modbus addressing table here for more information: https://autonomylogic.com/docs/2-5-modbus-addressing/
Reply 0 0
openSteff
Thank you for your answer. I’m glad that it now works with %QW100. Thanks!

However, I have another problem: it only works with the hardware option "Blank Layer Linux."
The LED connected to %QX0.0 (GPIO14) does not turn on—it stays off.

Is there a problem with the GPIOs when using the Linux hardware layer?
I suspect there is a conflict between my script and OpenPLC with the Raspberry Pi hardware configuration when both try to use the I2C device.
I tested the Raspberry Pi hardware configuration with only the LED on %QX0.0, and it lit up correctly.

Reply 0 0
thiagoralves
The GPIOs on the Pi will only work if you use the Raspberry Pi driver (hardware layer).
Reply 0 0
zoujy
The GPIOs on the Pi will only work if you use the Raspberry Pi driver (hardware layer).
Also Now easily configure by python-gpio
Reply 0 0
Reply