I'm working on a IR control program and want to send codes to the SX and have it
send the IR. I simplified the code to show my problem. My IF-Then call seems to
go to la la land and never returns.... help. see code... thanks
Your program is not working because you're using IF-THEN which has an implicit GOTO while what you really wanted was an implicit GOSUB.
Also, your code is somewhat behind the times vis-a-vis present SX/B coding standards. I've attached an update that uses SX/B 1.51.03 features and even modulates the IR pin for you using an interrupt. There are subroutines to send the byte, to delay in milliseconds (replaces PAUSE) and a delay for one bit time (500 us according to your listing).
This may take a few minutes to understand but I think you'll find it helpful.
Thanks Jon, A big help. The last assembly programing I did was 30 years ago on a 6502 & 6800
I am presently working on a control center project for a local utility and want to control 5 identical
Sony TV's from a Visual Basic program that will also control a video switcher... I'm an electrical
engineer.
I loaded your code and it worked as written.. So with it and an oscilloscope I got the timing ok
for the Sony protocol . I'm not at all practiced in the interrupts so can I turn the 38KHz modulation
off while I do serial communications with the SX? (then interrupts on for the IR send)
I want the PC to send commands to any one of
the 5 TV's and the SX should take the code and send it to one of 5 IR leds (they could all use the
same pin for modulation) Thanks for your help.
Bill
If you don't want to do interrupt-driven serial then get rid of the interrupts altogether. Since the SX is fast, you can create a "1" bit by manually toggling the pin for the "1" bit time.
But... if you're going to be sending standard Sony IRCS codes then your simple scheme won't work. The SIRCS protocol is 12 bits, has a 2.4 ms start bit, "1" bits that are 1.2ms wide, "0" bits that are 0.6ms wide, and every bit is padded with 0.6ms of "off." I've done lots of SIRCS decoding and a little encoding. I'm late for a dinner party, but was able to whip this up and think it will work -- no ISR needed, but if serial data comes in when you're transmitting IR you'll lose it
SUB TX_SIRCS
irCode VAR tmpW1
bitPos VAR tmpB1
irCode = __WPARAM12 ' capture code
TX_IR_BIT 182 ' 182 x 13.1us = 2.4ms
FOR bitPos = 0 TO 11
IF irCode.0 = 1 THEN
TX_IR_BIT 91 ' 91 x 13.1us = 1.2ms
ELSE
TX_IR_BIT 45
ENDIF
irCode = irCode >> 1
NEXT
ENDSUB
' -------------------------------------------------------------------------
SUB TX_IR_BIT
bitCycles VAR __PARAM1 ' don't change!
DO WHILE bitCycles > 0
IrOut = ~IrOut ' toggle LED output
PAUSEUS 13.1
DEC bitCycles
LOOP
IrOut = 0
PAUSEUS 600
ENDSUB
If you'll give me more details I'll help -- this seems pretty interesting and I think I could learn a few things along the way, too.
Thanks again. With your help and some of my old code I have a program that will send
Sony commands. I have another snippit of code to add, with the serial communications.
I have that tested, just have to add it to this code.
the attachment will send the Sony power code. The final version I want to keep flexible
so I can send descreet codes and let my visual basic program wait for an echo back and
the pc based program can do the code format etc... also not talk and wait for the SX.
also for 5 different TV's I'll have to have the pc commands tell the SX which port to send
the IR.
It's a work in progress
It will be a few days before I can play with the code you just sent...
Thanks.
Comments
Also, your code is somewhat behind the times vis-a-vis present SX/B coding standards. I've attached an update that uses SX/B 1.51.03 features and even modulates the IR pin for you using an interrupt. There are subroutines to send the byte, to delay in milliseconds (replaces PAUSE) and a delay for one bit time (500 us according to your listing).
This may take a few minutes to understand but I think you'll find it helpful.
Post Edited (JonnyMac) : 9/6/2008 5:45:23 AM GMT
I am presently working on a control center project for a local utility and want to control 5 identical
Sony TV's from a Visual Basic program that will also control a video switcher... I'm an electrical
engineer.
I loaded your code and it worked as written.. So with it and an oscilloscope I got the timing ok
for the Sony protocol . I'm not at all practiced in the interrupts so can I turn the 38KHz modulation
off while I do serial communications with the SX? (then interrupts on for the IR send)
I want the PC to send commands to any one of
the 5 TV's and the SX should take the code and send it to one of 5 IR leds (they could all use the
same pin for modulation) Thanks for your help.
Bill
But... if you're going to be sending standard Sony IRCS codes then your simple scheme won't work. The SIRCS protocol is 12 bits, has a 2.4 ms start bit, "1" bits that are 1.2ms wide, "0" bits that are 0.6ms wide, and every bit is padded with 0.6ms of "off." I've done lots of SIRCS decoding and a little encoding. I'm late for a dinner party, but was able to whip this up and think it will work -- no ISR needed, but if serial data comes in when you're transmitting IR you'll lose it
If you'll give me more details I'll help -- this seems pretty interesting and I think I could learn a few things along the way, too.
Sony commands. I have another snippit of code to add, with the serial communications.
I have that tested, just have to add it to this code.
the attachment will send the Sony power code. The final version I want to keep flexible
so I can send descreet codes and let my visual basic program wait for an echo back and
the pc based program can do the code format etc... also not talk and wait for the SX.
also for 5 different TV's I'll have to have the pc commands tell the SX which port to send
the IR.
It's a work in progress
It will be a few days before I can play with the code you just sent...
Thanks.
Bill