Any luck using BS2 to control TV remote?
GICU812
Posts: 289
Ive read and tried some examples, namely the one in the Understanding Signals book that came with my oscope.
It didnt work too well, mostly I just got all 1's sometimes I would get parts of signals, but most of the buttons would give the same signal.
What I want is, I have a motion activated security camera with chime, Id like the TV to pop over to the input for the camera. If nothing else, I just use an IR LED to shoot out the "input" button signal from my remote.
Anyone have any advice? I cant seem to sniff my remotes signals with the setup from the understanding signals book. Its a sony TV.
It didnt work too well, mostly I just got all 1's sometimes I would get parts of signals, but most of the buttons would give the same signal.
What I want is, I have a motion activated security camera with chime, Id like the TV to pop over to the input for the camera. If nothing else, I just use an IR LED to shoot out the "input" button signal from my remote.
Anyone have any advice? I cant seem to sniff my remotes signals with the setup from the understanding signals book. Its a sony TV.
Comments
The set-up for your scope will depend on how you have your IR detector setup.· If its idle output is Ground then the pulses will be positive-going and·so your scope should be set to·positive trigger; conversely, if its·idle output is +V then the pulses will be·negative-going and so your scope should be set for negative trigger.·
Your time/div should be set wide enough to view/analyse the entire data stream.· Start with a fast setting so that when you push a button all you see is a blip and then slow it down till you can "zoom in" on it.· [noparse][[/noparse]Your scope probably doesn't have a storage feature, you'll have to work that button.]
http://forums.parallax.com/showthread.php?p=721739
Post Edit -- Been looking at the results from a GE remote (for a DTV converter) and a Sony 'universal' set to control a Sanyo TV.· The data envelopes for both are 70ms wide.· Looks like they have a unique·"leader" (type/ID) followed by the actual data.· If I hold and press a button it doesn't turn out the data stream·time after time, it sends the data once·followed by·a "repeat" signal (which looks the same for both units.)
** If you are looking for a way to make the Stamp "record" results, I can't help you.
More -- Use the Auto MODE when you establish your triggering then, once you've dialed down, switch to Normal MODE and you'll nail it (data/trace sychronisation) every time.
Post Edited (PJ Allen) : 11/2/2008 11:30:11 PM GMT
Jax
'
[noparse][[/noparse] Program Title and Description ]
' Understanding Signals - DecodeSonyIRRemote.bs2
' Decode 38 kHz Sony IR TV remote control signal.
' Author: Andy Lindsay, Parallax, Inc.
' {$STAMP BS2}
' {$PBASIC 2.5}
'
[noparse][[/noparse] I/O Definitions ]
IR_detect PIN 8 ' IR detector output -> P8.
'
[noparse][[/noparse] Constants ]
active_high CON 1 ' Used to set PULSIN commands
active_low CON 0 ' to detect +/- pulses.
'
[noparse][[/noparse] Variables ]
' This program reads all the pulses delivered by the remote, but in
' practice, only the first two to five pulses are required. This can be
' used To save seven To 9 Words in RAM (in this section) and the same
' number OF PULSIN commands in the Process IR Pulses subroutine.
IR_pulse VAR Word(12)
counter VAR Nib
type VAR Nib
IR_message VAR Byte
'
[noparse][[/noparse] Initialization ]
DEBUG CLS ' BOE reset clears display.
'
[noparse][[/noparse] Main Routine ]
DO
DO ' Wait for IR detector output
LOOP UNTIL IR_Detect = 0 ' to go low.
GOSUB Display_Heading
GOSUB Find_and_Display_Start_Pulse
GOSUB Process_IR_Pulses
GOSUB Display_IR_Pulse_Values
GOSUB Convert_to_Binary_Number_Display
LOOP
'
[noparse][[/noparse] Subroutine - Display Heading in Debug Terminal ]
Display_Heading:
DEBUG HOME
DEBUG "IR Remote Messages ", CR, CR
DEBUG "Pulse Duration Value", CR
DEBUG "
", CR
RETURN
'
[noparse][[/noparse] Subroutine - Find and Display Start Pulse ]
' Packets are delivered around 20 times/second while a given button on the
' remote is pressed and held. This program extracts a start pulse from
' an earlier packet. The Process IR Pulses subroutine picks up the rest
' of the pulse values a few packets later. In remote controlled
' applications, the duration of the start pulse can simply be discarded.
Find_and_Display_Start_Pulse:
FOR counter = 0 TO 15
PULSIN IR_detect,active_low,IR_pulse(0)
IF IR_pulse(0) > 900 THEN
DEBUG "Start"
DEBUG " = ", DEC5 IR_pulse(0) * 2, " us "
DEBUG " Start Bit", CR
EXIT ' Exit FOR...NEXT after start
ENDIF ' pulse is detected.
NEXT
RETURN
'
[noparse][[/noparse] Subroutine - Process IR Pulses ]
Process_IR_Pulses:
DO
PULSIN IR_detect,active_high,IR_pulse(0)
LOOP UNTIL (IR_pulse(0) > 1400) AND (IR_pulse(0) <> 0)
' The BASIC Stamp 2p and 2SX modules are fast enough to load these
' values using a FOR...NEXT loop, but all other modules should load the
' pulse values as a sequence of PULSIN Commands.
PULSIN IR_detect,active_low,IR_pulse(0)
PULSIN IR_detect,active_low,IR_pulse(1)
PULSIN IR_detect,active_low,IR_pulse(2)
PULSIN IR_detect,active_low,IR_pulse(3)
PULSIN IR_detect,active_low,IR_pulse(4)
PULSIN IR_detect,active_low,IR_pulse(5)
PULSIN IR_detect,active_low,IR_pulse(6)
PULSIN IR_detect,active_low,IR_pulse(7)
PULSIN IR_detect,active_low,IR_pulse(8)
PULSIN IR_detect,active_low,IR_pulse(9)
PULSIN IR_detect,active_low,IR_pulse(10)
PULSIN IR_detect,active_low,IR_pulse(11)
RETURN
'
[noparse][[/noparse] Subroutine - Display IR Pulse Values ]
Display_IR_Pulse_Values:
FOR counter = 0 TO 10
DEBUG " ", DEC2 counter
DEBUG " = ", DEC5 IR_pulse(counter) * 2, " us "
IF IR_pulse(counter) > 450 THEN
DEBUG " Binary-1", CR
ELSE
DEBUG " Binary-0", CR
ENDIF
NEXT
RETURN
'
[noparse][[/noparse] Subroutine - Convert to Binary Number Display ]
Convert_to_Binary_Number_Display:
FOR counter = 0 TO 10
IF (IR_pulse(counter) < 450) THEN
IR_message.LOWBIT(counter) = 0
ELSE
IR_message.LOWBIT(counter) = 1
ENDIF
NEXT
DEBUG CR,CR,"Binary Value: ", BIN8 IR_message, CR
DEBUG "Decimal Value: ", DEC3 IR_message, CR
DEBUG "Without bit-7: "
DEBUG " ",DEC3 IR_message & %01111111,CR
RETURN
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
If a robot has a screw then it must be romoved and hacked into..
I honestly havent gotten back to this project, im fighting with C to read in 4800 baud serial data. Im recieving several diffrent codes, but a good example is
9
170
98
99
98
99
98
99
98
99
which if I tap the serial line, comes across fine in the debug window, but the program is randomly replacing some bytes with 255 and 19 for some unknown reason. Eh, off topic.
Your remote may not be SONY protocol.
Your remote might be similar to the NEC protocol. 32 bits. 8 bit custom, 8 bits NOT custom, 8 bits command code, 8 bit NOT command code.
The RCA protocol is similar to the NEC except the RCA is 24 bits. 6 bits custom code, 6 bits command code, 6 bit NOT custome code, 6 bit NOT command code.
And yes, the order the codes are sent "custom" and "command"·are unique to the protocols.
Also the sync timing is unique.
Here is some code I used to read a wireless canon remote that uses the NEC protocol.
"North" "south" "east" "west" and "center" 5 buttons arranged in a circle.
"Left" "center" and "right" are three buttons at the bottom of the remote.
' {$STAMP BS2}
' {$PBASIC 2.5}
'Canon Receiver
'38 kHz Receiver
'Sync: Light on = 8800uSec, Light Off = 4400uSec
'Binary 1: Light on = 678, Light Off = 1600
'Binary 0: Light on = 678, Light off = 474
'The remote sends 32 bits, MSB first, Byte 1 = (83), Byte 2 = (141), Byte 3 = Data, Byte 4 = NOT Data
'Buttons:
'······ Byte1,Byte2,Data,NOT Data
'Here is the data received from each button
'North = 83,141,66,189
'East = 83,141,2,253
'South = 83,141,194,61
'West = 83,141,130,125
'Shutter = 83,141,248,7
'Left =· 83,141,34,221
'Center = 83,141,98,157
'Right = 83,141,226,29
'I/O Definitions
det··· PIN·· 10···· 'data I/O, 5VDC, GND
pulse· VAR Word
pulsee VAR Word
codehigh VAR Word
codelow VAR Word
lcdpin··· PIN·· 8
LCDline1· CON·· 128·· 'Line one, charater zero (0 - 15)
LCDline2· CON·· 148·· 'line two, charater zero (0 - 15)
LCDline3 CON 168
lcdline4 CON 188
lcdon···· CON·· 22··· 'Turn LCD on cursor off no blink
clrlcd··· CON·· 12··· 'clear the LCD
blon····· CON·· 17··· 'Turn the back light on
lcdbaud·· CON·· 84··· 'BS2 9600 8, N, 1, checksum off
SEROUT lcdpin, lcdbaud, [noparse][[/noparse]22,12,17] 'On, Clear, Backlight On.
start:
IF det = 1 THEN Start
PULSIN det, 1, pulsee
IF pulsee < 1900 OR pulsee > 2400 THEN start 'check for 4400 uSec
RCTIME det, 1, pulse
IF pulse > 400 THEN codehigh.BIT15 = 1
RCTIME det, 1, pulse
IF pulse > 400 THEN codehigh.BIT14 = 1
RCTIME det, 1, pulse
IF pulse > 400 THEN codehigh.BIT13 = 1
RCTIME det, 1, pulse
IF pulse > 400 THEN codehigh.BIT12 = 1
RCTIME det, 1, pulse
IF pulse > 400 THEN codehigh.BIT11 = 1
RCTIME det, 1, pulse
IF pulse > 400 THEN codehigh.BIT10 = 1
RCTIME det, 1, pulse
IF pulse > 400 THEN codehigh.BIT9 = 1
RCTIME det, 1, pulse
IF pulse > 400 THEN codehigh.BIT8 = 1
RCTIME det, 1, pulse
IF pulse > 400 THEN codehigh.BIT7 = 1
RCTIME det, 1, pulse
IF pulse > 400 THEN codehigh.BIT6 = 1
RCTIME det, 1, pulse
IF pulse > 400 THEN codehigh.BIT5 = 1
RCTIME det, 1, pulse
IF pulse > 400 THEN codehigh.BIT4 = 1
RCTIME det, 1, pulse
IF pulse > 400 THEN codehigh.BIT3 = 1
RCTIME det, 1, pulse
IF pulse > 400 THEN codehigh.BIT2 = 1
RCTIME det, 1, pulse
IF pulse > 400 THEN codehigh.BIT1 = 1
RCTIME det, 1, pulse
IF pulse > 400 THEN codehigh.BIT0 = 1
RCTIME det, 1, pulse
IF pulse > 400 THEN codelow.BIT15 = 1
RCTIME det, 1, pulse
IF pulse > 400 THEN codelow.BIT14 = 1
RCTIME det, 1, pulse
IF pulse > 400 THEN codelow.BIT13 = 1
RCTIME det, 1, pulse
IF pulse > 400 THEN codelow.BIT12 = 1
RCTIME det, 1, pulse
IF pulse > 400 THEN codelow.BIT11 = 1
RCTIME det, 1, pulse
IF pulse > 400 THEN codelow.BIT10 = 1
RCTIME det, 1, pulse
IF pulse > 400 THEN codelow.BIT9 = 1
RCTIME det, 1, pulse
IF pulse > 400 THEN codelow.BIT8 = 1
RCTIME det, 1, pulse
IF pulse > 400 THEN codelow.BIT7 = 1
RCTIME det, 1, pulse
IF pulse > 400 THEN codelow.BIT6 = 1
RCTIME det, 1, pulse
IF pulse > 400 THEN codelow.BIT5 = 1
RCTIME det, 1, pulse
IF pulse > 400 THEN codelow.BIT4 = 1
RCTIME det, 1, pulse
IF pulse > 400 THEN codelow.BIT3 = 1
RCTIME det, 1, pulse
IF pulse > 400 THEN codelow.BIT2 = 1
RCTIME det, 1, pulse
IF pulse > 400 THEN codelow.BIT1 = 1
RCTIME det, 1, pulse
IF pulse > 400 THEN codelow.BIT0 = 1
SEROUT lcdpin, lcdbaud,[noparse][[/noparse]22,12,17]
DEBUG HEX2 codehigh.HIGHBYTE,HEX2 codehigh.LOWBYTE," "
DEBUG HEX2 codelow.HIGHBYTE,HEX2 codelow.LOWBYTE," "
SELECT codelow.HIGHBYTE
CASE = 66
DEBUG "NORTH" ,CR
DEBUG HEX codehigh
SEROUT lcdpin, lcdbaud, [noparse][[/noparse]LCDline1, "······ NORTH"]
CASE = 2
DEBUG "EAST " ,CR
SEROUT lcdpin, lcdbaud, [noparse][[/noparse]LCDline2, "··············· EAST"]
CASE =· 194
DEBUG "SOUTH",CR
SEROUT lcdpin, lcdbaud, [noparse][[/noparse]LCDline3, "······ SOUTH"]
CASE = 130
DEBUG "WEST " ,CR
SEROUT lcdpin, lcdbaud, [noparse][[/noparse]LCDline2, "WEST"]
CASE =248
DEBUG "SHUTTER",CR
SEROUT lcdpin, lcdbaud, [noparse][[/noparse]LCDline2, "····· SHUTTER"]
CASE = 34
DEBUG "LEFT" ,CR
SEROUT lcdpin, lcdbaud, [noparse][[/noparse]LCDline4, "LEFT"]
CASE = 98
DEBUG "CENTER" ,CR
SEROUT lcdpin, lcdbaud, [noparse][[/noparse]LCDline4, "······ CENTER"]
CASE = 226
DEBUG "RIGHT" ,CR
SEROUT lcdpin, lcdbaud, [noparse][[/noparse]LCDline4, "·············· RIGHT"]
ENDSELECT
codehigh=0
codelow=0
GOTO start
END
Here is some code I used to receive a RCA remote:
' {$STAMP BS2}
' {$PBASIC 2.5}
'RCA Protocol
'4000uSec burst, 4000uSec delay
'6 bit custom code, lsb first, 6 bits data code, lsb first,
'6 Bit invert custom code, lsb first, 6 bits invert data code, lsb first
' End/Stop burst
'I/O Definitions
det··· PIN·· 10···· 'data I/O, 5VDC, GND, 56KHz works best for RCA TV code 1000 with a start pulse of 3890 to 4010
buzzer PIN·· 6
pulse· VAR Word
pulsee VAR Word
cust_code VAR Byte
data_code VAR Byte
invrt_cust_code VAR Byte
invrt_data_code VAR Byte
lcdpin··· PIN·· 8
LCDline1· CON·· 128·· 'Line one, charater zero (0 - 15)
LCDline2· CON·· 148·· 'line two, charater zero (0 - 15)
lcdon···· CON·· 22··· 'Turn LCD on cursor off no blink
clrlcd··· CON·· 12··· 'clear the LCD
blon····· CON·· 17··· 'Turn the back light on
lcdbaud·· CON·· 84··· 'BS2 9600 8, N, 1, checksum off
HIGH lcdpin
PAUSE 100
SEROUT lcdpin, lcdbaud, [noparse][[/noparse]22,12,17] 'On, Clear, Backlight On.
start:
IF det = 1 THEN Start
PULSIN det, 1, pulsee
IF pulsee < 1945 OR pulsee > 2005 THEN start 'check for 3890 uSec (3890 to 4010)
RCTIME det, 1, pulse
IF pulse > 557 THEN cust_code.BIT0 = 1
RCTIME det, 1, pulse
IF pulse > 557 THEN cust_code.BIT1 = 1
RCTIME det, 1, pulse
IF pulse > 557 THEN cust_code.BIT2 = 1
RCTIME det, 1, pulse
IF pulse > 557 THEN cust_code.BIT3 = 1
RCTIME det, 1, pulse
IF pulse > 557 THEN cust_code.BIT4 = 1
RCTIME det, 1, pulse
IF pulse > 557 THEN cust_code.BIT5 = 1
RCTIME det, 1, pulse
IF pulse > 557 THEN data_code.BIT0 = 1
RCTIME det, 1, pulse
IF pulse > 557 THEN data_code.BIT1 = 1
RCTIME det, 1, pulse
IF pulse > 557 THEN data_code.BIT2 = 1
RCTIME det, 1, pulse
IF pulse > 557 THEN data_code.BIT3 = 1
RCTIME det, 1, pulse
IF pulse > 557 THEN data_code.BIT4 = 1
RCTIME det, 1, pulse
IF pulse > 557 THEN data_code.BIT5 = 1
RCTIME det, 1, pulse
IF pulse > 557 THEN invrt_cust_code.BIT0 = 1
RCTIME det, 1, pulse
IF pulse > 557 THEN invrt_cust_code.BIT1 = 1
RCTIME det, 1, pulse
IF pulse > 557 THEN invrt_cust_code.BIT2 = 1
RCTIME det, 1, pulse
IF pulse > 557 THEN invrt_cust_code.BIT3 = 1
RCTIME det, 1, pulse
IF pulse > 557 THEN invrt_cust_code.BIT4 = 1
RCTIME det, 1, pulse
IF pulse > 557 THEN invrt_cust_code.BIT5 = 1
RCTIME det, 1, pulse
IF pulse > 557 THEN invrt_data_code.BIT0 = 1
RCTIME det, 1, pulse
IF pulse > 557 THEN invrt_data_code.BIT1 = 1
RCTIME det, 1, pulse
IF pulse > 557 THEN invrt_data_code.BIT2 = 1
RCTIME det, 1, pulse
IF pulse > 557 THEN invrt_data_code.BIT3 = 1
RCTIME det, 1, pulse
IF pulse > 557 THEN invrt_data_code.BIT4 = 1
RCTIME det, 1, pulse
IF pulse > 557 THEN invrt_data_code.BIT5 = 1
display:
DEBUG "Pulse uSec ", DEC5 pulsee*2, CR
DEBUG "··· Custom Code: ",DEC2 cust_code, " ", BIN6 cust_code, "····· Data Code: ", DEC2 data_code, " ", BIN6 data_code, CR
DEBUG "NOT Custom Code: ",DEC2 invrt_cust_code, " ", BIN6 invrt_cust_code, "· NOT Data Code: ", DEC2 invrt_data_code, " ", BIN6 invrt_data_code, CR, CR
SEROUT lcdpin, lcdbaud, [noparse][[/noparse]12]
SEROUT lcdpin, lcdbaud, [noparse][[/noparse]lcdline1, "RCACustomCode:", DEC2 cust_code, lcdline2, "RCA Data Code:",DEC2 data_code]
'DEBUG·· DEC5 pulse*2,",",DEC5 pulsee*2,",",BIN8 codehigh, ",", BIN8 codelow.HIGHBYTE,",",BIN8 'codelow.LOWBYTE,"· ",DEC5 codehigh,",",DEC5 codelow, CR
cust_code = 0
data_code = 0
invrt_cust_code = 0
invrt_data_code = 0
PAUSE 100
GOTO start
END
Keep in mind this is writen for a slow BS2.
I also have working code for the NEC and RCA transmitters.
Let me know how the receivers work and I will post the code for the transmitters. You will need a stable 38KHz oscillator.
SJW
Of course that's for receiving IR, but your primary question is how to send IR to control a Sony TV. Fortunately for you, the Sony control codes are very well documented in all the Parallax literature and on the web. See http://www.hifi-remote.com/sony/Sony_tv.htm for codes. Your "input" key on your remote is likely sending either code 37, 42, or 64-73. Look at the "IR for the BoE-Bot" text and also·http://www.parallax.com/dl/docs/prod/audiovis/InfraredEmittingDiode.pdf to see the sequence of pulses necessary to send·a certain code. You can use a series of pulsouts to modulate a 38Khz carrier in the proper pattern: namely a start pulse and binary morse code at the proper rate. I set up a BS2 to send a Mute command (code 20) near the bottom of this thread: http://forums.parallax.com/showthread.php?p=718911. It requires building an external 555 circuit to generate the 38 kHz IR·carrier. You could also hack into a $5 universal remote and have the Stamp push the "INPUT" key.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."
Maybe my remote isnt compatable with the signals program, or I could have done something wrong, its happened before... once [noparse]:p[/noparse]
All this information should get the project back up·on my list soon.
Jax
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
If a robot has a screw then it must be romoved and hacked into..