Go Down

Topic: Pulse frequency and Servos (Read 9760 times) previous topic - next topic

brainybrown86

Hello,
If I use the already implemented Servo functions form Arduino, how do they behave regarding the pulse frequency of servos?:
Do the servo functions have already implemented a fixed time delay that assures that subsequent impulses are not sended too fast to the servo (e.g. in a while loop), or do I have to control for that on my own (e.g. if I had a while loop to include a delay comment after each motor command)?

If there is a delay already implemented in the servo functions, how can I change this value (e.g. if the servo allows a very high pulse frequency)?

I would be very glad for an answer.
Cheers.

Robin2

When you give a command such as myservo.write(90) the Arduino continuously produces the appropriate pulses until you give another command for the same servo. This all happens invisibly in the background.

In general you only need to give another servo.write() command when you want to move the servo arm to a different position.But it won't do any harm to repeatedly call servo.write() with the same position.

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

raschemmel

The servo library commands are written to the flashram and read from there by servo library commands. Thus , once written, the command will repeat until overwritten. In other words "what he [Robin2] said..."
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

brainybrown86

Okay, when it "continuously produces the appropriate pulses" at which pulse frequency does this happen and can this be modulated?  For, some servos allow higher pulse frequencies and some only allow lower pulse frequencies - or do I confuse something?
I would like to have the fastest control of servo moving as possible...

Thank you. 

Robin2

Sorry, but analogWrite() has nothing to do with servos.

The servo library produces a servo pulse every 20 millisecs in accordance with the normal servo standard.

I doubt if faster pulses would give a noticeable effect on the response of the servo as it takes an appreciable time (in computer terms) for the servo arm to move.

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

raschemmel

#5
Apr 25, 2014, 11:55 pm Last Edit: Apr 26, 2014, 08:29 am by raschemmel Reason: 1
Quote
If there is a delay already implemented in the servo functions, how can I change this value (e.g. if the servo allows a very high pulse frequency)?  


I don't have the answer for this question
*EDIT* The post with the link to "analogWrite" reference page was deleted because it does not apply to servo library.

Does anyone know what the OP is asking ? Is his question about duty cycle of the servo pwm ? (he doesn't mention that. His question is about delays and I don't know what delays he is talking about. When I look at the servo pwm waveform on the scope the only thing that might be construed as a delay (by a newbee) is the off time of the pwm waveform.
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

zoomkat

Seems some need to get up to speed on hobby servo operation.

http://en.wikipedia.org/wiki/Servo_control
Google forum search: Use Google Search box in upper right side of this page.
Why I like my 2005 Rio Yellow Honda S2000  https://www.youtube.com/watch?v=pWjMvrkUqX0

raschemmel

#7
Apr 26, 2014, 06:07 am Last Edit: Apr 26, 2014, 08:31 am by raschemmel Reason: 1
@Zoomcat,
Who me ? I know about PWM , but I couldn't tell what the OP was trying to ask with his questions about delays.
Was he trying to ask about duty cycle ? . I have a scope so I can look at any signals I want and I have already compared the servo pwm to the regular pwm and I know what the difference is.
The OP didn't mention duty cycle. Is that what he meant when he said delay ?

Quote
Do the servo functions have already implemented a fixed time delay that assures that subsequent impulses are not sended too fast to the servo (e.g. in a while loop), or do I have to control for that on my own (e.g. if I had a while loop to include a delay comment after each motor command)?
If there is a delay already implemented in the servo functions, how can I change this value (e.g. if the servo allows a very high pulse frequency)?  


Have you figured out what he is trying to ask ?








Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

brainybrown86

Thank you for your replies.

Okay let me perhaps again explain what I mean. I am not a native english speaker and probably I do not use the right technical terminology. I'm sorry for that.

Our goal is to constantly transform a biosignal (e.g. the eeg mu-rhythm of the motor cortex) into corresponding servo movements, with time delays as little as possible (this is really really important).

As far as I understood it, in normal servo control a PWM of 1-2ms is normally sent to a servo every 20ms, because the typical servo only has this pulse frequency of 50hz - and thus is not able to process a faster updating of new servo commands. Am I right with this?

However, we would like to use a very fast servo (the Align DS610: http://www.servodatabase.com/?sort=speed), which - in addition to his high speed (0.08 sec/60°) - is said to also have a higher pulse frequency than normal, namely 200hz. Thus, if I understand this right, this servo should be able to receive a new command each 5ms, instead of each 20ms (Aim I right with this interpretation?).

My question is now what happens if I sent two servo commands (using the implemented servo library) directly after each other: Will the second servo command immediately overwrite the first command, or will the second command only be arriving the servo after at least 20ms?
And if this is the case, how can I avoid this?

Thank you very much so far.


Robin2

I don't see anything about 200Hz on that site, and I looked at a few different servos.

I suspect (from other Threads here) it refers to the internal frequency at which the servo updates its position in response to the regular 50Hz pulses from the controller.

You couldn't rely on the new servo command overwriting the current command. Even if it did it would mean that your code would have to update it very frequently which is the opposite of how the system is intended to work.

If you really do need a 200Hz pulse rate you will either have to modify a copy of the Servo library or (which is probably easier) write your own code.

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

raschemmel

The fastest RC servo currently available is the Airtronics 94758Z.
http://www.servodatabase.com/servo/airtronics/94758z
Servo speed specs are rated by TIME/Degrees traveled, so this one , being rated for 0.06(sec)/60 deg means that the fastest possible move for 60 degrees will take 0.06 seconds which if repeated continuously would be a frequency of 16.6 hz. Obviously , if the fastest servo sold is 16.6 hertz for a 60 degree movement, you can kiss your plan of getting it to operate at 200hz goodbye. That's a pipe dream. Not possible. A medical EEG does not use RC servos, so your plan to build a working EEG chart recorder  using hobby servos and Bic pens is, well, maybe not flawed, but perhaps a little under researched. I don't know if you have ever actually seen an EEG chart recorder up close and personal, (I have, I was a medic in the AF and worked in a hospital ) but they have very delicate needles (the old mechanical ones , designed and build many years  before you were born) and one of the reasons is the energy needed to move some mass is proportional to the velocity and mass . An RC servo arm has a much greater mass than an EEG chart recorder needle so the torque needed is much greater. The needle , moving 3 cm (0.03 meters) in 5mS (200 hz) is  dist/time=velocity===>  0.03m/0.005mS=6 m/S . The fastest servo available is 3 cm (approx 60 deg)  ===>0.03m /0.06S=0.5m/S , which is 1/12th the velocity of an EEG chart recorder.
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

brainybrown86

Okay, I see that my plans are somewhow unrealistic or time-wasting, so I just will leave like it is.
I just wanted to assure to get the maximum out of what is possible with our servos.

Regarding the pulse frequency, I referred to this table here, http://www.ronlund.com/rcheli/HELP_SERVO_PULSE.html, but perhaps they refer to some other frequency?

Regarding EEG: Yes, I am acquainted with EEG, I am actually a cognitive neuroscientist.
I do not want to build an eeg recording system, I want to real-time control a robotic hand based on neuronal oscillations observed in the eeg.
And of course, I do not want to update the servos 200 times a second (10 times a second would be already awesome).
In fact, we will have to conduct some frequency analysis of the eeg raw signal (mu-component), in order to receive the final amplitude values that then can be transformed into motor commands (so there will be other latencies as well).
I just wanted to assure that there won`t be any unnecessary delays between each new calculated amplitude value and the following servo movement. But I see, that it is probably much more worth to spent more time on reducing the other possible latencies (eeg-amplifier to Matlab, online eeg artefact correction, frequency analysis, (classifier), servo command)

Thank you.

raschemmel

Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

Robin2



Regarding the pulse frequency, I referred to this table here, http://www.ronlund.com/rcheli/HELP_SERVO_PULSE.html, but perhaps they refer to some other frequency?

....

(10 times a second would be already awesome).



I think those frequency figures are all internal to the servo. Most of them refer to the standard 1500usec centre position.

If 10 times per second is OK I completely fail to see what all your questions are about as the normal servo pulses occur 50 times per second.

Or else we have been misunderstanding each other ...

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

zoomkat

#14
Apr 26, 2014, 08:02 pm Last Edit: Apr 26, 2014, 08:05 pm by zoomkat Reason: 1
Quote
I do not want to build an eeg recording system, I want to real-time control a robotic hand based on neuronal oscillations observed in the eeg.


From this statement is your robotic hand expected to have much faster movements than a human hand? The needle on a cheap undampened analog multimeter can move much faster than a human finger. The laws of inertia and momentum have to be respected when things are expected to move or change directions quickly. Have you actually setup a servo and done some testing of movement speed?  You probably modify the gearing in a standard servo similar to the below servo mod to increase the movement speed some. Lot of confusion as to PWM in servos. In a typical analog servo the internal H-bridge supplies the motor pulses at ~50hz. Digital servo H-bridges pulse the motor at much higher frequencies for better holding power (but also produced an auditory "whine" sound that some don't like). Both of these types are controlled with the standard servo pulse duration method.  

http://www.youtube.com/watch?v=wCx52hT4pu8
Google forum search: Use Google Search box in upper right side of this page.
Why I like my 2005 Rio Yellow Honda S2000  https://www.youtube.com/watch?v=pWjMvrkUqX0

Go Up