PDA

View Full Version : PWM stepper motor driver



micronewb
06-01-2010, 10:12 PM
I am working on running some stepper motors for a walker and I am interfacing with a microstep motor driver. The only problem I am having is I am losing my PWM signal at 28Khz. I am setup on the oscilloscope and the signal drops out higher than that frequency. I have tried writing a spin version using waitcnt and have tried the pwmx8 object. Any ideas why this is happening and how i can increase the frequency, I really need a signal up to at least 35 Khz. Thanks in advance for any help!

ElectricAye
06-01-2010, 10:33 PM
You should probably include some more details of your circuit design. For example, does this dropout occur only when the Propeller is connected to your motor or does it happen even when the motor driver is disconnected from your Prop? What stands between the Prop and motor, what sort of driver? A schematic would be most helpful.

Mike Green
06-01-2010, 10:44 PM
Ditto. There's no inherent reason why a Propeller can't do PWM above 28KHz. Without further information about your circuitry, driver, and code, it's impossible to guess why it doesn't work.

micronewb
06-01-2010, 10:45 PM
Right now I have the motor controller disconnected from the prop and am just viewing the signal on the I/O pin I am going to use. I have connected the motor controller and the signal quits at the same point as when it is not connected. I know you asked for a diagram, but right now I can't even get a frequency higher than 28 kHz without anything connected. Just to answer some of your other questions the motor controller is the US Digital MD1, and I can drive the stepper up to the 28 kHz, and I know the motor controller can go higher because I have pushed a much higher frequency signal with a commercial product that ran fine, so I am pretty confident if I can get the propeller to output the signal with a high enough frequency I can make the motor controller work.

micronewb
06-01-2010, 11:13 PM
Another update: I wrote a simple spin code that sets a pin to output and then triggers high and low without a pause. The fastest the chip will run is around 67 kHz. By the time I add a few lines of code to control my output this isn't unreasonable to see the drop in frequency. Is this a hardware limitation?

ElectricAye
06-02-2010, 12:36 AM
micronewb said...
Another update: I wrote a simple spin code that sets a pin to output and then triggers high and low without a pause. The fastest the chip will run is around 67 kHz. By the time I add a few lines of code to control my output this isn't unreasonable to see the drop in frequency. Is this a hardware limitation?


Do you have the external 5 MHz crystal hooked up properly? Is your clock phase-locked loop set properly?

In your CON section you should have:





_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000



Post Edited (ElectricAye) : 6/1/2010 5:42:24 PM GMT

micronewb
06-02-2010, 01:00 AM
i'm actually using the 6.25 crystal but yes this is what the con block looks like:

CON
_clkmode = xtal1 + pll16x
_xinfreq = 6_250_000

Timmoore
06-02-2010, 01:03 AM
You could use one of the objects in obex that use pasm for pwm generation e.g. pwm_32_v2 from beau, is one I use.

micronewb
06-02-2010, 01:30 AM
Does his object only take integer values for the timeon and timeoff? If so I need more control over the frequency than integer values are giving.

Timmoore
06-02-2010, 01:43 AM
The time is in multiples of the resolution 8.15us, that gives an upper Hz of ~61KHz unless you modify the object, it supports 32 pwm outputs, reducing that no will increase the resolution. though the higher the speed the less effective resolution you have over the pwm signal.
Another option is phil did an object that used the vga hardware to generate pwm. If I remember correctly it could do ~80KHz with 8bits of resolution, it is also in obex.

StefanL38
06-03-2010, 02:37 AM
you are right with a small loop in SPIN

like this




CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000

PUB Main
dira[15] := 1

repeat
!outa[15]




I get around 43 kHz

not much commands left to stay above 35kHz

So if you want to do 35kHz the signal has to be generated in PASM

Is your steppermotor continoius rotation and it is NOT important if you loose some steps?

Or do you need to control it and calculate with every single microstep ?


How about attaching your code to a posting as a propellertool archive to make sure that all files needed are included
and then let forum members take a look at your code and test it on theier propeller-chips?

It could be some really dumb detail but how should we know without looking into the code?

best regards

Stefan

Post Edited (StefanL38) : 6/2/2010 7:55:58 PM GMT

micronewb
06-03-2010, 02:53 AM
I got a response back from Dave and he said my code was trying to execute faster than the spin language can handle, so I am going to rewrite the routine in assembly and if that doesn't do the trick I will definitely post my code back...I might anyway i'm not the best assembly programmer :) Thanks for the help everyone.

robotdigg
06-10-2010, 09:15 AM
That depends on stepper motors
28KZ or 32KZ is a division. At this time the current is highest, as well the Back-EMF. Maybe surpass your motor's rated.

micronewb
06-17-2010, 07:09 PM
Hey everybody,

Turns out assembly solves all the problems. I can get my pwm signal up to 2.8 Mhz now. I lose resolution quickly after 2.0 Mhz as expected, but thanks again for the suggestions.

Gavin.

Zap-o
06-17-2010, 11:45 PM
Where is some code I would like to learn from the *** code. I need to run steppers at times and I cant get them to go any faster either..

micronewb
06-18-2010, 12:40 AM
Zap-O,

My only warning is we run through a motor driver currently so this will strictly give you a PWM signal. I don't take care of the stepper phases in this program, but if this is what your looking for have at it.