Control of a 298:1 micro metal gear motor HP @1.6A

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;
}

Hi Jay,

The Baby Orangutan can supply enough current for that motor, even at stall (although the driver will go into thermal shutdown eventually if you try to draw a continuous 1.6A from it). The problem is very likely due to an inadequate power supply. When you start a motor at full speed from rest, the motor briefly draws nearly the full stall current, which in turn is probably dropping your supply voltage below the Baby Orangutan’s brown-out level. This would also explain why your LEDs are turning off and staying off:

  1. The Baby Orangutan tries to drive the motor at full speed, causing a current spike and a drop in your supply voltage.
  2. The Baby Orangutan resets, which turns off the motor driver and allows the supply voltage to rise above the brown-out threshold.
  3. The Baby Orangutan starts running again from the beginning of your program (goto step 1)

It would probably appear to you like the Baby Orangutan isn’t doing anything when in reality it is repeatedly drawing short bursts of current from your power supply and resetting.

What is your power supply?

- Ben

Hi Ben,

Thank you for your very quick reply. My supply is 6xAA batteries which is currently at 7.6 V. I am running this directly to the Baby-O.

Cheers,

Jay

Ok progress!

I replaced the batteries with fresh ones and it’s fixed my problem.

I’m not sure why the 7.4V was not enough, but my guess is that the voltage available at the supply was only the no load voltage when in actual fact the loaded voltage is what I should be looking at to see if the supply is sufficient.

Thank you very much for your detailed reply Ben, it allowed my to fix my problem. You guys rock!

Cheers,

Jay

Your guess about that only being the no-load voltage is correct. Six fresh alkaline batteries should be over 9 V, so your batteries were pretty drained, and drained batteries can experience a steep dropoff in voltage as your current draw increases.

- Ben