There are currently 0 users and 2 guests online.
Build Your Own Micro RC Surveillance Robot
3.3 Programming the Robot
Submitted by Canabots on October 1, 2009 - 6:10am.
Now we need to program the robot.
At first, I started working on the PIC board. For odd reasons, it did not work. So I'll get back to you on that.
For the AVR board, I found the Axon would be the best candidate. So, Here's some of the programming I did:
//variable declaration for RC inputs
unsigned int L1=100; //Left motor output 1
This is only a segment of the whole program which is meant to go in control.c That code only does the ADC conversion for you the section commented out that says "custom code here" is where your own robot code goes. For starters, I tested on moving a servo back and forth.
Something else about this set-up; it is helpful to use a pull-up or pull-down resistor. I discovered this first when testing out the program, making a servo do pre-sequenced movements. When the servo kept moving after having released the controls, I knew there was something wrong. I used the SoR Scope to monitor the outputs of the RC receiver. The voltage level would vary ~70-120 (on a scale from 0 to 255).
This has it's advantages in a sense that you could leave the controls and ignore the robot while it does it's task. The problems being that (1) Eventually, the voltage may drift below the "High" level, and (2) To compensate for the fluctuating voltage, you must turn the controls in the opposite direction in order to bring it back down.