Menu

Using ST L6470 motor driver

Joe Bauer
2021-03-02
2021-05-10
  • Joe Bauer

    Joe Bauer - 2021-03-02

    I had been having trouble with my NEMA-8 stepper motor losing steps using the DRV8825HW203 version of the code. I modified Roberts code to use the ST L6470 driver. So far it's working great.

    Years ago I bought a SparkFun AutoDriver board, BOB-10859, based on the ST L6470 SPI controlled stepper motor driver. The L6470 has some neat features: it has a position register to store the microstep position from +/- 2^22 (+/- 2 million), it senses skipped/lost steps, it has a built in limit switch (for HPS). It's a set-and-forget driver. Tell it what position to go to and the driver tells you when it gets there, no need to send each step pulse.

    Most stepper drivers are current controlled and use a potentiometer to adjust the maximum current. The L6470 is PWM voltage based and uses registers to set the maximum voltage to use. It take a bit of calculation to determine the right settings, and the settings are based on the motor supply voltage. Once set it works great though.

    Robert posted my code, and some pictures, in the files section. I'm still working on the code though. So far I have it working with the OLED, rotary encoder, pushbuttons, temperature probe and the HPS. I ordered a TFT panel to see if I can get that going as well.

    Amazon sells generic versions of the SparkFun driver board for $6 and up. I ordered a couple of these to test if they work as well: https://www.amazon.com/gp/product/B07Q642GFR/
    (edit: I've noticed all the SparkFun driver clones use the same circuit board design, but most have the wrong decoupling capacitors. There should be 100uF/63V and 0.22uF caps for the motor power supply. Almost all large caps are 35V, some have the wrong values. Almost all are missing the small cap. I'll test out the boards I ordered, but just wanted to point out the main differences for the $30ish less cost)

    I also have an Uno-style shield sold by ST for $15: https://www.st.com/en/ecosystems/x-nucleo-ihm02a1.html

    I'm trying to get the code able to run both, so the code is still a work-in-progress. If anyone has questions about it let me know.

     

    Last edit: Joe Bauer 2021-03-03
  • Joe Bauer

    Joe Bauer - 2021-04-10

    Some progress on the L6470 controller version. It's working very well. I've gotten the stepper driver's home position switch circuitry working well with the MFP2 code.

    A picture showing the microswitch I added to my SCT focuser to act as the HPS:
    link to picture

    The focus knob turns a nut that moves a threaded rod to move the mirror. Going fully one direction causes the threaded rod to move out of the center of the focus knob. I use that to trip the HPS switch.

    You can see it better in a video I made:
    https://youtu.be/MPnKXa0gXQk

    In the video I go from a stepper position of 16000 steps (currently set to 32000 max) and hit the Home button on the windows app. You can see the stepper move close to zero, slow until the HPS closes then back-out slowly until the switch opens.

    (Robert, feel free to use the images and videos if you want to)

     
  • brownrb

    brownrb - 2021-04-10

    Hi Joe
    My Apologies for not getting round to this. At present I am dealing with issues across about 4 projects and trying to update apps, drivers and firmware. It has been full on lately,

    I got your email and will put something together. I do indeed want to showcase what you have done because I think it is awesome and others can derive benefit from it.

    I will get round to doing it omce I cut some of the issues and updates out of the way.

    Cheer
    Robert

     
  • Joe Bauer

    Joe Bauer - 2021-04-10

    No problem, I've been polishing the code and figuring out a few things. I had to rewrite the In/Out LED code and make a few adjustments in other sections. Let me know when you're ready and I'll send you my latest code.

    Since I didn't get any responses about the ST Uno Motor Shield I haven't bothered trying to integrate the two types of code. I did get a couple of the $6 SparkFun clone driver boards. They work well. They cut corners with the capacitors, but for that price I couldn't expect much.

     
  • Joe Bauer

    Joe Bauer - 2021-05-10

    Status update.
    Code version 305 was working great, but 308 ended up breaking the HPS code. I see that version 309 had a HPS code fix. I'll try updating using the 310 code and see if HPS works again. If things are good I'll post an update.

    I see the code being developed to make use of the TMC stall guard in that driver chip.  The ST L6470 also has stall detection, but in my testing so far it's not entirely reliable.  It depends on getting the over-current detection adjusted just right to trip when the motor loses steps due to physical resistance.  The L6470 is designed for bigger motors, up to 3A.  I'm using small 0.6A (per coil) motors so it's a bit finicky with over-current detection.

    I plan to work on the stall detection code after I get everything finished with my current design.  The physical HPS is working great, or was until I tried the 308 code, but I hope that's fixed in 309/310.

    The L6470 has a 16 bit status register, 14 flags plus a 2-bit motor status (stopped, running, accelerating, decelerating).  The flags cover missed step detection, over-current, under-voltage, temperature getting high, temperature shutdown, last driven motor direction, etc.

    Two of the flags cover the L6470's limit switch: is the switch currently open/closed, has the switch ever closed since the last status register check.  My code has replaced the Arduino HPS code with returning the status of those flags.  That part worked great in code 305.  I plan to change the "movedirection" variable with the last moved direction flag in a further code revision.

    I haven't heard any interest in the L6470, but I plan to post my status occasionally anyway. If anyone is interested, let me know and I'll send the latest code.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.