I'm trying to get my stepper to run smoothly and everything I've done seems to be almost but not good enough. The code below somehow spins it at a decent rate for about 3 or 4 seconds and then it starts pulsing. I can change the delay length and it pulses different so I know it has something to do with that area of the code...but nothing I do will smooth it out how I want.
I also can't come up with how to change speed/rpm even with using the help on the arduino site. This is killing me! LOL I know this is supposed to be basic, but any help is appreciated!
int dirPin = 7;
int stepperPin = 6;
void setup()
{
Serial.begin(9600); //Speed of information transfer
pinMode(dirPin, OUTPUT); //dirPin specifies input or output
pinMode(stepperPin, OUTPUT);
}
void loop()
{
digitalWrite(stepperPin, HIGH); //coil on
What kind of stepper drove are you using? A motor shield requires lines to be toggled in sequence, in fact there is a stepper class for such control. Also 50 microseconds is like insane fast for a stepper, 30 milliseconds is really fast (180 Hz).
This is a microstepping driver yes? Well its certainly step+direction pins so I'll
assume so.
You cannot just start sending step pulses at full speed, that motor will just not keep
up and mis-step, guaranteed. You have to ramp the rate up to allow the rotor to
accelerate up. The AccelStepper library does this (although I'm not sure its good enough for
a fast microstepping driver though).
There are two basic approaches to ramping up step rates - either adjust the
delay between step pulses, or adjust the proportion on clock ticks on which
you send a pulse using DDA style techniques and a timer interrupt.
BTW you only need to pulse the step pin for 10us high only, like this:
void loop()
{
digitalWrite(stepperPin, HIGH);
delayMicroseconds(10);
digitalWrite(stepperPin, LOW);
delayMicroseconds(delay - 10); // the delay you can vary.
}
(In fact most drivers are happier with shorter step pulses, but 10us allows for a
slow optocoupler)
ajofscott:
What kind of stepper drove are you using? A motor shield requires lines to be toggled in sequence, in fact there is a stepper class for such control. Also 50 microseconds is like insane fast for a stepper, 30 milliseconds is really fast (180 Hz).
The driver is a Big Easy Driver. The motor is a 400 step/rev NEMA17.
Do you know what NEMA17 means? It refers to a standard for mounting hole locations. That tells us NOTHING about the motor.
Why are you now using the Stepper library? How are you powering the motor? You may not be supply enough current to drive the stepper at the speeds you are trying to spin it.
Then I have no idea how to tell you what motor I have, much like I'm not sure about any of what I'm doing aside from the end product.
I'm using a 12V 1.5A wall plug for power. I don't necessarily want a super speedy rotation, I just want to learn how to control it. I'm not using the library because I tried and failed, came across this code and it actually accomplished something.
Stick a decent sized delay as the very last statement in loop, say delay(1000). As ajofscott suggests, you may simply be trying to step the motor faster than it can go. Obviously, if it helps, you can then reduce it to try to get the speed you're looking for.
It still pulses, regardless of what numbers I put in the delay. If I put 50 in both it moves at a good pace but pulses, if I put 1000 in both it just vibrates and stays in place like it's just resonating or something. None of this makes sense really.
What I'm suggesting is that you leave your existing delayMicroseconds delays as they are and put an additional large delay in milliseconds after them. What I'm hoping that will do is step the motor a single step every second without the pulsing symptom you see (although I'm really not sure what you mean by this).
If it works, you can gradually reduce the big delay to increase the motor speed.
Hopefully you can hear it in the video, as it doesn't really show it visually. I realize it is probably the delay that I am calling a pulse, but I'm lost on how to get the motor to run smooth and change its speed. At this point I'm at a loss for all of this as just getting it turning is not my end goal, and I imagine this is about as basic as this gets.
I was under the impression the driver took care of voltage, so long as it was between 4 and 30v. The diagrams I have seen all use a 12 volt source. I will have to figure out how to power it properly.
Using the EasyDriver’s current regulator
If you use use a higher voltage adapter than your stepper motor is rated at (this one is 12V) you could be supplying too much current, and could damage the motor. You can dial down the current on the easyDriver using the small dial on the board if needed – it can limit the current from 150ma – 750ma. This particular motor is rated at 300ma maximum. This basically gives you a way to only supply the motor what it needs if you could be supplying too much.
It isn't even capable of sink/source currents that your motor requires. An Arduino Motor Shield R3 would do it provided that you used the current sense amplifiers to control a PWM signal to the applicable ENA/ENB signal lines. There are 2 current sense amps one for channel A and one for channel B. Mapped to A0 and A1 respectively. You should be aware that HV chopper driving the motor will make it acoustic (noisy), this isn't a malfunction but an artifact of HF excitation and the permanent magnet rotor.
Well, it is safe to say I have absolutely no clue what I'm doing and have made zero progress. Why does it say it is capable of 4-30volts if it in fact...isn't? Maybe I am reading that claim wrong which is highly likely. I'll put everything away before I damage something and try to find someone that will help me in person and walk me through this.
For arduino to claim any of this is "easy" or "beginner friendly" is off base IMO.
Amps = volts/ohms. The 4-30V is the voltage limitation, the higher the step rate, the higher running voltage at the winding due to inductances. IPK = Voltage*time/inductance. IPK cannot exceed 750mA. So take a deep breath, the smoke is still in the black boxes, take some time an do some reading and research, including but not limited to clicking on my username and selecting other posts by this member. I have been doing alot of Q&A on steppers recently.
To get the most out of this setup, using the Big Easy Driver and the motor I have...how do I need to power it? Maybe if I can just get that done I can re-attempt the code and actually make something of all of this.