Forum Controllers/PLC

Welcome!

This community is for professionals and enthusiasts of our products and services. Share and discuss the best content and new marketing ideas, build your professional profile and become a better marketer together.

0

Reading analog inputs error and abnormal write digital outputs python scripts issues!!!

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!

2 Comments
Avatar
Discard
Avatar
FrozenBubble
-

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.

Avatar
FrozenBubble
-

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?

1 Answer
0
Avatar
Quesada Dani Salvans
Best Answer

Dear clients,

I am Dani from Industrial Shields Technical Department and I will try to solve all your doubts.
-Are you powering the PLC with a 12/24Vdc power supply?
-Have you followed all the steps installing the library shown on the repository?:
https://github.com/Industrial-Shields/rpiplc-python3-lib
-Take into account that if you have RPI PLC v3 you should install the Version 1 of the library    
and if you have the RPI PLC v4 you should install the version 2 of the library. Can you tell me please the S/N (lot) number of your device -> You can see it on its top serigraphy. 
-Respect to the outputs, are you connecting the GND of the analog output block with the actuator GND
that you are using or a reference ground when measuring the voltage?

Thank you, 

Avatar
Discard