Share this

UniMAT: Analog Calculation and Programming

2026-04-06 05:57:35 · · #1

Before performing analog calculations and programming, we must first understand some concepts and calculation bases, namely conversion formulas. Only by understanding these can we proceed with programming smoothly. The following section uses a 200 CPU analog input as an example.

1. **Conceptual Explanation: ** Engineering values ​​refer to the actual engineering quantities corresponding to the transmitter, such as pressure, temperature, and flow rates. Signal values ​​refer to the current and voltage values ​​detected by a multimeter. Channel readings refer to the values ​​read by the CPU from the channel. 2. **Conversion Formula : ** Analog values ​​read or output by the CPU have poor readability and generally require engineering conversion to facilitate analysis and utilization. The following formula (collected from the internet) can be used for conversion: Formula 1: Ov = [(Osh - Osl)*(Iv - Isl)/(Ish - Isl)] + Osl Where: Ov: Conversion result Iv: Conversion object Osh: Upper limit of the conversion result Osl: Lower limit of the conversion result Ish: Upper limit of the conversion object Isl: Lower limit of the conversion object 3. **Conversion Example:** The above formula is explained using a current-type transmitter as an example. The transmitter output is current-type, with a current range of 4 to 20 mA, corresponding to engineering values ​​of 0 to 100 kPa. Therefore, we can conclude that 4 to 20 mA corresponds to 0 to 100 kPa, and 6400 to 32000 kPa, respectively. That is, 4 mA corresponds to 0 kPa and 6400 kPa, and the relationship between the three is linear. Corresponding to the above formula: Ov = pressure value; Iv = CPU analog channel reading; Osh = 100 kPa; Osl = 0 kPa; Ish = 32000; Isl = 6400. When the CPU analog channel reading is N, the corresponding pressure is P. Substituting into the above formula: P=(100-0)*(N-6400)/(32000-6400)+0. Similarly, using this formula, we can calculate the current value I corresponding to the CPU analog channel reading of N: I=(20-4)*(N-6400)/(32000-6400)+4. Given one of the analog input signal values ​​(such as the detected current value), analog channel reading, and engineering value, the values ​​of the other two items can be easily calculated using the above formula. 4 Programming Examples Analog data can be processed in two ways: by calling the encapsulated library file or by manually writing the program. Calling the library file is suitable when there is a lot of analog data, and the library file can be called directly; when there is no library file on hand and there is little analog data, manual programming can be used. The former is recommended because it is simple and fast. (1) Scale Library Application By calling the library file, it is easy to process the analog data. The library selected is Scale. The Scale library has three sub-items: S_ITR (integer to real number conversion), which is used more for analog input data processing; S_RTR (real number to real number conversion), which is used more for PID data processing; and S_RTI (real number to integer conversion), which is used more for analog output data processing. This library is written based on Formula 1. The pin definitions are similar to Formula 1, except that the Ov code is changed to Output and the Iv code is changed to Input. In the previous example, the analog channel was AIW0. When the calculated data, VD0, deviates from the actual value, the deviation VD4 can be referenced. The two are added together to obtain a value VD8 that is closer to the actual value. See Figure 1 for a program example. Figure 1 Library file call (2) Manually write the conversion program In order to ensure accuracy, the principle of manually writing the program is to multiply first and then divide. See Figure 2 for a program example. Figure 2 When the data calculated by the conversion program , i.e., VD12, deviates from the actual value, the deviation VD16 can be referenced, and the two are added together to obtain a value VD20 that is closer to the actual value. 5. Notes (1) The library file of 200 is also applicable to analog output programming; (2) The analog input calculation of 300 can call FC105, and the output calculation can call FC105; (3) Taking current as an example, the transmitter signal collected by the 300 module is 0-20mA or 4-20mA, and the corresponding channel data word is 0-27648. It should be noted that the channel hardware configuration must be set correctly; (4) The channel readings of RTD and TC modules are 10 times the actual temperature and do not need to be converted. For example, if the channel reading is 500, the corresponding actual temperature is 50.0℃. (Forwarding code: Yiwei Company slogan: Trust comes from quality; Trust builds brand) Welcome to follow Yiwei WeChat subscription account (unimat2004) to share new industrial control technologies in real time!
Read next

CATDOLL 130CM Laura

Height: 130cm Weight: 27kg Shoulder Width: 31cm Bust/Waist/Hip: 64/60/72cm Oral Depth: 3-5cm Vaginal Depth: 3-15cm Anal...

Articles 2026-02-22