Go Down

Topic: function to generate a PPM output? (Read 3 times) previous topic - next topic

Techone

@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.


   

rahlk

@ 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: [Select]

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?
?•? ?Á??l ?•?

Grumpy_Mike

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.

rahlk

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: [Select]

Serial.printLN(pulseIn(5, HIGH)+pulseIn(5,LOW));

The value does 'NOT' change.
?•? ?Á??l ?•?

Grumpy_Mike

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.

justone


Go Up