Using legacy ports.

No-solder-parallel-port-break-out (Great for home control)
We are going to take the parallel port breakout cable and have some fun with the following code (which I may rewrite) and use some extra parts.
Part 1 C code
Code source
Note asm/io.h s/b sys/io.h in parcon.c
Part II Basic code:
Freebasic: (code snippet) (Note: Compiled code on linux must be run under sudo or root unless special rights are given to the program via chmod +s.)
1
2
3
4
5
6
7
8
| rem turn on D0 (pin 2 on the parallel port)out 888,1rem get status and print to terminal? inp(888)rem turn off D0 (pin 2 on the parallel port)out 888,0rem get status? inp(888) |
Circuit for testing the code. With the cable it will be easier to set up.

Simple LED driving circuits
You can make simple circuit for driving a small led through PC parallel port. The only components needed are one LED and one 470 ohm resistors. You simply connect the diode and resistor in series. The resistors is needed to limit the current taken from parallel port to a value which light up acceptably normal LEDs and is still safe value (not overloading the parallel port chip). In practical case the output current will be few milliamperes for the LED, which will cause a typical LED to somewhat light up visibly, but not get the full brightness.
LED and resistor
For reference purposes:
http://www.epanorama.net/circuits/parallel_output.html
==========================================
Other interesting info:
The joystick port can be also used too to collect data as we did here. We did not have a case to mount the parts so we just used an old particle board to act as a base and we have an altered plastic case for the emi and etc protection.

REM ***************************************************************REM * program: doorchek.basREM * purpose check value of joystick port connected to doorREM * last update 02/04/1994REM * Copyright (c) 1994 - 2010 CarbomanREM * All rights reserved.REM *REM ---------------------------------------------------------------REM mainlineREMGOSUB housekeepingWHILE TRUE%GOSUB dothedoorWENDGOSUB endofjobENDREM ---------------------------------------------------------------REM housekeepinghousekeeping:REM ........................................REM basic variables and flag settingsOLDFLAG = 0REM screentype% = 1 is 40 columns and 0 is 80 columns.screentype% = 0startflag = 0TRUE% = -1q$ = CHR$(34)KEY OFFSCREEN screentype%CLSREM .........................................REM give time before alarm system is set to evacuateFOR click = 1 TO 5000: NEXT clickREM .........................................REM headerPRINTtitle$ = " Door switch recording system"center = (W - LEN(title$)) / 2PRINT TAB(center); title$REM ..........................................REM set datafile name to date and timenowdate$ = LEFT$(DATE$, 2) + MID$(DATE$, 4, 2) + RIGHT$(DATE$, 2)nowtime$ = LEFT$(TIME$, 2) + "." + MID$(TIME$, 4, 2)nameoffile$ = nowdate$ + nowtime$REM ...........................................REM record starting time in file and on screenfileaccess$ = "O"doordid$ = "S"GOSUB dofilePRINTPRINT " Started at: "; TIME$; " on "; DATE$; "."REM ............................................REM set further file writing to appendfileaccess$ = "A"REM ............................................REM hold header and start time on screenVIEW PRINT 6 TO 24RETURNREM ---------------------------------------------------------------REM do the doorREMdothedoor:GOSUB getdoordataGOSUB reportdoordataGOSUB checkdearmRETURNREM ---------------------------------------------------------------REM check to system if de-armedcheckdearm:IF STRIG(3) THEN TRUE% = 0RETURNREM ---------------------------------------------------------------REM end of jobREMendofjob:doordid$ = "E"GOSUB dofilePRINTPRINT " System down at: "; TIME$; " on "; DATE$; "."VIEW PRINTRETURNREM ---------------------------------------------------------------REM get data from doorREMgetdoordata:r = STRIG(1)SELECT CASE r CASE -1 flag = 1 CASE 0 flag = 2 CASE ELSE GOSUB errornoticeEND SELECTRETURNREM ---------------------------------------------------------------REM report data from doorREMreportdoordata:SELECT CASE flag CASE OLDFLAG RETURN CASE 1 GOSUB doorclosed CASE 2 GOSUB dooropened CASE ELSE GOSUB errornoticeEND SELECTOLDFLAG = flagRETURNREM ---------------------------------------------------------------REM door closedREMdoorclosed:IF startflag = 0 THEN startflag = 1ELSE doordid$ = "C" GOSUB dofile PRINT " Door closed at: "; TIME$; " on "; DATE$; "."END IFRETURNREM ---------------------------------------------------------------REM door openedREMdooropened:doordid$ = "O"GOSUB dofilePRINT " Door opened at: "; TIME$; " on "; DATE$; "."GOSUB doalarmRETURNREM --------------------------------------------------------------REM sound alarmdoalarm:GOSUB domusicREM gosub domodemREM gosub dotalkRETURNREM --------------------------------------------------------------REM play music (make up your own tune if you wish.)REMdomusic:PLAY "mbcdeccdecdeffdeffgagfecgagfecc<b>cc"RETURNREM ---------------------------------------------------------------REM do the modem thingREMdomodem:OPEN "com1:1200,n,8,1" FOR RANDOM AS #2PRINT #2, "ATDT1234567;"FOR clickon = 1 TO 10000: NEXT clickonPRINT #2, "DT121212121212121212121212121212121212121212121212121212121"FOR clickoff = 1 TO 10000: NEXT clickoffCLOSE #2RETURNREM ------------------------------------------------------------------REM do the file thingREMdofile:OPEN fileaccess$, #1, nameoffile$PRINT #1, q$; doordid$; q$; ","; q$; TIME$; q$; ","; q$; DATE$; q$CLOSE #1RETURNREM ------------------------------------------------------------------REM error noticeREMerrornotice:VIEW PRINTCLSPRINTPRINTPRINT " Error occurred, Warn supervisor NOW!"RETURNREM ------------------------------------------------------------------REM * program: doorchek.basREM * purpose check value of joystick port connected to doorREM * last update 02/04/1994REM * Copyright (c) 1994 CarbomanREM * All rights reserved.REM *REM *******************************************************************REM -------------------------------------------------------------REM TALK MESSAGE (requires external program!)REMREM dotalkthing:REM FOR Xit = 1 TO 3REM talkmessage:REM SHELL "say W-AH-R-N-IH-N-G, tz-eh-r ih-s ah-n IH-N-T-R-UH-D-R"REM NEXT XitRETURN |

Comments
Post a Comment