plc.myforum.ro Forum Index plc.myforum.ro
PLCs users www.plc.myforum.ro!
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Save the value of an "HSC" counter for the S7-1200

 
Post new topic   Reply to topic    plc.myforum.ro Forum Index -> Simatic Automation Systems
View previous topic :: View next topic  
Author Message
mamiko
Member 2
Member 2
mamiko

Joined: 25 Dec 2017
Posts: 420

PostPosted: 31/05/2023 17:25    Post subject: Save the value of an "HSC" counter for the S7-1200 Reply with quote

Save the value of an "HSC" counter for the S7-1200 in STEP 7 (TIA Portal)
https://support.industry.siemens.com/cs/document/41995947/
How in STEP 7 (TIA Portal) do you save the value of an "HSC" (high-speed counter) for the S7-1200 after STOP mode or after a restart?
Description
In this video we show you how to retain and save the value of the high-speed counters after a CPU STOP.
https://teraboxapp.com/s/1VjkRu-XA2Cf-BNJLVmkekw
Instructions
To be able to execute the "Control high-speed counters" [CTRL_HSC] operation you must enable the high-speed counters in the device configuration. Open the CPU properties and navigate to the "High-speed counters (HSC)" folder in the "General" tab.
Click "HSC1". The properties of the high-speed counter "HSC1" are displayed in the right window.
Enable the option "Enable this high-speed counter", to enable High Speed Counter 1.
For the high-speed counter, set the type of counting, operating phase, and initial counting direction.
Save and compile the device configuration.

Create a global data block and define the DB variables for the parameters of the "Control high-speed counters" instruction. In this example we have assigned the symbolic name "DBHSCretain" for the DB.
Note
The current counter value for the "Control high-speed counters" operation is not provided for in the parameters. The address for the process image is assigned to the high-speed counter in the hardware configuration and includes the current counter value. You can read out the counter value directly via the program logic. The value output in your program is a correct counter value for the moment in which the counter was read. The actual counter value can therefore change before your program has completed a process with an old counter value.

Create the cyclic interrupt OB entitled "Cyclic interrupt" with a cycle time of 100 ms, for example, 100ms. The runtime of a cyclic interrupt OB must be significantly shorter than its time interval. Otherwise the time interval of the cyclic interrupt might expire before the that cyclic interrupt is processed.
Insert the "MOVE" instruction in Network 1.
Parameterize the input parameter of the "MOVE" instruction with the initial address of the high-speed counter "HSC_1" and define a symbolic variable for this ("HSC1_CV", for example).
Note
The initial address ID1000 for the high-speed counter HSC_1 is in the CPU properties under "Overview of addresses".

Parameterize the output parameter with the DB variable "HSC 1". When the program is executed, the counter value of the high-speed counter is transferred to the DB variable every 100 ms.
Create the start OB "Startup".
Insert the "MOVE" instruction in Network 1.
Parameterize the input and output parameter with the DB variable "HSC_1" and NEW_CV1".
When you do a restart the counter value in the DB variable is transferred as initial value to the variable "NEW_CV1" and used by the high-speed counter to start counting again.
To enable the counter value, insert the "Set output" [S] instruction in another network and parameterize the operands with the defined variable "CV1".
Open OB1 and insert the "Control high-speed counters" [CTRL HSC] instruction into the programming editor. The "CTRL_HSC" instruction is to be found in the instruction palette under "Technology > Counting".
Parameterize the "HSC" parameter with the system constant of the hardware ID (HW_ID). For this you open the dialog "Show all tags" and select the "System constants" tab.
If you split the editor area and have both the OB1 dialog and the "System constants" next to each other on the screen, you can drag-and-drop the constant "Local~HSC_1" to the parameter "HSC".
Then share the screen with the data block.
Now parameterize the other inputs and outputs of the "Control high-speed counters" instruction with the DB variables.
Insert the "Reset output" instruction in another network and parameterize the operands with the DB variable "CV1". After releasing the current counter value with this variable, the "CV" parameter must be reset again.
Save and compile the project and download the station into the CPU.
After changing from STOP to RUN mode or after switching the power supply off and on again, the fast counters (High Speed Counter) are reinitialized and the counters are reset to zero.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    plc.myforum.ro Forum Index -> Simatic Automation Systems All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Fa-ti si tu propriul forum GRATUIT, pe www.myforum.ro