Hi Guys,
I’m having an issue with controlling two motors using a Baby O, USB AVR programmer, Atmel Studio six and a benchtop power supply set at 6V. What I’m trying to accomplish is to control the direction of each motor separately by using external switches connected to the I/O lines of the controller. These switches are connected to 0V, so for example when I operate the switch connected to IO_C1, I want to rotate my crane clockwise. However when I operate the switches connected to IO_C1, C2 and C3 the motors operate at a very reduced speed and I’m only seeing 0.2-0.4V at the motor. When I switch on IO_C4 it operates fine. The baby O is currently sitting in a breadboard and I’ve checked the operation of the motors as well and they seem ok. This is my first ever robotics/programming venture so I’m pretty sure it’s to do with my code (which involved a lot of trial and error and cut and paste from examples). Any help would be gladly appreciated.
#include <pololu/orangutan.h>
void rotate_crane_clockwise()
{
set_m1_speed(100);
set_m2_speed(0);
}
void rotate_crane_anticlockwise()
{
set_m1_speed(-100);
set_m2_speed(0);
}
void extend_dolly()
{
set_m1_speed(0);
set_m2_speed(150);
}
void retract_dolly()
{
set_m1_speed(0);
set_m2_speed(-150);
}
void stationary()
{
set_m1_speed(0);
set_m2_speed(0);
}
int main()
{
set_digital_input(IO_C1,PULL_UP_ENABLED);
set_digital_input(IO_C2,PULL_UP_ENABLED);
set_digital_input(IO_C3,PULL_UP_ENABLED);
set_digital_input(IO_C4,PULL_UP_ENABLED);
while(1)
{
{if (is_digital_input_high(IO_C1))
{stationary();
}
else
{rotate_crane_clockwise();
}
}
{
if (is_digital_input_high(IO_C2))
{stationary();
}
else
{rotate_crane_anticlockwise();
}
}
{
if (is_digital_input_high(IO_C3))
{stationary();
}
else
{extend_dolly();
}
}
{
if (is_digital_input_high(IO_C4))
{stationary();
}
else
{retract_dolly();
}
}
}
}
Cheers
Justin