Update: Added new video.
What if your robot is stucked and can't free itself?
Take back the control and steer your robot out of trouble.
What if some danger approaches your robot and no sensor detects it?
Take back the control and move away.
This tip shows you how to use a PicooZ infrared remote control with an Arduino. Having a chance to remote control your robot can be an ace in your hand so if you want to give it a try - read on.
Look at the incoming binary pattern
Reading in IR data is straight forward. Use an three leg IR detector like this one and wire it like shown here. Use this code to detect the signals and transform into an int array with LOW and HIGH bits and their microseconds pulse durations.
Find the start of the protocol in the binary pattern
The PicooZ protocol is described here. Expect the following binary pattern from the remote control: ( H is High and L is Low )
HLHLHLHLHLHLHLHLHLHLHLHLHLHLHLHLHLHLHLHLHL
1. | HL | Header |
2. | HLHLHLHL | ID |
3. | HLHL | Channel |
4. | HLHLHLHL | Throttle |
5. | HLHLHLHL | Yaw Trim |
6. | HLHLHL | Yaw Control |
7. | HLHL | Check Sum |
8. | HL | Stop Bit |
Capture the protocol on/off durations
Using this code you can monitor the on/off durations and get orientation inside the protocol. For a robot the directions FORWARD, LEFT, RIGHT and STOP may be a good start ability so we need to find the position and binary setting for these directions. Capture each direction in an int array for further use.
FORWARD | LEFT |
int IRsignal_FORWARD_FULL_ChannelA[] = { // ON, OFF (in 10's of microseconds) 192, 54, 70, 54, 70, 54, 116, 62, 112, 62, 62, 48, 62, 50, 112, 110, 110, 110, 112, 110, 64, 48, 62, 50, 62, 48, 62, 50, 62, 48, 62, 50, 62, 48, 64, 48, 118, 102, 116, 104, 66, 4182} |
int IRsignal_LEFT_ChannelA[] = { // ON, OFF (in 10's of microseconds) 190, 54, 70, 54, 70, 54, 116, 60, 114, 62, 62, 48, 62, 50, 62, 50, 62, 48, 62, 50, 62, 48, 62, 50, 62, 48, 64, 48, 62, 50, 110, 112, 62, 48, 112, 110, 60, 50, 60, 50, 66, 4084} |
RIGHT | STOP |
int IRsignal_RIGHT_ChannelA[] = { // ON, OFF (in 10's of microseconds) 190, 56, 70, 54, 70, 54, 116, 60, 114, 60, 64, 48, 62, 50, 62, 48, 62, 50, 62, 50, 62, 48, 62, 50, 62, 48, 62, 50, 62, 48, 64, 48, 112, 110, 112, 110, 116, 102, 60, 50, 66, 4074} |
int IRsignal_STOP_ChannelA[] = { // ON, OFF (in 10's of microseconds) 188, 56, 70, 54, 70, 54, 116, 60, 114, 62, 62, 48, 62, 50, 62, 48, 64, 48, 62, 50, 60, 50, 62, 50, 62, 48, 62, 50, 62, 48, 64, 48, 62, 50, 62, 50, 58, 52, 58, 52, 66, 4078} |
Make pattern matching with your code
Using the patterns above you now can feed your controller. Basically your code reads from the IR until all expected pulses are arrived. There is a maximal no-signal duration of about 4180ms that is a strong indicator of a finished transmission. Then go on and match the new array with the FORWARD, RIGHT, LEFT and STOP arrays. Whatever matches is the direction to go for your robot.
Add fuzzyness
Since the values of the array are microseconds and they vary due to several reasons the precise pattern matching is not good enough to steer the robot. You need to be a bit fuzzy with the matching. As LOW with the PicooZ remote control takes about 0.57ms and the HIGH too you find LOW data from 0.52ms to 0.62ms. There is a 0.1ms fuzziness here.
Use this code to calculate the match.
Happy remote controlling
So now you can put everything together and are ready to help your autonomous robot out of a trap. Here is the code of this tip:
https://github.com/mnemonia/robotix/tree/master/Playground/PicooZ_IR_RemoteControl
Getting more precise
The binary code from the throttle for example can be interpreted by its 16bit spectum where 0000 is no throttle and 1111 is full. In between is where it is possible to have more discreete throttle levels.
Then as one steers with two axis at the same time you might match regions in the protocol instead of matching all at once as the tip mentions. Matching the throttle having 0110 and the yaw 101 would then result in a forward left command to the robot drive.
https://www.youtube.com/watch?v=C1FGf-9lqKU