HCBBS Forum (English)
Submit Chemical Projects / Find Solutions
Amplify Your Requirements on a Broader Chemical Platform *Engineering · Technology · Equipment · Solutions*
Submit Request

The S7-300 Siemens PLC uses timers to execute code in a loop

2019-01-24 View Original

Thread Content

Source: Changhui Instruments http://yunrun.com.cn/ The S_PULSE pulse S5 timer is used to achieve the purpose of cyclically executing certain code. 1. Open STEP 7 V5.5 and create a new project; here, the PLC is taken as an example of “CPU315-2 DP/NP”. 2. Create a new function block FC1, open the symbol table, and create the following variables: 3. Open OB1 and add the following code: Here, T1 refers to the S5 timer used for the S_PULSE pulse. The parameter TV represents the timing period; here we take 1 second as an example. When a rising edge is detected at the input S terminal, the timer starts, and the Q terminal outputs 1 ; When the timing period ends or the S terminal is 0, the Q terminal outputs 0. For specific parameters, please refer to the built-in help of STEP 7. M0.0 is the timer control bit, responsible for initiating (resetting) the timer at the rising edge ; M0.1 is the timer output bit, which also ensures the timer operates in self-locking mode. When the output bit M0.1 is 1, the timer continues to operate. When both the control bit M0.0 and the output bit M0.1 are 0, it indicates that one cycle of the timer has ended, and the code that needs to be executed in a loop can be run. Next, set the control bit M0.0 to 1 to start the timer. When both the control bit M0.0 and the output bit M0.1 are 1, it indicates that the timer has been started; set the control bit M0.0 to 0. The timer continues to operate through self-locking. Summary: From the end of each cycle to the start of the next one, there is a delay of one PLC cycle (the duration of this delay depends on the amount of code in the PLC), so it is not suitable for applications that require extremely precise timing. If there are any shortcomings or better methods, please feel free to comment and point them out.

Submit a Project

**Looking for Chemical Technology, Equipment & Solutions?** No Registration Required Broader Platform Exposure | Global Chemical Service Provider Connections

Submit Request — Free Consultation

Disclaimer

This is an automated machine translation of the original thread. Some technical terms may have inaccuracies; the original text shall prevail. Click "View Original" at the top right to access the source page, which supports IP-based automatic real-time language translation. Please watch out for contact details and sales inducements to prevent fraud. All content and translations are for reference only, representing solely the poster's personal views. For enquiries, email service@hcbbs.com.

Quick Links