oFreqL Object

Back to top of page Description:
 A Hardware Object that generates and outputs a low frequency tone.
 The following table lists the size and availability of the oFreqL Object.
 ObjectSizeDescriptionA1A2B1B2C1
oFreqL5 BytesAn Object that outputs a low frequency square wave on any I/O line.xxx
Back to top of page Operation:
 

When the Operate property is 1, the oFreqL Object cycles the I/O line specified by the IOLine property at a rate specified by the Divisor property.  

The Rate property is a clock divider value that specifies the frequency.  The Frequency is derived from a 1,132kHz clock divided by 128 minus the value of the Rate property. [Frequency = 1132/(128-Rate)]  For example, a Divisor of 120 will produce a frequency of 141.5Hz. [141.5 = (1132/(128-120))]  If 0 is given as the Divisor, then the output is shut off.  This is useful for some rudimentary low frequencies.  If you need a higher frequency, see the oFreqH object.  if you want music, see the oSoundgin object. 

The Rate can be calculated for the desired frequency using the following formula: Rate  = [128 - (1132 / Frequency)

The lowest frequency that can be generated is 8.913Hz  [8.913 = (1132/(128-1))]
The highest frequency that can be generated is 1132Hz  [1132 = (1132/(128-127))]

Note that the frequencies are not linear.  This will be most noticeable at the higher frequencies. 
(1132/1=1132Hz, 1132/2=566hz). 

The actual output is done by inverting the state of the I/O Line.  The result is a square wave output at the specified frequency.  If two or more oFreqL Objects are set to the same I/O line, the output is effectively the two tones combined.

The oFreqL Object's output shares its timing with the rest of the ooPIC's multitasking objects.  A large number of Objects running concurrently with the oFreqL Object can result in distortions on the higher frequency tones.

Back to top of page Properties:

The following table lists the properties of the oFreqL Object:

Property

Description

Rate
A value that specifies a 7-Bit divisor to a fixed frequency of 1132 kHz.
Object Class: oByte Value Range: 0 - 127 (MSB of byte not used)
Data Type: Numeric Default Value: 0
Determines the frequency using the following formula: Frequency = (1132/(128-Rate)
RateDescription
0The square wave is disabled.
1The square wave is generated at 8.913Hz.
2The square wave is generated at 8.984Hz.
3-125The square wave is generated at the specified frequency.
126The square wave is generated at 566Hz.
127The square wave is generated at 1132Hz.
IOLine
A value that specifies which I/O Line to output the square wave on.
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 square wave is outputted.
Object Class: oOperate Value Range: 0 - 1
Data Type: Numeric Default Value: 0
OperateConstantDescription
0cvOffThe square wave is disabled.
1cvOnThe square wave is generated and outputted.
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 examples, the oFreqL Object is used.
' Produce an alarm every 
'  two seconds.

Dim T As New oFreqL

Sub Main()
  T.IOLine = 21
  Do
    Call Alarm
    ooPIC.Delay = 200
  Loop
End Sub

Sub Alarm()
  T.Operate = 1    
  Do 5 Times
    T.Divisor = 120
    ooPIC.Delay = 3
    T.Divisor = 117
    ooPIC.Delay = 3
  Loop
  T.Operate = 0
End Sub
' Combine 2 tones

Dim T As New oFreqL
Dim G As New oFreqL

Sub Main()
  T.IOLine = 21
  T.Divisor = 113
  T.Operate = 1
  G.IOLine = 21
  G.Divisor = 127
  G.Operate = 1
  Do 
    ooPIC.Delay = 15
    G.Operate = 0
    ooPIC.Delay = 15 
    G.Operate = 1
    G = G - 1
  Loop
End Sub

Back to top of page Related Items:

 The following table lists objects that use the oFreqL Object.
 ObjectDescriptionA1A2B1B2C1
oToneAn Object that outputs a tone.xxx
 The following table lists objects with related functions
 ObjectDescriptionA1A2B1B2C1
oFreqHOutputs a high frequency square wave using hardware specific I/O lines.xx
oClockProvides a programmable logic clockxxx
oSoundginControls a Soundgin Sound Effects Engine / Voice Synthesizer chip.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.