void loop()
{
digitalWrite(ouenable, HIGH);
if (stepper.distanceToGo() == 0)
{
// Random change to speed, position and acceleration
// Make sure we dont get 0 speed or accelerations
delay(500);
long someRandomPosition=random(-2000, 2000);
stepper.setMaxSpeed(random(800, highestRandomNum) + 1);
stepper.setAcceleration(random(500, 800) + 1);
if(digitalRead(switchPinA)==HIGH || digitalRead(switchPinB)==HIGH)
{
someRandomPosition=someRandomPosition * -1; // just invert data
stepper.stop(); // Stop as fast as possible: sets new target
stepper.runToPosition();
}
stepper.moveTo(someRandomPosition);
}
stepper.run();
}
I'm having about the same problem. I'm using an arduino UNO and a Toshiba BL-TB6560 V2.0 single axis driver board. I'm driving 2 steppermotors nema 17. The CW+ and the CLK+ are on pin 8 and 9. Enable + is on the 5V and all the -'s are on the ground of the arduino. Now, when I turn on the current, both the steppers are locked. But when I make the connection between my PC and the arduino UNO, it's all gone. you can turn it around freely .
digitalWrite(directionpin, LOW); // Richting instellen, uit
delay(10);
int Dir = LOW;
Serial.println(">>");
for (i = 0; i<4000; i++) // Iteratie van 4000 microsteps
{
//digitalWrite(directionpin, Dir);
Dir = (Dir == LOW) ? HIGH : LOW;
digitalWrite(steppin, LOW);
delay(100); // Een delay zodat de motor niet te hoog gaat
digitalWrite(steppin, HIGH);
delay(100); // Een delay zodat de motor niet te hoog gaat, aan
}
I hope you guys know what i'm doing wrong. (I can make a picture of my connections if that would help you)
I originally wanted to use AccelStepper with the Toshiba TB6560 because it looked like such a nice useful Library (still does) but due to my lack of knowledge of how to implement the library to the TB6560 driver and my lack of knowledge in electronics in general and me just being a cutter/paster/meddler I found snippets of code and put them together.
Below is the code I use for my Elevation stepper motor with the Toshiba TB6560.
The Toshiba TB6560 has an output MO on leg 17 of the chip which I fed to an interrupt pin on the Arduino and counted the pulses. I'm not sure if this is the best way of doing this or how it has been designed to be used but it works ok.
If the author across the ditch of AccelStepper or anyone else could put up a brief example sketch of how to use it with the Toshiba TB6560 I would be very grateful.
Decide what the MCU is providing- source or sink to the photo-couplers. The program sends the signal to the switch
pin ( + or -) and then out the second pin to either V+ or GND.
Stepper Motors need to ramp up speed and ramp down.
You can't just flip them in reverse.
Also at a given high RPM, Different for every motor. They will loose steps and lock up. This dead zone is due to resonance in the system and varies for every product and design.