Receive and transmit IR remote codes

Discuss development of drivers for external hardware and components, such as LCD screens, sensors, motor drivers, etc.
Target audience: Users and developers of drivers.
mrggg
Posts: 6
Joined: Tue May 18, 2021 11:30 pm

Re: Receive and transmit IR remote codes

Post by mrggg » Wed May 19, 2021 11:01 pm

OK, I got it to work, but I do need a delay. I don't understand why it won't work if I just issue the command once, I seem to have to have it in a loop with a certain delay. The IR LED is a few inches away from the TV, pointed right at where ( I think ) the IR receiver is. I am using a transistor with 100 Ohms to 5V, so lots of IR power.

Code: Select all

sony = SONY_12( Pin(17, Pin.OUT, value = 0) )
addr = 0x1 # 0x1
data = 0x15 # 0x15
SleepTime = 0.12
TotalTime = 10
for n in range(int(TotalTime/SleepTime)) :
    sony.transmit(addr, data)
    time.sleep(SleepTime)
print("Done")
I can set SleepTime from 0.04 to 0.12 and it works. >= 0.13 does NOT work. 0.02 and 0.03 seem to only issue the command successfully once. <= 0.01 does NOT work.

Here is my application : I am using a 4K Sony TV as a monitor. Annoyingly, when my computer display controller goes to sleep, the TV will not wake up when I juggle the mouse - it shuts itself off after some time when seeing no HDMI input. So, I have to keep the remote handy to turn it on. Instead, I have written a daemon for my Mac Mini that will send a message to the Pico over USB if I wiggle the mouse and the display is asleep. So, I only need the Pico to send the IR command for Power On ( which is 0x2E, not 0x15 BTW.) So, in theory, I only need to issue the command once. I guess I can just use this loop and issue it with 0.08 secs delay for 10 secs, that would be OK. But, it would be nice to understand why I need to set the delay in the above range for this to work at all.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Receive and transmit IR remote codes

Post by pythoncoder » Thu May 20, 2021 8:28 am

Short delays will not work for the reason I have given: you must wait until the burst has been transmitted before sending another. This is not usually an issue as you are emulating a human pushing a button, so waiting for (say) 0.5 or 1 second between transmissions is typical. There is no upper limit on the delay: you might press a button on the remote and then not press it again for an hour.

I have no idea why long delays aren't working for you, why you need to send the command more than once, or why you need the transmitter to be so close to the receiver. Are you sure you know where the receiver is? These things normally work across a room.

I no longer own any Sony equipment but this has been tested in the past with a Sony VCR. I have also checked the output against a specification for the Sony protocol.
Peter Hinch
Index to my micropython libraries.

mrggg
Posts: 6
Joined: Tue May 18, 2021 11:30 pm

Re: Receive and transmit IR remote codes

Post by mrggg » Thu May 20, 2021 4:00 pm

Peter,

Regardless of all else, I really appreciate that you wrote this software. As a recently retired analog/RF electrical engineer, I'm sure I could eventually write code to do this myself, but you have made my life much easier making this available. I agree with what you say - I don't see why I should need some weird range of short delays to make it work. As to the proximity of the TX to the RX, that is simply my situation - I doubt that I need that, I just wanted you to know that distance was not the problem. I'm sure it would work over a long range ( line-of-sight). FYI, I stumbled into the short delay as I made a typo in the sleep command. Just prior to that I was using a 1 second delay, and wrapped a nested loop around it that sequenced through all addresses and codes in case the data was being altered somehow, but to no avail. Nothing worked until I used the short delay. Again, your ir_tx test.py code works every time, not the slightest problem with that. As a last resort, I was going to try to convert that to a function that sends the one code that I need. I would need to "fake" a button press however. Thanks for all your efforts, I truly appreciate it !

Post Reply