Hello Pololu and friends,
I’m trying to drive a 298:1 micro metal gear motor with a Baby-O 328 under no load, at full speed. I can successfully get the motor turning at full speed if I slowly ramp up the speed of the motor using the pololu library and the function “set_motors(motorSpeed, motorSpeed);”. I read an analogue input at PC0, to which a 10k pot is connected exactly the same way a 10k pot is hardwired to ADC7. I have connected the motor to M1B and M1A. I set the speed of the motor according to the pot value read at PC0. Along with the motor connected, I have two user LED’s flashing. One is the red LED on the Baby-O hard wired to PD1, and I have another at PD2 in series with a 390 Ohm resistor. The LED’s blink according to how fast the motor is running.
My problem is that unless I start the motor at very small speeds, the motor refuses to start and my other outputs also turn off, including the blinking LEDs. I assume that for some reason there is too much current draw when I connect the motor and a chip is resetting somewhere when it experiences a ‘brown out’ or something. To me this should not be happening because the Baby-O is supposedly able to draw 3A peak current and 1A continuous through its motor ports. My whole setup only draws 90mA when running the motor at full speed. However, when I try start the motor running at full speed, the all outputs on my Baby-O die until I remove the motor.
I have tried the same code on two Baby-Os and the same thing happens. I can only draw about 170mA when starting the micro motor before the Baby-O shuts down.
Any help is greatly appreciated.
Cheers,
Jay
// F_CPU tells util/delay.h our clock frequency
//#define F_CPU 8000000UL // Orangutan frequency (8MHz)
#define F_CPU 20000000UL // Baby Orangutan frequency (20MHz)
#include <avr/io.h>
#include <util/delay.h>
#include <pololu/orangutan.h>
unsigned long prevMillis = 0;
int main(){
int pot = 0;
int ledDelay = 100;
while(1){
pot = analog_read(1);
int motorSpeed = pot/2-256; // turn pot reading into number between -256 and 255
if(motorSpeed == -256)
motorSpeed = -255; // 256 is out of range
set_motors(motorSpeed, motorSpeed);
int ledDelay = motorSpeed;
if(ledDelay < 0)
ledDelay = -ledDelay; // make the delay a non-negative number
ledDelay = 256-ledDelay; // the delay should be short when the speed is high
red_led(0); // red LED off
set_digital_output(IO_D2, LOW);
delay_ms(ledDelay); // delay
red_led(1); // red LED on
set_digital_output(IO_D2, HIGH);
delay_ms(ledDelay); // delay
}
return 0;
}