The Tonto Project

Version 1.48
Share |

IR Waveforms and Cleaning Codes

An excellent introduction to IR waveforms and the Pronto Hex format by Barry Gordon can be found here.

Tonto's IR Database format

A sample from the database might looks something like this:

[Universal,RCA,DirecTV HD Satellite]
  Mute        = 1;S;58250;16500,2000,8250,4000,39500;;24,111100111111000011000000,f3f0c0,13,12,00,14;1
  Who         = 1;S;58250;16500,2000,4000,8250,39500;;24,011101100001100010011110,76189e,12,13,00,14;1
  Fetch       = 1;S;58250;16500,2000,4000,8250,39500;;24,011110010011100001101100,79386c,12,13,00,14;1
  GoBack      = 1;S;58250;16250,2000,4000,8250,39500;;24,011100100111100011011000,7278d8,12,13,00,14;1
  CH+         = 1;S;58250;16500,2000,4000,8250,39500;;24,011100101101100011010010,72d8d2,12,13,00,14;1
  CH-         = 1;S;58250;16500,2000,4000,8250,39500;;24,011100101100100011010011,72c8d3,12,13,00,14;1
  VOL+        = 1;S;58250;16500,2000,8250,4000,39500;;24,111100101111000011010000,f2f0d0,13,12,00,14;1
  VOL-        = 1;S;58250;16500,2000,8250,4000,39500;;24,111100101110000011010001,f2e0d1,13,12,00,14;1
  Guide       = 1;S;58250;16500,2000,4000,8250,39500;;24,011100011010100011100101,71a8e5,12,13,00,14;1
  Info        = 1;S;58250;16500,2000,4000,8250,39500;;24,011100111100100011000011,73c8c3,12,13,00,14;1
  Menu        = 1;S;58250;16500,2000,4000,8250,39500;;24,011100001000100011110111,7088f7,12,13,00,14;1
  Clear       = 1;S;58250;16500,2000,4000,8250,39500;;24,011100000110100011111001,7068f9,12,13,00,14;1
  Arrow-Up    = 1;S;58250;16500,2000,4000,8250,39500;;24,011101011001100010100110,7598a6,12,13,00,14;1
  Arrow-Down  = 1;S;58250;16500,2000,4000,8250,39500;;24,011101011000100010100111,7588a7,12,13,00,14;1
  Arrow-Left  = 1;S;58250;16500,2000,4000,8250,39500;;24,011101010110100010101001,7568a9,12,13,00,14;1
  Arrow-Right = 1;S;58250;16500,2000,4000,8250,39500;;24,011101010111100010101000,7578a8,12,13,00,14;1
  OK          = 1;S;58250;16500,2000,4000,8250,39500;;24,011111110100100000001011,7f480b,12,13,00,14;1
  Key-1       = 1;S;58250;16500,2000,4000,8250,39500;;24,011100110001100011001110,7318ce,12,13,00,14;1
  Key-2       = 1;S;58250;16500,2000,4000,8250,39500;;24,011100110010100011001101,7328cd,12,13,00,14;1
  Key-3       = 1;S;58250;16500,2000,4000,8250,39500;;24,011100110011100011001100,7338cc,12,13,00,14;1
  Key-4       = 1;S;58250;16500,2000,4000,8250,39500;;24,011100110100100011001011,7348cb,12,13,00,14;1
  Key-5       = 1;S;58250;16500,2000,4000,8250,39500;;24,011100110101100011001010,7358ca,12,13,00,14;1
  Key-6       = 1;S;58250;16500,2000,4000,8250,39500;;24,011100110110100011001001,7368c9,12,13,00,14;1
  Key-7       = 1;S;58250;16500,2000,4000,8250,39500;;24,011100110111100011001000,7378c8,12,13,00,14;1
  Key-8       = 1;S;58250;16500,2000,4000,8250,39500;;24,011100111000100011000111,7388c7,12,13,00,14;1
  Key-9       = 1;S;58250;16500,2000,4000,8250,39500;;24,011100111001100011000110,7398c6,12,13,00,14;1
  Key-0       = 1;S;58250;16500,2000,4000,8250,39500;;24,011100110000100011001111,7308cf,12,13,00,14;1
  Input       = 1;S;58250;16500,2000,4000,8250,39500;;24,011110100011100001011100,7a385c,12,13,00,14;1
  Antenna     = 1;S;58250;16500,2000,4000,8250,39500;;24,011100000101100011111010,7058fa,12,13,00,14;1
First, each section has a header in the form

[Model,Company,Description].

Each line following this is the name of a 'key' followed by '=' and an IR signal encoding. This signal encoding is a ';' (semicolon) delimited set of fields. Subfields inside of fields are delimited with ',' (comma). The IR signal fields are:

version ; type ; frequency base ; pulse index ; intro sequence ; repeat sequence ; repeat count

Before going much further, you need to understand a little more about basic IR codes. It's instructive to read Barry's article linked above. But in a nutshell, an IR signal usually has two basic components: 1) an introductory pulse sequence and 2) and a repeat sequence. The intro sequence is sent as soon as the button is pushed. This is followed by the repeat sequence which keeps being repeated as long as the button is pressed. Each sequence is sent at least once. This is useful when understanding the 'type' field.

'Version' is always 1.

'Type' is one of 'S', 'F', or 'N'. 'S' is 'Standard' which means the intro and repeat are sent normally. 'F' is 'Repeat Full' which means the intro and repeat will both be repeated. 'N' is 'Repeat None' which means the intro and repeat will only be sent once each. Almost all signals will be of type 'S'.

'Frequency Base' is the carrier frequency of the IR signal. Use "0x400000 / pronto-frequency" to get the number used by Tonto.

'Pulse Index' is the list of pulse timings used in the intro and repeat segments. The first number is 0. So a Pulse Index of '1000, 2000, 3000, 4000' and a intro sequence of '01020101' could be decoded as '1000 2000 1000 3000 1000 2000 1000 2000'. The value of a pulse index is equivalent to the "pronto-frequency * the pronto-time-value". From below, the pronto-frequency would be 0x0048 and the pronto-time-value might be 0x00e5.

'Intro Sequence' and 'Repeat Sequence' are both in the same format. Each is divided into a number of sub-fields separated by ',' (comma). The intro and repeat fields are optional and may be empty as in the example above. The fields in the sequences are:

numbits , bit pattern , hex value , zero pulse , one pulse , header , trailer

The 'numbits' and 'hex value' fields are ignored and only used for visually examining a sequence of codes.

'numbits' is the number of bits in the bit pattern.

'bit pattern' is the sequence of on/off pulses pairs that is de-referenced using the 'zero pulse' and 'one pulse' fields.

'hex value' is literally the hex value of the bit pattern.

'zero pulse' is a set of two 'pulse index' values that represent a logical 'zero' in the IR code.

'one pulse' is a set of two 'pulse index' values that represent a logical 'one' in the IR code.

'header' is a set of one or more 'pulse index' values that is the prefix to the IR value segment.

'trailer' is a set of one or more 'pulse index' values that is the postfix to the IR value segment.

How to apply this practically

Take the following Pronto IR code as an example. Here is another place where reading Barry's article is helpful.

0000 0048 0000 001a 00e5 00e5 001b 0072
001b 0072 001b 0072 001b 0072 001b 0037
001b 0037 001b 0072 001b 0072 001b 0072
001b 0072 001b 0072 001b 0072 001b 0037
001b 0037 001b 0037 001b 0037 001b 0072
001b 0072 001b 0037 001b 0037 001b 0037
001b 0037 001b 0037 001b 0037 001b 0224
'0000' means learned code. '0048' is the frequency of the IR signal. The next '0000' is the length of the intro signal. In this case, there is none. '001a' is the length of the repeat field. In this case it's 26 in decimal. That means the next 52 'xxxx' hex fields are to be decoded as the on/off pulse lengths of the repeat sequence.

You'll immediately notice that the repeat sequence has a lot of fields with the same values. If we take each unique number and assign it an index, we will get something like this:

Then we can re-write the repeat sequence as '00 12 12 12 12 13 13 12 12 12 12 12 12 13 13 13 13 12 12 13 13 13 13 13 13 14'. Most the values are either '12' or '13' so we will call them bit zero and bit one to generate the hex value. The prefix and postfix are then neatly '00' and '14'. This happens to be the 'Mute' key from the above database example. The sequence of '12' and '13' turns into a bit pattern that is the hex value of that key.

There are actually some subtleties to all of this. All of the codes for this remote share the same number of bits in a code, the same prefix and postfix and the same pulse indexes. If you look closely, you will also notice that the first 12 bits and the last 12 bits are inversions of each other. This is one way that the receiving end can validate that the code was not corrupted during transmission. It also means that there are really only 2^12 possible code that this signal can encode.

There are some shortcomings to this encoding strategy. The most prominent is that it cannot, in it's current form, capture codes with toggle bits. That's on the todo list. The advantage is that it makes it really easy to spot patterns and find hidden codes.

Hope that helps a little.