Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
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
- 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 04 Apr 2014