Where to insert a DigitalWrite pin low command.

I need to remove the holding power to my stepper motor after a command to move the focuser as it and the driver are getting pretty hot over the course of a night. The code is used to control a telescope focuser.

The control pins are 3 PWMa
11 PWMb
12 DIRa
13 Dir b

It’s a L298 motor shield.

I have tried inserting the command inside the loop but although it stops the holding current it messes with the stepper.

I did not write this code, it is open source for the Astronomy community. Any help would be appreciated.

Code attached as a file

Regards Terry

PnPFocus.ino (12.2 KB)

but although it stops the holding current it messes with the stepper.

Did you expect something else? "It messes with the stepper" doesn't tell us anything. The code does something. You expect it to do something. Tell us what those things are. Tell us which pin you are setting low. Obviously, setting either direction pin low will not affect the current that the stepper draws. Setting the step pin low is what actually triggers it to step.

So, it isn't clear what you are turning off.

My best advice is to get a real stepper driver. The L298 shield is meant to drive variable speed electric motors, NOT stepper motors.

There is a comment in the source code for the ArdumotoStepper library:

 * By making use of the fact that at any time two of the four motor coils are
 * the inverse of the other two, the number of control connections can be
 * reduced from 4 to 2 for the unipolar and bipolar motors.

There is a broken link to the “circuits”. The code implies that you have a “circuit” in your stepper driver that converts two control lines into 4, and at any given moment two of those 4 control lines are high and two are low. If that is indeed the case, I think you’re out of luck. No matter what you put out on the control lines, there will still be holding current, because two of the 4 actual control lines will be high.

There is some other strange stuff going on with that library. analogWrite(x, 255) interspersed with digitaWrite() functions.