oCdS Object

Main Index
Object List
Back to top of pageDescription:
 

The oCdS Object is a Hardware Object that uses one I/O line to read a cadmium sulfide photo-resistor, also known as a CdS cell.

It calculates a value based on the amount of light shining on the CdS cell.  The value can be adjusted in such a way that a trip point can be set for a certain amount of light.  In addition, the adjustment can be changed on the fly to provide a Schmitt trigger function.

 The following table lists the size and availability of the oCdS Object.
 ObjectSizeDescriptionA1A2B1B2C1
oCdS5 BytesReads a Sharp GP2D12 IR ranging module.xxx
Back to top of pageOperation:
 

The oCdS Object reads the output signal from a circuit containing a CdS cell and calculates a number that indicates the amount of light that the CdS cell is exposed to.  It is expecting that the CdS cell circuit is attached to the I/O line specified by the IOLine property.

The Level property is updated with the level of light returned by the CdS cell circuit.

As long as the Operate property is 1, the oCdS Object will continually update its Level property with the reading. 

The Adjust property was added in firmware version B.2.0 to allow the input value from the CdS cell circuit to be adjusted.  Each CdS cell returns slightly different readings.  Therefore, when connecting a new CdS cell, the Adjust property needs to be set so that when it is total darkness, the oCdS Object returns a steady reading of 0.  The Adjust property can also be used as a level indicator.  When used this way, when a certain brightness or more of light is reached, the level will read a positive value.  When it is darker the level will be a negative number.

When created, the oCdS Object also creates an instance of the oA2DX object which it uses to read the output signal from the sensor.  The instance of the oA2DX is configured to use a 5 volt reference and modifying that or any other properties of the oA2DX instance will affect the oCdS Object's operation in ways that could make the oCdS Object unable to read the sensor.  See the oA2DX Help for more detail on how analog signals (such as the signal form the CdS cell circuit) are read.

Back to top of pageProperties:

The following table lists the properties of the oCdS Object:

Property

Description

Level
A value that indicates the light level.
Object Class: oPower Value Range: -128 to +127
Data Type: Numeric Default Value: 0
IOLine
A value that specifies which I/O Line is use to read the CdS cell circuit.
Object Class: oIOLineA Value Range: 0 - 7
Data Type: Numeric Default Value: 0
Adjust
A value that specifies a calibration value for the CdS cell circuit.
Object Class: oAdjust Value Range: -128 to +127
Data Type: Numeric Default Value: 0
Availability: This property was added if firmware version B.2.0
Operate
A value that selects whether or not the CdS cell circuit is read.
Object Class: oOperate Value Range: 0 - 1
Data Type: Numeric Default Value: 0
OperateConstantDescription
0cvOffThe CdS cell is not read.
1cvOnThe CdS cell is read.
A2D
The I/O function object used to read the CdS cell circuit.
Object Class: oA2DX Value Range: -128 to +127
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 pageExamples:
 In the following example, the oCdS Object is used.
Visual Basic SyntaxC and Java Syntax
'This program reads a CdS
'cell and outputs the binary
'result on a oDio8.

Dim I As New oCdS  
Dim P As New oDIO8

Sub Main()
  I.IOLine = 1
  I.Operate = 1
  P.IOGroup = 3
  P.Direction = cvOutput
  Do
    P.State = I.Level
  Loop
End Sub
// This program reads a CdS
// cell and outputs the binary
// result on a oDio8.

oCdS I = New oCdS;
oDIO8 P = New oDIO8;

Void Main(Void){
  I.IOLine = 1;
  I.Operate = 1;
  P.IOGroup = 3;
  P.Direction = cvOutput;
  Do{
    P.State = I.Level;
  } While (1);
}
Basic Syntax
'This program reads a CdS
'cell and outputs the binary
'result on a oDio8.

I As oCdS(1,0,cvOn)
P As oDIO8(3,cvOutput)

1:
P.State = I.Level
Goto 1
Back to top of page Connections:
The oCdS uses 1 I/O line.  The I/O line can be any 1 of the analog I/O lines.  As shown, a CdS cell is connected in a circuit with a resistor. 

Note that the value of the resistor can be from 10k ohms to 1k ohms.  Be sure not to use anything less than 1k ohms.  The value of the resistor in combination with the resistance of the CdS cell will determine the value range of the Level property. 

Back to top of page Related Items:
 The following table lists objects with related functions
 ObjectDescriptionA1A2B1B2C1
oUVTronHMReads a Hamamatsu UVTron Flame detector.xxx
Back to top of page Version History and Bug List:
 Firmware Ver B.1.0: Introduced.
Firmware Ver B.2.0: The Adjust property was added.

Bugs: No known bugs.


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