PID Cntrl with ADwin Prcessrs with Sub-Micrsecnd Respnse Times Cntrl a Variety f I/O CHESTERLAND OH March 9, 2015 *Adapted frm PID Cntrl with ADwin, by Dug Rathburn, Keithley Instruments By Terry Nagy, Cmputer Aided Slutins, LLC. Intrductin One f the mst cmmn autmatic cntrl methds is the Prprtinal-plus-Integral-and-Derivative (PID) cntrller. Industrial cntrllers utilizing this technique are used fr cntrlling prcesses like thse fund in chemical plants, thse fr temperature cntrl, fr certain autmtive applicatins, etc. The purpse f a cntrller is t cmpensate fr the effects f disturbances n prcess variables and t frce a prcess variable t track a desired set pint. While these cntrllers can be built using analg circuits, implementing them using a digital cntrller prvides greater flexibility in adjusting the cntrl algrithm and in fine-tuning the cntrller settings. The PID cntrller measures the utput f the prcess and calculates the difference (errr) between what is measured and the set pint. If an errr exists, the cntrller adjusts its utput t alter the prcess t bring it clser t the desired pint, thus minimizing the errr. Each time an errr is calculated, the cntrller must decide hw much t alter the prcess. If the cntrller is t aggressive (underdamped), it may cause the prcess t becme unstable and scillate. If cntrl is nt aggressive enugh (ver-damped), the system may require t much time t recver r nt recver at all. The respnse characteristics f the cntrller are determined by the PID cnstants prvided t the cntrller. The Prprtinal, Integral, and Derivative cnstants are used t calculate what the utput shuld be relative t the measured errr. The Prprtinal cnstant represents the area in which the cntrller is actually cntrlling the prcess and determines the band f peratin. It represents a cnstant that is multiplied by the errr. While the prprtin represents a cnstant multiplier f the errr, as the errr gets small, the effect f the prprtin term als gets small. Simply increasing the magnitude f the prprtin factr can lead t instability. The Integral prtin crrects fr the ffset between the set pint and the prcess variable by autmatically resetting r shifting the prprtining band. The integral accumulates the small cnstant errr ver time and frces the system twards the set pint.
The Derivative cnstant determines the rate at which the cntrller reacts t large changes in the prcess variable. Implementing a Digital PID Cntrller The architecture f the ADwin prduct family f data acquisitin and cntrl systems makes it well-suited fr PID applicatins. In a Windws-based envirnment, respnse times can vary dramatically depending n what ther applicatins are running n the PC. In fact it s nt uncmmn t see up t 50 msec. respnse times which is ften unacceptable fr maintaining the level f cntrl required in industrial r research prcess cntrl. ADwin systems cme with their wn DSP prcessrs with sub-micrsecnd respnse times that cntrl a variety f I/O. The I/O includes ADCs (analgt-digital cnverters), DACs (digital-t-analg cnverters), digital inputs, and digital utputs. Analg r digital inputs mnitr the prcess, and the prcessr calculates the errr between prcess utput and the set pint. A new utput level fr either analg r digital utput is calculated t cntrl the prcess. ADCs fr the ADwin prducts can be either 12- r 16-bit, while the digital inputs are either TTL, quadrature encder, PWM, r up/dwn cunters. The ADwin-PRO als has thermcuple and PTD input mdules. Fr highly-ptimized cnditins, the ADwin hardware is capable f acquiring data at a rate f up t 1MHz, and input signals can be measured n bth analg and digital inputs. The ADwin-GOLD has tw ADCs fr measuring tw channels simultaneusly and can be multiplexed acrss 16 inputs. The Pr- Ain-F family f analg input mdules are well-suited fr synchrnized sampling. Each channel has a dedicated A/D t allw fr parallel measurements, and the measurements can als be simultaneusly triggered acrss multiple input mdules. Once the prcess is cmpiled nt the ADwin micrprcessr and running, the prcess will run as lng as it is cnnected t the pwer supply. The perating system n the hst PC can crash, but as lng as the ADwin system is pwered, the prcess will cntinue t execute. Therefre, the ADwin system s prcesses run independently frm the lad f the PC prcessr. This cntinuus executin makes ADwin the ideal slutin fr fault-intlerant systems r where reliance n the hst PC s perating system is
impssible. The ADwin-Gld and ADwin-Pr prducts als have bt lader ptins that allw them t be pre-prgrammed t run n pwer-up withut the need f a PC. Flw cntrl is a very cmmn use fr PID cntrllers. This applicatin invlves cntrlling hw much fluid r gas is flwing thrugh a pipe with a valve. This vlume is mnitred and then cntrlled with the PID. The cntrl steps are summarized here: 1. Values fr the desired flw and PID cnstants are passed t the ADwin prcessr. 2. The flw sensr is measured using ne ADwin analg input channel. 3. The differential between what has been measured and the new set pint is calculated. 4. The errr is added t all previus errr terms that have been calculated. 5. The sum f errrs is cmpared t the limit f the valve. If the sum is t large r small, the sum is capped t crrespnd t a wide pen r clsed valve. 6. The new psitin fr the valve is calculated and then changed with ne analg utput channel n the ADwin. 7. Return t Step 2 t cntinue the algrithm. Available Input Types: Analg (12 & 16-bit) Digital Thermcuple RTD Cunter/Encder Quadrature PWM
Calculating the PID Cnstants Calculating the cnstants that are used by the PID cntrller is the tpic f much science and research. Likewise many bks and methds exist fr tuning the cntrller t prvide the desired respnse. Mst methds prvide values fr each cnstant, but when the system is actually implemented, the system des nt functin prperly. In fact, even the best methds typically nly allw users t apprach the crrect cnstants, but fr ptimal peratin fr a specific cntrller and prcess variable, there is still an element f trial and errr. ADwin prducts easily allw fr this trial and errr. The prgramming language fr the ADwin family is ADbasic. The hardware and ADbasic allw yu t define integer and flating-pint variables that are stred in registers that can be accessed while ADwin is running. The I/O registers can be easily accessed by mst f tday s ppular prgramming envirnments such as TestPint, LabVIEW, Visual Basic, r C. The PID cnstants can then be passed t the apprpriate register lcatin and used by the ADwin prcessr during peratin. Als, imprtant prcess infrmatin can be read thrugh ne f the prgrams while ADwin is running. PID Lp Timing and Multiple Cntrllers The PID lp time is determined by hw many times per secnd the utput f the cntrller is updated. Fr a 1kHz lp, the inputs are measured and utputs changed fr the cntrller 1000 times per secnd. A general rule f thumb states that the PID cntrl lp shuld update twice as ften as the physical parameter (e.g. temperature, lever psitin, valve, etc.) Therefre if the time cnstant f this physical parameter is ne secnd, then the cntrl lp shuld be updated every 0.5 secnds. Typical industrial PID cntrllers update at 1kHz, while ther real-time cntrllers are generally capable f nly abut 5kHz. ADbasic enables quick and simple develpment f different cntrl structures in additin t the PID, but it is pssible t cnstruct a PID lp fr ADwin at 500kHz (100% CPU lad). As the cntrl lp speed is decreased, the lad n the CPU is als reduced. Therefre, a PID cntrl lp running at 50kHz culd require nly abut 10% f the ADwin CPU, and a 20kHz lp uses apprximately 4%.
Fr cntrl lps running at less than 500kHz, excess prcessr bandwidth is available t run multiple cntrllers n the same ADwin hardware. These multiple cntrllers culd be either cascaded r independent. The cntrllers can als run at different frequencies r cycle times. Equipment List: 1. PC running Windws (95/98/ME/NT/2000/XP/Windws 7) 2. ADwin real-time cntrl hardware 3. ADbasic real-time develpment envirnment 4. Custm wiring harness fr cnnecting t test setup Alternative Slutins The ADwin prduct family ffers many different frm factrs, prcessrs, and I/O in which t create the PID cntrller. The ADwin family includes: ADwin-Light-16 systems Plug-in bards and external Analg inputs and utputs (ne 12-bit A/D) expandable Digital I/O Optinal cunters PCI, USB r Ethernet cmmunicatin with the PC ADwin-GOLD Stand-alne, external system 16 analg inputs (16-bit @ 10ms & 12-bit @ 0.8ms) BNC cnnectins
2 analg utputs (16-bit) expandable 32 digital I/Os, in blck f 8 as input r utput Optinal cunter (event cunter, encder interface, perid cycle, PWM) Integrated USB r Ethernet cmmunicatin with the PC ADwin-PRO Industrial, mdular 19-inch system Up t 4 CPUs per system Mdular and expandable: 480 analg inputs (multiplexed r parallel) 120 analg utputs 480 digital I/Os Thermcuples, RTD, cunter, filters, islatin, etc. CAN-bus, Prfibus, RS-232, RS-485, RS-422 USB r Ethernet fr cmmunicatin with the PC In additin, the ADwin-Gld and ADwin-Pr can supprt up t 32Mbytes f RAM per prcessr and ptinal btlader. The btlader stres an ADbasic prcess(es) and begins running the prcess upn pwer-up. Therefre, nce the ADwin hardware is prgrammed, it can be used as a stand-alne slutin withut a PC.