AR500 PWM Output Order


03.29.09 Posted in Quadcopter by

So I didn’t want to throw down several hundred dollars for a TxRx combo, so I went with the $99 solution. The Spektrum DX5e is a five channel, full range transmitter that comes bundled with the AR500 receiver. Since I am reading the PWM in parallel and not the PPM, I needed to determine the output order.

Why is the output order important? In code, the pulseIn command is used to read the pulse width on a digital pin. It looks like this (only three below).

roll = pulseIn(ROLLPIN, HIGH, TIMEOUT);
pitch = pulseIn(PITCHPIN, HIGH, TIMEOUT);
yaw = pulseIn(YAWPIN, HIGH, TIMEOUT);

The ROLLPIN is the digital pin connected to the roll axis gyroscope, HIGH means it is going to measure the width of how long the pulse is at a logical 1, and TIMEOUT specifies how long to wait for anything to happen. You can omit the third parameter, but speed is a necessity. This is why the order is important. The outputs of the receiver come in a specific order. In code, you need to read all of the PWMs sequentially (in my case, all 5). For example, look at the above code. Roll is read right before pitch. Pretend there are no TIMEOUTs. The arduino will wait around until there is a pulse for roll. It reads it successfully. However, what if pitch was the pulse right before roll? The arduino will wait around almost an entire cycle before reading the pitch pulse. The same disaster could happen for the yaw pulseIn. So of course, if we determine the proper output order of the pulses, all of the information could be read in a fraction of the time when incorrectly ordered.

I took my TxRx to the best oscilloscope I could get my hands on. Using both channels of the ‘scope, I probed two of the channel outputs. An example of it is below. You can see that there is about a 3 millisecond gap between the pulses. This means that there are two pulses in between the ones I have selected, so I probe around the second channel (green line) until it comes right after the first channel’s pulse.

Pretty cool huh? And it’s easy (as long as you have a nice ‘scope). My confusion with the DX5e is that there were two outputs for the aileron channel. I had no idea if they were separate pulses or simultaneous, so I checked it out. As you can see below, they occur at the exact same time. This means I can ignore one of the two and only pulseIn five channels.

As a result of my tests, here is the channel output order of the AR500:

  • Aile1 and Aile2 (simultaneous)
  • Elev
  • Rudd
  • Throttle
  • Gear

Make sure one of the Aileron channels is in digital pin 2 so that it can properly trigger the interrupt. Again, I’m using a lot of

Mikro’s code

that he was nice enough to share on the

forum

that has the common goal of making Arduino quadcopters.




Comments are closed.

Social Networks
Links
Search the Archives: