Measuring and Controlling of Analog signal Based on High-speed port of PLC
- 格式:doc
- 大小:133.50 KB
- 文档页数:10
Measuring and Controlling of Analog signal Based on High-speed I/O port of PLCHongtao Ma, Xiaojun Wang, FenPing ZhouCollege of Information Science & EngineeringHebei University of Science & TechnologyShijiazhuang,Chinamiracle@, ma-hongtao@AbstractFrequency signal is gotten from voltage signal by external V/F converter, and then is sent to high-speed counter of PLC. As a host, CPU222 of Siemens S7-200 series PLC is used. Through programming PLC, input voltage is measured byhigh-speed I/O channels. High-speed digital pulse of variable duty cycle produced by PLC’s PWM pulse generator is turned into voltage signal of amplitude-adjustable after external RC low-pass filter circuit filter to achieve controlling of output analog. The method reduces the cost of measurement and control system via replacing expensive analog I/O modules. Peripheral circuit design and PLC program are given. Through analyzing and comparing data, it is found that the system can achieve ± 0.1% accuracy.Key words: PLC; High-speed I/O; A/D;I. INTRODUCTIONPLC has advantages of high reliability, simple programming, easy learning, convenient usage and small volume. It can implement sequential logic control and automatic control of analog according to the requirement of technological process, so it is widely used in industrial field and also make a good control effect. In some systems controlled by PLC, the circumstance of measuring analog voltage signal often is encountered. Analog extended module of PLC is adopted to do some conversion work in this case. But these modules’ prices are close to the small and medium-sized PLC’s price, and only provide f ew input port. In addition, more one module is connected in order to practical application, whose expensive cost cause to decrease of performance cost ratio[1-8].Based on CPU222 of Siemens S7-200 series PLC, use PLC’s high-speed digital I / O channel with low-cost add-in V/F converter to convert voltage signal into frequency signal and then send it into PLC’s high-speed counter. By programming the PLC, it realizes measurement of input voltage. PLC use high-speed PWM pulse generator to produce digital pulse with variable duty cycle. Through external RC low-pass filter circuit, voltage with variable amplitude can be achieved. This method completes the measuring and controlling without special expensive analog I/O module and decrease the cost of system.II. CIRCUIT DESIGNA. Analog input circuitCPU222 host can only accept digital input signals, the author design external V / F converter to convert 0~10V voltage signal to 0~10kHz frequency signal. The V/F converter adopted LM331 IC, the production of NS Corporation, U.S.. Main features of LM331 includes: (1) wide dynamic range, up to 100dB;(2) good linearity, the largest non-linear distortion is less than 0.01 percent, andeven has better linearity at the low-frequency 0.1Hz; (3) high-precision conversion, digital resolution is up to 12 bit; (4) simple peripheral circuit, only a few external components are needed to form a V/F converter and easily ensure accuracy.The V/F converter circuit is shown as Figure 1. The circuit can achieve ±0.03% linearity in the range of 10Hz -10kHz.Figure 1. V/F converter circuitThe output frequency of the circuit is calculated as following equationwhere RS=R4+RP1. According to component parameter in Figure 1 to adjust potentiometer RP1, so RS value changes, to make f OUT up equal to 10kHz.Output frequency signal of LM331 is fed into PLC’s port of high-speed counter. Timeris also started at time of beginning to count, so that the output frequency f = D/T, in which D denotes counter value and T denotes counting time. T may be set up by timer, so the value of f can be able to calculate out if we know the value of D. PLC processes and stores the value of f, so that an A/D conversion is implemented.B.Measuring method of input voltageS7-200 family PLC have 6 high-speed counters of HSC0~HSC5. Each counter may operates at different mode to implement different function. Output frequency of V/F converter in this paper is 0~10kHz, corresponding to input voltage 0~10V, that is, the resolution is 1mV/Hz..Firstly, control byte MB47 of high-speed counter is presented with hexadecimal value FC. Its meaning is: up counting, updateable preset value, updateable current value, activating HSC1.Then counter HSC1 is set at operating mode 0 using HDEF instruction, that is, reset input, start input and selecting input of external direction don’t exist. Reset value of current-value register SMD48 is 0, preset value register SMD52 is set with FFFFH. Interval register SMB34 of timing interrupt is set with 100ms. Timer interrupt is allocated to interrupt 0 and allow interruption. Finally HSC1 is started to count by instruction.Interrupt serving routine 0 is called every 100ms to read out count value of counter HSC1 and then clear it. Input voltage can be calculated out by count value of HSC1 according to transform relationship. Here a 0~10kHz V/F converter is adopted, so in 100ms gate time 1000 pulses can be accumulated at most. It is equivalent to 1000h10=10000 pulses can be accumulated in one second, which corresponds to actual 10V input voltage. Supposed that count value is 200 in 100ms gate, and then its actual voltage is 2V. Such that a resolution of 10V/1000=0.01V=10mV can beacquired.A group of experimental result data of measured voltage with PLC high-speed counter to count pulses of V/F converter is listed in TABLE I.TABLE I. EXPERIMENTAL RESULT OF COUNT V/F PULSES IN100ms GATEInput CalculatedFrom the experimental results it can be seen that this method can reach a resolution of 10mV and full error of ±0.1%.Interval of PLC timing interruption is variable within the range of 5~255ms. To extend the interval such that makes gate time longer, result of measuring voltage will be more accurate, but measuring speed will slow down at the same time. If gate time is set at 200ms, then measuring resolution may reach 5mV and full error can reach ±0.05%.C.Anolog output circuitAnalog output circuit is shown in Figure 2, which is supplied by PLC's+24V power. PWM signal of 24Vp-p outputted by Q0.0 port of host CPU222 is reshapinged by U1A and U1B after being stepped proportionally down by R1 andR2. High accuracy PWM signal outputted by U1B is filtered by low-pass filter constructed by R6 and C9. Finally U2 provides direct current voltage relating to PWM signal.RC time constant directly impact on the ripple amplitude of output voltage. The larger RC value is, the smaller the ripple voltage is. But to use too large RC value is inadvisable, because it will increase the corresponding time of output voltage.Figure 2. Analog output circuitD.O utput voltage control methodS7-200 series PLC have 2 generators to output high-speed pulse sequence, which can implement period-variable, width-adjustable PWM waveform. Two outputs are respectively dedicated to Q0.0 and Q0.1. The set range of PWM period is within 2~65535, the set range of PWM pulse width is within 0~65535. Time base of PWM is 1us or 1ms.In this paper, Q0.0 is selected to output PWM signal.Period of PWM is set to 5000, and pulse width of PWM is in range of 0~5000. Time base of 1us is adopted such that period of PWM is 5000 us (5 ms), and duty cycle changes from 0 to 100%. Resolution of PWM is 1/5000, which is equivalent to that of 12-bit A/D converter.Direct-current output voltages are listed in TABLE II when the case is selected that PWM period is 5ms, time constant of RC filter is 25 ms and PWM is in different duty cycle.From the TABLE II, we can see that although theoretical resolution can reach to 1/5000, that is, 2mV, equivalent to 0.02% of full scale, actually there is approximately f10mV error and f0.1% full error. This is only equivalent to the accuracy of 10-bit D/A converter.In experiment, changing time constant of RC filter, ripple voltage is measured with oscillograph under different duty cycle. The measured result is listed in TABLE III.It can be seen from TABLE III that ripple voltage is larger when only one stageRC filter is used. To decrease this ripple voltage,multi-stage Rcfilters can be introduced.TABLE II. PWM OUTPUT VOLTAGE OF DIFFERENT DUTY CYCLE】TABLE III. THE RELATIONSHIP OF RIPPLE VOLTAGE AND RC TIMECONSTANT AND DUTY CYCLEIII.CONCLUSIONIn this paper, a simple V/F converter circuit converts 0 ~ 10V voltage to 0~10kHz frequency. The frequency signal is then sent to high-speed digital input of PLC. Input voltage is measured through programming the PLC and can achieve the measurement accuracy of ±0.1%. PWM ability of PLC with external RC filter implements 0~10V output voltage and reached ± 0.1% accuracy.On the occasion of no requiring high accuracy, this solution achieve measuring and control of analog without expensive PLC analog I/O modules, which reducesgreatly the cost of system.REFERENCES[1] Henning Dierks. PLC-automata: a new class of implementablereal-time automate. Theotetical computer science, 2001, 253:61-93.[2] David G. Johnson. Programmable Controllers for Factory Automation. NewYork and Basel: Marcel Dekker Inc,1987.[3] Can Saygin, Firat Kahraman. A Web-based Programmable LogicController laboratory for manufacturing engineering education. The International Journal of Advanced Manufacturing Technology, 2004,24(7):590-598.[4] J.-S. Lee, P.-L. Hsu. An improved evaluation of Ladderlogic diagrams and Petri nets for the sequence controllerdesign in manufacturing systems. The International Journal ofAdvanced Manufacturing Technology, 2004, 2(5): 279-287.[5] John, Karl-Heinz, Michael. Programming Industrial AutomationSystem, Berlin. New York: Springer, 2001.[6] T. Mikulczynski, Z. Samsonowicz, R Wieclawek. The GrafpolProgramming Language for Programmable Logic Controllers.Archives of Control Sciences, 2000,10(1):17-30.[7] Nanette Bauer, Sebastian Engell, Ralf Huuck, etal. Verification ofPLC Programs Given as Sequential Function Charts. Lecture Notesin Computer Science, 2004, 45(22): 517-540.[8] Stephane Klein, Georg Frey, Mark Minas. PLC Programming with SignalInterpreted Petri Nets. Lecture Notes in Computer Science, 2003, 4(8):440-449.。