If you remember from the last post, I'd utilised an H bridge to drive the motor, and that the H bridge had three inputs. Two inputs set the polarity of the two outputs, and the last input enabled or disabled the output transistors. I've thrown together a rough overview in the picture below. Things like power and encoder are deliberately omitted.
![]() |
Rough hookup |
The first iteration of the code only used the two inputs on the H bridge, as I wanted a quick test to see I was in the right place. That seemed to go well. The second iteration used all three inputs, and the result was less than great. What I got was a noisy, jerky drive from the motor, with lots of vibration and hunting as the PID loop tried to keep the carriage in position.
Now, as I'd made some code changes, I immediately blamed my code changes, even though they shouldn't have caused an issue. I went back to a simpler version of the code, and that all worked well - leaving me scratching my head. Reflashing the updated code demonstrated the same noisy, jerky, vibrating drive that I'd seen.
Wondering what was going on, I used some LEDs to monitor the output from the Seeduino Lite, but they seemed to indicate that the outputs from the Seeduino were as I would have expected them to be. Hooking up an oscilloscope to one of the drive lines and the PWM line netted me this picture:
![]() |
Input A and PWM lines |
![]() |
Motor terminals |
The green trace is one side of the motor referenced to ground, and the cyan trace is the other (apologies - colours are reverse from the previous image). I was expecting to see the green trace stay grounded while the cyan trace pulsed on and off at the same speed as the PWM signal. What I got instead was the two output channels switching polarity, driving the motor in the opposite direction! The H bridge was the source of the heavy vibration and jerkiness I was seeing. It's also odd to see that there are differences in the first and second set of pulses. So, using the enable input to PWM modulate the power to the motor was causing this strange response from the H bridge. Obviously this isn't how I'm going to get things happening.
Now, if I had read some of the links I'd posted in my previous post - especially those from Modular Circuits' H-Bridges series, I would have saved myself a lot of trouble. However, I finished writing the previous post after I discovered the issue and wanted to save you, dear reader, the trouble I encountered!
No comments:
Post a Comment