I have been working on a project with the Baby Orangutan B168 and a Power HD-1440A.
I have been able to get the servo to move using the orangutan-lib files. The problem is the servo is definitely not moving through its range of motion.
First I run a line of code moving the servo to center
servo_set(vector, 1500); //This centers and works fine
//Next I run a code that should move it somewhere to one of its maximum.
servo_set(vector, 2000); //This moves as it should but only moves about 10-15 degrees which doesn’t seem right
//If I try to move it in the opposite direction it again has a very similar problem moving only 10-15 degrees.
At this point I do not have another servo to try, but I do not believe it is code. Any Ideas? My servo a dud?
How are you connecting your servo to the Baby Orangutan? How are you powering it, and how are you powering your Baby Orangutan?
The Baby Orangutan has a dedicated 9V input from a DC Lab Supply.
I have also created a 6V dedicated rail for the servo.
No power is being taken from the Vcc on the board.
The servo signal is connected via PB1.
Well, your power setup sounds sufficient, assuming your 6V supply isn’t being current-limited. Can you try to hardcode the servo control signals:
#define F_CPU 20000000
DDRB |= 1 << PB1; // set servo pin as a digital output
while (1) // entire loop takes 20 ms
PORTB |= 1 << PB1; // set servo pin high
_delay_ms(1); // delay for 1 ms
PORTB &= ~(1 << PB1); // set servo pin low
_delay_ms(10); // delay for a total of 19 ms
_delay_ms(9); // this function can delay for a max of around 13 ms with FCPU = 20 MHz, so call it multiple times
You can change the _delay_ms(1) to _delay_ms(2) to try to send the servo to its opposite extreme, or you can replace the _delay_ms() with a microsecond delay that will give you more control over the servo position pulse. The Pololu AVR Library has a microsecond delay that might be useful.
Please let me know if this approach leads to a different behavior.
The hard code works well. Thanks. I didnt realize the hard code was going to be that easy otherwise I would have started with it.
Controlling a single servo is pretty easy if you can just use loop delays. It gets harder if you want to have your program do other things while simultaneously generating the servo signal. In that case, you’d likely want to use one of the hardware timers either to generate an appropriate PWM output or to cause an interrupt when it’s time to change the state of the servo signal pin.
I’m glad to hear the problem isn’t with the servo.