o7Seg Object

Back to top of page Description:
 An o7Seg Object is a Hardware Object that controls the LED segments in a 7-Segment LED Display.  It is capable of setting the segments with a value of 0 through 9 and letters A though F.  In addition, each of the 7 segments and the decimal point are is individually controllable allowing graphical patterns. 

Which number is displayed is controlled by a single value with a range of  0 to 9.  Values of 10 through 15 will display letters of A thought F which allows the display to show hexadecimal numbers.

The o7Seg Object uses eight digital I/O lines to control the 8 LEDs in the display.

 The following table lists the size and availability of the o7Seg Object.
 ObjectSizeDescriptionA1A2B1B2C1
o7Seg5 BytesAn Object that displays a number on a 7-Segment LED display.x
Back to top of page Operation:
 The Value property controls the number shown on the display.  Setting the Value property will cause the individual segments in the display to be set in such a way that they show the number assigned to the Value property.  For example, If the value 1 is written, then segments B and C are turned on while the rest are turned off.  Likewise, if the value 8 is written, then all segments except the Decimal Point are turned on.  When the Value property is read it will return the last value that was written to it. Note that if the segments are manually changed (as described below), the Value property will not reflect the changes.  Instead, the Value property will still read back the last value that was written to it.  The numeric range for the Value property is 0 to 15.  0 through 9 are shown on the display normally, while the values of 10 through 15 are translated to A through F (hexadecimal Numbers). 

Because the Value property can be read or written, it can be used in mathematical operations.  For example, to increase the value displayed, the following code can be used (where D is the name of the o7Seg object.)  :

D.Value = D.Value + 1
D.value++;

Note that because the Value property is treated as a hexadecimal number, then when the value property is currently at 9, adding one will increate its value to 10 which will show the letter "A".

The Segments property contains the actual binary data that specifies which of the LEDs are on and off.  As true with any binary data, bit 0 has a value of 1 while bit 7 has a value of 127.  As noted above, when the Value property is written to, the segments required to display the value are determined and then the Segments property is set to the sum of those values.  For example, If the value 1 is written to the Value property, then segments B and C (which carry the binary values of 2 and 4) are needed, therefore the number 6 is written to the Segments property.  Likewise, the value of the Segments property can be set manually to create any pattern.  The Segments property can also be used in mathematical operations such as right shift creating interesting scrolling patterns.

The binary data contained within the Segments property can also be controlled on a bit by bit basis.  Within the Segments property, each bit is assigned a name that specifies which segment that it controls.  For example, the following code will turn on the "G" segment:

D.Segment.G = 64

The Decimal Point is also controlled in this way.  Note that unlike the other segments, the state of the Decimal Point is not changed when the Value property is written to.

The IOGroup property specifies which group of 8 I/O lines is used to output the data to the segments.  The I/O groups are 8 contiguous I/O Lines beginning at I/O line 8, 16, or 24.  In each group, the first I/O line is considered bit 0 and the last is considered bit 7.

The DIO property is an instance of the oDIO8B object which is created when the o7Seg object is.  The o7Seg object configures the oDIO8B object in such a way that it will control the 7 Segment Display.  Attributes of the display's operation can be adjusted by directly manipulating the oDIO8B object. Note that doing so may change the way the output behaves to something different than the way described in this document.  (see oDIO8B object for more detail)

A dual 7 Segment Display can also be controlled by using the o7Seg2 object.

Back to top of page Properties:

The following table lists the properties of the o7Seg Object:

Property

Description

Value
A value that specifies what number will be shown on the display.
Object Class: oNib Value Range: 0 - 15
Data Type: Numeric Default Value: 0
IOGroup
A value that specifies which group of 8 I/O lines is connected to the Display.
Object Class: oIOGroup Value Range: 0 - 3
Data Type: Numeric Default Value: 0
Some I/O Lines have special purposes.  Be sure to see oIOGroup for details.
Segments
The raw binary value used to control the Individual LED Segments
Object Class: oCharSegments Value Range: 0 - 255
Data Type: Numeric Default Value: 0
Operate
A value that selects if the display is on or off.
Object Class: oOperate Value Range: 0 - 1
Data Type: Numeric Default Value: 0
OperateConstantDescription
0cvOffThe display is off.
1cvOnThe display is on.
DIO
The I/O function object that controls the output
Object Class: oDIO8B Value Range: 0 - 255
Data Type: Numeric Default Value: 0
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 Example:

The following examples use the o7Seg Object.
Visual Basic SyntaxC and Java Syntax
' This program counts down 
' from whatever number B is
' assigned to and shows that
' number on a 7Seg display.
' When the countdown is done,
' I/O line 8 is turned on.

Dim A As New oCountDown 
Dim B As New o7Seg
Dim C As New oDIO1
Dim W As New oWire

Sub Main()
  B.IOGroup = 3
  B.Operate.TurnOn
  C.IOLine = 8
  C.Direction = cvOutput
  W.Input.Link(A.NonZero)
  W.InvertIn = cvTrue
  W.Output.Link(C)
  W.Operate = cvTrue
  A.Output.Link(B)
  A.PreScale = 59
  A.ClockIn.Link(ooPIC.Hz60)
  A.Operate = 1
  B = 5
  ooPIC.Delay = 10000
  B = 6
End Sub 
// This program counts down
// from whatever number B is
// assigned to and shows that
// number on a 7Seg display.
// When the countdown is done,
// I/O line 8 is turned on.

oCountDown A = New oCountDown;
o7Seg B = New o7Seg;
oDIO1 C = New oDIO1;
oWire W = New oWire;

Void Main(Void){
  B.IOGroup = 3;
  B.Operate.TurnOn;
  C.IOLine = 8;
  C.Direction = cvOutput;
  W.Input.Link(A.NonZero);
  W.InvertIn = cvTrue;
  W.Output.Link(C);
  W.Operate = cvTrue;
  A.Output.Link(B);
  A.PreScale = 59;
  A.ClockIn.Link(ooPIC.Hz60);
  A.Operate = 1;
  B = 5;
  ooPIC.Delay = 10000;
  B = 6;
} 
Basic Syntax 
' This program counts down 
' from whatever number B is
' assigned to and shows that
' number on a 7Seg display.
' When the countdown is done,
' I/O line 8 is turned on.

Dim A As New oCountDown(,,59,,cvOn)
Dim B As New o7Seg(3,0,cvOn)
Dim C As New oDIO1(8,cvOutput)
Dim W As New oWire(,cvTrue,,cvOn)

W.Input.Link(A.NonZero)
W.Output.Link(C)
A.Output.Link(B)
A.ClockIn.Link(ooPIC.Hz60)
B = 5
ooPIC.Delay = 10000
B = 6
 
Back to top of pageConnections:
 A 7-Segment LED Display uses 8 contiguous I/O lines.  These 8 I/O Lines are specified with the IOGroup property.  Each I/O line needs to be attached to a resistor and then to the appropriate pin on the display.
7 Segment LED Display.

Back to top of page Related Items:

 The following table lists objects that use the o7Seg Object.
 ObjectDescriptionA1A2B1B2C1
o7Seg2An Object that displays a number on a Dual 7-Segment LED display.x
 The following table lists objects with related functions
 ObjectDescriptionA1A2B1B2C1
oLCDControls a LCD Display.xxx
oVideoICControls an Intuitive Circuits On-Screen Display Character Overlay board.xxx
Back to top of page Version History and Bug List:
 Firmware Ver C1: Introduced.

Bugs: No known bugs.


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