Menu

Stepper motor drivers for laser printers. We assemble a CNC machine from a printer with our own hands

Roof


When designing another CNC machine, or simply a 3-axis milling and drilling machine for printed circuit boards and small milling work, I had a restless desire to sort everything out “on the shelves.”
Many will say that the topic is not new, there are many projects, many technical and software solutions. But, swimming in this sea of ​​information, I tried to remove all the “water” and get the “dry residue”.
That's what came out of it…

The task of building a machine usually comes down to three subtasks - mechanics, electronics, software. Apparently, I will also have to write three articles.
Since our magazine is still about practical electronics, I’ll start with electronics and a little bit with mechanics!

Drive unit

It is necessary to move the milling cutter itself in 3 directions - XYZ, which means you need 3 drives - 3 motors with the transmission of rotation of the motor shaft into linear movement.
About the transfer...
For a milling machine where there are lateral forces cutting the material, it is advisable not to use belt drives, which are very popular in 3D printers. I will use a screw-nut transmission. The most budget-friendly gear is a regular steel screw and a backlash-free, preferably bronze, nut. More correct - a screw with a trapezoidal thread and a nut made of caprolon. The best (and, alas, most expensive) ball screw, or ball screw. I will tell you more about this later...
Each gear has its own coefficient, its own pitch - that is, how linearly the milling cutter will move along the axis in one engine revolution, for example, by 4 mm.

Engine (motor)

I identified a stepper motor (SM) as a motor for the drive.
Why stepper? What is this anyway?
There are AC and DC motors, brushed and brushless, and so-called “stepping” motors. In any case, we need to ensure some positioning accuracy, for example 0.01 mm. How to do it? If the motor has a direct drive - the motor shaft is connected directly to the propeller, then to ensure such accuracy it is necessary to rotate it through a certain angle. In this case, with a gear pitch of 4 mm and a desired movement accuracy of 0.01 mm, this is... only 1/400 of a revolution, or 360/400 = 0.9 degrees! Nonsense, let’s take a regular motor...

With a “regular” motor there is no way to do this without feedback. Without going into too much detail, the motor control circuit needs to "know" what angle the axle has turned. Of course, you can install a gearbox - we will lose speed, and still there is no guarantee, no feedback at all! A rotation angle sensor is installed on the axle. This solution is reliable, but expensive.

An alternative is a stepper motor (read for yourself how it works). We can assume that in one “command” it will rotate its axis by a certain degree, usually 1.8 or 0.9 degrees (the accuracy is usually no worse than 5%) - just what is needed. The disadvantage of this solution is that under heavy load the engine will skip commands - “steps” and may stop altogether. The issue is resolved by installing a obviously powerful engine. Most amateur machines are made using stepper motors.

Choosing a stepper motor

2 windings, with minimum current, minimum inductance and maximum torque - that is, the most powerful and economical motor.

Conflicting demands. Low current means high resistance, which means many turns of motor winding wire, which means high inductance. And a large torque means a large current and many turns. We choose in favor of higher current and lower inductance. And the moment must be chosen based on the load, but more on that later.

The characteristics of some engines are shown in the table:


For a small machine with a working space measuring 300x300x100 mm and a lightweight milling cutter, engines with a torque of 0.3 Nm and higher are quite suitable. The optimal current is from 1.5 to 2.5 Amps, FL42STH38-1684 is quite suitable

Stepper Motor Driver

There is an engine. Now we need a driver to switch the voltage on the motor windings in a certain way, without exceeding the set current.

The simplest solution is a source of a given current and two pairs of transistor switches for each winding. And four protective diodes. And a logical circuit to change direction. And... This solution is usually made on the ULN2003A microcircuit for motors with low current, it has many disadvantages, I will not dwell on them.

An alternative is specialized all-in-one microcircuits - with logic, transistors and protection diodes inside (or outside). And such microcircuits control the current of the windings and regulate it using PWM, and can also implement the “half-step” mode, and some modes 1/4 step, and 1/8 step, etc. These modes can improve positioning accuracy , increase smoothness of movement and reduce resonance. Usually, the “half-step” mode is sufficient, which will increase the theoretical accuracy of linear positioning (in my example, up to 0.005 mm).

What's inside a stepper motor driver IC? Logic and control unit, power supplies, PWM with circuits for generating the torque and time of winding switching, output switches on field-effect transistors, feedback comparators - the current is controlled by the voltage drop across resistors (Rs) in the power supply circuit of the windings. The motor current is set by the reference voltage.

To implement these functions, there are other circuit solutions, for example, using PIC or ATMEGA microcontrollers (again with external transistors and protection diodes). In my opinion, they do not have a significant advantage over “ready-made” microcircuits and I will not use them in this project.

Wealth of choice

Today there are quite a lot of different microcircuits and quite a lot of ready-made boards and SD driver modules. You can buy a ready-made one, or you can “reinvent the wheel”, here everyone decides in their own way.

Of the ready-made ones, the most common and inexpensive drivers are based on Allegro A4988 (up to 2A), Texas Instruments DRV8825 (up to 2.5A) chips.
Since the modules were originally developed for use in 3D printers such as the Rep-rap project of the Arduino project, they are not complete modules (for example, they also need logic power (+5V), which is supplied from the so-called ramp).

There are also solutions based on DRV8811 (up to 1.9 A), A3982 (up to 2 A), A3977 (up to 2.5 A), DRV8818 (up to 2.5 A), DRV8825 (up to 2.5 A), Toshiba TB6560 (up to 3 A) and others.

Since I’m interested in doing something myself, plus the opportunity to “taste” the Allegro A3982 and A3977 microcircuits, I decided to make a couple of drivers myself.

I didn’t like the ready-made solutions on the A4988, primarily due to the miniaturization of the printed circuit board size at the expense of good cooling. The typical resistance of open transistors in the A4388 at a current of 1.5A is 0.32+0.43 Ohm, plus a 0.1-0.22 Ohm “measuring” resistor - it turns out to be about 0.85 Ohm. And there are two such channels, and although they operate pulsed, 2-3 Watts of heat must be dissipated. Well, I don’t believe in a multilayer board and a tiny cooling radiator - the datasheet shows a much larger board.

The motor wires must be kept short and the driver installed next to the motor. There are 2 technical solutions in audio engineering: a long signal cable to the amplifier + short wires to the speaker system, or a short signal cable to the amplifier + long wires to the speaker system. Both solutions have their pros and cons. It's the same with motors. I chose long control wires and short wires to the motor.

Control signals - “step” (step), “direction” (dir), “enable” (enable), indication of the state of control signals. Some circuits do not use the “Enable” signal, but this leads to unnecessary heating of both the chip and the motor in idle mode.

One power supply 12-24 volts, logic power supply (+5V) - on the board. The dimensions of the board are sufficient for good cooling, double-sided printing with a large “copper” area, the ability to glue a radiator onto the chip (used to cool the memory of video cards).

SD driver on Allegro A3982 chip



Power supply voltage: 8…35 V Logic supply voltage: 3.3…5 V Output current (maximum, depends on mode and cooling): ±2 A Typical resistance of open transistors (at a current of 1.5A): 0.33+0 .37 Ohm

SD driver on Allegro A3977 chip

Main characteristics and block diagram:


Power supply voltage: 8…35 V Logic supply voltage: 3.3…5 V Output current (maximum, depends on mode and cooling): ±2.5 A Typical resistance of open transistors (at a current of 2.5A): 0.33 +0.45 Ohm

Scheme and prototype



Designed in the DipTrace environment. The A3982 driver is included according to the diagram from the manufacturer's documentation. Half-step mode is enabled. Additionally, for reliable operation of control and indication signals, I used a 74NS14 logic chip (with Schmitt triggers). It was possible to make galvanic isolation using optocouplers, but for a small machine I decided not to do it. The circuit on the A3977 differs only in additional step mode jumpers and a more powerful power connector, but has not yet been implemented in hardware.

Printed circuit board

The manufacturing process is LUT, double-sided. Dimensions 37x37 mm, fasteners - like engines, 31x31 mm.


For comparison, on the left is my work, on the right is the driver for the A4988.

The article provides schematic diagrams of options for a simple, inexpensive stepper motor controller and resident software (firmware) for it.

General description.

The stepper motor controller is developed on the PIC controller PIC12F629. This is an 8 pin microcontroller that costs only $0.5. Despite the simple circuit and low cost of components, the controller provides fairly high performance and broad functionality.

  • The controller has circuit options to control both unipolar and bipolar stepper motors.
  • Provides adjustment of engine rotation speed over a wide range.
  • It has two stepper motor control modes:
    • full step;
    • half-step.
  • Provides rotation in forward and reverse directions.
  • Setting modes, parameters, and controlling the controller is carried out using two buttons and an ON signal (turn on).
  • When the power is turned off, all modes and parameters are saved in the controller’s non-volatile memory and do not require resetting when turned on.

The controller does not have protection against short circuits of the motor windings. But the implementation of this function significantly complicates the circuit, and shorting the windings is an extremely rare case. I haven't encountered anything like this. In addition, mechanical stopping of the stepper motor shaft during rotation does not cause dangerous currents and does not require driver protection.

You can read about the modes and methods of controlling a stepper motor, about divers.

Controller circuit for a unipolar stepper motor with a bipolar transistor driver.

There is nothing special to explain in the diagram. Connected to the PIC controller:

  • buttons "+" and "–" (via the analog input of the comparator);
  • ON signal (engine switching on);
  • driver (transistors VT1-Vt4, protective diodes VD2-VD9).

The PIC uses an internal clock generator. Modes and parameters are stored in internal EEPROM.

The driver circuit based on bipolar transistors KT972 provides a switching current of up to 2 A, winding voltage of up to 24 V.

I soldered the controller onto a 45 x 20mm breadboard.

If the switching current does not exceed 0.5 A, you can use BC817 series transistors in SOT-23 packages. The device will be quite miniature.

Software and controller management.

Resident software is written in assembly language with cyclic resetting of all registers. In principle, the program cannot freeze. You can download software (firmware) for PIC12F629.

Controlling the controller is quite simple.

  • When the "ON" signal is active (closed to ground), the engine rotates; when it is inactive (torn off from the ground), it is stopped.
  • When the engine is running (the ON signal is active), the “+” and “–” buttons change the rotation speed.
    • Each press of the "+" button increases the speed by a minimum increment.
    • Pressing the “–” button decreases the speed.
    • By holding down the “+” or “–” buttons, the rotation speed smoothly increases or decreases by 15 increments per second.
  • When the engine is stopped (the ON signal is not active).
    • Pressing the "+" button sets the rotation mode in the forward direction.
    • Pressing the “–” button puts the controller into reverse rotation mode.
  • To select a mode – full-step or half-step, you must hold the “–” button pressed while applying power to the controller. The motor control mode will be changed to another (inverted). It is enough to hold the button pressed for 0.5 seconds.

Controller circuit for a unipolar stepper motor with a driver based on MOSFET transistors.

Low-threshold MOSFET transistors allow you to create a driver with higher parameters. The use of MOSFET transistors, for example, IRF7341, in the driver provides the following advantages.

  • The transistor resistance in the open state is no more than 0.05 Ohm. This means a low voltage drop (0.1 V at a current of 2 A), the transistors do not heat up and do not require cooling radiators.
  • Transistor current up to 4 A.
  • Voltage up to 55 V.
  • One 8-pin SOIC-8 package houses 2 transistors. Those. To implement the driver, 2 miniature cases will be required.

Such parameters cannot be achieved with bipolar transistors. For switching currents above 1 A, I strongly recommend the device option using MOSFET transistors.

Connection to the controller of unipolar stepper motors.

Motors with 5, 6 and 8 wire winding configurations can operate in unipolar mode.

Wiring diagram for a unipolar stepper motor with 5 and 6 wires (leads).

For FL20STH, FL28STH, FL35ST, FL39ST, FL42STH, FL57ST, FL57STH motors with a 6-wire winding configuration, the terminals are marked in the following colors.

The 5-wire configuration is an option in which the common winding wires are connected inside the motor. There are such engines. For example, PM35S-048.

Documentation for the PM35S-048 stepper motor in PDF format can be downloaded.

Wiring diagram for a unipolar stepper motor with 8 wires (leads).

The same as for the previous option, only all winding connections occur outside the motor.

How to choose voltage for a stepper motor.

According to Ohm's law through the winding resistance and the permissible phase current.

U = Iphase * Rwinding

The DC winding resistance can be measured, but the current must be looked for in the reference data.

I emphasize that we are talking about simple drivers that do not provide a complex form of current and voltage. Such modes are used at high rotation speeds.

How to determine the windings of stepper motors if there is no reference data.

In unipolar motors with 5 and 6 terminals, the middle terminal can be determined by measuring the resistance of the windings. Between the phases the resistance will be twice as great as between the middle terminal and the phase. The middle terminals are connected to the positive of the power supply.

Then any of the phase pins can be assigned as phase A. There will be 8 options for switching pins. You can sort them out. If you consider that the winding of phase B has a different middle wire, then the options become even fewer. Matching phase windings does not lead to failure of the driver or motor. The engine rattles and does not turn over.

Just remember that too high a rotation speed (out of synchronization) leads to the same effect. Those. It is necessary to set the rotation speed deliberately low.

Circuit diagram of a bipolar stepper motor controller with an L298N integrated driver.

Bipolar mode provides two advantages:

  • a motor with almost any winding configuration can be used;
  • Torque increases by approximately 40%.

Creating a bipolar driver circuit using discrete elements is a thankless task. It's easier to use the L298N integrated driver. There is a description in Russian.

The controller circuit with the L298N bipolar driver looks like this.

The L298N driver is included according to the standard scheme. This controller option provides phase currents up to 2 A, voltage up to 30 V.

Connection to a bipolar stepper motor controller.

In this mode, a motor with any winding configuration of 4, 6, 8 wires can be connected.

Wiring diagram for a bipolar stepper motor with 4 wires (leads).

For FL20STH, FL28STH, FL35ST, FL39ST, FL42STH, FL57ST, FL57STH motors with a 4-wire winding configuration, the terminals are marked in the following colors.

Wiring diagram for a bipolar stepper motor with 6 wires (leads).

For motors FL20STH, FL28STH, FL35ST, FL39ST, FL42STH, FL57ST, FL57STH with this winding configuration, the terminals are marked with the following colors.

Such a circuit requires a supply voltage twice as high as compared to a unipolar connection, because The winding resistance is twice as high. Most likely, the controller must be connected to a 24 V power supply.

Wiring diagram for a bipolar stepper motor with 8 wires (leads).

There may be two options:

  • with sequential connection
  • with parallel connection.

Scheme of sequential connection of windings.

A circuit with windings connected in series requires twice the winding voltage. But the phase current does not increase.

Diagram of parallel connection of windings.

A circuit with parallel connection of windings doubles the phase currents. The advantages of this circuit include the low inductance of the phase windings. This is important at high rotation speeds.

Those. The choice between serial and parallel connection of an 8-pin bipolar stepper motor is determined by the following criteria:

  • maximum driver current;
  • maximum driver voltage;
  • engine rotation speed.

Software (firmware) for PIC12F629 can be downloaded.

For the operation of almost all electrical devices, special drive mechanisms are required. We propose to consider what a stepper motor is, its design, operating principle and connection diagrams.

What is a stepper motor?

A stepper motor is an electrical machine designed to convert electrical energy from the network into mechanical energy. Structurally, it consists of stator windings and a soft magnetic or hard magnetic rotor. A distinctive feature of a stepper motor is discrete rotation, in which a given number of pulses corresponds to a certain number of steps taken. Such devices are most widely used in CNC machines, robotics, and information storage and reading devices.

Unlike other types of machines, a stepper motor does not rotate continuously, but in steps, which is where the name of the device comes from. Each such step is only a fraction of its full revolution. The number of steps required to completely rotate the shaft will vary depending on the connection diagram, motor brand and control method.

Advantages and disadvantages of a stepper motor

The advantages of using a stepper motor include:

  • In stepper motors, the angle of rotation corresponds to the number of electrical signals supplied, while after stopping the rotation, the full torque and fixation are maintained;
  • Precise positioning – provides 3 – 5% of the set step, which does not accumulate from step to step;
  • Provides high speed start, reverse, stop;
  • It is highly reliable due to the absence of rubbing components for current collection, unlike commutator motors;
  • The stepper motor does not require feedback to position;
  • Can produce low speeds for a directly applied load without any gearboxes;
  • Relatively lower cost relative to the same;
  • A wide range of shaft speed control is provided by changing the frequency of electrical pulses.

The disadvantages of using a stepper motor include:

  • A resonance effect and slippage of the stepper unit may occur;
  • There is a possibility of loss of control due to lack of feedback;
  • The amount of electricity consumed does not depend on the presence or absence of a load;
  • Difficulty in control due to the design of the circuit

Design and principle of operation

Rice. 1. Operating principle of stepper motor

Figure 1 shows 4 windings that belong to the motor stator, and their arrangement is arranged so that they are at an angle of 90º relative to each other. From which it follows that such a machine is characterized by a step size of 90º.

When voltage U1 is applied to the first winding, the rotor moves by the same 90º. If voltage U2, U3, U4 is alternately supplied to the corresponding windings, the shaft will continue to rotate until the full circle is completed. After which the cycle repeats again. To change the direction of rotation, it is enough to change the order of supply of pulses to the corresponding windings.

Stepper Motor Types

To ensure various operating parameters, both the step size by which the shaft will move and the moment applied for movement are important. Variations in these parameters are achieved due to the design of the rotor itself, the connection method and the design of the windings.

By rotor design

The rotating element provides magnetic interaction with the electromagnetic field of the stator. Therefore, its design and technical features directly determine the operating mode and rotation parameters of the stepper unit. In order to practically determine the type of stepper motor, with the network de-energized, you need to turn the shaft; if you feel resistance, this indicates the presence of a magnet; otherwise, it is a design without magnetic resistance.

Reactive

A reactive stepper motor is not equipped with a magnet on the rotor, but is made of soft magnetic alloys; as a rule, it is made of plates to reduce induction losses. The design in cross section resembles a gear with teeth. The poles of the stator windings are powered by opposite pairs and create a magnetic force to move the rotor, which moves from the alternating flow of electric current in the winding pairs.


A significant advantage of this stepper drive design is the absence of a stopping moment generated by the field in relation to the reinforcement. In fact, this is the same in which the rotor rotates in accordance with the stator field. The disadvantage is the reduction in torque. The pitch for a jet engine ranges from 5 to 15°.

With permanent magnets

In this case, the moving element of the stepper motor is assembled from a permanent magnet, which can have two or more poles. Rotation of the rotor is ensured by the attraction or repulsion of the magnetic poles by the electric field when voltage is applied to the corresponding windings. For this design, the angular step is 45-90°.


Hybrid

It was developed to combine the best qualities of the two previous models, due to which the unit has a smaller angle and pitch. Its rotor is made in the form of a cylindrical permanent magnet, which is magnetized along the longitudinal axis. Structurally, it looks like two round poles, on the surface of which there are rotor teeth made of soft magnetic material. This solution made it possible to provide excellent holding and torque.


The advantages of a hybrid stepper motor are its high accuracy, smoothness and speed of movement, small steps - from 0.9 to 5°. They are used for high-end CNC machines, computer and office equipment and modern robotics. The only drawback is the relatively high cost.

As an example, let’s look at the option of hybrid motors with 200 shaft positioning steps. Accordingly, each of the cylinders will have 50 teeth, one of them is a positive pole, the second is negative. In this case, each positive tooth is located opposite the groove in the negative cylinder and vice versa. Structurally it looks like this:


Because of this, there are 100 alternating poles with excellent polarity on the stepper motor shaft. The stator also has teeth as shown in Figure 6 below, except for the spaces between its components.


Rice. 6. Operating principle of a hybrid stepper motor

Due to this design, it is possible to achieve a displacement of the same south pole relative to the stator in 50 different positions. Due to the difference in the position in the half-position between the north and south poles, the ability to move in 100 positions is achieved, and the phase shift by a quarter division makes it possible to double the number of steps due to sequential excitation, that is, up to 200 steps of the angular shaft per 1 revolution.

Pay attention to Figure 6, the principle of operation of such a stepper motor is that when current is supplied in pairs to opposite windings, the opposite poles of the rotor, located behind the stator teeth, are pulled together and the like poles, going in front of them in the direction of rotation, are repelled.

By type of windings

In practice, a stepper motor is a polyphase motor. The smoothness of operation in which directly depends on the number of windings - the more there are, the smoother the rotation occurs, but also the higher the cost. In this case, the torque does not increase from the number of phases, although for normal operation their minimum number on the electric motor stator must be at least two. The number of phases does not determine the number of windings, so a two-phase stepper motor can have four or more windings.

Unipolar

A unipolar stepper motor differs in that the winding connection diagram has a branch from the middle point. This makes it easy to change magnetic poles. The disadvantage of this design is that only half of the available turns are used, resulting in less torque being achieved. Therefore, they are distinguished by their large dimensions.


To use the full power of the coil, the middle terminal is left unconnected. Consider the designs of unipolar units; they may contain 5 and 6 leads. Their number will depend on whether the middle wire is brought out separately from each motor winding or whether they are connected together.


Bipolar

The bipolar stepper motor is connected to the controller via 4 pins. In this case, the windings can be connected internally both in series and in parallel. Consider an example of his work in the figure.


In the design diagram of such a motor you see one excitation winding in each phase. Because of this, changing the direction of the current requires the use of special drivers (electronic chips designed for control) in the electronic circuit. A similar effect can be achieved by turning on the H-bridge. Compared to the previous one, the bipolar device provides the same torque with much smaller dimensions.

Connecting a stepper motor

To power the windings, you will need a device capable of delivering a control pulse or a series of pulses in a certain sequence. Such blocks are semiconductor devices for connecting a stepper motor and microprocessor drivers. Which have a set of output terminals, each of them determines the power supply method and operating mode.

Depending on the connection diagram, one or another output of the stepper unit should be used. With various options for connecting certain terminals to the DC output signal, a certain rotation speed, step or microstep of linear movement in the plane is obtained. Since some tasks require a low frequency, while others require a high one, the same motor can set the parameter at the expense of the driver.

Typical SD connection diagrams

Depending on the number of pins present on a particular stepper motor: 4, 6 or 8 pins, the possibility of using one or another connection diagram will also differ. Look at the pictures, typical options for connecting a stepper mechanism are shown here:


Connection diagrams for various types of stepper motors

Provided that the main poles of the stepper machine are powered from the same driver, according to these diagrams the following distinctive features of operation can be noted:

  • The leads are clearly connected to the corresponding terminals of the device. When connecting windings in series, the inductance of the windings increases, but the current decreases.
  • Provides the passport value of electrical characteristics. In a parallel circuit, the current increases and the inductance decreases.
  • When connecting one phase per winding, the torque at low speeds is reduced and the magnitude of the currents is reduced.
  • When connected, it carries out all electrical and dynamic characteristics according to the passport, rated currents. The control scheme is greatly simplified.
  • Produces much more torque and is used for high rotation speeds;
  • Like the previous one, it is designed to increase torque, but is used for low rotation speeds.

Stepper motor control

Performing operations with a stepper unit can be carried out using several methods. Each of which differs in the way it supplies signals to pairs of poles. In total, there is a range of winding activation methods.

Wave– in this mode, only one winding is excited, to which the rotor poles are attracted. At the same time, the stepper motor is not capable of pulling a large load, since it produces only half the torque.


Full step– in this mode, simultaneous phase switching occurs, that is, both are excited at once. Because of which the maximum torque is ensured, in the case of parallel connection or series connection of the windings, the maximum voltage or current will be created.


Half-step– is a combination of the two previous methods of switching windings. During the implementation of which in the stepper motor, voltage is alternately supplied first to one coil, and then to two at once. This ensures better grip at maximum speeds and a greater number of steps.


For softer control and overcoming rotor inertia, microstepping control is used, when the sine wave of the signal is carried out by microstep pulses. Due to this, the interaction forces of the magnetic circuits in the stepper motor receive a smoother change and, as a result, the rotor moves between the poles. Allows you to significantly reduce stepper motor jerks.

Without controller

An H-bridge system is used to control brushless motors. Which allows you to switch the polarity to reverse the stepper motor. It can be performed on transistors or microcircuits that create a logical chain for moving keys.


As you can see, voltage is supplied to the bridge from the power source V. When contacts S1 – S4 or S3 – S2 are connected in pairs, current will flow through the motor windings. Which will cause rotation in one direction or another.

With controller

The controller device allows you to control the stepper motor in various modes. The controller is based on an electronic unit that generates groups of signals and their sequence sent to the stator coils. To prevent the possibility of damage in the event of a short circuit or other emergency situation on the motor itself, each terminal is protected by a diode, which will not allow a pulse to pass in the opposite direction.


Connection via unipolar stepper motor controller

Popular motor control schemes


Control circuit from a controller with differential output

It is one of the most noise-resistant ways of working. In this case, the direct and inverse signals are directly connected to the corresponding poles. In such a circuit, shielding of the signal conductor must be used. Ideal for low power loads.


Control circuit from a controller with an “open collector” type output

In this circuit, the positive inputs of the controller are combined, which are connected to the positive pole. In case of power supply above 9V, a special resistor must be included in the circuit to limit the current. Allows you to set the required number of steps at a strictly set speed, determine acceleration, etc.

The simplest DIY stepper motor driver

To assemble a driver circuit at home, some elements from old printers, computers and other equipment may be useful. You will need transistors, diodes, resistors (R) and a microcircuit (RG).


To build a program, be guided by the following principle: when a logical unit is applied to one of the D pins (the others signal zero), the transistor opens and the signal passes to the motor coil. Thus one step is completed.

Based on the diagram, a printed circuit board is made, which you can try to make yourself or make to order. After that, the corresponding parts are soldered onto the board. The device is capable of controlling a stepper device from a home computer by connecting to a regular USB port.

Useful video



Part 2. Circuitry of control systems

The most important general issues of using stepper motors, which will help in their development, were discussed above. But, as our favorite Ukrainian proverb says: “I won’t believe it until I check it” (“I won’t believe it until I check it”). Therefore, let's move on to the practical side of the issue. As already noted, stepper motors are not a cheap pleasure. But they are available in old printers, floppy and laser disk readers, for example, SPM-20 (a stepper motor for head positioning in 5"25 Mitsumi disk drives) or EM-483 (from an Epson Stylus C86 printer), which can be found in your old trash or buy for pennies at a radio market.Examples of such engines are presented in Figure 8.

The simplest for initial development are unipolar motors. The reason lies in the simplicity and low cost of their winding control driver. Figure 9 shows a practical diagram of the driver used by the author of the article for a P542-M48 series unipolar stepper motor.

Naturally, the choice of the type of transistor for the winding control keys should take into account the maximum switching current, and its connection should take into account the need to charge/discharge the gate capacitance. In some cases, direct connection of the MOSFET to the switch IC may not be acceptable. As a rule, series-connected resistors of small values ​​are installed in the gates. But in some cases it is also necessary to provide an appropriate driver to control the keys, which will ensure the charge/discharge of their input capacity. Some solutions propose using bipolar transistors as switches. This is only suitable for very low power motors with low winding current. For the motor under consideration with an operating current of the windings I = 230 mA, the control current at the base of the key should be at least 15 mA (although for normal operation of the key it is necessary that the base current be equal to 1/10 of the operating current, that is, 23 mA). But it is impossible to extract such current from the 74HCxx series microcircuits, so additional drivers will be required. As a good compromise, you can use IGBTs that combine the advantages of field-effect and bipolar transistors.

From the point of view of the author of the article, the most optimal way to control the switching of small-power motor windings is to use an R DC(ON) MOSFET that is suitable for the current and open channel resistance, but taking into account the recommendations described above. The power dissipated on the keys for the P542-M48 series engine selected as an example, when the rotor is completely stopped, will not exceed

P VT = R DC(ON) × I 2 = 0.25 × (0.230) 2 = 13.2 mW.

Another important point is the correct choice of so-called snubber diodes that shunt the motor winding (VD1...VD4 in Figure 9). The purpose of these diodes is to suppress the self-induction EMF that occurs when the control switches are turned off. If the diodes are chosen incorrectly, then failure of the transistor switches and the device as a whole is inevitable. Please note that such diodes, as a rule, are already built into high-power MOSFETs.

The motor control mode is set by the switch. As noted above, the most convenient and effective is control with phase overlap (Figure 4b). This mode is easily implemented using triggers. A practical diagram of a universal switch, which the author of the article used both in a number of debugging modules (including the one with the driver above) and for practical applications, is shown in Figure 10.

The circuit in Figure 10 is suitable for all types of motors (unipolar and bipolar). The engine speed is set by an external clock generator (any duty cycle), the signal from which is supplied to the “STEPS” input, and the direction of rotation is set through the “DIRECTION” input. Both signals have logic levels and, if open collector outputs are used to generate them, then appropriate pull-up resistors will be required (they are not shown in Figure 10). The timing diagram of the switch is shown in Figure 11.

I would like to draw the attention of readers: on the Internet you might have come across a similar circuit, made not on D-flip-flops, but on JK-flip-flops. Be careful! In a number of these schemes, an error was made in connecting the IC. If there is no need for reverse, then the switch circuit can be significantly simplified (see Figure 12), while the rotation speed will remain unchanged, and the control diagram will be similar to that shown in Figure 11 (oscillograms before switching the phase order).

Since there are no special requirements for the “STEPS” signal, any generator suitable for the output signal levels can be used to generate it. For his debugging modules, the author used an IC-based generator (Figure 13).

To power the engine itself, you can use the circuit shown in Figure 14, and the switch and generator circuit can be powered either from a separate +5 V power supply or through an additional low-power stabilizer. In any case, the lands of the power and signal parts must be separated.

The circuit in Figure 14 provides two stable voltages to power the motor windings: 12 V in operating mode and 6 V in hold mode. (The formulas necessary to calculate the output voltage are given in). The operating mode is activated by applying a high logical level to the “BRAKE” contact of connector X1. The admissibility of reducing the supply voltage is determined by the fact that, as already noted in the first part of the article, the holding torque of stepper motors exceeds the rotational torque. Thus, for the P542-M48 engine under consideration, the holding torque with a 25:6 gearbox is 19.8 Ncm, and the rotation torque is only 6 Ncm. This approach allows you to reduce power consumption from 5.52 W to 1.38 W when the engine is stopped! Complete shutdown of the engine is carried out by applying a high logical level to the “ON/OFF” contact of connector X1.

If the control circuit has an output using open-collector transistors, then there is no need for switches VT1, VT2, and the outputs can be connected directly instead of the mentioned keys.

Note: In this embodiment, the use of pull-up resistors is unacceptable!

The author used an SDR1006-331K coil (Bourns) as a choke. The total power supply of the voltage driver for the motor windings can be reduced to 16 - 18 V, which will not affect its operation. Once again, please note: when making your own calculations, do not forget to take into account that the driver provides a mode with phase overlap, that is, it is necessary to rely on the rated current of the power circuit, equal to twice the maximum current of the windings at the selected supply voltage.

The task of controlling bipolar motors is more complex. The main problem is in the driver. These engines require a bridge-type driver, and making it, especially in modern conditions, using discrete elements is a thankless task. Yes, this is not required, since there is a very large selection of specialized ICs. All these ICs can be roughly reduced to two types. The first is the L293D IC, which is very popular among robotics enthusiasts, or its variants from. They are relatively inexpensive and suitable for controlling low-power motors with winding currents up to 600 mA. ICs have protection against overheating; it must be installed with a heat sink, which is the foil of the printed circuit board. The second type is already familiar to readers from publication in the LMD18245 IC.

The author used the L293DD driver in a circuit to control a low-power bipolar motor type 20M020D2B 12 V/0.1 A while studying the problem of using stepper motors. This driver is convenient because it contains four half-bridge switches, so only one IC is required to control a bipolar stepper motor. The complete circuit shown in and repeated many times on Internet sites is suitable for use as a test board. Figure 15 shows the inclusion of the driver IC (linked to the switch from Figure 10), since this is the part that is of interest to us now, and Figure 6 (Bipolar Stepping-Motor Control) from the specification is not entirely clear to a novice user. It is misleading, for example, in that it shows external diodes that are actually built into the IC and cope well with the windings of low-power motors. Naturally, the L293D driver can work with any switch. The driver is turned off by logical zero at the R input.

Note: IC L293, depending on the manufacturer and suffixes indicating the type of case, have differences in numbering and number of pins!

Unlike the L293DD, the LMD18245 is a dual-channel driver rather than a four-channel one, so two ICs are required to implement the control circuit. The LMD18245 driver is made using DMOS technology, contains protection circuits against overheating and short circuits, and is housed in a convenient 15-pin TO-220 package, which makes it easy to remove excess heat from its case. The circuit shown earlier in Figure 13 was used as a master oscillator, but with the resistance of resistor R2 increased to 4.7 kOhm. To supply single pulses, use the BH1 button, which allows you to move the motor rotor one step. The direction of rotation of the rotor is determined by the position of switch S1. The engine is turned on and off by switch S2. In the “OFF” position, the motor rotor is released, and its rotation by control pulses becomes impossible. Hold mode reduces the maximum current drawn by the motor windings from two amps to one amp. If control pulses are not supplied, the motor rotor remains in a fixed position with power consumption reduced by half. If pulses are supplied, then the engine rotates in this mode with a reduced torque at low rotation speeds. It should be noted that since with full-step control " two-phase-on"both windings are turned on, the motor current doubles, and the driver circuit must be calculated based on the requirements of providing a given current to two windings (resistors R3, R8).

The circuit contains the previously described bidirectional two-phase driver based on D-flip-flops (Figure 10). The maximum driver current is set by a resistor connected to the circuit of pin 13 of the LMD18245 IC (resistors R3, R8), and by a binary code on the contacts of the current control circuit (pins 8, 7, 6, 4). The formula for calculating the maximum current is given in the driver specification. Current limitation is carried out by the pulse method. When the maximum specified current value is reached, it is “chopping” (“chopping”). The parameters of this “cutting” are set by a parallel RC chain connected to pin 3 of the driver. The advantage of the LMD18245 IC is that the current-setting resistor, which is not connected directly to the motor circuit, has a fairly large rating and low power dissipation. For the circuit under consideration, the maximum current in amperes, according to the formula given in the formula, is:

V DAC REF - DAC reference voltage (5 V in the circuit under consideration);
D - DAC bits involved (in this mode all 16 bits are used);
R S - resistance of the current-limiting resistor (R3 = R8 = 10 kOhm).

Accordingly, in hold mode (since 8 bits of the DAC are used), the maximum current will be 1 A.

As you can see from the proposed article, although stepper motors are more difficult to control than commutator motors, they are not so difficult to abandon them. As the ancient Romans said: “He who walks can master the road.” Naturally, in practice, for many applications, it is advisable to control stepper motors on the basis of microcontrollers, which can easily generate the necessary commands for drivers and act as switches. Additional information and a more detailed consideration of the problems associated with the use of stepper motors, in addition to the links mentioned above [, ,], can be gleaned from the now classic monograph by Kenio Takashi and on specialized Internet sites, for example,.

There is one more point to which the author of the article would like to draw the attention of readers. Stepper motors, like all DC motors, are reversible. What is meant? If you apply an external rotating force to the rotor, then the EMF can be removed from the stator windings, that is, the engine becomes a generator, and a very, very efficient one at that. The author of the article experimented with this use case for stepper motors while working as a power electronics consultant for a wind energy company. It was necessary to work out a number of practical solutions using simple mock-ups. According to the observation of the author of the article, the efficiency of a stepper motor in this application was higher than that of a brushed DC motor of similar parameters and dimensions. But that is another story.

  • Rentyuk Vladimir “Control stepper motors in both directions” EDN March 18, 2010
  • Kenyo Takashi. Stepper motors and their microprocessor control systems: Per. from English, M.: Energoatomizdat, 1987 - 199 p.
  • 07-05-2009

    Tools:

    • Glue gun
    • Wire cutters
    • Scissors
    • Soldering Accessories
    • Dye

    For controller:

    • 1 DB-25 connector - wire
    • 1 x DC cylindrical socket For test bench
    • 1 threaded rod
    • 1 nut that fits the rod - various washers and screws - pieces of wood

    For the control computer:

    • 1 old computer (or laptop)
    • 1 copy of TurboCNC (from here)

    Step 2.

    We take parts from an old scanner. To build your own CNC controller, you first need to remove the stepper motor and control board from the scanner. There are no photos here because each scanner looks different, but usually you just need to remove the glass and remove a few screws. In addition to the motor and board, you can also leave metal rods that will be required for testing the stepper motor.

    Step 3.

    Removing the chip from the control board Now you need to find the ULN2003 chip on the stepper motor control board. If you were unable to find it on your device, ULN2003 can be purchased separately. If there is one, it needs to be desoldered. This will require some skill, but is not that difficult. First, use suction to remove as much solder as possible. After this, carefully insert the end of a screwdriver under the chip. Carefully touch the tip of the soldering iron to each pin while continuing to press down on the screwdriver.

    Step 4.

    Soldering Now we need to solder the chip onto the breadboard. Solder all pins of the microcircuit to the board. The breadboard shown here has two power rails, so the positive pin of the ULN2003 (see schematic and picture below) is soldered to one of them and the negative pin to the other. Now, you need to connect pin 2 of the parallel port connector to pin 1 of the ULN2003. Pin 3 of the parallel port connector connects to pin 2 of the ULN2003, pin 4 to pin 3 of the ULN2003, and pin 5 to pin 4 of the ULN2003. Now pin 25 of the parallel port is soldered to the negative power rail. Next, the motor is soldered to the control device. This will have to be done through trial and error. You can simply solder the wires so that you can then attach crocodiles to them. You can also use screw terminals or something similar. Simply solder wires to pins 16, 15, 14 and 13 of the ULN2003 chip. Now solder a wire (preferably black) to the positive power rail. The control device is almost ready. Finally, connect a cylindrical DC jack to the power rails on the breadboard. To prevent the wires from breaking off, they are secured with glue from a gun.

    Step 5.

    Installing the software Now about the software. The only thing that will definitely work with your new device is Turbo CNC. Download it. Unpack the archive and burn it to CD. Now, on the computer that you are going to use for management, go to the C:// drive and create a "tcnc" folder in the root. Then, copy the files from the CD to a new folder. Close all windows. You have just installed Turbo CNC.

    Step 6.

    Software setup Restart your computer to switch to MS-DOS. At the command prompt, type "C: cncTURBOCNC". Sometimes it is better to use a boot disk, then a copy of TURBOCNC is placed on it and you need to type “A: cncTURBOCNC” accordingly. A screen similar to the one shown in Fig. will appear. 3. Press Spacebar. Now you are in the main menu of the program. Press F1, and use the arrow keys to select the "Configure" menu. Use the arrow keys to select "number of axis". Press Enter. Enter the number of axes to be used. Since we only have one motor, we select "1". Press Enter to continue. Press F1 again and select "Configure axes" from the "Configure" menu, then press Enter twice.

    The following screen will appear. Press Tab until you reach the "Drive Type" cell. Use the down arrow to select "Phase". Use Tab again to select the "Scale" cell. To use the calculator, we need to find the number of steps the motor makes in one revolution. Knowing the engine model number, you can determine how many degrees it turns in one step. To find the number of steps the motor makes per revolution, you now need to divide 360 ​​by the number of degrees per step. For example, if the motor rotates 7.5 degrees in one step, 360 divided by 7.5 equals 48. Enter the number you get into a scale calculator.

    Leave the rest of the settings as they are. Click OK, and copy the number in the Scale cell to the same cell on another computer. Set the Acceleration cell to 20 because the default of 2000 is too high for our system. Set the initial speed to 20 and the maximum speed to 175. Press Tab until you reach the "Last Phase" item. Set it to 4. Press Tab until you reach the first row of X's.

    Copy the following into the first four cells:

    1000XXXXXXXX
    0100XXXXXXXX
    0010XXXXXXXX
    0001XXXXXXXX

    Leave the remaining cells unchanged. Select OK. You have now configured the software.

    Step 7

    Building a test shaft The next stage of work will be to assemble a simple shaft for the test system. Cut 3 pieces of wood and fasten them together. To get straight holes, draw a straight line on the surface of the wood. Drill two holes on the line. Drill 1 more hole in the middle below the first two. Disconnect the bars. Thread steel rods through two holes that are on the same line. Use small screws to secure the rods. Thread the rods through the second block. Secure the engine to the last block. It doesn't matter how you do it, be creative.

    To secure the engine that was available, two pieces of 1/8 threaded rod were used. A block with an attached motor is placed on the free end of the steel rods. Secure them again with screws. Thread a threaded rod through the third hole on the first block. Screw the nut onto the rod. Pass the rod through the hole in the second block. Rotate the rod until it goes through all the holes and reaches the motor shaft. Connect the motor shaft and rod using a hose and wire clamps. On the second block, the nut is held in place with additional nuts and screws. Finally, cut a piece of wood for the stand. Screw it to the second bar with screws. Check that the stand is installed level on the surface. The position of the stand on the surface can be adjusted using additional screws and nuts. This is how the shaft for the test system is made.

    Step 8

    Connecting and testing the motor Now you need to connect the motor to the controller. First, connect the common wire (see the motor documentation) to the wire that was soldered to the positive power bus. The other four wires are connected through trial and error. Connect them all, and then change the connection order if your motor takes two steps forward and one step back or something similar. To test, connect a 12V 350mA DC power supply to the barrel jack. Then connect the DB25 connector to the computer. In TurboCNC, check how the motor is connected. As a result of testing and verifying that the motor is connected correctly, you should have a fully functional shaft. To test your device's scaling, attach a marker to it and run a test program. Measure the resulting line. If the line length is about 2-3 cm, the device is working correctly. Otherwise, check the calculations in step 6. If you succeeded, congratulations, the hardest part is over.


    Step 9

    Case manufacturing

    Part 1

    Making the body is the final stage. Let's join the environmentalists and make it from recycled materials. Moreover, our controller is also not from store shelves. The sample board presented to your attention measures 5 by 7.5 cm, so the case will measure 7.5 by 10 by 5 cm to leave enough space for the wires. Cut out the walls from a cardboard box. Cut out 2 rectangles measuring 7.5 by 10 cm, 2 more measuring 5 by 10 cm and 2 more measuring 7.5 by 5 cm (see pictures). You need to cut holes in them for the connectors. Trace the outline of the parallel port connector on one of the 5 x 10 walls. On the same wall, trace the contours of a cylindrical socket for DC power. Cut out both holes along the contours. What you do next depends on whether you soldered the connectors to the motor wires. If yes, then attach them to the outside of the second currently empty 5 x 10 wall. If not, poke 5 holes in the wall for the wires. Using a glue gun, connect all the walls together (except the top, see pictures). The body can be painted.

    Step 10

    Case manufacturing

    Part 2

    Now you need to glue all the components inside the case. Make sure to get plenty of glue on the connectors because they will be subject to a lot of stress. To keep the box closed, you need to make latches. Cut out a couple of ears from foam plastic. Then cut out a couple of strips and four small squares. Glue two squares to each of the strips as shown in the picture. Glue the ears on both sides of the body. Glue stripes on top of the box. This completes the manufacture of the body.

    Step 11

    Possible applications and conclusion This controller can be used as: - CNC device - plotter - or any other thing that needs precise motion control. - addendum - Here is a diagram and instructions for making a three-axis controller. To configure the software, follow the above steps, but enter 3 in the "number of axis" field.

    To configure the first axis, do everything as stated above, for the second axis too, but in the lines of the first four phases, enter the following:

    "XXXX1000XXXX
    XXXX0100XXXX
    XXXX0010XXXX
    XXXX0001XXXX"

    For the third axis, in the lines of the first four phases, enter:

    "XXXXXXXX1000
    XXXXXXXXX0100
    XXXXXXXXX0010
    XXXXXXXXX0001"

    To comment on materials from the site and gain full access to our forum, you need register .