void loop(){
stepper.moveTo(500);
while (stepper.currentPosition() != 300) // Full speed up to 300
stepper.run();
stepper.stop(); // Stop as fast as possible: sets new target
stepper.runToPosition();
// Now stopped after quickstop
// Now go backwards
stepper.moveTo(-500);
while (stepper.currentPosition() != 0) // Full speed basck to 0
stepper.run();
stepper.stop(); // Stop as fast as possible: sets new target
stepper.runToPosition();
// Now stopped after quickstop
}
Stepper drives are opto-isolated and either have bare opto coupler
inputs or with resistors built in. If with resistors you just drive the step (PUL+),
direction (DIR+) and enable (ENA+) lines from Arduino and return all the
cathodes to Arduino ground.
If without resistors you simply add 150 ohm or 220 ohm resistors into each
signal yourself.
The particular model of drive linked above might have common anodes on the
opto coupler (not sure from the marking), in which case you connect to the PUL-, DIR-,
ENA- using negative logic and return the anodes to Arduino +5V.
"The ENABLE input allows the user to turn off the current to the motor by providing
a 5-12 VDC positive voltage between EN+ and EN-"
So I assumed EN pins are used for limit switches type of scenario.
Did you mean: STEP-,DIR-,EN- pins are connected to Arduino Ground (cathode)?
STEP+ to pin 9 , DIR+ to Pin 8 on arduino. (But how about EN+?)
I did not understand "in which case you connect to the PUL-, DIR-, ENA- using negative logic and return the anodes to Arduino +5V."
Does it mean: STEP- to pin 9 , DIR- to Pin 8 on arduino. (But how about EN-?)
STEP+,DIR+,EN+ pins are connected to Arduino +5V (Anode)?
This step drive is opto isolated and assuming it is has common anodes on the optocoupler, it would be great if you can point to me which drive pin is connected to where on the arduino?
STEP drive pins:
STEP+/-, DIR+/-,EN+/-
Arduino PINS:
+5V, GND, 8(DIR), 9(STEP). Again where is the EN+/- pin connected to on Arduino?
I might have found the problem. In my setup Arduino Pin 8 is connected to DIR- and Pin 9 is connected to STEP-
And my Accelstepper library is declared as: AccelStepper stepper(1,8,9);
indicating PIN 8 to be step and PIN 9 to be direction.
I realized this from reading about the accelstepper library on AccelStepper Arduino Library, connecting Stepper Motors to Teensy
Where it says: AccelStepper mystepper(1, pinStep, pinDirection);
So I swapped the pins around i.e. PIN 8 to STEP- and PIN 9 to DIR- in my setup and the stepper works fine now.
So the new setup look like this:- http://postimg.org/image/nvlkom93x/
I think you may be right..... I have been doing too of the brute force programming, just throwing things at the problem, and not really understanding them.
What exactly does this part of the code mean:
void loop(){
stepper.moveTo(5000);
while (stepper.currentPosition() != 4000) // Full speed up to 300
stepper.run();
stepper.stop(); // Stop as fast as possible: sets new target
stepper.runToPosition();
// Now stopped after quickstop
I am thinking the 4000, in the while loop, means that the stepper motor goes full speed till 4000 steps, and then begins to ramp down? since the total movement steps would be 5000, this mean that the ramp down period is 1000 steps?
I really appreciate your help, like i said i am not a programmer by nature.....