ir monitor via parallel port.

The figure shows a schematic of the IR receiver circuit. The heart of the circuit is MOD1, an infrared detector module that removes the IR carrier frequency and transmits only the data that are encoded in the received IR signal. A suitable IR module is available at Radio Shack (No. 276-137 which is no longer sold). Might try Model: 276-640, but check the specs for sure. You probably could pull one from an old vcr.  The IR module needs a clean 5-V power supply, which is provided by IC1, a 7805 regulator. Power is supplied to the regulator by 9-V battery B1. The output of the module is wired to a male DB-25 multipin connector. The infrared detector module receives a signal, filters it, and removes the 40-kHz carrier. The output of the module is a TTL-level signal consisting of long and short pulses. The PC records those voltage levels over time, while the signal is being sent, and stores the data in a file. The line normally used by the PC's printer port to indicate that the printer is out of paper (pin 12) is used in this project to accept data from the IR module. The I/O port is located at the address ox379. Bit 5 corresponds to input pin 12. Various software programs are required to let a PC store information input to its printer port.  The program stores the value it reads from the PC's printer port into an array. When the input line is logic high, the ASCII character 1 is stored in the array. When the input line is logic low, ASCII character 0 is stored.

untested.
 '**************************************************************************
'* Program title  : Arco.bas
'* Date written   : original c code in 1994
'* Last Update    : August 1995
'* Language       : Basic
'* Written by     : eddie  from Barry Hamilton's c code (C) 1994
'*                  in the Electonics Now - August 1995 issue
'* Written for    : Barry Hamilton and Electronics Now
'* Program intent : Monitor's out of paper input
'* I/O and files  : Pin 12 of the parallel printer port
'*                  irlog.raw
'*                  irlog.gph
'*                  irlog.fnl
'*-------------------------------------------------------------------------

'--------------------------------------------------------------------------
DEFINT A-Z
Zero = 0
One = 1
Two = 2
Fpin = One
Fpout = Two
Inchar = Zero
Lastchar = Zero
Totalcnt = Zero
Limit = 30000
DIM Store(Limit)
CONST The.Title = "Printer port pin 12 project"

ON ERROR GOTO Error.line
DO
    CLS
    PRINT
    PRINT The.Title + "."
    PRINT
    PRINT "   A - Get data"
    PRINT "   C - Convert data"
    PRINT "   R - Report data"
    PRINT "   Q - Quit"
    PRINT
    PRINT "choice: ";
    z$ = " "
    DO WHILE INSTR("ACRQ", z$) < 1
        z$ = ""
        DO WHILE z$ = ""
            z$ = UCASE$(INPUT$(1))
        LOOP
    LOOP
    PRINT z$
    SELECT CASE z$
        CASE "A"
            GOSUB Dget
        CASE "C"
            GOSUB Dconvert
        CASE "R"
            GOSUB Dreport
        CASE "Q"
            EXIT DO
        CASE ELSE
            REM
    END SELECT
LOOP
PRINT
PRINT "The end!"
END

'--------------------------------------------------------------------------
Dget:
    Timedelay = Zero
    Sloop = One
    Skey = Zero
    Cntr1 = Zero
    Cntr2 = Zero
    Cindata = Zero
    Fpout$ = ""
    Escape.key = 27
    CLS
    PRINT
    PRINT The.Title + ": I/R Get."
    PRINT
    INPUT "Enter time delay  : ", Timedelay
    IF Timedelay < Zero THEN
        Timedelay = 20
    END IF
    INPUT "      outfile name: ", Fpout$
    IF LCASE$(Fpout$) = "" THEN
        Fpout$ = "irlog.raw"
    END IF
    PRINT
    PRINT "Opening "; LCASE$(Fpout$); " for output."
    OPEN Fpout$ FOR OUTPUT AS #Fpout
    PRINT "Gathering data with a time delay of "; LTRIM$(RTRIM$(STR$(Timedelay))); "."
    DO WHILE Sloop = One
        PRINT TAB(5); "Start: "; TIME$
        FOR Cntr1 = Zero TO Limit - One
            Cindata = INP(&H379)
            IF (Cindata AND 32) <> Zero THEN
                Store(Cntr1) = ASC("1")
            ELSE
                Store(Cntr1) = ASC("0")
            END IF
            FOR Cntr2 = One TO Timedelay
            NEXT Cntr2
        NEXT Cntr1
        PRINT TAB(5); "Ending: "; TIME$
        PRINT "Writing data to "; LCASE$(Fpout$); "."
        PRINT #Fpout, "[";
        FOR Cntr1 = Zero TO Limit - One
            PRINT #Fpout, CHR$(Store(Cntr1));
        NEXT Cntr1
        PRINT #Fpout, "]";
        PRINT "Press escape to quit and any other key to continue";
        PRINT ":"
        BEEP
        Skey = ASC(INPUT$(One))
        IF Skey = Escape.key THEN
            EXIT DO
        END IF
    LOOP
    PRINT "Closing "; LCASE$(Fpout$); "."
    CLOSE #Fpout
RETURN

'--------------------------------------------------------------------------
Dconvert:
    Fpin$ = ""
    Fpout$ = ""
    Nlimit = 80
    S2$ = ""
    One$ = STRING$(9, "1")
    Zero$ = STRING$(9, "0")
    S11$ = ""
    S10$ = ""
    FOR Cntr = One TO Eight
        S11$ = S11$ + One$ + "+"
        S10$ = S10$ + Zero$ + "+"
    NEXT Cntr
    CLS
    PRINT
    PRINT The.Title + ": I/R Graph."
    PRINT
    INPUT "Enter name of infile : ", Fpin$
    IF Fpin$ = "" THEN
        Fpin$ = "irlog.raw"
    END IF
    INPUT "              outfile: ", Fpout$
    IF Fpout$ = "" THEN
        Fpout$ = "irlog.gph"
    END IF
    PRINT
    PRINT "Opening file: "; Fpin$; " for input."
    OPEN Fpin$ FOR INPUT AS #Fpin
    PRINT "Opening file: "; Fpout$; "for output."
    OPEN Fpout$ FOR OUTPUT AS #Fpout
    PRINT
    Zline = CSRLIN
    DO WHILE NOT EOF(Fpin)
        Inchar = ASC(INPUT$(1, #Fpin))
        LOCATE Zline, One
        PRINT "Examining: "; CHR$(Inchar);
        IF Inchar = ASC("0") AND Lastchar = ASC("0") THEN
            Totalcnt = Totalcnt + One
        END IF
        IF Inchar = ASC("1") AND Lastchar = ASC("1") THEN
            Totalcnt = Totalcnt + One
        END IF
        IF Lastchar = ASC("[") THEN
            Totalcnt = One
        END IF
        IF Lastchar = ASC("]") THEN
            Totalcnt = Zero
        END IF
        IF Inchar = ASC("0") AND Lastchar = ASC("1") THEN
            IF Totalcnt < Nlimit THEN
                S2$ = ""
                S2$ = LEFT$(S2$ + S11$, Totalcnt)
                PRINT #Fpout, S2$
            ELSE
                PRINT #Fpout, "        | ";
                PRINT #Fpout, USING "####"; Totalcnt;
                PRINT #Fpout, "1"
            END IF
            Totalcnt = One
        END IF
        IF Inchar = ASC("1") AND Lastchar = ASC("0") THEN
            IF Totalcnt < Nlimit THEN
                S2$ = ""
                S2$ = LEFT$(S2$ + S10$, Totalcnt)
                PRINT #Fpout, S2$
            ELSE
                PRINT #Fpout, "        | ";
                PRINT #Fpout, USING "####"; Totalcnt;
                PRINT #Fpout, "0"
            END IF
            Totalcnt = One
        END IF
        IF Inchar = ASC("]") AND Lastchar = ASC("0") THEN
            IF Totalcnt < Nlimit THEN
                S2$ = ""
                S2$ = LEFT$(S2$ + S10$, Totalcnt)
                PRINT #Fpout, S2$
            ELSE
                PRINT #Fpout, "        | ";
                PRINT #Fpout, USING "####"; Totalcnt;
                PRINT #Fpout, "0"
            END IF
            Totalcnt = Zero
        END IF
        IF Inchar = ASC("]") AND Lastchar = ASC("1") THEN
            IF Totalcnt < Nlimit THEN
                S2$ = ""
                S2$ = LEFT$(S2$ + S11$, Totalcnt)
                PRINT #Fpout, S2$
            ELSE
                PRINT #Fpout, "        | ";
                PRINT #Fpout, USING "####"; Totalcnt;
                PRINT #Fpout, "1"
            END IF
            Totalcnt = Zero
        END IF
        Lastchar = Inchar
    LOOP
    PRINT
    PRINT "Closing "; LCASE$(Fpout$); "."
    CLOSE #Fpout
    PRINT "Closing "; LCASE$(Fpin$); "."
    CLOSE #Fpin
RETURN

'--------------------------------------------------------------------------
Dreport:
    Cmark = One
    Cspace = Zero
    Maxzero = Zero
    Maxone = Zero
    Syncstate = Zero
    Fpin$ = ""
    Fpout$ = ""
    CLS
    PRINT
    PRINT The.Title + ": I/R Final."
    PRINT
    PRINT "(M)ark or (S)pace Sync: ";
    z$ = " "
    DO WHILE INSTR("MS", z$) < 1
        z$ = ""
        DO WHILE z$ = ""
            z$ = UCASE$(INPUT$(1))
        LOOP
    LOOP
    PRINT z$
    SELECT CASE z$
        CASE "M"
            Syncstate = Mark
        CASE "S"
            Synstate = Space
    END SELECT
    INPUT "Enter the maxzero factor : ", Maxzero
    INPUT "      the maxone  factor : ", Maxone
    INPUT "      the file for input : ", Fpin$
    IF Fpin$ = "" THEN
        Fpin$ = "irlog.raw"
    END IF
    INPUT "      the file for output: ", Fpout$
    IF Fpout$ = "" THEN
        Fpout$ = "irlog.fnl"
    END IF
    PRINT
    OPEN Fpin$ FOR INPUT AS #Fpin
    PRINT "Opening file: "; Fpin$; " for input."
    OPEN Fpout$ FOR OUTPUT AS #Fpout
    PRINT "Opening file: "; Fpout$; " for output."
    PRINT
    Zline = CSRLIN
    DO WHILE NOT EOF(Fpin)
        Inchar = ASC(INPUT$(One, #Fpin))
        LOCATE Zline, One
        PRINT "Examining: "; CHR$(Inchar);
        IF Inchar = ASC("0") AND Lastchar = ASC("0") THEN
            Totalcnt = Totalcnt + One
        END IF
        IF Inchar = ASC("1") AND Lastchar = ASC("1") THEN
            Totalcnt = Totalcnt + One
        END IF
        IF Lastchar = ASC("[") THEN
            Totalcnt = One
        END IF
        IF Lastchar = ASC("]") THEN
            Totalcnt = Zero
        END IF
        IF Inchar = ASC("0") AND Lastchar = ASC("1") THEN
            IF Syncstate = Space THEN
                IF Totalcnt <= Maxzero THEN
                    PRINT #Fpout, "0";
                END IF
                IF Totalcnt > Maxzero AND Totalcnt < Maxone THEN
                    PRINT #Fpout, "1";
                END IF
                IF Totalcnt >= Maxone THEN
                    PRINT #Fpout, "        | ";
                    PRINT #Fpout, USING "####"; Totalcnt;
                    PRINT #Fpout, "1="
                END IF
             END IF
             Totalcnt = One
        END IF
        IF Inchar = ASC("1") AND Lastchar = ASC("0") THEN
            IF Syncstate = Mark THEN
                IF Totalcnt <= Maxzero THEN
                    PRINT #Fpout, "0";
                END IF
                IF Totalcnt > Maxzero AND Totalcnt < Maxone THEN
                    PRINT #Fpout, "1";
                END IF
                IF Totalcnt >= Maxone THEN
                    PRINT #Fpout, "        | ";
                    PRINT #Fpout, USING "####"; Totalcnt;
                    PRINT #Fpout, "0="
                END IF
             END IF
             Totalcnt = One
        END IF
        IF Inchar = ASC("]") AND Lastchar = ASC("0") THEN
            PRINT #Fpout, "        | ";
            PRINT #Fpout, USING "####"; Totalcnt;
            PRINT #Fpout, "0]"
            Totalcnt = Zero
        END IF
        IF Inchar = ASC("]") AND Lastchar = ASC("1") THEN
            PRINT #Fpout, "        | ";
            PRINT #Fpout, USING "####"; Totalcnt;
            PRINT #Fpout, "1]"
            Totalcnt = Zero
        END IF
        Lastchar = Inchar
    LOOP
    PRINT
    PRINT "Closing "; LCASE$(Fpout$); "."
    CLOSE #Fpout
    PRINT "Closing "; LCASE$(Fpin$); "."
    CLOSE #Fpin
RETURN

'--------------------------------------------------------------------------
Error.line:
    END
'*******************************************************

Comments

Popular posts from this blog

Guiless?

Web.com and Network Solutions, the Walmart of the internet.

MSOffice vs Libreoffice