10 years, 1 month ago.

pwmout with motor

Hi, I am trying to run dc motor with KL25Z. my configuration is as follows:

I have mosfet switch, with source as ground, drain is connected to Vcc, and gate is connected to PwmOut of PTA4 pin. I observed when I disconnect the PTA4 pin with gate motor start running, otherwise it doesnt run at all.

Can any one tell me how to control the speed with PwmOut signal, which parameters I need to modify. what should be my pulsewidth, period and duty cycle.. help me asap, it is the part of my final year project

1 Answer

10 years, 1 month ago.

I think you mean drain is connected to the motor and than to Vcc. First test with a digital IO to switch the motor on and off. The output level of the pins is 3V. What type of mosfet are you using ? What type of motor ?

The speed is controlled with the duty-cycle. From 0.0 to 1.0. With 0.5 the pwm output is 50% on and 50% off. The frequency of this signal is controlled with the period parameter. You have to test which value will work with your setup. There is a maximum switching speed of your mosfet. If you use a low frequency you can produce sound effects .

As u suggested, i tried with Digital IO, as follows

  1. include "mbed.h"

DigitalInOut pin(PTB0);

int main() { pin.output(); pin = 0; wait_us(500); pin.input(); wait_us(500); }

in this way I was getting just sound, I increased the waiting time, it tried to move the motor, but couldnt do so I am using N-channel mosfet with DC motor. I have connected drain with the -ve of the load, that is motor, and gate is connected to Digital I/O pin can u tell me what is i am doing wrong

thanks in advance

posted by zain aftab 04 Apr 2014

one more thing, I am able to blink the led, but not able to drive the motor, i think I need some more current for it. isnt it ???

posted by zain aftab 04 Apr 2014

The USB port will not drive a motor. You need a mosfet which can be driven from a logic port. The 3V will not drive all sorts of mosfet.

posted by Peter Drescher 04 Apr 2014