Forum Rule: Always post complete source code & details to reproduce any issue!
Page 1 of 5 1 2 3 ... LastLast
Results 1 to 25 of 111

Thread: Arduino RC library

  1. #1
    Member
    Join Date
    Mar 2014
    Location
    Fremantle Western Australia
    Posts
    47

    Arduino RC library

    Very new to arduino and C but i have a need to learn. My project is probably not too ez for a beginner but what the hell, try anything once This project needs to be very small and the nano only has 1 timer and that makes it too hard, others have given up. basically i need to strip the values from 2 ppm streams and then mix them into 1 and add a couple of local inputs.
    Has anyone tried the Arduino rclib on a teensy. http://sourceforge.net/projects/arduinorclib/
    I am waiting for my teensies to arrive but would love to hear from anyone who has especially if they have ported it.

    Mike

  2. #2
    Member
    Join Date
    Jan 2014
    Location
    London, UK
    Posts
    76
    Sounds quite simple, are you able to give more details of the actual problem?

  3. #3
    Member
    Join Date
    Mar 2014
    Location
    Fremantle Western Australia
    Posts
    47
    As i said basically i need to strip the values from 2 ppm streams and then mix them into 1 and add a couple of local inputs. The devices are head trackers for control of 2 cameras in an RC model, I need a couple of other channels as well. The head trackers use a nano board. The originator of this project http://www.rcgroups.com/forums/showthread.php?t=1677559 found that he couldn't add the input stream as the nano only had 1 timer and the input decoding messed with the pulse timing of the outgoing stream. This has to be as small as possible. I would need to either port this to something small but able to decode the input stream and have the head tracking as original or make a separate device to read the 2 streams and then combine the wanted channels onto the output stream. It would be better to have the separate device with the 2 head tracker inputs as then the extra channels are always available even with no head trackers plugged in.
    The ArdunioRClib has all the parts required to do what i want and a lot more but i gather its far too much for a nano. maybe there is another small board beside the teensy that could do it but i think the teensy is a good choice in these days of increasing features.
    As a newby to this world i have huge amounts to learn but i don't give up easily. I am sure if the rclib would work with the teensy then i would have a hugely easier life.

    Mike

  4. #4
    Member
    Join Date
    Jan 2014
    Location
    London, UK
    Posts
    76
    Are the PPM streams actually PPM, have you scoped them to check. The RC world seems to get very confused between PPM and PWM, because the old analog radio transmitters used PPM multiplexing with PWM data transmission. The PWM signal is what the servos are interested in. The PPM encoding is for the RX to know which Servo to send the PWM signal to.

  5. #5
    Member
    Join Date
    Mar 2014
    Location
    Fremantle Western Australia
    Posts
    47
    Yes definitely Pulse Position Modulation and not Pulse Width
    I am a tech and know the difference. They output very stable streams, at least on my CRO, and they need to remain nice and stable after combining.

  6. #6
    Member
    Join Date
    Jan 2014
    Location
    London, UK
    Posts
    76
    Quote Originally Posted by whimsical View Post
    Yes definitely Pulse Position Modulation and not Pulse Width
    I am a tech and know the difference. They output very stable streams, at least on my CRO, and they need to remain nice and stable after combining.

    Excellent, should be simple enough to sample the input streams with an interrupt on each pin, and then use a timer to generate the new stream on a third

  7. #7
    Member
    Join Date
    Mar 2014
    Location
    Fremantle Western Australia
    Posts
    47
    Yes, doesn't sound hard at all but the nano only has 1 timer/counter which makes it a bit hard.
    If i am going to get more involved with this stuff i want to learn 1 device that fits most of my needs and i think Teensy is the 1, quite cheap and small. I have quite a few more projects i want to do but this one first.
    I used to do a lot of machine language back in the Z80 days, with and without assemblers, but nothing since. I tried high level languages then but they were so illogical. Machine code makes sense, C or the others didn't but that is the way of the word and if we only had machine code we wouldn't be as advanced as we are now.

  8. #8
    Member
    Join Date
    Jan 2014
    Location
    London, UK
    Posts
    76
    I grew up on 68k asm with my Amiga 500. You should be able to do this with a single timer

    Also, believe me, C is vastly superior to ASM

  9. #9
    Member
    Join Date
    Mar 2014
    Location
    Fremantle Western Australia
    Posts
    47
    Also, believe me, C is vastly superior to ASM
    That depends on what u want to do. For the stuff i built i wouldn't agree. Disassembled the ibm format routine for the floppy because i wanted to find out why it took so bloody long. What a mess, my machine routine took a few seconds, maybe 10, to format 2 sides not the minutes the IBM took.

    back to topic
    The guy that wrote the head tracker found that with only 1 timer he wanted more to time the input stream and without more he had jitter. I haven't played with it yet and have a lot to learn before i can comment much. Will wait till the Teensy arrives then get started with a few simple things first. If the ArduinoRClib runs on the teensy, which i doubt because i wouldn't be that lucky, it should be a lot easier for me. I just hope someone with the experience is playing with the lib.

  10. #10
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,174
    I took a quick look at this library. It's going to take quite a bit of work... I can help, but I think we're really going to need to get Daniel van den Ouden (the original author) involved. Does anyone have his contact info?

    This library has a nice-looking abstraction for Timer1. The problem is PPMIn.cpp, PPMOut.cpp, ServoIn.cpp, and ServoOut.cpp directly access TCNT1, OCR1A and OCR1B, rather than using the abstraction layer, which makes porting a messy job. Not impossible, but very messy....
    Last edited by PaulStoffregen; 03-05-2014 at 02:00 PM.

  11. #11
    Member
    Join Date
    Mar 2014
    Location
    Fremantle Western Australia
    Posts
    47
    The project seems to be in limbo.
    Was lots of activity regarding the next 2 releases but that was 2 years ago. He did make a couple of comments in the discussion area but nothing since last August
    I still haven't found out what board he was using. All i have is that it was using an Atmega328p.
    I would guess probably a Duemilanove
    Last edited by whimsical; 03-05-2014 at 02:19 PM.

  12. #12
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,174
    The more I look at this library's code, the less I like it.

    It's bad enough that the library scatters direct hardware access throughout several files, rather than using its own Timer1 class. But the user examples are filled with direct hardware access too. From a hardware abstraction point of view, it's pretty terrible design.

    Then again, one nice thing is the library has a lot of code and examples for specific RC hobby products, which I'm not familiar with at all.

    I glanced briefly at that rcgroups forum. That thread has 2011 messagse!

    @whimsical - Please try to understand I have NEVER built any RC plane or shopped for RC hobby stuff. I'm not familiar with the many RC hobby products and their specific lingo with is sometimes quite different from the terminology used for normal electronics. Perhaps you could describe your application in more generic terminology that doesn't assume familiarity with the specific RC hobby products you're using?

  13. #13
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,174
    Looking at this a bit more, a really ideal solution would be using the input capture feature on multiple timer channels.

    That library uses a pin change interrupt and reads the timer, implementing input capture using software, which of course means any interrupt latency will become error in the signal.

    In theory, Teensy 3.1 ought to be able to simultaneously capture several PPM streams with perfect input capture, since its timers have so many features including 16 bit input capture on all channels.

  14. #14
    Member
    Join Date
    Mar 2014
    Location
    Fremantle Western Australia
    Posts
    47
    Paul
    A head tracker is used to control a remote gimble that has a camera. The video is transmitted back to the user who has goggles, which are just basically a tiny screen and there is a diy project for that as well . Thus when the user moves their head around the camera and the picture the user sees follows. They call it FPV, first person view, and the results are quite immersive and realistic. I want 2 trackers, 1 for the passenger. These craft can use long range radios and can go for quite a few miles exploring. A working example of what i want to do http://www.youtube.com/watch?v=b8MoeWX1QXs
    Any other things you need an explanation for fire away and hopefully i can expand your experience base.

    I read quite a bit looking for some base code to get me started, that head tracker project was a good start as it has the mixing side done. Several places i read of the difficulties of both decoding and encoding streams with limited timers, and i understand why. Many other open DIY projects have difficulties owing to limited hardware. So i started looking for a small board that didn't have the timer problems and found you, aren't you lucky . I do believe that the Teensy is a good fit for the RC world, not a lot more expensive than the Nano and small but most importantly capable of doing far more than the other small Boards.

    PaulStoffregen

    Looking at this a bit more, a really ideal solution would be using the input capture feature on multiple timer channels.

    That library uses a pin change interrupt and reads the timer, implementing input capture using software, which of course means any interrupt latency will become error in the signal.

    In theory, Teensy 3.1 ought to be able to simultaneously capture several PPM streams with perfect input capture, since its timers have so many features including 16 bit input capture on all channels.


    That pretty much sums up why i picked the Teensy. I downloaded the arm manual, 1400 pages, but i really need to get some more toner before i print it out and i hate trying to read something like that as a PDF.

    I was hoping the rclib would be better executed but maybe i expected too much, drop modules in and they play nice together. Not just for me but the whole RC community would benefit from a well written library for many varied projects. My next project will be a working primary flight display on a 1.5 to 3" lcd so that when the camera looks down the user will see the working instrument. A PFD shows an artificial horizon, altitude, speed and quite a few others. Much like a head up display you see on modern fighter aircraft, must have seen 1 of those in the movies. This has been done but is closed source and not commerially available yet.
    There are many little gadgets in the RC world that are based on pic's or similar, most are closed and expensive and don't quite do what many want. There are also many DIY projects on many different forums, 1 example http://www.rcgroups.com/diy-electronics-199/ so it is an active and growing area of modelling.



    Sounds like i am back to the drawing board

  15. #15
    Member
    Join Date
    Nov 2012
    Location
    Olympia, WA
    Posts
    52
    Disclaimer: I am only familiar with the site in relation to sound generation, but noted some discussion of Arduino servo library shortcomings and some higher level PPM and timer discussions. Being on a phone prevents me from diving in to see if it's straight up applicable; happy browsing:

    http://rcarduino.blogspot.com/

    EDIT: Although useful and relevant, I don't think you can pull off reading two PPM streams using the linked libraries. One plus processing and outputting as PWM or PPM. Even with less optimized code, it should be do-able on the Teensy 3 series.

    http://rcarduino.blogspot.com/2012/1...pm-stream.html (reading PPM)
    and http://rcarduino.blogspot.com/2012/1...nofastlib.html (general speedups vs. standard)
    and http://rcarduino.blogspot.com/2013/0...r-testers.html (PPM output)
    Last edited by drjohn; 03-06-2014 at 05:23 AM. Reason: More digging

  16. #16
    Member
    Join Date
    Mar 2014
    Location
    Fremantle Western Australia
    Posts
    47
    A few other notable devices that is common in the RC world.
    Full auto pilots with route setting by waypoints and control from a ground station much like the drones the military have. These have a multitude of sensors such as GPS, Magnetometer, Gyro's, shock sensors barometer for altitude, differential pressure sensor for air speed etc, even sonar sensors to more accurately determine height above ground.
    Small boards that use the telemetry data from the auto pilots to inject an overlay into the FPV video stream
    There is a very advanced full open source RC transmitter project that i have yet to explore. The transmitter i use utilizes this but is so complex i stayed away from trying to extract the bits i might need.

  17. #17
    Member
    Join Date
    Mar 2014
    Location
    Fremantle Western Australia
    Posts
    47
    drjohn
    Thanks for that saved it for a later read.
    This is what i find everywhere not enough interrupts or timer/counters with work arounds causing jitter in the output or huge amounts of latency
    I only briefly looked at servo library. It is more oriented towards outputting the PWM signals to control servos, although it has to decode the PPM stream to do it i suppose.

  18. #18
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,174
    Thanks. That explanation really helps.

    Teensy 3.1 has dramatically more capable hardware than AVR-based Arduino. I believe it should be possible to run a few simultaneous PPM inputs/outputs (each with 10-16 signals) with 21 ns timing accuracy, of course with proper coding that leverages the timer hardware for both input capture and output compare.

    The optimized Arduino version appears to have a 500 ns accuracy for the timer compare generated outputs. The input is probably much worse, since it's based on pin change interrupts, with varying interrupt latency between the actual hardware event and the ISR acquiring the signal.

    I can't spend a lot of time writing a comprehensive library right now, but perhaps I can fiddle with this for an evening and see if I can come up with at least a good starting point.

    If this does turn into a nice library, my biggest question is how can we get it into the hands of more people building RC projects? Probably very few people interested in this sort of stuff will see if here on this forum thread.

  19. #19
    Member
    Join Date
    Mar 2014
    Location
    Fremantle Western Australia
    Posts
    47
    I have already pointed a couple of the diy coders on 1 of the RC forums toward the teensy and I certainly will keep pointing people towards it at every opportunity. I think given the small price increase over the Nano, which seems to be very common in RC world, the Teensy gives them far more tools than they have now. I think you would be surprised just how many coders are involved in the RC area. Maybe i should start a dedicated thread to highlight it and explore what peoples thoughts are, good idea i will do that just to try and gauge the reactions. There are several forums with active coders so i will start a thread on all of them.
    I feel it would be a lot better if we could promote a single device that covers the broadest range of needs at a reasonable price. This must surely promote portability and integration of projects where people want to integrate parts from several different projects. i have seen a few projects starting towards the Due which is an arm 3 so before that gets too much traction time to push the teensy as being smaller it would appeal to a broader range of projects. Not sure how comparable the 2 are ?

  20. #20
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,174
    Teensy 3.1 and Arduino Due are very similar in hardware capability. The on-chip peripherals are totally different, so only very generic Arduino code tends to be portable between them. An optimized PPM in/out library would need to be rewritten for each board.
    Last edited by PaulStoffregen; 03-06-2014 at 02:38 PM.

  21. #21
    Member
    Join Date
    Mar 2014
    Location
    Fremantle Western Australia
    Posts
    47
    Teensy has had its first, i think, project in the RC world interfacing what must be the best known and used autopilots telemetry output to what is becoming a hugely popular radio system based on the open source TX software OpenTx. http://www.diydrones.com/forum/topic...ge=14#comments . DIY Drones manufactures many types of autopilot, the original of which used the Mega 2650 but is moving to arm http://diydrones.com/ . This originates from the http://dev.ardupilot.com/ efforts which has versions for fixed wing, helicoptes and multi rotor craft.

    The different peripherals is a bit of a shame as it tends to dilute efforts but fortunately its not that well established in RC yet and its huge in comparison which for so many projects size is a huge problem.
    Last edited by whimsical; 03-06-2014 at 02:48 PM.

  22. #22
    Member
    Join Date
    Mar 2014
    Location
    Fremantle Western Australia
    Posts
    47
    Have made a post in a couple of forums. Will do some more tomorrow. See what reaction i get to the Teensy.

  23. #23
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,174
    Ok, I made a quick first attempt at this......

    http://www.pjrc.com/teensy/td_libs_PulsePosition.html

    Edit: signed up on DIY Drones and submitted a blog post about the new library, soliciting beta testers.
    Last edited by PaulStoffregen; 03-06-2014 at 11:21 PM.

  24. #24
    Member
    Join Date
    Mar 2014
    Location
    Fremantle Western Australia
    Posts
    47
    I am amazed so quick. I haven't got my 2 Teensies yet so i can't play
    Quite taken that you have noticed 1 of the more subtle things about servos, shorter than 20MS frames, but then u have modded the servo lib, although there is no mention of Teensy 3 on that yet.
    Have had a couple of moderators on RC forums get a bit miffed because they are thinking i am selling the Teensies but hopefully i can sort that out.

  25. #25
    I'll be in the same place as my rc gear mid next week - I can do some testing then . . .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •