3
\$\begingroup\$

Edit: The motor consumes 130 mA, I have tried the ULN2803A and the L2930DNE, but there is no way to make this work..

I thought this question would be already asked, but I have used the search tool and I did not find it.

I am trying to control 2 motors of a robot-car(5V DC) with an infrared remote-control. To ensure that the program is written correctly, I used 2 leds simulating the motors, and it succeeded. Once I know it works, I changed leds for the motors, and it did not work. It is obviously because of the lack of current, but I do not know how to deal with it. I used the bc547c transistor, with some resistors between 500 ohm - 40k ohm, but it did not work. I used the Darlington configuration with the bc547 and bd139, same resistors, but it did not work either. With this last configuration, the motor moves a bit, but in more or less 5 seconds the micro gets reset.

Do someone have an idea of how to deal with it?.

Thank you very much.

Kind regards.

PD1: I am using PIC18F2520. PD2: I tried these 2 configurations.

enter image description here

enter image description here

\$\endgroup\$
  • \$\begingroup\$ Can you use the schematic tool to sketch how you connected the transistor to your microcontroller? Also, is there a datasheet for the motors available? There are so many different motors, we have no clue what current requirements they have. \$\endgroup\$ – Arsenal Feb 6 '15 at 22:36
  • \$\begingroup\$ You might have killed your microcontroller output pins with the first try when you directly connected the motor. Make sure you use new pins, or maybe even a new chip. If the controller resets, this might hint that you've got a power supply problem: As soon as the motor draws current, the voltage drops because the source can't deliver. Did you use decoupling capacitors (100n+)? Really fat 470µF on the rails powering the motor will help buffer some energy and smooth the voltage. (Monitoring the voltage with a scope would also be helpful.) \$\endgroup\$ – DerManu Feb 6 '15 at 22:45
  • \$\begingroup\$ About killing the microcontroller pins, it's a good suggestion, but I know they work because always before connecting the pin to the motor I test it with a led, and it works perfectly. About the specific current needed I have no idea because I bought a package, but I will look for the datasheet of the motors. I tested the motors directly with the power supply ( 3 AA batteries of 1.5V ) and they work correctly, so the battery can supply the motor. \$\endgroup\$ – Manuel Joaquín Feb 6 '15 at 23:05
4
\$\begingroup\$

There appear to be two things going on here:

  1. You need to be able to switch the full current the motors require. A simple way to do that is with a FET low side switch:

    This particular FET can be driven directly from a PIC pin without any additional parts.

    Note the reverse diode across the motor. This is not optional.

  2. Your power supply can't supply the full motor current. You mention that the micro gets reset when you do get the motor to move a little. If the power supply can hold up the voltage, then this shouldn't be happening. Try to run just the motor off the power supply directly, and watch its voltage. If it goes down, then you need to get a beefier power supply.

    Other possible causes of resetting are that you omitted the reverse diode across the motor (D1 in the example above), omitted the bypass cap across the Vdd/Vss pins of the micro, MCLR is not properly held high, or the PGM pin is floating and LVP is not disabled (the default). Make sure that ALL power and ground pins are connected, including AVdd. And each power pin gets its own 100 nF to 1 µF ceramic cap close to the chip back to the nearest ground pin.

\$\endgroup\$
  • \$\begingroup\$ First of all, thank you for your post. My power supply can supply the motors, because they work perfectly when they are directly connected to the battery. I have read that the micro can be reset after dealing with more current than prepared for ( it happened to me when i used a relay between the transistor and the motor, PIC got reset when the relay closed the circuit). I have never heard about this mosfet, I will look for further information. \$\endgroup\$ – Manuel Joaquín Feb 6 '15 at 23:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.