Close

OpenIR Software Design Update

A project log for OpenIR - Infrared Remote Control

Open source universal infrared remote control based upon the STM8S microcontroller with oooodles of connectivity options.

nevynNevyn 01/04/2015 at 10:430 Comments

Revision A of the board is now working and can send a single IR sequence out to a device in the real world when the on board switch is pressed. If OpenIR is to be truly universal the system needs to be able to send a multitude of commands not just a single command. In order to do this we need to be able to store IR command sequences and also allow the user to select which IR sequence is transmitted.

The STM8S has been set up to connect the TTL serial port to the FTDI and RedBear BLE board ports. Doing this allows communication with the outside world (PC, iPhone etc.). The proposed solution uses the serial TTL port to send commands to the STM8S and for the STM8S to store details of the IR signals (carrier frequency, active period etc.) in the on chip EEPROM.

The chip along with the chosen have a limit built into them, the fact that the free version of the IAR tools have an 8 KByte limit. This limits what can be achieved on the STM8S microcontroller.

Serial Commands

The STM8S will listen on the serial TTL port for commands from the outside world. The following list of commands are proposed as a starting point:

Command IDDescription
1Get Remote control ID. This returns a text string which identified the remote control.
2Set the remote control ID.
3Get the carrier frequency. This gets the two bytes which are used by Timer 1 to determine the frequency of the PWM signal.
4Set the carrier frequency. This set the two bytes which are used by Timer 1 to determine the frequency of the PWM signal.
5Get the contents of the EEPROM pulse data store.
6Set the contents of the EEPROM pulse data store on the STM8S.
7Transmit pulses for sequence number x where x is the item in the payload.
8Transmit pulses. This transmits and arbitrary sequences of pulses which are contained in the remainder of the payload.
9Time Lapse mode. Send the pulses for sequence x after y seconds.
10Reset the remote control.
11Enable or disable the on board power LED.

A close look at the above shows that commands 1, 3 and 4 are related as are commands 2, 4 and 6. They are either getting or setting blocks of memory in the STM8S EEPROM. Given the reduced memory available and the limits of the tools it may be optimal reduce this to reading and writing the contents of the EEPROM. The configuration data would be processed on a device with more memory (PC, iPhone etc.) and the EEPROM image built and transmitted to the STM8S. The STM8S then simply needs to update the EEPROM. The final command set becomes:

Command IDDescription
1Get the contents of the EEPROM.
2Set the contents of the EEPROM on the STM8S
3Transmit pulses for sequence number x where x is the item in the payload.
4Transmit pulses. This transmits and arbitrary sequences of pulses which are contained in the remainder of the payload.
5Time Lapse mode. Send the pulses for sequence x after y seconds.
6Reset the remote control.
7Enable or disable the on board power LED.

Layout of the EEPROM

The STM8S on the EEPROM stores the configuration of the remote control. The data stored is a mixture of basic configuration along details of the pulses for each command the remote control can transmit.

OffsetLengthDescription
0x0016Text ID of the remote control
0x102Two bytes which are used by Timer 1 to determine the frequency of the carrier signal. The carrier signal is assumed to be 50% duty cycle.
0x121Number of command sequences stored in the EEPROM.
0x131Number of seconds to use for the time lapse sequence.
0x1412Unused
0x2064Length of the pulse sequences (0x20 = length of sequence 0, 0x21 = length of sequence 1 etc.).
0x40512Pulse data. It is assumed that the pulse sequences will start with an on period followed by and off period until the number of sequences have been consumed.

Conclusion

The basic layout of the EEPROM has been determined along with a proposed command sequence. The next step is to implement the STM8S code and some sample Windows code to configure the remote control.

Discussions