Analog Class¶
- class AnalogClass : public EntityClass¶
The AnalogClass is the interface to analog entities on BrainStem modules. Analog entities may be configured as a input or output depending on hardware capabilities. Some modules are capable of providing actual voltage readings, while other simply return the raw analog-to-digital converter (ADC) output value. The resolution of the voltage or number of useful bits is also hardware dependent.
Public Functions
- AnalogClass()¶
Constructors.
- ~AnalogClass()¶
Destructor.
- !AnalogClass ()
Finalizer.
- void init (BrainStem2CLI::ModuleClass^ module, const unsigned char index)
Initializes the class. Should only be called when manually creating classes.
- Parameters:
pModule – The module.
index – The cmdANALOG index to be addressed.
- aErr getValue(unsigned short %value)¶
Get the raw ADC output value in bits.
Note
Not all modules are provide 16 useful bits; this value’s least significant bits are zero-padded to 16 bits. Refer to the module’s datasheet to determine analog bit depth and reference voltage.
- Parameters:
value – 16 bit analog reading with 0 corresponding to the negative analog voltage reference and 0xFFFF corresponding to the positive analog voltage reference.
- Returns:
Returns common entity return values
- aErr setValue(const unsigned short value)¶
Set the value of an analog output (DAC) in bits.
Note
Not all modules are provide 16 useful bits; the least significant bits are discarded. E.g. for a 10 bit DAC, 0xFFC0 to 0x0040 is the useful range. Refer to the module’s datasheet to determine analog bit depth and reference voltage.
- Parameters:
value – 16 bit analog set point with 0 corresponding to the negative analog voltage reference and 0xFFFF corresponding to the positive analog voltage reference.
- Returns:
Returns common entity return values
- aErr getVoltage(int %microvolts)¶
Get the scaled micro volt value with refrence to ground.
Note
Not all modules provide 32 bits of accuracy; Refer to the module’s datasheet to determine the analog bit depth and reference voltage.
- Parameters:
microvolts – 32 bit signed integer (in microvolts) based on the board’s ground and reference voltages.
- Returns:
Returns common entity return values
- aErr setVoltage(const int microvolts)¶
Set the voltage level of an analog output (DAC) in microvolts.
Note
Voltage range is dependent on the specific DAC channel range.
- Parameters:
microvolts – 32 bit signed integer (in microvolts) based on the board’s ground and reference voltages.
- Returns:
Returns common entity return values
- aErr getEnable(unsigned char %enable)¶
Get the analog output enable status.
- Parameters:
enable – 0 if disabled 1 if enabled.
- Returns:
Returns common entity return values
- aErr setEnable(const unsigned char enable)¶
Set the analog output enable state.
- Parameters:
enable – set 1 to enable or 0 to disable.
- Returns:
Returns common entity return values
- aErr getRange(unsigned char %range)¶
Get the analog input range.
- Parameters:
range – 8 bit value corresponding to a discrete range option
- Returns:
Returns common entity return values
- aErr setRange(const unsigned char range)¶
Set the analog input range.
- Parameters:
range – 8 bit value corresponding to a discrete range option
- Returns:
Returns common entity return values
- aErr getConfiguration(unsigned char %configuration)¶
Get the analog configuration.
- Parameters:
configuration – - Current configuration of the analog entity.
- Returns:
Returns common entity return values
- aErr setConfiguration(const unsigned char configuration)¶
Set the analog configuration.
- Parameters:
configuration – - bitAnalogConfigurationOutput configures the analog entity as an output.
- Return values:
aErrConfiguration – - Entity does not support this configuration.
- Returns:
EntityReturnValues “common entity” return values
- aErr getBulkCaptureSampleRate(unsigned int %value)¶
Get the current sample rate setting for this analog when bulk capturing.
- Parameters:
value – upon success filled with current sample rate in samples per second (Hertz).
- Returns:
Returns common entity return values
- aErr setBulkCaptureSampleRate(const unsigned int value)¶
Set the sample rate for this analog when bulk capturing.
- Parameters:
value – sample rate in samples per second (Hertz). Minimum rate: 7,000 Hz Maximum rate: 200,000 Hz
- Returns:
Returns common entity return values
- aErr getBulkCaptureNumberOfSamples(unsigned int %value)¶
get the current number of samples setting for this analog when bulk capturing.
- Parameters:
value – number of samples.
- Returns:
Returns common entity return values
- aErr setBulkCaptureNumberOfSamples(const unsigned int value)¶
Set the number of samples to capture for this analog when bulk capturing.
- Parameters:
value – number of samples. Minimum # of Samples: 0 Maximum # of Samples: (BRAINSTEM_RAM_SLOT_SIZE / 2) = (3FFF / 2) = 1FFF = 8191
- Returns:
Returns common entity return values
- aErr initiateBulkCapture(void)¶
Initiate a BulkCapture on this analog. Captured measurements are stored in the module’s RAM store (RAM_STORE) slot 0. Data is stored in a contiguous unsigned char array with each sample stored in two consecutive bytes, LSB first.
- Returns:
Returns common entity return values. When the bulk capture is complete getBulkCaptureState() will return either bulkCaptureFinished or bulkCaptureError.
- aErr getBulkCaptureState(unsigned char %state)¶
get the current bulk capture state for this analog.
- Parameters:
state – the state of bulk capture.
Idle: bulkCaptureIdle = 0
Pending: bulkCapturePending = 1
Finished: bulkCaptureFinished = 2
Error: bulkCaptureError = 3
- Returns:
Returns common entity return values