Remote Control Power Sockets: Part 2: Oscilloscope Protocol Analysis

Tools and materials

Anyone who has read the first post of this series already knows: we want to replace the remote control of these devices with a low-cost 433 MHz transmitter and a microcontroller platform. To do so, the microcontroller has to reproduce the protocol that the remote control encoder PT2262 sends. From the previous post we also know that at the press of a button the PT2262 generates a unique codeword and sends it to the RF modulator. The datasheet says:

The encoded waveform is serially outputted to this pin. When PT2262 is not transmitting, DOUT outputs low (Vss) voltage.

So that we can replace the remote control with our own circuit, controlled by a microcontroller, we determine the codeword of each button.

Oscilloscope

Oscilloscope: signal at DOUT

The most convenient way to analyse the protocol of the remote control is with an oscilloscope. A low-cost one like the Rigol DS1052e is more than enough. Anyone who cannot afford one need not worry: in a later post we show a cheaper way to get to the bottom of the protocol.

Connection

We connect the ground clip of the probe to pin 9 (VSS) of the HX2262 and the probe tip to pin 17 (DOUT).

Rigol DS1052E settings

  • Long Memory (Acquire -> MemDepth -> Long Mem)

  • Single-shot trigger

Determining the oscillating clock period α

Oscilloscope: waveform of a "0" bit

From the datasheet we already know that each bit waveform consists of two pulse cycles and each pulse cycle spans 16 oscillating clock periods. A bit "0" therefore consists of four periods high, twelve periods low, four periods high and another twelve periods low. We find this pattern easily with the oscilloscope.

The picture on the left shows the total time (2.8 ms) for a "0" bit:

\begin{equation*} \alpha = \frac{2800\,us}{32} = 87.5\,us \end{equation*}
Oscilloscope: duration of four clock periods

The picture on the right shows the high part of the first pulse cycle (4 periods high) with a total time of 350 µs:

\begin{equation*} \alpha = \frac{350\,us}{4} = 87.5\,us \end{equation*}
Oscilloscope: duration of twelve clock periods

The picture on the left shows the low part of the first pulse cycle (12 periods low) with a total time of 1050 µs:

\begin{equation*} \frac{1050\,us}{12} = 87.5\,us \end{equation*}

From these three results we take 87.5 µs as the oscillating clock period α. According to the datasheet, a resistor between pins 15 (OSC 1) and 16 (OSC 2) sets α, so the value can differ for other sockets. We had better not hard-code it.

Oscilloscope: period at pin OSC 1

There is a more direct way: we put the probe tip on pin 15 (OSC 1) and measure the oscillator frequency. The next picture on the right shows the duration of one oscillator cycle. The measured period of 87.6 µs fits our assumption of 87.5 µs perfectly.

Codeword analysis

A group of Code Bits is called a Code Word. A Code Word consists of 12 AD bits followed by one Sync Bit.

Structure of a codeword of 12 AD bits and one sync bit

In Part 1 of this series we assumed that the first five bits encode the socket group part of the codeword, the next five the socket within that group and the last two the on/off part. This is easy to check: we press the matching push-button on the remote control and look at the waveform on the oscilloscope. As a starting point, we set all pins of the DIP switch (A0 to A4) to off (socket group 0) and press the on and the off push-button for each socket of this group.

Each of the following image series shows a complete codeword that a press of the on or off push-button produces for a different combination of group and socket. Some signal transitions overlap; we look for the bit patterns that we already know from the datasheet. Each picture (except the last one) contains four bit patterns. Together that makes 12 AD bits followed by one sync bit. Then we split each codeword into its parts: group (five bits), socket (five bits) and data (two bits).

Socket group 0 | Socket 1 | On

The on push-button for socket 1 in group 0 produces this codeword:

Oscilloscope: codeword group 0, socket 1, on, picture 1 of 4Oscilloscope: codeword group 0, socket 1, on, picture 2 of 4Oscilloscope: codeword group 0, socket 1, on, picture 3 of 4Oscilloscope: codeword group 0, socket 1, on, picture 4 of 4

Codeword: FFFF F0FF FF0F Sync

Group

Socket

On/Off

FFFFF

0FFFF

0F

Socket group 0 | Socket 1 | Off

The off push-button for the same socket (1) in the same group (0) gives a very similar result: only the last two bits differ.

Oscilloscope: codeword group 0, socket 1, off, picture 1 of 4Oscilloscope: codeword group 0, socket 1, off, picture 2 of 4Oscilloscope: codeword group 0, socket 1, off, picture 3 of 4Oscilloscope: codeword group 0, socket 1, off, picture 4 of 4

Codeword: FFFF F0FF FFF0 Sync

Group

Socket

On/Off

FFFFF

0FFFF

F0

Socket group 0 | Socket 2 | On

The next image series shows the result for the on push-button of socket 2 in group 0. This time the socket part of the codeword changes, while the group part stays the same.

Oscilloscope: codeword group 0, socket 2, on, picture 1 of 4Oscilloscope: codeword group 0, socket 2, on, picture 2 of 4Oscilloscope: codeword group 0, socket 2, on, picture 3 of 4Oscilloscope: codeword group 0, socket 2, on, picture 4 of 4

Codeword: FFFF FF0F FF0F Sync

Group

Socket

On/Off

FFFFF

F0FFF

0F

Socket group 1 | Socket 1 | On

If we set the first DIP switch to "on" and press the on push-button for socket 1 again, we get a different codeword. This time the first bit group changes.

Oscilloscope: codeword group 1, socket 1, on, picture 1 of 4Oscilloscope: codeword group 1, socket 1, on, picture 2 of 4Oscilloscope: codeword group 1, socket 1, on, picture 3 of 4Oscilloscope: codeword group 1, socket 1, on, picture 4 of 4

Codeword: 0FFF F0FF FF0F Sync

Group

Socket

On/Off

0FFFF

0FFFF

0F

Socket group 31 | Socket 1 | On

The last image series shows the codeword when all DIP switches of the remote control are on (group 31) and we press the on push-button for socket 1.

Oscilloscope: codeword group 31, socket 1, on, picture 1 of 4Oscilloscope: codeword group 31, socket 1, on, picture 2 of 4Oscilloscope: codeword group 31, socket 1, on, picture 3 of 4Oscilloscope: codeword group 31, socket 1, on, picture 4 of 4

Codeword: 0000 00FF FF0F Sync

Group

Socket

On/Off

00000

0FFFF

0F

The combinations above show a clear pattern: groups and sockets are binary-coded, the first bit of each part is the LSB, the fifth the MSB. A cleared bit gives an "F" waveform, a set bit a "0" waveform.

Conclusion

The assumptions from Part 1 of this series appear to be correct. A codeword consists of five bits for the socket group, five bits for the socket within this group and two bits for the on/off part.

We measured the time base of the codeword (oscillating clock period α) with the oscilloscope: it is 87.5 µs.