go_away

Author Topic: Toggling power to a servo with Axon  (Read 811 times)

0 Members and 1 Guest are viewing this topic.

Offline GertlexTopic starter

  • Supreme Robot
  • *****
  • Posts: 744
  • Helpful? 23
  • Nuclear Engineer Roboticist
Toggling power to a servo with Axon
« on: April 17, 2012, 11:12:25 PM »
I am powering an HS-55 micro servo directly via the Axon's regulated 5V and hardware PWM.  The servo in action can be seen below (sound not recommended :D )
 
linky


It works except for one detail... there's enough resistance on the pushrods that are being actuated such that the servo doesn't usually get all the way back to its intended position after it's done moving.  It'll be like a single degree off and keep trying to get to center, but not able to overcome friction.  This is bad as it's wasting current, and possibly shortening the life of the servo.

What I would like to do is be able to toggle the power supply to the servo via software.  As the vid shows, the servo goes back and forth 3 times (when I press a button).  It seems I should be able to turn power on/off for the duration of this actuation.

From the Axon datasheet, I evidently do not want to use the digital IO pins (they supply 10 mA or so; servo takes about 150 mA in no-load movement).  Is there some other pin to toggle purely in software?

I suspect what will work is to have a transistor somewhere.  A digital IO going to the transistor's base, and splice collector/emitter into the 5V wire for the servo.  Or do I want to splice into the ground wire?

Any insights? Thanks!

Edit: It was brought to my attention that I ought to be able to disable the PWM temporarily... will have to look into this as well.

Edit2: Can the PWM be disabled by setting the pulse-width to 0? (and setting the limit to that in Project Designer as well)
It seems I might be able to pin_low(E3);... Going to test this.

Edit3: I found that the following does not work - when the button is pressed, the servo still holds position.  Do I need to disable the timer?
Code: [Select]
if(SWITCH_pressed(&button)){
// pressed
pin_low(E5);
}

if(SWITCH_released(&button)){
// released
:
TICK_COUNT ms = loopStart / 1000; // Get current time in ms
int16_t now = ms % (TICK_COUNT)10000; // 10 sec for a full swing
if(now >= (int16_t)5000){ // Goes from 0ms...5000ms
now = (int16_t)10000 - now; // then 5000ms...0ms
}

DRIVE_SPEED speed = interpolate(now, 0, 5000, DRIVE_SPEED_MIN, DRIVE_SPEED_MAX);
act_setSpeed(&servo,speed);

}

Edit4: I found that pwmOff(E3) works, but can't turn it back on... so I'm looking at the PWM duty cycle methods.
« Last Edit: April 18, 2012, 06:30:44 PM by Gertlex »
I

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,150
  • Helpful? 109
Re: Toggling power to a servo with Axon
« Reply #1 on: April 18, 2012, 06:41:44 PM »
If its just a standard servo then you can stop sending it pwm, and turn it back on again, using the act_setConnected command (see the manual: for C - http://webbot.org.uk/WebbotLibDocs/27168.html#obj_27238 for C++ then http://webbot.org.uk/WebbotLibDocs2/43888.html )

The only times this doesn't work is if there is a 3rd party board in-between your controller and the servos. Mainly coz they don't provide a similar cmd for WebbotLib to give them.
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline GertlexTopic starter

  • Supreme Robot
  • *****
  • Posts: 744
  • Helpful? 23
  • Nuclear Engineer Roboticist
Re: Toggling power to a servo with Axon
« Reply #2 on: April 18, 2012, 06:50:20 PM »
If its just a standard servo then you can stop sending it pwm, and turn it back on again, using the act_setConnected command (see the manual: for C - http://webbot.org.uk/WebbotLibDocs/27168.html#obj_27238 for C++ then http://webbot.org.uk/WebbotLibDocs2/43888.html )

Thanks!

Quote
The only times this doesn't work is if there is a 3rd party board in-between your controller and the servos. Mainly coz they don't provide a similar cmd for WebbotLib to give them.

I had read you mention similar before... and then my brain forgot the external controllers part, and so I never tried the connection methods  :-X
I

 


Get Your Ad Here