Shop OBEX P1 Docs P2 Docs Learn Events
Transmitting Infra Red Remote Control TV / DVD signals — Parallax Forums

Transmitting Infra Red Remote Control TV / DVD signals

TheBrainSurgeonTheBrainSurgeon Posts: 1
edited 2007-12-24 19:03 in BASIC Stamp
Hi.

Before saying anything else, I would like to point I am a complete novice.

I can understand that what I have done will probably make any experts cringe.

But nevertheless, it does work and provides the required output.

I needed a set up that would enable me to generate various Infrared transmissions.

The aim was to control various AV equipment such as the TV or DVD recorder.

I fiddled around and learnt the basics of how these things worked.

What I have finally produced is an arrangement that will produce code to control

equipment which makes use of the Panasonic type protocol.

The devices I am controlling (Panasonic) make use of a 48 bit binary number.

I have written a short program in Qbasic, which I have saved as a stand alone .EXE file.

When executed, this Qbasic program asks the user to type in the binary number which eventually

will be transmitted.

This .EXE file then outputs a .BAS file which can be loaded directly into a BS1 STAMP.

The STAMP then switches PIN0 from HI to LOW to provide the required pulsetrain.

The output from PIN0, is then fed directly to the RESET pin on a 555 timer circuit, which

has been tuned to provide an oscillation of 38kHz.

The 555 oscillator output is connected via a transistor to an Infrared LED.

When the PIN0 output is HI it lets the IR LED flash at its required 38kHz frequency.

Once PIN0 goes low, the flashing IR LED is disabled.

Below is a list of code which is the output from my Qbasic stand alone .EXE file.


>>
'remember this is a test
'c:\testfile.bas
'12-24-2007
'The following Binary Number will be transmitted:
'000001111100001111
pins=%00000000
dirs=%00000000
'this part is needed just before the actual data begins
loop:
pause 74: pause 0
pulsout 0,363
pause 1
'this is where the code for pulses really starts
pulsout 0,59
pulsout 0,59
pulsout 0,59
pulsout 0,59
pulsout 0,59
pulsout 0,59: pause 0: pause 0: pause 0
pulsout 0,59: pause 0: pause 0: pause 0
pulsout 0,59: pause 0: pause 0: pause 0
pulsout 0,59: pause 0: pause 0: pause 0
pulsout 0,59: pause 0: pause 0: pause 0
pulsout 0,59
pulsout 0,59
pulsout 0,59
pulsout 0,59
pulsout 0,59: pause 0: pause 0: pause 0
pulsout 0,59: pause 0: pause 0: pause 0
pulsout 0,59: pause 0: pause 0: pause 0
pulsout 0,59: pause 0: pause 0: pause 0
pulsout 0,59
goto loop

'the last "pulsout 0,59" is needed for closure of the preceding BIT. It isn't actually a DATA BIT

'pulsout 0,59: pause 0: pause 0: pause 0
'the batch of instructions in the line above, produces a BIT 1

'pulsout 0,59
'the instruction in the line above, produces a BIT 0

>>

I don't know if this is of any use to anyone, but if anyone wants the .EXE file, just ask.

I would attach it here but the system won't allow it.

Alternatively, if you have access to Qbasic, then here is the code:

>>

'this prog produces a STAMP Basic program, to send a binary number to
'the BASIC STAMP for Infrared transmission
'the data required is thebinarynumber$,the binary number
' PROGNAME$ (8 digit maximum with .bas extension)
' COMMENTS$
'

CLS
PRINT ""
PRINT ""
PRINT ""
GOTO start
fault: CLS : PRINT ""
PRINT " Try again"
PRINT ""
start:
COMMENTS$ = ""
thebinarynumber$ = ""

PRINT " BASIC STAMP PROGRAM GENERATOR for IR Transmission."
PRINT ""
PRINT " Please supply required data."
PRINT ""

INPUT "Enter the Binary Number to be transmitted: ", thebinarynumber$
INPUT "Enter drive, path and filename for output file - maximum 8 digit filename with .bas extension: ", PROGNAME$
OPEN PROGNAME$ FOR OUTPUT AS #1
INPUT "Enter comments: ", COMMENTS$



CLS
PRINT "The following data has been supplied"
PRINT ""
PRINT "Binary Number ="; thebinarynumber$
PRINT ""
PRINT "Program name and path: "; PROGNAME$
PRINT ""
PRINT "Comments: "; COMMENTS$


INPUT "Do you wish to continue? Y/N If N then restart ", CONTINUE$
IF CONTINUE$ <> "y" AND CONTINUE$ <> "Y" THEN GOTO fault
CLS

'
PRINT #1, "'"; COMMENTS$
PRINT #1, "'"; PROGNAME$
PRINT #1, "'"; DATE$
PRINT #1, "'The following Binary Number will be transmitted:"
PRINT #1, "'"; thebinarynumber$
PRINT #1, "pins=%00000000"
PRINT #1, "dirs=%00000000"
PRINT #1, "'this part is needed just before the actual data begins"
PRINT #1, "loop:"
PRINT #1, "pause 74: pause 0"
PRINT #1, "pulsout 0,363"
PRINT #1, "pause 1"
PRINT #1, "'this is where the code for pulses really starts"
'
stringlength = LEN(thebinarynumber$)

FOR n = 1 TO stringlength
digitstore$ = MID$(thebinarynumber$, n, 1)

IF digitstore$ = CHR$(49) THEN GOSUB OUT1 ELSE GOSUB OUT0
NEXT n


PRINT #1, "pulsout 0,59"
PRINT #1, "goto loop"
PRINT #1, ""
PRINT #1, "'the last pulsout is needed for closure of the preceding BIT"
PRINT #1, ""
PRINT #1, "'pulsout 0,59: pause 0: pause 0: pause 0"
PRINT #1, "'the batch of instructions in the line above, produces a BIT 1"
PRINT #1, ""
PRINT #1, "'pulsout 0,59"
PRINT #1, "'the instruction in the line above, produces a BIT 0"


PRINT ""
PRINT " Program Complete."
SLEEP 1
SYSTEM


OUT1:

PRINT #1, "pulsout 0,59: pause 0: pause 0: pause 0"
RETURN

OUT0:

PRINT #1, "pulsout 0,59"
RETURN

>>

I haven't taken any time to provide escape routines for overcoming inputting of incorrect data,

however, it will provide a useable programme if 1's and 0's are input correctly.

Regards. The Brain Surgeon

Post Edited (TheBrainSurgeon) : 12/24/2007 10:28:22 PM GMT

Comments

  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2007-12-24 16:49
    Just attach your basic stamp file. That is much easier
    for anyone trying your code (and even for just reading the code).

    regards peter
  • Paul Sr.Paul Sr. Posts: 435
    edited 2007-12-24 19:03
    To remove the "smiley" icons you should use the "CODE" Tags as I have done below:

    TheBrainSurgeon said...
    Hi.

    Before saying anything else, I would like to point I am a complete novice.

    I can understand that what I have done will probably make any experts cringe.

    But nevertheless, it does work and provides the required output.

    I needed a set up that would enable me to generate various Infrared transmissions.

    The aim was to control various AV equipment such as the TV or DVD recorder.

    I fiddled around and learnt the basics of how these things worked.

    What I have finally produced is an arrangement that will produce code to control

    equipment which makes use of the Panasonic type protocol.

    The devices I am controlling (Panasonic) make use of a 48 bit binary number.

    I have written a short program in Qbasic, which I have saved as a stand alone .EXE file.

    When executed, this Qbasic program asks the user to type in the binary number which eventually

    will be transmitted.

    This .EXE file then outputs a .BAS file which can be loaded directly into a BS1 STAMP.

    The STAMP then switches PIN0 from HI to LOW to provide the required pulsetrain.

    The output from PIN0, is then fed directly to the RESET pin on a 555 timer circuit, which

    has been tuned to provide an oscillation of 38000kHz.

    The 555 oscillator output is connected via a transistor to an Infrared LED.

    When the PIN0 output is HI it lets the IR LED flash at its required 38000kHz frequency.

    Once PIN0 goes low, the flashing IR LED is disabled.

    Below is a list of code which is the output from my Qbasic stand alone .EXE file.


    >>
    'remember this is a test
    'c:\testfile.bas
    '12-24-2007
    'The following Binary Number will be transmitted:
    '000001111100001111
    pins=%00000000
    dirs=%00000000
    'this part is needed just before the actual data begins
    loop:
    pause 74[img]http://forums.parallax.com/images/smilies/tongue.gif[/img]ause 0
    pulsout 0,363
    pause 1
    'this is where the code for pulses really starts
    pulsout 0,59
    pulsout 0,59
    pulsout 0,59
    pulsout 0,59
    pulsout 0,59
    pulsout 0,59[img]http://forums.parallax.com/images/smilies/tongue.gif[/img]ause 0[img]http://forums.parallax.com/images/smilies/tongue.gif[/img]ause 0[img]http://forums.parallax.com/images/smilies/tongue.gif[/img]ause 0
    pulsout 0,59[img]http://forums.parallax.com/images/smilies/tongue.gif[/img]ause 0[img]http://forums.parallax.com/images/smilies/tongue.gif[/img]ause 0[img]http://forums.parallax.com/images/smilies/tongue.gif[/img]ause 0
    pulsout 0,59[img]http://forums.parallax.com/images/smilies/tongue.gif[/img]ause 0[img]http://forums.parallax.com/images/smilies/tongue.gif[/img]ause 0[img]http://forums.parallax.com/images/smilies/tongue.gif[/img]ause 0
    pulsout 0,59[img]http://forums.parallax.com/images/smilies/tongue.gif[/img]ause 0[img]http://forums.parallax.com/images/smilies/tongue.gif[/img]ause 0[img]http://forums.parallax.com/images/smilies/tongue.gif[/img]ause 0
    pulsout 0,59[img]http://forums.parallax.com/images/smilies/tongue.gif[/img]ause 0[img]http://forums.parallax.com/images/smilies/tongue.gif[/img]ause 0[img]http://forums.parallax.com/images/smilies/tongue.gif[/img]ause 0
    pulsout 0,59
    pulsout 0,59
    pulsout 0,59
    pulsout 0,59
    pulsout 0,59[img]http://forums.parallax.com/images/smilies/tongue.gif[/img]ause 0[img]http://forums.parallax.com/images/smilies/tongue.gif[/img]ause 0[img]http://forums.parallax.com/images/smilies/tongue.gif[/img]ause 0
    pulsout 0,59[img]http://forums.parallax.com/images/smilies/tongue.gif[/img]ause 0[img]http://forums.parallax.com/images/smilies/tongue.gif[/img]ause 0[img]http://forums.parallax.com/images/smilies/tongue.gif[/img]ause 0
    pulsout 0,59[img]http://forums.parallax.com/images/smilies/tongue.gif[/img]ause 0[img]http://forums.parallax.com/images/smilies/tongue.gif[/img]ause 0[img]http://forums.parallax.com/images/smilies/tongue.gif[/img]ause 0
    pulsout 0,59[img]http://forums.parallax.com/images/smilies/tongue.gif[/img]ause 0[img]http://forums.parallax.com/images/smilies/tongue.gif[/img]ause 0[img]http://forums.parallax.com/images/smilies/tongue.gif[/img]ause 0
    pulsout 0,59
    goto loop
    
    'the last "pulsout 0,59" is needed for closure of the preceding BIT. It isn't actually a DATA BIT
    
    'pulsout 0,59[img]http://forums.parallax.com/images/smilies/tongue.gif[/img]ause 0[img]http://forums.parallax.com/images/smilies/tongue.gif[/img]ause 0[img]http://forums.parallax.com/images/smilies/tongue.gif[/img]ause 0
    'the batch of instructions in the line above, produces a BIT 1
    
    'pulsout 0,59
    'the instruction in the line above, produces a BIT 0
    
    >>
    
    I don't know if this is of any use to anyone, but if anyone wants the .EXE file, just ask.
    
    I would attach it here but the system won't allow it.
    
    Alternatively, if you have access to Qbasic, then here is the code:
    
    >>
    
    'this prog produces a STAMP Basic program, to send a binary number to
    'the BASIC STAMP for Infrared transmission
    'the data required is   thebinarynumber$,the binary number
    '                       PROGNAME$ (8 digit maximum with .bas extension)
    '                       COMMENTS$
    '                     
    
    CLS
    PRINT ""
    PRINT ""
    PRINT ""
    GOTO start
    fault: CLS : PRINT ""
    PRINT "                                  Try again"
    PRINT ""
    start:
    COMMENTS$ = ""
    thebinarynumber$ = ""
    
    PRINT "                              BASIC STAMP PROGRAM GENERATOR for IR Transmission."
    PRINT ""
    PRINT "                          Please supply required data."
    PRINT ""
    
    INPUT "Enter the Binary Number to be transmitted: ", thebinarynumber$
    INPUT "Enter drive, path and filename for output file - maximum 8 digit filename with .bas extension: ", PROGNAME$
    OPEN PROGNAME$ FOR OUTPUT AS #1
    INPUT "Enter comments: ", COMMENTS$
    
    
    
    CLS
    PRINT "The following data has been supplied"
    PRINT ""
    PRINT "Binary Number ="; thebinarynumber$
    PRINT ""
    PRINT "Program name and path: "; PROGNAME$
    PRINT ""
    PRINT "Comments: "; COMMENTS$
    
    
    INPUT "Do you wish to continue? Y/N If N then restart ", CONTINUE$
    IF CONTINUE$ <> "y" AND CONTINUE$ <> "Y" THEN GOTO fault
    CLS
    
    '------------------------------------------
    PRINT #1, "'"; COMMENTS$
    PRINT #1, "'"; PROGNAME$
    PRINT #1, "'"; DATE$
    PRINT #1, "'The following Binary Number will be transmitted:"
    PRINT #1, "'"; thebinarynumber$
    PRINT #1, "pins=%00000000"
    PRINT #1, "dirs=%00000000"
    PRINT #1, "'this part is needed just before the actual data begins"
    PRINT #1, "loop:"
    PRINT #1, "pause 74[img]http://forums.parallax.com/images/smilies/tongue.gif[/img]ause 0"
    PRINT #1, "pulsout 0,363"
    PRINT #1, "pause 1"
    PRINT #1, "'this is where the code for pulses really starts"
    '-------------------------------------------
    stringlength = LEN(thebinarynumber$)
    
    FOR n = 1 TO stringlength
    digitstore$ = MID$(thebinarynumber$, n, 1)
    
    IF digitstore$ = CHR$(49) THEN GOSUB OUT1 ELSE GOSUB OUT0
    NEXT n
    
    
    PRINT #1, "pulsout 0,59"
    PRINT #1, "goto loop"
    PRINT #1, ""
    PRINT #1, "'the last pulsout is needed for closure of the preceding BIT"
    PRINT #1, ""
    PRINT #1, "'pulsout 0,59[img]http://forums.parallax.com/images/smilies/tongue.gif[/img]ause 0[img]http://forums.parallax.com/images/smilies/tongue.gif[/img]ause 0[img]http://forums.parallax.com/images/smilies/tongue.gif[/img]ause 0"
    PRINT #1, "'the batch of instructions in the line above, produces a BIT 1"
    PRINT #1, ""
    PRINT #1, "'pulsout 0,59"
    PRINT #1, "'the instruction in the line above, produces a BIT 0"
    
    
    PRINT ""
    PRINT "                           Program Complete."
    SLEEP 1
    SYSTEM
    
    
    OUT1:
    
    PRINT #1, "pulsout 0,59[img]http://forums.parallax.com/images/smilies/tongue.gif[/img]ause 0[img]http://forums.parallax.com/images/smilies/tongue.gif[/img]ause 0[img]http://forums.parallax.com/images/smilies/tongue.gif[/img]ause 0"
    RETURN
    
    OUT0:
    
    PRINT #1, "pulsout 0,59"
    RETURN
    
    


    >>

    I haven't taken any time to provide escape routines for overcoming inputting of incorrect data,

    however, it will provide a useable programme if 1's and 0's are input correctly.

    Regards. The Brain Surgeon
Sign In or Register to comment.