Pages: 1 [2]   Go Down
Author Topic: function to generate a PPM output?  (Read 3131 times)
0 Members and 1 Guest are viewing this topic.
Toronto, Canada
Offline Offline
Edison Member
*
Karma: 2
Posts: 1234
"Keep it R.E.I.L. - "Research, Experiment, Investigate and Learn"
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@rahlk

Let me get this...  A ON time of 1000 us or 1 ms to 2000 us or 2 ms.   And a OFF time of 20 ms.  You say you need 200 Hz to 300 Hz.   All right , let figure out the frequency using the Ton and Toff.

@ Ton = 1 ms or 1000 us
Toff = 20 ms

 1 / Period  = Frequency  ---->  1 / ( 1 ms + 20 ms ) = 47.61904762 Hz

@ Ton = 2 ms or 2000 us
Toff = 20 ms

1 / Period = Frequency  ----->  1 / ( 2 ms + 20 ms ) = 45.454545...... Hz

My question is : Where the 200 Hz to 300 Hz come from ? The problem is the 20 ms, it make the frequency slower.

My calculation is saying that a 50 Hz servo system will work. So can you try the servo library and see what happen ?

My 2 cent.


    
Logged

India
Offline Offline
Newbie
*
Karma: 0
Posts: 13
Electronics is clearly the winner of the day, Anyday and Everyday!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@ AWOL and Lefty-
Okay I got this. Screw the wise men (maybe they aren't that wise after all..).
Servo library works like a charm!
But here's what I did.. I used:
Code:
void setup() {
Serial.begin(115200);
}
// The channel 2 of my receiver is connected to pin 5 of my Arduino Mega.
void loop() {
Serial.print(pulseIn(5, HIGH));
Serial.print("                ");
Serial.println(pulseIn(5,LOW));
delay(50);
}

I noticed that pulseIn(5, HIGH); gives a value around 1049 to 1899 (As i gradually move the throttle stick up)
and a separate pulseIn(5, LOW); gives a value from 18900 to 17900 (again as i move the throttle stick up)
In essence this isn't a ppm (which according to many people must have a constant Toff period of 20ms).
It theoretically is a pwm pulse, which has a variable duty cycle.

So what does a servo library generate anyway, eh?
Logged

 ∙•● яÁђนl ●•∙

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 596
Posts: 33271
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
It theoretically is a pwm pulse, which has a variable duty cycle.
But PWM has a constant period which your experiments are not showing anyway.

Quote
(which according to many people must have a constant Toff period of 20ms).
I would say the Ton has to be the constant one.
It looks like the high part is supposed to be constant but is drifting a bit.

Anyway it is much more like PPM that PWM.
Logged

India
Offline Offline
Newbie
*
Karma: 0
Posts: 13
Electronics is clearly the winner of the day, Anyday and Everyday!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
But PWM has a constant period which your experiments are not showing anyway.
i guess it is a constant PERIOD pulse. If I do this:
Code:
Serial.printLN(pulseIn(5, HIGH)+pulseIn(5,LOW));
The value does 'NOT' change.
Logged

 ∙•● яÁђนl ●•∙

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 596
Posts: 33271
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
The value does 'NOT' change.
OK so you have PWM, it is not the right way to drive a servo, but some servos will make sense of it.
Logged

Offline Offline
Full Member
***
Karma: 2
Posts: 199
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

 A nice little video showing ppm and pwm .

Logged

Pages: 1 [2]   Go Up
Jump to: