Servo pulses per second


hello, stuck on seemingly simple problem.

i trying create subroutine control rate of pulses per second servo.  

if rate = distance / time, i'm trying determine rate.  

let's say:  rate = 1000 pulses / 20 seconds
rate = 50 pulses / second

but, can't figure out how translate workable.   i'm figuring need use millis() i'm quite confused.  

if use 2 servos now, traveling different distances, starting , ending @ same time, change method?  i considered using delay(x) , delay(y) each servo, pauses entire program, causing both servos slow down.  

can me?
thank you.
brian


servo speed isn't controlled pulses per second, it's controlled internal circuitry tries move specified position (i.e. position encoded pulse width) possible.  if want control servo speed, need build own ramping function sends changing position commands on time.

if want 2 timing-based operations @ once, don't want use delay().  instead, either want use timer-driven interrupts (take @ mstimer2 library) or want poll timer , take action when period of time has elapsed.  for example:

void loop()
{
 if ((millis() % 7) == 0)
 {
   // take action every 7 ms
 }

 if ((millis() % 13) == 0)
 {
   // take action every 13 ms
 }
}

a more standard construction use variable store start time, , like

if (millis() - starttime >= duration_in_ms_to_be_timed)
{
 // take action
 starttime = millis();
}

because these timing functions don't block cpu execution delay(), can many want in parallel.

i can give pseudocode solution servo problem if post doesn't clear things you.

- ben


Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > Servo pulses per second


arduino

Comments

Popular posts from this blog

CAN'T INSTALL MAMBELFISH 1.5 FROM DIRECTORY - Joomla! Forum - community, help and support

error: expected initializer before 'void'

CPU load monitoring using GPIO and leds - Raspberry Pi Forums