OneWireContainer20 Class Reference

Inherits com::dalsemi::onewire::container::OneWireContainer, and com::dalsemi::onewire::container::ADContainer.

List of all members.


Detailed Description

1-Wire® container that encapsulates the functionality of the 1-Wire family type 20 (hex), Maxim Integrated Products part number: DS2450, 1-Wire Quad A/D Converter.

Features

Usage

Example device setup


      byte[] state = owd.readDevice();
      owd.setResolution(OneWireContainer20.CHANNELA, 16, state);
      owd.setResolution(OneWireContainer20.CHANNELB, 8, state);
      owd.setRange(OneWireContainer20.CHANNELA, 5.12, state);
      owd.setRange(OneWireContainer20.CHANNELB, 2.56, state);
      owd.writeDevice();
 

Example device read


      owd.doADConvert(OneWireContainer20.CHANNELA, state);
      owd.doADConvert(OneWireContainer20.CHANNELB, state);
      double chAVolatge = owd.getADVoltage(OneWireContainer20.CHANNELA, state);
      double chBVoltage = owd.getADVoltage(OneWireContainer20.CHANNELB, state);
 

Note

When converting analog voltages to digital, the user of the device must gaurantee that the voltage seen by the channel of the quad A/D does not exceed the selected input range of the device. If this happens, the device will default to reading 0 volts. There is NO way to know if the device is reading a higher than specified voltage or NO voltage.

DataSheet

http://pdfserv.maxim-ic.com/arpdf/DS2450.pdf

Version:
0.00, 28 Aug 2000
Author:
JK,DSS

Public Member Functions

 OneWireContainer20 ()
 Default constructor.
 OneWireContainer20 (DSPortAdapter sourceAdapter, byte[] newAddress)
 Creates a container with a provided adapter object and the address of the 1-Wire device.
 OneWireContainer20 (DSPortAdapter sourceAdapter, long newAddress)
 Creates a container with a provided adapter object and the address of the 1-Wire device.
 OneWireContainer20 (DSPortAdapter sourceAdapter, String newAddress)
 Creates a container with a provided adapter object and the address of the 1-Wire device.
String getName ()
 Gets the name of this 1-Wire device.
String getAlternateNames ()
 Gets any other possible names for this 1-Wire device.
String getDescription ()
 Gets a brief description of the functionality of this 1-Wire device.
int getMaxSpeed ()
 Gets the maximum speed this 1-Wire device can communicate at.
Enumeration getMemoryBanks ()
 Gets an enumeration of memory banks.
int getNumberADChannels ()
 Queries to get the number of channels supported by this A/D.
boolean hasADAlarms ()
 Queries to see if this A/D measuring device has high/low alarms.
double[] getADRanges (int channel)
 Queries to get an array of available ranges for the specified A/D channel.
double[] getADResolutions (int channel, double range)
 Queries to get an array of available resolutions based on the specified range on the specified A/D channel.
boolean canADMultiChannelRead ()
 Queries to see if this A/D supports doing multiple voltage conversions at the same time.
byte[] readDevice () throws OneWireIOException, OneWireException
 Retrieves the entire A/D control/status and alarm pages.
void writeDevice (byte[] state) throws OneWireIOException, OneWireException
 Writes the bytes in the provided A/D register pages that have been changed by the 'set' methods.
double[] getADVoltage (byte[] state) throws OneWireIOException, OneWireException
 Reads the voltage values.
double getADVoltage (int channel, byte[] state) throws OneWireIOException, OneWireException
 Reads a channels voltage value.
void doADConvert (int channel, byte[] state) throws OneWireIOException, OneWireException
 Performs voltage conversion on specified channel.
void doADConvert (boolean[] doConvert, byte[] state) throws OneWireIOException, OneWireException
 Performs voltage conversion on all specified channels.
void doADConvert (int channel, int preset, byte[] state) throws OneWireIOException, OneWireException, IllegalArgumentException
 Performs voltage conversion on specified channel.
void doADConvert (boolean[] doConvert, int[] preset, byte[] state) throws OneWireIOException, OneWireException
 Performs voltage conversion on all specified channels.
double getADAlarm (int channel, int alarmType, byte[] state)
 Extracts the alarm voltage value of the specified channel from the provided state buffer.
boolean getADAlarmEnable (int channel, int alarmType, byte[] state)
 Extracts the alarm enable value of the specified channel from the provided state buffer.
boolean hasADAlarmed (int channel, int alarmType, byte[] state)
 Checks the alarm event value of the specified channel from the provided state buffer.
double getADResolution (int channel, byte[] state)
 Extracts the conversion resolution of the specified channel from the provided state buffer expressed in volts.
double getADRange (int channel, byte[] state)
 Extracts the input voltage range of the specified channel from the provided state buffer.
boolean isOutputEnabled (int channel, byte[] state) throws IllegalArgumentException
 Detects if the output is enabled for the specified channel from the provided register buffer.
boolean getOutputState (int channel, byte[] state) throws IllegalArgumentException
 Detects if the output is enabled for the specified channel from the provided register buffer.
boolean getDevicePOR (byte[] state)
 Detects if this device has seen a Power-On-Reset (POR).
boolean isPowerExternal (byte[] state)
 Extracts the state of the external power indicator from the provided register buffer.
void setADAlarm (int channel, int alarmType, double alarm, byte[] state)
 Sets the alarm voltage value of the specified channel in the provided state buffer.
void setADAlarmEnable (int channel, int alarmType, boolean alarmEnable, byte[] state)
 Sets the alarm enable value of the specified channel in the provided state buffer.
void setADResolution (int channel, double resolution, byte[] state)
 Sets the conversion resolution value for the specified channel in the provided state buffer.
void setADRange (int channel, double range, byte[] state)
 Sets the input range for the specified channel in the provided state buffer.
void setOutput (int channel, boolean outputEnable, boolean outputState, byte[] state)
 Sets the output enable and state for the specified channel in the provided register buffer.
void setPower (boolean external, byte[] state)
 Sets or clears the external power flag in the provided register buffer.

Static Public Member Functions

static double interpretVoltage (long rawVoltage, double range)
 Converts a raw voltage long value for the DS2450 into a valid voltage.
static int voltageToInt (double voltage, double range)
 Converts a voltage double value to the DS2450 specific int value.

Static Public Attributes

static final int BITMAP_OFFSET = 24
 Offset of BITMAP in array returned from read state.
static final int ALARM_OFFSET = 8
 Offset of ALARMS in array returned from read state.
static final int EXPOWER_OFFSET = 20
 Offset of external power offset in array returned from read state.
static final int CHANNELA = 0
 Channel A number.
static final int CHANNELB = 1
 Channel B number.
static final int CHANNELC = 2
 Channel C number.
static final int CHANNELD = 3
 Channel D number.
static final int NO_PRESET = 0
 No preset value.
static final int PRESET_TO_ZEROS = 1
 Preset value to zeros.
static final int PRESET_TO_ONES = 2
 Preset value to ones.
static final int NUM_CHANNELS = 4
 Number of channels.

Constructor & Destructor Documentation

OneWireContainer20 ( DSPortAdapter  sourceAdapter,
byte[]  newAddress 
)

Creates a container with a provided adapter object and the address of the 1-Wire device.

Parameters:
sourceAdapter adapter required to communicate with this device
newAddress address of this 1-Wire device

OneWireContainer20 ( DSPortAdapter  sourceAdapter,
long  newAddress 
)

Creates a container with a provided adapter object and the address of the 1-Wire device.

Parameters:
sourceAdapter adapter required to communicate with this device
newAddress address of this 1-Wire device

OneWireContainer20 ( DSPortAdapter  sourceAdapter,
String  newAddress 
)

Creates a container with a provided adapter object and the address of the 1-Wire device.

Parameters:
sourceAdapter adapter required to communicate with this device
newAddress address of this 1-Wire device


Member Function Documentation

String getName (  ) 

Gets the name of this 1-Wire device.

Returns:
representation of this 1-Wire device's name

Reimplemented from OneWireContainer.

String getAlternateNames (  ) 

Gets any other possible names for this 1-Wire device.

Returns:
representation of this 1-Wire device's other names

Reimplemented from OneWireContainer.

String getDescription (  ) 

Gets a brief description of the functionality of this 1-Wire device.

Returns:
description of this 1-Wire device's functionality

Reimplemented from OneWireContainer.

int getMaxSpeed (  ) 

Gets the maximum speed this 1-Wire device can communicate at.

Returns:
maximum speed of this One-Wire device

Reimplemented from OneWireContainer.

Enumeration getMemoryBanks (  ) 

Gets an enumeration of memory banks.

Returns:
enumeration of memory banks
See also:
com.dalsemi.onewire.container.MemoryBank

com.dalsemi.onewire.container.PagedMemoryBank

com.dalsemi.onewire.container.OTPMemoryBank

Reimplemented from OneWireContainer.

int getNumberADChannels (  ) 

Queries to get the number of channels supported by this A/D.

Channel specific methods will use a channel number specified by an integer from [0 to (getNumberChannels() - 1)].

Returns:
the number of channels

Implements ADContainer.

boolean hasADAlarms (  ) 

Queries to see if this A/D measuring device has high/low alarms.

Returns:
true if it has high/low trips

Implements ADContainer.

double [] getADRanges ( int  channel  ) 

Queries to get an array of available ranges for the specified A/D channel.

Parameters:
channel channel in the range [0 to (getNumberChannels() - 1)]
Returns:
available ranges starting from the largest range to the smallest range

Implements ADContainer.

double [] getADResolutions ( int  channel,
double  range 
)

Queries to get an array of available resolutions based on the specified range on the specified A/D channel.

Parameters:
channel channel in the range [0 to (getNumberChannels() - 1)]
range specified range
Returns:
available resolutions

Implements ADContainer.

boolean canADMultiChannelRead (  ) 

Queries to see if this A/D supports doing multiple voltage conversions at the same time.

Returns:
true if can do multi-channel voltage reads

Implements ADContainer.

byte [] readDevice (  )  throws OneWireIOException, OneWireException

Retrieves the entire A/D control/status and alarm pages.

It reads this and verifies the data with the onboard CRC generator. Use the byte array returned from this method with static utility methods to extract the status, alarm and other register values. Appended to the data is 2 bytes that represent a bitmap of changed bytes. These bytes are used in the writeADRegisters() in conjuction with the 'set' methods to only write back the changed register bytes.

Returns:
register page contents verified with onboard CRC
Exceptions:
OneWireIOException Data was not read correctly
OneWireException Could not find part

Implements OneWireSensor.

void writeDevice ( byte[]  state  )  throws OneWireIOException, OneWireException

Writes the bytes in the provided A/D register pages that have been changed by the 'set' methods.

It knows which state has changed by looking at the bitmap fields appended to the register data. Any alarm flags will be automatically cleared. Only VCC powered indicator byte in physical location 0x1C can be written in the calibration memory bank.

Parameters:
state register pages
Exceptions:
OneWireIOException Data was not written correctly
OneWireException Could not find part

Implements OneWireSensor.

double [] getADVoltage ( byte[]  state  )  throws OneWireIOException, OneWireException

Reads the voltage values.

Must be used after a doADConvert() method call. Also must include the last valid state from the readDevice() method and this A/D must support multi-channel read canMultiChannelRead() if there are more then 1 channel.

Parameters:
state current state of this device returned from readDevice()
Returns:
voltage values for all channels
Exceptions:
OneWireIOException Data was not read correctly
OneWireException Could not find part

Implements ADContainer.

double getADVoltage ( int  channel,
byte[]  state 
) throws OneWireIOException, OneWireException

Reads a channels voltage value.

Must be used after a doADConvert() method call. Also must include the last valid state from the readDevice() method. Note, if more then one channel is to be read then it is more efficient to use the getADVoltage(byte[]) method that returns all channel values.

Parameters:
channel channel in the range [0 to (getNumberChannels() - 1)]
state current state of this device returned from readDevice()
Returns:
voltage value for the specified channel
Exceptions:
OneWireIOException Data was not read correctly
OneWireException Could not find part
IllegalArgumentException Invalid channel number passed

Implements ADContainer.

void doADConvert ( int  channel,
byte[]  state 
) throws OneWireIOException, OneWireException

Performs voltage conversion on specified channel.

The method getADVoltage() can be used to read the result of the conversion.

Parameters:
channel channel in the range [0 to (getNumberChannels() - 1)]
state current state of this device returned from readDevice()
Exceptions:
OneWireIOException Data was not written correctly
OneWireException Could not find part

Implements ADContainer.

void doADConvert ( boolean[]  doConvert,
byte[]  state 
) throws OneWireIOException, OneWireException

Performs voltage conversion on all specified channels.

The method getADVoltage() can be used to read the result of the conversion. This A/D must support multi-channel read canMultiChannelRead() if there are more then 1 channel is specified.

Parameters:
doConvert which channels to perform conversion on.
state current state of this device returned from readDevice()
Exceptions:
OneWireIOException Data was not written correctly
OneWireException Could not find part

Implements ADContainer.

void doADConvert ( int  channel,
int  preset,
byte[]  state 
) throws OneWireIOException, OneWireException, IllegalArgumentException

Performs voltage conversion on specified channel.

The method getADVoltage() can be used to read the result of the conversion.

Parameters:
channel 0,1,2,3 representing the channels A,B,C,D
preset preset value: NO_PRESET (0), PRESET_TO_ZEROS (1), and PRESET_TO_ONES (2)
state state of this device returned from readDevice()
Exceptions:
OneWireIOException Data could not be written correctly
OneWireException Could not find part
IllegalArgumentException Invalid channel number passed

void doADConvert ( boolean[]  doConvert,
int[]  preset,
byte[]  state 
) throws OneWireIOException, OneWireException

Performs voltage conversion on all specified channels.

The method getADVoltage() can be used to read the result of the conversion.

Parameters:
doConvert which channels to perform conversion on
preset preset values NO_PRESET (0), PRESET_TO_ZEROS (1), and PRESET_TO_ONES (2)
state current state of this device returned from readDevice()
Exceptions:
OneWireIOException Data could not be written correctly
OneWireException Could not find part

double getADAlarm ( int  channel,
int  alarmType,
byte[]  state 
)

Extracts the alarm voltage value of the specified channel from the provided state buffer.

The state buffer is retrieved from the readDevice() method.

Parameters:
channel channel in the range [0 to (getNumberChannels() - 1)]
alarmType desired alarm, ALARM_HIGH (1) or ALARM_LOW (0)
state current state of this device returned from readDevice()
Returns:
alarm value in volts
Exceptions:
IllegalArgumentException Invalid channel number passed

Implements ADContainer.

boolean getADAlarmEnable ( int  channel,
int  alarmType,
byte[]  state 
)

Extracts the alarm enable value of the specified channel from the provided state buffer.

The state buffer is retrieved from the readDevice() method.

Parameters:
channel channel in the range [0 to (getNumberChannels() - 1)]
alarmType desired alarm, ALARM_HIGH (1) or ALARM_LOW (0)
state current state of the state returned from readDevice()
Returns:
true if specified alarm is enabled
Exceptions:
IllegalArgumentException Invalid channel number passed

Implements ADContainer.

boolean hasADAlarmed ( int  channel,
int  alarmType,
byte[]  state 
)

Checks the alarm event value of the specified channel from the provided state buffer.

The state buffer is retrieved from the readDevice() method.

Parameters:
channel channel in the range [0 to (getNumberChannels() - 1)]
alarmType desired alarm, ALARM_HIGH (1) or ALARM_LOW (0)
state current state of the state returned from readDevice()
Returns:
true if specified alarm occurred
Exceptions:
IllegalArgumentException Invalid channel number passed

Implements ADContainer.

double getADResolution ( int  channel,
byte[]  state 
)

Extracts the conversion resolution of the specified channel from the provided state buffer expressed in volts.

The state is retrieved from the readDevice() method.

Parameters:
channel channel in the range [0 to (getNumberChannels() - 1)]
state current state of the state returned from readDevice()
Returns:
resolution of channel in volts
Exceptions:
IllegalArgumentException Invalid channel number passed

Implements ADContainer.

double getADRange ( int  channel,
byte[]  state 
)

Extracts the input voltage range of the specified channel from the provided state buffer.

The state buffer is retrieved from the readDevice() method.

Parameters:
channel channel in the range [0 to (getNumberChannels() - 1)]
state current state of the state returned from readDevice()
Returns:
A/D input voltage range
Exceptions:
IllegalArgumentException Invalid channel number passed

Implements ADContainer.

boolean isOutputEnabled ( int  channel,
byte[]  state 
) throws IllegalArgumentException

Detects if the output is enabled for the specified channel from the provided register buffer.

The register buffer is retrieved from the readDevice() method.

Parameters:
channel channel in the range [0 to (getNumberChannels() - 1)]
state current state of the device returned from readDevice()
Returns:
true if output is enabled on specified channel
Exceptions:
IllegalArgumentException Invalid channel number passed

boolean getOutputState ( int  channel,
byte[]  state 
) throws IllegalArgumentException

Detects if the output is enabled for the specified channel from the provided register buffer.

The register buffer is retrieved from the readDevice() method.

Parameters:
channel channel in the range [0 to (getNumberChannels() - 1)]
state current state of the device returned from readDevice()
Returns:
false if output is conducting to ground and true if not conducting
Exceptions:
IllegalArgumentException Invalid channel number passed

boolean getDevicePOR ( byte[]  state  ) 

Detects if this device has seen a Power-On-Reset (POR).

If this has occured it may be necessary to set the state of the device to the desired values. The register buffer is retrieved from the readDevice() method.

Parameters:
state current state of the device returned from readDevice()
Returns:
false if output is conducting to ground and true if not conducting

boolean isPowerExternal ( byte[]  state  ) 

Extracts the state of the external power indicator from the provided register buffer.

Use 'setPower' to set or clear the external power indicator flag. The register buffer is retrieved from the readDevice() method.

Parameters:
state current state of the device returned from readDevice()
Returns:
true if set to external power operation

void setADAlarm ( int  channel,
int  alarmType,
double  alarm,
byte[]  state 
)

Sets the alarm voltage value of the specified channel in the provided state buffer.

The state buffer is retrieved from the readDevice() method. The method writeDevice() must be called to finalize these changes to the device. Note that multiple 'set' methods can be called before one call to writeDevice().

Parameters:
channel channel in the range [0 to (getNumberChannels() - 1)]
alarmType desired alarm, ALARM_HIGH (1) or ALARM_LOW (0)
alarm alarm value (will be reduced to 8 bit resolution)
state current state of this device returned from readDevice()
Exceptions:
IllegalArgumentException Invalid channel number passed

Implements ADContainer.

void setADAlarmEnable ( int  channel,
int  alarmType,
boolean  alarmEnable,
byte[]  state 
)

Sets the alarm enable value of the specified channel in the provided state buffer.

The state buffer is retrieved from the readDevice() method. The method writeDevice() must be called to finalize these changes to the device. Note that multiple 'set' methods can be called before one call to writeDevice().

Parameters:
channel channel in the range [0 to (getNumberChannels() - 1)]
alarmType desired alarm, ALARM_HIGH (1) or ALARM_LOW (0)
alarmEnable alarm enable value
state current state of this device returned from readDevice()
Exceptions:
IllegalArgumentException Invalid channel number passed

Implements ADContainer.

void setADResolution ( int  channel,
double  resolution,
byte[]  state 
)

Sets the conversion resolution value for the specified channel in the provided state buffer.

The state buffer is retrieved from the readDevice() method. The method writeDevice() must be called to finalize these changes to the device. Note that multiple 'set' methods can be called before one call to writeDevice().

Parameters:
channel channel in the range [0 to (getNumberChannels() - 1)]
resolution resolution to use in volts
state current state of this device returned from readDevice()
Exceptions:
IllegalArgumentException Invalid channel number passed

Implements ADContainer.

void setADRange ( int  channel,
double  range,
byte[]  state 
)

Sets the input range for the specified channel in the provided state buffer.

The state buffer is retrieved from the readDevice() method. The method writeDevice() must be called to finalize these changes to the device. Note that multiple 'set' methods can be called before one call to writeDevice().

Parameters:
channel channel in the range [0 to (getNumberChannels() - 1)]
range max volt range, use getRanges() method to get available ranges
state current state of this device returned from readDevice()
Exceptions:
IllegalArgumentException Invalid channel number passed

Implements ADContainer.

void setOutput ( int  channel,
boolean  outputEnable,
boolean  outputState,
byte[]  state 
)

Sets the output enable and state for the specified channel in the provided register buffer.

The register buffer is retrieved from the readDevice() method. The method writeDevice() must be called to finalize these changes to the device. Note that multiple 'set' methods can be called before one call to writeDevice().

Parameters:
channel channel in the range [0 to (getNumberChannels() - 1)]
outputEnable true if output is enabled
outputState false if output is conducting to ground and true if not conducting. This parameter is not used if outputEnable is false
state current state of the device returned from readDevice()

void setPower ( boolean  external,
byte[]  state 
)

Sets or clears the external power flag in the provided register buffer.

The register buffer is retrieved from the readDevice() method. The method writeDevice() must be called to finalize these changes to the device. Note that multiple 'set' methods can be called before one call to writeDevice().

Parameters:
external true if setting external power is used
state current state of this device returned from readDevice()

static double interpretVoltage ( long  rawVoltage,
double  range 
) [static]

Converts a raw voltage long value for the DS2450 into a valid voltage.

Requires the max voltage value.

Parameters:
rawVoltage raw voltage
range max voltage
Returns:
calculated voltage based on the range

static int voltageToInt ( double  voltage,
double  range 
) [static]

Converts a voltage double value to the DS2450 specific int value.

Requires the max voltage value.

Parameters:
voltage voltage
range max voltage
Returns:
the DS2450 voltage


The documentation for this class was generated from the following file:

Generated on Thu Aug 28 15:42:35 2008 for 1-Wire API for .NET by  doxygen 1.5.6