Main menu

Implement Yourself

This page is only for those who do not want to use the prebuilt module. The prebuilt module is recommended since it takes care of all the communication and the decoding of the IR signals. If you make your own implementation it is important to keep in mind that your system needs to be stable and should always be able to decode the IR signals even if you main CPU hangs or go into deadlock. This is crucial since the kill switch should always be operative.

Implement the remote start and kill switch by yourself
If you prefer to implement everything by yourself you can follow the documentation on this page.

Hardware

Hardware remote start
The hardware of the remote start system fairly simple: it is mainly a 38khz IR receiver connected to one of the I/O pins on the microcontroller. Any standard 38Khz IR receiver should do, you can find two examples here: Vishay, Vishay at sparkfun. In the datasheets of the components you can also find examples of how to use the receiver and what additional components that is necessary (usually the receiver requires a resistor and a capacitor).

Status LED
The contestant have to provide a LED, display or something similar that can give feedback of what state the robot is in.

Input and output pins
The microcontroller will have to provide at least total of 2 I/O pins (3 for the 3kg class): 1 input pin for the IR receiver and 1 output pin for the LED. For the 3kg class, at least one additional output for the kill switch circuit is needed.

Software

The microcontroller to which the IR receiver is connected have to take care of the reading the commands from the receiver. The commands are sent using the standard RC-5 protocol.

The 5 bit address will be fixed which means the system will listen for a RC-5 signal only with this pre-decided address. The next 5 bits in the command will tell which dohyo the signal belongs to and the last bit will tell if the robot is suppose to start or stop. A one means start and a zero means stop. To change what dohyo identifier to listen for a programming command is sent. This package will consist of a fixed system address (the programming address) and the new stop command.

The fixed address used for starting and stopping the robots: 0×07 (hexadecimal)

Caution: The implentation of the RC-5 communication is usally done with very cheap components therefore the timing is never perfect. This have to be considered when designing the code, such as adding a tolerance for the the lengths of bits. Consult the source code examples listed in the end for further details.

Non-volatile memory
The microcontroller should save the current state in a non-volatile memory. This is to ensure robustness of the system. If the microcontroller should reset it will then return to the last saved state (in the same way the prebuilt module works).

Source code
Source code can be found on Github under Source, look at the “Generic” examples.

Example of operation

Here follows a short example of operation, which is an example of how an implementation should work. It goes through start, stop and program.

Your robot receives an RC-5 package when in Power-ON or Started state with the following data:

At this point, the robot should go into Power-ON state and wait for a start command (even if the current state was Started). The robot should also stop its motors. Remember to save this state and the stopCommand into a non-volatile memory. The robot should also signal that it has been programmed by blinking an LED 2 times quickly (about 500ms between each blink).

Next, your robot receives an RC-5 package when in Power-ON state with the following data:

rc5Address = 0×07 (Competition system address, also defined in the standard as Experimental)

This means that your robot must stop, since the stop command is received. Shut off your motors, set your state to STOPPED and save it to the non-volatile memory. Your robot should also indicate that it’s in stopped by blinking an LED slowly. It should not listen to any further commands until it has gone through a power cycle.

When your robot boots, it should read the current state and stopCommand from the non-volatile memory and calculate the startCommand as:startCommand = stopCommand +1; //for instanceIt should also restore its behaviour according to the current state. If the current state is Stopped, simple set the current state to Power-ON and proceed as normal.

To make the code more secure, you should add an exception case for when the data read is not any of the allowed states (which could happen after programming or if the memory has become corrupt for some reason for instance).

Quick reference

This is intended as a quick-check to see if your implementation complies with the remote-start system. To comply, your implementation should…

Decode RC-5 signals using 38kHz carrier frequency.

Listen to commands only sent on the predefined addresses (see “software” above).

Signal the current state, preferably using at least an LED as described for the prebuilt module.

Be able to be listen to different start commands used at different dohyos (it should support “programming”).

For anyone making the remote – you should use the Atmega168PA. I first tried with the Atmega48 which is listed as an alternative chip in the componentlist, but couldn’t get the .hex file from GitHub to work until I switched over to Atmega168PA-AUR.

For programming the remote (using an USB ASP from ebay) I used the command;

avrdude -c usbasp -p m168 -F -U flash:w:remoteControl.hex

When you include the crystal (I used 8MHz, mouser part: 559-FOXS080-20-LF), which is listed as optional in the component list, you should not have to change the fusebits.