Post by open on How to create a stopwatch?
CODESYS Forge
talk
(Post)
Hi @ph0010421, I tried the program the TimeTaken is calculated when stop is triggered. I want the TimeTaken to be continuously calculated and counting when a BOOL variable is true. I tried to program this way: Declaration: PROGRAM PLC_PRG VAR bStartStop: BOOL := FALSE; // Start/Stop button bReset: BOOL := FALSE; // Reset button bRunning: BOOL := FALSE; // Flag indicating whether the stopwatch is running tStartTime: TIME; // Variable to store the start time tElapsedTime: TIME; // Variable to store the elapsed time END_VAR Implementation: // Main program logic IF bReset THEN // Reset button pressed, reset the stopwatch bRunning := FALSE; tElapsedTime := T#0s; ELSIF bStartStop THEN // Start/Stop button pressed, toggle the running state IF bRunning THEN // Stop the stopwatch bRunning := FALSE; ELSE // Start the stopwatch bRunning := TRUE; tStartTime := tElapsedTime; END_IF; END_IF // Update the elapsed time when the stopwatch is running IF bRunning THEN tElapsedTime := tElapsedTime + T#1s; // Adjust the time increment as needed END_IF However counting of the seconds is not accurate. I tried changing the main task cycle time interval to 1000ms. The counting of seconds become slower. (see attached) Please help
Last updated: 2023-12-08
Post by t-roger on Beckhoff EL6652-0010 with Codesys
CODESYS Forge
talk
(Post)
Hi, I have the same problem. Have you found a solution to this problem? t-roger
Last updated: 2025-03-20
how to make a real time CLock
CODESYS Forge
talk
(Thread)
how to make a real time CLock
Last updated: 2011-05-25
Time Measurement between two events with V2.3 using Wago750-890
CODESYS Forge
talk
(Thread)
Time Measurement between two events with V2.3 using Wago750-890
Last updated: 2020-12-26
CANopen and level 2 CAN at the same time
CODESYS Forge
talk
(Thread)
CANopen and level 2 CAN at the same time
Last updated: 2012-09-03
Alarm Manager - large delay time not accepted
CODESYS Forge
talk
(Thread)
Alarm Manager - large delay time not accepted
Last updated: 2019-07-10
How to get task cycle time before Application run
CODESYS Forge
talk
(Thread)
How to get task cycle time before Application run
Last updated: 2021-05-05
Print text and time in the same object
CODESYS Forge
talk
(Thread)
Print text and time in the same object
Last updated: 2022-05-19
Display minutes and second from time variable.
CODESYS Forge
talk
(Thread)
Display minutes and second from time variable.
Last updated: 2019-04-16
Ping with SysSockPing and Connection Time Out
CODESYS Forge
talk
(Thread)
Ping with SysSockPing and Connection Time Out
Last updated: 2019-01-29
first Time connect Codesys with Raspberry pi
CODESYS Forge
talk
(Thread)
first Time connect Codesys with Raspberry pi
Last updated: 2021-12-23
Implementing a time delay within a function block
CODESYS Forge
talk
(Thread)
Implementing a time delay within a function block
Last updated: 2009-02-13
Time Quanta, Baud Rate Prescaler on MCP2515
CODESYS Forge
talk
(Thread)
Time Quanta, Baud Rate Prescaler on MCP2515
Last updated: 2019-05-21
Comparing projects 3.5.17- Takes a long time to load
CODESYS Forge
talk
(Thread)
Comparing projects 3.5.17- Takes a long time to load
Last updated: 2022-01-04
Temperature Input to PID time base output
CODESYS Forge
talk
(Thread)
Temperature Input to PID time base output
Last updated: 2008-01-10
SMC_NcInterpreter g code processing takes a long time.
CODESYS Forge
talk
(Thread)
SMC_NcInterpreter g code processing takes a long time.
Last updated: 2023-06-02
Wago 750-841 Network Time Protokoll (ntp)
CODESYS Forge
talk
(Thread)
Wago 750-841 Network Time Protokoll (ntp)
Last updated: 2009-05-14
How to Sync PLC DateTime with Internet Time Server
CODESYS Forge
talk
(Thread)
How to Sync PLC DateTime with Internet Time Server
Last updated: 2016-01-16
One time execution in ST code
CODESYS Forge
talk
(Thread)
One time execution in ST code
Last updated: 2016-03-14
Getting Date and Time with DTU.GetDateAndTime only once
CODESYS Forge
talk
(Thread)
Getting Date and Time with DTU.GetDateAndTime only once
Last updated: 2018-09-12
Opc Ua variable time delay to server
CODESYS Forge
talk
(Thread)
Opc Ua variable time delay to server
Last updated: 2023-03-09
TargetVisu and WebVisu running at the same time
CODESYS Forge
talk
(Thread)
TargetVisu and WebVisu running at the same time
Last updated: 2023-05-01
Why declare FB instance name every time?
CODESYS Forge
talk
(Thread)
Why declare FB instance name every time?
Last updated: 2005-09-13
Date Time Picker to visible Timespan in Trendcontrol
CODESYS Forge
talk
(Thread)
Date Time Picker to visible Timespan in Trendcontrol
Last updated: 2020-12-17
1 Wire Increases my Task time by 1000 times
CODESYS Forge
talk
(Thread)
1 Wire Increases my Task time by 1000 times
Last updated: 2019-04-25
To search for an exact phrase, put it in quotes. Example: "getting started docs"
To exclude a word or phrase, put a dash in front of it. Example: docs -help
To search on specific fields, use these field names instead of a general text search. You can group with AND
or OR
.