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, 8 months ago.
Problem with PWM controlled motor
Hi Mbed Community,
I am seeing help in understanding why I see the following output from my scope. Let me provide background first and my assumptions for what I believe should happen if everything was going well.
SETUP L298N H-Bridge with recommended fast-acting diodes and capacitors hooked up Controlling on motor 400W power supply set to 12V no current limit Motor is a small DC motor with 10:1 gear box Hooked up with logic level converter to IN1 and IN2 (3.3V to 5V) Hooked up mbed PWM output pin directly to ENA line Channel one of scope is hooked up to Motor + from the H-bridge and hooked to power supply ground Channelg two of scope is hooked up to PWM output from Mbed and hooked to power supply ground
WHAT I SEE When I set the duty cycle to .5 I would expect to "see" a voltage across the motor of 6V Instead, what I see is 10.4V...
On the scope, with duty cycle of .5, when the portion of the PWM signal is high, the voltage seen at Ch 1 on the scope is 12V, which is what I expect. When the portion of the PWM signal is low, the voltage seen at Ch 1 on the scope IS NOT 0V, instead is 10V (actually it has fluctuations between 7.2 and 10.4)
If I adjust the PWM duty cycle and as it approaches 1, the voltage seen during the off portion of the cycle approaches 12V. If I adjust the PWM duty cycle and as it approaches 0, the voltage seen during the off portion of the cycle approaches 0V.
Any clue at what is going on or is this what I should expect?
2 Answers
10 years, 8 months ago.
Hi Joshua,
From what i understood i can tell you the following :
1- If you're using a level converter then you shouldn't connect the PWM directly to the L298, you should route it through the level converter first (Since its waiting for a +5v logic and the mbed outputs +3.3v).
2 - To control the motor using the L298, from looking at the data sheet you should connect your PWM pin to the INPUT pins not the enable pins (i.e INPUT1 & INPUT2 to control channel A for example). The Enable pins will activate the motor if High and disconnect it if LOW
Hope that helps
Regards
I have PWM hooked up through a log level converter already. As for determining I am supposed to PWM the input pin, what have you that info on the data sheet? Might pointing me to that info?
I will try again doing so and see what happens!
posted by 11 Mar 2014datasheet can be found here :
L298N Datasheet https://www.sparkfun.com/datasheets/Robotics/L298_H_Bridge.pdf
take a look at pages 3 and 6
a control example : set Enable pin to high and PWM IN1 and set IN2 to LOW. the motor will rotate with certain speed in a given direction
posted by 11 Mar 201410 years, 8 months ago.
The running motor will act as a generator during the PWM-off time which explains the voltage that you see. You could use the bridge to actively shortcircuit the motor during the PWM-off parts to even ''brake'' the motor...
Do the mbed and your motor driver have a single shared ground?
posted by Erik - 10 Mar 2014Hi Erik, yes they share a single ground
posted by Joshua Liu 10 Mar 2014