Author Topic: How do IR remotes wake up on key press?  (Read 3656 times)

0 Members and 1 Guest are viewing this topic.

Offline PeabodyTopic starter

  • Super Contributor
  • ***
  • Posts: 2248
  • Country: us
How do IR remotes wake up on key press?
« on: September 06, 2019, 02:08:26 pm »
I'm working on an Arduino-based IR remote code generator that will work like a standard remote, using keypress entry on a 4x3 matrix keypad.  And I want the battery to last a long time.  I always assumed that remotes were truly OFF, and drawing no current at all, until a key is pressed.  But I'm having trouble coming up with a way to do that, so maybe my assumption is wrong.  Does anyone here have experience designing remotes?

If the processor has to ON, but asleep, until a key is pressed, then with Arduinos in particular I would be concerned about how deep the sleep could be and still wake up fast enough to process the keypress, particularly if the oscillator is off during sleep.
 

Offline agehall

  • Frequent Contributor
  • **
  • Posts: 390
  • Country: se
Re: How do IR remotes wake up on key press?
« Reply #1 on: September 06, 2019, 02:39:13 pm »
Check the data sheet for whatever MCU you are looking to use. I would not expect the wake up time to be a huge problem for a remote control application. Things move so slowly in the world of user interactions anyway that whatever time it takes the MCU to wake up, it is probably nothing compared to the speed with which the user presses the buttons.
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 13217
Re: How do IR remotes wake up on key press?
« Reply #2 on: September 06, 2019, 02:46:34 pm »
A 455KHz resonator can start and become stable in 1000 cycles.  That's under 2.2ms, which is negligible in human button press terms.  If you use the stock Arduino ceramic resonator, it may take a few more cycles, but at 16MHz the delay is truly negligible. Other wakeup or reset delays should be insignificant.

Use a bare AVR so you don't have all sorts of stuff on the rest of the board leaching off your Vcc rail,  and put it in power-down sleep mode waiting for a pin change interrupt to wake it up on any keypress on any of the key matrix lines (e.g monitoring all the rows as inputs with internal weak pullup with all columns set to output '0' immediately before going to sleep), and, assuming you don't need any sort of timed wakeup, an ATmega328P can draw less than a uA, so 3x A76/LR44 alkaline button cells (for Vcc=4.5V dropping to 2.7V at EOL, so use INTOSC or an 8MHz resonator) will basically last as long as their shelf life if the remote is rarely used. 

In practice board surface leakage current through accumulated spooge under the contact mat will probably dominate.  3x AAA batteries would be a better choice if you can afford the weight and volume, as their larger capacity can tolerate a much higher quiescent current without impacting the usable lifespan.
« Last Edit: September 06, 2019, 02:50:46 pm by Ian.M »
 

Offline golden_labels

  • Super Contributor
  • ***
  • Posts: 1473
  • Country: pl
Re: How do IR remotes wake up on key press?
« Reply #3 on: September 06, 2019, 03:01:40 pm »
LR6 (Alkaline AA) at 5mA discharge rate work for 600–800h(1). On log-log scale the current/service hours curve is approximately linear, so I guess they may hold for over 4kh with a µC running in sleep mode. And that is half a year. 3Ah, low self-discharge rechargeables are also available and they will easily live that long too.

But even if my guess above is wrong, there are switches that are drawing no current when turned off (the default) and are activated by being pulled down/up. Then they conduct until they receive a turn-off signal. This way you may enable the controller whenever a key is pressed. There are existing parts to perform that task, but you may build one yourself. As it happens, Dave even made video on that topic (the first part is of interest to you):


Pulling down/up from multiple buttons may be achieved with a simple diode logic OR gate. Turning it off from Arduino may be a bigger problem, because you must keep the disable signal on while the µC itself is already being turned off. For this reason I would stick to just keeping the controller in the sleep mode if that suffices. Otherwise the cost of parts needed for the circuit may exceed the cost of using the solution based on keeping the controller in the sleep mode. Not to mention all the pain of implementing it and space wasted.
____
(1) Based on the datasheet for Duracell Coppertop, as an example of consumer AA batteries.
« Last Edit: September 06, 2019, 03:05:13 pm by golden_labels »
People imagine AI as T1000. What we got so far is glorified T9.
 

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 3382
  • Country: gb
Re: How do IR remotes wake up on key press?
« Reply #4 on: September 06, 2019, 03:48:21 pm »
Many micros can be configured to wake up from sleep by a change in port pin state.  Use these pins for your key scanning.
 
The following users thanked this post: Kilrah

Offline PeabodyTopic starter

  • Super Contributor
  • ***
  • Posts: 2248
  • Country: us
Re: How do IR remotes wake up on key press?
« Reply #5 on: September 06, 2019, 05:57:50 pm »
Ok, it sounds like I was wrong about remotes being completely powered down.  They're just sleeping.  And there would be no economic benefit from powering them down because with sleep currents being so low, sleeping would just mean the user might have to replace the batteries a week earlier after a couple years.

So the Atmel chip should work fine with no regulator, USB adapter or power LED.  And maybe using the internal oscillator at 8 MHz so 3V would work, if that's accurate enough. A better choice might be a Pro Mini with an 8MHz resonator.  And deep sleep just waiting for an I/O change on the column lines.

Thanks for all the information.

 

Offline MosherIV

  • Super Contributor
  • ***
  • Posts: 1530
  • Country: gb
Re: How do IR remotes wake up on key press?
« Reply #6 on: September 06, 2019, 06:51:45 pm »
Most infra red remotes use asic chips that have very low power draw.

Quote
deep sleep just waiting for an I/O change on the column lines.
The clasic way to do it is to arrange for any keypad press to trigger the wake irq of the micro. As soon as the micro starts running the embedded program, it scans the key matrix to work out which key has been pressed. Then it can generate the pulse train out in infra red.
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 13217
Re: How do IR remotes wake up on key press?
« Reply #7 on: September 06, 2019, 11:11:26 pm »
There's one more trick you can do to optimise battery life (but check compatibility with the specific type of IR receiver its going to be used with): design the IR LED driver for max rated output (less a moderate safety margin), at the 3/4 discharged battery voltage when driven by a 50% duty cycle PWM, use the ADC's 1.1V FVR with ADC Ref from Vcc to calculate the actual battery voltage, then, if its not yet discharged to 3/4, reduce the PWM duty cycle according to the battery voltage to maintain the same average LED current.   The effective optical power at the receiver will vary a bit but far less than if you drove the LED at flat out max. pulsed If when the batteries are brand new, and you'll extend the active battery life by your If safety margin.  Past 3/4 discharged, you are on the tail of the Alkaline characteristic with increasing internal impedance and an accelerating voltage drop, so in most cases you'll get more use out of them by letting the average current drop off and the range decrease rather than trying to maintain the output power.  In all cases, if you don't want it to be a battery hog, you'll need a *LOT* of low leakage bulk decoupling, so the rising battery impedance doesn't prematurely limit the pulsed  IR LED load current.
« Last Edit: September 06, 2019, 11:15:03 pm by Ian.M »
 

Offline amyk

  • Super Contributor
  • ***
  • Posts: 8526
Re: How do IR remotes wake up on key press?
« Reply #8 on: September 07, 2019, 12:42:56 am »
A lot of remotes power the transmitter and encoder IC only when a button is pressed, so they do truly have 0 standby power (possibly neglecting the tiny amount of leakage current through the power switching transistor.)
 

Offline PeabodyTopic starter

  • Super Contributor
  • ***
  • Posts: 2248
  • Country: us
Re: How do IR remotes wake up on key press?
« Reply #9 on: September 07, 2019, 05:11:05 pm »
At this point, I'm looking at an Arduino Pro Mini running on an 8 Mhz external resonator.  While it has a 3.3V regulator, the schematic suggests that can be completely un-jumpered.  The Mini would then be powered directly by a single 18650.  I would probably not build in a charger, but just replace the discharged 18650 with a charged one as needed.

There are Arduino libraries for both IR remote and keypads, so the programming should be pretty easy.  I don't have a demodulating IR receiver, but was able to get the Roku IR codes for Back, Left, Right and OK using my scope and a plain IR phototransistor.  For those interested, the Roku format is 32-bit NEC.

So any of the three column lines would interrupt the Atmel and wake it up from deep sleep.  On waking up, the sketch would identify the current key being pressed, wait for it to be released, then look for another keypress for perhaps a second.  If another keypress is found, the first key value would be muliplied by 10, and second key value added in, then wait again for release.  When a timeout finally occurs, the accumulated channel number value would be looked up in a table, and its corresponding My Channels position would be compared to the current position, and the number of Left's or Right's needed to get to the new channel calculated.

After all the moving is done, the processor is put to sleep.

The big problem is probably going to be finding an appropriate box to put it in.  There ought to be a law that says anyone who manufactures a keypad has to specify a project box that fits it.  :-)  Or maybe there's a box that comes with a keypad installed.

The IR library controls the duty cycle of the transmitter, and I believe it's 50%.  But the recommended value is 25-33%.  25% would in theory save half your power usage unless it also effectively cuts the range in half, which I assume it does (otherwise this would be a free lunch, which is not permitted).
 

Offline amyk

  • Super Contributor
  • ***
  • Posts: 8526
Re: How do IR remotes wake up on key press?
« Reply #10 on: September 07, 2019, 05:27:19 pm »
So any of the three column lines would interrupt the Atmel and wake it up from deep sleep.  On waking up, the sketch would identify the current key being pressed, wait for it to be released, then look for another keypress for perhaps a second.  If another keypress is found, the first key value would be muliplied by 10, and second key value added in, then wait again for release.  When a timeout finally occurs, the accumulated channel number value would be looked up in a table, and its corresponding My Channels position would be compared to the current position, and the number of Left's or Right's needed to get to the new channel calculated.
You have created a "stateful" remote, and in my experience those will always go out of sync with the receiver side and frustrate you that way, so I suggest redesigning your solution so that the remote is as dumb as possible and all the complex processing happens at the receiver. Pressing a key should do nothing more than continuously transmit that key's code.
 
The following users thanked this post: Ian.M

Offline PeabodyTopic starter

  • Super Contributor
  • ***
  • Posts: 2248
  • Country: us
Re: How do IR remotes wake up on key press?
« Reply #11 on: September 07, 2019, 10:05:02 pm »
So any of the three column lines would interrupt the Atmel and wake it up from deep sleep.  On waking up, the sketch would identify the current key being pressed, wait for it to be released, then look for another keypress for perhaps a second.  If another keypress is found, the first key value would be muliplied by 10, and second key value added in, then wait again for release.  When a timeout finally occurs, the accumulated channel number value would be looked up in a table, and its corresponding My Channels position would be compared to the current position, and the number of Left's or Right's needed to get to the new channel calculated.
You have created a "stateful" remote, and in my experience those will always go out of sync with the receiver side and frustrate you that way, so I suggest redesigning your solution so that the remote is as dumb as possible and all the complex processing happens at the receiver. Pressing a key should do nothing more than continuously transmit that key's code.

The receiver is a Roku, and I have no way to change its firmwear or behavior.  So if this doesn't work, I'm not sure I have any alternative solution.  I could try to use the wifi version of the remote, but I think it would suffer from the same sync issue IR does.  Well it isn't going to cost much to try the IR other than my time.
 

Offline amyk

  • Super Contributor
  • ***
  • Posts: 8526
Re: How do IR remotes wake up on key press?
« Reply #12 on: September 08, 2019, 01:12:36 am »
Make a retransmitter, like what used to be common for turning on the TV at the same time as the cable box/VCR, and do the stateful logic there.
 

Offline Mechatrommer

  • Super Contributor
  • ***
  • Posts: 11714
  • Country: my
  • reassessing directives...
Re: How do IR remotes wake up on key press?
« Reply #13 on: September 08, 2019, 02:03:14 am »
my recent circuit regarding remote control attached for 3 switches... when a button is pressed, mcu will hold power by output HI on gp through either sw1 or/and sw2 nodes, and it can detect which of the 3 buttons is pressed by shifting IO state. after it finish doing the transmitting, gp is set to LO, Q1 and Q2 will shut off everything. current consumption (leakage) during off is 15uA. with 1500mAh battery, thats 11 years of idle but thats too optimistic... C2-C4 can be replaced with resistors but circuit will ON as long as if someone press a button. pic10f206 sleep current is 0.1uA but i was having trouble with sleep/wake up issues last time, so i'm exercising transistor switch in this circuit, will be useful reference for me when i use more power hungry mcu later. by the 0.1uA figure in datasheet, battery direct on pic10f206 mcu and sleeped should be better, suggestion to improve is welcomed. if transmitter is only one switch like my diy door bell, the switch is connecting to battery direct, if switch is not pressed, battery will last till the end of time, theoritically.
« Last Edit: September 08, 2019, 02:08:17 am by Mechatrommer »
Nature: Evolution and the Illusion of Randomness (Stephen L. Talbott): Its now indisputable that... organisms “expertise” contextualizes its genome, and its nonsense to say that these powers are under the control of the genome being contextualized - Barbara McClintock
 

Offline sokoloff

  • Super Contributor
  • ***
  • Posts: 1799
  • Country: us
Re: How do IR remotes wake up on key press?
« Reply #14 on: September 08, 2019, 11:24:43 am »
Does "NA" mean "0" or infinite or something else? (I'm a struggling beginner at analog electronics.)

I think it can't mean 0, but I'm not totally sure.
« Last Edit: September 08, 2019, 11:31:34 am by sokoloff »
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 13217
Re: How do IR remotes wake up on key press?
« Reply #15 on: September 08, 2019, 12:52:22 pm »
NA could variously be nA - nanoAmps, or N/A - Not Applicable.

In this case I think Mechatrommer is misusing it instead of DNP - do not populate (optional components on the PCB layout but not fitted).   It would be vastly preferable to also give the value e.g."DNP 10K" so you know what should be fitted there if it does need populating.
« Last Edit: September 08, 2019, 12:56:28 pm by Ian.M »
 
The following users thanked this post: Mechatrommer

Offline Mechatrommer

  • Super Contributor
  • ***
  • Posts: 11714
  • Country: my
  • reassessing directives...
Re: How do IR remotes wake up on key press?
« Reply #16 on: September 08, 2019, 02:43:34 pm »
Does "NA" mean "0" or infinite or something else? (I'm a struggling beginner at analog electronics.)
I think it can't mean 0, but I'm not totally sure.
sorry. thats a beginner work who stubbornly cant take advice from an expert, NA means Not Available (Not Applicable as Ian spotted), i mean... it can be Not Installed. it is there in case the nodes floating high due to some stray effect (resulting gp high and turning the circuit ON all the time), then i have to install pull down resistors. i'm dealing with less than ideal flux and solder element here. or simply just forget about it, the important idea is how the switching ON/OFF is made.
Nature: Evolution and the Illusion of Randomness (Stephen L. Talbott): Its now indisputable that... organisms “expertise” contextualizes its genome, and its nonsense to say that these powers are under the control of the genome being contextualized - Barbara McClintock
 

Offline amyk

  • Super Contributor
  • ***
  • Posts: 8526
Re: How do IR remotes wake up on key press?
« Reply #17 on: September 08, 2019, 06:27:48 pm »
In this case I think Mechatrommer is misusing it instead of DNP
That's not the only thing misused in that "schematic"...

Hint: a bunch of disconnected parts with net labels is NOT a schematic.
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 13217
Re: How do IR remotes wake up on key press?
« Reply #18 on: September 08, 2019, 07:10:41 pm »
That's the modern OSHW 'style'.  If us old farts that are used to being able to follow a wire on a paper schematic without needing an ecopy of it and a compatible viewer that can hilite by net name, went postal on all the young designers using it, we'd all be doing serious jail time and there'd be no-one left who actually remembers the hands on experience of the design lessons of the 20th century.
 

Offline Mechatrommer

  • Super Contributor
  • ***
  • Posts: 11714
  • Country: my
  • reassessing directives...
Re: How do IR remotes wake up on key press?
« Reply #19 on: September 08, 2019, 07:55:19 pm »
yeah sorry if its hard on some people. i didnt know about the DNP, NA or N/A is much more understandable in any discipline imho. unfortunately i kinda dislike DNP because its too sounds like DXP (Altium executable :P) sorry. even NA is not really what i meant. what i want is "Populate If Necessary" (PIN) or "Do Not Populate But Please Do If Necessary" (DNPBPDIN) or (DNPBPIN) but that will make nomenclatures much worst.

i'm aware about those old style schematics, its neat in one single unit but man, for me its hard to trace or explode smaller circuit units into separate logical circuits. i dont have to take complex circuit like HP/Agilent/Tektronix DSO or PSU, things like alm's PSU in the other thread is hard to understand for ee noobs like me. i have to bend neck 90 and -90 degrees trying to understand what this transistor do and to where its connected logically, i never managed to understand it until today, people who made his circuit i guess is just blind copy paste it onto their circuit, or knowledgable enough first hand, in harser word maybe too clever or too stupid.

furthermore, with the era of embedded/mixed signal circuit and EDA, disconnection is inevitable, to avoid spagethiness. we can check how Dave made the schematics in his video, a slight component addition to the old style circuit will be a nightmare, deleting and repopulating traces, rearranging component etc, at least for me. so somehow these aspect have educated me, the not original ee-born chap. in the schematics i linked, you can just make a selection box around those resistors and make it disappear (cut) and the circuit still applies.

i know earlier generations are too meticulous and persistent with their work. with eraser, pencil and ruler (this includes mechanical CAD/drafting work) they are well respected, but this is EDA/CAD/CAM age, new generations maybe including me got stiffer, heavier and lazier arse esp if one is a Mechatrommer (3 in 1 master of none) :-\ this is off-topic btw. cheers.
« Last Edit: September 08, 2019, 08:01:19 pm by Mechatrommer »
Nature: Evolution and the Illusion of Randomness (Stephen L. Talbott): Its now indisputable that... organisms “expertise” contextualizes its genome, and its nonsense to say that these powers are under the control of the genome being contextualized - Barbara McClintock
 

Offline PeabodyTopic starter

  • Super Contributor
  • ***
  • Posts: 2248
  • Country: us
Re: How do IR remotes wake up on key press?
« Reply #20 on: September 09, 2019, 01:05:44 am »
I got the basic device up and running this afternoon, so now I can enter the target channel as the channel number I'm used to using on Cox Cable, and my device will issue the IR commands needed for the Roku to get to that channel.   But haven't addressed the sleep and interrupt issues yet.  I think that should all be fairly straighforward since I don't need the ISR to do anything except wake up the processor.
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 13217
Re: How do IR remotes wake up on key press?
« Reply #21 on: September 09, 2019, 03:11:54 am »
Lets hope it stays in sync reliably.  :popcorn: However if not, the best option may be to be to put a smart controller on your LAN where it can interrogate your Roku for its current status.

The *easiest* way to do that would be running LIRC on a Raspberry Pi Zero W.  On the hardware side of things, just add an IR receiver and you can 'drive' it from any 'dumb' remote that doesn't conflict with any of your other AV kit.  Add  some small IR LEDs and a beefy driver transistor and you can control AV equipment that isn't network aware, e.g. to turn on the TV, select the input your Roku's on and control the TV volume etc..  On the software side of things, LIRC does all the IR protocol 'heavy lifting' but you will have to write the (probably Python) scripts to tie it all together and talk to the Roku ECP network control API.

See:
https://camp.isaax.io/en/isaax-examples/ir-control-via-lirc-on-raspberry-pi-zero-w

https://developer.roku.com/en-gb/docs/developer-program/discovery/external-control-api.md
and, for an actual implementation of Roku ECP control, albeit on an ESP8266:
https://blog.adafruit.com/2018/09/29/homemade-roku-remote-uses-roku-external-control-api-huzzah-esp8266/
which should save you much wading through the ECP API documentation and much headscratching!  :phew:
 

Offline PeabodyTopic starter

  • Super Contributor
  • ***
  • Posts: 2248
  • Country: us
Re: How do IR remotes wake up on key press?
« Reply #22 on: September 09, 2019, 02:36:21 pm »
I found that the Roku stays in sync if the interval between IR commands is 400ms, but it couldn't keep up at 250ms, and I ended up one channel short of the target.  But at the slower speed it has yet to fail.

I did the IR version because I had the parts to do it.  But it turns out there are three ways to communicate with the Roku.  In addition to IR, there appears to be an RF remote option, which is a direct RF communication (not through the router) between the remote and the Roku.  Apparently Roku sticks have to use that because they have no IR, but I think all modern Rokus come with such an RF remote.  I haven't found any information about how that works.

But then there's the ECP thing, which takes place over the LAN using the Roku's IP address.  I assume that's what the iOS and Android Roku apps use.  The ESP8266 device you linked to is what I would fall back to if IR doesn't work well in the end.  Since this would be battery powered, I think this would be a better option than a Pi, and of course much less expensive.

But one thing isn't clear to me.  It seems with ECP you can command the Roku to play a specific channel by name.  But in my case the channels I want are within Sling, so they are one level down from the Roku Sling channel.  I don't see a way to send commands to Sling.

I'm thinking of using the * key to tell the Arduino what the current Sling channel actually is - in case it gets out of sync - or maybe just reset it to the first channel.  And maybe the # key could tell my TV to toggle the input between HDMI and OTA. I might even throw caution to the winds and get a 4x4 keypad.  :-)
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 13217
Re: How do IR remotes wake up on key press?
« Reply #23 on: September 10, 2019, 02:47:17 am »
The Pi would sit next to the Roku powered with a wallwart and itself controlled over IR from a dumb(ish) off-the-shelf remote, e.g. a universal one programmed for a brand of kit you don't own.  If not all the commands/functions you need are accessible by ECP, you could use a hybrid  approach:  Use ECP to get the Roku into a known state as close as possible to the desired state then transmit IR commands from the Pi using LIRC to get the Roku into the desired final state.

Although the Pi Zero W sold ''bare board' seems to be in short supply stateside (probably due to the poor profit margin for resellers if they aren't packaging them with accessories), Adafruit have it in stock for $10 USD, rationed to one per customer.  Apart from a SD card, the Pi just needs a wallwart,  an IR LED + driver transistor, and an IR receiver module, + a remote to control it, all of which can be scavenged from dead AV kit.  An 8 GB micro SD card should be findable for around $5, so all in, it should be under $20.  I think that's reasonably competitive against having to build custom handheld remote.  Heck the case and keypad could well set you back more than that.

To get going with it, you can headlessly tether it to your PC as a RNDIS device (USB 'ethernet adapter') and activate SSH, by editing files  on its SD card, then once you've got a console over SSH, and have bridged the Pi RNDIS adapter to your PC's LAN adapter to let it use your internet, you can SSH into it to install VNC and then VNC to its desktop with full access (except for video playback) from your PC's mouse, screen and keyboard.  Of course its *EASIER* if you can hook it to a monitor to check progress but its certainly not essential. 

Hint: To tether it, use a really short USB data cable that came with a phone you have retired, as cheap dollar store USB leads tend to drop too much voltage for a Pi Zero W to be stable tethered.
« Last Edit: September 10, 2019, 08:22:51 am by Ian.M »
 

Offline PeabodyTopic starter

  • Super Contributor
  • ***
  • Posts: 2248
  • Country: us
Re: How do IR remotes wake up on key press?
« Reply #24 on: September 10, 2019, 04:59:06 am »
I'm sorry, Ian, but I think you greatly over-estimate my level of knowledge.  I don't know what LIRC, RNDIS or VNC are, and have never used a Pi or Linux.  And I don't understand the need for a Pi when it appears even for the networked version an ESP8266 remote could do the same thing without the need for any IR - as in your earlier referenced Huzzah-based remote.  As for the cost, the total for the Arduino Pro Mini, keypad, 18650 and 18650 holder would be about $18, and that's even paying up for US sources for fast delivery.  Don't know about the enclosure yet.  I already have the IR LED and an 18650 charger.

Since the breadboard version of the IR remote is already working, I think for now I'm going to just get that into finished form and be done with it.  If in the end it's not up to the task, the ESP8266 would be the next step.
« Last Edit: September 10, 2019, 05:04:10 am by Peabody »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf