Reading PWM from a receiver

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
E-mail me when people leave their comments –

You need to be a member of diydrones to add comments!

Join diydrones

Comments

  • MIght help. http://diydrones.com/forum/topics/705844:Topic:26900
  • Is there a general place where code can be found?
  • 3D Robotics
    It's here
  • I'm always looking for code, is there a repository where I could find this (the RCTest code?
  • Yup here it is Chris. It is a lengthy thread but a gold mine of information.
  • 3D Robotics
    Can you use the link icon to insert a link to that thread please?
  • @Chris There is a thread on RCGroups in the multi-rotor helicopter section by two fellows, Mikro and PaulRene that are doing this both ways.

    Mikro is using a spread spectrum receiver and reading the indiividual channels then using interrupts to trigger the pulses with the ServoTimer2 library and pulseIn and Paulrene is using ServoDecode library and SoftwareServo library to read the PPM train and then then run the pulses and functions in parallel so CPU time is minimal. Check out the threads. Very informative. I now have my receiver working both ways and reading the channels. Next up is to get the radio to do something useful like integrate gyros and accels to create an IMU.
  • @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...
  • 3D Robotics
    @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?
  • 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)
This reply was deleted.