i have revised the demo as the old downloaded one is not working
#include <cpwStepper.h>
// drive types
#define WAVE 1
#define HALF 2
#define TORQUE 3
#define MICRO4 4
#define MICRO8 8
#define MICRO16 16
#define MICRO32 32
#define MICRO64 64
// make sure to use analog pins for motors if you plan on using microstepping
const int x_coil1a = 10;
const int x_coil1b = 11;
const int x_coil2a = 12;
const int x_coil2b = 13;
const boolean invert_x_dir = false;
int i=0;
int steps=50;
int steptime=1;
int waittime=100;
// you can't change stepping type within an instance of the class because it will screw up the counter
cpwStepper cpwStepper_x_wave(x_coil1a, x_coil1b, x_coil2a, x_coil2b, WAVE);
cpwStepper cpwStepper_x_half(x_coil1a, x_coil1b, x_coil2a, x_coil2b, HALF);
cpwStepper cpwStepper_x_torque(x_coil1a, x_coil1b, x_coil2a, x_coil2b, TORQUE);
cpwStepper cpwStepper_x_micro4(x_coil1a, x_coil1b, x_coil2a, x_coil2b, MICRO4);
cpwStepper cpwStepper_x_micro8(x_coil1a, x_coil1b, x_coil2a, x_coil2b, MICRO8);
cpwStepper cpwStepper_x_micro16(x_coil1a, x_coil1b, x_coil2a, x_coil2b, MICRO16);
cpwStepper cpwStepper_x_micro32(x_coil1a, x_coil1b, x_coil2a, x_coil2b, MICRO32);
cpwStepper cpwStepper_x_micro64(x_coil1a, x_coil1b, x_coil2a, x_coil2b, MICRO64);
void setup()
{
Serial.begin(9600);
}
void loop()
{
// go forward in wave drive mode for 200 steps
Serial.println("Wave drive");
i = 0;
while(i<steps1) {
cpwStepper_x_wave.takestep(invert_x_dir);
delay(steptime10);
i++;
}
cpwStepper_x_wave.disable();
delay(waittime);
// go backward in half step mode for 200 steps
// note: this will travel half as far as twice as slow as the other modes
Serial.println("Half stepping");
i = 0;
while(i<steps2) {
cpwStepper_x_half.takestep(!invert_x_dir);
delay(steptime10);
i++;
}
cpwStepper_x_half.disable();
delay(waittime);
// go forward in high torque mode for 200 steps
Serial.println("Full torque");
i = 0;
while(i<steps1) {
cpwStepper_x_torque.takestep(invert_x_dir);
delay(steptime10);
i++;
}
cpwStepper_x_torque.disable();
delay(waittime);
// go backward in 4x microstep mode for 200 steps
// note: this will travel 1/4th as far as 4x as slow as the other modes
Serial.println("4x Microstepping");
i = 0;
while(i<steps*4) {
cpwStepper_x_micro4.takestep(!invert_x_dir);
delay(steptime);
i++;
}
cpwStepper_x_micro4.disable();
delay(waittime);
// go forward in 8x microstep mode for 200 steps
// note: this will travel 1/8th as far as 8x as slow as the other modes
Serial.println("8x Microstepping");
i = 0;
while(i<steps*8) {
cpwStepper_x_micro8.takestep(invert_x_dir);
delay(steptime);
i++;
}
cpwStepper_x_micro8.disable();
delay(waittime);
// go backward in 16x microstep mode for 200 steps
// note: this will travel 1/16th as far as 16x as slow as the other modes
Serial.println("16x Microstepping");
i = 0;
while(i<steps*16) {
cpwStepper_x_micro16.takestep(!invert_x_dir);
delay(steptime);
i++;
}
cpwStepper_x_micro16.disable();
delay(waittime);
// go forward in 32x microstep mode for 200 steps
// note: this will travel 1/16th as far as 16x as slow as the other modes
Serial.println("32x Microstepping");
i = 0;
while(i<steps*32) {
cpwStepper_x_micro32.takestep(invert_x_dir);
delay(steptime);
i++;
}
cpwStepper_x_micro32.disable();
delay(waittime);
// go backward in 64x microstep mode for 200 steps
// note: this will travel 1/16th as far as 16x as slow as the other modes
Serial.println("64x Microstepping");
i = 0;
while(i<steps*64) {
cpwStepper_x_micro64.takestep(!invert_x_dir);
delay(steptime);
i++;
}
cpwStepper_x_micro64.disable();
delay(waittime);
}