Help with a project: Strip multiwii back to ppm in-servo out

Post Reply
cardboard
Posts: 183
Joined: Tue Mar 15, 2011 9:40 am

Help with a project: Strip multiwii back to ppm in-servo out

Post by cardboard »

I wasn't sure where exactly to put this thread but it is about code so this seemed as better place as any.

I have an arduino project I am working on that involves reading a ppm stream from a receiver and spitting out servo control.
In between there is some GPS goodness to act as a RTH.
This is a personal project I'm doing for fun, I already have OSDs I like and don't fell like spending $200+ for a full OSD RTH fancy thing when all I want to something very simple. For use in rc cars, gliders etc that only require steering or the rudder to turn, things like that.

Anywho the reason I have come and asked for help, I have ppm decoding (using timer 1) and I was planning on using the servotimer2 library for driving my servos but these 2 bits of code don't play nice together. Although it works, every ~30s or so all the servos glitch which makes it non usable. All the ppm decoding I have found uses timer 1 so that can't change, and the servo library built into arduino can't be used as it uses timer 1 as well.

I'm trying to stick with using a 328 as I have a number of them and as shown by multiwii they are capable of doing the above job. I am somewhat knowledgeable in arduino and can read through and roughly follow the multiwii code but don't have the skill to strip it back to the ppm and servo out functions.

If there is an early early prototype lump of code that does that it would be great to have or if someone could point me in the correct direction to better understand how to do this even better. Hell if there was a nice person that had some spare time to strip it for me that'd be amazing.

Thanx Hadley.

PatrikE
Posts: 1976
Joined: Tue Apr 12, 2011 6:35 pm
Location: Sweden
Contact:

Re: Help with a project: Strip multiwii back to ppm in-servo

Post by PatrikE »

I have made a PPM to PWM converter.

PPm in and 8 servo outputs.
Is it somthing like this you mean?

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: Help with a project: Strip multiwii back to ppm in-servo

Post by copterrichie »

PatrikE wrote:I have made a PPM to PWM converter.

PPm in and 8 servo outputs.
Is it somthing like this you mean?


IMO, I believe this would be a better solution: http://www.pololu.com/catalog/product/207

Still would require code modification.

cardboard
Posts: 183
Joined: Tue Mar 15, 2011 9:40 am

Re: Help with a project: Strip multiwii back to ppm in-servo

Post by cardboard »

@PatrikE that sounds like EXACTLY what I have been after.

edit: you mean the one you linked to in this thread?
viewtopic.php?f=15&t=2832
If so I fell rather silly as I spent a good week trying to search out allot of various options for solving my problem and never cam accross that thread.
If I wanted to manipulate the sero values with code before they got written to the servos where would the best place be....???
and could I still use my serial gps or would the serial protocol already in multiwii cause me issues?
Last edited by cardboard on Sat Feb 02, 2013 6:57 pm, edited 2 times in total.

cardboard
Posts: 183
Joined: Tue Mar 15, 2011 9:40 am

Re: Help with a project: Strip multiwii back to ppm in-servo

Post by cardboard »

@copterrichie, better? Im just interested in your reasoning.
I to had a look at that very board but wanted to keep everything in 1 IC if at all possible.
I see it uses serial as well, although it runs up to 38400 (same as my gps) would the extra traffic cause things to jam up and slow down?

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: Help with a project: Strip multiwii back to ppm in-servo

Post by copterrichie »

Because it would offload the control, the Range, 12bit timer and as for serial, Sebbi modified the Arduino SoftSerial. But again, I stated my opinion, others may not agree. ;)

PatrikE
Posts: 1976
Joined: Tue Apr 12, 2011 6:35 pm
Location: Sweden
Contact:

Re: Help with a project: Strip multiwii back to ppm in-servo

Post by PatrikE »

That's exactly the one i meant!...
Iw'e updated it with setup from gui.

RcSerial from Gui.
Enable from gui and pull the sliders for RcValues.

!!Warning!!
Make shure no props is mounted on the model!!!!!...
Or Battery disconnected from Motor/ESC..

ServoTest BETA

Happy testing

//Patrik

PatrikE
Posts: 1976
Joined: Tue Apr 12, 2011 6:35 pm
Location: Sweden
Contact:

Re: Help with a project: Strip multiwii back to ppm in-servo

Post by PatrikE »

cardboard wrote:If I wanted to manipulate the sero values with code before they got written to the servos where would the best place be....???
and could I still use my serial gps or would the serial protocol already in multiwii cause me issues?


In Mixtable in output.
Now the RX PPM is simply passedthru to servos.
Adjustable Servocenter,Rewerse and max throws adjustable form Gui.
Failsafe sets all Servos to Servocenter if PPM signal is lost.

Serial is free to use to anything!
Ex. OSD,Telemety or a homebrew RcSerial controll.

cardboard
Posts: 183
Joined: Tue Mar 15, 2011 9:40 am

Re: Help with a project: Strip multiwii back to ppm in-servo

Post by cardboard »

I tried compiling the code in the zip you posted above and got "'plog' was not declared in this scope"..... is that meant to be there?
And I also found the mix table for PPM_PWM_CONVERTER but I was hoping for some obvious values I could manipulate, sorry my brain fells like mush after all the code I have been reading lately.

PatrikE
Posts: 1976
Joined: Tue Apr 12, 2011 6:35 pm
Location: Sweden
Contact:

Re: Help with a project: Strip multiwii back to ppm in-servo

Post by PatrikE »

Sorry.
I missed to remove a debug who caused the compile error.

Fixed it and now it should be god to go!
The Mix became more comlex when i added the Gui config

This is the line who do the actual mixing

Code: Select all

 servo[i]  =((rcData[i] - MIDRC + conf.servoTrim[i])*conf.servoDirection[i])+MIDRC; 


Simplified to the bone Then this is what it do!...

Code: Select all

   servo[i]  = rcData[i];  

Just copy Raw Rcdata to servo.
The rest is for trim,reversing and endpoints.

When it's userfriendly normally it's not developerfrienly... :(

cardboard
Posts: 183
Joined: Tue Mar 15, 2011 9:40 am

Re: Help with a project: Strip multiwii back to ppm in-servo

Post by cardboard »

One more bug, the GUI locks up whenever start is pressed. The serial lights flicker for a sec then nothing.
I uncommented

#define SERIAL_SUM_PPM ROLL,PITCH,THROTTLE,YAW,AUX1,AUX2,AUX3,AUX4,8,9,10,11 //For Robe/Hitec/Futaba
and
#define PPM_PWM_CONVERTER // PPM to 8 servos
as well as cleared the eeprom on the board.

it should be working at this stage shouldn't it?

cardboard
Posts: 183
Joined: Tue Mar 15, 2011 9:40 am

Re: Help with a project: Strip multiwii back to ppm in-servo

Post by cardboard »

And I do realise that complex code is normally not overly simple to interface with, just have to keep learning.
On that note, I can't add a Serial.begin() can I? It throws up a vector error that I am guessing is to do with an timer somewhere.

cardboard
Posts: 183
Joined: Tue Mar 15, 2011 9:40 am

Re: Help with a project: Strip multiwii back to ppm in-servo

Post by cardboard »

Another silly question, what physical pins are each of the 8 outputs connected to?

PatrikE
Posts: 1976
Joined: Tue Apr 12, 2011 6:35 pm
Location: Sweden
Contact:

Re: Help with a project: Strip multiwii back to ppm in-servo

Post by PatrikE »

Mwii serial is initiated by default.
If you do it one more time you will probably get a conflict.

Fixed the Gui and uploaded.

Same Pinout as Airplane.
http://fotoflygarn.blogspot.fi/2012/03/how-to-setup-multiwii-airplane-same.html

cardboard
Posts: 183
Joined: Tue Mar 15, 2011 9:40 am

Re: Help with a project: Strip multiwii back to ppm in-servo

Post by cardboard »

Sweet, got the GUI working and the servo outputs all figured out. Had a play with the mix table and managed to wrap my head around that to some degree.
One last stupid question, how do I use the built in Mwii serial?
I'm used to working with the normal serial commands but reading through this
viewtopic.php?f=8&t=1516
looks like it needs slightly more work but as you said earlier, more features = not as straight fwd to use.

I'm looking at reading a serial GPS and printing out some basic things for debugging etc.
I know these features have been implemented already by various people but I would still like to pursue my own rendition.

Anywho, thanx for all your help thus far.

crashlander
Posts: 506
Joined: Thu May 05, 2011 8:13 am
Location: Slovenia

Re: Help with a project: Strip multiwii back to ppm in-servo

Post by crashlander »

Hello, hope this is the right thread....
PatrikE: I'm using your ServoTest code + GUI on Flying wing and the code seems to work properly (did short flight test), also the part of GUI to set servo outputs is OK.
But.... ...the basic (old) part of GUI is broken:
- The part that shows input TX signals puts sliders on wrong channel (eg. when I move TH on TX yaw moves in GUI...),
- the part that should show output signals (to ESC and servos) is dead and does not move.
This is on MacOSX and using your precompiled GUI.

Any chance to include those fixes/improvements in mainline dev. releases?

Best Regards
Andrej

cardboard
Posts: 183
Joined: Tue Mar 15, 2011 9:40 am

Re: Help with a project: Strip multiwii back to ppm in-servo

Post by cardboard »

The sliders being on the wrong channels is an easy fix.
When you uncomment the define for ppm in just swap around the order of the channels.
As for the second bit, you did read start then read??

it all works fine for me.

crashlander
Posts: 506
Joined: Thu May 05, 2011 8:13 am
Location: Slovenia

Re: Help with a project: Strip multiwii back to ppm in-servo

Post by crashlander »

cardboard wrote:The sliders being on the wrong channels is an easy fix.
When you uncomment the define for ppm in just swap around the order of the channels.

I do not use PPM and the wing fly just fine so channel mapping (TX/RX -> MWII) is O.K. only channel sliders in GUI are wrongly mapped
(MWII -> GUI)!

Regards Andrej

PatrikE
Posts: 1976
Joined: Tue Apr 12, 2011 6:35 pm
Location: Sweden
Contact:

Re: Help with a project: Strip multiwii back to ppm in-servo

Post by PatrikE »

Hi.

I corrected the TX order.
Servotest.zip


There's a lot of changes made in this dev.
I Need to have all models tested.
Almost all models with servos is supported in this dev.

Gimbals and BI copter is missing.

When everything is verified it may be included to _shared.
But it means adding several MSP.

Post Reply