Infrared IO "explorer"

NEC protocol mode using universal remote and also transmitting back to itself.

RC5 protocol using a universal remote and also reflecting IR back to itself. RC5 mode forces the stop bits (13, 14) to 1.

RC5 has a “toggle” bit.

  • When holding a button down the toggle bit doesn’t change.
  • When pressing multiple times it flips each time.

In the screenshot I’m pressing the “1” button (command 1). Each time I press the toggle bit flips 1/0. If I hold the button it repeats and the toggle bit stays the same. This remote will only repeat the numbers buttons 3 times and then stops. It will repeat the volume and channel buttons indefinitely.

.define public TICKS_PER_LOOP 16         ; the number of instructions in the loop (for timing) **2samples per bit = 16 not 8**
.define public NUM_BITS 14               ; the number of bits to receive per frame
.wrap_target
get_bit:
    in pins, 1 [6]       ; Read the bit, sleep 3/4 of a bit
    jmp y-- get_bit      ; collect all the bits
public entry_point:
    set y ((NUM_BITS*2)-2)  ; initialize the bit counter, with some delay to avoid triggering on previous bit
    in x, 1             ; Insert the invisible first half of the start bit
    wait 0 pin 0 [2]       ; Wait for the 1->0 transition - this is the middle of the start bit   
.wrap

Every time I use a PICO SDK PIO example it is just too cute to function in the real world. Manchester decoding example works great as a demo, but in the real world waiting on pin state changes mean we get hopelessly out of sync and stuck in the state machine.

After a day of messing with it I decided to use the PIO to sample each half bit of the manchester encoded signal, then process the result in the firmware. This is more like a UART now. Advantages:

  • No longer get stuck waiting for pin changes during invalid signals
  • Inherent timeout and reset feature
  • Firmware does the manchester decoding, so we can detect invalid/bad encoding and reject the data as invalid

I’m going to push this now. Would welcome feedback from anyone with the IR Toy plank.

2 Likes