Go Down

Topic: Anyone know servo-PWM duty cycle mapped values? (Read 243 times) previous topic - next topic

JeromeAriola

As the title suggests, anyone?

I want to use my ESCs, so I did some research. A guy online used servo values (0-180), but I know that my ESCs have a minimim of 700us and max 2000us to arm.

His own was servo vals; 5 for min and 180 for max.

This makes me think that servo 5 is 700us and 180 is 2000. Am I correct?

Thanks in advance

Rome

AWOL

You have all the source of the Servo class.
Use writeMicroseconds  instead of write.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

JeromeAriola

I understand, AWOL, but I am asking for the equivalent us value of the servo values...

Which file is the info I need in? It's not in Servo.h.

JeromeAriola

I found this: http://forum.arduino.cc/index.php?topic=132846.0

Knowing that 1000us is for 0 and 2000us is for 180, i can manually calc the values.


AWOL

Why calculate an approximation to the duration, when you can specify the duration?
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

JeromeAriola

I hope I'm not sounding like a incompetent monkey here, but how can I specify it? You mean like define it?

I can't find the file where the angle equivalent of the write.microseconds() function, so I linked that. It gives me a rough estimate of the PWM us values when I map(x,0,180,1000,2000)

AWOL

Quote
I can't find the file where the angle equivalent of the write.microseconds() function
The function is called Servo::writeMicroseconds ; it does exactly what is says on the tin.

I don't understand why you're fixated on the "angle" fiction.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

Robin2

I don't understand why you're fixated on the "angle" fiction.
If I understand things correctly the OP has been given some angle values and he wants to convert them to the appropriate microsecond values.


By the way, shouldn't this Thread be moved to the Project Guidance section?

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

slipstick

#8
Nov 14, 2017, 10:44 pm Last Edit: Nov 14, 2017, 10:46 pm by slipstick
Even without using writeMicroseconds() you have control over what pulse width 0 and 180 translate to. That's what the min and max parameters on servo.attach(pin, min, max) control.

The default is 0 = 544 microseconds and 180 = 2400. So in your mapping terms it would be map (angle, 0, 180, 544, 2400).

If you want 700 to 2000 set it in attach. servo.attach(servoPin,700, 2000).

It's all detailed in the Servo library reference.

Steve

Delta_G

If you want 700 to 2000 set it in attach. servo.attach(servoPin,700, 2000).

That won't make 700 be 0 degrees and 2000 be 180 though.  It just sets the minimum and maximum values that Servo will put out.  The relationship between angle and pulse length is a property of the particular servo you are using. 
If at first you don't succeed, up - home - sudo - enter.

Delta_G

If I understand things correctly the OP has been given some angle values and he wants to convert them to the appropriate microsecond values.

From what I got he is trying to give an ESC specific length pulses and is trying to figure out which angles to put into servo.write to get those lengths of pulse.  If that's really the case then forget the angles, just use write microseconds and give it the pulse length you want. 
If at first you don't succeed, up - home - sudo - enter.

slipstick

That won't make 700 be 0 degrees and 2000 be 180 though.  It just sets the minimum and maximum values that Servo will put out.  The relationship between angle and pulse length is a property of the particular servo you are using. 
It will make write(0) equivalent to writeMicrosconds(700) and write(180) equivalent to writeMicroseconds(2000). That should cover the full range of movement of a servo specified for pulse widths between 700 and 2000 microseconds and that's what the OP seems to be asking for.

You're correct that 0-180 in servo.write() angles don't map to specific physical angles. But given that the full range of movement of a servo could be anywhere from about 110 degrees to about 2500 degrees (for a sail winch servo) it is about the best we can do without individual calibration.

Steve

Delta_G

and that's what the OP seems to be asking for.

The OP doesn't even have a servo.  He's got an ESC.  ESC doesn't have an angle to it.  So it would make a lot more sense to write the pulse width you want instead of going through a bunch of machinations to turn it into degree values which are meaningless in the context of an ESC and would require his code to have math to turn his pulse widths into degrees just to have the Servo library turn them back. 
If at first you don't succeed, up - home - sudo - enter.

slipstick

The OP doesn't even have a servo.  He's got an ESC.  ESC doesn't have an angle to it.  So it would make a lot more sense to write the pulse width you want
I agree and it's what I've been doing since about the second or third time I used servos/ESCs. But since the OP had already been advised of that several times and seems oddly resistant to the idea I thought I'd try to help him understand what the servo.write(angle) function was actually doing (i.e. a small calc then writeMicroseconds()).

Steve

Go Up