Decoding a Superknight IR dimmer - The Planted Tank Forum
Old 03-24-2015, 03:14 AM Thread Starter
Planted Tank Guru

Join Date: Aug 2014
Location: Maryland, USA
Posts: 2,339
Decoding a Superknight IR dimmer

So, I have been working on converting my planted+ dimmer mod from using a dial dimer to an arduino controlled IR dimmer, thus allowing me programmed cycles.

The dimmer itself is a Superknight 1-channel 24-button 12-button dimmer:
http://www.amazon.com/gp/product/B00KS20W7Q/ref=oh_aui_detailpage_o05_s00?ie=UTF8&psc=1

Thus far I've done captures of all the relevant buttons using code from:
http://playground.arduino.cc/Code/InfraredReceivers and a simple IR http://www.amazon.com/gp/product/B00A1BNP6O/ref=oh_aui_detailpage_o05_s00?ie=UTF8&psc=1
And then plotted the data in gnuplot:

Thus far I've figured the protocol starts with a 4.456ms "on" pulse at the start.

From there there are narrow pulses, high for ~500usec, and wide pulses, high for ~1617usec.

Knowing no better, I'm going to assume this is a pulse-width protocol, so I've called the narrow pulses 0's and wide pulses 1's.

Every message starts off with the same 16-bit sequence (after start pulse and before the black line in my drawing):
common header: 0100 0000 1111 1111 or 0x40FF

From there, each message has another 16-bits:

10% 0010 0000 1101 1111 = 0x20DF
20% 1010 0000 0101 1111 = 0xA05F
30% 0110 0000 1001 1111 = 0x60EF
40% 0001 0000 1110 1111 = 0x10DF
50% 1001 0000 1101 1111 = 0x90DF
60% 0101 0000 1101 1111 = 0x50DF
70% 0011 0000 1100 1111 = 0x30CF
80% 1011 0000 0100 1111 = 0xD08F
90% 0111 0000 1000 1111 = 0x708F
full 0100 0000 1011 1111 = 0x40BF
power 0000 0000 1111 1111 = 0x00FF

Not bad for a start, now to integrate these into some arduino code, adjust the timings of the code, and hook up an IR led.

edit: corrected 24 to 12 button

Last edited by mattinmd; 03-24-2015 at 11:38 AM. Reason: corrected 24 button to 12
mattinmd is offline

Old 03-24-2015, 03:44 AM
Banned

Join Date: Jun 2013
Location: WI
Posts: 11,794
From a laymans almost total lack of understanding this part of programming but as a cursory glance.. the hex or binary numbering has no logical rhyme or reason..
I freely admit I could be wrong though..

Suspended for 30 days for being awful to other forum members
jeffkrol is offline
Old 03-24-2015, 11:47 AM Thread Starter
Planted Tank Guru

Join Date: Aug 2014
Location: Maryland, USA
Posts: 2,339
There's not a whole lot of sense to the order at first glance, but there is a pattern.

First observation is only the first hex digit is used. After the first hex digit, the next digit is always 0, and the next two digits are the first two bit-inverted..

So the table could be simplified to:

10% = 0x2
20% = 0xA
30% = 0x6
40% = 0x1
50% = 0x9
60% = 0x5
70% = 0x3
80% 0xD
90% = 0x7
full = 0x4
power = 0x0

Now if you re-order the bits backwards:
10% = 0x4
20% = 0x5
30% = 0x6
40% = 0x8
50% = 0x9
60% = 0xA (=10)
70% = 0xC (= 12)
80% = 0xD (= 13)
90% = 0xE (= 14)
full = 0x2
power = 0x0

New to planted tanks, avid gardener/tinkerer.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Fluval C4 + Quietflow 30, Finnex Planted+ with
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
, low-tech.
10 gallon secondary tank with Finnex stingray with
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
, AC20, low tech

Last edited by mattinmd; 03-24-2015 at 01:03 PM. Reason: corrected lack of decimal to hex conversion...
mattinmd is offline

Old 03-26-2015, 03:30 AM Thread Starter
Planted Tank Guru

Join Date: Aug 2014
Location: Maryland, USA
Posts: 2,339
Ok, so some more work on this..

Looking at Shriff's IRremote code the bit timings aren't exactly matching any protocol they have.. It's close to sony though..

This is the timing for the sony:
#define SONY_HDR_MARK 2400
#define SONY_HDR_SPACE 600
#define SONY_ONE_MARK 1200
#define SONY_ZERO_MARK 600

But the superknight is more like:

#define SK_HDR_MARK 4400 //much longer, almost 2x
#define SK_HDR_SPACE 600 // same

But I'm wondering if the sony protocol works, and it is just the transmitter not quite doing it right...

I guess I'm going to have to give it a shot with the sony TX..

The code currently does sony codes most-significant bit first, so my original hex codes would be the ones to try, not the bit-reversed ones.

That said they'll need to be done as 32-bit codes with the 0x40FF stuck in front of each one...

New to planted tanks, avid gardener/tinkerer.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Fluval C4 + Quietflow 30, Finnex Planted+ with
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
, low-tech.
10 gallon secondary tank with Finnex stingray with
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
, AC20, low tech
mattinmd is offline
Old 03-27-2015, 03:44 AM Thread Starter
Planted Tank Guru

Join Date: Aug 2014
Location: Maryland, USA
Posts: 2,339
Ok, so I ended up using IRDump from
https://github.com/shirriff/Arduino-IRremote

However, there were some trials and tribulations. Arduino ships with an old recieve-only version of IRremote as a part of RobotIRRemote..

On my system it lived in C:\Program Files (x86)\Arduino\libraries\RobotIRremote and I just renamed IRremote.cpp, IRremote.h and IRremoteInt.h to have _robot in their names. I don't really care about this library, so who cares if I break it, right?

So, using IRDump, I found out it is really NEC encoded...

I also found a few errors in my codes, and decoded the flash buttons too..

I used IndyChu's SendCode() function from:
https://www.plantedtank.net/forums/sh...d.php?t=391265

Regardless, I was able to do a small demo that did 10% 90% 20% 80% on a repeating cycle with 3 seconds between as a quick test.. worked great..
Attached Files
 File Type: txt transmitter.txt (1.3 KB, 28 views)

New to planted tanks, avid gardener/tinkerer.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Fluval C4 + Quietflow 30, Finnex Planted+ with
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
, low-tech.
10 gallon secondary tank with Finnex stingray with
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
, AC20, low tech
mattinmd is offline
Old 04-01-2015, 01:46 AM Thread Starter
Planted Tank Guru

Join Date: Aug 2014
Location: Maryland, USA
Posts: 2,339
So, some retrospective lessons learned, now that I've had a chance to think about things a bit:

1) when decoding an IR remote, get the latest IRDump from shirriff and try that first.. Only use the arduino.cc method if that doesn't work... I spent a lot of time messing with gnuplot just to decode all the buttons correctly in 10 minutes using IRDump. Doh...

2) Arduino comes with an outdated copy of IRremote in the RobotIRremote. This is an annoying namespace conflict, but can be worked around.

Also for reference, if you don't want to download the .txt above, the codes for the superknight are as follows (designed to work with indyChu's SendCode):

unsigned long codeHeader = 0x40FF; // Always the same

#define SK_PCT_10 0x20DF
#define SK_PCT_20 0xA05F
#define SK_PCT_30 0x609F
#define SK_PCT_40 0x10EF
#define SK_PCT_50 0x906F
#define SK_PCT_60 0x50AF
#define SK_PCT_70 0x30CF
#define SK_PCT_80 0xB04F
#define SK_PCT_90 0x708F
#define SK_PCT_FULL 0x40BF
#define SK_POWER 0x00FF
#define SK_FLASH 0x08F7
#define SK_FLASH_UP 0x8877
#define SK_FLASH_DOWN 0x48B7

New to planted tanks, avid gardener/tinkerer.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Fluval C4 + Quietflow 30, Finnex Planted+ with
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
, low-tech.
10 gallon secondary tank with Finnex stingray with
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
, AC20, low tech
mattinmd is offline

 Tags None

Message:
Options

## Register Now

In order to be able to post messages on the The Planted Tank Forum forums, you must first register.

User Name:
OR