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:
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...
Regards, Sven