Making Analog Data Digital
Understand how to create digital representations of analog systems for control system applications.
Editors note: Last November, we published an article , Designing Your Own Control System, that offered a link to a more detailed work on the design concepts of industrial control systems. We warned that it tackled some issues that might make you dust off your math textbooks from engineering school. The full-length version of article was heavily downloaded, which suggests that you readers are not afraid of a challenge.
This month we have another offering in the same vein, a discussion of how analog data taken from process and discrete field devices and sensors is converted into a digital representation for use in a control system. The article shows how a digital controller can be created from an analog (or continuous) model, which is especially useful when a processor is used to control an analog system. While there are many methods available to convert between analog and digital systems, the author concentrates on Tustin’s method and hold equivalence as two that work especially well. These particular methods are evaluated to show how they compare with an analog system, and how they can be used as an introduction to the subject or applied to advanced systems.
Digital Representations of Analog systems for Control System Applications is a condensed (12-page) tutorial that should help expand your understanding of critical concepts that underlie most process and discrete control systems.
The author, Peter Way, is president of VentiMar, LLC, a consulting group that helps companies develop and market high-tech products. He also consults in control system projects. Reach him at firstname.lastname@example.org . The following is an excerpt from the tutorial.
An excerpt from the introduction:
This tutorial shows how digital controllers can be created from an analog (or continuous) model. This is especially useful when a processor is used to control an analog system. Note that this process works equally well for converting filters or compensators from analog to digital form.
Many methods are available to convert between analog and digital systems. I have tried several others and selected two approaches that model the analog system well: Tustin’s Method and Hold Equivalence . These are evaluated to show how they compare with an analog system. These methods were tedious to implement in the past, and are now easily managed by tools for doing algebra symbolically, or solving the equations in matrix form. This makes the job much easier and more accurate.
Just a modest amount of theory is presented to help with understanding the methods. If you want to see the full details and derivations of formulas, consult a digital control textbook. This application note is somewhat introductory, but the techniques can also be applied for advanced solutions.
Processors sample analog (continuous) system signals and convert the values to numbers they can work with. Typically an Analog to Digital converter (ADC) takes a reading of the signal at each time T (the sample time). A series of these values are held in the processor.
Another common input device is a rotary or linear encoder. In this case pulses are counted as the encoder moves. At each time T, the present count is added/subtracted to get a new position depending on direction of rotation. Velocity is proportional to the number of counts received during each time T. Once the desired calculations are made in the processor, the numbers are reconstructed into a signal that the rest of the system can use.
If an analog output is desired, the simplest solution is to output the current value through a Digital to Analog converter (DAC) and hold it until a new one arrives. This implies a Zero Order Hold (ZOH) and is the most common reconstructor. Another popular way to reconstruct the signal is through a Pulse Width Modulator (PWM). This modulator makes a constant frequency square wave and varies the width of the pulse. The benefit of a PWM is that it can efficiently drive power transistors to move motors or actuators. Many processors have built-in PWM and DAC outputs and ADC converters. SimApp4 is a simulation program that was used to make all the models in this paper.
There are two main options for designing a digital controller:
Method 1 : Start by designing an analog controller. Then convert it to digital form including the effects of sampling the analog plant and holding the output at the DAC. This approach is most intuitive for the designer since you are working in the familiar s-domain (Laplace domain). The key is to make a digital equivalent of the controller that really represents the analog controller well.
Method 2 : Start by converting the plant, DAC/ZOH, and ADC to an effective digital form. Then design a digital controller that makes this system perform as desired. This method may have some advantages when the plant contains a delay element since this is naturally modeled in digital form. This model is not as intuitive since the dynamic specifications for the system need to be defined in the discrete domain (z-domain). This usually begins with the s-domain specifications and then the poles/zeros of the solution are mapped to the z-domain.
We will assume Method 1 in this application note. You may have done a compensator design, either as a PID or a more sophisticated one. Since compensators are essentially filters, the discussion will show how to convert an example analog filter to a digital one. Then the whole system can be simulated to ensure the right results are achieved.
Discrete equivalents—the Z transform is simpler than it would seem
The job of the processor is to read in inputs (at the ADC) at each sample time T: u 0 , u 1 … u n -1 , u n , and then to convert them to outputs over time (to the DAC): y 0 , y 1 … y n -1 , y n . The subscript n represents the current time and n -1, n -2, etc. others happen earlier at time intervals T. The processor only keeps the last few values required to make the calculation of the output.
In the processor we may want to make an output from the inputs by a difference equation like this, where a and b values are constants:
y n = a 1 y n -1 + a 2 y n -2 + a 3 y n -3 …+ b 0 u n + b 1 u n -1 + b 2 u n -2 …
This is a general form for a digital filter with a single input/output. It is in the form of an equation that can be easily implemented in a processor. Note that if we make the a values 0, and b n = b n -1 = b n -2 = 1/3, the result is a moving average of three values ( a very simple digital filter).
Two important points for implementation:
1. The difference equation is assumed to be calculated instantly when the timer goes off and u n is measured. The output y n goes immediately to the DAC. Naturally the calculations take some time. You can precalculate items that depend on past values during the last time sample and then just add the new information b 0 u n once the timer interrupt occurs. If the calculation delay T d between measurement and output is significant, you can model an extra small delay e - sTd delay into the model of the analog plant being controlled.
2. Many of the calculations involved in digital control should be done with floating point. While integer or byte-level math can be done, it can take a lot of effort to implement the equations for numerical accuracy. Why not use a faster processor if possible?
Understanding the Z transform
If you remember the basics of Laplace transforms (frequency domain), a delay of time T is represented by multiplication with e - sT . Please review a control system text if you are interested in knowing how this works. So, a way of dealing with the inputs and outputs above and providing the correct relationship between them is a number of fixed time T delays. Note that u 0 is T earlier than u 1 and so on to higher subscripts. A general way to say it: u n - k is kT earlier than u n ,. If the current time is u n the delay from a previous time is written in the frequency domain is: e -skT . This is the same as ( e -sT ) k . Now to simplify this notation, we will use: z -1= e -sT . (Who wants to write that exponential all the time?) e -skT is then equal to z -k . You will also see z = e sT in books since this is mathematically correct (but would require you to have time machine to travel to the future). So the equations always have to be rearranged so that the exponents are negative or 0 before implementation.
View this article online at www.controleng.com/file/10409-Digital_Representation_of_Analog_Systems.pdf
- Events & Awards
- Magazine Archives
- Oil & Gas Engineering
- Salary Survey
- Digital Reports
- Survey Prize Winners
Annual Salary Survey
Before the calendar turned, 2016 already had the makings of a pivotal year for manufacturing, and for the world.
There were the big events for the year, including the United States as Partner Country at Hannover Messe in April and the 2016 International Manufacturing Technology Show in Chicago in September. There's also the matter of the U.S. presidential elections in November, which promise to shape policy in manufacturing for years to come.
But the year started with global economic turmoil, as a slowdown in Chinese manufacturing triggered a worldwide stock hiccup that sent values plummeting. The continued plunge in world oil prices has resulted in a slowdown in exploration and, by extension, the manufacture of exploration equipment.
Read more: 2015 Salary Survey