Moderator: miprotek

 
yushengzhou
Topic Author
Posts: 4
Joined: 17 Oct 2018, 09:29

What's the difference between different types of IO type?

18 Oct 2018, 10:43

hello veryone
What's the difference between different types of IO type(200=INP, 301=OUT, 302=MEM)?
Why can I use "revpi.io.I_1.value = 1" to set the value of "I_1" but not "revpi.io. OutputPWMActive.value = 30" to set the value of "OutputPWMActive"?


I love you all :) :) :) :)
 
User avatar
dirk
Posts: 119
Joined: 15 Dec 2016, 13:19

Re: What's the difference between different types of IO type?

18 Oct 2018, 10:47

I have moved your post to the RevPiModIO board.
 
User avatar
miprotek
Posts: 150
Joined: 20 Jan 2017, 08:44
Contact:

Re: What's the difference between different types of IO type?

18 Oct 2018, 16:08

Hi yushengzhou!

The IO type(200=INP, 301=OUT, 302=MEM) are used internal in the RevPiModIO library to identify the IO Type.

If you can WRITE to an input without an exception on the RevPi, you maybe used RevPiModIODriver() - which you should not do on a RevPi!

So, please use RevPiModIO to instantiate your RevPi in Python:
import revpimodio2
rpi = revpimodio2.RevPiModIO(autorefresh=True)

If you do so, you are able to write values for outputs and will get an exception, if you try to write to inputs - which is the right behavior!
rpi.io.O_3.value
False
rpi.io.O_3.value = True
rpi.io.O_3.value
True
rpi.io.I_4.value
False
rpi.io.I_4.value = True
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/revpimodio2/io.py", line 616, in set_value
    "can not write to input '{0}'".format(self._name)
AttributeError: can not write to input 'I_4'

If you like to use the PWM, you have to configure the Memory "OutputPWMActive" in piCtory (!), to activate the PWM function! To use Output 1 as PWM Output, set MEM: "OutputPWMActive" to 1, "Save as Start-Config." and Reset Driver!

After that, you can set the the PWM_1 output with you Python program and control the frequency:
# Max
rpi.io.PWM_1.value = 255
# Off
rpi.io.PWM_1.value = 0
# Very low
rpi.io.PWM_1.value = 1
# Something else :D
rpi.io.PWM_1.value = 100
# And so on...
Regards, Sven
python3-RevPiModIO - https://revpimodio.org/ || Supported by miprotek GmbH - http://www.miprotek.de || Der RevPi ist das Beste, was passieren konnte!

Who is online

Users browsing this forum: No registered users and 1 guest