Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

DC Motor hookup to MCU

Status
Not open for further replies.

nicksydney

Junior Member level 3
Joined
Sep 24, 2011
Messages
27
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,487
Hi,

I just bought a small DC motor to experiment on how to control it. I've got a STM32 Cortex-M3 dev board (attached in this post). I know how to program the board and run an app I need guidance from the expert whether what I'm doing is the right thing.

What I plan to do is connect the (+) of the motor to one of the available GPIO pin and the (-) to the GND of the available pin and then write a program to enable the (+) pin is this right ? and once the program is running what kind of data must I send to the pin ?

Can anybody please help.

Thanks
 

Attachments

  • IMG_20111112_224355.jpg
    IMG_20111112_224355.jpg
    1.7 MB · Views: 79
  • IMG_20111104_204951.jpg
    IMG_20111104_204951.jpg
    1.5 MB · Views: 80

Forget about connecting the motor directly to any mcu pin, the outputs can just give a few mA and are not intended for such loads.
You need to use a driver, this can be transistor, mosfet or IC driver but in any case a device that will be able to drive the motor using the low current GPIO signal.

Alex
 

Hi Alex,

Forget about connecting the motor directly to any mcu pin, the outputs can just give a few mA

Sorry for a basic question as I understand that the board is powered up using USB so it's a 5v so how do we calculate the output in mA ?

You need to use a driver, this can be transistor, mosfet or IC driver but in any case a device that will be able to drive the motor using the low current GPIO signal.

I have a breadboard so I connect the GPIO pin using a female-male pin and then I can use a transistor in the breadboard correct ? can you help me to understand how to know what kind of transistor to use ?

Thank you.
 

The max current that the mcu pin can give can be found in the datasheet of your mcu in the electrical characteristics section, it is not a matter of the power supply.
I assume that there are no drivers on board , if there are then you may be able to connect the motor to them

Do you just want to be able to start stop the motor or you intend to change the rotation direction too?
Do you intend to use PWM or just start/stop function?
And what is the specification of the motor?
 

Do you just want to be able to start stop the motor or you intend to change the rotation direction too?

For now I'm happy to start and stop the motor but later I also want to change the rotation but it's not important right now, just trying to get the basic first.

Do you intend to use PWM or just start/stop function?

Frankly speaking I'm not sure for this one, what I'm planning to do is just make the DC motor turn by starting or stopping it from the program eg: the motor will start and then after few seconds it will stop

And what is the specification of the motor?

When I bought the motor the packaging doesn't say anything it just says it's a DC motor, but I can give you the dimension

Length from end to to the tip = 4cm
Cylindrical top = 2cm

Thanks
 

A solution like DC Motor interfacing with Microcontrollers tutorial: L293D H-Bridge interfacing with microcontroller : 8051 Microcontroller Projects AVR PIC Projects Tutorials Ebooks Libraries codes
will be able to control the rotation direction.

The on/off solution involves a transistor like **broken link removed**
but you have to keep the base current below the max current specification of the mcu pin

or you can use a mosfet instead of a transistor
Microcontroller Interfacing Table of Contents
 

Thanks for the reply.

This is where I bought the DC motor from and it's got the specification that you were looking for **broken link removed**
 

The important characteristics are the operating voltage and current, keep the voltage in the specified range and use devices that can provide the rated current

Torque: Low
Operating Volts: 1.5- 4.5V
Nominal Volts: 3V
Speed (no load): 12000rpm
Current (no load): 0.28A
Speed (max eff): 8540rpm
Current (max eff): 0.69A
Torque (max eff): 7.94gcm
Size dia: 20mm
Size length: 25mm
Shaft length: 8.1mm
Shaft dia: 2mm.
 

Hi,

I read one of the link that you provdided **broken link removed** take note, we were lucky because our Ibase = 16mA, a microcontroller’s single pin can only source a current of about 20mA. If om/2011/03/22/how-to-drive-a-motor-using-mcu/ and it mentioned


Just take note, we were lucky because our Ibase = 16mA, a microcontroller’s single pin can only source a current of about 20mA. If

Correct me if I'm wrong does this mean that the current coming out from the MCU pin is enough to power the DC motor without using an external source as what is specified in the link ?. The DC motor specification states that the current is 0.28A am I making the right assumption ?

Thanks
 

Normally when a transistor is used as a switch it needs a base current 1/10 to 1/20 of the output current in order to saturate the trnasistor so that the collector-emitter voltage drop is kept low, if your mcu can't provide that then you can use two transistors like a predriver and driver.
Another alternative is the mosfet which doesn't need a constant driving current like a transistor.
You can also use a device like a ULN2003 or UDN2981 or ULN2065

The 16mA mentioned in the example above refer to a different mcu, you have to check the datasheet of your mcu to see the max current in your case.
What is the model of the mcu on your board?

Alex
 

Hi,

The MCU Im using a STM32 Cortex M3.Need to download datasheet.
 

STM32 is not an mcu model, it is a family name , I need the specific model so I can download the datasheet
 

STM32 is not an mcu model, it is a family name , I need the specific model so I can download the datasheet
 

Attachments

  • STM32F103VET6Datasheet.pdf
    1.1 MB · Views: 97

Sorry for the last posting meant to say --> The model is STM32F103VET6. I've attached the datasheet in the previous post for you.

Thanks for the help.
 

This is what it says in the electrical characteristics (absolute max)
Output current sunk by any I/O and control pin 25mA
Output current source by any I/Os and control pin −25mA

Then in page 71 it says
Output driving current
The GPIOs (general-purpose inputs/outputs) can sink or source up to ±8mA, and sink or source up to ±20mA (with a relaxed VOL/VOH).
In the user application, the number of I/O pins which can drive current must be limited to respect the absolute maximum rating specified in Section5.2:
● The sum of the currents sourced by all the I/Os on VDD, plus the maximum Run consumption of the MCU sourced on VDD, cannot exceed the absolute maximum rating IVDD (see Table7).
● The sum of the currents sunk by all the I/Os on VSS plus the maximum Run consumption of the MCU sunk on VSS cannot exceed the absolute maximum rating IVSS (see Table7).

IVDD and IVSS are 150mA

There is also a table in page 72, if you stay in the 8mA range then the output voltages will be 0.4v to Vcc-0.4v (this means that the output will be 0.4 instead of 0v when LOW and Vcc-0.4v when HIGH)
If you go to 20mA then this becomes 1.3v to Vcc-1.3v

I would suggest you stay to the 8mA region unless you are using only one or two pins with a current higher that 8mA, so I would suggest or the ULN/UDN chips or a mosfet or L293 (for direction control too).
You can also use two transistors (NPN+PNP) or NPN darlington

Alex
 

Ok, so let me see if I understand all this correctly (sorry just trying to get my head around it, I'm a slow learner at this :) ), so from your explanation using the either Mosfet or NPN Darlington is enough to drive the motor without using an extra source, is this correct ?
 

I don't know what you mean by extra source but all the mentioned solutions need a power supply and a switching device controlled by the GPIO.
I would suggest using an external power source for the motor because I don''t know if the power source of your board can supply the needed power for the motor
 

I would suggest using an external power source for the motor because I don''t know if the power source of your board can supply the needed power for the motor

That's what I'm trying to understand whether after calculating that we have calculate before we still need extra power source, so looks like it we still need an extra power.
 

This also depends on the power source you use for your board, if it is USB then use an external source (connect the grounds), if your power supply can provide the current for the motor and the board then you can use it but you have to get the voltage from the input (I would suggest before the board regulator) so if the voltage is >4.5v then you will need to lower it before feeding the motor.
An alternative of course is using PWM (for example 9v 50% duty) but this will complicate things at this point and will need a fast reacting motor driver.

Alex
 

The dev board is powered up using USB so I will need to use an external power source, ok this I understand better now. Now looking at the motor spec it requires 0.28A (no load) and Operating Volts of 1.5- 4.5V and Nominal Volts 3V, bit lost here what is the difference between operating and nominal volt ? should I focus on nominal volt which means I can provide source of 2 x 1.5v batteries ?
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top