Its acceleration values are output in 16 bit digital numbers. The output data rate (ODR) can be up to 1600.
Resolution of its digital output
$$ \text{mg/digit} = \frac{2g - (-2g)}{2^{16}-1} = 61 \text{ } \mu \text{g} = 0.5966 \text{ mm s}^{-2} $$
where the gravity at Singapore is 9781 mm s-2.
Therefore, its resolution due to its digitization is 61 μg/digit. In face, the actual sensitivity of the accelerometer (sensing resolution) depends on its noise floor. Its noise density as in the datasheet is 150 μg/sqrt(Hz). For a bandwidth of 100 Hz, its sensing resolution will be 1500 μg.
$$ An = {150} \times {\sqrt{BW}} = 1500 \text{ } \mu \text{g} = 14.67 \text{ mm s}^{-2} $$
Using SPI Interface
An example schematic circuit diagram for LIS3DSH to use SPI interface is shown below. In this example, only 4-wires are used and interrupt is not utilized.In the following example, schematic and program for using LIS3DSH accelerometer with Arduino Uno through SPI interface is presented. Digital IO of Arduino Uno is 5V while that of LIS3DSH is 3.3V. Therefore, a bi-directional logic level converter is used to interface them. Schematic circuit diagram with STEVAL-MKI134V1 adapter board is shown below.
SPI library for Arduino is used for Serial Peripheral Interface (SPI) - Mode 3, MSB first.
#include <SPI.h> const int CS_Pin = 10;// set pin 10 as the chip select SPISettings settingsA(2000000, MSBFIRST, SPI_MODE3); // set up the speed, data order and data mode //SPI pin configuration: pin 11 as MOSI (SDI), pin 12 as MISO (SDO) , pin 13 as clock (SPC) int x,y,z; float K=0.061; // (4000/65535) milli-g per digit for +/-2g full scale using 16 bit digital output void setup() { Serial.begin(9600); pinMode (CS_Pin, OUTPUT); //Chip Select pin to control SPI digitalWrite(CS_Pin, HIGH);//Disable SPI SPI.begin(); SPI.beginTransaction(settingsA); digitalWrite(CS_Pin, LOW);//Enable SPI SPI.transfer(0x20);//Send address of 'Control register 4' to write configuration SPI.transfer(0x7F);//Write a value that enables x,y,z accelerometers digitalWrite(CS_Pin, HIGH);//Disable SPI } void loop() { delay(1000); digitalWrite(CS_Pin, LOW);//Enable SPI SPI.transfer(0xA8);//Send address of LSB of x. Address is auto-increased after each reading. x = SPI.transfer(0) | SPI.transfer(0)<<8; //x acceleration y = SPI.transfer(0) | SPI.transfer(0)<<8; //y acceleration z = SPI.transfer(0) | SPI.transfer(0)<<8; //z acceleration digitalWrite(CS_Pin, HIGH);//Disable SPI Serial.println("x=" + String(K*x)+" mg \ty=" + String(K*y)+" mg \tz=" + String(K*z)+" mg"); }
Using I2C Interface
I2C interface with LIS3DSH is shown below.As an example, a schematic and a program for using LIS3DSH accelerometer with Arduino Uno through I2C interface is presented. Normally, when a pin is configured as an I2C pin, it will be in open drain configuration and they can be just connected directly using a suitable pull-up resistor. But, in the case of Arduino UNO, A4 and A5 looks pulled up internally to 5V. That is why, a bi-directional logic level converter is used as a safety measure.
For I2C (Inter-Integrated Circuit), Wire Library for Arduino is used.
#include <Wire.h> int x,y,z; float K=0.061; // (4000/65535) milli-g per digit for +/-2g full scale using 16 bit digital output void setup() { Wire.begin(); // join i2c bus (address optional for master) Serial.begin(9600); // start serial for output Wire.beginTransmission(0x1E); // transmit to device #30 Wire.write(0x20);//Send address of 'Control register 4' to write configuration Wire.write(0x7F);//Write a value that enables x,y,z accelerometers Wire.endTransmission();// stop transmitting } void loop() { delay(1000); Wire.beginTransmission(0x1E); // transmit to device #30 Wire.write(0x28);//Send address of LSB of x. Address is auto-increased after each reading. Wire.endTransmission(); // stop transmitting Wire.requestFrom(0x1E, 6); // request 6 bytes from slave device #30 x = Wire.read() | Wire.read()<<8; //x acceleration y = Wire.read() | Wire.read()<<8; //y acceleration z = Wire.read() | Wire.read()<<8; //z acceleration Serial.println("x=" + String(K*x)+" mg \ty=" + String(K*y)+" mg \tz=" + String(K*z)+" mg"); }
A code sample for NXP LPC54102 dual core ARM microcontroller to read accelerometers and a gyroscope can be found at the following link together with the above examples.
Accelerometer_LIS3DSH_ADIS16003 on GitHub
Figure. A gyroscope and 4 accelerometers on the bottom side, and a dual core ARM microcontroller on top side of an in-house built embedded circuit board (Ø < 1 in).
Uisg ADIS16003 accelerometer with AT89C51CC03 8051 microcontroller can also be found there too.
No comments:
Post a Comment
Comments are moderated and don't be surprised if your comment does not appear promptly.