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
What's the difference between different types of IO type?
Moderator: RevPiModIO
-
- Posts: 7
- Joined: 17 Oct 2018, 09:29
Re: What's the difference between different types of IO type?
I have moved your post to the RevPiModIO board.
- RevPiModIO
- KUNBUS
- Posts: 335
- Joined: 20 Jan 2017, 08:44
- Contact:
Re: What's the difference between different types of IO type?
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:
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!
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:
Regards, Sven
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:
Code: Select all
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!
Code: Select all
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:
Code: Select all
# 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...
python3-RevPiModIO - https://revpimodio.org/ || Der RevPi ist das Beste, was passieren konnte!