Dear Pololu team,
I would like to control 2 stepper motor (Two "36v4 "pololu drivers)with 1 arduino mega.
my question is how to initialise the two drivers and the pin assignment .
this code work fine for only one driver :
#include <SPI.h>
#include <HighPowerStepperDriver.h>
const uint8_t CSPin = 49;
// This period is the length of the delay between steps, which controls the
// stepper motor's speed. You can increase the delay to make the stepper motor
// go slower. If you decrease the delay, the stepper motor will go faster, but
// there is a limit to how fast it can go before it starts missing steps.
const uint16_t StepPeriodUs = 2000;
HighPowerStepperDriver sd;
void setup()
{
SPI.begin();
sd.setChipSelectPin(CSPin);
// Give the driver some time to power up.
delay(1);
// Reset the driver to its default settings and clear latched status
// conditions.
sd.resetSettings();
sd.clearStatus();
// Select auto mixed decay. TI's DRV8711 documentation recommends this mode
// for most applications, and we find that it usually works well.
sd.setDecayMode(HPSDDecayMode::AutoMixed);
// Set the current limit. You should change the number here to an appropriate
// value for your particular system.
sd.setCurrentMilliamps36v4(1000);
// Set the number of microsteps that correspond to one full step.
sd.setStepMode(HPSDStepMode::MicroStep32);
// Enable the motor outputs.
sd.enableDriver();
}
void loop()
{
// Step in the default direction 1000 times.
sd.setDirection(0);
for(unsigned int x = 0; x < 1000; x++)
{
sd.step();
delayMicroseconds(StepPeriodUs);
}
// Wait for 300 ms.
delay(300);
// Step in the other direction 1000 times.
sd.setDirection(1);
for(unsigned int x = 0; x < 1000; x++)
{
sd.step();
delayMicroseconds(StepPeriodUs);
}
// Wait for 300 ms.
delay(300);
}
how can i customise this code for 2 drivers
what happens for the (MISO MOSI SCK)pins ?
how does Arduino uni recognise the parameter pins for the two drivers?
thanks for the support
<3