oCycleTimeL Object

Main Index
Object List
Back to top of page Description:
 Measures the cycle time of an low-frequency input on any I/O line.

The oCycleTimeL Object is capable of measuring the approximate frequency of a square wave input with a frequency of up to 283Hz.  (see note)

Typical applications are bicycle speedometers or any other application that provides a low-frequency square wave.  The Hamamatsu UVTron Flame detector also outputs a signal that can be read by this object. (see related items)

 The following table lists the size and availability of the oCycleTimeL Object.
 ObjectSizeDescriptionA1A2B1B2C1
oCycleTimeL6 BytesMeasures the cycle time of an low-frequency input on any I/O line.xxx
Back to top of page Operation:
 

When the Operate property is 1, the oCycleTimeL Object monitors the I/O line specified by the IOLine property for a high-going transition.  When the input transitions to a high state, a counter is started at 255.  The counter will then decrement at a rate of 283Hz.  When the next high-going transition occurs, the count is copied to the duration property and the process starts again.

If no high-going pulses are detected, or the high-going pulses are more than ~0.9 seconds apart, the counter will eventually count down to 0 at which time the counter stops.  Thus, a cycle time of longer than approximately 0.9 seconds will read 0.

The Duration property is calculated from the following formula: Duration = (256 - (283 / Frequency))
Inversely, the Frequency can be calculated from the Duration: Frequency = (283 / (256-Duration))

Note that the Duration is not a linear property.  As the frequency goes up, the Duration increases at a quicker rate.  Thusly, while the the oCycleTimeL Object is capable of measuring a frequency of up to 283hz, it is best at measuring frequencies below 5Hz.  (See Duration property table)

If the input has a frequency of more than 283hz then the high going pulses will happen before the counter gets to decrement one time.  Thus, a cycle time shorter than approximately 0.0035 seconds will read 255.

Back to top of page Properties:

The following table lists the properties of the oCycleTimeL Object:

Property

Description

Duration
A value that indicates the current duration of one cycle.
Object Class: oByte Value Range: 0 - 255
Data Type: Numeric Default Value: 0
Determines the duration using the following formula: Duration = [256 - (283 / Frequency)
DurationDescription
0The cycle duration is greater than ~0.9 seconds.
1The cycle duration is ~0.90 seconds. (1.105hz)
2The cycle duration is ~0.89 seconds. (1.110hz)
3-252The cycle duration is between ~0.89 and ~0.014 seconds.
253The cycle duration is ~0.014 seconds. (94.33Hz)
254The cycle duration is ~0.007 seconds. (141Hz)
255The cycle duration is ~0.0035 seconds (283Hz) or less.
IOLine
A value that specifies which I/O Line to use for the frequency input.
Object Class: oIOLine Value Range: 0 - 31
Data Type: Numeric Default Value: 0
Some I/O Lines have special purposes.  Be sure to see oIOLine help file for details.
Operate
A value that selects whether or not the cycle duration is measured.
Object Class: oOperate Value Range: 0 - 1
Data Type: Numeric Default Value: 0
OperateConstantDescription
0cvOffThe cycle duration is not measured.
1cvOnThe cycle duration is measured.
Address
Returns a pointer to the address of the oCounter Object instance.
Object Class: oAddress Value Range: 0 - 127
Data Type:Pointer (Read Only) Default Value: Address of Object

Back to top of page Examples:
 In the following example, the oCycleTimeL Object is used.
Visual Basic SyntaxC and Java Syntax
'This program reads the cycle 
'time of an input on I/O line
'1 and outputs the duration 
'on I/O lines 8 - 15.

Dim A As New oCycleTimeL 
Dim B As New oDIO8
Dim C As New oDIO1

Sub Main()
  A.IOLine = 1
  A.Operate = cvTrue
  B.IOGroup = 1
  B.Direction = cvOutput
  C.IOLine = 31
  C.Direction = cvOutput
  Do
    B.State = A.Duration
    C.State = A.Duration.NonZero
  Loop
End Sub 
//This program reads the cycle 
//time of an input on I/O line
//1 and outputs the duration 
//on I/O lines 8 - 15.

oCycleTimeL A = New oCycleTimeL ;
oDIO8 B = New oDIO8;
oDIO1 C = New oDIO1;

Void Main(Void){
  A.IOLine = 1;
  A.Operate = cvTrue;
  B.IOGroup = 1;
  B.Direction = cvOutput;
  C.IOLine = 31;
  C.Direction = cvOutput;
  Do{
    B.State = A.Duration;
    C.State = A.Duration.NonZero;
  } While (1)
}
Basic Syntax 
'This program reads the cycle 
'time of an input on I/O line
'1 and outputs the duration 
'on I/O lines 8 - 15.

A As oCycleTimeL 
B As oDIO8(1,cvOutput)
C As oDIO1(31,cvOutput)

A.IOLine = 1
A.Operate = cvTrue

Do
  B.State = A.Duration
  C.State = A.Duration.NonZero
Loop

Back to top of page Related Items:

 The following table lists objects that use the oCycleTimeL Object.
 ObjectDescriptionA1A2B1B2C1
oSpeedOMeterReads a Speedometer.xxx
oUVTronHMReads a Hamamatsu UVTron Flame detector.xxx
 The following table lists objects with related functions
 ObjectDescriptionA1A2B1B2C1
oFeedBack1TMeasures the time interval between a signal sent on one I/O line and returned on a second I/O line.xxx
Back to top of page Version History and Bug List:
 Firmware Ver B1: Introduced.

Bugs: No known bugs.


ooPIC Compiler Ver 6.0 (c) Copyright 1997 - 2007 Savage Innovations, LLC.