Go Down

### Topic: How to PWM stepper motor? (Read 1 time)previous topic - next topic

#### taimur21

##### Feb 14, 2013, 04:31 pm
Hi,
I am looking for any code examples about PWM control the stepper motor using arduino.
Taimur

#### PaulS

#1
##### Feb 14, 2013, 04:36 pm
Quote
I am looking for any code examples about PWM control the stepper motor using arduino.

Steppers step. You can't use PWM to take 2/3 of a step.

Explain why you think you need to, or why you think you want to, misuse PWM to "control" a stepper motor.

#### HazardsMind

#2
##### Feb 14, 2013, 04:42 pmLast Edit: Feb 14, 2013, 04:46 pm by HazardsMind Reason: 1
Steppers move with a sequence of bits.
1000
0100
0010
0001

Depending on the rate at which you switch between the sequences, will control how fast the stepper rotates.

So what you could try is set up an array of bits (that would be considered a nibble above) and switch between them with a counter and a delay.
The smaller the delay is between the sequences, the faster it will switch the array and rotate.

You can do it with case statements too.
My GitHub:
https://github.com/AndrewMascolo?tab=repositories

#### taimur21

#3
##### Feb 14, 2013, 05:35 pm
I am actually using a position encoder(Potentiometer) for stepper motor and I want PWM to maintain the speed of stepper motor.
Taimur

#### PaulS

#4
##### Feb 14, 2013, 05:38 pm
How are you making the stepper step? Are you using a motor shield of some sort?

Changing the speed of a stepper means changing when the stepper steps. PWM doesn't enter into it.

#### macavity

#5
##### Apr 22, 2013, 10:43 pm
taimur21, are attempting to use pwm to do microstepping directly on an arduino?  if so, your going to need the duty cycle of the motor and figure out what position ( think degrees ) the motor is at and where it is going to.  Then it is a matter of trig to figure out how long to pulse the pin for each of the  leads to the motor.  I'm working on this myself at the moment.

Go Up

Please enter a valid email to subscribe