2-DAP Configuration for Measuring Control Loop Latency | |||
Introduction(View more Data Acquisition articles or download this article in PDF format.) This note describes how to use a Data Acquisition Processor (DAP) board to measure control loop signal propagation delays. This is not something that everybody will want to do, but it is something that anybody could do, if necessary, to obtain a realistic determination of control loop performance. A real-time system has two important, but very different properties: its throughput and its latency.
For purposes of control systems, the key property is latency: the ability to deliver a timely and regular response so that the feedback loop does not become noisy or unstable. When a control loop is implemented using a Data Acquisition Processor, and the performance measurements are independently captured and analyzed using another DAP, this leads to a 2-DAP test configuration. DAP boards are multitasking devices, and it is tempting to let the same DAP operate the control loop and also measure itself. Such measurements are possible to a limited extent, but there are some significant difficulties. The monitoring activities compete with the control activities for processing resources, and this can alter the performance measurements significantly. The monitoring and control updates are time-correlated, not independent, so there is a significant chance that the monitor will consistently miss worst cases, or consistently exaggerate them. The following is a diagram of the basic 2-DAP hardware configuration for latency measurement. The measurement strategy is based on three key ideas:
The System Under TestThe Data Acquisition Processor board serving as a controller will perform control and data conversion tasks in the same way as it would in the actual application. As long as the operation is stable and within a normal operating range, control output levels don't matter. A typical configuration for a DAP board under test will define
// Configuration for a single-channel PID controller reset pipe setpipe word pipe gains float constant lolim word = 10000 constant hilim word = 20000 constant Tsamp float = 0.01 // K Ti Td Z fill gains 5.0 6.0 0.01 1.0 fill setpipe 13500 // Delivery of control output signals pipe pDrive word // Receiving feedback input, sampling time idefine pidsamp channels 1 set IP0 s0 time 100 end // Delivering the control response pdefine controller PID (setpipe, IP0, gains, Tsamp, pDrive, lolim, hilim ) DACOUT(pDrive,0) end start Data arrive at precise intervals, timed by the controller DAP's sampling clock. Responses computed by the controller algorithm are delivered with minimal delay, and without waiting for a clock. The Testing DAPA typical configuration for the DAP that coordinates the testing will define
reset // Detection levels on disturbance and control response variable DIST_LOW word = 2000 variable DIST_HIGH word = 32700 variable RESP_LOW word = 3500 variable RESP_HIGH word = 32700 // Clocked sampling of disturbance and response signals constant SAMPLING word = 25 idefine monitoring channels 2 set ip0 s0 // Controller drive signal set ip1 s1 // Disturbance signal time SAMPLING end // Detection of disturbances and disturbance responses trigger tDisturb mode=normal holdoff=100 startup=5000 trigger tRespond mode=normal holdoff=100 startup=5000 pipes ptDisturb long, ptRespond long pipe pDelay float // Processing to measure response delays pdefine observe dlimit(ip1,inside,DIST_LOW,DIST_HIGH,tDisturb) tstamp(tDisturb, ptDisturb ) dlimit(ip0,inside,RESP_LOW,RESP_HIGH,tReceiving) tstamp(tRespond, ptRespond ) $Binout = (ptRespond - ptDisturb)*SAMPLING*2 end start Disturbance SignalsA typical disturbance signal is a small square wave, added to the ordinary feedback response. The sharp rising edge of this disturbance usually results in a sharp controller response that is easy to detect. Then the steady flat tops of the disturbance waveform allow for settling time between the sharp edges. Timing of disturbance signals is not critical. Precise periodic waveforms are not required. The example configuration assumes that the controller operates in a stable manner in combination with a real system, or something that responds sufficiently like one. You will get no useful measurements if the control loop is unstable and oscillating hard, or clamped against an output limit. Offline TestingThe point of the control latency measurement is to determine controller delays, not identify system closed loop dynamics. The dynamics of an actual system can get in the way of delay measurements. Sometimes it is too awkward, too expensive, or too dangerous to perform measurements on an actual system. The actual system really doesn't matter for the purposes of testing controller delays. You just need the loop to stabilize. If you are able to set up a simple "R-C lag filter" as a substitute for your actual system, and you can get the closed control loop to stabilize with this, it is an excellent configuration. It is inexpensive and has a natural filtering response that will control measurement noise. The disturbance signal can be coupled into the RC network to produce crisp edges that are easy to detect in the controller output. As an alternative to building an electronic network, it is often possible to let the testing DAP simulate an adequate system response. The disturbance can be computed as well, eliminating the need for any supplemental electronic devices. The following modifications to the testing DAP configuration will compute a small square wave disturbance, a first order lag response for simulation, and a combination yielding the feedback signal. // Declare additional elements for simulation constant cTlag float = 500 pipes prsim1 word, prsim2 float, pdisturb word fill prsim2 0 // Declare properties of disturbance waveform constant wavelength word = 10000 constant amplitude word = 800 // Simulate first-order lag response with disturbance pdefine simulate squarewave(amplitude,wavelength,pdisturb) prsim2 = (prsim2*cTlag + ip0)/(cTlag+1) prsim1 = prsim2 + pdisturb dacout(prsim1,0) end Testing Multiple Loop ConfigurationsData Acquisition Processors gain tremendous advantage from processing data in blocks. The bulk of the computational cost is usually related to operating the hardware and moving the data through the pipe system. For a DAP system, the cost for fetching a block of data is not much more than the cost of fetching just one value. If the sampling rate is boosted by a factor of N, a set of N control loops can share input operations, each channel receiving data at the original rate. Each loop will have similar control processing, but each can have its own independent states and tuning. In all respects other than shared timing of input and output activity, the loops operate independently. You can use a 2-DAP configuration to measure latency of multiple-loop controllers with just a few variations in the test configuration. Do these things for the duration of the test.
Analyzing Test ResultsThere are three main sources of delay in measured time delay results.
Because of the variation in the delays, you will need to take many measurements and analyze the results statistically, looking at the typical and worst cases. Some guidelines for analyzing the test results:
Return to the Data Acquisition articles page. |