Problem with "Small Motor Control Made Easy" program
Lev
Posts: 182
If you haven't already seen it, the latest Spin Zone article explains how to drive up to two DC motors at 20 kHz using Spin. Very cool, no assembly is required, which makes it easy to understand and modify. Despite that, I have have a problem I can't figure out.
The program (attached) defines constants for the direction and pwm pins for each of up to two motors. If only 1 motor is used, the unused motor is assigned a pin numbers of -1. I tested the program and it works great for any one motor, using either of my motor drivers (so I think the drivers are good). If I assign valid pins (not -1) for both motors, both motors run in the same direction at the same constant speed, alternating on for about 30 seconds, off for about 30 seconds, indefinitely. The program does not allow me to control speed by changing the "speed" variable value.
I tried isolating the control power from the motor power, thinking it might be a brownout/reset issue, but the same thing happened.
Any suggestions?
I am thinking this is a program issue and belongs in this forum. If it belongs in Robotics, my apologies.
The program (attached) defines constants for the direction and pwm pins for each of up to two motors. If only 1 motor is used, the unused motor is assigned a pin numbers of -1. I tested the program and it works great for any one motor, using either of my motor drivers (so I think the drivers are good). If I assign valid pins (not -1) for both motors, both motors run in the same direction at the same constant speed, alternating on for about 30 seconds, off for about 30 seconds, indefinitely. The program does not allow me to control speed by changing the "speed" variable value.
I tried isolating the control power from the motor power, thinking it might be a brownout/reset issue, but the same thing happened.
Any suggestions?
I am thinking this is a program issue and belongs in this forum. If it belongs in Robotics, my apologies.
Comments
Your Attachment jm_dualmotor_ez_demo.spin says its an invalid link. EDIT: It works fine now.
This code couldn't have come at a better time for me. Thanks JonnyMac.
-Ron
The article came at a perfect time for me too. I was rebuilding my Stingray after watching magic smoke come up from the MSR1. The rebuilding has been a "Flight of the Phoenix" sort of experience. I decided to use JonnyMacs Propeller board (from Gadget Gangster) for the controller, and a motor driver from Pololu. That led me to figuring out how to PWM the motors, then JonnyMacs article arrived in the mail. How cool was that?!
Thanks for the great program JonnyMac. Do you plan on submitting it to the OBEX?
John Abshier
I am using the Pololu breakout board that includes dual MC33926's. I set up the drivers for 2 pin per motor control. After tons of testing, it seems to work fine with a single motor at 20 kHz, using either driver. But, there seems to be an issue with controlling 2 motors at 20 kHz. I am not sure if the problem is with the Propeller counter hardware, with Spin execution time, or something with running the 2 motor drivers in parallel.
this thread it would be very helpful.
Thanks
Larry
It's been a while since I wrote that so I will have to review and possibly clean-up before posting in ObEx. It is my opinion that too many coders put junk code into ObEx and I don't want to be guilty of that myself.
delivery delay.
Larry
I'm currently trying to directly control the motor in a servo that has the electronics ripped out and modified for continuous rotation.
Using a motor controller, so need two prop pins to control it. Suppose can keep one pin held down or up and use the PWM on the other pin...
I was going to write an assembly driver to do it, but this might be a simpler way...
Suppose the downside is that a cog could only work 2 motors, where an assembly driver could to several.
But, I think the simplicity and readablility of this approach is much better.
Plus, this is for driving the 2 wheels of a robot, so 2 is all I need...