TOAD vs Discrete Codes

From LinuxMCE
Jump to: navigation, search

The goal of LinuxMCE media is to let the homeowner press 1 button, such as 'watch tv', and have LinuxMCE automatically turn on all the necessary a/v equipment and adjust all the settings automatically. Sometimes the manufacturers of a/v equipment had the foresight to build into their products a mechanism for a smart home system, like LinuxMCE, to control their devices automatically. These devices have a computer connection like RS232 or Ethernet. They will always work exceptionally well in a LinuxMCE home. LinuxMCE can command the a/v to do anything.

Very few a/v manufacturers put this type of control in their devices, and therefore LinuxMCE must control the equipment by sending infrared codes just like you do when you hit the button on your remote control. The problem is that some a/v devices were designed in such a way that only a human operator can control them. For example, to select an input on many TV's the operator must press an 'input select' button on the remote control and watch the display on the TV until they see the input they want. If LinuxMCE needs to set your TV to 'INPUT #3', it's impossible for LinuxMCE to 'watch' the screen and know when the TV is at the right input. Fortunately, some manufacturers added what are called 'discrete codes' to their TV. This means that there is an infrared command that will cause the TV to go directly to Input #3, for example, no matter what input it is currently on. There may not be a button for Input #3 on the remote--you may still have to use the toggle 'input select' button--but the TV has a special code that will cause it to go directly to that input. Sony brand TV's are an example. Even though there is only a toggle 'input select' button on the remote, there are infrared commands that LinuxMCE can send to make the TV go directly to the desired input. These are called 'discrete codes'.

The same thing is true with turning the device on and off. Some remote controls have dedicated 'on' and 'off' buttons. But others have only a 'power' button that toggles the state, and the manufacturer expects you, the user, to watch what's on the TV and decide if it's on or off.

If you are going to buy new a/v equipment we recommend that you only buy devices that have computer-type controls, like RS232, or, at least, recognize discrete codes. There are several web sites like that have a lot of information on this subject and recommendations for equipment that have discrete codes.

If your device does not recognize discrete codes, it is referred to in the industry as a TOAD (Toggle Only Analog Device). It just recognizes commands that toggle it's state, such as the input or power. LinuxMCE will still control these devices but due to their nature, it is impossible to control them perfectly. For example, you will need to go to the A/V Properties page and list all the inputs that your device has in the right order. LinuxMCE will then 'remember' what input it last left the device on, and send the appropriate number of toggle commands. If LinuxMCE last turned the device to Input #1, and you now want to watch something on Input #4, LinuxMCE will send the input select command 3 times. This is not a perfect system. If someone manually changed the input, or if the device ever didn't recognize a code, it could get out of sync. LinuxMCE may think it's on one input when it's really on another.

The same thing is true for the power. If your device has only a toggle power button, LinuxMCE will remember if you left the device on or off so it knows when to send the toggle power command. But if LinuxMCE gets out of sync, it could be turning the TV off when it really thinks it's turning it on. For the power setting, at least, your LinuxMCE Pro dealer has lots of tricks they can use to work around this problem. There are sensors that LinuxMCE can read to determine if the TV is on or off, for example.

Semi-Discrete Inputs

There is a common type of input that is almost a hybrid of these two, which I will call semi-discrete for lack of a better term. For example, a TV may require that you press the input button and then press [2] to reach the Component 1 input (while continuing to press input may start to toggle through inputs). In this scenario, you may be able to combine the IR codes to achieve discrete inputs. To do this, you will need the two IR codes you want to combine (e.g., [Input] and [4] codes). Here are some example snippets:

[Input]:   0000 006F 0000 0032 0081 0041 ... (lots more)
[4]:       0000 0071 0000 0032 0080 003f ... (lots more)

There is a lot more information at this article, but the important thing is that the first four groups (words) in each code is essentially a header, and the rest is the data. Specifically, the fourth word is the size of the data section, so to combine these you would use one of the headers (updating the size) and both of the data portions. In the examples above, the size field for both codes is 0x32 (50 in decimal), so the new size would be 0x64 (100 decimal). Your resulting code would look like this:

[Input 4]: 0000 006F 0000 0064 0081 0041 ... (lots more) ... 0080 003f ... (lots more)

Note that this worked for my TV (Panasonic PT-52LCX66). I'm not sure if this capability of handling combined IR codes like this is specific to the hardware, so please update this article if your experience differs.

Edit January 21st 2012

Manufactures that do have a value assigned to the third word which is the length of the One Time Burst, this value needs to be doubled when combining the codes, experienced with a Toshiba 24SL410U This fix was provided by phenigma on the forum to a topic opened [1]

Original Code

[Input]:   0000 006D 0022 0002 0156 00AB ... (lots more) ... 0056 0015 0E4E
[4]:       0000 006D 0022 0002 0156 00AB ... (lots more) ... 0056 0015 0E51

Thus combining, would require doubling the third (3) group and the fourth (4) group, thus the new code will read Combined

[Input 4]: 0000 006D 0044 0004 0156 00AB ... (lots more) ... 0056 0015 0E4E 0156 00AB ... (lots more) ... 0056 0015 0E51

This worked for a Toshiba 24SL410U