PPM to PWM

Electronic projects that are either related to the firmwares for the 9x, or simply great for radio control applications.
User avatar
Rob Thomson
Site Admin
Posts: 4543
Joined: Tue Dec 27, 2011 11:34 am
Country: United Kingdom
Location: Albury, Guildford
Contact:

Re: PPM to PWM

Post by Rob Thomson »

Lol.

Not knocking your project. Everything has its place.

All depends on if you are into DIY or not. Which is why I mentioned the commercial option.

Rob
Slope Soaring, FPV, and pretty much anything 'high tech'
...........if you think it should be in the wiki.. ask me for wiki access, then go add it!

User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: PPM to PWM

Post by jhsa »

yes of course.. :)
I guess if you're not into DIY, you might just as well buy an 8 channel receiver instead of the decoders.. :D

João
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
User avatar
Rob Thomson
Site Admin
Posts: 4543
Joined: Tue Dec 27, 2011 11:34 am
Country: United Kingdom
Location: Albury, Guildford
Contact:

Re: PPM to PWM

Post by Rob Thomson »

Big advantage of these devices is with fpv models using UHF.

You often need to put the rx in a strange place - like the tail!

A ppm expander like this allows you to use just one wire from the rx, to both power it - and drive the servos from a Usefull location.

Rob

Sent from my GT-I9300 using Tapatalk
Slope Soaring, FPV, and pretty much anything 'high tech'
...........if you think it should be in the wiki.. ask me for wiki access, then go add it!
User avatar
MikeB
9x Developer
Posts: 18010
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: PPM to PWM

Post by MikeB »

João:
I've spent a little time looking at this, Here's a start using "real" code instead of the Arduino libraries.

PPM_PWM.zip
(1.34 KiB) Downloaded 436 times
PPM_PWM.zip
2nd effort
This now uses tables to direct the pulses and time them.
Coded for 8 channels output, 4 then 4 more, only 4 sent now.
To avoid interrupts colliding, I send the shortest pulse first.
10uS later I start the next shortest, and so on.
(1.54 KiB) Downloaded 396 times
PPM_PWM.zip
3rd effort
Reads the PPM inpit (on IO8, PB0)
Sends out 8 pulses.
Drops to failsafe setting if no input
(2.87 KiB) Downloaded 522 times
3rd version seems to be working as required for PPM input.

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
User avatar
MikeB
9x Developer
Posts: 18010
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: PPM to PWM

Post by MikeB »

Second version added to the post above.
Next is to decode the PPM input. I shall need to use PB0 (IO8) for the input as this is the timer 1 capture input.

For the Sbus input, I think we will need to use a hardware inverter into the hardware serial, although it may be possible to read the Sbus in software (takes around 3mS), then send out 2 lots of 4 pulses in the 6mS gap before the next Sbus data arrives. Maybe send 4 pulses in one gap, and the other 4 in the next gap.

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!

User avatar
Kilrah
Posts: 11109
Joined: Sat Feb 18, 2012 6:56 pm
Country: Switzerland

Re: PPM to PWM

Post by Kilrah »

Frankly I'd have gone the simple route - emulate the 4017.
Use an entire 8-bit port as output, set it to 1 at the first active edge, and just shift it on subsequent ones. Run a timer that resets the port to 0 if no active edge is received.

About one page of assembly code, negligible jitter, and does the job :)
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: PPM to PWM

Post by jhsa »

MikeB wrote:Second version added to the post above.
Next is to decode the PPM input. I shall need to use PB0 (IO8) for the input as this is the timer 1 capture input.

For the Sbus input, I think we will need to use a hardware inverter into the hardware serial, although it may be possible to read the Sbus in software (takes around 3mS), then send out 2 lots of 4 pulses in the 6mS gap before the next Sbus data arrives. Maybe send 4 pulses in one gap, and the other 4 in the next gap.

Mike.
Mike, thank you for spending some time on this.. I gotta say, I can understand a few lines of the arduino code. But normal C looks like Hieroglyphs to me :mrgreen:
Will program the arduino in a little while.. Need to catch up with the other testing as well ;)

The original project was to decode PPM into PWM for the servos.. Are we talking S-Bus as well now? :o ;) :D

João
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
User avatar
MikeB
9x Developer
Posts: 18010
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: PPM to PWM

Post by MikeB »

Sbus as well, hopefully, which is why I didn't do as Kilrah suggested, I wanted output code that would work for either.
I can see no reason one piece of code could auto detect whether the input was PPM or Sbus and work as required!
What I will do is add a lot of comments so you can, hopefully, understand what various parts of the code are doing.

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: PPM to PWM

Post by jhsa »

Thanks Mike.. So, your idea is the arduino will recognize PPM and S-Bus automatically, and then output 8 channels PWM for servos?
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
User avatar
MikeB
9x Developer
Posts: 18010
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: PPM to PWM

Post by MikeB »

At least 8, yes.

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: PPM to PWM

Post by jhsa »

Nice.. I can see many possibilities.. 4 channel receivers sending 8 channels to servos. It will work with the X series with S-Bus, etc..

Mike just thinking here.. Maybe in case the S-Bus, PPM signal is lost, the pulses should stop? with electric models, most ESCs will stop the motor if no pulses are present.

João
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
User avatar
gohsthb
Posts: 1412
Joined: Wed Dec 28, 2011 2:32 pm
Country: -
Location: Naperville, IL

Re: PPM to PWM

Post by gohsthb »

And likely the receiver you are using will have fail safe. So if you do lose the radio link that will send the proper pulses. I see this a little different. I might make a tiny 25 that can have 4 outputs. Then you could put one or 2 in the wing, and have less cables to run.
-Gohst

Sent from my LG-D801 using Tapatalk
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: PPM to PWM

Post by jhsa »

Gohst, that was my original idea if you read back to the first few posts. The problem seem to be that the attiny's don't have a 16 bit timer? I was thinking also about assigning the channels to the pins using the PPM stream itself. For example, a jumper would put it in programming mode, and then with the tx we could assign the channels to the pins. Of course I have no idea if that is possible of not :)
Joao

Sent from my GT-I9195 using Tapatalk
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: PPM to PWM

Post by jhsa »

My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
User avatar
MikeB
9x Developer
Posts: 18010
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: PPM to PWM

Post by MikeB »

Just added a "working" version to the post above.

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: PPM to PWM

Post by jhsa »

Thanks Mike..
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: PPM to PWM

Post by jhsa »

Mike, I can see that you are forcing channel 3 to 1000uS when in failsafe.. is it not better to just stop the pulses and let the receiver handle the failsafe? If the receiver fails then there won't be any pulses, esc will cut the power to the motor anyway.
Also some people might have thr on a different channel..
If this is just like this for testing, then I do apologise, and what I wrote above doesn't apply :)

João
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
User avatar
Kilrah
Posts: 11109
Joined: Sat Feb 18, 2012 6:56 pm
Country: Switzerland

Re: PPM to PWM

Post by Kilrah »

Just found this if you need many channels and conversions in all directions between ppm, pwm and sbus:
http://www.fpvmodel.com/rmilec-high-pre ... _g478.html
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: PPM to PWM

Post by jhsa »

that's what I would call a 3 in 1 :mrgreen:
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
User avatar
MikeB
9x Developer
Posts: 18010
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: PPM to PWM

Post by MikeB »

Yes, the failsafe settings are for testing. Ideally we need to be able to set them and store them in the EEPROM.
We probably need a small button that you press for (say 1 second) to set the failsafe to the current PPM input, and perhaps press for 3 seconds to set the failsafe to no pulses.

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: PPM to PWM

Post by jhsa »

good idea.. Mike, any chance of something similar working on an attiny?
Specially if making a 1 cable connection like with s-bus, 4 channels per unit would be enough as we would have several on different parts of the model. The boards would then be rally small.

João
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: PPM to PWM

Post by jhsa »

I'm having a problem. When using 2 boards with 4017, sometimes when certain servos are close to each other, one of them will have glitches when I move the other.. when I separate them, the glitches stop.
I scoped the channel of the servo that would glitch and indeed noticed that sometimes when I moved the other servo the pulse would very briefly go to zero. please see the video. but you have to really look well because it is very difficult to get it on the scope and on video. you will see sometimes a line appear at the bottom. also the top of the pulse fluctuates a bit..
this only happens when the servos are close.. as I said, when I separate them, it doesn't happen.
I would like to understand why this happens.. :(

João

[BBvideo 425,350]http://www.youtube.com/watch?v=CXkPnFI6 ... e=youtu.be[/BBvideo]
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
User avatar
MikeB
9x Developer
Posts: 18010
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: PPM to PWM

Post by MikeB »

jhsa wrote:any chance of something similar working on an attiny?
The ATTINY44A is a 14 pin device and has a 16 bit timer so should work.

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: PPM to PWM

Post by jhsa »

hmmm, I was thinking of something smaller.. could it run on the internal oscillator to save some space?

João
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: PPM to PWM

Post by jhsa »

On this video you can see better what's happening.

[BBvideo 425,350]http://www.youtube.com/watch?v=dgPgj0my ... e=youtu.be[/BBvideo]
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
User avatar
MikeB
9x Developer
Posts: 18010
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: PPM to PWM

Post by MikeB »

Re glitching: Which channels are the servos on?

The internal oscillator won't be accurate enough.
Non of the 8-pin devices have a 16 bit timer, nor do any of their timers have an input capture function.

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: PPM to PWM

Post by jhsa »

Mike, I replaced the servo and it seems that the glitching stopped. I even tried one equal to the one causing the problem. and it stopped. Put the other back and the glitching started. So, it might have been the servo.. will keep an eye on it..
the servo doing it was on channel 3.

about the attiny:
so, maybe the best would be to use the arduino (we can find them really cheap now) or an attiny 44A. 16Mhz? what would we need on the board? XTAL, 2 caps and a pullup resistor to the reset pin? maybe also a resistor on the input pin as we will parallel some of them? maybe we could keep it quite small after all.. maybe even smaller than with the 4017.
Thanks for looking into this Mike

João
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
User avatar
Bill
Posts: 195
Joined: Thu Jul 04, 2013 5:54 pm
Country: -

Re: PPM to PWM

Post by Bill »

Can't see your board that well in the video but it looks as though you could do with at least a 100 mF Capacitor across the power supply on the board and a 100 pF decoupling capacitor across the 4017.
“A good politician is quite as unthinkable as an honest banker”
They used to say "if you don’t want to work at McDonald’s, go to college." Now they say "if you want to work at McDonald’s, go to college.”
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: PPM to PWM

Post by jhsa »

on the board I have a 10uF and a 100nF in parallel on the 4017 supply.
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
User avatar
Bill
Posts: 195
Joined: Thu Jul 04, 2013 5:54 pm
Country: -

Re: PPM to PWM

Post by Bill »

OK well 100-1000 Mf for the large capacitor will probably fix the problem, 4000 series Cmos is also very sensitive to switching spikes so the small capacitor needs to be as close as possible to the chip across the power supplies.
“A good politician is quite as unthinkable as an honest banker”
They used to say "if you don’t want to work at McDonald’s, go to college." Now they say "if you want to work at McDonald’s, go to college.”

Post Reply

Return to “General RC Electronic Projects and Discussion”