Advertisement

Design Design How-To

How to implement a stepper motor driver for smart gauges–Part I

Advertisement

The world is digital today, and most information is represented in numbers. However, human nature is more “analog” and better represented in the old-fashioned way, using pointer gauges and bar graphs. Pointer gauges can be found in many applications. Automobiles, trains, and even modern aircraft dashboards emulate analog gauge functionality on control flat panel plasma or TFT screens. It does not look like good ol’ pointer gauges will disappear in the near future.

A number of techniques can be used to control a pointer gauge and stepper motors are one widely used method. In this article, we will explore:

  • Why a stepper motor may be the best approach to drive pointer gauges
  • Basics of stepper motor operation
  • How to use a single SoC to process sensor data and drive the stepper motor
  • Common challenges faced and how to overcome them
  • Firmware architecture for optimum response time and resource management

Pointer Gauges

Advertisement

A number of techniques can be used to control a pointer gauge. The most popular technique is to use a mechanical system, which consists of a turning coil mounted outside a two-pole permanent magnet. The applied DC current causes a magnetic force that rotates the coil and associated gauge pointer. Springs limit the coil rotation angle and the stable pointer rotation angle is in direct proportion to the coil current. Such a gauge can be equipped with an oil damper to suppress oscillations during coil angle setup and improve the system’s mechanical stability with respect to vibration. This method has limitations in the operational temperature range because oil viscosity changes with temperature, causing the gauge to be unstable amid vibrations.

Advertisement

Other gauges use a bimetallic plate with a heater. This type consumes a lot of current during operation and readings are dependent on environmental temperature. An alternative approach uses two quadrature-located coils to set the pointer position. In this system, the pointer rotation angle is determined in relation to the coil. A mechanical damper is still required to prevent pointer flicker due to mechanical vibrations at setup time.

Stepper Motor basics

An efficient way to control a pointer gauge is to use a stepper motor. A stepper motor is an electromechanical device that converts electrical pulses into discrete mechanical movements. The shaft or spindle of a stepper motor rotates in discrete step increments when electrical command pulses are applied to it in the proper sequence. The motors rotation has several direct relationships to these applied input pulses. The sequence of the applied pulses is directly related to the direction of motor shafts rotation. The speed of the motor shafts rotation is directly related to the frequency of the input pulses.

Stepper motors  are synchronous, dividing a full rotation into a number of steps. Unlike a DC motor that rotates continuously when a fixed DC voltage is applied to it, a step motor rotates in discrete step angles. Stepper motors,  therefore, are manufactured with steps per revolution of 12, 24, 72, 144, 180, and 200, resulting in stepping angles of 30, 15, 5, 2.5, 2, and 1.8 degrees per step.

Different stepper motor steps

FULL-STEP: In full-step operation, the motor steps through the normal step angle; e.g. 200 step/revolution motors take 1.8 steps compared to 0.9 steps while in half-step operation. There are two kinds of full-step modes. Single-phase full-step excitation is where the motor is operated with only one phase energized at a time. This mode should only be used where torque and speed performance are not important such as when the motor is operated at a fixed speed and load conditions are well defined. Problems with resonance can preclude operation at some speeds. This mode requires the least amount of power from the drive power supply of any of the excitation modes. With dual-phase full-step excitation, the motor operates with two phases energized at a time. This mode provides good torque and speed performance with a minimum of resonance problems. Dual excitation provides about 30 to 40 percent more torque than single excitation but requires twice the power from the drive power supply.

HALF-STEP: Half-step excitation is an alternate single- and dual-phase operation resulting in steps one half the normal step size. This mode provides twice the resolution. While the motor torque output varies on alternate steps, this is more than offset by the need to step through only half the angle. This offers almost complete freedom from resonance problems.

MICRO-STEP: In micro-step mode, a motor’s natural step angle can be divided into much smaller angles. For example, a standard 1.8 degree motor has 200 steps/revolution. If the motor is micro-stepped with a ‘divide-by-10’, then each micro-step would move the motor 0.18 degrees and there would be 2,000 steps/revolution. Typically, micro-step modes range from divide-by-10 to divide-by-256 (51,200 steps/rev for a 1.8 degree motor). The micro-steps are produced through proportional current in the two windings according to sine and cosine functions. This mode is only used where smoother motion or more resolution is required.

Advantages of using stepper motors

  • The motor has full torque at standstill (if the windings are energized).
  • Precise positioning and repeatability of movement since good stepper motors have an accuracy of 3 – 5% of a step and this error is noncumulative from one step to the next.
  • Excellent responsiveness to starting/stopping/reversing.
  • The motor’s response to digital input pulses provides open-loop control, making the motor simpler and less costly to control.
  • It is possible to achieve very low speed synchronous rotation with a load that is directly coupled to the shaft.
  • A wide range of rotational speeds can be realized since speed is proportional to the frequency of the input pulses.

Advantages of using stepper motors

The motor has full torque at standstill (if the windings are energized).

Precise positioning and repeatability of movement since good stepper motors have an accuracy of 3 – 5% of a step and this error is noncumulative from one step to the next.

Excellent responsiveness to starting/stopping/reversing.

The motor’s response to digital input pulses provides open-loop control, making the motor simpler and less costly to control.

It is possible to achieve very low speed synchronous rotation with a load that is directly coupled to the shaft.

A wide range of rotational speeds can be realized since speed is proportional to the frequency of the input pulses.

Stepper Motor Control System

Stepper motor control primarily consists of a sensor, SoC, and stepper motor. The sensor output is given to a SoC, which then drives the stepper motor based on the processed sensor output.

Sensor

Vehicle dashboards have a speedometer indicating the speed of vehicle and a fuel meter showing the fuel level. There are dedicated sensors for each of these – Vehicle Speed Sensor (VSS), Wheel Speed Sensor, fuel sensor, tire pressure monitoring sensor, etc. These sensors give out electrical signals based on a voltage, current, or frequency that is proportional to the level of the parameter, which the sensor is measuring.

SoC

The SoC is responsible for three main functions:

  • Measure the input data from sensor
  • Process the measured data
  • Drive the stepper motor

Measuring the input data from sensor involves:

Voltage Input– Voltage input measurements require just an A/D convertor in the SoC.

Challenges : Noisy A/D convertor output

Solution : The noise in the ADC output can be removed using software-based filters like IIR, average filter etc.ADC offset error

Solution : Ground the input of the A/D convertor and fetch the digital value. This digital value is used as the offset which is subtracted from the A/D convertor output value for each corresponding input voltage.Mismatch between sensor output and A/D convertor input range. This reduces the resolution of input measurement.

Solution : Modern day SoCs come with programmable gain amplifiers where the gain of the amplifiers can be adjusted to scale the sensor output voltage range to A/D converter input range.

Current Input:

This is similar to voltage input measurements. Connect a resistor of the appropriate value to the input of the A/D converter. The input current is converted to a voltage and is measured using the A/D converter.

Frequency Input: There are two classic methods for measuring frequency:

Counting Cycles for a Fixed Time

Figure 2 shows the topology for counting the number of cycles in a fixed period.

The counter’s value is latched at sample rate fsample and incremented every cycle of the input signal finput . The double latch enables the old count value to be subtracted from the new, resulting in a new accumulated value for each sample period.

This method of measuring the frequency has the advantage that the answer outputs at the constant sample rate fsample . The equation below gives the accumulated value for the given input and the sample frequencies:

Measuring Time for a Single Cycle

Figure 3 shows the topology for measuring the time of a single input cycle.

The counter is continuously incremented by a clock frequency fclock and latched by the input signal finput . The double latch enables the old count value to be subtracted from the new count value, resulting in the new accumulated value for each sample period.

This method has the advantage of updating at the rate of the input frequency finput . The equation below gives the accumulated value for the given input and the sample frequencies:

Challenges:

Both methods for measuring frequency have their particular advantages. Counting cycles is best for measuring higher frequencies while measuring a cycle’s period is better for lower frequencies. Both have the limitation that for any amount of decent resolution (i.e., small relative error), the input frequency range for any particular clock or sample frequencies is limited.

Solution : There are two solutions to tackle the above problem

One traditional solution is to support different ranges; that is, several selectable clocks or sample frequencies. This requires intelligence to determine when it is best to change range or measurement method.

A hybrid method could be used to measure the width of as many cycles that fit in a specified sample period.

Frequencies beyond the acceptable range due to noise

 

Solution : This can be avoided by adding a band pass filter

Process the measured data:

Now that the sensor input is measured, the angle by which the stepper motor should be driven needs to be calculated.The two main aspects in processing the measured signal are

Relationship between angle and input signal – By having the information of the input signal range and the total angle required, an interpolation is done to find out the angle required for a specific input level.

Minimum deviation check – When the difference between the calculated new angle and the previous angle is above a particular threshold, then the stepper motor is driven with the difference between the two angles. This threshold is provided in order to avoid small differences between the new angle and the old angle, which might be due to noise or an error in calculation.

Get Direction

If the new angle is greater than the previous angle, the motor should be rotated clockwise to move the gauge pointer in the forward direction and vice versa.
In Part II, we will cover details on motor driving techniques, including how to achieve smooth, noise-free responsiveness.

0 comments on “How to implement a stepper motor driver for smart gauges–Part I

Leave a Reply