Command I/O Counter
 
Description The 31 I/O counters use pre-define variables which can be reset and tested for value.
The counter uses an unsigned 32bit register (U32) with names CNTKxx where xx=00 to 30.
They require the I/O to be set as an interrupt but do not require an associated INT() command.
Counter increment depends on the rising or falling edge of the interrupt.
The command RESET(CNTK00) resets to zero the I/O counter on K00.
The maximum counter speed is 0-10kHz+ and is dependent on other interrupt and entity usage.
 
Syntax/Parameters CNTK00-CNTK30
 
Example IF(CNTK00>300?Func300);   //if greater than 300 run function called Func300
TEXT(K00Text,CNTK00);;     //update counter value on page and refresh screen
 
Command RunTime Counter
 
Description The RUNTIME counter uses pre-define variables which can be set and tested for values
The command Reset(RUNTIME) sets all vales to zero and starts the timer.
This runtime counter is independent of the real time clock and runs continually so no setup is required.
 
Syntax/Parameters CNTMILLI - Increments every millisecond 0-999
CNTSECS -
Increments every second 0-59
CNTMINS -
Increments every minute 0-59
CNTHOURS -
Increments every hour 0-23
CNTDAYS -
Increments every 24 hours
CNTRUN -
Increments every millisecond since system reset. 86,400,000 = 1 day - v47.12.
 
Options

RunTime Counter Interrupts
Wrap-around interrupt for the RunTime counter have been added.
       INT(name,CNTMILLI,function);  // function called every 1000ms
       INT(name,CNTSECS,function);   // function called every 60s
       INT(name,CNTMINS,function);   // function called every 60mins
       INT(name,CNTHOURS,function);  // function called every 24hours
       INT(name,CNTDAYS,function);   // function called every 2^32days
       For timer resolutions of less than a second, use TIMER0 to TIMER9.

 
Example IF(CNTMINS>30?FuncHalfHour);   //if greater than 30 minutes run function called FuncHalfHour
TEXT(MinsText,CNTMINS);;         //update counter value on page and refresh screen
 
Update Information

 Version

 Title

Date  

 Details

49.48

 System Timer Accuracy

21 Nov 13 

Show

* Fixed accuracy of 200us system tick timer - used for incrementing counters CNTRUN, CNTMILLI, ... CNTDAYS, TIMER0-TIMER19, and decrementing WAIT().
* Wrong divider value was being used. Needed to be divider value minus one.
* This resulted in a tick value of 200.174us rather than 200us.
* Assuming a perfect crystal frequency giving a 92,000,000Hz clock then there would be a +0.87ms error for every second.

49.32

 Count per second / 100ms - Added ability to count number of I/O events per second or 100ms.

14 Feb 13 

Show

* Added ability to count number of I/O events per second or 100ms.
* Additional parameters added to KEYIO setup:
cntpersec = \\xxxxxxxx;
cntper100m = \\xxxxxxxx;
* Any I/O port that is enabled with either of these settings result in value of CNTKxx being the number of events received during the last 1 second / 100ms time slot.

49.00

 Interrupts - Fixed problem with interrupts stopping after 255 interrupts

22 Mar 12 

Show

Fixed problem with interrupts stopping after 255 interrupts

49.00

 Error Interrupt Handlers - Code now jumps to error handlers for Prefetch Abort, Data Abort, SWI, and Undefined Interrupts.

22 Mar 12 

Show

Code now jumps to error handlers for Prefetch Abort, Data Abort, SWI, and Undefined Interrupts.

47.12

 Total Run Counter - CNTRUN added which counts milliseconds since startup or reset of RUNTIME counters.

09 Sep 11 

Show

CNTRUN added which counts milliseconds since startup (with no wrapping at 1000ms) or reset of RUNTIME counters.

45.00

 RunTime Counter Interrupts - Wrap-around interrupt for the RunTime counter have been added.

10 Jun 11 

Show

Wrap-around interrupt for the RunTime counter have been added.
INT(name,CNTMILLI,function); // function called every 1000ms
INT(name,CNTSECS,function); // function called every 60s
INT(name,CNTMINS,function); // function called every 60mins
INT(name,CNTHOURS,function); // function called every 24hours
INT(name,CNTDAYS,function); // function called every 2'32days
For timer resolutions of less than a second, use TIMER0 to TIMER9.

41.00

 Introduce 24 I/O-Counters - Added counter on each of K-inputs K00 to K23.

26 Jan 11 

Show

Added counter on each of K-inputs K00 to K23.
These can be accessed as U32 Vars with reserved names CNTK00 to CNTK23.
The count values can be read and tested. RESET(CNTKxx); will clear the counter.

23.00

 CNTMILLI - Runtime counter implemented.

17 Aug 10 

Show

Runtime counter implemented. Access via:
CNTMILLI, CNTSECS, CNTMINS, CNTHOURS, CNTDAYS