A 5 in 16 out Issue 2 Board Interface for the Raspberry PI
|
|
The
circuit diagram is on the right. In this particular design I have used three ULN 2803 chips. The inputs are inverting, i.e. they are connected via a 10k resistor to the 3.3V line. Closing a switch takes this line down to 0V. Connection to the GPIO pins is done via a 1k resistor, which should protect the pins if they happen to be assigned as outputs rather than inputs. The outputs can sink up to 0.5A at 30V, though without heat sinks the 0.5A value may be slightly optimistic. Anything connected to the outputs must also supply a 0V line as well as the 'Clamp' voltage, which is a connection to the positive power line supplying the connected board. The interface seems to work very well and so far I have had no problems with it. |
|
The shot on the left shows the interface connected to the Pi as well as a 5 switch input unit and a 16 LED output board. The main GPIO connector cable has been removed so that the extra 4 line GPIO cable can be seen. P5 is supposed to be accessed from the bottom of the Pi's pcb, but this means that the little computer cannot be put into a case. I soldered the wires in from the top side and secured them with a dab of glue from a hot glue gun. The arrangement performed satisfactorily. The pcb layout is shown on the right. Below is a link to the pcb layout in the form of a zip archive containing a Xara .wmf file as well as the original drawfile for RISCOS users. The wmf file can be read by many programs and should provide a good quality printout. 5x16-interface Here is a link to the archive containing the little test program below: Test_in_out.zip There is also a YouTube video demo
10 REM Test_in_out 20 REM Test 16*LED board with Interface Mark 2 and Interface bard 5x16 30 REM Jochen Lueg 40 REM 18th December 2012 50 REM http://roevalley.com 60 70 ON ERROR PRINT REPORT$;" at line ";ERL:END 80 90 PROCinit 100 110 PRINT "Press any of the five switches for a different pattern" 120 FOR Loop% = 1 TO 3 130 FOR J% = 0 TO 15 140 SYS "GPIO_WriteData",Out%(J%),1 150 NEXT 160 TIME=0:REPEAT UNTIL TIME > 50 170 FOR J% = 0 TO 15 180 SYS "GPIO_WriteData",Out%(J%),0 190 NEXT 200 TIME=0: REPEAT UNTIL TIME >30 210 NEXT 220 230 C%=0:Switch%=99 240 250 REPEAT 260 REM Scan the switches 270 REPEAT 280 SYS"GPIO_ReadData",In%(C%) TO S%:IF S%=1 Switch%=C% 290 C%+=1 300 UNTIL S%=1 OR C%>4 310 IF Switch%=0 PROCwalk_up:Switch%=99 320 IF Switch%=1 PROCwalk_down:Switch%=99 330 IF Switch%=2 PROCwalk_up_and_down:Switch%=99 340 IF Switch%=3 PROCflash_LEDs:Switch%=99 350 IF Switch%=4 PROCwalk_very_fast:Switch%=99 360 C%=0 370 UNTIL FALSE 380 PRINT "This program has been terminated" 390 STOP 400 410 420 DEFPROCwalk_up_and_down 430 LOCAL J% 440 FOR I%=1 TO 3 450 FOR J%= 0 TO 15 460 SYS "GPIO_WriteData",Out%(J%),1 470 TIME=0:REPEAT UNTIL TIME>2 480 SYS"GPIO_WriteData",Out%(J%),0 490 NEXT 500 510 FOR J%= 15 TO 0 STEP-1 520 SYS "GPIO_WriteData",Out%(J%),1 530 TIME=0:REPEAT UNTIL TIME>2 540 SYS"GPIO_WriteData",Out%(J%),0 550 NEXT 560 NEXT 570 ENDPROC 580 590 600 DEFPROCwalk_up 610 LOCAL J%,I% 620 FOR I%=1 TO4 630 FOR J%= 0 TO 15 640 SYS "GPIO_WriteData",Out%(J%),1 650 TIME=0:REPEAT UNTIL TIME>5 660 SYS"GPIO_WriteData",Out%(J%),0 670 NEXT 680 NEXT 690 ENDPROC 700 710 720 DEFPROCwalk_down 730 LOCAL J%,I% 740 FOR I%=1 TO4 750 FOR J%= 15 TO 0 STEP -1 760 SYS "GPIO_WriteData",Out%(J%),1 770 TIME=0:REPEAT UNTIL TIME>5 780 SYS"GPIO_WriteData",Out%(J%),0 790 NEXT 800 NEXT 820 ENDPROC 830 840 850 DEFPROCflash_LEDs 860 FOR Loop% = 1 TO 3 870 FOR J% = 0 TO 15 880 SYS "GPIO_WriteData",Out%(J%),1 890 NEXT 900 TIME=0:REPEAT UNTIL TIME > 30 910 FOR J% = 0 TO 15 920 SYS "GPIO_WriteData",Out%(J%),0 930 NEXT 940 TIME=0: REPEAT UNTIL TIME >30 950 NEXT 960 ENDPROC 970 980 990 DEFPROCwalk_very_fast 1000 FOR I%=1 TO 7 1010 FOR J%= 0 TO 15 1020 SYS "GPIO_WriteData",Out%(J%),1 1030 FOR T%=1 TO 100000:NEXT 1040 SYS"GPIO_WriteData",Out%(J%),0 1050 NEXT 1060 1070 FOR J%= 15 TO 0 STEP-1 1080 SYS "GPIO_WriteData",Out%(J%),1 1090 FOR T%=1 TO 100000:NEXT 1100 SYS"GPIO_WriteData",Out%(J%),0 1110 NEXT 1120 NEXT 1150 ENDPROC 1160 1161 1280 DEFPROCinit 1290 OSCLI"RMEnsure GPIO 0.00 RMLoad GPIO" 1300 OSCLI"RMensure GPIO 0.40 ERROR Please install the GPIO module" 1310 1320 SYS"GPIO_EnableI2C",0 1330 SYS"GPIO_ExpAsGPIO",2 1340 1350 SYS"GPIO_GetBoard" TO PiType% 1360 DIM Out%(15) 1370 REM ISSUE 1 1380 IF PiType%=11 PRINT "This won't work with this Raspberry Pi":STOP 1390 1400 REM ISSUE 2 Interface board 5x16 1410 IF PiType%=12 Out%()=2,3,4,17,27,22,10,9,11,7,8,25,24,23,18,15 1420 1430 REM Set up the otput lines 1440 FOR J%=0 TO 15 1450 SYS"GPIO_WriteMode",Out%(J%),1 1460 NEXT 1470 1480 DIM In%(4) 1490 In%()=14,29,31,30,28 1500 1510 REM set p the input lines 1520 FOR J%=0 TO 4 1530 SYS"GPIO_WriteMode",In%(J%),0 1540 NEXT 1550 1560 ENDPROC
|
| Back to the interface section |
Visit Limavady and
the Roe Valley
|