AN4241 Application note dSPIN™ family: fully integrated stepper motor drivers By Enrico Poli Introduction The L6470 and L6472 are fully integrated motor drivers providing a complete stand-alone solution for the high-end stepper motor applications. The devices can be controlled by a host microcontroller through a fast SPI interface and are able to execute a complete set of motion commands. This document describes how the devices can be configured and gives some suggestions about the operation and the application design. The current control algorithm of the devices (the L6470 voltage mode driving and the L6472 advanced current control) is not investigated in this document. For further details, please, refer to the respective application notes AN4144 "Voltage mode control operation and parameter optimization" and AN4158 "Peak current control with automatic decay adjustment and predictive current control: basics and setup". January 2013 Doc ID 024193 Rev 1 1/18 www.st.com Contents AN4241 Contents 1 2 The L6470 and L6472 communication interface . . . . . . . . . . . . . . . . . . . 3 1.1 Communication protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1.2 Daisy chain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1.3 5 V and 3.3 V communication interface . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Motion engine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 2.1 Speed tracking commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 2.2 Positioning commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 2.2.1 3 Change the target position of the on-the-fly command . . . . . . . . . . . . . . 9 2.3 Stop commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 2.4 Initializing position using GoUntil and ReleaseSW commands . . . . . . . . 10 Protections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 3.1 Overtemperature protection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 3.2 Overcurrent protection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 3.3 Undervoltage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 4 Stall detection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 5 Main clock source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 6 Layout suggestions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 7 Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 2/18 Doc ID 024193 Rev 1 AN4241 1 The L6470 and L6472 communication interface The L6470 and L6472 communication interface The device (always slave) can be driven by a MCU (always master) sending commands through an 8-bit SPI interface. The 8-bit shift register of the device is kept enabled while CS input is forced low. During this time, at every raising edge of the serial clock (CK), the SDI input is stored into the shift register. At CK falling edges the SDO output is updated according to the last bit of the shift register. When the CS input is raised, the device catches the shift register content and interprets its value as a command or an argument of the previously received command. All the bytes are sent through the SPI data lines starting from the most significant bit. 1.1 Communication protocol The communication protocol is based on single byte commands that can be followed by a command argument up to 3 byte long which must be transmitted starting from the most significant byte. Part of the information needed to execute the target operation could be embedded into the command byte, for example the target register address in the GetParam and SetParam commands, and the argument provides extra data as well as the target position of the GoTo command. By default the response byte of the device is h00 (hexadecimal format). Some commands, for example those used to read the value of a register, generate a response from the device up to 3 byte long which is transmitted during the following transmission cycles starting from the most significant byte. 1.2 Daisy chain The device is compatible with the daisy chain architecture allowing the MCU to drive multiple devices with a single SPI interface. The daisy chain architecture is obtained as follows: ● Master serial clock line is connected to the CK input of each slave device; ● Master slave select line is connected to the CS input of each slave device; ● Master serial data output (MOSI) is connected to the SDI input of the first slave of the chain; ● The SDO output of each slave device is connected to the SDI input of the next one, last slave excluded; ● Master serial data input (MISO) is connected to the SDO output of the last slave of the chain, The connection diagram of the configuration is shown in Figure 1. Doc ID 024193 Rev 1 3/18 The L6470 and L6472 communication interface Figure 1. AN4241 Daisy chain connection diagram MCU Slave select Serial clock Serial data out Device 1 (1st of the chain) Device X Device X+1 Device N (last of the chain) Serial data in CS CS CS CK CK CK SDI SDI SDO to SDI of device 2 SDO SDI from SDO of device X -1 CS CK SDI SDO to SDI of device X+2 SDO from SDO of device N -1 AM16587v1 In this configuration, the chain of slaves acts as a single slave with an SPI device of N byte. Each communication cycle, for example when the master needs to transmit/receive a byte from/to a slave, the master must fill all the shift registers of the slaves before raising the CS line. The devices are addressed according to the position of the byte in the communication cycle: the first byte transmitted by the master is received by the last device of the chain; the second one is received by the last-but-one slave and so on down to the last transmitted byte which is received by the first slave of the chain. The response bytes from the device chain are addressed to the same way: the first byte received by the master has been transmitted by the last device of the chain; the second one has been transmitted by the last-but-one slave and so on down to the last received byte which has been transmitted by the first slave of the chain. In theory, the number of slaves that an MCU can drive using the daisy chain configuration is unlimited; in practice the maximum number of devices connected to the same SPI depends on the clock skew. The number of slaves limits the communication speed also because every time a byte has to be transmitted to a device, the whole N slave chain has to be filled transmitting N - 1 extra bytes. 1.3 5 V and 3.3 V communication interface The device can be configured to operate both with 3.3 V and 5 V standard logic as shown in Figure 2. 4/18 Doc ID 024193 Rev 1 AN4241 The L6470 and L6472 communication interface Figure 2. Logic interface supply scenarios Fully self supplied device Compliant with 3.3 V logic CREGPOL CREG 47 µF 100 nF CDD VREG VDD 100 nF CDDPOL 10 µF 5V Self supplied device Compliant with 5 V logic CREGPOL CREG 47 µF 100 nF CDD VREG VDD VREG VDD 100 nF CDDPOL 10 µF 3.3 V Externally supplied device Compliant with 3.3 V logic CREG 100 nF CDD 100 nF 10 µF 5V 3.3 V Externally supplied device Compliant with 5 V logic CDDPOL CREG 100 nF CDD VREG VDD 100 nF CDDPOL 10 µF AM16588v1 Doc ID 024193 Rev 1 5/18 Motion engine 2 AN4241 Motion engine The dSPIN™ family devices integrate a motion engine providing a full set of commands. The motion engine generates the step sequence according to the programmed speed profile and the requested command. The speed profile represents the operation boundaries, defined by the acceleration, deceleration, maximum and minimum speed, which should be respected to ensure the proper functioning of the application. The devices allow all the parameters to be set independently: ● Acceleration and deceleration values range from 14.55 up to 59590 steps/s2. The device can also be set to use an infinite acceleration and deceleration value; in this case, both the acceleration and deceleration phases are totally skipped. ● Maximum speed value ranges from 15.25 steps/s up to 15610 step/s. ● Minimum speed value ranges from 0 up to 976 steps/s. The acceleration, deceleration and minimum speed parameters can be modified when the motor is stopped only. The maximum speed can be also changed when the motor is running, but the new value is only considered at next command execution. The commands supported by the motion engine are listed in Table 1. Table 1. Name Length (bytes) Description Notes Move Can be executed when 4 (including 3 Performing the target number of microsteps the motor is stopped of arguments) as per requested direction. only. GoTo Reaching the absolute target position 4 (including 3 (ABS_POS register) using the shortest of arguments) path. Not accepted while another command is under execution. Reaching the absolute target position 4 (including 3 (ABS_POS register) running as per of arguments) requested direction. Not accepted while another command is under execution. GoTo_DIR Not accepted while another command is under execution. GoHome 1 Reaching the home position (all zeroes) using the shortest path. GoMark 1 Not accepted while Reaching the position stored into the MARK another command is register using the shortest path. under execution. Run StepClock 6/18 Command list Always accepted and 4 (including 3 Reaching the target speed in the requested immediately executed of arguments) direction. (if present, the previous command is aborted) 1 Switching the device in step-clock mode imposing the direction. Doc ID 024193 Rev 1 Can be executed when the motor is stopped only. AN4241 Motion engine Table 1. Name GoUntil ReleaseSW SoftStop HardStop SoftHiZ HardHiz 2.1 Command list (continued) Length (bytes) Description Notes Always accepted and Reaching the speed target in the requested 4 (including 3 immediately executed direction and stopping when SW input is of arguments) (if present, the previous forced low (falling edge). command is aborted) 1 Always accepted and Runnig the motor at low speed in the immediately executed requested direction and stopping when SW (if present, the previous input is forced high (rising edge). command is aborted) 1 Stopping the motor in accordance to the programmed speed profile. Always accepted and immediately executed (if present, the previous command is aborted) 1 Stopping the motor immediately (infinite deceleration). Always accepted and immediately executed (if present, the previous command is aborted) 1 Stopping the motor in accordance to the programmed speed profile and then disabling the power bridges. Always accepted and immediately executed (if present, the previous command is aborted) Disabling the power bridges immediately. Always accepted and immediately executed (if present, the previous command is aborted) 1 Speed tracking commands During the speed tracking, the device dynamically changes the motor speed according to the application requirements. The Run command can be used to achieve this result. The Run command sets the speed target and direction which the motor has to reach. Both speed target and direction can be changed in real time through a new Run command (see Figure 3). Doc ID 024193 Rev 1 7/18 Motion engine AN4241 Figure 3. Speed tracking using Run command sequences Speed 500 Run(forward, 600) 400 300 200 100 Time Run(forward, 100) 100 Run(forward, 400) 200 Run(reverse, 300) 300 400 AM16589v1 2.2 Positioning commands The motion engine, integrated into the devices, allows the position of the motor in a target position based on integrated ABS_POS register. The ABS_POS register traces all the motion performed by the motor adding a unit to each microstep completed in forward direction and subtracting a unit when the microstep is performed in reverse direction. The target positioning can be directly imposed indicating the ABS_POS register value (absolute position) or the distance between the current position and the target one (relative position). The relative positioning command is Move. The motion engine executes this command only when the motor is stopped in order to avoid unexpected behaviors (e.g. the target of number of steps is not enough to allow the speed profile compliance). Figure 4. Relative positioning command example h3FFFFF 0 h000001 Final position Move(Reverse) h3FFFFF 0 h000001 Starting position Starting position Move(Forward) h200000 h200000 h1FFFFF Final position h1FFFFF AM16590v1 8/18 Doc ID 024193 Rev 1 AN4241 Motion engine The absolute positioning commands are GoTo and GoTo_DIR. The former moves the motor to the position target choosing the rotation direction according to a minimum path algorithm (i.e. the lower number of microsteps is executed) whereas the latter imposes the direction directly. Figure 5. Absolute positioning command example h3FFFFF 0 h000001 h3FFFFF 0 h000001 Target position Target position GoTo Starting position Starting position GoTo_DIR(Forward) h200000 h1FFFFF h200000 h1FFFFF AM16591v1 If a GoTo command is requested when the motor is running, the minimum path algorithm also considers the steps required to reverse the direction (see Figure 6). Figure 6. Minimum path algorithm when motor is running h3FFFFF 0 h000001 Reverse direction path Current position Target position Motor is running in forward direction Forward direction path Zero speed position (where the motor will stop if it starts decelerating) h200000 h1FFFFF Reverse direction path > Forward direction path then forward direction is used. AM16592v1 The GoTo and GoTo_DIR can only be executed when no other commands are under execution. 2.2.1 Change the target position of the on-the-fly command If a Run command is sent to the device during the execution of a GoTo command, it aborts the previous command. This effect can be used to change the target position of the motion engine on-the-fly. Doc ID 024193 Rev 1 9/18 Motion engine AN4241 Following the suggested sequence of operations: 1. Read the current motor speed (SPEED register) and direction (DIR bit in the STATUS register). 2. Send a Run command setting the target speed and direction equal to the values obtained at point 1. 3. Wait for the execution command monitoring the BUSY pin or the BUSY flag in the STATUS register. 4. Send the new positioning command. This operation could introduce a small error in the generation of the speed profile. If the target position is changed a high number of times (tracking position) the error increases and anomalous behaviors could occur. 2.3 Stop commands The motor can be stopped through the stop commands. These commands can be sent at any time and they are executed immediately. The SoftStop command stops the motor fitting the deceleration value of the speed profile whereas HardStop command stops the motor immediately (infinite deceleration). The SoftHiZ and HardHiZ commands operate similarly, but the power bridges are disabled as soon as the zero speed is reached (the high impedance status is forced). 2.4 Initializing position using GoUntil and ReleaseSW commands The GoUntil and ReleaseSW commands can be used to initialize the absolute position information stored into the ABS_POS register according to an external position sensor. In this way a relation between ABS_POS value and mechanical position of the motor can be established. The position initialization sequence, as shown in Figure 7, is the following: 10/18 1. In power-up status, the load position is unknown. 2. Using GoUntil command the load is moved to the limit switch at high speed. 3. When the load reaches the limit switch the SW input of the device is forced low. The motor decelerates and then stops. 4. Considering the high speed used to approach the load to the limit switch, a significant error in the positioning could happen. 5. Using ReleaseSW command the load is moved away from the limit switch at low speed. 6. As soon as the threshold position of the limit switch is crossed by the load the SW input of the device is forced high. The motor stops immediately. 7. The load is positioned in correspondence to the threshold position of the limit switch with a high precision. Doc ID 024193 Rev 1 AN4241 Motion engine Figure 7. Initialization position using GoUntil and ReleaseSW commands Position sensor (limit switch) Load in unknown position SW Stepper motor dSPIN family motor driver GoUntil command is executed and the load reaches the limit switch SW ReleaseSW command is executed and the load is positioned exactly on the triggering point of the limit switch SW AM16593v1 Doc ID 024193 Rev 1 11/18 Protections 3 AN4241 Protections The dSPIN™ family devices provide a complete set of protections designed to prevent from damaging the device in critical conditions. The implemented protections are: 3.1 ● Overtemperature (see Section 3.1) ● Overcurrent (see Section 3.2) ● Undervoltage (see Section 3.3) Overtemperature protection The overtemperature protection disables the power stage of the device when the temperature of the chip exceeds the safe operation conditions. When the overtemperature protection is triggered the device is locked in a safe condition (all MOSFETs are turned off) and is kept in this condition until the junction temperature decreases below 130 °C (typical). The thermal shutdown event occurrence is signaled through the respective flag (TH_SD) in the STATUS register which is kept low until it is released by a GetStatus command (more details are available in the datasheet of the device). A warning threshold is also present allowing the host to control the device to prevent the shutdown. 3.2 Overcurrent protection The overcurrent protection monitors the current in all power MOSFETs of the device and disables the power stage when the programmed current threshold is reached. No information about the specific MOSFET or bridge causing the failure is available. As soon as the overcurrent protection is triggered, the device is locked in a safe condition (all MOSFETs are turned off) and is kept in this condition until the OCD failure flag is released by a GetStatus command. When the device is locked in safe state no command enabling the bridges can be executed (e.g. Move, Run, GoTo, HardStop, etc.). The commands are simply ignored, no nonperformable signalling is returned by the device. Warning: 3.3 The overcurrent protection can be disabled setting the OC_SD pin of the CONFIG register to zero. However it is not recommended this protection to be disabled. Undervoltage The undervoltage protection avoids the power stage of the device to operate with a supply voltage below the safe conditions. 12/18 Doc ID 024193 Rev 1 AN4241 Protections At power-up, the device is in undervoltage status: the power bridges of the device are kept disabled until the supply voltage is below the turn-on threshold. In this condition all the commands enabling the bridges (e.g. Move, Run, GoTo, HardStop, etc.) are ignored and the UVLO failure flag is forced low. When the turn-on threshold is reached the power bridges are operative. The UVLO flag is kept low until it is released through a GetStatus command. The device returns in undervoltage status if the supply voltage falls below the turn-off threshold. Figure 8. Undervoltage protection VS Turn-on threshold Turn-off threshold Time Power bridges are kept disabled. the UVLO flag is forced to zero. Power bridges can be enabled. The UVLO flag is kept to zero until it is released (GetStatus command). Power bridges are kept disabled. the UVLO flag is forced to zero. Power bridges can be enabled. The UVLO flag is kept to zero until it is released (GetStatus command). AM16594v1 Doc ID 024193 Rev 1 13/18 Stall detection 4 AN4241 Stall detection The L6470 also includes a sensorless stall detection system. This feature allows the device to detect the stall condition of the motor measuring the increase of phase current caused by the sudden cancellation of the back electromotive force. The voltage mode control applies a sinusoidal voltage to the motor phases obtaining a sinusoidal current. The amplitude of the voltage sinewave increases according to the speed in order to compensate the back electromotive force effect and keep the amplitude of the phase current constant. If the motor stalls (i.e. stops its rotation) the back electromotive force becomes null, but the voltage applied to the phase is still increased to face its effect. In this condition the phase current results higher than the nominal one and the stall condition can be easily detected. The stall detection threshold must be set above the nominal peak current. Figure 9. Stall detection threshold Normal conditions Stall conditions Stall threshold Iph Stall threshold Iph AM16595v1 14/18 Doc ID 024193 Rev 1 AN4241 5 Main clock source Main clock source The motion engine integrated into the dSPIN™ generates the internal step clock starting from the main clock source of the system. As a consequence, the perturbations on the main clock affect the accuracy with which the device generates the speed of the motor (step rate). In the L6470 the main clock also affects the frequency of the PWM modulators and in the L6472 it is used for the measurement of the timings of the advanced current control. The devices can operate with both external and internal clock sources. By default the clock source is the integrated oscillator operating at 16 MHz. This solution, if compared to a high precision external source, allows the maximum integration with a lower precision of the generation of the speed profile (acceleration, deceleration and target speed). The effects on the current control systems (voltage mode or advanced current control) are negligible. The device can be configured to use an external clock source or to drive a crystal/resonator. In both cases the clock frequency must be chosen among four values: 8, 16, 24 or 32 MHz. Warning: Setting the wrong value or applying a clock frequency significantly different from the nominal value might cause failures. The external clock source allows a higher precision of the speed profile to be obtained. Doc ID 024193 Rev 1 15/18 Layout suggestions 6 AN4241 Layout suggestions The devices of the dSPIN™ family integrate a power stage which can dissipate a significant amount of power compared to the die dimension. For this reason, the devices are proposed in packages with high thermal performance and exposed pads in order to ease the heat dissipation. In this situation, the layout of the board is a significant part of the thermal design of the application. The exposed pad of the device must be directly connected to the ground layer of the board, which acts as a heat sink. For the same reason, the size of the ground layer must be as wider as possible and, if more layers are present, the top and bottom ones should be preferred. In multi-layer designs the exposed pad must be connected to all the ground layers using multiple vias equally spaced. 16/18 Doc ID 024193 Rev 1 AN4241 7 Revision history Revision history Table 2. Document revision history Date Revision 25-Jan-2013 1 Changes Initial release. Doc ID 024193 Rev 1 17/18 AN4241 Please Read Carefully: Information in this document is provided solely in connection with ST products. STMicroelectronics NV and its subsidiaries (“ST”) reserve the right to make changes, corrections, modifications or improvements, to this document, and the products and services described herein at any time, without notice. All ST products are sold pursuant to ST’s terms and conditions of sale. Purchasers are solely responsible for the choice, selection and use of the ST products and services described herein, and ST assumes no liability whatsoever relating to the choice, selection or use of the ST products and services described herein. No license, express or implied, by estoppel or otherwise, to any intellectual property rights is granted under this document. If any part of this document refers to any third party products or services it shall not be deemed a license grant by ST for the use of such third party products or services, or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoever of such third party products or services or any intellectual property contained therein. UNLESS OTHERWISE SET FORTH IN ST’S TERMS AND CONDITIONS OF SALE ST DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY WITH RESPECT TO THE USE AND/OR SALE OF ST PRODUCTS INCLUDING WITHOUT LIMITATION IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE (AND THEIR EQUIVALENTS UNDER THE LAWS OF ANY JURISDICTION), OR INFRINGEMENT OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT. UNLESS EXPRESSLY APPROVED IN WRITING BY TWO AUTHORIZED ST REPRESENTATIVES, ST PRODUCTS ARE NOT RECOMMENDED, AUTHORIZED OR WARRANTED FOR USE IN MILITARY, AIR CRAFT, SPACE, LIFE SAVING, OR LIFE SUSTAINING APPLICATIONS, NOR IN PRODUCTS OR SYSTEMS WHERE FAILURE OR MALFUNCTION MAY RESULT IN PERSONAL INJURY, DEATH, OR SEVERE PROPERTY OR ENVIRONMENTAL DAMAGE. ST PRODUCTS WHICH ARE NOT SPECIFIED AS "AUTOMOTIVE GRADE" MAY ONLY BE USED IN AUTOMOTIVE APPLICATIONS AT USER’S OWN RISK. Resale of ST products with provisions different from the statements and/or technical features set forth in this document shall immediately void any warranty granted by ST for the ST product or service described herein and shall not create or extend in any manner whatsoever, any liability of ST. ST and the ST logo are trademarks or registered trademarks of ST in various countries. Information in this document supersedes and replaces all information previously supplied. The ST logo is a registered trademark of STMicroelectronics. All other names are the property of their respective owners. © 2013 STMicroelectronics - All rights reserved STMicroelectronics group of companies Australia - Belgium - Brazil - Canada - China - Czech Republic - Finland - France - Germany - Hong Kong - India - Israel - Italy - Japan Malaysia - Malta - Morocco - Philippines - Singapore - Spain - Sweden - Switzerland - United Kingdom - United States of America www.st.com 18/18 Doc ID 024193 Rev 1