Show pageOld revisionsBacklinksBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ==== Opto-isolator inputs configuration ==== File ''/etc/rc.local'' Edit the file with this command (Inserted at the end of the file just BEFORE ''exit 0'' ) <code bash> sudo nano /etc/rc.local </code> <code bash> #INPUTS echo "24" > /sys/class/gpio/export & sleep 2 echo in > /sys/class/gpio/gpio24/direction echo "25" > /sys/class/gpio/export & sleep 2 echo in > /sys/class/gpio/gpio25/direction echo "26" > /sys/class/gpio/export & sleep 2 echo in > /sys/class/gpio/gpio26/direction echo "27" > /sys/class/gpio/export & sleep 2 echo in > /sys/class/gpio/gpio27/direction </code> ==== Tests of opto-isolator inputs ==== <note important> {{ :documents:optoinputs.jpg?nolink&200|}} :!: __For SVXCard version 1.0 (2015) :__ The ground at the input of the optocoupler is not connected to the ground of the main board. So you need to power your inputs with an external power (outside the main board). So you MUST IMPERATIVELY connect your input on a pin that is not at + 5V (board). ---- A second way is to use the distributed +5V to feed the external contact. In this case, it will be necessary to link pine 9 or 10 of connectors J26 (screenprinting OPTO INPUTS) with the mass plan. In this case, the opto-isolation is not operational because the power supply comes from the card. </note> The following python code allows you to check the states of each of the 4 inputs. <code bash> sudo nano test-input.py </code> <code python | test-inputs.py> #!/usr/bin/python import time from RPi import GPIO GPIO.setmode(GPIO.BOARD) GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) GPIO.setup(22, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) GPIO.setup(37, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) GPIO.setup(13, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) while True: inputval1 = GPIO.input(18) inputval2 = GPIO.input(22) inputval3 = GPIO.input(37) inputval4 = GPIO.input(13) print "INPUT1="+str(inputval1) + ",INPUT2="+str(inputval2) + ",INPUT3="+str(inputval3) + ",INPUT4="+str(inputval4) time.sleep(1) </code> The tests will be launch with this command <code bash> sudo python test-input.py </code> Here are the results of the tests for the channels 1 to 4. {{ :documents:test-inputs.gif?nolink |}} CTRL-C to exit en/essais_des_entrees_optocouplees.txt Last modified: 2020/07/05 17:13(external edit)