(working) Use this code for calibrating the Load cells.

Fork of ADISense1000_Example_FW by Analog Devices

Committer:
RGurav
Date:
Thu Jul 19 13:25:33 2018 +0000
Revision:
2:2f9f9f7f0243
Parent:
0:76fed7dd9235
(Working); Code to read values from bridge load cell

Who changed what in which revision?

UserRevisionLine numberNew contents of line
seanwilson10 0:76fed7dd9235 1 Key Topics
seanwilson10 0:76fed7dd9235 2 ==========
seanwilson10 0:76fed7dd9235 3
seanwilson10 0:76fed7dd9235 4 [TOC]
seanwilson10 0:76fed7dd9235 5
seanwilson10 0:76fed7dd9235 6 # Register Interface {#registerinterface}
seanwilson10 0:76fed7dd9235 7 The ADI Sense module provides a register-style interface for the purpose
seanwilson10 0:76fed7dd9235 8 of exchanging configuration, status, and data with the host application
seanwilson10 0:76fed7dd9235 9 processor.
seanwilson10 0:76fed7dd9235 10
seanwilson10 0:76fed7dd9235 11 ## Overview {#registerinterface_overview}
seanwilson10 0:76fed7dd9235 12 The registers can be divided broadly into the following categories:
seanwilson10 0:76fed7dd9235 13 * Command input register
seanwilson10 0:76fed7dd9235 14 - This special register is used to issue commands to the module.
seanwilson10 0:76fed7dd9235 15 - New commands are typically ignored until the running command
seanwilson10 0:76fed7dd9235 16 has completed (as indicated via the Status registers)
seanwilson10 0:76fed7dd9235 17 * Configuration input registers
seanwilson10 0:76fed7dd9235 18 - Configuration registers are used to specify configuration parameters
seanwilson10 0:76fed7dd9235 19 for use by the module, typically specifying details such as operating
seanwilson10 0:76fed7dd9235 20 mode, sensor information, limits, and many other options.
seanwilson10 0:76fed7dd9235 21 - Changes to configuration input registers are typically ignored until a
seanwilson10 0:76fed7dd9235 22 command is issued to "apply" the configuration on the device.
seanwilson10 0:76fed7dd9235 23 * Status output registers
seanwilson10 0:76fed7dd9235 24 - Status information is provided by the module via these read-only registers
seanwilson10 0:76fed7dd9235 25 - Dedicated output signals (e.g. ERROR and ALERT) may be linked with this
seanwilson10 0:76fed7dd9235 26 status information
seanwilson10 0:76fed7dd9235 27 - The host application processor may acknowledge and reset/clear the status
seanwilson10 0:76fed7dd9235 28 indicators by reading the relevant status registers. The status indicators
seanwilson10 0:76fed7dd9235 29 will be set again if the underlying condition is subsequently detected again
seanwilson10 0:76fed7dd9235 30 * Data output registers
seanwilson10 0:76fed7dd9235 31 - Measurement data samples produced by the module are typically accessed via
seanwilson10 0:76fed7dd9235 32 a FIFO-style register which may be read repeatedly until all available data
seanwilson10 0:76fed7dd9235 33 has been consumed.
seanwilson10 0:76fed7dd9235 34 - Data samples are provided in a pre-determined format according to the
seanwilson10 0:76fed7dd9235 35 measurement mode, and typically comprise a processed measurement value,
seanwilson10 0:76fed7dd9235 36 status flags, measurement channel identifier and, optionally, the raw
seanwilson10 0:76fed7dd9235 37 (unprocessed) data sample retrieved from the sensor input channel.
seanwilson10 0:76fed7dd9235 38 * Keyhole access registers
seanwilson10 0:76fed7dd9235 39 - Access to large internal memory regions within the module is typically
seanwilson10 0:76fed7dd9235 40 provided via an pair of "keyhole" registers, consisting of an address
seanwilson10 0:76fed7dd9235 41 register and a data register. An address (i.e. an starting offset within
seanwilson10 0:76fed7dd9235 42 the region) must first be written to the address register, then the
seanwilson10 0:76fed7dd9235 43 companion data register may be accessed repeatedly to read/write data to
seanwilson10 0:76fed7dd9235 44 the corresponding region. The address is automatically incremented with
seanwilson10 0:76fed7dd9235 45 each access to the data register, so that data can be transferred in a
seanwilson10 0:76fed7dd9235 46 single burst for efficiency.
seanwilson10 0:76fed7dd9235 47
seanwilson10 0:76fed7dd9235 48 # Configuration {#configuration}
seanwilson10 0:76fed7dd9235 49 The ADI Sense module is a flexible measurement processor which must be
seanwilson10 0:76fed7dd9235 50 configured via the [register interface](@ref #registerinterface) before it
seanwilson10 0:76fed7dd9235 51 can be used to acquire data from its external sensor inputs.
seanwilson10 0:76fed7dd9235 52
seanwilson10 0:76fed7dd9235 53 ## Overview {#configuration_overview}
seanwilson10 0:76fed7dd9235 54 A configuration consists of the following elements:
seanwilson10 0:76fed7dd9235 55 * Global configuration register settings, such as:
seanwilson10 0:76fed7dd9235 56 - Operating modes
seanwilson10 0:76fed7dd9235 57 - Power configuration
seanwilson10 0:76fed7dd9235 58 - Measurement cycle timing
seanwilson10 0:76fed7dd9235 59 - External reference values
seanwilson10 0:76fed7dd9235 60 * Channel-specific register settings, such as:
seanwilson10 0:76fed7dd9235 61 - measurement count
seanwilson10 0:76fed7dd9235 62 - connected sensor type
seanwilson10 0:76fed7dd9235 63 - sensor configuration details
seanwilson10 0:76fed7dd9235 64 - settling time
seanwilson10 0:76fed7dd9235 65 - filter options
seanwilson10 0:76fed7dd9235 66 - threshold limits
seanwilson10 0:76fed7dd9235 67 - calibration adjustments
seanwilson10 0:76fed7dd9235 68 * Optional user-defined analog sensor linearisation data
seanwilson10 0:76fed7dd9235 69 - used to compensate for inherent non-linear characteristics of analog sensors
seanwilson10 0:76fed7dd9235 70 - supplied via a Look-Up Table data structure with a specific format
seanwilson10 0:76fed7dd9235 71 - allows the user to leverage the data acquisition and processing features
seanwilson10 0:76fed7dd9235 72 of the ADI Sense module for use with non-standard or unsupported sensors
seanwilson10 0:76fed7dd9235 73
seanwilson10 0:76fed7dd9235 74 ## Configuration data structure {#configuration_data}
seanwilson10 0:76fed7dd9235 75 Although the module can be configured and managed directly via the
seanwilson10 0:76fed7dd9235 76 [register interface](@ref #registerinterface), the ADI Sense Host Library
seanwilson10 0:76fed7dd9235 77 provides a level of abstraction above this which allows a more simplified
seanwilson10 0:76fed7dd9235 78 programming paradigm for the device.
seanwilson10 0:76fed7dd9235 79
seanwilson10 0:76fed7dd9235 80 A single C-language configuration data structure can be used to define all
seanwilson10 0:76fed7dd9235 81 configuration values for the ADI Sense module. This can be passed to the
seanwilson10 0:76fed7dd9235 82 relevant ADI Sense Host Library API functions, which will do the work of
seanwilson10 0:76fed7dd9235 83 translating the configuration details into the appropriate register values
seanwilson10 0:76fed7dd9235 84 and sending them to the module via its host communication interface.
seanwilson10 0:76fed7dd9235 85
seanwilson10 0:76fed7dd9235 86 The [examples](doc/examples.md) provided with the ADI Sense Host Library
seanwilson10 0:76fed7dd9235 87 demonstrate this configuration method. Individual configurations are stored
seanwilson10 0:76fed7dd9235 88 and compiled as .c files, and a configuration may be selected and loaded by
seanwilson10 0:76fed7dd9235 89 the application code. Note that only the essential configuration fields are
seanwilson10 0:76fed7dd9235 90 filled, depending on the specific sensor configuration and operating mode
seanwilson10 0:76fed7dd9235 91 required.
seanwilson10 0:76fed7dd9235 92
seanwilson10 0:76fed7dd9235 93 ## Loading and Applying a configuration {#configuration_loading}
seanwilson10 0:76fed7dd9235 94 Configuration data must first be loaded via the @ref adi_sense_SetConfig API
seanwilson10 0:76fed7dd9235 95 function - which updates the registers on the module according to the supplied
seanwilson10 0:76fed7dd9235 96 configuration details - and then applied by calling the @ref
seanwilson10 0:76fed7dd9235 97 adi_sense_ApplyConfigUpdates function which issues a special command to instruct
seanwilson10 0:76fed7dd9235 98 the module to apply the new configuration. If user-defined linearisation data
seanwilson10 0:76fed7dd9235 99 is also required, this must also be loaded via the @ref
seanwilson10 0:76fed7dd9235 100 adi_sense_1000_SetLutData function _before_ applying the new configuration.
seanwilson10 0:76fed7dd9235 101
seanwilson10 0:76fed7dd9235 102 To avoid loading the configuration details to the module every time it is
seanwilson10 0:76fed7dd9235 103 powered on, it is possible to save it to non-volatile memory on the module
seanwilson10 0:76fed7dd9235 104 using @ref adi_sense_SaveConfig and @ref adi_sense_SaveLutData. The saved
seanwilson10 0:76fed7dd9235 105 configuration is automatically restored by default when the module is
seanwilson10 0:76fed7dd9235 106 subsequently reset or powered on, and can also be reloaded on demand if required
seanwilson10 0:76fed7dd9235 107 using the @ref adi_sense_RestoreConfig and @ref adi_sense_RestoreLutData
seanwilson10 0:76fed7dd9235 108 functions. Note that, in all cases, @ref adi_sense_ApplyConfigUpdates _must_
seanwilson10 0:76fed7dd9235 109 be called to instruct the module to apply the configuration before will be used.
seanwilson10 0:76fed7dd9235 110
seanwilson10 0:76fed7dd9235 111 Once a valid configuration has been loaded and applied, the user may issue
seanwilson10 0:76fed7dd9235 112 commands to the module to initiate measurement cycles, internal calibration, or
seanwilson10 0:76fed7dd9235 113 diagnostic routines (all of which depend on a valid configuration being applied
seanwilson10 0:76fed7dd9235 114 in advance).
seanwilson10 0:76fed7dd9235 115
seanwilson10 0:76fed7dd9235 116 ## Configuration errors {#configuration_errors}
seanwilson10 0:76fed7dd9235 117 Attempts to load invalid configuration details will be flagged via the relevant
seanwilson10 0:76fed7dd9235 118 status registers and signals. After calling @ref adi_sense_ApplyConfigUpdates,
seanwilson10 0:76fed7dd9235 119 it is advisable to check the status of the module by calling @ref
seanwilson10 0:76fed7dd9235 120 adi_sense_GetStatus and examining the relevant status information returned from
seanwilson10 0:76fed7dd9235 121 the module. Subsequent commands issued to the module may not execute correctly
seanwilson10 0:76fed7dd9235 122 in the presence of unresolved configuration errors.
seanwilson10 0:76fed7dd9235 123
seanwilson10 0:76fed7dd9235 124 # Measurement Cycles {#measurementcycles}
seanwilson10 0:76fed7dd9235 125 ## Overview {#measurementcycles_overview}
seanwilson10 0:76fed7dd9235 126 Conversions are carried out sequentially across each of the enabled channels in
seanwilson10 0:76fed7dd9235 127 a predictable pattern which has a defined order and user-specified number of
seanwilson10 0:76fed7dd9235 128 conversions per channel. This is typically referred to as the _Measurement
seanwilson10 0:76fed7dd9235 129 Sequence_.
seanwilson10 0:76fed7dd9235 130
seanwilson10 0:76fed7dd9235 131 A _Measurement Cycle_ essentially consists of a single _Measurement Sequence_
seanwilson10 0:76fed7dd9235 132 which may be repeated at specified time intervals.
seanwilson10 0:76fed7dd9235 133
seanwilson10 0:76fed7dd9235 134 The configuration parameters required to define the Measurement Cycle and
seanwilson10 0:76fed7dd9235 135 Sequence are as follows:
seanwilson10 0:76fed7dd9235 136 * Cycle interval time (specified in microseconds/milliseconds/seconds)
seanwilson10 0:76fed7dd9235 137 * For each enabled sensor input channel:
seanwilson10 0:76fed7dd9235 138 - Number of conversions-per-cycle
seanwilson10 0:76fed7dd9235 139 - Extra settling time (specified in microseconds)
seanwilson10 0:76fed7dd9235 140
seanwilson10 0:76fed7dd9235 141 In addition to the cycle time, the following operating modes dictate when and
seanwilson10 0:76fed7dd9235 142 how many cycles should be executed:
seanwilson10 0:76fed7dd9235 143 * **Single-Cycle Mode**
seanwilson10 0:76fed7dd9235 144 - Executes a single Measurement Cycle and stops
seanwilson10 0:76fed7dd9235 145 * **Continuous Mode**
seanwilson10 0:76fed7dd9235 146 - Executes Measurement Cycles continuously until stopped by the host
seanwilson10 0:76fed7dd9235 147 application processor
seanwilson10 0:76fed7dd9235 148 * **Multi-Cycle Mode**
seanwilson10 0:76fed7dd9235 149 - Executes a specified number (burst) of Measurement Cycles and stores the
seanwilson10 0:76fed7dd9235 150 results in a buffer for retrieval by the host.
seanwilson10 0:76fed7dd9235 151 - Repeats this indefinitely at specified intervals (multi-cycle burst
seanwilson10 0:76fed7dd9235 152 interval) until stopped by the host application processor.
seanwilson10 0:76fed7dd9235 153
seanwilson10 0:76fed7dd9235 154 ## Executing Measurement Cycles {#measurementcycles_executing}
seanwilson10 0:76fed7dd9235 155 Once a valid configuration is loaded (see @ref #configuration),
seanwilson10 0:76fed7dd9235 156 Measurement Cycles are initiated by the host application processor via @ref
seanwilson10 0:76fed7dd9235 157 adi_sense_StartMeasurement, and may be stopped if necessary via @ref
seanwilson10 0:76fed7dd9235 158 adi_sense_StopMeasurement. These functions issue the relevant commands to the
seanwilson10 0:76fed7dd9235 159 ADI Sense module via its dedicate command register.
seanwilson10 0:76fed7dd9235 160
seanwilson10 0:76fed7dd9235 161 Certain auxiliary tasks may also be carried out internally by the module on a
seanwilson10 0:76fed7dd9235 162 per-cycle basis, such as Calibration and Diagnostics. These are discussed in
seanwilson10 0:76fed7dd9235 163 in later sections below.
seanwilson10 0:76fed7dd9235 164
seanwilson10 0:76fed7dd9235 165 ## Sequence Order {#measurementcycles_sequence}
seanwilson10 0:76fed7dd9235 166 The sequence is constructed according to which channels are enabled and how many
seanwilson10 0:76fed7dd9235 167 measurements must be performed per channel. The arrangement is similar to
seanwilson10 0:76fed7dd9235 168 round-robin scheduling - a measurement is carried out on each enabled channel, in
seanwilson10 0:76fed7dd9235 169 ascending channel order, and then the loop is repeated until the requested number
seanwilson10 0:76fed7dd9235 170 of measurements on each channel has been satisfied.
seanwilson10 0:76fed7dd9235 171
seanwilson10 0:76fed7dd9235 172 For example, lets say channels [0, 3, 4, 5] are enabled, with measurementsPerCycle
seanwilson10 0:76fed7dd9235 173 set as follows:
seanwilson10 0:76fed7dd9235 174
seanwilson10 0:76fed7dd9235 175 channelId | measurementsPerCycle
seanwilson10 0:76fed7dd9235 176 --------- | --------------------
seanwilson10 0:76fed7dd9235 177 CJC_1 | 4
seanwilson10 0:76fed7dd9235 178 SENSOR_0 | 2
seanwilson10 0:76fed7dd9235 179 I2C_1 | 3
seanwilson10 0:76fed7dd9235 180 SPI_0 | 1
seanwilson10 0:76fed7dd9235 181
seanwilson10 0:76fed7dd9235 182 The length of the sequence would be 10 measurements in total, and the order in
seanwilson10 0:76fed7dd9235 183 which the channel measurements appear in the sequence would look like this:
seanwilson10 0:76fed7dd9235 184
seanwilson10 0:76fed7dd9235 185 | **CJC_1** | **SENSOR_0** | **I2C_1** | **SPI_0** | **CJC_1** | **SENSOR_0** | **I2C_1** | **CJC_1** | **I2C_1** | **CJC_1** |
seanwilson10 0:76fed7dd9235 186
seanwilson10 0:76fed7dd9235 187 When measurement data samples are retrieved from the ADI Sense by the host
seanwilson10 0:76fed7dd9235 188 application, this is the order in which those data samples will appear.
seanwilson10 0:76fed7dd9235 189
seanwilson10 0:76fed7dd9235 190 The ADI Sense 1000 provides up to 13 measurement channels, and allows a maximum
seanwilson10 0:76fed7dd9235 191 measurementsPerCycle of 128, so a single cycle can produce a maximum of 1664
seanwilson10 0:76fed7dd9235 192 measurements. In other words, the maximum length of the sequence is 1664.
seanwilson10 0:76fed7dd9235 193
seanwilson10 0:76fed7dd9235 194 ## Sequence Timing {#measurementcycles_timing}
seanwilson10 0:76fed7dd9235 195 The timing of each measurement within the sequence depends on a number of factors:
seanwilson10 0:76fed7dd9235 196 * **Settling time**
seanwilson10 0:76fed7dd9235 197 - A settling time is applied when switching between each channel (unless only
seanwilson10 0:76fed7dd9235 198 a single channel in the sequence), particularly to allow the analog
seanwilson10 0:76fed7dd9235 199 front-end circuit to stabilise before a conversion is performed.
seanwilson10 0:76fed7dd9235 200 - Each channel is subject to a minimum settling time (e.g. 500 microseconds)
seanwilson10 0:76fed7dd9235 201 - Additional settling time can be configured per-channel if required
seanwilson10 0:76fed7dd9235 202 - As the analog sensor channels are multi-plexed into a single physical input
seanwilson10 0:76fed7dd9235 203 channel, with different front-end circuit configurations for each, the
seanwilson10 0:76fed7dd9235 204 settling and conversion of the analog channels must be done one-at-a-time in
seanwilson10 0:76fed7dd9235 205 series. Their settling time starts only when the channel is reached in the
seanwilson10 0:76fed7dd9235 206 sequence.
seanwilson10 0:76fed7dd9235 207 - Digital sensors operate independently, and so are activated in parallel to
seanwilson10 0:76fed7dd9235 208 other sensors. Consequently, their settling time may start at the start of
seanwilson10 0:76fed7dd9235 209 a cycle, or immediately after a previous conversion result has been obtained
seanwilson10 0:76fed7dd9235 210 from the sensor.
seanwilson10 0:76fed7dd9235 211 * **Conversion time**
seanwilson10 0:76fed7dd9235 212 - Once the settling time has passed, a conversion is initiated to obtain a raw
seanwilson10 0:76fed7dd9235 213 measurement value from the sensor input.
seanwilson10 0:76fed7dd9235 214 - The time required for the conversion may be influenced by factors such as
seanwilson10 0:76fed7dd9235 215 filter configuration (in the case of analog channels) or specific digital
seanwilson10 0:76fed7dd9235 216 sensor performance characteristics and configuration options.
seanwilson10 0:76fed7dd9235 217 * **Processing time**
seanwilson10 0:76fed7dd9235 218 - Once the raw conversion result is obtained, it is subjected to further
seanwilson10 0:76fed7dd9235 219 processing to apply correction for non-linear sensors, calibration
seanwilson10 0:76fed7dd9235 220 adjustments, and conversion into standard measurement units
seanwilson10 0:76fed7dd9235 221 - The processing time varies depending on the sensor type and correction
seanwilson10 0:76fed7dd9235 222 algorithms to be applied, but a standard budget of processing time (e.g.
seanwilson10 0:76fed7dd9235 223 500 microseconds) is allocated to each channel to produce consistent and
seanwilson10 0:76fed7dd9235 224 predictable time separation between the measurement results.
seanwilson10 0:76fed7dd9235 225
seanwilson10 0:76fed7dd9235 226 So, to summarise, the distinct phases for each measurement on each channel
seanwilson10 0:76fed7dd9235 227 typically look like this:
seanwilson10 0:76fed7dd9235 228
seanwilson10 0:76fed7dd9235 229 **settling** > **conversion** > **processing** > **publishing**
seanwilson10 0:76fed7dd9235 230
seanwilson10 0:76fed7dd9235 231 Taking the sequence example in the previous section, let's assume a base
seanwilson10 0:76fed7dd9235 232 settling time (_Ts_) and processing time (_Tp_) of 500 microseconds for each channel
seanwilson10 0:76fed7dd9235 233 and the following variable timing parameters _Te_ and _Tc_ (in units of microseconds):
seanwilson10 0:76fed7dd9235 234
seanwilson10 0:76fed7dd9235 235 channelId | extraSettlingTime (_Te_) | conversionTime (_Tc_) | sum (_Ts_ + _Te_ + _Tc_ + _Tp_) | measurementsPerCycle | total
seanwilson10 0:76fed7dd9235 236 --------- | ------------------------ | --------------------- | ------------------------------- | -------------------- | -----
seanwilson10 0:76fed7dd9235 237 CJC_1 | 4000 | 50000 | 55000 | 4 | 220000
seanwilson10 0:76fed7dd9235 238 SENSOR_0 | 1000 | 50000 | 52000 | 2 | 104000
seanwilson10 0:76fed7dd9235 239 I2C_1 | 20000 | 1000 | 22000 | 3 | 66000
seanwilson10 0:76fed7dd9235 240 SPI_0 | 0 | 800 | 1800 | 1 | 1800
seanwilson10 0:76fed7dd9235 241
seanwilson10 0:76fed7dd9235 242 To clarify: _Te_ above comes directly from the channel configuration. _Tc_, however,
seanwilson10 0:76fed7dd9235 243 is dictated by the sensor and its configuration.
seanwilson10 0:76fed7dd9235 244
seanwilson10 0:76fed7dd9235 245 The minimum time required for the cycle to complete is, in the above example,
seanwilson10 0:76fed7dd9235 246 391800 microseconds.
seanwilson10 0:76fed7dd9235 247
seanwilson10 0:76fed7dd9235 248 If the selected operating mode is Continuous or Multi-Cycle mode, the
seanwilson10 0:76fed7dd9235 249 configuration must also specify the interval between successive cycles
seanwilson10 0:76fed7dd9235 250 (cycleInterval). If this is less than the actual time required to
seanwilson10 0:76fed7dd9235 251 complete the cycle, the next cycle will start immediately after the
seanwilson10 0:76fed7dd9235 252 completion of the previous one; if it is more, there will be a delay
seanwilson10 0:76fed7dd9235 253 until the next cycle is started.
seanwilson10 0:76fed7dd9235 254
seanwilson10 0:76fed7dd9235 255 ## Measurement Results storage and retrieval {#measurementcycles_publishing}
seanwilson10 0:76fed7dd9235 256 As part of module configuration, a data-ready mode must be selected to decide
seanwilson10 0:76fed7dd9235 257 how measurements results are made available and retained for consuming by the
seanwilson10 0:76fed7dd9235 258 host application processor:
seanwilson10 0:76fed7dd9235 259
seanwilson10 0:76fed7dd9235 260 * **Per-Conversion**
seanwilson10 0:76fed7dd9235 261 - In this mode, each measurement result (a.k.a. data sample) is made available
seanwilson10 0:76fed7dd9235 262 as soon as it is ready.
seanwilson10 0:76fed7dd9235 263 - Only a single result is stored, and it is overwritten when the next
seanwilson10 0:76fed7dd9235 264 measurement result becomes ready. Only the latest result is retained.
seanwilson10 0:76fed7dd9235 265 - The host application processor must, therefore, consume each single
seanwilson10 0:76fed7dd9235 266 measurement result (by reading the DATA_FIFO register) as soon as the
seanwilson10 0:76fed7dd9235 267 result becomes available.
seanwilson10 0:76fed7dd9235 268 * **Per-Cycle**
seanwilson10 0:76fed7dd9235 269 - In this mode, the measurement results from a full cycle (10 data samples,
seanwilson10 0:76fed7dd9235 270 in the example above) are made available only when the measurement cycle is
seanwilson10 0:76fed7dd9235 271 complete.
seanwilson10 0:76fed7dd9235 272 - The results are overwritten when the next measurement cycle (if any)
seanwilson10 0:76fed7dd9235 273 is completed.
seanwilson10 0:76fed7dd9235 274 - The host application processor must consume the measurement results in a
seanwilson10 0:76fed7dd9235 275 batch as soon as they become available.
seanwilson10 0:76fed7dd9235 276 * **Per-Multicycle-Burst**
seanwilson10 0:76fed7dd9235 277 - In this mode, the measurement results from a burst of measurement cycles
seanwilson10 0:76fed7dd9235 278 are made available only when thise measurement cycles are completed.
seanwilson10 0:76fed7dd9235 279 - The results are overwritten when the next burst of measurement cycles
seanwilson10 0:76fed7dd9235 280 are completed.
seanwilson10 0:76fed7dd9235 281 - The host application processor must consume the measurement results in a
seanwilson10 0:76fed7dd9235 282 batch as soon as they become available.
seanwilson10 0:76fed7dd9235 283 - Note that this data-ready mode is only available when the Multi-Cycle
seanwilson10 0:76fed7dd9235 284 operating mode is also selected.
seanwilson10 0:76fed7dd9235 285
seanwilson10 0:76fed7dd9235 286 When new measurement results are ready for retrieval, the DRDY output signal
seanwilson10 0:76fed7dd9235 287 is asserted. The host application may check this signal continuously, or attach
seanwilson10 0:76fed7dd9235 288 an interrupt notification to this signal, to ensure that measurement results are
seanwilson10 0:76fed7dd9235 289 retrieved in a timely fashion before they are subsequently overwritten by the
seanwilson10 0:76fed7dd9235 290 next conversion/cycle. Alternatively, the host application may also read the
seanwilson10 0:76fed7dd9235 291 STATUS register to check the DRDY status indicator.
seanwilson10 0:76fed7dd9235 292
seanwilson10 0:76fed7dd9235 293 The ADI Sense Host Library API provides the following functions which are
seanwilson10 0:76fed7dd9235 294 relevant for data retrieval:
seanwilson10 0:76fed7dd9235 295 * @ref adi_sense_RegisterGpioCallback for recieving DRDY interrupt notifications
seanwilson10 0:76fed7dd9235 296 * @ref adi_sense_GetGpioState for polling the state of the DRDY signal
seanwilson10 0:76fed7dd9235 297 * @ref adi_sense_GetStatus for reading the module status registers
seanwilson10 0:76fed7dd9235 298 * @ref adi_sense_GetData for retrieveing the measurement results from the module
seanwilson10 0:76fed7dd9235 299
seanwilson10 0:76fed7dd9235 300 The @ref adi_sense_1000_GetDataReadyModeInfo API function, specific to the ADI
seanwilson10 0:76fed7dd9235 301 Sense 1000, is also useful for obtaining information on the number of
seanwilson10 0:76fed7dd9235 302 measurement results to expect when the DRDY indicator is asserted, based on the
seanwilson10 0:76fed7dd9235 303 operating and data-ready mode configuration settings currently set in the module
seanwilson10 0:76fed7dd9235 304 registers.
seanwilson10 0:76fed7dd9235 305
seanwilson10 0:76fed7dd9235 306 # Calibration {#calibration}
seanwilson10 0:76fed7dd9235 307 The ADI Sense module incorporates a number of calibration measures to ensure
seanwilson10 0:76fed7dd9235 308 the accuracy of measurement results, described in the following sections. These
seanwilson10 0:76fed7dd9235 309 mostly pertain to the analog measurement channels, but some provisions are also
seanwilson10 0:76fed7dd9235 310 included for calibration of digital sensors.
seanwilson10 0:76fed7dd9235 311
seanwilson10 0:76fed7dd9235 312 ## Factory calibration {#calibration_factory}
seanwilson10 0:76fed7dd9235 313 Calibration is performed during factory production for error introduced by
seanwilson10 0:76fed7dd9235 314 components (e.g. resistors, switches) present on the signal paths of the
seanwilson10 0:76fed7dd9235 315 module's analog front-end. Calibration offset and gain values are calculated
seanwilson10 0:76fed7dd9235 316 and stored in non-volatile memory within the module as part of the production
seanwilson10 0:76fed7dd9235 317 process. These are applied automatically without intervention from the host
seanwilson10 0:76fed7dd9235 318 application.
seanwilson10 0:76fed7dd9235 319
seanwilson10 0:76fed7dd9235 320 ## Internal auto-calibration {#calibration_internal}
seanwilson10 0:76fed7dd9235 321 The high-accuracy ADC incorporated within the ADI Sense module includes
seanwilson10 0:76fed7dd9235 322 internal calibration functions to assist in removing offset or gain errors
seanwilson10 0:76fed7dd9235 323 internal to that ADC. As this is a time-consuming process, it is invoked
seanwilson10 0:76fed7dd9235 324 only in the following circumstances:
seanwilson10 0:76fed7dd9235 325 * The host application issues a self-calibration command (@ref
seanwilson10 0:76fed7dd9235 326 adi_sense_RunCalibration)
seanwilson10 0:76fed7dd9235 327 * The host application updates the module configuration and the module
seanwilson10 0:76fed7dd9235 328 determines, based on the configuration changes, that re-calibration is
seanwilson10 0:76fed7dd9235 329 required. In this case, the calibration is carried out at the point
seanwilson10 0:76fed7dd9235 330 where the new configuration settings are applied (@ref
seanwilson10 0:76fed7dd9235 331 adi_sense_ApplyConfigUpdates)
seanwilson10 0:76fed7dd9235 332
seanwilson10 0:76fed7dd9235 333 In all cases, a valid configuration must be set and it used as part of the
seanwilson10 0:76fed7dd9235 334 calibration process. External sensors and reference circuits must be
seanwilson10 0:76fed7dd9235 335 connected for calibration to work correctly.
seanwilson10 0:76fed7dd9235 336
seanwilson10 0:76fed7dd9235 337 ## User calibration {#calibration_user}
seanwilson10 0:76fed7dd9235 338 Additional gain and offset correction parameters may be specified per-channel as
seanwilson10 0:76fed7dd9235 339 part of the module configuration. These are applied as a final step to each
seanwilson10 0:76fed7dd9235 340 measurement result from the channel during the final stages of processing before
seanwilson10 0:76fed7dd9235 341 the data sample is made available to the host processor.
seanwilson10 0:76fed7dd9235 342
seanwilson10 0:76fed7dd9235 343 # Diagnostics {#diagnostics}
seanwilson10 0:76fed7dd9235 344 The ADC within the ADI Sense module includes a range of sophisticated diagnostic
seanwilson10 0:76fed7dd9235 345 features to automatically detect error conditions such as under-/over-voltage on
seanwilson10 0:76fed7dd9235 346 analog input signals, supply voltage errors, reference detection errors and more.
seanwilson10 0:76fed7dd9235 347 These are enabled by default and, if triggered, will result in an ERROR or ALERT
seanwilson10 0:76fed7dd9235 348 signal being asserted by the module. Diagnostic status can be queried via the
seanwilson10 0:76fed7dd9235 349 module status registers (@ref adi_sense_GetStatus).
seanwilson10 0:76fed7dd9235 350
seanwilson10 0:76fed7dd9235 351 Additional diagnostic tests may be executed by the module to detect additional
seanwilson10 0:76fed7dd9235 352 error conditions such as a disconnected or mis-wired sensor. These tests are
seanwilson10 0:76fed7dd9235 353 typically time-consuming, and so are carried out only if selected by the user:
seanwilson10 0:76fed7dd9235 354 * Sensor diagnostics may be requested by executing a dedicated diagnostics
seanwilson10 0:76fed7dd9235 355 command (@ref adi_sense_RunDiagnostics)
seanwilson10 0:76fed7dd9235 356 * Sensor diagnostics may be optionally executed at the start of each measurement
seanwilson10 0:76fed7dd9235 357 cycle, at a frequency determined by the user through the configuration
seanwilson10 0:76fed7dd9235 358 parameters (see @ref ADI_SENSE_1000_DIAGNOSTICS_CONFIG)
seanwilson10 0:76fed7dd9235 359
seanwilson10 0:76fed7dd9235 360 # Sensor Linearisation {#linearisation}
seanwilson10 0:76fed7dd9235 361 Analog sensors typically produce an output which is not completely linear or
seanwilson10 0:76fed7dd9235 362 directly proportional with respect to their input. Different sensor types
seanwilson10 0:76fed7dd9235 363 generally have different linearity characteristics, each requiring different
seanwilson10 0:76fed7dd9235 364 correction methods or coefficients for accurate translation of the sensor output
seanwilson10 0:76fed7dd9235 365 back to the corresponding input. Typical methods include use of linearisation
seanwilson10 0:76fed7dd9235 366 formulae (e.g. polynomial equations with variable coefficients), or tables of
seanwilson10 0:76fed7dd9235 367 sample input values and their corresponding outputs which can be used with
seanwilson10 0:76fed7dd9235 368 interpolation to perform the translation.
seanwilson10 0:76fed7dd9235 369
seanwilson10 0:76fed7dd9235 370 The ADI Sense module performs linearisation and calibration correction of the
seanwilson10 0:76fed7dd9235 371 analog sensor measurements, and incorporates the linearisation functions
seanwilson10 0:76fed7dd9235 372 complete with coefficients or translation tables for a range of supported sensor
seanwilson10 0:76fed7dd9235 373 types. On the ADI Sense 1000, for example, measurement results from any
seanwilson10 0:76fed7dd9235 374 [sensor types](@ref ADI_SENSE_1000_ADC_SENSOR_TYPE) named with the
seanwilson10 0:76fed7dd9235 375 "_L1" suffix or with a specific sensor model name (e.g. @ref
seanwilson10 0:76fed7dd9235 376 ADI_SENSE_1000_ADC_SENSOR_VOLTAGE_PRESSURE_AMPHENOL_NPA300X) will be
seanwilson10 0:76fed7dd9235 377 automatically linearised using built-in linearisation functions and coefficients
seanwilson10 0:76fed7dd9235 378 or translation tables.
seanwilson10 0:76fed7dd9235 379
seanwilson10 0:76fed7dd9235 380 It is also possible to have ADI Sense perform linearisation on other sensor
seanwilson10 0:76fed7dd9235 381 types. A range of [sensor type IDs](@ref ADI_SENSE_1000_ADC_SENSOR_TYPE) named
seanwilson10 0:76fed7dd9235 382 with an "_L2" suffix are reserved for this purpose. By specifying one of these
seanwilson10 0:76fed7dd9235 383 sensor types, and by providing the necessary linearisation information for that
seanwilson10 0:76fed7dd9235 384 sensor type as part of a "look-up table" data structure loaded via the @ref
seanwilson10 0:76fed7dd9235 385 adi_sense_1000_SetLutData API function, the ADI Sense module can be extended to
seanwilson10 0:76fed7dd9235 386 work with sensor variants which require a different linearisation what is
seanwilson10 0:76fed7dd9235 387 already provided through built-in methods. Linearisation data may be provided
seanwilson10 0:76fed7dd9235 388 in the form of a coefficient list for a polynomial equation, or as a
seanwilson10 0:76fed7dd9235 389 translation table, depending on what is most appropriate for that sensor.
seanwilson10 0:76fed7dd9235 390
seanwilson10 0:76fed7dd9235 391 Translation tables can be expressed in a number of formats, such as 1- or
seanwilson10 0:76fed7dd9235 392 2-Dimensional tables, with equally- or non-equally-spaced vectors. 2-D tables
seanwilson10 0:76fed7dd9235 393 are used where the sensor output is affected by both the sensor input and
seanwilson10 0:76fed7dd9235 394 another factor such as the operating temperature of the sensor itself. If the
seanwilson10 0:76fed7dd9235 395 sensor output values can be captured for an equally-spaced set of input values
seanwilson10 0:76fed7dd9235 396 (i.e. values separated by a constant increment, such as 3,6,9,12,etc.), the
seanwilson10 0:76fed7dd9235 397 equally-spaced table formats allow for a more compact represenation as only the
seanwilson10 0:76fed7dd9235 398 ouput values need to be listed individually.
seanwilson10 0:76fed7dd9235 399
seanwilson10 0:76fed7dd9235 400 Multiple coefficient lists can be specified for a given sensor type, along with
seanwilson10 0:76fed7dd9235 401 an applicable range of input values, as it may be necessary to apply different
seanwilson10 0:76fed7dd9235 402 equations depending on the input range. For example, RTD sensors feature a
seanwilson10 0:76fed7dd9235 403 different linearity curve for input ranges above/below 0 degrees Celsius.
seanwilson10 0:76fed7dd9235 404
seanwilson10 0:76fed7dd9235 405 The ADI Sense 1000 allows a flexible look-up table (LUT) data structure up to a
seanwilson10 0:76fed7dd9235 406 [maximum size](@ref ADI_SENSE_LUT_MAX_SIZE) to be loaded by the user for use
seanwilson10 0:76fed7dd9235 407 with custom "L2" sensor types. The LUT data structure format, defined as @ref
seanwilson10 0:76fed7dd9235 408 ADI_SENSE_1000_LUT, allows for a variable set of tables of different formats
seanwilson10 0:76fed7dd9235 409 to be included as part of the overall data structure. Each table is preceeded
seanwilson10 0:76fed7dd9235 410 by a descriptor which specifies the format of the following table. A single
seanwilson10 0:76fed7dd9235 411 top-level header at the start of the LUT specifies how many tables are contained
seanwilson10 0:76fed7dd9235 412 within. The LUT structure basically looks like this:
seanwilson10 0:76fed7dd9235 413
seanwilson10 0:76fed7dd9235 414 |---------------------|
seanwilson10 0:76fed7dd9235 415 | top-level header |
seanwilson10 0:76fed7dd9235 416 |---------------------|
seanwilson10 0:76fed7dd9235 417 | table #0 descriptor |
seanwilson10 0:76fed7dd9235 418 | table #0 data |
seanwilson10 0:76fed7dd9235 419 |---------------------|
seanwilson10 0:76fed7dd9235 420 | table #1 descriptor |
seanwilson10 0:76fed7dd9235 421 | table #1 data |
seanwilson10 0:76fed7dd9235 422 |---------------------|
seanwilson10 0:76fed7dd9235 423 ~~~
seanwilson10 0:76fed7dd9235 424 |---------------------|
seanwilson10 0:76fed7dd9235 425 | table #N descriptor |
seanwilson10 0:76fed7dd9235 426 | table #N data |
seanwilson10 0:76fed7dd9235 427 |---------------------|
seanwilson10 0:76fed7dd9235 428
seanwilson10 0:76fed7dd9235 429 To cater for this flexibility, the data structure definition is inherently
seanwilson10 0:76fed7dd9235 430 complex. To absorb some of this complexity, a supplementary API function named
seanwilson10 0:76fed7dd9235 431 @ref adi_sense_1000_AssembleLutData is provided. By providing a list of
seanwilson10 0:76fed7dd9235 432 pointers to descriptors and data elements for each table to be included in the
seanwilson10 0:76fed7dd9235 433 LUT structure, along with buffer of allocated memory, this function constructs
seanwilson10 0:76fed7dd9235 434 the top-level header and appends each table and also fills some fields within
seanwilson10 0:76fed7dd9235 435 the table descriptors (e.g. length, CRC). Please refer to the "user_lut_data"
seanwilson10 0:76fed7dd9235 436 application example for an illustration of how this function can be used.
seanwilson10 0:76fed7dd9235 437