Controlling a motor using a PWM

dc motormicrocontrollerpwm

Im trying to use a Freescale FRDM-KL25Z,

enter image description here

I have been looking at the datasheet to see if I can find the maximum oputput current of the pins with no luck, im assuming its 500mA since its powered via USB

I already have my code up and running, basically im using a potentiometer connected to my ADC to change the frequency from my PWM, it comes out at the port i assign however how can I drive a DC motor without blowing the FRDM-KL25Z or anything else, the first thing it came to mind was look in the internet i found several diagrams showing a zener diode to protect the motor, but i lack the knowlege of why is that zener there, and then i found the use of NPN transistors, however that would mean im using the PWM to open and close the transistor several times while i use an external power supply instead of the power provided by the board, so I ask here, is it possible to make the motor spin WITHOUT an external power supply?

This is the most complete circuit that I have found, but still im wondering if there is a better way to do it, also D3 is a normal rectifier diode instead of a Zener in this case

enter image description here

Heres another pick where they use a resistor to limit the current going to the transistor (i asume its in order to drop the output current as low as possible) while using an external power supply to feed the motor

enter image description here

Best Answer

The maximum current that the pins can handle is going to be the same as the microcontroller that is driving it. If you are unable to find the number in this sheet, then you would want to check the number for the microcontroller. According to the datasheet, it is a MKL46Z4 MCU, and I was unable to find a maximum current. But you are correct that it would have to be under 500mA if it is powered through USB.

I don't know the specs on the motor that you are using, but I am going to make the assumption that it needs more than 500mA. If so, then you cannot control this motor without an external power supply.

PWM will not change the amount of current that is going to be drawn from the power supply, it just changes the amount of time it spends drawing that current. For example, with a 5V power supply and a motor with 1ohm resistance, the amount of current that is drawn will be 5A. Let's say you wanted to use PWM to 'output' 3V instead. That means you will want a duty cycle of 60%(3V / 5V * 100). This means that 60% of the time the motor will be drawing 5A with 5V applied to it. The other 40% there will be no current flow and no voltage. This will average out to 3V.

Motors will typically draw more current that a microcontroller can support. That is when a motor driver comes in handy. In essence, it is a transistor in which an external power supply powers the motor and the microcontroller controls it with the transistor. This allows you to supply more current to the motor while controlling it with the microcontroller. The only difference between the first and second diagrams is that the first one contains a 555 timer that does the PWM while the second one is hooked up to a microcontroller that does the PWM. They both consist of a transistor, external power supply, and schottky diode.

The purpose of the schottky diode is to prevent damage to your electronics. When you first supply power to a motor, it produces a back-EMF to resist the change. This back-EMF will cause current to flow, and to prevent the current from flowing through your delicate electronics, such as a microcontroller, the schottky diode is placed there so that it will just flow through the diode and to ground.

Related Topic