So, I am trying to use the sample code which accompanies the 4x4 board here: https://www.sparkfun.com/products/11352 (see the link for Arduino Library link - there is some shift stepper code). The library installed after a slight tweak so the name doesn’t cause a failure, and then there is some sample code at the top of the ShiftStepper.cpp file. The user manual had some of the settings I needed to add (hopefully these are compatible with the Mega2560, since the board was designed for the Uno):
#define DATPIN 4
#define SCLPIN 13
#define LATPIN 7
#define MRPIN 8
#define INDPIN 2
static const uint8_t stepSequence[4] = {0x2, 0x4, 0x1, 0x8};
static const uint8_t motChans0[channelsPerMotor] = {0,2,3,1};
static const uint8_t motChans1[channelsPerMotor] = {4,5,6,7};
static const uint8_t motChans2[channelsPerMotor] = {11,9,10,8};
static const uint8_t motChans3[channelsPerMotor] = {15,14,13,12};
shiftChain *myChain = 0;
shiftStepMotor motor0(channelsPerMotor, stepSequence, motChans0);
shiftStepMotor motor1(channelsPerMotor, stepSequence, motChans1);
shiftStepMotor motor2(channelsPerMotor, stepSequence, motChans2);
shiftStepMotor motor3(channelsPerMotor, stepSequence, motChans3);
shiftDevice *motors[4] = {&motor0, &motor1, &motor2, &motor3};
shiftSixteen board0(4, motors); shiftBoard *boards[1] = {&board0};
shiftChain storeChain(1, boards, DATPIN, SCLPIN, LATPIN, MRPIN, INDPIN);
So, the example showed to have the following in setup():
void setup()
{
myChain = &storeChain;
myChain->startTimer(preScaler32, 0, 2); //this causes my flashing LED code to stay solid
motor0.setSpeed(100); //no effect
pinMode(13, HIGH);
}
void loop()
{
digitalWrite(13, HIGH);
delay(2000);
digitalWrite(13, LOW);
motor0.doSteps(4, 10);
myChain->doTick();
delay(2000);
}
So, I have 4 LEDs connected to outputs 0-3, and when I run the above code, LEDs 0 and 3 light, but no others. The comments at the top of ShiftStepper.cpp seem to indicate using a timer would be best, but this is the first I have ventured past making the LED flash. While I am using LEDs now, I wish to connect up a BLDC to it and drive the motor using this shield. Right now, I just want to prove that I can make the sample code roll through the canned step sequences with the library for this board {0,2,3,1}, etc. I see there are methods for setting the speed and such, but so far I am unable to do anything useful with this thing.
Any ideas?
Thanks,
-Kevin