guenter's blog‎ > ‎

AVR ATmega48 RUWIDO Merlin IR Keyboard Decoder

posted May 21, 2012, 8:46 AM by Guenter Bartsch
Here is a small by-product of a larger AVR based embedded project I am working on these days: A pinchange interrupt driver, MIT licensed decoder for the RUWIDO Merlin IR Keyboard. This keyboard is very small, yet has full-sized keys and is available for 2,95 EUR at pollin - and even comes in US layout! 

What is special about this implementation and differntiates it from IRMP (which is also great for basically anything except the RUWIDO protocol in my experience) is that it doesn't require you to call an interrupt service routine regularly from a timer interrupt but uses a pin change interrupt instead (the timer is still used but just to provide a realtime clock). Benefits of this approach:
  • less cpu hungry (ISR is called only when an actual IR event occurs)
  • more robust decoding under CPU load (timer used will be unaffected by CPU load, ISR is called less frequently and timing of ISR call is not that critical)
The code will also handle the NEC protocol and can be adapted to many other protocols, even comes with a full data logging facility to help reengineer unknown protocols. The test-program supplied with the code will simply log any IR event recognized on the serial port (38400 8N1):

IR:  adr=0x2AAB cmd=0x0000 flags=001 cnt=016 data=0x00002AAB
IR:  adr=0x2AAB cmd=0x0AB4 flags=000 cnt=030 data=0x0AAACAB4
IR:  adr=0x2AAB cmd=0x0000 flags=001 cnt=016 data=0x00002AAB
IR:  adr=0x2AAB cmd=0x0000 flags=001 cnt=016 data=0x00002AAB
IR:  adr=0x2AAB cmd=0x0000 flags=001 cnt=016 data=0x00002AAB
IR:  adr=0x2AAB cmd=0x0000 flags=001 cnt=016 data=0x00002AAB
IR:  adr=0x2AAB cmd=0x02B5 flags=000 cnt=028 data=0x02AAB2B5
IR:  adr=0x2AAB cmd=0x02B5 flags=000 cnt=028 data=0x02AAB2B5
IR:  adr=0x2AAB cmd=0x0000 flags=001 cnt=016 data=0x00002AAB
IR:  adr=0x2AAB cmd=0x0000 flags=001 cnt=016 data=0x00002AAB
IR:  adr=0x2AAB cmd=0x0000 flags=001 cnt=016 data=0x00002AAB
IR:  adr=0x2AAB cmd=0x0000 flags=001 cnt=016 data=0x00002AAB
IR:  adr=0x22D6 cmd=0x0867 flags=000 cnt=032 data=0x22D69867
IR:  adr=0x22D6 cmd=0x02CD flags=000 cnt=032 data=0x22D632CD
IR:  adr=0x22D6 cmd=0x0A75 flags=000 cnt=032 data=0x22D68A75
IR:  adr=0x22D6 cmd=0x00DF flags=000 cnt=032 data=0x22D620DF
IR:  adr=0x22D6 cmd=0x08D7 flags=000 cnt=032 data=0x22D628D7


Address 0x2AAB is RUWIDO, 0x22D6 is NEC. The infrared keyboard will continue to produce key events while a key is held down (flags==0) and produce key-up events when the key is released (flags==1). More information on the interface/data structures used in ir/ir.h (pretty similar to IRMP actually).

Finally, here is a picture of the test setup:



Code is attached to this post.
ċ
ioirtest.tar.gz
(9k)
Guenter Bartsch,
May 21, 2012, 9:06 AM
Comments