Invistigation into closed loop stepper motor control systems
Chapter 1: Proposal
Closed loop motor controlling systems are important assets of todays industry as they have critical affects on the quality of the product or the operation they are responsible for. The general open loop control methods that have to receive electrical signals from a third party via an actuator for example so as to perform a particular action such as connecting a battery to a motor is not practically efficient at all because the controller cant tell you if the task was performed perfectly and it may also require human intervention to get correct results. The following block diagram represents a DC motor controller circuit used to control a motor of an old CNC machine
In open loop control, having no feedback is a problem and this problem has called the need to obtain more control efficiency and that was through letting the electronics handle a part in the control process. The closed loop controller is able to obtain more accurate results with very short response time and little/no need for human intervention. The rationale of this project is to design and build a closed loop motor speed controller and investigate the behaviour of its different inputs such as, speed, direction and torque. In order to do that, a means of gaining information about the rotation of the shaft such as the number of rpm (revolution per minute) or even the rotational angle of the shaft is needed and it this source of information is called feedback and that is because it conveys back information from the controlled actuator to the controller reporting on any errors occurring.
1.2 Aims of the project
The main aims of the project are:
- Investigate feedback devices used in closed loop motor control systems
- Test a feedback device on a closed loop stepper Motor control circuit Performing practical tests on the behavior of the circuit design and documenting all The results as well as drawing conclusions and recommendations for further work
An investigation will be carried on the above mentioned aims in order to establish good knowledge of the feedback devices behavior. The next step is build and test each bit of the controller that runs efficiently and also cheap to build.
The work is broken down into several chunks. Each chunk is allocated to the scheduled timetable the areas are:
1. Background research
- Control Theory
- Open Loop Theory
- Closed loop Theory
- Stepper Motors
- Why Microcontroller in Motor Control systems
2. Electric Motor Feedback Devices
- Incremental/Serial Encoders
- Hall effect sensors
- Resolver s
- Tachometer Generators
- Motor (stepper)
- Control Unit (Microcontroller)
- Motor Drive
- Logic Circuit
- Feedback Device ( rotary encoder)
- Circuit built Schematic
- PCB design Details
4. Implementation & Results
6. Future Work
Chapter 2: Prior research
2.1. Control theory
Control systems is very crucial and without it, there could be no computers, no regulated environments, no industry and manufacturing, no vehicles- to cut a long story short, no sense of technology. They are what comprise machinery and operate them to perform the wanted function. Control theory is a broad branch of engineering and maths and it involves dealing with the physical behavior of dynamical systems. The wanted output of a control system is referred to as the Reference and when one variable or more of one system have to follow a particular reference over time, a unit called controller is used to manipulate the inputs to the system to perform the wanted effect on the system output.
2.2. Open loop control systems
An open loop system is basically a system that is controller directly by an input signal pulses. The most basic components of this kind comprise only a motor and a control amplifier. What the amplifier does is that it receives a low level input and amplifies it to a level enough to drive the motor and perform the mechanical job.
The diagram below shows a basic block diagram of an open loop system, in this system the input is represented as a signal fed to the amplifier; the amplifier output is directly proportional to the input signal amplitude and its polarity determines the direction of shaft rotation, the amplifier then amplifies the signal and feed it to the motor. Nevertheless, the motor will not stop running the output shaft until the input signal is decreased to 0 or taken out.
The open loop system does not normally require more than an operator to control the direction and speed of the motor by changing the input signal, which can be controller either mechanically or electrically.
2.3. Closed loop control systems:
In open loop control, having no feedback is a problem and this problem has called the need to obtain more control efficiency and that was through letting the electronics handle a part in the control process. The closed loop controller is able to obtain more accurate results with very short response time and little/no need for human intervention. The rationale of this project is to design and build a closed loop motor speed controller and investigate the behaviour of its different inputs such as, speed, direction and torque. In order to do that, a means of gaining information about the rotation of the shaft such as the number of rpm (revolution per minute) or even the rotational angle of the shaft is needed and it this source of information is called feedback and that is because it conveys back information from the controlled actuator to the controller reporting on any errors occurring
A closed loop control system or what is also called a servo system is any system that is capable of the following functions:
- Accept any command that identifies a wanted result.
- Determine the current states of the system using a method of feedback
- Perform a comparison between the desired result and the current states and represent it as a difference or an error signal.
- Correct the error signal to change the present states to the desired value.
- Accept all the correction orders.
Although open loop control systems are also called servo systems in the Navy and other publication, they still lack one of the five basic necessities which is feedback. FIG2 shows a basic servo system (closed loop system).
3. CHAPTER 3: ELECTRIC MOTOR FEEDBACK DEVICES
Feedback devices found on motors used by industry come in a wide variety. Some of the more common devices would be:
- Incremental / serial encoders
- Hall Effect sensors
- Resolver s
- Tachometer Generators
These devices are utilized to send information back to the control about speed, direction of rotation, position, acceleration / deceleration rate, and the relative position of the rotor to the stator.
3.2. Incremental Encoders
They generate a group of square wave pulses that will be from 100 to several thousand pulses for each rotation of the shaft. These pulses will usually be labeled A, B, and Z. The A pulses are offset from the B pulses. They are offset so that the A pulse occurs first and then the B pulse in one rotation (normally forward) and the B pulse occurs first for the other rotation (usually reverse). The Z pulse will occur one time for each revolution. Thus the Z pulse is the indexing pulse or the start pulse.
Encoders are in use more and more and they are also designed to presume more feedback functions that were previously done by other devices for example tachometers, Hall Effect sensors, and photosensitive pick-ups. In addition to the A, B, and Z signals output by an encoder, also there are maybe commutating signal tracks attached to the encoder disc, which tend to replace sensors like the Hall Effect devices for commutation of signals. Also, optically generated cosine and sine signals are added to some items. This would allow an encoder to be used instead of a Resolver . These simulated cosine and sine signals could then be used for commutation, speed and direction of rotation alike the way a Resolver would be used. However, computer algorithms are preferred to be used to develop the commutating signals for the control to use. Basically, it is almost possible to have an encoder function for all of the feedback signals required by the control and combining all the needed output signals into one entity makes this device very cost effective.
3.2.1 Encoder operation
Incremental optical encoders operate on the principle of photoelectric scanning of the very fine lines on a rotating disc.
The photoelectric scanning of the disc and the processing electronics produce incremental output of pulses that when counted by the electronics of the drive will determine speed, direction, incremental movement, and total movement of the shaft to which it is connected.
3.2.2. Encoder disc
The FIG below is of a disc special for an incremental optical encoder. The outside track is solid excluding one set of lines that will create the Z and Z* output pulses. The next track has a lot of small lines from which the A, A*, B, and B* channels are generated. The (*) is used to indicate the corresponding signal (180 degrees out of phase).
The 3 tracks of the inside are used to generate the commutating signals which are com1, com2, com3, com4 etc. Additional tracks may be utilized to generate the complements of the signals above for instance A*, B*, and Z* or complementary signals special for commutation signals. In addition, these complimentary signals can be produced through the electronics embedded within the encoder. Basically, the outputs of any incremental optical encoder will typically be according to the table shown below:
The outputs that have asterisk designations are typically referred to as not. For example: A A and A* A not. These outputs that are referred to as not are the complement these outputs without the asterisk. This means they are always the opposite of one another. When A is high subsequently A* is low etc. These letter designations are popular, but there are no worldwide standards. There are other designations that differ from one manufacturer to another; however their functions may be the same. Good understanding of the function of each signal is very significant because the labels may differ between manufacturers. Moreover, there are typical tests that are carried out on incremental encoders to guarantee that they meet original specifications are and they are as follows:
- Use an oscilloscope to check the pulse stream waveforms
- Use an oscilloscope to check the relationship of the A to B signal
- Use an oscilloscope to check the Z signal
- Do a line using a digital pulse counter
- do a dependability check by run a continuous count rest at operating speed
- Determine the offset signal from signal A to B
- Determine the on time against the off time of each pulse
3.3. Serial pulse encoders
A Serial pulse encoder does not transmit the A, B, and Z pulses that the incremental encoder sends to the control. Hence, they must be tested in a different way. They perform the same functions as the incremental encoders perform. Nevertheless, instead of putting out incremental pulses, they communicate with the control unit through a serial word. This word, or string of binary characters which make this word up, is a string of characters that the control unit is programmed to understand. The same information communicates with the control unit as would be sent by an incremental encoder by this technique. It would do so through using only two wires instead of a separate wire for each and every signal. The construction of the serial encoder is very similar to the incremental encoder except that it has processing electronics built in that processes the information and then use it to communicate with the control. If you are to test these serial encoders separately from their control unit, then a computer interface that is programmed to interpret this serial data is required.
3.2.1 Serial encoder using an internal microprocessor
The serial encoder decreases the number of lines between the motor and the control unit. For controllers that are already computer based this form of communication is more logical. Besides, there can be additional information in the serial data stream for example a self-check bit, error checking, battery condition, etc. Some manufacturers maybe take advantage of encoders with a combination of both serial and incremental output signals.
3.4. HALL EFFECT SWITCHES
They are basically solid-state devices that change their output whenever placed in a magnetic field. The output changes state if the magnetic field is reversed. These sensors are mainly used to return a signal that keeps up a correspondence to the position of the permanent magnet rotor.
When they are placed in close proximity to the rotor, the signal from the sensors will tend to represent the position of the rotors magnets. Alternatively, the Hall Effect switches could be mounted external to the rotor if a separate permanent magnet rotor that has magnetic poles, which match the poles on the rotor, acts upon them.
These sensors have been widely used on permanent magnet servo motors for commutation feedback signals to the control. Most Hall Effect switches offer an open collector or sometimes an open drain sort of output. The Hall switch acts only as a switch and consequently does not output any voltage by itself. In order to derive a functional output signal, a pull-up resistor is added which is connected between the supply voltage and output of the Hall switch.
The controller for the motor usually supplies this pull-up resistor as well as the power supply voltage so as to generate the signal from the sensor. The value of this pull-up resistor is not very significant; however, it should be high resistance that enough and does not overload the output transistor. Typically 2k to 10k ohms is adequate.
Hall switches maybe directly run by the rotor magnets, however most manufacturers decide to put them away to protect them from the internal heat of the motor and place them in the enclosure at the end of the motor away from the output shaft. In this attachment it is possible to operate them by a small permanent magnet rotor which can be mounted on the shaft and it will have the exact same number of poles as the motor rotor. Another arrangement might use a disc that has cutaway openings and made of magnetic material, i.e. sheet metal.
This arrangement could have the number of openings that correspond to the motors number of poles. With the Hall Effect switch positioned in a sensor which has its own magnetic source, then the disc would be capable to interrupt the magnetic flux to cause the sensor output to equal the position of rotor magnets.
The graphical representation shown in FIG11 is the typical setup of Hall switch sensors used for sensing the position of the rotor of the permanent magnet. It is obvious from the graph that they are always spaced 120 electrical degrees from one another.
The physical spacing of the Hall sensors shown in the FIG above is only true for a two-pole motor. If this was a four-pole motor arrangement instead, the mechanical degree will be different, i.e. the physical spacing of the sensors will be sixty mechanical degrees and for a six pole motor physical spacing of the sensors will be forty mechanical degrees and for an eighth pole motor thirty mechanical degrees etc. Besides, the permanent magnets functioning on the Hall sensors shown in FIG11 are for a two-pole motor. These will also be altered to match the number of poles in the motor if the motor was to be having different number of poles.
If the sensors are photosensitive pickups, the number of unclear and clear areas will also match the number of poles in the motor. This could allow the output signal to keep up a correspondence to the back EMF of the stator winding. Basically, So long as the rotating part of the position sensing setup will precisely keep up a correspondence to the rotor and the fixed part will keep up a correspondence to the stator winding, the relative position of stator and rotor may be represented. FIG 12 demonstrates the electrical spacing of Hall sensors output which will represent the rotor position. In addition, they may be considered as outputting a signal that will represent or match the three counter generated voltages from the motor whenever the rotor is rotating.
From FIG12 it can be seen that the Hall Effect sensor switches will be high for 180 electrical degrees and low for another 180 electrical degrees. Also, they are displaced from one another by 120 electrical degrees. These signals can after that be mated to matching counter generated voltages that are generated in the stator windings which will be positive for 180 electrical degrees and negative for another 180 electrical degrees, as well as be spaced 120 electrical degrees apart. From all this, it can be understood that the signals from the Hall sensors may be matched up with the counter voltages from the stator windings. This would after that be the configuration that could be used for the control to suitably reverse the power to the motor. Shown below in FIG13 is the configuration of one signal of a position sensor that could come out of a Hall sensor or an encoder and one signal that might be gained from the generated counter voltage of the motor.
They are simply rotating transformers with a brushless rotor winding. The windings of the stator are two identical windings, which are 90 electrical degrees apart from one another and one of them is identified as the sine and the other as cosine. The angle of the rotor can be resolved from the output of the stator windings. Knowledge of the virtual angular position of the shaft lets this device be used for speed, direction, and commutation feedback. Sensors, such as Hall Effect, give switch points; however, do not have anything to specify position between switch points. A Resolver is an ideal choice for a control because of the fact that a Resolver indicates the position continuously. It is always designed to have sinusoidal power output from the control to the motor.
The work according to the configuration below:
- At 0 degrees, the sine output is 0 and the cosine output is high and-in-phase with the excitation voltage.
- At 90 degrees the cosine is 0 and the sine is high and-in-phase.
- At 180 degrees the sine is 0 and the cosine output high and-out-of-phase with the excitation voltage.
- At 270 degrees the cosine is 0 and the sine is high and-out-of-phase.
The Resolvers shaft angel can be determined by the mixture of voltage level and the phase relationship of the sine and cosine voltages to the excitation voltage for a full three hundred sixty electrical degrees of rotation. For a one-speed Resolver, three hundred sixty electrical degrees would also be three hundred sixty mechanical degrees. A two-speed Resolver would have three hundred sixty electrical degrees output for one hundred eighty mechanical degrees of rotation. This ratio of mechanical to electrical degrees would be true for three, four, or five speed Resolver s etc. There are no universal standards for the lead markings on a Resolver. Nevertheless, there are commonly found color codes used. These would be:
- Red Cosine high (S1)
- Black Cosine low (S3)
- Yellow Sine high (S2)
- Blue Sine low (S4)
- White/red Excitation high (R1)
- White/yellow or White/black Excitation low (R2)
Usual rotation would normally be CCW when looking at the shaft.
- Interchanging the sine leads will reverse rotation.
- Interchanging the cosine leads will reverse rotation and move 0 one hundred eighty-degrees
- Interchanging the excitation leads will move 0 one hundred eighty degrees.
- Interchanging the sine leads with the cosine leads will move 0 90 degrees and reverse rotation.
Resolvers are not as vulnerable to filthy, greasy, or hot surroundings like the electronic circuits in other devices may be. Devices such as encoders will be more susceptible to these conditions. Consequently the Resolver has been the feedback device of choice by many manufacturers. Many manufacturers will place a mark on the rotor winding and on the stator winding, when these marks are lined-up with each other, the Resolver will be at 0 angle. That is, the output of the sine winding will be 0 and the output of the cosine winding will be maximum and in phase with the excitation voltage. The sine winding and the cosine winding will be identical to one another in resistance. Although they are identical windings, they are also physically located in the stator to give 90 electrical degrees shift in their outputs. The excitation winding will have a different resistance than the sine or cosine. This normally makes it simple to recognize the excitation winding. If leads are not marked based on the normal standard mentioned above, the line positioned on the windings may be used to help find out which winding is which. For the reason that, as mentioned above, the sine winding will then have 0 voltage output when the Resolver is set on 0 degrees.
Another way to identify the sine and cosine windings is by exciting the rotor windings and taking measurements with a digital meter or oscilloscope. presuming that the lines on the rotor and stator show the 0 angle for the Resolver, that means by setting the Resolver with these lines physically aligned, the electrical conditions at 0 angle will be sine winding output because it would be very low and almost close to 0 and the cosine winding output will be high as well as in phase with the excitation. Typically, there are two variables that taken into consideration carefully when working with Resolver s and they are:
- The frequency of the voltage that is applied to the excitation winding: The input frequency range of these units is usually from two kilohertz to twenty kilohertz. But most commonly a frequency of five to ten kilohertz
- The magnitude of the voltage that is applied: The input voltage range of these units is usually from two to ten volts.
If the frequency is greatly different than the frequency for which the Resolver is designed to operate, then a phase shift between the excitation and the sine / cosine outputs may occur and that is shown in FIG15.
If the voltage magnitude is too high, then the waveform may be become distorted due to core saturation and that is shown in FIG16. These conditions may be observed by connecting a variable frequency supply to the excitation winding and viewing the waveforms of the input and output on a dual channel oscilloscope as the frequency and the amplitude are adjusted.
Waveform relationships between the counter voltages produced by a permanent magnet brushless servo motor and the rotating Resolver may look similar to the waveforms in FIG18. The generated counter voltage from the stator would depend upon the speed and number of poles. The sine voltage is a high frequency of two to twenty kilohertz that is modulated by the rotation of the shaft.
As the shaft passes through 0 degrees the sine voltage would be 0; at 90 degrees it would be high and in phase with the excitation; at one hundred eighty degrees the sine voltage would again be 0; at two hundred seventy degrees the sine would be high and out of phase with the excitation. This modulated high frequency sine waveform could be aligned with the generated counter voltage which also varies in magnitude and phase with the rotation of the shaft as shown here in FIG 18.
3.5. TACHOMETER GENERATORS:
Tachometer generators come in a variety of sizes and designs. It is important, to assure the proper operation of the motor when it is installed, that the tachometer operates properly.
Thus, the tachometer should be rotated in both directions and the following checks performed:
- The output value should be compared to the rated output at the test speed. Normally this would be done at 1000 RPM and the voltage at this speed compared to the rated voltage.
- The polarity and voltage level of the output of a DC tachometer should be noted for both directions of rotation of the tachometer. Reversed polarity of the tachometer may cause a runaway condition by the-motor.
- The ripple content and irregularities of a DC tachometer generator should be checked with an oscilloscope. This will indicate the condition of the tachometer commutator, brushes, and windings. Most good tachometers will have less than two percent ripple. Some have a one percent rating. Over two percent ripple could cause a problem. Example: For 10 VDC two percent equals 0.2 volt ripple. The ripple content should be checked with the oscilloscope in the AC coupled setting. By using AC coupling the DC voltage is blocked by the capacitive coupling and the ripple content may be measured in the milli-volt range giving the needed sensitivity. The over all DC voltage may then be measured using DC coupling on the oscilloscope. There are also some AC tachometers that have a three-phase AC output that are required to be aligned with the rotor position feedback devices.
The above filter may be used for looking at the output of a DC tachometer. The filter is not intended to mask or smooth any ripple from the generator. It is intended to filter electrical noise that may be present from the power being supplied to drive the motor that may be attached to the tachometer. This noise will be transferred through the common frame to the tachometer.
All three of the above oscilloscope waveforms were taken from the same DC tachometer generator
- FIG 21 is an unfiltered AC coupled waveform. Notice the noise on the waveform
- FIG 22 is the same waveform with a filter inserted between the tachometer and the oscilloscope.
- FIG 23 is the output of the tachometer with DC coupling on the input to the oscilloscope. Notice the waveform is offset from the 0 line by the amount of the DC voltage of the tachometer.
Chapter 4: circuit design
Open loop control means no feedback information regarding the position is needed. This eliminates the need for costly sensing and feedback devices, such as optical encoders. In this chapter, there will be a design and built of a stepper control circuit that has a feedback device to sense the motor position simply by keeping track of the number of input step pulses. The circuit is designed for testing purposes and to also see the difficulties involved in PIC driven stepper motor controller. The design is inspired by the Stepper Motor Micro-stepping with PIC18C452 AN822 microchip application note.
4.2. Stepper MOTOR
A stepper motor, as its name implies, moves one step each time, not like those conventional motors, which rotate continuously. If a stepper motor is commanded to move some particular number of steps, it spins incrementally the exact number of steps and then stops. Due to this basic nature of a stepper motor, it is commonly used in low cost, open loop position control systems.
4.3. CONTROL UNIT
The heart of the circuit and the control unit of the project is the PIC18F542, which is a High-Performance, Enhanced Flash Microcontroller with 10-Bit A/D. It has 40 pins. Which include a Parallel Slave Port (PSP) implemented, a number of Analogue-to-Digital (A/D) converter input channels, etc. An overview of features of this microcontroller is shown in Table below.
Ram, data EEPROM features and they are shown in FIG23, and FIG24 shows its pins diagram and what each one is called:
In addition to all the other features listed in the datasheet of this type of microcontrollers, one unique feature was one of the reasons to have chosen to use it in the design which is:
Two Capture/Compare/PWM (CCP) modules: CCP pins can be configured as:
- Capture input: capture is 16-bit, max. resolution 6.25 ns (TCY/16)
- Compare is 16-bit, max. resolution 100 ns (TCY)
- PWM output: PWM resolution is 1- to 10-bit, max. PWM freq@: 8-bit resolution = 156 kHz 10-bit resolution = 39 kHz 
It also has other special features which make it differ from the PIC18C family and they are as follows:
- 100,000 erase/write cycle Enhanced FLASH program memory typical
- 1,000,000 erase/write cycle Data EEPROM memory
- FLASH/Data EEPROM Retention: > 40 years
- Self-reprogrammable under software control
- Power-on Reset (POR), Power-up Timer (PWRT) and Oscillator Start-up Timer (OST)
- Watchdog Timer (WDT) with its own On-Chip RC Oscillator for reliable operation
- Programmable code protection
- Power saving SLEEP mode
- Selectable oscillator options including:
- 4X Phase Lock Loop (of primary oscillator)
- Secondary Oscillator (32 kHz) clock input
- Single supply 5V In-Circuit Serial Programming (ICSP) via two pins
- In-Circuit Debug (ICD) via two pins
4.4 Motor Driver
Motor drivers have been developed to power motors up and to segregate the other ICs from any problems. These circuits can be designed in a way that they could be totally separate boards, and can be used in various projects. A very common circuit for driving DC motors is called an H-bridge. It is named H bride because it looks like the capital letter 'H' on schematics. It can be really simple or very complex, depending upon the kind of component the H-bridge is implemented with such as bipolar transistors, MOSFET transistors, power MOSFETs, FET transistors or even chips. The TC4469 device is used in to control the stepper motor which is a four-output CMOS buffers/MOSFET driver with ability to provide 1.2A drive.
Unlike other MOSFET drivers, this device has two inputs for every output, these inputs are configured as logic gates AND/INV (TC4469).
The TC4469 driver can continuously source up to 250 mA into ground referenced loads. It is ideal for direct driving low current motors or driving MOSFETs in a H-bridge configuration for higher current motor drive. The fact of having the logic gates onboard the driver helps reduce component count in the designs. Fig27 shows how the motor driver is connected in the circuit.
4.5. LOGIC CIRCUIT
The principle of driving the motor is by generating PWM signal from the PIC18F452. The motor driver needs 4 PWM signals which allow driving motor in both directions. The fact that the PIC has only 2 PWM pins calls for the need to use logic circuit to invert one of them twice to produce the other two complement signals. 74HC04 and 74HC08 IC chips are used in the design.
Style and Policy Manual For Theses and Dissertations. Revised ed. Seattle: University of Washington Graduate School, 1994
Hacker, Diana. A Writers Reference. 2nd ed. Boston: Bedford Books of St. Martins Press, 1992
 PIC18F452 Datasheet
 Microchip PIC18F452 Datasheet