Welcome! Log In Create A New Profile

Advanced

PWM and Stepper drivers

Posted by Schultz 
PWM and Stepper drivers
December 08, 2008 08:38AM
I'm having problems with the Sanguino or the motor driver, but I think it's the Sanguino.

I've got the Sanguino to run motors with one 3aixs board but only at one speed, and I can switch direction no problem. When I hook it up to another 3 axis board it will only spin the motor a few rotations then quit. If I just hook up LEDs to the PWM output I can see the voltage go from 0-2.5vdc, and the ligt vary in brightness as I adjust the analogWrite command up and down, however when it's connected to a driver boards the voltage is nearly zero no matter how high the analogWrite command is set.

Any suggestions to what is driving the signal down so much?
Re: PWM and Stepper drivers
December 08, 2008 09:32AM
I was giving this some more thought. Do I need to connect the PWM board between the Sanguino and the 3 axis motor driver board?
sid
Re: PWM and Stepper drivers
December 08, 2008 11:14AM
Nope the pwm is connected to the arduino/sanguino but not to any other board

this wiring diagram might help:
[www.reprap.org]

(just replace the arduino with the sanguino; make sure to use the correct pinout since that might be different (I'm pretty sure it IS))

'sid
Re: PWM and Stepper drivers
December 08, 2008 01:02PM
Thanks for the schematic. It appears that I'm doing something completely different and likely wrong. The diagram shows the step for the motor drivers connected to digital and sometimes digital/pwm outputs. Looking through the Arduino examples they have the stepper driving by digitalWrite commands and not analogWrite commands as I was trying to do. I was thinking the PWM wave using the analogWrite would work for the drivers, but so far it hasn't.

Do I just use a digitalWrite(HIGH) command with a delay loop to create the step wave to the motor driver? Does anyone have any code examples they can point me to?
Thanks,
Tim
Re: PWM and Stepper drivers
December 08, 2008 05:33PM
Schultz Wrote:
-------------------------------------------------------
> Thanks for the schematic. It appears that I'm
> doing something completely different and likely
> wrong. The diagram shows the step for the motor
> drivers connected to digital and sometimes
> digital/pwm outputs. Looking through the Arduino
> examples they have the stepper driving by
> digitalWrite commands and not analogWrite commands
> as I was trying to do. I was thinking the PWM
> wave using the analogWrite would work for the
> drivers, but so far it hasn't.
>
> Do I just use a digitalWrite(HIGH) command with a
> delay loop to create the step wave to the motor
> driver? Does anyone have any code examples they
> can point me to?
> Thanks,
> Tim
Hi Tim

There's a stepper motor test program on the stepper motor test page. Look on the package the parts for it came in for the url link.
Re: PWM and Stepper drivers
December 09, 2008 04:01AM
Ah, I think I know what's up here Schultz. The stepper driver boards are expecting digital inputs; Direction and Step. Step might not be what you're expecting.

The idea is that for every pulse the stepper driver board receives on the Step pin, it moves the stepper forward (or backward) one step. So if you hook it up to a PWM output and give it any analog value other than 0, the driver will drive constantly at the PWM chopping frequency; the actual PWM setting will make no difference, as the stepper motor driver doesn't care what the pulse width is, it only cares how many pulses per second it gets.

The PWM pins are normally used for the analog outputs, such as the DC motors and the nichrome heater; if you hook up the stepper driver to a PWM output pin, you'll need to run that pin as a digital output and not a PWM. Works fine, as long as you didn't need the PWM elsewhere.

You'll have to combine a digitalWrite(High) with a digitalWrite(Low) to get a full pulse; but yeah, that would do it. Have a look at the guts of the Arduino Gcode code here:

[reprap.svn.sourceforge.net]

The actual step code is pretty simple:

184 void do_step(byte step_pin)
185 {
186 digitalWrite(step_pin, HIGH);
187 delayMicroseconds(5);
188 digitalWrite(step_pin, LOW);
189 }

This is called every time you determine you need to move to the next step (0.125 mm on my machine); the high time is only 5 microseconds.

Hope that helps!

Wade
Re: PWM and Stepper drivers
December 09, 2008 09:00AM
Wade
That helps a lot, and explains my problems. I was trying to use the analog signal and not the digital signal for driving the motors. I'll test it today sometime and let you know.

Thanks
Tim
Sorry, only registered users may post in this forum.

Click here to login