How to use PLC to measure speed - News - Global IC Trade Starts Here.
As a beginner in PLC programming, I’ve decided to summarize my learning process here for future reference. Since my knowledge is still limited, there may be some errors or omissions in this article. I welcome any feedback or corrections you might have. All the programs described here were written using Step7Template.mwp, and the CPU used is from the Siemens S7-200 series, specifically the 226 CN model. Let’s start with the low-speed measurement (up to 1000 RPM). The program uses a basic counter setup: LD I0.0 LD M20.1 CTU C0, +5000 // Set the upper limit of the counter Then, we use a timer to control the cycle: LD SM0.0 A M20.0 TON T37, +30 // Turn on immediately, delay 3 seconds before turning off Next, we reset the timer and set up the next step: LD SM0.0 O M20.0 AN T37 = M20.0 // Reset the timer Now, we count the pulses over time: LD M20.0 LD M20.1 CTU C1, +20 // Set the upper limit for the up counter C1 Once the counter reaches 20, it means one minute has passed. The result is then moved to VW200: LD C1 MOVW C0, VW200 = M20.2 Finally, we reset the counter and repeat the cycle: LD M20.2 = M20.1 // Reset the up counter C1 This setup works well for low speeds, but when the speed increases beyond 1000 RPM, the PLC's clock cycle can affect the accuracy. To overcome this, we use the built-in high-speed counter. For high-speed measurement (over 1000 RPM), we use the high-speed counter inside the PLC, which is not affected by the system clock: LD SM0.1 CALL SBR_0 // Initialize high-speed counter Then, we set a 10-second timer: LD SM0.0 A M20.0 TON T37, +100 // Delay for 10 seconds After the timer runs out, we read the high-speed counter value and convert it to RPM: LD T37 MOVD HC0, VD100 // Read high-speed counter HC0 MOVD VD100, VD200 MUL +6, VD200 // Multiply by 6 to get RPM per minute CALL SBR_0 // Reinitialize the counter after 10 seconds The high-speed counter initialization subroutine looks like this: SBR_0 LD SM0.0 MOVB 16#F8, SMB37 // Configure counter: increment mode, enabled MOVD +0, SMD38 // Load current value MOVD +0, SMD42 // Load preset value HDEF 0, 0 HSC 0 This method allows us to measure speeds up to 2500 RPM during testing. The reason for measuring for 10 seconds and multiplying by 6 instead of measuring for a full minute is mainly for user experience—displaying results faster is more practical, especially when using a digital display. Now, let's talk about the peripheral circuit. The Hall sensor converts the rotational speed into a pulse signal that is fed into the PLC through I0.0. The connection is as follows: VCC connects to 24V, GND to the negative terminal, and the A pin connects to I0.0 via a resistor. The Hall element is mounted on the object being measured, and a magnet is placed nearby. When the object rotates, the magnet passes the Hall sensor, causing a voltage drop at the A pin, which generates a pulse signal. The distance between the magnet and the Hall sensor should be around 3–5 mm. It’s important to ensure the correct orientation of the magnet during installation. After collecting the data, it's stored in the PLC's memory. While you can monitor it through the software, it's more convenient to use an LED digital display for real-time visibility. This makes it easier for users to see the speed readings without needing to access the PLC directly.
Sand And Dust Test Chamber,Lock Dust Test Machine,Dustproof Test Box,Seal Dust Test Equipment
Wuxi Juxingyao Trading Co., Ltd , https://www.juxingyao.com