Auto driver

This Tutorial is Retired!

This tutorial covers concepts or technologies that are no longer current. It"s still here for you khổng lồ read and enjoy, but may not be as useful as our newest tutorials.

Bạn đang xem: Auto driver


The AutoDriver board is based on the STMicro L6470 dSPIN stepper motor driver. This powerful chip allows you khổng lồ control a stepper motor with a voltage from 8-45V at 3Arms over an SPI connection. Compared lớn traditional step/direction motor controllers, it offers a number of advantages:

The L6470 tracks the current position of the motor, so the application màn chơi doesn"t have sầu lớn."Fire-and-forget" motion control, which allows the application to continue working while the motor autonomously completes the desired motion.Acceleration & deceleration curves without complex software algorithms.Microstepping for extra smooth movements.Configurable currents for acceleration, deceleration, run, & hold, which give sầu greater control to lớn the user over power consumption.SPI interface, which allows for a greater number of motors lớn be driven from a single processor.

The primary disadvantage of the L6470 is that it requires a great deal more configuration and adds software complexity to lớn your system. This hookup guide will attempt to lớn relieve some of that difficulty.

Suggested Reading

Before you get started, you may want to lớn look at these other tutorials lớn get you headed in the right direction:


The AutoDriver board is designed to lớn be easily integrated into a project, even with multiple boards. Here"s a brief tour of the hardware và how lớn connect it up.

The Board

As you can see above, there are several connectors on the board. Let"s take them one at a time:

A & B winding outputs - the L6470 is designed to work with a bipolar stepper motor or a unipolar or universal stepper motor configured as a bipolar. One winding should be connected lớn each of these terminals, although it doesn"t matter which winding connects to which terminal (other than lớn determine which direction is considered "forward").ADC input/potentiometer footprint - this footprint can be populated with a 200k potentiometer to provide for motor supply voltage correction, to ensure a constant drive current across varying supply voltages. Highly optional, but we put the footprint there, just in case.An Example Connection to a RedBoard


Later in this tutorial, we will show you how khổng lồ hook up two AutoDriver boards lớn a RedBoard. For that example, you"ll need two AutoDriver Boards along with the following:

Test Hardware Assembly

Here"s a step-by-step guide for assembling the parts used for the rest of the guide. If you have sầu your own hardware, feel miễn phí to skip this part, but it"s not a bad exercise lớn get you up to speed và make sure that your hardware is in a "known good" state before you begin writing code.

I"m going khổng lồ take a few liberties with the basics here & assume that you"re capable of assembling the RedBoard/Breadboard holder on your own, và that you can put the headers and screw terminal blocks on the AutoDriver boards without help. Pay attention khổng lồ the orientation of the shrouded headers on the AutoDriver -- if you get them lined up properly, it"ll help ensure that the signal routing through the ribbon cables is proper later on. Also note the single pin for the chip select, near the control signal in header. You"ll need that later on.


I"ve sầu also made a base plate to lớn hold my AutoDriver boards in place; mine is fancy laser-cut acrylic, but you can hot glue the boards to a piece of cardboard or even just leave sầu them loose, depending on your personal preferences và tool availability.

Assembling the ribbon cables

You can use pre-assembled ribbon cables, but, as we don"t sell pre-assembled 6-conductor cables nor ribbon cables terminated in breadboard-friendly connections, I"m going to lớn cover assembling the necessary cables here.

The easiest way to crimp the connectors to lớn the kết thúc of the cable is to lớn use a workbench vise; alternatively a pair of channel lock or vise-grip type pliers works well. In a pinch, you can use body weight và any flat surface; it takes quite a lot of pressure lớn push the connectors shut, however. Don"t squeeze too hard, or you"ll break the plastic.

Start by cutting your ribbon cable pieces. A pair of scissors works great for this, although it"ll be rough on them, so don"t use your sewing scissors! To keep our images concise, I"m using really short ribbons for these pictures. Feel không tính phí to make yours as long as necessary, although cables longer than a foot or two may cause signal integrity issues, which may affect the operation of your system.

Make sure that there are no little pieces of wire protruding from the kết thúc of the ribbon cable -- those can really ruin your day.

Now we need lớn crimp connectors onlớn the ends of each cable. We"ll start with the breadboard-friendly ends; those are the hardest. cảnh báo that we"re using the 2x5 connector for both the 10- & 6-conductor cables, since we don"t sell a 2x3 breadboard-friendly end.

Insert the ribbon cable inkhổng lồ the connector as shown below. For the 2x3, make sure that you"ve sầu got the ribbon cable all the way lớn the top edge!

Before you apply pressure to lớn crimp the connector closed, you need something khổng lồ prsự kiện the pins from being smashed in the process. A pencil fits between the pins perfectly.

Next, we"ll want to crimp on one of the other connectors. See the image below for proper orientation; crimping this in place is much easier because it doesn"t have sầu pins to lớn be damaged.

Finally, assemble the additional connectors khổng lồ the ends of the other ribbon cables, as shown below. Orientation of the connector is important, as the keying on the shrouded headers forces them inlớn the proper orientation only if the cables are assembled right!

Pay careful attention to the orientation of the keying tab relative to the xanh wire!

Wiring up the stepper motors

As mentioned earlier, there are two screw terminals on the board for connecting the motor. Each one should have one coil of the motor connected to lớn it; if you"re not sure of how your stepper motor"s wires are connected, you can use a multimeter to figure it out. Two wires connected to lớn the same coil should show a very low resistance (on the order of a few ohms) between them.

Once you"ve sầu identified the pairs of wires, connect one pair to the "A" screw terminal and the other to lớn the "B" screw terminal. The order of the wires isn"t terribly important yet, as the order determines the direction in which the motor turns, not whether it turns or not.

The above sầu picture shows the order I"ve selected for our medium stepper motors. It"s probably a good idea to use the same wire order on both boards, so the relative direction of both motors is the same. If you need the direction to be opposite for the two motors (say, to lớn drive sầu the wheels of a robot), you can simply reverse the order of one pair of wires.

Connecting the boards

If all your ribbon cables are properly assembled, the rest of this should be a snap. Start by inserting the breadboard-friendly ends into lớn the breadboard. You"ll be making connections on both sides of the connector, so it helps to pre-bend the ribbon khổng lồ a right angle with the breadboard.

Here"s a little wiring diagram of how the connections lớn the breadboard connectors should be made from the RedBoard or Arduino.

That"s the hardest part. Now all you need lớn bởi vì is connect the ribbon cables lớn the AutoDriver boards.

The last thing you"ll need is a connection between the second board"s chip select pin & the RedBoard. Cheông chồng it out:

Connecting the nguồn Supply

Finally, connect up the power. All you need is a four pieces of hookup wire with bared ends. Here"s a picture of the power connections all wired up:

It"s generally a good idea to lớn hook up the power lớn the RedBoard và súc tích circuitry before you power the AutoDrivers; bởi vì note that you can"t access the AutoDriver boards via SPI until BOTH parts are powered, however.

Arduino Library - Configuration

To make your life a little easier, we"ve sầu developed a fairly comprehensive library for configuring & controlling the AutoDriver. On this page, we"ll go through the various commands in the library and the impact they have on the operation of the AutoDriver board.

As mentioned earlier, the AutoDriver requires more configuration to lớn operate than standard "step/direction" type stepper motor drivers. We"ve sầu provided functions lớn make configuring the registers in the L6470 chip much easier than it might otherwise be. Here they are, in no particular order.

Downloading the Library

The library is hosted on GitHub, along with the other kiến thiết files associated with the AutoDriver board. To install the library and example code to your computer, download this zip file và follow these directions to install the library.

Initialization functions

There are two initialization functions (or "constructors", in C++ class-speke) provided for the AutoDriver library. You must invoke one of them khổng lồ create an instance of class AutoDriver before you can use the board.

Xem thêm: List 5 Thực Đơn Đồ Nướng Vỉa Hè, Quán Nướng Vỉa Hè Sài Gòn Giá Bình Dân Đông Khách

language:cppAutoDriver(int CSPin, int resetSạc, int busyPin);AutoDriver(int CSSạc, int resetPin);The two constructors provided allow you khổng lồ specify which pins the particular AutoDriver boards are connected lớn. It is assumed that you will connect at least the reset and chip select pins; connecting the busy pin is optional, as the busyCheck() function will kiểm tra either the pin state or the device"s internal register to determine if the AutoDriver is busy or not.

These functions also initialize all the other SPI pins và hardware as appropriate; there is no need to invoke the SPI library or configure the SPI pins. It is, however, recommended that you use pin 10 as a chip select pin, since that pin must remain an output at all times in order for the library to lớn function properly (this is a requirement of the SPI peripheral in the chip và cannot be changed).

Setting Basic Chip Parameters

There are many different parameters which must be mix for the AutoDriver khổng lồ function properly. These are stored in RAM on the AutoDriver và must be configured after every power cycle or chip rephối.

Some of these parameters must be set for the chip lớn operate successfully; those parameters are described here.

void configSyncPin(byte pinFunc, byte syncSteps);The BUSY pin on the AutoDriver actually has two possible functions: it can indicate when the board is BUSY (usually indicating that a motion command is underway và has not yet completed) or it can be used khổng lồ output a sync signal for counting full motor steps with an external device.

There are constants defined for the two parameters: the first can be either BUSY_PIN or SYNC_PIN. If SYNC_PIN is passed, the second parameter should be one of the following:

SYNC_FS_2 - two pulses on sync pin per full step of motorSYNC_FS - one pulse per full stepSYNC_XFS - where X can be 2, 4, 8, 16, 32, or 64, and X indicates the number of full steps between pulses on the sync pin

If BUSY_PIN is passed, the second paramater should be zero.

void configStepMode(byte stepMode);The AutoDriver is capable of microstepping, wherein the output signal is PWMed lớn create a pseudo-sine wave sầu output which makes the transition from one step lớn the next less jerky. There are 8 possible microstep options, and defines have sầu been provided for selecting between them:

STEP_FS - Full-step mode; microstepping disabledSTEP_FS_X - Enable microstepping with X microsteps per full step. X can be 2, 4, 8, 16, 32, 64, or 128.

lưu ý that enabling microstepping has no effect on motion commands or sync pulse outputs; it is not possible lớn move less than one full step. Microstepping simply makes the transition between steps smoother.

void setMaxSpeed(float stepsPerSecond);Provide an upper limit khổng lồ the speed the driver will attempt khổng lồ reach. Attempts to exceed this tốc độ will result in motion being completed at this tốc độ. The value established by this command will also be the value used for motion commands such as goTo() where no tốc độ parameter is provided.

void setMinSpeed(float stepsPerSecond);The minimum speed is slowest tốc độ the motor will run. If low tốc độ optimization is enabled (see below), minimum speed is automatically zero, & the special low-tốc độ wavesize optimization will be used until minimum speed is reached. Defaults khổng lồ zero.

void setFullSpeed(float stepsPerSecond);If microstepping is enabled, this parameter sets the tốc độ above which microstepping is disabled và the driver engages full step mode.

void setAcc(float stepsPerSecondPerSecond);void setDec(float stepsPerSecondPerSecond);Set the acceleration/deceleration curves to be used. The maximum value for this is 29802; above sầu that, the AutoDriver will not use any curve sầu at all.

void setOCThreshold(byte threshold);Sets the cấp độ at which an overcurrent sự kiện occurs. There are 16 different options; all take the format OC_XmA, where X is the limit và can be any of these values: 375, 750, 1125, 1500, 1875, 2250, 2625, 3000, 3375, 3750, 4125, 4500, 4875, 5250, 5625, or 6000.

void setPWMFreq(int divisor, int multiplier);There"s a separate internal clochồng for the PWM frequency used by the chip when microstepping or when KVAL settings (more on these later) call for a reduction in current. This frequency is 31.3kHz (nominal, when using the internal 16MHz clock), & is adjusted by the divisor và multiplier sent to this function. Again, we"ve sầu created a phối of defines for the possible values:

For divisor, define syntax is PWM_DIV_X, where X can be any value 1-7.For multiplier, define syntax is PWM_MUL_X, where X can be 0_625 (for 0.625), 0_75 (for 0.75), 0_875, 1, 1_25, 1_5, 1_75, or 2.

It"s a good idea to keep the frequency above sầu 20kHz or so, to avoid annoying those in cthua thảm proximity lớn the device, as lower frequencies can cause an audible ring or buzz.

void setSlewRate(int slewRate);The slew rate is the slope of the voltage change coming out of the driver. There are three options here: 180V/us, 290V/us, & 530V/us. Higher slew rates increase the torque at higher speeds, at the risk of increased electromagnetic emissions, which may or may not matter to you. The defines for this are SR_180V_us, SR_290V_us, SR_530V_us.

void setOCShutdown(int OCShutdown);By mặc định, the drive transistors in the L6470 chip will shutdown on an overcurrent sự kiện khổng lồ prsự kiện damage to motor và driver. This can be disabled by passing the define OC_SD_DISABLE to lớn this function, và re-enabled by passing OC_SD_ENABLE.

void setOscMode(int oscillatorMode);This is one of the more important of the basic parameters. By mặc định, the chip will run at 16MHz on its internal oscillator, and that suffices for most applications. However, in a situation where more than one AutoDriver is being used in a circuit, it"s best khổng lồ drive sầu all of the boards from a common clochồng, so the motors will remain synchronized. That clock source can be either an external clock fed to lớn the first chip and then passed along to subsequent chips, or it can be the internal cloông chồng source of the first chip, passed along lớn later devices. There are rather a lot of possible options here; we"ve created a verbose mix of constants lớn help you select the right one:

INT_16MHZ - Use the internal 16MHz oscillator, with no output on the OSCOUT line.INT_16MHZ_OSCOUT_2MHZ - Internal 16MHz, 2MHz on OSCOUT. Default.INT_16MHZ_OSCOUT_4MHZ - Internal 16MHz, 4MHz on OSCOUT.INT_16MHZ_OSCOUT_8MHZ - Internal 16MHz, 8MHz on OSCOUT.INT_16MHZ_OSCOUT_16MHZ - Internal 16MHz, 16MHz on OSCOUT. Recommended for the first AutoDriver in a system with more than one AutoDriver.EXT_8MHZ_XTAL_DRIVE - External 8MHz crystal. Not recommended.EXT_16MHZ_XTAL_DRIVE - External 16MHz crystal. Not recommended.EXT_24MHZ_XTAL_DRIVE - External 24MHz crystal. Not recommended.EXT_32MHZ_XTAL_DRIVE - External 32MHz crystal. Not recommended.EXT_8MHZ_OSCOUT_INVERT - 8MHz cloông chồng to lớn OSCIN. Inverted OSCIN on OSCOUT.EXT_16MHZ_OSCOUT_INVERT - 16MHz clochồng khổng lồ OSCIN. Inverted OSCIN on OSCOUT. Recommended for subsequent boards in a multi-board system.EXT_24MHZ_OSCOUT_INVERT - 24MHz cloông chồng lớn OSCIN. Inverted OSCIN on OSCOUT.EXT_32MHZ_OSCOUT_INVERT - 32MHz cloông xã khổng lồ OSCIN. Inverted OSCIN on OSCOUT.

Two things of note regarding the osciallator settings: first, if you select an invalid setting (for example, an external crystal in a system with no crystal), the AutoDriver board will stop responding. Because the settings are stored in RAM, however, a rephối or power cycle of the chip will restore it to operation, allowing you khổng lồ change your program to a supported clock mode.

Second, the frequency specified in this is used by the library to convert user-friendly units khổng lồ units the chip understands. Using any frequency besides 16MHz will result in scale errors when setting speeds in steps per second, acceleration in steps per second per second, etc.

Advanced Chip Parameters

void setVoltageComp(int vsCompMode);Voltage compensation attempts lớn keep the motor"s behavior consistent across varying supply voltage. This is not as straightforward as it sounds, và users wanting to employ this functionality are urged khổng lồ consider page 34 of the L6470 datasheet.

The defines to lớn enable or disable this are VS_COMP_ENABLE & VS_COMP_DISABLE.

void setSwitchMode(int switchMode);The switch input on the AutoDriver mode can be made khổng lồ vị one of two things: hard-stop the motor (for limit switch functionality), or perform user-based functions by exposing the switch mode to lớn the user through an internal register. The constants khổng lồ select between the modes are SW_HARD_STOP.. and SW_USER.

void setAccKVAL(byte kvalInput);void setDecKVAL(byte kvalInput);void setRunKVAL(byte kvalInput);void setHoldKVAL(byte kvalInput);The KVAL settings allow you to impose a global scaling on the current used for the four conditions listed above. The đầu vào ranges from 0-255, or 0% to 100% in steps of approximately .4%. This can be a good way lớn reduce the power consumption of your system if the full torque provided by 100% current operation is not required.

Xem thêm: Nghĩa Của Từ Commercial Manager Là Gì ? Mách Bạn Tin Cực Hot Về Senior Manager

void setLoSpdOpt(boolean enable);Low-speed optimization attempts khổng lồ improved the zero-crossing of the driving sine wave sầu at low speeds. When low-speed optimization is enabled (true passed to this function), the value set for minimum speed above becomes the tốc độ at which low-speed optimization is no longer applied. When disabled (mặc định, or false passed khổng lồ this function), the minimum speed value is the lowest tốc độ the driver will attempt to use.

Chuyên mục: Digital Marketing