How to use PLC to measure speed - News - Global IC Trade Starts Here.
As a beginner in PLC programming, I'm sharing my notes from past studies for future reference. I apologize in advance for any errors or omissions, and I welcome any feedback or corrections you might have. All the programs in this article are written using Step7Template.mwp, with the CPU selected as Siemens S7-200 series 226 CN. Let's start with the low-speed measurement (up to 1000 RPM): LD I0.0 LD M20.1 CTU C0, +5000 // Set the upper limit of the counter LD SM0.0 A M20.0 TON T37, +30 // Turn on immediately, delay for 3 seconds before turning off LD SM0.0 O M20.0 AN T37 = M20.0 // Reset signal for T37 timer LD M20.0 LD M20.1 CTU C1, +20 // Set the upper limit of the up counter C1 LD C1 MOVW C0, VW200 = M20.2 LD M20.2 = M20.1 // Reset signal for C1 The peripheral circuit uses I0.0 as the input port. T37 delays for 3 seconds before triggering C1. After each 3-second interval, C1 counts once, then resets T37 and repeats. This process continues until C1 reaches 20, which equals one minute. During this time, C0 counts the pulses from I0.0. Once the minute is over, the result is moved to VW200. This program can measure speeds below 1000 RPM, with an experimental upper limit of over 1400 RPM. However, due to the limitations of the low-speed counter, high-speed pulses may not be fully captured within a minute, leading to potential inaccuracies. To address this, we use the built-in high-speed counter, which is not affected by the PLC's clock cycle, to measure speeds above 1000 RPM: LD SM0.1 CALL SBR_0 // Call high-speed counter initialization subroutine LD SM0.0 A M20.0 TON T37, +100 // Delay for 10 seconds LD SM0.0 O M20.0 AN T37 = M20.0 // Trigger after 10 seconds LD T37 MOVD HC0, VD100 // Read high-speed counter HC0 MOVD VD100, VD200 MUL +6, VD200 // Multiply by 6 to get the per-minute value LD T37 CALL SBR_0 // Re-initialize the counter SBR_0 // High-speed counter initialization subroutine LD SM0.0 MOVB 16#F8, SMB37 // Configure the counter: increase mode, enabled MOVD +0, SMD38 // Load current value MOVD +0, SMD42 // Load preset value HDEF 0, 0 HSC 0 The high-speed measurement program can handle speeds over 1000 RPM, with a maximum recorded speed of 2500+ RPM during testing. Due to limited equipment, the actual upper limit remains unknown. You might wonder why we measure for 10 seconds and multiply by 6 instead of measuring for a full minute. The reason is that the final data is displayed on a digital tube, and users prefer real-time updates, so a 10-second read and 6x scaling is more practical. Finally, let's discuss the peripheral circuit. It converts rotational speed into a pulse signal, which is fed into I0.0 of the PLC. A Hall sensor is used for signal conversion. The connection is as follows: VCC connects to 24V, GND to the power supply’s negative terminal, and the A terminal connects to I0.0. A resistor is placed between A and 24V. The Hall element is fixed to the object being measured, like a wheel, while the magnet is mounted on the surface of the wheel. When the wheel rotates, the magnet and Hall element come into contact, causing a drop in voltage at the A terminal, generating a pulse signal for the PLC. The distance between the magnet and the Hall sensor should be around 3–5 mm, and the polarity of the magnet must be carefully considered during installation. After all the measurements, the data is stored in the PLC’s memory. While it's possible to monitor it via software, it's somewhat inconvenient. A better option is to display the data on LED digital tubes for easier viewing.
Temperature And Humidity Test Chamber
Temperature And Humidity Test Chamber,Temperature Humidity Test Box,Test Machine For Aerospace,Constant Temperature Humidity Tester
Wuxi Juxingyao Trading Co., Ltd , https://www.juxingyao.com