Rover Build Update: Arduino + GPS + Servo = glitch

In today’s learn as you go along lesson, hit a problem trying to integrate a GPS module on the Arduino with a servos connected to the board’s PWM pin.  The result was the servos would glitch about every second or so.  Doing some searching and based on some forum posts (here too), it looks like the solution is going to be a Servo Shield.  Offloading the PWM processing to the shield should hopefully alleviate the interrupt contention.

Here’s a video showing what the glitches looks like.

Compass Placement on the Robot

Another fun lesson learned in robot building.  Where to place the compass?  I noticed some strange readings today on my Adafruit LSM303.  I had already previously discovered that the metal and other electronics of the vehicle was messing with the readings.  I dug up a real compass to compare and immediately discovered an easy way to determine the location of interference and best placement.  For now, on this vehicle I will put forward of the front wheels.  I could also have given it some altitude if I wanted to place it further back.  This is fine for now since I’m still just prototyping.

 

ISS Radio Signal Capture

Had a great opportunity last night to capture a radio signal from space.  The ISS flew by transmitting a commemorative space anniversary broadcast.  Found out about it at the very last minute and didn’t have time to set up a proper recording and demodulation, but I did manage to take this video.  The signal came in quite strong.

 

How to Read the Traxxas Radio PWM Signals using an Arduino

These are my notes on how to read the PWM servo signal coming from the Traxxas TQ receiver.

Disclaimer: use this information at your own risk.  I am not responsible for any damage.

RC car radio receivers communicate with the steering servo and electronic speed controller using electrical pulses called PWM(pulse width modulation).  Using an Arduino, we are able to capture  these pulses and print their values out to the Serial Monitor.  These numbers represent the width of the electrical pulse in microseconds, and are essentially the same numbers you would use in an Arduino sketch to control the car programmatically.

Materials Needed

  • Arduino
  • RC car radio receiver
  • USB Cable
  • Jumper Wire

Receiver

The TQ Receiver that comes with a stock Traxxas vehicle consists of two channels, representing steering and throttle.  Starting from the bottom is Channel 1.  The next one up is also Channel 1 (I am unsure why they exist in duplicate)  The third one up is Channel 2 and it is used for the ESC.  These are the two we are concerned with.

Each channel contains three pins:

  1. The left-most pin is for the “signal”.  This is the pin that communicates by sending electrical  pulses to the servo and ESC, directing them to turn, go forward, or reverse.
  2. The middle pin is the Positive terminal.
  3. The right-most pin is the Ground/Negative terminal of your  power supply.

Note:  the Positive and Negative pins are all connected together underneath.  Sending power to any channel will supply electrical charge to any of the other +/- pins.  Once you connect power to one channel, connecting power to the other channels is not necessary.

Important:  be sure to disconnect all wires from the radio before connecting anything to the Arduino.  In the stock configuration, the receiver is powered by the ESC at 6 volts.  You do not want to accidentally turn on the ESC with any of the radio’s +/- pins connected to the 5v pins of the Arduino as this may damage your board.

To set up, you will need to plug a wire to a PWM pin on the Arduino.  These are designated by the tilde ~ symbol.  This code example will be using Pin 3.  Connect Pin 3 to the left-most pin of Channel 1 on the receiver.  Then connect a red wire from the +5 pin of the Arduino to the middle pin of Channel 1.  Finally, connect a black wire to right-most pin of Channel 1 and the ground pin of the Arduino.

 

Connect the USB cable.  The LED light on the Receiver should turn red.  This indicates that it is on but not connected to the Transmitter.  Power on your Transmitter controller, the LED light should change green.

Now upload the following sketch:


byte PIN = 3;
int pwm_value;

void setup() {
    pinMode(PIN, INPUT);
    Serial.begin(9600);
}

void loop() {
    pwm_value = pulseIn(PIN, HIGH);
    Serial.println(pwm_value);
}

 

Next open the Serial Monitor by going to the menu:  Tools -> Serial Monitor

If you get an error in the console that looks like this:   Board at /dev/ttyACM0 is not available

Go to Tools -> Ports and select the port listed in the error code(in this example it would be /dev/ttyACM0).

You should see values in the Serial Monitor.  Turn the steering knob of the transmitter and the values should change.

Full left should be around 1000

Full right should be around 2000

And neutral position should be around 1500.

For reading the throttle values, simply disconnect the left-most wire(signal) from Channel 1 and plug it in to Channel 2.  Look closely at the markings(it’s tiny!).  Channel 2 is actually third from the bottom.  Use a magnifying glass to be sure.

You do not need to move the +/- wires since those pins are already connected together inside the radio.

 

Now squeeze the throttle on the transmitter and observe the values in the Serial Monitor.

Controlling a Traxxas ESC with an Arduino

These are my notes for getting an Arduino Uno to control a Traxxas Velineon VXL-3s speed controller.

Disclaimer: use this information at your own risk.  I am not responsible for any damage.

Materials Needed

  • Traxxas ESC Velineon VXL-3s
  • Arduino Uno
  • Stock Traxxas 7.2v battery
  • Power cable

First you need to connect one of the Arduino PWM(~) signal pins to ESC connector’s white lead).  Be sure it’s the ESC connector and not the steering servo, they look the same.

Warning:  the other two red and black wires of the speed controller connector are used to supply power to the Traxxas radio receiver and it is 6 volts.  DO NOT use these wires to connect to the 5v and ground pins of the Arduino or it may damage your board since these pins bypass the voltage regulator.  It’s best to send power through the board’s DC plug which can handle a range of 7-12v.

For power, I used a Traxxas battery harness .  I cut off one of the battery connectors and spliced on a DC plug.   This allows powering the Arduino using the Traxxas battery at the same time it is plugged in to the ESC.

 

 

Figuring out the code to “arm” the ESC took some trial and error.  ESCs need a specific sequence of commands before they will turn the motor.  I assume this is for safety reasons, you wouldn’t want to turn on your RC car and have it suddenly take off at 30mph.  I couldn’t find a definitive guide on how to do this for Traxxas, just lots of unanswered forum posts.   For this reason I decided to post my notes in case it helps someone else.

I should also say this is my first time doing this and it may not be the best answer.  It may even be different for other Traxxas models(and it is certainly different for other brands).  I discovered this by accident.  Nothing had worked until I uploaded the Arduino Servo library Sweep sketch included in the IDE.  It loops forwards and backwards through all servo values and it had activated my ESC mysteriously.  From there I was able to narrow it down to a short range in the middle.  A single forward loop incrementally writing to the angles of 90 through 100 with a short delay in between is what it took to arm it.

Sample code:


#include <Servo.h>

Servo throttle;

int pos = 0;
int pin = 3;

void setup() {

   throttle.attach(pin);

   // This loop arms the ESC
   for (pos = 90; pos <= 100; pos += 1) { 
      throttle.write(pos);             
      delay(150);                       
   }
}

void loop() {
    throttle.write(120);
}

Lessons Learned:

  1. I should have removed the wheels.  There were a lot of sudden starts and stops at full speed while debugging.  The mass of the wheels at high speed coming to an instant stop damaged the spur gear.  Removing the wheels might have prevented that.
  2. Traxxas vehicles have a Training Mode which reduces the throttle rate by 50%.  This too might have helped prevent gear damage.