S7-200PLC uses high-speed counter to measure analog signals - Database & Sql Blog Articles

Photocoupler

1, analog acquisition requires the signal itself to be better, including the power supply of sensors and meters! The analog transmission line should try to avoid strong electric cables and high, medium and low frequency interference, such as: high frequency welding machine, medium frequency heating furnace and inverter output to the motor cable, otherwise, add a point to your real signal. Material", thereby contaminating the signal source;
2. The grounding of the electrical system should be paid special attention to in the construction design. If the grounding treatment is not good, the lighter interferes with the normal operation of the plc system, and the heavy one cannot use or damage the sensor or PLC in the control loop with analog quantity. Power, analog and other modules. If the above precautions are only for attention in the construction design, you need to work harder in the following situations:
1. The analog acquisition module of PLC does not use the analog quantity and PLC loop isolation mode. Therefore, the analog input and output circuits need special care. If the sensor or input circuit is connected to the high voltage signal, beware of damage to the PLC host?
2. The PLC module adopts high-speed sampling mode, which can distinguish the signal change of 0.25ms. This is a good thing, but it is very annoying because it is too sensitive, which affects the normal acquisition of analog signals. In case of signal loop interference and poor shielding, we want to remove the interference. It is impossible to solve such problems simply by increasing the filtering time. We have encountered such problems before, and we must filter the input signal through the RC filter loop. Reluctantly work!
Due to some systems controlled by PLC, it is often necessary to measure various types of analog voltage/current signals. In the past, voltage/current sensors were usually used for sampling, and the analog expansion module of PLC was used for arithmetic processing. The output of the voltage sensor is analog. In the environment with strong electromagnetic interference, large measurement error is easy to occur. At the same time, due to the valuable input point of the analog expansion module (the analog expansion module price is close to the medium and small PLC). The price, and the input point is very small, which makes the system cost-effective. When the voltage/current/frequency converter is used for sampling and then counted by the PLC high-speed counter, the above problem can be better solved. The output of the VFC or IFC converter is a pulse signal, and the signal changes minimally under electromagnetic interference; In addition, the signal is digital and can be directly connected to the input point of the PLC high-speed counter.
CPU224 has 6 high-speed counters of HSC0-HSC5. Each high-speed counter has multiple working modes to complete different functions. When using a high-speed counter, according to the control needs of the system, first select a working mode for the counter. It can be set by the high speed counter definition instruction HDEF. The dynamic parameters of the counter can only be programmed if the counter and counter modes are defined. Only one HDEF instruction can be used per high-speed counter during programming. Each high-speed counter has a control byte that includes the enable or disable count, the control of the count direction, the current value of the counter to be loaded, and the preset value to be loaded.
The V/F sensor converts the measured analog voltage signal into a rectangular pulse signal at a fixed ratio.
First, the VFC or IFC transmitter converts the input voltage (current) into a pulse signal, which is then sent to the input of the high-speed counter HSC1 and accumulates the number of pulses. The time of the accumulated pulse of the high-speed counter is controlled by setting the interval time of the timer interrupt 0. When the preset interval time is reached, the measured voltage (current) value is calculated based on the accumulated pulse number.
Programming principle:
The main program calls the subroutine SBR0 in the first scan cycle;
Initialization of SBR0 high-speed counter and timer interrupt;
INT0 timing interrupt routine for evaluating the high speed counter;
The program and the comment main program call the initialization subroutine SBR0 in the first scan cycle, only in the first scan cycle flag bit SM01=1. Initialization is implemented by the subroutine SBR0.
First, the control byte MB47 of the high-speed counter HSC1 is set to a hexadecimal number FC, which means: counting in the positive direction, updating the preset value (PV), updating the current value (CV), and activating HSC1.
Then, the high-speed counter HSC1 is set to the operating mode 0 by the definition command HDEF, that is, there is no reset or start input, and there is no external direction selection. The current value SMD48 is reset to 0, and the preset value SMD52 is set to FFFF (hexadecimal). The timer interrupt 0 interval time SMB34 is set to 100ms, the interrupt program 0 is assigned to the timer interrupt 0, and the interrupt is enabled. The high-speed counter is started by the instruction HSC1.
Interrupt program 0 is called every 100ms, and after reading the value of the high-speed counter, it is set to zero. The measured voltage value is obtained by the HSC1 count value and the conversion relationship.
The above method has been applied to a plurality of self-control projects, and it has been proved that the method performs analog voltage signal measurement with high precision, strong anti-interference and reliable operation.

Portable Power

With 15+ years manufacturing experience for portable power.

Supply various portable charger for iPhone, Airpods, laptop, radio-controlled aircraft ,laptop, car and medical device mobile device, ect.


From the original ordinary portable power source to Wireless Power Bank, Green Energy Solar Power Bank, Magnetic Mobile Power, Portable Power Stations and other products continue to innovate.

Avoiding your devices run out of charge, Portable Chargers to keep your mobile device going.

We help 200+ customers create a custom mobile power bank design for various industries.


Portable Power Supply, Wholesale Powerbank,Portable Phone Charger,wholesale gifts

TOPNOTCH INTERNATIONAL GROUP LIMITED , https://www.mic11.com