Hey all.

I know this subject has been covered in many ways, but I am hoping that someone can assist me. I hope someone can have the patience to answer a few of my VERY NEWB questions.

What I am trying to do is to send PWM to an arduino on an air vehicle which will then send the appropriate servo controls. Simple enough some may say, but I am in a bind since I just cannot get my head wrapped around this and frankly, I think my research has gotten me confused.

My BASIC NEED is to be able to see the pulsewidth values in Milliseconds or in PWM values on Serial Monitor and see the values change as the sticks and knobs are moved.

I know some may say, why not just use RC to control the servos without the Arduino? The answer to that is that I want to eventually turn control over to the Arduino like in ArduPilot, and use the Arduino as an IMU sort of. The ArduPilot code has been interesting to analyze but I have not gotten closer to my VERY BASIC need. Being able to look at the ArduPilot Pro code would likely be a very good insight......but that is not available to my knowledge.

I have tried ServoDecode, ServoTimer2 and SerialServer libraries and I can capture the PPM for the channels alright on Pin 8, but it does not show me the changes to the pulsewidth when the sticks are moved. I thought I might have what I needed by downloading Chris' RCTest code but since I don't want to move anything like motors for thrust or vectoring and tried to uncomment the Servo stuff it doesn't do anything. When I compile it and run, it does nothing. It just sits there and the servos just jitter and sometimes go to extreme lock..I just need to see the pulsewidths and move SERVOS accordingly.. Jordi in his thread to Hack a receiver was a good piece of code, but the next file he released to read the PPM just displays a scattered array of numbers that don't relate to anything. In that code, and in finding the PPM string I get a value that goes like 214567. Is this a MicroSecond value and how could one convert this to a Milli-Second value? Multiply by 1000?

Thanks to all in advance for any help or direction you may send my way.

Happy Holidays to all.

Jim

Views: 2668


3D Robotics
Comment by Chris Anderson on December 23, 2008 at 12:46pm
All of our code is to read PWM, but you're talking about PPM. PWM is the signal that goes to the servos. PPM can only be read if you tap a special pin on the chips in older (non spread spectrum) RC receivers.

(see this from the Paparazzi site for a fuller explanation)

Which did you mean?
Comment by James Holbrook on December 23, 2008 at 1:05pm
Thank you Chris. What I am referring to is to be able to read the pulse that leaves the receiver and goes to the servos. I have modified my receiver to be able to attach the output stream to Pin 8 and I also have tried pulseIn as you all do. PPM PWM whatever it is. I need to be able to read it on the Serial Monitor to see the changing values as the sticks/knobs are moved. I would be using serialPrint to the screen. In the RC Test code, I thought this might be useful and meet my basic need, but the motor control stuff threw my brain into a tizzy.

Have looked at the Paparazzi link you mentioned and thank you. Still the question remains to be able to see the pulses on Serial Monitor.

3D Robotics
Comment by Chris Anderson on December 23, 2008 at 1:34pm
Ah. Okay, you mean PWM. Big difference (can you correct the post title and body so people aren't confused?)

When you run my RCTest code, it should be sending Channel 1 and Channel 2 readings to your serial monitor. (Ignore all the motor stuff--it doesn't matter if they're connected or not). Are you seeing those?
Comment by James Holbrook on December 23, 2008 at 2:07pm
Hey Chris.

The setup is my receiver is on, the servo pins are connected to pins 5&6. When I start the code it states: Ready.
Then is says Channel 1: 0
Initial Throttle: 1497
Channel 2: 0
0 -224
Initial Steer: 0
Channel 1: 0

then on the next cycle it just repeats endlessly.

Any Clues? The receiver drives servos fine on all channels.

Jim

3D Robotics
Comment by Chris Anderson on December 23, 2008 at 2:21pm
It looks like I may have commented the code wrong. The code I'm looking at shows the RC input is on pins D6 and D7:

Channel1Value = pulseIn (PD7, HIGH, 20000); //read RC channel 1
Channel2Value = pulseIn (PD6, HIGH, 20000); //read RC channel 2
Comment by James Holbrook on December 23, 2008 at 2:23pm
Hold the train Chris,

Got it to read the pulses now. I had followed the pinout in the code but the pin numbers didn't match up and once I connected to PD7 to D7, it started working. Now Do I just repeat the code for these two channels for the next two channels so I can read channels 1-4 on the serial monitor. This code is based on Servo or Servotimer1?

Jim

3D Robotics
Comment by Chris Anderson on December 23, 2008 at 2:42pm
It's based on the Servo library. It takes about 20-30% of available CPU capacity to read each channel, so you'll find that reading four channels slows down the code a lot. Servotimer is more efficient but is limited to just two channels.
Comment by quix-fz on December 24, 2008 at 11:16pm
http://diydrones.com/profiles/blogs/705844:BlogPost:39393

this will read the sum-ppm-signal of all channels, without using any cpu (less than 1%). can easily be modified to read one channel, or any other number you like (by ANDing all the channels you want to read)

3D Robotics
Comment by Chris Anderson on December 24, 2008 at 11:59pm
@quix: If I'm not mistaken, getting that PPM signal requires soldering a wire in the RC receiver, and as I recall doesn't work with modern spread-spectrum receivers. Is that correct?
Comment by quix-fz on December 25, 2008 at 3:09am
@chris: that's correct. but ORing the signals (not anding as i wrote before) could still work...

it just seems very wrong to me to use that much cpu time waiting for a signal....

i think a saw a simple port expander ic, which had a input-capture function for each pin... i'll see if i can find it again...

Comment

You need to be a member of DIY Drones to add comments!

Join DIY Drones

Social Networking

Contests

Season Two of the Trust Time Trial (T3) Contest has now begun. The fourth round is an accuracy round for multicopters, which requires contestants to fly a cube. The deadline is April 14th.

A list of all T3 contests is here

Groups

Advertisement

© 2013   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service