Author Topic: Reading a servo position...without a servo...  (Read 1083 times)

0 Members and 1 Guest are viewing this topic.

Offline mstachoTopic starter

  • Supreme Robot
  • *****
  • Posts: 365
  • Helpful? 10
Reading a servo position...without a servo...
« on: September 14, 2011, 01:29:49 PM »
Hi all,

So here's the scenario: I have an output on my board that normally goes to an RC car's Electronic Speed Control (ESC), which takes a signal that is identical to that of a servo-- 1500us is neutral, 1000us is MAX_REVERSE_SPEED, and 2000us is MAX_FORWARD_SPEED.

Now, problem is that the robot we're working with does not have such an ESC (mainly because it's a riding lawnmower and we're already voiding the warranty by doing this  ;D) It has its own controller that can just take a PWM signal directly.

So, since I can't modify the code in the control board, and the riding lawnmower takes a PWM signal, I was thinking of just reading in the servo signal and turning it into a PWM signal.  How do I do that?  I'm aware that I could just consider the servo signal to be a PWM signal and read it like an analog voltage into something like an arduino, but the voltage range of that would be 0.26V to 0.46V and we'd not have enough resolution on an ADC.

Any thoughts?  Is there an easy way to write code that just counts when the servo signal is received and turn that into a more useful signal?

(I put this in software because I always consider coding the solution before making a circuit.  I guess it can easily go into electronics as well)

MIKE
Current project: tactile sensing systems for multifingered robot hands

Offline joe61

  • Supreme Robot
  • *****
  • Posts: 417
  • Helpful? 16
Re: Reading a servo position...without a servo...
« Reply #1 on: September 14, 2011, 01:52:45 PM »
Off the top of my head, if this is an Atmel chip you might use the input capture facility of the timer to get the frequency of the incoming signal. Don't know about other chips.

Joe

Offline rbtying

  • Supreme Robot
  • *****
  • Posts: 452
  • Helpful? 31
Re: Reading a servo position...without a servo...
« Reply #2 on: September 14, 2011, 03:28:54 PM »
The servo signal is pretty slow--any 16-bit counter should be able to record the length. Use an interrupt to trigger the counter start on the rising edge, and counter stop on the falling edge. The value in the counter should be related to the time that the pulse was high.

Offline mstachoTopic starter

  • Supreme Robot
  • *****
  • Posts: 365
  • Helpful? 10
Re: Reading a servo position...without a servo...
« Reply #3 on: September 15, 2011, 07:22:02 AM »
Thanks guys!  I went with the second option: interrupt on HIGH, start counting, interrupt on LOW, stop counting.  works like a charm.

MIKE
Current project: tactile sensing systems for multifingered robot hands

 


Get Your Ad Here

data_list