30
Practical Electronics/Stepper Motors Stepper Motors are devices that turn a shaft by a small set angle (usually between 1 and 5 degrees) at a time. This is done very precisely, and so they are very useful for application requiring motion that does not have any feedback to govern the motor speed. However, they cannot be simply driven by a DC or AC voltage like simpler motors; they need more complex circuitry to drive them. For more information on stepper motors, please visit the "Stepper" page in the Wikibook of Electric Motors and Generators.  For this book, we will just look at the basics. There are two kinds of stepper motor - unipolar  and bipolar . Bipolar motors are the simplest, so we will look at those first. Bipolar Motors Bipolar motors have two coils, each with a connection at each end, giving a total of four wires. It is possible to identify which wires are which, as the resistance between wires of different coils will be infinite. Generally, the connections are named in schematics, 1a and 1b being the two connections for one coil and 2a and 2b being for the other coil. To drive a bipolar stepper motor by one step, the coils have to be energized in a particular sequence. Consider just one coil; if 1a is held high and 1b is held low, the coil is said to conduct forwards. If 1a is at ground and 1b is high, then it conducts backwards. To drive the stepper motor, the coils have to be switched from conducting forwards to conducting backwards alternately. The input voltages to the four wires in order to drive the motor forward on step are shown in the table below. The coil polarities generated by this sequence are shown on the far right of the table. Seq. 1a 1b 2a 2b Coil 1 Polarity Coil 2 Polarity 1 + - + - Forwards Forwards 2 - + + - Backwards Forwards 3 - + - + Backwards Backwards 4 + - - + Forwards Backwards  There are many ways to produce this sequence, from using basic logic to incorporating the control into a micro-controller. Below is the circuit diagram for a motor controller made of simple logic components. Every time there is a low-to-high transition on the STEP input, the circuit advances the output on stage. The DIR input controls the direction of the step; if it is high, it steps one way, if it is low it steps the other way.

Practical Electronics Motor

Embed Size (px)

DESCRIPTION

electric

Citation preview

Practical Electronics/Stepper MotorsStepper Motors are devices that turn a shaft by a small set angle (usually between 1 and 5 degrees) at a time. This is done very precisely, and so they are very useful for application requiring motion that does not have any feedback to govern the motor speed. However, they cannot be simply driven by a DC or AC voltage like simpler motors; they need more complex circuitry to drive them.For more information on stepper motors, please visit the "Stepper" page in the Wikibook of Electric Motors and Generators. For this book, we will just look at the basics. There are two kinds of stepper motor - unipolar and bipolar. Bipolar motors are the simplest, so we will look at those first.Bipolar MotorsBipolar motors have two coils, each with a connection at each end, giving a total of four wires. It is possible to identify which wires are which, as the resistance between wires of different coils will be infinite. Generally, the connections are named in schematics, 1a and 1b being the two connections for one coil and 2a and 2b being for the other coil.To drive a bipolar stepper motor by one step, the coils have to be energized in a particular sequence. Consider just one coil; if 1a is held high and 1b is held low, the coil is said to conduct forwards. If 1a is at ground and 1b is high, then it conducts backwards. To drive the stepper motor, the coils have to be switched from conducting forwards to conducting backwards alternately.The input voltages to the four wires in order to drive the motor forward on step are shown in the table below. The coil polarities generated by this sequence are shown on the far right of the table.Seq.1a1b2a2bCoil 1 PolarityCoil 2 Polarity

1+-+-ForwardsForwards

2-++-BackwardsForwards

3-+-+BackwardsBackwards

4+--+ForwardsBackwards

There are many ways to produce this sequence, from using basic logic to incorporating the control into a micro-controller. Below is the circuit diagram for a motor controller made of simple logic components. Every time there is a low-to-high transition on the STEP input, the circuit advances the output on stage. The DIR input controls the direction of the step; if it is high, it steps one way, if it is low it steps the other way.

However, this circuit cannot drive a stepper motor by itself, as the logic outputs cannot supply nearly enough current. Some sort of amplification is needed. A dual H-Bridge arrangement can provide the necessary current and voltage reversal:

Recommended transistors for driving stepper motors are MOSFETs IRF510 or IRF530 (N-channel) and IRF9520 or IRF9530 (P-channel). These have built in clamping diodes, so the D1-D8 in the above circuit are unnecessary. If you are operating at high currents, it is wise to keep them for added protection. However any kind of power transistor (FET or BJT) should be suitable for this, as long as the current required to drive the motor does not exceed the rating of the transistor.Unipolar MotorsUnipolar motors have a more complex system of coil windings, but a simpler method of driving. Instead of having two connections, a unipolar motor coil has three - there is a centre tap on each coil. Unipolar motors have six leads therefore, in two groups of three. Sometimes there are just five, as the centre taps may be joined internally.To identify unmarked leads, first find the two triplets of wires - there will be no connection at all between the triplets. Then, find the centre tap - this is the wire with equal resistance between it and the other two wires in the triplet. If the centre taps are joined together internally, this will be more difficult, but by trial and error, it should be possible. Usually, however, the connection can be worked out by looking carefully as the wires as they come out of the motor - they will often be physically grouped into triplets or connected to a small PCB with the connections laid out logically.By holding this centre tap at a common voltage (probably ground) and switching the voltage used to power to motor from one end of the coil to the other, the direction of voltage flow can be reversed.

The windings in unipolar motors are bifilar, meaning there are two coils wound on top of each other - one connecting the "a" connector to the centre tap and one connecting the "b" connector to the centre tap. Because each half of the bifilar winding is as big as one coil in a bipolar motor, unipolar motors tend to be wider than bipolar motors.The advantage of unipolar motors is that there is no need for H-bridge drivers because all that needs to be done is to apply a high voltage to one of the connectors when the coil is to be energised - the other end does not need an opposite treatment, it can just be disconnected rather than having to be connected to the opposite power rail.The sequence of voltages applied to connectors 1a, 1b, 2a and 2b is the same as before, so the system of XOR gates and JK flip-flops (or PIC, etc) can be used for unipolar motors. The transistor driver circuit is simpler, however:

Any kind of power transistor (FET or BJT) should be suitable for this, as long as the current required to drive the motor does not exceed the rating of the transistor. Suggested transistors are IRF520, TIP31, TIP120, etc. Again, if the transistors have built in clamping diodes, the separate diodes are not needed, but will not do any damage if left in (suitable is any diode with voltage and forward current values similar to the transistor).If need be, unipolar motors can have the centre taps ignored and be used as bipolar motors. This will result in less torque as the coils are twice as long and so have twice the resistance and half the current. Alternatives, ignore one of the end connections and use one half of the winding. This should provide exactly the same characteristics as the motor when used normally. However, care should be taken to insulate the dangling wire as it will act like an auto-transformer and double the voltage applied to the lower half-coil.

Stepper MotorsA stepper motor is a motor controlled by a series of electromagnetic coils. The center shaft has a series of magnets mounted on it, and the coils surrounding the shaft are alternately given current or not, creating magnetic fields which repulse or attract the magnets on the shaft, causing the motor to rotate.This design allows for very precise control of the motor: by proper pulsing, it can be turned in very accurate steps of set degree increments (for example, two-degree increments, half-degree increments, etc.). They are used in printers, disk drives, and other devices where precise positioning of the motor is necessary.There are two basic types of stepper motors, unipolar steppers and bipolar steppers.Unipolar Stepper MotorsThe unipolar stepper motor has five or six wires and four coils (actually two coils divided by center connections on each coil). The center connections of the coils are tied together and used as the power connection. They are called unipolar steppers because power always comes in on this one pole.

Bipolar stepper motorsThe bipolar stepper motor usually has four wires coming out of it. Unlike unipolar steppers, bipolar steppers have no common center connection. They have two independent sets of coils instead. You can distinguish them from unipolar steppers by measuring the resistance between the wires. You should find two pairs of wires with equal resistance. If youve got the leads of your meter connected to two wires that are not connected (i.e. not attached to the same coil), you should see infinite resistance (or no continuity).Like other motors, stepper motors require more power than a microcontroller can give them, so youll need a separate power supply for it. Ideally youll know the voltage from the manufacturer, but if not, get a variable DC power supply, apply the minimum voltage (hopefully 3V or so), apply voltage across two wires of a coil (e.g. 1 to 2 or 3 to 4) and slowly raise the voltage until the motor is difficult to turn. It is possible to damage a motor this way, so dont go too far. Typical voltages for a stepper might be 5V, 9V, 12V, 24V. Higher than 24V is less common for small steppers, and frankly, above that level its best not to guess.To control the stepper, apply voltage to each of the coils in a specific sequence. The sequence would go like this:Stepwire 1wire 2wire 3wire 4

1Highlowhighlow

2lowhighhighlow

3lowhighlowhigh

4highlowlowhigh

To control a unipolar stepper, you use a Darlington Transistor Array. The stepping sequence is as shown above. Wires 5 and 6 are wired to the supply voltage.

To control a bipolar stepper motor, you give the coils current using to the same steps as for a unipolar stepper motor. However, instead of using four coils, you use the both poles of the two coils, and reverse the polarity of the current.The easiest way to reverse the polarity in the coils is to use a pair of H-bridges. The L293D dual H-bridge has two H-bridges in the chip, so it will work nicely for this purpose.

Once you have the motor stepping in one direction, stepping in the other direction is simply a matter of doing the steps in reverse order.Knowing the position is a matter of knowing how many degrees per step, and counting the steps and multiplying by that many degrees. So for examples, if you have a 1.8-degree stepper, and its turned 200 steps, then its turned 1.8 x 200 degrees, or 360 degrees, or one full revolution.Two-Wire ControlThanks to Sebastian Gassner for ideas on how to do this.In every step of the sequence, two wires are always set to opposite polarities. Because of this, its possible to control steppers with only two wires instead of four, with a slightly more complex circuit. The stepping sequence is the same as it is for the two middle wires of the sequence above:Stepwire 1wire 2

1lowhigh

2highhigh

3highlow

4lowlow

The circuits for two-wire stepping are as follows:Unipolar stepper two-wire circuit:

Biolar stepper two-wire circuit:

Programming the Microcontroller to Control a StepperBecause both unipolar and bipolar stepper motors are controlled by the same stepping sequence, we can use the same microcontroller code to control either one. In the code examples below, connect either the Darlington transistor array (for unipolar steppers) or the dual H-bridge (for bipolar steppers) to the pins of your microcontroller as described in each example. There is a switch attached to the microcontroller as well. When the switch is high, the motor turns one direction. When its low, it turns the other direction.The examples below use the 4-wire stepping sequence. A two-wire control program is shown for the Wiring/Arduino Stepper library only.Wire pins 9-12 of the BX-24 to inputs 1-4 of the Darlington transistor array, respectively. If youre using the PicBasic Pro code, its designed for a PIC 40-pin PIC such as the 16F877 or 18F452. Use pins PORTD.0 through PORTD.3, respectively. If youre using a smaller PIC, you can swap ports, as long as you use the first four pins of the port.Note that the wires read from left to right. Their numbers dont correspond with the bit positions. For example, PORTD.3 would be wire 1, PORTD.2 would be wire 2, PORTD.1 would be wire 3, and PORTD.0 would be wire 4. On the BX-24, pin 9 is wire 1, pin 10 is wire 2, and so forth.BX-24 code:dim motorStep(1 to 4) as bytedim thisStep as integer

Sub main() call delay(0.5) ' start program with a half-second delay

dim i as integer

' save values for the 4 possible states of the stepper motor leads ' in a 4-byte array. the stepMotor routine will step through ' these four states to move the motor. This is a way to set the ' value on four pins at once. The eight pins 5 through 12 are ' represented in memory as a byte called register.portc. We will set ' register.portc to each of the values of the array in order to set ' pins 9,10,11, and 12 at once with each step.

motorStep(0) = bx0000_1010 motorStep(1) = bx0000_0110 motorStep(2) = bx0000_0101 motorStep(3) = bx0000_1001

' set the last 4 pins of port C to output: register.ddrc = bx0000_1111

' set all the pins of port C low: register.portc = bx0000_0000

do ' move motor forward 100 steps. ' note: by doing a modulo operation on i (i mod 4), ' we can let i go as high as we want, and thisStep ' will equal 0,1,2,3,0,1,2,3, etc. until the end ' of the for-next loop.

for i = 1 to 100 thisStep = i mod 4 call stepMotor(thisStep) next

' move motor backward for i = 100 to 1 step -1 thisStep = i mod 4 call stepMotor(thisStep) next loop

End Sub

sub stepMotor(byref whatStep as integer) ' sets the value of the eight pins of port c to whatStep register.portc = motorStep(whatStep)

call delay (0.1) ' vary this delay as needed to make your stepper step.end subPicBasic Pro code:start: High PORTB.0

' set variables:x VAR BYTEsteps VAR WORDstepArray VAR BYTE(4)clear

TRISD = %11110000PORTD = 255input portb.4Pause 1000

stepArray[0] = %00001010stepArray[1] = %00000110stepArray[2] =%00000101stepArray[3] = %00001001

main: if portb.4 = 1 then steps = steps + 1 else steps = steps - 1 endif

portD = stepArray[steps //4] pause 2

GoTo mainpBasic (Basic Stamp 2) code:' set variables:x var bytestepper var nibsteps var word

' set pins 8 - 10 as outputs, using DIRS to do so:dirs.highbyte = %00001111

main: steps = 200 gosub clockStep pause 1000 gosub counterClockStep pause 1000goto main

clockStep: debug "counter" , cr for x = 0 to steps lookup x//4, [%1010,%1001,%0101,%0110], stepper outs.highbyte.lownib = stepper pause 2 nextreturn

counterclockStep: debug "clockwise", cr for x = 0 to steps lookup x//4, [%0110,%0101,%1001,%1010], stepper outs.highbyte.lownib = stepper pause 2 nextreturnWiring Code (for Arduino board):This example uses the Stepper library for Wiring/Arduino. It was tested using the 2-wire circuit. To change to the 4-wire circuit, just add two more motor pins, and change the line that initalizes the Stepper library like so:Stepper myStepper(motorSteps, motorPin1,motorPin2,motorPin3,motorPin4); /* Stepper Motor Controller language: Wiring/Arduino

This program drives a unipolar or bipolar stepper motor. The motor is attached to digital pins 8 and 9 of the Arduino.

The motor moves 100 steps in one direction, then 100 in the other.

Created 11 Mar. 2007 Modified 7 Apr. 2007 by Tom Igoe

*/

// define the pins that the motor is attached to. You can use// any digital I/O pins.

#include

#define motorSteps 200 // change this depending on the number of steps // per revolution of your motor#define motorPin1 8#define motorPin2 9#define ledPin 13

// initialize of the Stepper library:Stepper myStepper(motorSteps, motorPin1,motorPin2);

void setup() { // set the motor speed at 60 RPMS: myStepper.setSpeed(60);

// Initialize the Serial port: Serial.begin(9600);

// set up the LED pin: pinMode(ledPin, OUTPUT); // blink the LED: blink(3);}

void loop() { // Step forward 100 steps: Serial.println("Forward"); myStepper.step(100); delay(500);

// Step backward 100 steps: Serial.println("Backward"); myStepper.step(-100); delay(500);

}

// Blink the reset LED:void blink(int howManyTimes) { int i; for (i=0; i< howManyTimes; i++) { digitalWrite(ledPin, HIGH); delay(200); digitalWrite(ledPin, LOW); delay(200); }}For more on steppers, see the DC motor notes on this site.

A 4017 decade counter/divider driven from a low-frequency oscillator (Ul-a and Ul-b) is used to drive transistor switches to sequence the windings, as is needed. MOT1 is a 12-V stepper motor. R9 and RIO are selected for the motor`s current rating. A 3.3-Hz signal from Ul will cause the motor to run at 1 rpm,

The circuit shown in Fig. 62-15A is designed to drive a 15-V, two-phase, bipolar stepping motor, providing a bidirectional single level voltage across each winding at currents of up to 9.6 A. The circuit consists of two identical transistor bridge stages employing complementary npn and pnp devices. The transistor conduction sequence is determined by external control logic, and the circuit will interface directly with standard TTL.

Stepper motors are a subject that keeps recurring. This little circuit changes a clock signal (from a square wave generator) into signals with a 90-degree phase difference, which are required to drive the stepper motor windings. The price we pay for the simplicity is that the frequency is reduced by a factor of four. This isn`t really a problem, s visit page.

ince we just have to increase the input frequency to compensate. The timing diagram clearly shows that the counter outputs of the 4017 are combined using inverting OR gates to produce two square waves with a phase difference. This creates the correct sequence for powering the windings: the first winding is negative and the second positive, both windings are negative, the first winding is positive and the second negative, and finally both windings are positive. Internally, the 4017 has a...

NEC`s UPB1008K is a Silicon RFIC especially designed for handheld low power/low cost GPs receivers. The IC com- bines an LNA followed by a double-conversion RF/IF downconverter block and a PLL Frequency Synthesizer on one chip. The second IF Freqency is a pseudo- baseband signal into a on-chip 2-bit A/D converters The device CAN operate on a suppl visit page.

y voltage as low as 2. 7 V, and is a housed in a small 36 pin QFN (Quad, Flat, No-lead) package, resulting in a very low power consumption and reduced board space. NEC`s stringent quality assurance and test procedures en- sure the highest reliability and performance. By NEC Electronics Inc.

As you see in the circuit above the four pins `Controller pin 1`, 2, 3 and 4 will control the motion and direction of the stepper motor according to the step sequece programmed in the controller. As already discussed in case of L293D, Here in this circuit too the four pins `Controller pin 1`, 2, 3 and 4 will control the motion and direction of the ste visit page.

pper motor according to the step sequece sent by the controller. As we have studied that, Bi-polar stepper motors has 2 different coils. The step sequence for Bipolar stepper motor is same as that of unipolar stepper motors. The driving circuit for this require an H-Bridge as it allows the polarity of the power applied to be controlled independently. This can be done as shown in the figure below: Now we have seen the methods for connecting stepper motors with your microcontroller. So keeping...

A better way to make a stepper motor controller is to make a printed circuit board, and then simply drop the components in. After making the PCB, placing the components and soldering them hardly takes any time at all, in contrast to the proto board which took a ton of time to make. Here`s a picture of the first stepper motor controller I made in PCB-form: Here is the schematic for the PCB version of my visit page.

stepper motor controller. Notice that some improvements were made, such as the Schmitt trigger to help filter out noise. I want to thank Phil for his help when I was designing the PCB. He has a lot of experience with these stepper motor ICs and gave me a lot of advice. I also borrowed the idea of using a Schmitt trigger from him.BC517 Bipolar Stepper Motor Control Circuit Diagram. Features: Each winding can carry a positive current, A bipolar motor has two windings . visit page.

The following circuit shows about Stepper motor controller. This circuit based on the PIC16F84A IC. Features: transistor is used to drive the .. visit page.

Unipolar Stepper Motor Driver CircuitThis page presents a circuit for driving high-power unipolar stepper motors. Here you will find all the information needed to make your own. This circuit allows step-level control and can be easily modified for other modes of operation. Contents[hide] 1 What you need 2 Circuit Schematic and Photo 3 xPC Code 4 Alternative

What you need Power +5v (low power) +12v (high power) ICs L297 Stepper Controller Discrete Components (4x) 2N6045 NPN Darlington Power Transistor OR (1x) DS2003 (8x) 1N4001 Diodes (2x) 3.3kOhm Resistors Other PC104 or High-Level Controller 12v Unipolar Stepper Motor Circuit Schematic and PhotoThe L297 has several inputs that can be generated by a PC/104 stack or other controller. This circuit allows you to control each step, in full-step mode. Meaning: You can tell it to move one step in either direction (of course you can make it move fast and it will continuously rotate). The two inputs are a direction and a pulse. In the next section you will find a program to control this using xPC.

Here is the CircuitMaker file: Unipolar Stepper Driver Circuit

You may find the following diagrams useful when constructing this circuit:

xPC CodeThe program below is the simplest program for controlling the circuit above. The Pulse block dictates the speed of the stepper and the constant (1 or 0) sets the direction.

AlternativeAn alternative method for building this circuit is using the DS2003 darlington array. It is lower power, but will save some space and is easier to construct. The circuit is exactly the same as above, except the transistors and half the diodes are inside the IC.

Bipolar stepper motor driver circuitThis circuit (see Fig. 1.) produces the power to drive a bipolar stepper motor. The rotation speed and the rotation direction of the stepper motor can be changed.This circuit consists of two integrator circuits (A1, A3) and the amplifier (A2) connected in series. This connection provides necessary feedback to get the oscillation. The circuit is using the quad operational amplifier LM324. The capacitor C1 is used in the feedback network of the amplifier A2, this capacitor corrects the phase. It helps the stepper motor to start and to achieve synchronous rotation.

Stepper Motor Driver (74194)

Probably the simplest, reversible drive circuit is the H-Bridge. Some BEAMbots use H-bridge motor drivers; many more use an H-bridge variant of some sort. Here's a simple conceptual schematic: Image Based on the SN74LS194 - Bidirectional Universal Shift Register the circuit is designed to drive UNIPOLAR type stepper motors and provides only basic control functions - Forward, Reverse, Stop and Speed adjustment. The only step angle for this driver is the design step angle for the motor. The circuit is not complex and is cheaper than many dedicated driver/controller devices and the parts are easy to find.

This page links to UNIPOLAR and BIPOLAR stepper motor driver pages. The drivers are designed for simple requirement applications and are made with parts that are available from a variety of sources.

Both of the stepper drivers are use a 74194 - Bidirectional Universal Shift Register from the 74LS or 74HC - TTL families of logic devices to produce the stepping function. A diagram at the bottom of this page shows the difference between the 74194 - UNIPOLAR and BIPOLAR stepping pattern generation.

The UNIPOLAR driver uses a ULN2003 - eight segment, darlington IC as its output device.

The BIPOLAR driver uses a SN74410 - four segment, Quad - 1/2 H-Bridge IC as its output device.

These stepper drivers have only basic control functions: Forward, Reverse and Stop and Step rate adjustment. The calculated Step rate adjustment range of the drivers is 0.72 (1.39 sec) to 145 steps per second. (Lower and higher step rates are also possible.)

The only step angle for these drivers is the design step angle of the motor itself. 'Half-stepping' is not possible with either of the driver circuits.

What are Servo Motors?Servo refers to an error sensing feedback control which is used to correct the performance of a system. Servo or RC Servo Motors are DC motors equipped with a servo mechanism for precise control of angular position. The RC servo motors usually have a rotation limit from 90 to 180. Some servos also have rotation limit of 360 or more. But servos do not rotate continually. Their rotation is restricted in between the fixed angles.Where are Servos used?The Servo motors are used for precision positioning. They are used in robotic arms and legs, sensor scanners and in RC toys like RC helicopter, airplanes and cars.

Servo Motor Applications in RC AirplanesServo Motors in Robotic ArmsServo Motor manufacturersThere are four major manufacturers of servo motors: Futaba, Hitec, Airtronics and JR radios. Futaba and Hitec servos have nowadays dominated the market. Their servos are same except some interfacing differences like the wire colors, connector type, spline etc.

Servo Motor wiring and plugsThe Servo Motors come with three wires or leads. Two of these wires are to provide ground and positive supply to the servo DC motor. The third wire is for the control signal. These wires of a servo motor are color coded. The red wire is the DC supply lead and must be connected to a DC voltage supply in the range of 4.8 V to 6V. The black wire is to provide ground. The color for the third wire (to provide control signal) varies for different manufacturers. It can be yellow (in case of Hitec), white (in case of Futaba), brown etc.Futaba provides a J-type plug with an extra flange for proper connection of the servo. Hitec has an S-type connector. A Futaba connector can be used with a Hitec servo by clipping of the extra flange. Also a Hitec connector can be used with a Futaba servo just by filing off the extra width so that it fits in well.

Hitec splines have 24 teeth while Futaba splines are of 25 teeth. Therefore splines made for one servo type cannot be used with another. Spline is the place where a servo arm is connected. It is analogous to the shaft of a common DC motor.

Unlike DC motors, reversing the ground and positive supply connections does not change the direction (of rotation) of a servo. This may, in fact, damage the servo motor. That is why it is important to properly account for the order of wires in a servo motor.