ip tracker

Monday, June 9, 2008

PLC COMMUNICATION

COMMUNICATIONSThere are several methods to communicate between a PLC and a programmer or even between two PLCs.Communications between a PLC and a programmer (PC or Hand held) are provided by the makers and you only have to plug in a cable from your PC to the programming port on the PLC. This communication can be RS232; RS485 or TTY.Communications between two PLCs can be carried out by dedicated links supplied/programmed by the makers (RS232 etc) or via outputs from one PLC to the inputs on another PLC. This direct link method of communication can be as simple as, if an output on the first PLC is on then the corresponding input on the second PLC will be on and then this input is used within the program on the second PLC. If a word of input/outputs (16 bits) are used then numerical data can be transferred from one PLC to the other (refer back to the section on numbering systems).There are many other methods of communication between PLCs and also from PLC to PC. Please refer to the manuals supplied with the PLC that you are using for full details on communications.

integral controller

What Is An Integral Control System?Often control systems are designed using Integral Control. In this control method, the control systems acts in a way that the control effort is proportional to the integral of the error. You should have studied proportional control before tackling this lesson. A proportional control system is shown in the block diagram below.The proportional controller amplifies the error and applies a control effort to the system that is proportional to the error. In integral control, the control effort is proportional to the integral so the controller now needs to be an integrator, and it will have a transfer function of Ki/s - not just a gain, Kp.What Do You Need To Get From This Lesson?This is a short lesson. The goals are simple. Given a closed loop, integral control system,Know that the SSE is zero - exactly! Be able to explain why the SSE can be zero even though there is no input to the integrator.What Is Integral Control? - Some BackgroundIntegral control is what you have when the signal driving the controlled system is derived by integrating the error in the system. The transfer function of the controller is Kp/s, if you think in terms of transfer functions and Laplace transforms. That is what is shown in the diagram below.That's the general outline, but to understand how integral control really works, it helps to understand exactly what an integral is. Let's consider that a while.To use integral control you really need to understand what an integrator is and what an integral is. Let's get back to basics. An integral is really the area under a curve. Let's assume that the independent variable is time, t. Then as time goes on the area accumulates. In math courses when they talk about integration, they picture it as the limit of a process of taking small incremental areas - shown below - and letting the interval, T, shrink to zero. In digital integration, that visualization process is important. Here is an approximation to an integral that is a sum of areas under the curve of the function being integrated.If the integral starts at zero, then the integral is just the area under the curve. Let's look at some implications of that.If the input goes to zero, then the integral stops changing and just has whatever value it had just before the input became zero.The integral can change in either direction as the signal goes positive and negative. Negative area can subtract from positive area, lowering the value of an integral. The first point here is very important because it has implications for the way that the error in the system behaves. The second point has strong implications for overall system behavior, particularly for understanding overshoot in the output of an integral control system.Using Integral ControlLet's look at the structure of a system to control liquid level in a tank. The input is some desired level. The output level is measured and fed back to be compared to the input, generating an error signal. We integrate that error signal to get the voltage to be applied to the pump.Consider this question. What happens when the error signal is zero?The answer to this question is that maybe nothing happens. If the error signal is zero, then the output of the integrator stays constant! That means that the voltage applied to the pump stays constant, and if everything is at steady state, the liquid level in the tank stays constant.If the output level is the desired level, this is a desirable steady state. Let's review this situation.If output level matches the desired level, the error is zero.Because the error is zero, the integrator output does not change.Because the integrator output doesn't change, if the rest of the system is at steady state nothing else changes. All is copasetic! This sounds too good to be true. What could possibly go wrong? Well there could be at least two problemsThe system has to reach steady state. You'll need to learn something about system dynamics to ensure stability. If the system starts to oscillate wildly, then it may not reach a steady state, so the zero state state behavior is never really seen.Although the error goes to zero, no guarantees about speed of response are given. This has been a very cursory look at integral control. You'll need to get into the details to really make it work. The important point you need to take from this lesson is this.If you can design a stable integral control system, the steady state error (SSE) will be zero - exactly!The guarantee of zero steady state error may be important in a system.Questions To Be Answered About Integral ControlYou are a long way from a complete understanding of integral control - but you've made a good start. There are lots of unanswered questions about integral control, and we'll give you some questions and links here and on the next page.Many of the questions revolve around system dynamics. You need to be sure that you can predict how a system behaves.Does the system oscillate a lot before it gets to steady state?How long does the system take to get to steady state? What do we mean by "How long?"? Other questions revolve around how you can implement integral control. There are two basic ways to implement integral control, and both are widely used.Use an analog integrator. Here's the circuit, and you may have seen it already.The analog integrator can be used when the rest of the control system is implemented with analog components.Another option is:Use digital integration. You may want to check the introductory lesson on digital integration and implementation of integral control.If you want to use digital integration, you'll need to learn about digital integration algorithms, and you'll need to be conversant with sampled systems, and particularly Z-transform methods.SummaryThe main thing to take from this lesson is that integral control will produce zero SSE. There's not if's, and's or but's about it. It will be zero. When you think about that, you may wonder why it isn't always used. As with most things in life, there are advantages and disadvantages. The disadvantage is that integral control might produce a closed loop system with significantly slower response times. That's a subject that will take some knowledge about system response times and how they are related to the system you are controlling. You'll need some knowledge about root locus. Using the root locus you can get a handle on response times and how they are related to the parameters of the controlled system, and to the gain you choose for the integral controller.

proportional controller

Proportional controllerA proportional control system is a type of linear feedback control system. Two classic mechanical examples are the toilet bowl float proportioning valve and the fly-ball governor.The proportional control system is more complex than an on-off control system like a thermostat, but simpler than a proportional-integral-derivative (PID) control system used in something like an automobile cruise control.An on-off control is like driving a car by applying either full power or no power and varying the duty cycle, to control speed. The power would be on until the target speed is reached, and then the power would be removed, so the car reduces speed. When the speed falls below the target, with a certain hysteresis, full power would again be applied. It can be seen that this looks like pulse-width modulation, but would result in poor control.Proportional control is how most drivers control the speed of a car. If the car is at target speed and the speed increases slightly, the power is reduced slightly, or in proportion to the error (the actual versus target speed), so that the car reduces speed gradually and reaches the target point with very little, if any, "overshoot", so the result is much smoother control than on-off control.Further refinements like PID control would help compensate for additional variables like hills, where the amount of power needed for a given speed change would vary, which would be accounted for by the integral function of the PID control.

temperature regulator

SAMSON makes its documentation and product information available in different languages. Available language versions can be viewed by clicking the desired two-letter language code given in square brackets. The language codes comply with the international ISO 639 standard. The ISO codes for the relevant languages are as follows:CS = CzechDA = DanishDE = GermanEN = EnglishES = SpanishFI = FinnishFR = FrenchHU = HungarianIT = ItalianJA = JapaneseNL = DutchPL = PolishPT = PortugueseRU = RussianSK = SlovakSL = SlovenianSV = SwedishTR = TurkishZH = ChineseAdditional language codes differing from ISO:BR = special Portuguese version for Brazil CA = special English version for Canada and the USLanguagesDocumentation and product information are available in PDF format. The free Adobe Acrobat Reader is required to view the documents.When viewing PDF documents directly in your web browser, it may happen that only an empty page is displayed. This may be due to the web server having problems handling the browser's Acrobat Reader plug-in. This problem may occur depending on the Acrobat Reader version installed on your system.In such cases, it is recommended to download the file and view it directly in Acrobat Reader.To download a file, right-click the associated link and select "Save Target As" (Internet Explorer) from the context-sensitive menu. Save the file to your system and open it in Acrobat Reader.PDF formatThe spare parts lists contain information in five languages.Western Europe:English, French, German, Italian, and Spanish.Eastern Europe:Russian, further languages in preparation.Spare parts listsAll dimensional drawings are available in vector format as DXF files, compressed to ZIP archives. Unpack the ZIP files to view the drawings. A suitable software is required to view or further process the DXF files.Dimensional drawingsThe × mark displayed next to certain documents indicates that the associated product is no longer available as it has been removed from the SAMSON product range. If you require a replacement device, please contact your local SAMSON subsidiary for an alternative solution.

integral controller

What Is An Integral Control System? Often control systems are designed using Integral Control. In this control method, the control systems acts in a way that the control effort is proportional to the integral of the error. You should have studied proportional control before tackling this lesson. A proportional control system is shown in the block diagram below. The proportional controller amplifies the error and applies a control effort to the system that is proportional to the error. In integral control, the control effort is proportional to the integral so the controller now needs to be an integrator, and it will have a transfer function of Ki/s - not just a gain, Kp. --------------------------------------------------------------------------------What Do You Need To Get From This Lesson? This is a short lesson. The goals are simple. Given a closed loop, integral control system, Know that the SSE is zero - exactly! Be able to explain why the SSE can be zero even though there is no input to the integrator.--------------------------------------------------------------------------------What Is Integral Control? - Some Background Integral control is what you have when the signal driving the controlled system is derived by integrating the error in the system. The transfer function of the controller is Kp/s, if you think in terms of transfer functions and Laplace transforms. That is what is shown in the diagram below. That's the general outline, but to understand how integral control really works, it helps to understand exactly what an integral is. Let's consider that a while. To use integral control you really need to understand what an integrator is and what an integral is. Let's get back to basics. An integral is really the area under a curve. Let's assume that the independent variable is time, t. Then as time goes on the area accumulates. In math courses when they talk about integration, they picture it as the limit of a process of taking small incremental areas - shown below - and letting the interval, T, shrink to zero. In digital integration, that visualization process is important. Here is an approximation to an integral that is a sum of areas under the curve of the function being integrated. If the integral starts at zero, then the integral is just the area under the curve. Let's look at some implications of that. If the input goes to zero, then the integral stops changing and just has whatever value it had just before the input became zero. The integral can change in either direction as the signal goes positive and negative. Negative area can subtract from positive area, lowering the value of an integral. The first point here is very important because it has implications for the way that the error in the system behaves. The second point has strong implications for overall system behavior, particularly for understanding overshoot in the output of an integral control system. --------------------------------------------------------------------------------Using Integral Control Let's look at the structure of a system to control liquid level in a tank. The input is some desired level. The output level is measured and fed back to be compared to the input, generating an error signal. We integrate that error signal to get the voltage to be applied to the pump. Consider this question. What happens when the error signal is zero? The answer to this question is that maybe nothing happens. If the error signal is zero, then the output of the integrator stays constant! That means that the voltage applied to the pump stays constant, and if everything is at steady state, the liquid level in the tank stays constant. If the output level is the desired level, this is a desirable steady state. Let's review this situation. If output level matches the desired level, the error is zero. Because the error is zero, the integrator output does not change. Because the integrator output doesn't change, if the rest of the system is at steady state nothing else changes. All is copasetic! This sounds too good to be true. What could possibly go wrong? Well there could be at least two problems The system has to reach steady state. You'll need to learn something about system dynamics to ensure stability. If the system starts to oscillate wildly, then it may not reach a steady state, so the zero state state behavior is never really seen. Although the error goes to zero, no guarantees about speed of response are given. This has been a very cursory look at integral control. You'll need to get into the details to really make it work. The important point you need to take from this lesson is this. If you can design a stable integral control system, the steady state error (SSE) will be zero - exactly! The guarantee of zero steady state error may be important in a system. --------------------------------------------------------------------------------Questions To Be Answered About Integral Control You are a long way from a complete understanding of integral control - but you've made a good start. There are lots of unanswered questions about integral control, and we'll give you some questions and links here and on the next page. Many of the questions revolve around system dynamics. You need to be sure that you can predict how a system behaves. Does the system oscillate a lot before it gets to steady state? How long does the system take to get to steady state? What do we mean by "How long?"? Other questions revolve around how you can implement integral control. There are two basic ways to implement integral control, and both are widely used. Use an analog integrator. Here's the circuit, and you may have seen it already. The analog integrator can be used when the rest of the control system is implemented with analog components. Another option is: Use digital integration. You may want to check the introductory lesson on digital integration and implementation of integral control. If you want to use digital integration, you'll need to learn about digital integration algorithms, and you'll need to be conversant with sampled systems, and particularly Z-transform methods. --------------------------------------------------------------------------------Summary The main thing to take from this lesson is that integral control will produce zero SSE. There's not if's, and's or but's about it. It will be zero. When you think about that, you may wonder why it isn't always used. As with most things in life, there are advantages and disadvantages. The disadvantage is that integral control might produce a closed loop system with significantly slower response times. That's a subject that will take some knowledge about system response times and how they are related to the system you are controlling. You'll need some knowledge about root locus. Using the root locus you can get a handle on response times and how they are related to the parameters of the controlled system, and to the gain you choose for the integral controller. --------------------------------------------------------------------------------Problems --------------------------------------------------------------------------------Links To Related Lessons Other Introductory Lessons General Introduction Introduction To Proportional Control Introduction To Integral Control Introduction To Block Diagram Representations More Advanced Material On Integral Control Integral Control Implementing Integral Control --------------------------------------------------------------------------------Send us your comments on these lessons.

Derivative Control

Derivative ControlWith derivative action, the controller output is proportional to the rate of change of the measurement or error. Some manufacturers use the term rate or pre-act instead of derivative. Derivative, rate and pre-act are the same thing. The controller output is calculated by the rate of change of the error with time.controller output = Td*d(error)/dt = Td*d(SP - PV)/dtwhere the parameter Td is called derivative time. Derivative control is mathematically the opposite of integral action, but while we might have an integral-only controller, we would never have a derivative-only controller. The reason for this is that derivative control only knows the error is changing. It does not know what the setpoint actually is.Derivative action has the potential to improve performance when sudden changes in measured variable occur, but is should be used with care. It is mostly a matter of using enough, not too much.Derivative Gain LimitationIn most commercial processes sudden changes in process output may appear. In most casesa sudden change in the slope of such a process output cannot be avoided at all times. Using such a process output in controllers with pure derivative action, would lead to unwanted steps in the controller output. Moreover, high frequency noise in the measured signals may lead to unwanted large outputs of the controller.To prevent this unwanted effect, the derivative action can be filtered by a first-order system with time constant Td/N.This approximation acts as a derivative for low-frequency signal components. The gain, however, is limited to K*N. This means that high-frequency measurement noise is amplified at most by a factor KN. This is why the parameter N is called the derivative gain limitation. Typical values of N are 8 to 20. Sometimes the reciprocal value of N is used, mostly with the name beta (beta = 1/N).

smart transmitter

major difference between electronic and pneumatic transmission systems is the time required for signal transmission. In an electronic system there are no moving parts, only the state of the signal changes. This change occurs with virtually no time lost. Signal Transmission for Electronic and Pneumatic Signals As we stated previously, mechanical movement takes place whenever any pneumatic process signal changes. When devices move mechanically, time is lost. In addition, pneumatic systems, because they contain moving parts, are higher maintenance and subject to vibration, as well as rotational or gravitational mounting problems. However, pneumatic systems are still in place in many plants because they are safer than electrical systems in certain environments containing potentially explosive atmospheres. 4.1 Transmission lag Pneumatic Transmission Signal Lag The figure above shows the time lost with a pneumatic system. This figure represents a system using 3/16 ID tubing for the transmission line. As shown at the bottom of the graphic, in short distances, the effect of time is small. Under 200 feet, a signal can change 15 psi to 3 psi (the span of a pneumatic device) in roughly 0.4 seconds or less. This lost time represents the time needed to make up the air volume difference in the line (either replacing or releasing the air volume). A lag of 0.4 seconds is not critical, but as the distance of the signal line increases, so does the lag. At 400 feet, the lag time rises to about 1.3 seconds. At 1000 feet, the time is nearly 7 seconds -- in some processes, a critical period of time. Note: This time measurement represents the time required for the signal to travel from the sensing device to the controlling device. If there is a change and the controller responds to it immediately, the amount must be doubled for the signal transmission to reach a final control device. Pneumatic devices are best used for safety applications, simplicity, and for valve actuators, always in applications where the line length is kept under 100 feet; otherwise electronic signals should be used. 4.2 Transmitter gain A transmitter's gain, that is the ratio of the output of the transmitter to the input signal, is constant regardless of its output. In other words, an electronic transmitter's gain will remain constant whether it's output is 0% of span (4 mA) or 100% of span (20 mA) or any other point between those extremes. Transmitter Gain for an Electronic Transmitter 4.3 Smart Transmitters So far, the discussion has centered around electronic and pneumatic transmitters. The input and output of both of these types of transmitters is an analog signal -- either a mA current or air pressure, both of which are continuously variable. There is another kind of transmitter -- the "smart" transmitter. Smart Transmitter Components and Function The figure above illustrates functions of a smart transmitter. They can convert analog signals to digital signals (A/D), making communication swift and easy and can even send both analog and digital signals at the same time as denoted by D/A. A smart transmitter has a number of other capabilities as well. For instance, inputs can be varied, as denoted by A/D. If a temperature transmitter is a smart transmitter, it will accept millivolt signals from thermocouples and resistance signals from resistance temperature devices (RTDs), and thermistors. Components of the smart transmitter are illustrated in the lower figure. The transmitter is built into a housing about the size of a softball as seen on the lower left. The controller takes the output signal from the transmitter and sends it back to the final control element. The communicator is shown on the right. The communicator is a hand-held interface device that allows digital "instructions" to be delivered to the smart transmitters. Testing, configuring , and supply or acquiring data are all accomplished through the communicator. The communicator has a display that lets the technician see the input or output information. The communicator can be connected directly to the smart transmitter, or in parallel any where on the loop. 4.4 Smart transmitter microprocessor-based features Smart transmitters also have the following features: Configuration Re-ranging Characteristics Signal conditioning Self-diagnosis 4.4.1 Configuration Smart transmitters can be configured to meet the demands of the process in which they are used. For example, the same transmitter can be set up to read almost any range or type of thermocouple, RTD, or thermistor. Because of this, they reduce the need for a large number of specific replacement devices. 4.4.2 Re-ranging The range that the smart transmitter functions under can be easily changed from a remote location, for example by the technician in a control room. The technician or the operator has access to any smart device in the loop and does not even have to be at the transmitter to perform the change. The operator does need to use a communicator, however. A communicator allows the operator to interface with the smart transmitter. The communicator could be a PC, a programmable logic controller (PLC), or a hand-held device. The type of communicator depends on the manufacturer. Re-ranging is simple with the smart transmitter. For instance, using a communicator, the operator can change from a 100 ohm RTD to a type-J thermocouple just by reprogramming the transmitter. The transmitter responds immediately and changes from measuring resistance to measuring millivoltage. There is a wide range of inputs that a smart transmitter will accept. For instance, with pressure units, the operator can determine ahead of time whether to use inches of water, inches of mercury, psi, bars, millibars, pascals, or kilopascals. 4.4.3 Characteristics Another characteristic of a smart transmitter is its ability to act as a stand-alone transmitter. In such a capacity, it sends the output signal to a distributed control system (DCS) or a PLC. 4.4.4 Signal conditioning Smart transmitters can also perform signal conditioning, scanning the average signal and eliminating any "noise" spikes. Signals can also be delayed (dampened) so that the response does not fluctuate. This is especially useful with a rapidly changing process. 4.4.5 Self-diagnosis Finally, a smart transmitter can diagnose itself and report on any problems in the process. For example, it can report on a circuit board which is not working properly. 4.4.6 Summary of smart transmitter benefits There are distinct advantages in using a smart transmitter. The most important include ease of installation and communication, self-diagnosis, improved and digital reliability. Smart transmitters are also less subject to effects of temperature and humidity than analog devices. And although vibration can still affect them, the effects are far less than with analog devices. Smart transmitters also provide increased accuracy. And because can replace several different types of devices, using them allows for inventory reduction

microcontroller basd pid controller

PID (proportional, integral, derivative) control is not as complicated as it sounds. Follow these simple implementation steps for quick results. At work, I am one of three designated "servo guys," and the only one who implements control loops in softwae. As a result, I often have occasion to design digital control loops for various projects. I have found that while there certainly are control problems that require all the expertise I can bring to bear, a great number of control problems can be solved with simple controllers, without resorting to any control theory at all. This article will tell you how to implement and tune a simple controller without getting into heavy mathematics and without requiring you to learn any control theory. The technique used to tune the controller is a tried and true method that can be applied to almost any control problem with success. PID control The PID controller has been in use for over a century in various forms. It has enjoyed popularity as a purely mechanical device, as a pneumatic device, and as an electronic device. The digital PID controller using a microprocessor has recently come into its own in industry. As you will see, it is a straightforward task to embed a PID controller into your code. PID stands for "proportional, integral, derivative." These three terms describe the basic elements of a PID controller. Each of these elements performs a different task and has a different effect on the functioning of a system. In a typical PID controller these elements are driven by a combination of the system command and the feedback signal from the object that is being controlled (usually referred to as the "plant"). Their outputs are added together to form the system output. Figure 1 shows a block diagram of a basic PID controller. In this case the derivative element is being driven only from plant feedback. The plant feedback is subtracted from the command signal to generate an error. This error signal drives the proportional and integral elements. The resulting signals are added together and used to drive the plant. I haven't described what these elements do yet-we'll get to that later. I've included an alternate placement for the proportional element (dotted lines)-this can be a better location for the proportional element, depending on how you want the system to respond to commands. Sample plants In order to discuss this subject with any sense of reality we need some example systems. I'll use three example plants throughout this article, and show the effects of applying the various controllers to them: A motor driving a gear train A precision positioning system A thermal system Each of these systems has different characteristics and each one requires a different control strategy to get the best performance. Motor and gear The first example plant is a motor driving a gear train, with the output position of the gear train being monitored by a potentiometer or some other position reading device. You might see this kind of mechanism driving a carriage on a printer, or a throttle mechanism in an automobile cruise control system, or almost any other moderately precise position controller. Figure 2 shows a diagram of such a system. The motor is driven by a voltage that is commanded by software. The motor output is geared down to drive the actual mechanism. The position of this final drive is measured by the potentiometer. A DC motor driven by a voltage wants to go at a constant speed that is proportional to the applied voltage. Usually the motor armature has some resistance that limits its ability to accelerate, so the motor will have some delay between the change in input voltage and the resulting change in speed. The gear train takes the movement of the motor and multiplies it by a constant. Finally, the potentiometer measures the position of the output shaft. Figure 3 shows the step response of the motor and gear combination. I'm using a time constant value of t0 = 0.2s. The step response of a system is just the behavior of the output in response to an input that goes from zero to some constant value at time t = 0. Since we're dealing with fairly generic examples here I've shown the step response as a fraction of full scale, so it goes to 1. Figure 3 shows the step input and the motor response. The response of the motor starts out slowly due to the time constant, but once that is out of the way the motor position ramps at a constant velocity. Precision actuator It is sometimes necessary to control the position of something very precisely. A precise positioning system can be built using a freely moving mechanical stage, a speaker coil (a coil and magnet arrangement), and a non-contact position transducer. You might expect to see this sort of mechanism stabilizing an element of an optical system, or locating some other piece of equipment or sensor. Figure 4 shows such a system. Software commands the current in the coil. This current sets up a magnetic field that exerts a force on the magnet. The magnet is attached to the stage, which moves with an acceleration proportional to the coil current. Finally, the stage position is monitored by a non-contact position transducer. With this arrangement, the force on the magnet is independent of the stage motion. Fortunately this isolates the stage from external effects. Unfortunately the resulting system is very "slippery," and can be a challenge to control. In addition, the electrical requirements to build a good current-output amplifier and non-contact transducer interface can be challenging. You can expect that if you are doing a project like this you are a member of a fairly talented team (or you're working on a short-lived project). The equations of motion for this system are fairly simple. The force on the stage is proportional to the drive command alone, so the acceleration of the system is exactly proportional to the drive. The step response of this system by itself is a parabola, as shown in Figure 5. As we will see later this makes the control problem more challenging because of the sluggishness with which the stage starts moving, and its enthusiasm to keep moving once it gets going. Temperature control The third example plant I'll use is a heater. Figure 6 shows a diagram of an example system. The vessel is heated by an electric heater, and the temperature of its contents is sensed by a temperature-sensing device. Thermal systems tend to have very complex responses. I'm going to ignore quite a bit of detail and give a very approximate model. Unless your performance requirements are severe, an accurate model isn't necessary. Figure 7 shows the step response of the system to a change in Vd. I've used time constants of t1 = 0.1s and t2 = 0.3s. The response tends to settle out to a constant temperature for a given drive, but it can take a great deal of time doing it. Also, without lots of insulation, thermal systems tend to be very sensitive to outside effects. This effect is not shown in the figure, but we'll be investigating it later in the article. Controllers The elements of a PID controller presented here either take their input from the measured plant output or from the error signal, which is the difference between the plant output and the system command. I'm going to write the control code using floating point to keep implementation details out of the discussion. It's up to you to adapt this if you are going to implement your controller with integer or other fixed-point arithmetic. I'm going to assume a function call as shown below. As the discussion evolves, you'll see how the data structur and the internals of the function shapes up. double UpdatePID(SPid * pid, double error, double position){...}The reason I pass the error to the PID update routine instead of passing the command is that sometimes you want to play tricks with the error. Leaving out the error calculation in the main code makes the application of the PID more universal. This function will get used like this: ..position = ReadPlantADC();drive = UpdatePID(&plantPID, plantCommand - position, position);DrivePlantDAC(drive);..Proportional Proportional control is the easiest feedback control to implement, and simple proportional control is probably the most common kind of control loop. A proportional controller is just the error signal multiplied by a constant and fed out to the drive. The proportional term gets calculated with the following code: double pTerm;...pTerm = pid->pGain * error;...return pTerm;Figure 8 shows what happens when you add proportional feedback to the motor and gear system. For small gains (kp = 1) the motor goes to the correct target, but it does so quite slowly. Increasing the gain (kp = 2) speeds up the response to a point. Beyond that point (kp = 5, kp = 10) the motor starts out faster, but it overshoots the target. In the end the system doesn't settle out any quicker than it would have with lower gain, but there is more overshoot. If we kept increasing the gain we would eventually reach a point where the system just oscillated around the target and never settled out-the system would be unstable. The motor and gear start to overshoot with high gains because of the delay in the motor response. If you look back at Figure 2, you can see that the motor position doesn't start ramping up immediately. This delay, plus high feedback gain, is what causes the overshoot seen in Figure 8. Figure 9 shows the response of the precision actuator with proportional feedback only. Proportional control alone obviously doesn't help this system. There is so much delay in the plant that no matter how low the gain is, the system will oscillate. As the gain is increased, the frequency of the output will increase but the system just won't settle. Figure 10 shows what happens when you use pure proportional feedback with the temperature controller. I'm showing the system response with a disturbance due to a change in ambient temperature at t = 2s. Even without the disturbance you can see that proportional control doesn't get the temperature to the desired setting. Increasing the gain helps, but even with kp = 10 the output is still below target, and you are starting to see a strong overshoot that continues to travel back and forth (this is called ringing). As the previous examples show, a proportional controller alone can be useful for some things, but it doesn't always help. Plants that have too much delay, like the precision actuator, can't be stabilized with proportional control. Some plants, like the temperature controller, cannot be brought to the desired set point. Plants like the motor and gear combination may work, but they may need to be driven faster than is possible with proportional control alone. To solve these control problems you need to add integral or differential control or both. Integral Integral control is used to add long-term precision to a control loop. It is almost always used in conjunction with proportional control. The code to implement an integrator is shown below. The integrator state, iState is the sum of all the preceding inputs. The parameters iMin and iMax are the minimum and maximum allowable integrator state values. double iTerm;...// calculate the integral state // with appropriate limitingpid->iState += error;if (pid->iState > pid->iMax) pid->iState =pid->iMax;else if (pid->iState iMin) pid->iState = pid->iMin;iTerm = pid->iGain * iState; // calculate the integral term...Integral control by itself usually decreases stability, or destroys it altogether. Figure 11 shows the motor and gear with pure integral control (pGain = 0). The system doesn't settle. Like the precision actuator with proportional control, the motor and gear system with integral control alone will oscillate with bigger and bigger swings until something hits a limit. (Hopefully the limit isn't breakable.) Figure 12 shows the temperature control system with pure integral control. This system takes a lot longer to settle out than the same plant with proportional control (see Figure 10), but notice that when it does settle out, it settles out to the target value-even with the disturbance added in. If your problem at hand doesn't require fast settling, this might be a workable system. Figure 12 shows why we use an integral term. The integrator state "remembers" all that has gone on before, which is what allows the controller to cancel out any long term errors in the output. This same memory also contributes to instability-the controller is always responding too late, after the plant has gotten up speed. To stabilize the two previous systems, you need a little bit of their present value, which you get from a proportional term. Figure 13 shows the motor and gear with proportional and integral (PI) control. Compare this with Figures 8 and 11. The position takes longer to settle out than the system with pure proportional control, but it will not settle to the wrong spot. Figure 14 shows what happens when you use PI control on the heater system. The heater still settles out to the exact target temperature, as with pure integral control (see Figure 12), but with PI control, it settles out two to three times faster. This figure shows operation pretty close to the limit of the speed attainable using PI control with this plant. Before we leave the discussion of integrators, there are two more things I need to point out. First, since you are adding up the error over time, the sampling time that you are running becomes important. Second, you need to pay attention to the range of your integrator to avoid windup. The rate that the integrator state changes is equal to the average error multiplied by the integrator gain multiplied by the sampling rate. Because the integrator tends to smooth things out over the long term you can get away with a somewhat uneven sampling rate, but it needs to average out to a constant value. At worst, your sampling rate should vary by no more than ý20% over any 10-sample interval. You can even get away with missing a few samples as long as your average sample rate stays within bounds. Nonetheless, for a PI controller I prefer to have a system where each sample falls within ý1% to ý5% of the correct sample time, and a long-term average rate that is right on the button. If you have a controller that needs to push the plant hard, your controller output will spend significant amounts of time outside the bounds of what your drive can actually accept. This condition is called saturation. If you use a PI controller, then all the time spent in saturation can cause the integrator state to grow (wind up) to very large values. When the plant reaches the target, the integrator value is still very large, so the plant drives beyond the target while the integrator unwinds and the process reverses. This situation can get so bad that the system never settles out, but just slowly oscillates around the target position. Figure 15 illustrates the effect of integrator windup. I used the motor/controller of Figure 13, and limited the motor drive to ý0.2. Not only is controller output much greater than the drive available to the motor, but the motor shows severe overshoot. The motor actually reaches its target at around five seconds, but it doesn't reverse direction until eight seconds, and doesn't settle out until 15 seconds have gone by. The easiest and most direct way to deal with integrator windup is to limit the integrator state, as I showed in my previous code example. Figure 16 shows what happens when you take the system in Figure 15 and limit the integrator term to the available drive output. The controller output is still large (because of the proportional term), but the integrator doesn't wind up very far and the system starts settling out at five seconds, and finishes at around six seconds. Note that with the code example above you must scale iMin and iMax whenever you change the integrator gain. Usually you can just set the integrator minimum and maximum so that the integrator output matches the drive minimum and maximum. If you know your disturbances will be small and you want quicker settling, you can limit the integrator further. Differential I didn't even show the precision actuator in the previous section. This is because the precision actuator cannot be stabilized with PI control. In general, if you can't stabilize a plant with proportional control, you can't stabilize it with PI control. We know that proportional control deals with the present behavior of the plant, and that integral control deals with the past behavior of the plant. If we had some element that predicts the plant behavior then this might be used to stabilize the plant. A differentiator will do the trick. The code below shows the differential term of a PID controller. I prefer to use the actual plant position rather than the error because this makes for smoother transitions when the command value changes. The differential term itself is the last value of the position minus the current value of the position. This gives you a rough estimate of the velocity (delta position/sample time), which predicts where the position will be in a while. double dTerm;...dTerm = pid->dGain * (position - pid->dState);pid->dState = position;...With differential control you can stabilize the precision actuator system. Figure 17 shows the response of the precision actuator system with proportional and derivative (PD) control. This system settles in less than 1/2 of a second, compared to multiple seconds for the other systems. Figure 18 shows the heating system with PID control. You can see the performance improvement to be had by using full PID control with this plant. Differential control is very powerful, but it is also the most problematic of the control types presented here. The three problems that you are most likely going to experience are sampling irregularities, noise, and high frequency oscillations. When I presented the code for a differential element I mentioned that the output is proportional to the position change divided by the sample time. If the position is changing at a constant rate but your sample time varies from sample to sample, you will get noise on your differential term. Since the differential gain is usually high, this noise will be amplified a great deal. When you use differential control you need to pay close attention to even sampling. I'd say that you want the sampling interval to be consistent to within 1% of the total at all times-the closer the better. If you can't set the hardware up to enforce the sampling interval, design your software to sample with very high priority. You don't have to actually execute the controller with such rigid precision-just make sure the actual ADC conversion happens at the right time. It may be best to put all your sampling in an ISR or very high-priority task, then execute the control code in a more relaxed manner. Differential control suffers from noise problems because noise is usually spread relatively evenly across the frequency spectrum. Control commands and plant outputs, however, usually have most of their content at lower frequencies. Proportional control passes noise through unmolested. Integral control averages its input signal, which tends to kill noise. Differential control enhances high frequency signals, so it enhances noise. Look at the differential gains that I've set on the plants above, and think of what will happen if you have noise that makes each sample a little bit different. Multiply that little bit by a differential gain of 2,000 and think of what it means. You can low-pass filter your differential output to reduce the noise, but this can severely affect its usefulness. The theory behind how to do this and how to determine if it will work is beyond the scope of this article. Probably the best that you can do about this problem is to look at how likely you are to see any noise, how much it will cost to get quiet inputs, and how badly you need the high performance that you get from differential control. Once you've worked this out, you can avoid differential control altogether, talk your hardware folks into getting you a lower noise input, or look for a control systems expert. The full text of the PID controller code is shown in Listing 1 and is available at www.embedded.com/code.html. Listing 1: PID controller code typedef struct{double dState; // Last position inputdouble iState; // Integrator statedouble iMax, iMin; // Maximum and minimum allowable integrator statedouble iGain, // integral gainpGain, // proportional gaindGain; // derivative gain} SPid;double UpdatePID(SPid * pid, double error, double position){double pTerm,dTerm, iTerm;pTerm = pid->pGain * error; // calculate the proportional term// calculate the integral state with appropriate limitingpid->iState += error;if (pid->iState > pid->iMax) pid->iState = pid->iMax;else if (pid->iState iMin) pid->iState = pid->iMin;iTerm = pid->iGain * iState; // calculate the integral termdTerm = pid->dGain * (position - pid->dState);pid->dState = position;return pTerm + iTerm - dTerm;}Tuning The nice thing about tuning a PID controller is that you don't need to have a good understanding of formal control theory to do a fairly good job of it. About 90% of the closed-loop controller applications in the world do very well indeed with a controller that is only tuned fairly well. If you can, hook your system up to some test equipment, or write in some debug code to allow you to look at the appropriate variables. If your system is slow enough you can spit the appropriate variables out on a serial port and graph them with a spreadsheet. You want to be able to look at the drive output and the plant output. In addition, you want to be able to apply some sort of a square-wave signal to the command input of your system. It is fairly easy to write some test code that will generate a suitable test command. Once you get the setup ready, set all gains to zero. If you suspect that you will not need differential control (like the motor and gear example or the thermal system) then skip down to the section that discusses tuning the proportional gain. Otherwise start by adjusting your differential gain. The way the controller is coded you cannot use differential control alone. Set your proportional gain to some small value (one or less). Check to see how the system works. If it oscillates with proportional gain you should be able to cure it with differential gain. Start with about 100 times more differential gain than proportional gain. Watch your drive signal. Now start increasing the differential gain until you see oscillation, excessive noise, or excessive (more than 50%) overshoot on the drive or plant output. Note that the oscillation from too much differential gain is much faster than the oscillation from not enough. I like to push the gain up until the system is on the verge of oscillation then back the gain off by a factor of two or four. Make sure the drive signal still looks good. At this point your system will probably be responding very sluggishly, so it's time to tune the proportional and integral gains. If it isn't set already, set the proportional gain to a starting value between 1 and 100. Your system will probably either show terribly slow performance or it will oscillate. If you see oscillation, drop the proportional gain by factors of eight or 10 until the oscillation stops. If you don't see oscillation, increase the proportional gain by factors of eight or 10 until you start seeing oscillation or excessive overshoot. As with the differential controller, I usually tune right up to the point of too much overshoot then reduce the gain by a factor of two or four. Once you are close, fine tune the proportional gain by factors of two until you like what you see. Once you have your proportional gain set, start increasing integral gain. Your starting values will probably be from 0.0001 to 0.01. Here again, you want to find the range of integral gain that gives you reasonably fast performance without too much overshoot and without being too close to oscillation. Other issues Unless you are working on a project with very critical performance parameters you can often get by with control gains that are within a factor of two of the "correct" value. This means that you can do all your "multiplies" with shifts. This can be very handy when you're working with a slow processor. Sampling rate So far I've only talked about sample rates in terms of how consistent they need to be, but I haven't told you how to decide ahead of time what the sample rate needs to be. If your sampling rate is too low you may not be able to achieve the performance you want, because of the added delay of the sampling. If your sampling rate is too high you will create problems with noise in your differentiator and overflow in your integrator. The rule of thumb for digital control systems is that the sample time should be between 1/10th and 1/100th of the desired system settling time. System settling time is the amount of time from the moment the drive comes out of saturation until the control system has effectively settled out. If you look at Figure 16, the controller comes out of saturation at about 5.2s, and has settled out at around 6.2s. If you can live with the one second settling time you could get away with a sampling rate as low as 10Hz. You should treat the sampling rate as a flexible quantity. Anything that might make the control problem more difficult would indicate that you should raise the sampling rate. Factors such as having a difficult plant to control, or needing differential control, or needing very precise control would all indicate raising the sampling rate. If you have a very easy control problem you could get away with lowering the sampling rate somewhat (I would hesitate to lengthen the sample time to more than one-fifth of the desired settling time). If you aren't using a differentiator and you are careful about using enough bits in your integrator you can get away with sampling rates 1,000 times faster than the intended settling time. Exert control This covers the basics of implementing and tuning PID controllers. With this information, you should be able to attack the next control problem that comes your way and get it under control. Tim Wescott has a master's degree in electrical engineering and has been working in industry for more than a decade. His experience has included a number of control loops closed in software using 8- to 32-bit microprocessors, DSPs, assembly language, C, and C++. He is currently involved in control systems design at FLIR Systems where he specifies mechanical, electrical, and software requirements and does electrical and software design. You can contact him at tim@wescottdesign.com.

Capacitive-type displacement and pressure sensitive transducer

The transducer functions as a capacitor to sense variations in inter-plate istances produced either by transducer displacement or by pressure. The capacitor plates include flexible rubber sheathing members having interior conductive surfaces spaced slightly from a conductive centrally-disposed metal plate. A pair of electrets are disposed one between each rubber surface and the central metal plate. Electrets are a battery replacement supplying a large electrostatic field. Opposite polarization of the electrets provides push-pull and directional capabilities. Like polarities, or the omission of one electrode, provide responsiveness both to pressure and to displacement. The central metal plate has sufficient mass to remain substantially stationary relative to the flexible movements of the rubber sheathing. Variations in the plate spacings produces variations in the capacitor output.

Integral Orifice

Rosemount 1195 Integral OrificeThe Rosemount 1195 Integral Orifice Assembly is designed to meet the need for highly accurate small bore flow measurements with minimal installation and maintenance requirements. The Rosemount 1195 is suitable for measurement of any clean gas, liquid, or vapor flow. It can be directly mounted to any Rosemount differential pressure transmitter in many environments and applications. It connects to the process piping using one of the following methods: a threaded or socket-weld Rosemount 1195 body, threaded pipe ends, flanged pipe ends, or pipe ends prepared for welding.Features of the Rosemount 1195 include:Available preassembled to the world's most popular pressure transmitters Numerous process connections and construction material options Wide orifice bore/flow range capability Compliance with NACE MR 01-75(90) Complete Point SolutionsTMRosemount Inc. Complete Point Solutions provides fully engineered measurement solutions, combining best product and practices for improved performance, reliability, and cost of ownership. We compliment our field instruments with a wide range of technologies; including manifolds, primary elements, process flanges and seals, and temperature sensors and accessories.Complete Point Solutions is designed to provide you with Best-in-Class equipment allowing you to save on installation costs, and improve the reliability and capability of your process. Take advantage of our vast experience in process measurement.

brushless DC motor

A brushless DC motor (BLDC) is a synchronous electric motor which is powered by direct-current electricity (DC) and which has an electronically controlled commutation system, instead of a mechanical commutation system based on brushes. In such motors, current and torque, voltage and rpm are linearly related.A BLDC motor powering a micro remote-controlled airplane. The motor is connected to a microprocessor-controlled BLDC controller. This 5-gram motor produces more thrust than twice the weight of the entire plane. Being an outrunner, the rotor-can containing the magnets spins around the coil windings on the stator.Two subtypes exist:The stepper motor type may have more poles on the stator. The reluctance motor. In a conventional (brushed) DC motor, the brushes make mechanical contact with a set of electrical contacts on the rotor (called the commutator), forming an electrical circuit between the DC electrical source and the armature coil-windings. As the armature rotates on axis, the stationary brushes come into contact with different sections of the rotating commutator. The commutator and brush system form a set of electrical switches, each firing in sequence, such that electrical-power always flows through the armature coil closest to the stationary stator (permanent magnet).In a BLDC motor, the electromagnets do not move; instead, the permanent magnets rotate and the armature remains static. This gets around the problem of how to transfer current to a moving armature. In order to do this, the brush-system/commutator assembly is replaced by an electronic controller. The controller performs the same power distribution found in a brushed DC motor, but using a solid-state circuit rather than a commutator/brush system.

diaphragm pump

A diaphragm pump is a positive displacement pump that uses a combination of the reciprocating action of a rubber or teflon diaphragm and suitable non-return check valves to pump a fluid. Sometimes this type of pump is also called a membrane pump.There are three main types of diaphragm pumps:In the first type, the diaphragm is sealed with one side in the fluid to be pumped, and the other in air or hydraulic fluid. The diaphragm is flexed, causing the volume of the pump chamber to increase and decrease. A pair of non-return check valves prevent reverse flow of the fluid. As described above, the second type of diaphragm pump works with volumetric positive displacement, but differs in that the prime mover of the diaphragm is neither oil nor air; but is electro-mechanical, working through a crank or geared motor drive. This method flexes the diaphragm through simple mechanical action, and one side of the diaphragm is open to air. The third type of diaphragm pump has one or more unsealed diaphragms with the fluid to be pumped on both sides. The diaphragm(s) again are flexed, causing the volume to change. When the volume of a chamber of either type of pump is increased (the diaphragm moving up), the pressure decreases, and fluid is drawn into the chamber. When the chamber pressure later increases from decreased volume (the diaphragm moving down), the fluid previously drawn in is forced out. Finally, the diaphragm moving up once again draws fluid into the chamber, completing the cycle. This action is similar to that of the cylinder in an internal combustion engine.[edit] ApplicationsDiaphragm pumps have good suction lift characteristics, some are low pressure pumps with low flow rates; others are capable of higher flows rates, dependent on the effective working diameter of the diaphragm and its stroke length. They can handle sludges and slurries with a good amount of grit and solid content. Diaphragm pumps have good dry running characteristics. Diaphragm pumps are low-shear pumps. Diaphragm pumps can be used to make artificial hearts. Diaphragm pumps can be up to 97% efficient. Diaphragm pumps have good self priming capabilities Membrane pump on oil tanker deck

flow rate

In fluid dynamics and hydrometry, the volumetric flow rate also volume flow rate and rate of fluid flow, is the volume of fluid which passes through a given surface per unit time (for example cubic meters per second [m3 s-1] in SI units, or cubic feet per second [cu ft/s]). It is usually represented by the symbol Q. Volumetric flow rate should not be confused with volumetric flux, represented by the symbol q, with units of m3/(m2 s), that is, m s-1. The integration of a flux over an area gives the volumetric flow rate. Volumetric flow rate is also linked to viscosity.Given an area A, and a fluid flowing through it with uniform velocity v with an angle θ away from the perpendicular to A, the flow rate is:In the special case where the flow is perpendicular to the area A, that is, θ = 0, the volumetric flow rate is:If the velocity of the fluid through the area is non-uniform (or if the area is non-planar) then the rate of fluid flow can be calculated by means of a surface integral:where dS is a differentialsurface described by:with n the unit surface normal and dA the differential magnitude of the area.If a surface S encloses a volume V, the divergence theorem states that the rate of fluid flow through the surface is the integral of the divergence of the velocity vecto field v on that volume: