org.bluemelon.bluesense
Class AdcInputDevice

java.lang.Object
  extended by org.bluemelon.bluesense.Device
      extended by org.bluemelon.bluesense.AdcInputDevice

public class AdcInputDevice
extends Device

Interface to the analog input device BM7003. The BM7003 can be used to convert analogue signals into digital values. The module contains six inputs for different analogue signals. Via software you can configure the resolution of the AD coversion from 1 to 10 bits. The sample rate canbe adjusted in steps of 1 ms to a maximum of 1000 samples per second.


Field Summary
static int ADCINPUT_P1
          Port pin value for pin 1
static int ADCINPUT_P2
          Port pin value for pin 2
static int ADCINPUT_P3
          Port pin value for pin 3
static int ADCINPUT_P4
          Port pin value for pin 4
static int ADCINPUT_P5
          Port pin value for pin 5
static int ADCINPUT_P6
          Port pin value for pin 6
static int INPUT_COUNT
           
static int MAX_RESOLUTION
           
static int MAX_VREF
           
static int PROXY_ID
           
static java.lang.String PROXY_TITLE
           
static int[] SUPPORTS
           
 
Constructor Summary
AdcInputDevice(Master master, int deviceId)
          Creates a 'software' adcinput device with a given id.
 
Method Summary
 boolean configPending()
          Checks if a configuration is being currently being set or being retrieved
 int getChangedInputsMask()
           
 int getCurrentResolution()
          Obtain the last retrieved resolution settings.
 int getCurrentSampleDelay()
          Obtain the last retrieved sample delay settings.
 int getCurrentVoltageReference()
          Obtain the last retrieved voltage reference settings.
 int getLastSampledInput(int port)
          Gets the analog input value of a certain port.
 boolean getRequestGetConfigDone()
          Checks if the configuration request is finished
 boolean getRequestSetConfigDone()
          Checks if the configuration set request is finished
 long getSampleCount()
           
 long getTimeOutUs()
          Returns the current set time out delay.
 void requestGetConfiguration()
          Request to obtain the configuration settings from a adcInput Device.
 void requestSetConfiguration(int voltageReference, int sampleDelay, int resolution)
          Request the adcInput device to set a new reference voltage, sample delay and resolution
 void requestSetResolution(int resolution)
          Requests the adcInput device to set a new sample resolution
 void requestSetSampleDelay(int sampleDelay)
          Requests the adcInput device to set a new sample delay
 void requestSetVoltageReference(int voltageReference)
          Requests the adcInput device to set a new reference voltage
 void setTimeOutUs(int timeOutUs)
          Sets the time out value which is used to check if a request was acknowledged in the set time.
 
Methods inherited from class org.bluemelon.bluesense.Device
addDeviceEventListener, detect, getFirmwareVersion, getId, getType, getTypeName, isAccessible, removeDeviceEventListener
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROXY_TITLE

public static final java.lang.String PROXY_TITLE

PROXY_ID

public static final int PROXY_ID

SUPPORTS

public static final int[] SUPPORTS

INPUT_COUNT

public static final int INPUT_COUNT

MAX_VREF

public static final int MAX_VREF

MAX_RESOLUTION

public static final int MAX_RESOLUTION

ADCINPUT_P1

public static final int ADCINPUT_P1
Port pin value for pin 1


ADCINPUT_P2

public static final int ADCINPUT_P2
Port pin value for pin 2


ADCINPUT_P3

public static final int ADCINPUT_P3
Port pin value for pin 3


ADCINPUT_P4

public static final int ADCINPUT_P4
Port pin value for pin 4


ADCINPUT_P5

public static final int ADCINPUT_P5
Port pin value for pin 5


ADCINPUT_P6

public static final int ADCINPUT_P6
Port pin value for pin 6

Constructor Detail

AdcInputDevice

public AdcInputDevice(Master master,
                      int deviceId)
Creates a 'software' adcinput device with a given id. The device will inacessible until a physical device with the same id is detected.

Parameters:
master -
deviceId -
Method Detail

getLastSampledInput

public int getLastSampledInput(int port)
Gets the analog input value of a certain port.

Parameters:
port - pin port value. @see bsAdcInput_p1
Returns:
the last sampled value

getSampleCount

public long getSampleCount()
Returns:
returns the total number of samples received since the start of the application

getCurrentResolution

public int getCurrentResolution()
Obtain the last retrieved resolution settings.

Returns:
the last retrieved resolution settings

getCurrentSampleDelay

public int getCurrentSampleDelay()
Obtain the last retrieved sample delay settings.

Returns:
the last retrieved sample delay settings

getCurrentVoltageReference

public int getCurrentVoltageReference()
Obtain the last retrieved voltage reference settings.

Returns:
the last retrieved voltage reference settings

configPending

public boolean configPending()
Checks if a configuration is being currently being set or being retrieved

Returns:
1 if busy, 0 if done

getRequestGetConfigDone

public boolean getRequestGetConfigDone()
Checks if the configuration request is finished

Returns:
1 if configuration was retrieved, 0 if still busy

getRequestSetConfigDone

public boolean getRequestSetConfigDone()
Checks if the configuration set request is finished

Returns:
1 if request finished, 0 if request still busy

requestGetConfiguration

public void requestGetConfiguration()
Request to obtain the configuration settings from a adcInput Device.


requestSetConfiguration

public void requestSetConfiguration(int voltageReference,
                                    int sampleDelay,
                                    int resolution)
Request the adcInput device to set a new reference voltage, sample delay and resolution

Parameters:
voltageReference - the new reference voltage in mv, should lie between 1000 and ADC_MAX_VREF. @see ADC_MAX_VREF
sampleDelay - sets the delay in ms (0-65535) between samples.
resolution - the sample resolution in bits, should lie between 1 and BLUESENSE_ADCIN_MAX_RESOLUTION. @see BLUESENSE_ADCIN_MAX_RESOLUTION

requestSetResolution

public void requestSetResolution(int resolution)
Requests the adcInput device to set a new sample resolution

Parameters:
resolution - the sample resolution in bits, should lie between 1 and BLUESENSE_ADCIN_MAX_RESOLUTION. @see BLUESENSE_ADCIN_MAX_RESOLUTION

requestSetSampleDelay

public void requestSetSampleDelay(int sampleDelay)
Requests the adcInput device to set a new sample delay

Parameters:
sampleDelay - sets the delay in ms (0-65535) between samples.

requestSetVoltageReference

public void requestSetVoltageReference(int voltageReference)
Requests the adcInput device to set a new reference voltage

Parameters:
voltageReference - the new reference voltage in mv, should lie between 1000 and ADC_MAX_VREF. @see ADC_MAX_VREF

getTimeOutUs

public long getTimeOutUs()
Returns the current set time out delay. The time out delay is used to check if a request was acknowledged in the set time. If an answer to a request is not received within the set time, the request is resent.

Returns:
the time out value in microseconds.

setTimeOutUs

public void setTimeOutUs(int timeOutUs)
Sets the time out value which is used to check if a request was acknowledged in the set time. If an answer to a request is not received within the set time, the request is resent.

Parameters:
timeOutUs - the value in microseconds which is the maximum duraion between a request and its answer.

getChangedInputsMask

public int getChangedInputsMask()
Returns:
Returns a bit mask indicating which inputs have changed