Analog In
- class
analogIn.
AnalogIn
Bases:
Schedule
Class which contains the ADC features.
These functions should only be called from your device’s
adc
parameter:my_device.adc.function()
. The functions below are used to configure and use Analog In of your VPixx Device.getBaseAddress
()Gets the Ram buffer start address.
This method allows the user to get the RAM buffer start address used in schedules. It should only be used if the user wants the schedules to wrap when it has reached its maximum size. When schedules are expected to wrap, the user should also use setBufferSize()
Returns: Any value in a range of 0 up to the RAM size.
Return type: int
getBufferSize
()Gets the Ram buffer size.
This method allows the user to get the RAM buffer size used in schedules.
Returns: Any value in a range of 0 up to the RAM size.
Return type: int
getChannelRange
(channel)Gets the range of a channel.
Returns: Range of the channel. The returned value is a tuple with the minimum range followed by the maximum range. Both values are integers.
Return type: tuple
getChannelReference
(channel)Gets the reference associated with a channel.
Parameters: channel (int) – channel to query.
Returns: one of the following predefined constants.
-
gnd : Referenced to ground.
-
diff : Referenced to adjacent analog input.
-
ref0 : Referenced to REF0 analog input.
-
ref1 : Referenced to REF1 analog input.
Return type: String
See also
-
getChannelValue
(channel)Gets the current value of a channel.
This method allows the user to know the value of a given channel. The return value is a 16-bit 2’s complement signed number. Value can be obtained for channels 0 to 17.
Returns: value of the channel.
Return type: int
getChannelVoltage
(channel)Gets the current voltage of a channel.
Returns: voltage of the channel.
Return type: float
getNbrOfChannel
()Gets the number of channels available.
Returns: Number of channels.
Return type: int
getScheduleCount
()Gets the schedule count value.
This method allows the user to get the current count for a schedule.
Returns: Any positive value equal to or greater than 0.
Return type: int
See also
getScheduleOnset
()Gets the schedule onset value.
This method allows the user to get the schedule onset value used in schedules. The onset represents a nanosecond delay between schedule start and first sample.
Returns: Any positive value equal to or greater than 0.
Return type: int
getScheduleRate
()Gets the schedule rate value.
This method allows the user to get the schedule rate value used in schedules. The rate represents the speed at which the schedule updates.
Returns: Any positive value equal to or greater than 0.
Return type: int
getScheduleUnit
()Gets the schedule unit value.
This method allows the user to get the schedule unit value used in schedules.
Returns: Any positive value equal to or greater than 0.
Return type: int
See also
getStatus
(inDict)Updates the information dictionary for the ADC schedule.
Parameters: inDict (dict) – The dictionary returned by the schedule setup
- Updates the dictionary with the following information:
-
“dacAdcLoopback” is True if ADC inputs are driven internally by DAC outputs, or False if ADC inputs report real analog inputs. “freeRunning” is True if ADC hardware is sampling continuously, or False if it only samples on ADC acquisition schedule ticks. “scheduleRunning” is True if the analog acquisition schedule is currently running, or False if stopped. “scheduleOnset” is the programmed delay in seconds between StartAdcSchedule execution, and the first ADC sample acquisition. “scheduleRate” is the rate at which subsequent ADC samples are acquired. “scheduleRateUnits” is the programmed units of scheduleRate: “Hz” is samples per second, “video” is samples per video frame, “nano” is seconds per sample “numAdcSchedChans” is the number of ADC channels scheduled for acquisition. “channelList” is the list of channels and their reference, if enabled. “bufferBaseAddress” is the acquisition data buffer base address within the Datapixx. “bufferSize” is the number of bytes in the acquisition data buffer. “numBufferFrames” is the total number of samples which fit in the acquisition data buffer. “currentWriteFrame” is the buffer frame which will be written by the next acquired ADC sample. “currentReadFrame” is the buffer frame which will be read by the next streaming call to ReadAdcBuffer. “newBufferFrames” = currentWriteFrame - currentReadFrame. This is the maximum number of frames which can be read by the next call to ReadAdcBuffer in streaming mode, without causing a streaming underflow. “maxScheduleFrames”, if non-0, is the value of currentWriteFrame which will automatically stop the schedule.
getWriteAddress
()Gets the Ram buffer write address.
This method allows the user to get the RAM buffer write address used in schedules.
Returns: Any value in a range of 0 up to the RAM size.
Return type: int
isChannelRamBuffering
(channel)Verifies the ram buffering mode.
This method allows the user to know if a ram buffering is enabled for a given channel.
Parameters: channel (int) – Channel number to query.
Returns: True if the given channel is buffered, False otherwise.
Return type: Bool
See also
isCountDownEnabled
()Verifies the schedule count down mode.
Returns: True if the schedule is decrementing at every sample, False otherwise.
Return type: Bool
See also
isFreeRunEnabled
()Verifies the continuous acquisition mode state.
Returns: True if continuous acquisition is activated, False otherwise.
Return type: Bool
See also
isHardwareCalibration
()Verifies the hardware calibration mode.
Returns: True if hardware calibration is enabled, False otherwise.
Return type: Bool
See also
isLogTimetagsEnabled
()Verifies if the timetag mode is enabled.
Returns: True if timetag mode is enabled, False otherwise.
Return type: Bool
See also
isLoopbackEnabled
()Verifies the digital inputs and outputs loop back mode.
Returns: True if transitions are being stabilized, False otherwise.
Return type: Bool
See also
isScheduleRunning
()Verifies if a schedule is currently running on the subsystem.
Returns: True if a schedule is currently running, False otherwise.
Return type: Bool
See also
readBuffer
(inDict, numFrames=0, customReadAddr=None)Reads data from the ADC buffer.
Parameters: -
inDict (dict) – The dictionary returned by the schedule setup
-
numFrames (int) – Number of frames of information to retrieve from the ADC buffer. Leave to 0 to read the full buffer, which is the default argument.
-
customReadAddr (int) – The byte address in Datapixx RAM where the buffered data can be found. If this argument is not provided, it will take on the value of bufferBaseAddress passed to the last call to SetAdcSchedule. Specifying abufferAddress of -1 will cause data to be streamed from the buffer which was defined in the last call to SetAdcSchedule.
Returns: Returns a tuple of list, where the first one is the data and the second one are its timetags. The data will be nChan*numFrames, where nChan is the number of channels activated for recording.
Return type: [data], [timetag] (list,list)
See also
DPxEnableAdcSchedCountdown
,DPxSetAdcSchedule
-
setBaseAddress
(address)Sets the Ram buffer start address.
This method allows the user to set the RAM buffer start address used in schedules. The given address must be an even value.
Parameters: address (int) – Any value in a range of 0 up to the RAM size.
setBufferSize
(buffer_size)Sets the Ram buffer size.
This method allows the user to set the RAM buffer size used in schedules. It should only be used if the user wants the schedules to wrap when it has reached its maximum size. When schedules are expected to wrap, the user should also use
setBaseAddress()
. The given size is in bytes and must be an even value.Parameters: buffer_size (int) – Any value in a range of 0 up to the RAM size.
setChannelRamBuffering
(enable, channel=None)Sets the ram buffering mode.
This method allows the user to enable or disable ram buffering on a given channel. When enabled, a given channel is buffered in ram. Enabling RAM buffering can only be done for channels 0 to 15.
Parameters: -
enable (Bool) – True if hardware calibration is enabled, False otherwise.
-
channel (int) – Channel number to enable or disable. Passing None will set all channels.
See also
-
setChannelReference
(channel, reference)Sets a reference to a channel.
This method allows the user to enable or disable ram buffering on a given channel. When enabled, a given channel is buffered in ram. Enabling RAM buffering can only be done for channels 0 to 15.
Parameters: -
channel (int) – Channel number to associate with a reference.
-
reference (String) –
Valid argument is one of the following predefined constants.
-
gnd : Referenced to ground.
-
diff : Referenced to adjacent analog input.
-
ref0 : Referenced to REF0 analog input.
-
ref1 : Referenced to REF1 analog input.
-
See also
-
setFreeRunMode
(enable)Sets the continuous acquisition mode.
This method allows the user to enable or disable the continuous acquisition (free running) mode. When enabled, the ADCs convert continuously. Doing so can add up to 4 microseconds random latency to scheduled samples. When disabled, the ADCs only convert on schedule ticks. This can be used for microsecond-precise sampling.
Parameters: enable (Bool) – True if loopback is enabled, False otherwise.
See also
setHardwareCalibration
(enable)Sets the hardware calibration mode.
This method allows the user to enable or disable the hardware calibration mode. When enabled, the ADC data bypasses the hardware calibration. When disabled, the ADC data passes by the hardware calibration.
Parameters: enable (Bool) – True if hardware calibration is enabled, False otherwise.
See also
setLogTimetags
(enable)Sets the timetag mode on the data samples.
This method allows the user to enable or disable the timetag on acquired data. When enabled, each buffered sample is preceded with a 64-bit nanosecond timetag. When disabled, buffered data has no timetags.
Parameters: enable (Bool) – True to activate the timetag mode, False otherwise.
See also
setLoopback
(enable)Sets the digital inputs and outputs loopback mode.
This method allows the user to enable or disable the loopback between digital output ports and digital inputs. When enabled, the digital outputs send their data to the digital inputs. When disabled, the digital inputs will not get the digital outputs data.
Parameters: enable (Bool) – True if loopback is enabled, False otherwise.
See also
setSchedule
(onSet, rateValue, rateUnits, maxScheduleFrames, channelList=None, bufferBaseAddr=4000000.0, numberBufferFrames=None)Configure a schedule for autonomous ADC analog signal acquisition.
This function is used to fully setup an acquisition schedule on the device. Regardless of the actual format chosen, the resulting sample rate cannot exceed 200 kHz. It returns a dictionary that is needed when reading data or updating the buffer. Use ReadAdcBuffer to upload the acquired data from this address after calling StartAdcSchedule. Note that every call to StartAdcSchedule must be preceeded by a call to SetAdcSchedule (ie: multiple calls to StartAdcSchedule each require their own call to SetAdcSchedule).
Parameters: -
onSet (float) – The desired delay (in double precision seconds) between schedule initiation, and the first ADC sample acquisition.
-
rateValue (int) – The rate at which the ADC’s acquire successive samples.
-
rateUnits (str) – This can have three values: “Hz” for samples/seconds, “video” for samples/video frame or “nano” for seconds/samples
-
maxScheduleFrames (int) – If the dataset has a known length, then maxScheduleFrames should be that number. If it is a dynamic length, pass 0.
-
channelList (list) – The channelList can have two formats, a list of the channels you want to use, or a list of the channels you want to use in the first row, and the 2nd row contains the differential. The first row of the list contains 1 or more integers in the range 0 to GetAdcNumChannels-1. This is the list of ADC channels which will be acquired. The second row of the matrix indicates the differential voltage references for each acquired channel. The list must have this format: [[chanNum, ref]…] or 1D list [chanNum, chanNum2, …]. The reference is selected using a string with value “gnd”, “diff”, “ref0” or “ref1”. Code “gnd” is used when no differential subtraction is required during acquisition. All analog inputs are referenced to ground, also known as single-ended acquisition. Code “diff” implements fully differential inputs, subtracting the adjacent channel’s voltage before acquiring (eg: acquiring ADC0 with code = “diff” would subtract the ADC1 voltage from the ADC0 voltage, writing the result to the acquisition buffer). When using this mode, data is typically acquired only on the even channels, effectively halving the number of available channels. Code “ref0” implements a differential input referenced to the REF0 analog input (see the Datapixx user manual for pinouts). This has the benefits of high-impedance differential inputs, without having to sacrifice half of the channels as with fully differential inputs. Code “ref1” implements a differential input referenced to the REF1 analog input. It is possible to use different codes for different analog channels in a single acquisition schedule. For example ADC0 and ADC1 could be acquired single-ended while ADC2 is referenced to ADC3, and ADC4/5/6/7 could be referenced to REF0. It is also possible to pass only a single row of ADC channels to channelList. In this case, all of the ADC channels will be acquired single-ended.
-
bufferBaseAddress (int) – The start of the RAM buffer which should hold the acquired data inside the Datapixx. Default value is 4e6.
-
numBufferFrames (int) – Specifies the desired size of the acquisition buffer in the Datapixx RAM. Default value of maxScheduleFrames. If maxScheduleFrames is larger than numBufferFrames (or 0), then each time the acquisition frame counter reaches a multiple of numBufferFrames, the acquisition buffer address automatically wraps back to bufferBaseAddress. This circular buffer effect can be used for acquiring arbitrarily long analog datasets. Simply monitor newBufferFrames returned by GetAdcStatus, and use ReadAdcBuffer in streaming mode to upload newly acquired data from the Datapixx RAM to the host.
Returns: Returns a dictionary which has some global information which must be passed to other ADC functions.
Return type: AdcDictionary (dict)
-
setScheduleCount
(count)Sets the schedule count.
This method allows the user to set the schedule count for a schedule with a fixed number of samples. In which case, the schedule will decrement at a given rate and stop when the count reaches 0.
Parameters: count (int) – Any positive value greater than 0.
See also
setScheduleCountDown
(enable)Sets the schedule count down mode.
This method allows the user to enable or disable the count down on a schedule. When enabled, the schedule decrements at the given rate and stops automatically when the count hits 0. When disabled, the schedule increments at the given rate and is stopped by calling stopSchedule().
Parameters: enable (Bool) – True if count down is enabled, False otherwise.
See also
setScheduleOnset
(onset)Sets the schedule onset value.
This method allows the user to set the nanosecond delay between schedule start and first sample. If no delay is required, this method does not need to be used. Default value is 0.
Parameters: onset (int) – Any positive value equal to or greater than 0.
setScheduleRate
(rate, unit='hz')Sets the schedule rate.
This method allows the user to set the schedule rate. Since the rate can be given with different units, the method also needs to have a unit associated with the rate.
nanosecond delay between schedule start and first sample. If no delay is required, this method does not need to be used. Default value is 0.
Parameters: -
rate (int) – Any positive value equal to or greater than 0.
-
unit (String) –
Any of the following predefined constants:
-
hz : samples per second, maximum 200 kHz.
-
video : samples per video frame, maximum 200 kHz.
-
nano : sample period in nanoseconds, minimum 5000 ns.
-
-
setWriteAddress
(address)Sets the Ram buffer write address.
This method allows the user to set the RAM buffer write address used in schedules. This address is used by the schedule to know where the data should be first written to. The schedule will then write the following data to the address following the RAM buffer write address.
The given address must be an even value.
Parameters: address (int) – Any value in a range of 0 up to the RAM size.
startSchedule
()Starts a schedule.
Schedules may be configured in different ways, affecting their behavior. Before a schedule is started, the user should make sure that it is properly set in the right mode.
stopSchedule
()Stops the active schedule for a given subsystem.
Depending on how the Schedules are configured, it may not be necessary to call this method. When a schedule is using a count down, it is not required to stop the schedule.