Power System For Robotics Controller?

Discussion in 'Embedded Systems and Microcontrollers' started by crazyengineer, Jan 19, 2012.

  1. crazyengineer

    Thread Starter Member

    Dec 29, 2010
    156
    2
    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: Jan 19, 2012
  2. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    We need a schematic to better assist you.

    Post one here if you can.

    hgmjr
     
  3. crazyengineer

    Thread Starter Member

    Dec 29, 2010
    156
    2
    Sorry!
    [​IMG]
     
  4. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    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
     
  5. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    Also, what is the part number of your n-channel mosfet devices?

    hgmjr
     
  6. crazyengineer

    Thread Starter Member

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

    Source Code
    Code ( (Unknown Language)):
    1.  
    2. #define F_CPU 1000000UL
    3. #include <avr/io.h>
    4. #include <util/delay.h>
    5.  
    6. nt main(void)
    7. {
    8.     // Setting Up Internal Registers
    9.     DDRB=0x03;
    10.         // Sets PB3 and PB2 as inputs, and PB0 and PB1 as outputs
    11.     PORTB=0x0C;
    12.    
    13.     //  Repeats indefinitely.
    14.     while(1)
    15.     {
    16.  
    17.         // Checks to see if sensor 1 and sensor 2 have detected a white space
    18.         if(bit_is_clear(PINB, 3) && bit_is_clear(PINB, 2))
    19.         {
    20.             PORTB |= 0x03;
    21.             _delay_ms(100);
    22.             PORTB &= ~0x03;
    23.         }
    24.         //  Checks to see if sensor 1 has detected a white space, but sensor 2 has detected black
    25.         else if(bit_is_clear(PINB, 3) &&  !bit_is_clear(PINB, 2))
    26.         {
    27.             //  Turns on soley motor 2
    28.             PORTB |= 0x02;
    29.             _delay_ms(100);
    30.             PORTB &= ~0x02;
    31.         }
    32.         //  Checks to see if sensor 2 has detected a white space, but sensor 1 has detected black
    33.         else if(!bit_is_clear(PINB, 3) &&  bit_is_clear(PINB, 2))
    34.         {
    35.             //  Turns on soley motor 1
    36.             PORTB |= 0x01;
    37.             _delay_ms(100);
    38.             PORTB &= ~0x01;
    39.         }
    40.        
    41.         else
    42.         {
    43.             // Turns both motors off while leaving the state of the sensors intact
    44.             PORTB &=0x0C;
    45.             _delay_ms(1000);
    46.         }
    47.  
    48.     }
    49.     return 0;
    50. }
    51.  
    52.  
    53.  
    54.  
    55.  
    Also, I'm using two of these for line detection
     
  7. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    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
     
  8. crazyengineer

    Thread Starter Member

    Dec 29, 2010
    156
    2
    Yeap. It gets dim every time. Although I tested it using these hobby motors from radioshack I'm actually using this for the project.
     
  9. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    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
     
    crazyengineer likes this.
  10. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    What motors are you using?

    hgmjr
     
  11. crazyengineer

    Thread Starter Member

    Dec 29, 2010
    156
    2
    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)?
     
  12. crazyengineer

    Thread Starter Member

    Dec 29, 2010
    156
    2
    I tested the controller using these motors from radioshack, but the line following robot will actually use this instead.
     
  13. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    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
     
  14. crazyengineer

    Thread Starter Member

    Dec 29, 2010
    156
    2
    I'll take your advice and hook up 8 AA batteries. Thanks!
     
Loading...