Power System For Robotics Controller?

Thread Starter

crazyengineer

Joined Dec 29, 2010
156
So I worked on my engineering class project which is to build a line following robot. I built it using an ATtiny and used 2 N Channel Mosfets to control two DC motors. This controller is thus far powered by a single 9 volt battery. The problem is that whenever I turn on one motor, it works fine, but when I used two motors, they won't turn on.

So is the problem that the 9 volt battery does not have enough current to drive both motors at the same time? If so, then what type of battery should I use for this project?

Also, in the future, is it better to have two different power supplies when working with project that involves controlling DC motors (one for the motors and the other for the microcontroller)?
 
Last edited:

hgmjr

Joined Jan 28, 2005
9,027
Not knowing what your motor's power consumption it is tough to say for sure but it sounds like you are probably right about the over loading of your power source. If you have a voltmeter, you can turn on both motors and measure the voltage at the output of your 5V regulator.

Can you post your source code for us to see?

hgmjr
 

Thread Starter

crazyengineer

Joined Dec 29, 2010
156
Here's the two transistors that I used

Source Code
Rich (BB code):
#define F_CPU 1000000UL
#include <avr/io.h>
#include <util/delay.h>

nt main(void)
{
	// Setting Up Internal Registers
	DDRB=0x03;
        // Sets PB3 and PB2 as inputs, and PB0 and PB1 as outputs
	PORTB=0x0C;
	
	//	Repeats indefinitely.
	while(1)
	{

		// Checks to see if sensor 1 and sensor 2 have detected a white space
		if(bit_is_clear(PINB, 3) && bit_is_clear(PINB, 2))
		{
			PORTB |= 0x03;
			_delay_ms(100);
			PORTB &= ~0x03;
		}
		//	Checks to see if sensor 1 has detected a white space, but sensor 2 has detected black
		else if(bit_is_clear(PINB, 3) &&  !bit_is_clear(PINB, 2))
		{
			//	Turns on soley motor 2 
			PORTB |= 0x02;
			_delay_ms(100);
			PORTB &= ~0x02;
		}
		//	Checks to see if sensor 2 has detected a white space, but sensor 1 has detected black
		else if(!bit_is_clear(PINB, 3) &&  bit_is_clear(PINB, 2))
		{
			//	Turns on soley motor 1 
			PORTB |= 0x01;
			_delay_ms(100);
			PORTB &= ~0x01;
		}
		
		else
		{
			// Turns both motors off while leaving the state of the sensors intact 
			PORTB &=0x0C;
			_delay_ms(1000);
		}

	}
	return 0;
}
Also, I'm using two of these for line detection
 

hgmjr

Joined Jan 28, 2005
9,027
The mosfets appear to be a good choice for this application. Also your reflective optical sensors look reasonable for the application.

Does the LED that you are using to monitor the +5V power line dim when bother motors are turned on?

hgmjr
 

Thread Starter

crazyengineer

Joined Dec 29, 2010
156
The mosfets appear to be a good choice for this application. Also your reflective optical sensors look reasonable for the application.

Does the LED that you are using to monitor the +5V power line dim when bother motors are turned on?

hgmjr
Yeap. It gets dim every time. Although I tested it using these hobby motors from radioshack I'm actually using this for the project.
 

hgmjr

Joined Jan 28, 2005
9,027
Then you can bet that the 5V is being overloaded.

You may want to consider getting a couple of 4 AA battery holders and wire them in series. That will give you 12 volts maximum and keep things working for a lot longer than the 9V battery will.

hgmjr
 

Thread Starter

crazyengineer

Joined Dec 29, 2010
156
Then you can bet that the 5V is being overloaded.

You may want to consider getting a couple of 4 AA battery holders and wire them in series. That will give you 12 volts maximum and keep things working for a lot longer than the 9V battery will.

hgmjr
Do you 4 battery holders that hold 2 AA batteries?

Thank you very much for diagnosing the problem! Also, I want to build own robotics controller in the future (just for fun). Do you recommend having separate power supplies for the whole system (one for powering the motors, the other for IC's)?
 

hgmjr

Joined Jan 28, 2005
9,027
Neither of those motors provide data on current consumption so it is hard to evaluate what their current draw might be.

I would not be surprised if each motor takes 100 to 200 milliamps to operate. If I am correct that would explain why they stall when both motors are on. Keep in mind that the two LEDs are consuming power and the micro is taking its share of power.

The 8 AA batteries can deliver a lot more power than the 9V battery.

hgmjr
 

Thread Starter

crazyengineer

Joined Dec 29, 2010
156
Neither of those motors provide data on current consumption so it is hard to evaluate what their current draw might be.

I would not be surprised if each motor takes 100 to 200 milliamps to operate. If I am correct that would explain why they stall when both motors are on. Keep in mind that the two LEDs are consuming power and the micro is taking its share of power.

The 8 AA batteries can deliver a lot more power than the 9V battery.

hgmjr
I'll take your advice and hook up 8 AA batteries. Thanks!
 
Top