Hello,
I just recently bought a RpiPLC 58+ with 16 analog inputs. And I am fighting with two problems.
1. When I'm trying to read an analog inputs from python code, using your python examples from GitHub (https://github.com/Industrial-Shields/rpiplc-python3-lib), it return me an error like this:
pi@raspberrypi:~/rpiplc-python3-lib $ python3 test1.py
i2c_write: Remote I/O error
i2c_write: invalid len (4294967295 != 3)
The I0.12 is reading : 0
And the sample code which I ran is this:
from rpiplc_lib import rpiplc
def digitalreadwrite():
rpiplc.pin_mode("Q0.0", 1)
rpiplc.digital_write("Q0.0", rpiplc.HIGH)
rpiplc.delay(1000)
rpiplc.digital_write("Q0.0", rpiplc.LOW)
rpiplc.delay(1000)
def analogreadwrite():
rpiplc.pin_mode("I0.12", rpiplc.INPUT)
read_value = rpiplc.analog_read("I0.12")
print("The I0.12 is reading : ", read_value)
def main():
rpiplc.init("RPIPLC_58")
while True:
digitalreadwrite()
analogreadwrite()
if __name__ == "__main__":
main()
If I am missing something please help me!
Another problem is about digital outputs setting, when I run the same code as above, and the command is to turn on the Q0.0 output, strangely it turn on the Q2.2 output, and this "rule" is available for all the outputs, I mean none of the outputs are synchronize with python scripts.
Again, if I'm missing something, please give me some hints.
Have a nice day!
I have the same problem.
Sadly it seems these raspberry PLC libraries are not working very well.
I also notice the analog write functions are doing nothing to the analog outputs. (no error though, just no change in the analog outputs)
Very dissapointing.
Update: I tried reading from the analog inputs using node red following this tutorial:
https://www.industrialshields.com/blog/raspberry-pi-for-industry-26/using-a-python-script-in-node-red-to-control-a-raspberry-plc-494
the tutorial appears to work, but the analog read always returns 0.
I have connected a 5V signal from the canbus connector to the analog input and the corresponding light on top goes on when I connect it which shows that the input is receiving 5V. So it appears to be a software issue with whatever library is used to interface with the analog input IC?