STSPIN220 stepper motor driver microstepping

I have a RPi 4 controlling a STSPIN220 stepper motor driver that sends signals to a stepper motor. The stepper motor works perfectly in full step mode. I realize that the STEP and DIR pins on this type of driver can be used to set the micro stepping mode in addition.

I am trying to set a 1/8th micro stepping mode at power up but confused on how this is done. The page for the driver explaining this is confusing and hard to follow. Are there any examples?

Couldn’t find any sample code. I also think it will be better if you please add some. @Pololu team

Hello.

The step mode is determined by the state of 4 pins on power-up or when standby mode is released: MODE1, MODE2, MODE3 (Step), and MODE4 (DIR). You can find a table with the pin states for the available resolutions under the “Step (and mcrostep) size” heading on the STSPIN220 carrier product page.

We do not have any specific examples for doing this with a Raspberry Pi, but essentially, if you want to change step modes you could drive the nSTBY pin low, then configure the 4 Mode# pins for the microstep mode you want, then drive the nSTBY pin high to latch the step mode. Once that is done, you can use the STEP and DIR pins to control the driver as usual.

Brandon

I already looked at the product page. I am interested in configuring the micro stepping size on power up. I’m confused on how a signal can be sent in this manner. If you have any additional information on how this can be done on power up, it would be appreciated. @Pololu

To do it on power up, you would just apply the appropriate signals to the board prior to it being powered. You might be able to get by with connecting pull resistors to each MODE# pin to configure them how you want when the driver is powered up. However, if you are powering the Raspberry Pi and stepper motor driver at the same time, please note that the Raspberry Pi GPIO pins might be driven in unpredictable ways while it is booting. So, you would probably get more reliable results by having the Raspberry Pi run a program as soon as it is finished booting that puts the driver in standby mode, drives the MODE# pins as you want, then takes the driver out of standby (as I described in my previous post). Alternatively, you could have a relay control the power to the driver, so the Raspberry Pi can power it up once it has booted.

Brandon