This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
resources:quick-start:adxl313_quick_start_guide [16 Jul 2020 23:29] – added DATA FORMAT section Pablo del Corro | resources:quick-start:adxl313_quick_start_guide [16 Jul 2020 23:58] – [INITIALIZATION] Pablo del Corro | ||
---|---|---|---|
Line 43: | Line 43: | ||
The interrupt behavior, latch high or latch low, can be configured through the DATA_FORMAT register. Refer to the ADXL313 data sheet for details. | The interrupt behavior, latch high or latch low, can be configured through the DATA_FORMAT register. Refer to the ADXL313 data sheet for details. | ||
+ | <note tip> | ||
+ | Always make set the ADXL313 in Standby mode first before configuring any register. | ||
+ | </ | ||
==== DATA FORMAT ==== | ==== DATA FORMAT ==== | ||
The ADXL313 registers length is 8 bits, while its acceleration in full resolution is 13 bits. Thus the acceleration data of each axis is stored in two registers. For example, for X-axis DATAX0 is the low byte register and DATAX1 is the high byte register. Once acceleration data is acquired from data registers, the user must reconstruct the data as a 16-bits word length. | The ADXL313 registers length is 8 bits, while its acceleration in full resolution is 13 bits. Thus the acceleration data of each axis is stored in two registers. For example, for X-axis DATAX0 is the low byte register and DATAX1 is the high byte register. Once acceleration data is acquired from data registers, the user must reconstruct the data as a 16-bits word length. | ||
Line 50: | Line 53: | ||
{{ : | {{ : | ||
- | <note tip> | ||
In programming language this will be equivalent to: | In programming language this will be equivalent to: | ||
< | < | ||
Line 56: | Line 58: | ||
</ | </ | ||
with X_16bits a variable defined as uint16. | with X_16bits a variable defined as uint16. | ||
- | </ | ||
- | Make sure to zero the unwanted MSB (14th to 16th bit) by doing: | + | Also make sure to zero the unwanted MSB (14th to 16th bit) by doing: |
< | < | ||
- | X_16bits | + | X_raw = X_16bits & 0x1FFF; |
</ | </ | ||
- | + | where **X_raw** is uint16 that contains actual acceleration information formatted as **two's complement**. | |
- | <note important> | + | |
The two's complement function can be implemented with the following code: | The two's complement function can be implemented with the following code: | ||
Line 77: | Line 77: | ||
} | } | ||
</ | </ | ||
- | For this example, the argument **value** will be X_16bits | + | For this example, the argument **value** will be X_raw and the argument **bits** will be 13 (full resolution). |
To calculate the acceleration value in units of //g//, multiply the two's complement value obtained times the Scale Factor (1/ | To calculate the acceleration value in units of //g//, multiply the two's complement value obtained times the Scale Factor (1/ | ||
- | < | + | In code this is: |
+ | < | ||
+ | X_g = (twos_complement(X_raw, | ||
+ | </ | ||
+ | where **X_g** is the X-axis acceleration in units of //g//. | ||
+ | |||
+ | < | ||