Ctr Function
Returns the counter value of the specified Hardware Input counter.
Syntax
Ctr(bitNumber)
Parameters
- bitNumber
- Number of the Input bit defined in the counter. Only 16 counters can be active at the same time.
Return Values
The current count of the specified Hardware Input Counter. (Integer expression from 0-65535)
Description
Ctr works with the CTReset statement to allow Hardware inputs to be used as counters.
Each time a hardware input specified as a counter is switched from the Off to On state that input causes the counter to increment by 1.
The Ctr function can be used at any time to get the current counter value for any counter input. Any of the Hardware Inputs can be used as counters. However, only 16 counters can be active at the same time.
Counter Pulse Input Timing Chart
See Also
CTReset
Ctr Function Example
The following example shows a sample of code which could be used to get a hardware input counter value.
CTReset 3 'Reset counter for input 3 to 0
On 0 'Turn an output switch on
Wait Ctr(3) >= 5
Off 0 'When 5 input cycles are counted for Input 3 turn switch off (output 0 off)