0

I am a student and currently doing a semester project. The first goal is to get accelerometer and gyroscope data from FIS1100 using the Arduino (Uno). I've got the FIS1100 Evaluation Kit user guide from my supervisor. I've simply separated the sensor PCB from the MCU and connected this sensor to an Arduino Uno as shown on this photo:

FIS+Arduino

The connections are as following:

  • SCL (on the header of FIS) - A5 (Arduino)
  • SDA (on the header of FIS) - A4 (Arduino)
  • GND (on the header of FIS) - GND (Arduino)
  • 3V3-to VIOREF (on the header of FIS) - 3V3 (Arduino)

I wrote this simple code, which I uploaded to the Arduino board. Unfortunately as a result, I got zeros as output.

#include <Wire.h>
const int I2C_address = 0b1101010;
long a_X, a_Y, a_Z;
float g_X, g_Y, g_Z;

long gyro_X, gyro_Y, gyro_Z;
float rot_X, rot_Y, rot_Z;

void setup() {
  Serial.begin(9600);
  Wire.begin();
  setupFIS();

}

void loop() {
  recordAccelRegisters();
  recordGyroRegisters();
  printData();
  delay(800);

}

void setupFIS(){
  Wire.beginTransmission(I2C_address);
  Wire.write(0x02);
  Wire.write(0b00000000);
  Wire.endTransmission(true);

  Wire.beginTransmission(I2C_address);
  Wire.write(0x08);
  Wire.write(0b10000011);
  Wire.endTransmission(true);

  Wire.beginTransmission(I2C_address);
  Wire.write(0x04);
  Wire.write(0b00000000);
  Wire.endTransmission(true);

  Wire.beginTransmission(I2C_address);
  Wire.write(0x03);
  Wire.write(0b00000000);
  Wire.endTransmission(true);

  Wire.beginTransmission(I2C_address);
  Wire.write(0x05);
  Wire.write(0b00000000);
  Wire.endTransmission(true);

  Wire.beginTransmission(I2C_address);
  Wire.write(0x06);
  Wire.write(0b00000000);
  Wire.endTransmission(true);

  Wire.beginTransmission(I2C_address);
  Wire.write(0x07);
  Wire.write(0b00000000);
  Wire.endTransmission(true);
}

void recordAccelRegisters(){
  Wire.beginTransmission(I2C_address);
  Wire.write(0x19);
  Wire.endTransmission(false);
  Wire.requestFrom(I2C_address,6,true);
  //while(Wire.available()<6);
  a_X = Wire.read()<<8|Wire.read();
  a_Y = Wire.read()<<8|Wire.read();
  a_Z = Wire.read()<<8|Wire.read();
  processAccelData();
}

void processAccelData(){
  g_X = a_X/16384.0;
  g_Y = a_Y/16384.0;
  g_Z= a_Z/16384.0;
}

void recordGyroRegisters(){
  Wire.beginTransmission(I2C_address);
  Wire.write(0x1F);
  Wire.endTransmission(false);
  Wire.requestFrom(I2C_address,6,true);
  //while(Wire.available()<6);
  gyro_X = Wire.read()<<8|Wire.read();
  gyro_Y = Wire.read()<<8|Wire.read();
  gyro_Z = Wire.read()<<8|Wire.read();
  processGyroData();
}

void processGyroData(){
  rot_X = gyro_X/1024.0;
  rot_Y = gyro_Y/1024.0;
  rot_Z= gyro_Z/1024.0;
}

void printData(){
  Serial.print("Gyro(deg)");
  Serial.print(" X=");
  Serial.print(rot_X);
  Serial.print(" Y=");
  Serial.print(rot_Y);
  Serial.print(" Z=");
  Serial.print(rot_Z);

  Serial.print("   Accel(g)");
  Serial.print(" X=");
  Serial.print(g_X);
  Serial.print(" Y=");
  Serial.print(g_Y);
  Serial.print(" Z=");
  Serial.println(g_Z);
} 

So, I really need help to get some relevant data.

And also I have doubts concerning the I2C-address of the FIS1100. In the datasheet of the FIS1100 on page 50 it is said:

the address is 0b1101010 in case when pin SA0 is left unconnected, internally there is a weak pull-down of 200k; the address is 0b1101011 in case when pin SA0 is pulled-up externally.

Now lets go again to user guide and on page 25 (schematic of pull-up/down resistors) we see that SA0 is externally pulled-down.

Question: which I2C-address should I use?

migrated from electronics.stackexchange.com Oct 23 '17 at 14:30

This question came from our site for electronics and electrical engineering professionals, students, and enthusiasts.

  • 1
    Use a i2c scanner playground.arduino.cc/Main/I2cScanner That is the i2c address that you should use. Try to read a status register. According to the datasheet, at startup the sensors are turned off and they will return zero. – Jot Oct 23 '17 at 17:10
  • Thanks for feedback! I've read the STATUS0 and it gives me 255 – Yuliya Oct 25 '17 at 15:09
  • Reading STATUS0 seems to start something. What happens when you read the WHO_AM_I register ? How do you read it ? Perhaps a Wire.read() into a byte ? The Wire.read() returns -1 if there is no communication with the sensor, that -1 might turn into 255. Did you run the i2c scanner ? – Jot Oct 25 '17 at 16:18
1

I think you'll find you need to add some pull up resistors to both connections on the I2C (SDA and SCL).

Also I'm not sure what you should be pulling them up to 3.3v or 5v. You should check if you need a level shifter or if the device you are connecting is 5v tolerant.

According to you question you should be using the address 0x6A. 0x6B is when you have an external pull up resistor, which I don't think you do have. So your code is correct.

  • First, thanks a lot for feedback! Actually if to refer to the user guide (hyperlink in my post) on the page 24 you can see level-shifters. And yes, all the interface pins (SDA, SCL) are pulled properly. Even I used address 0x6A nothing - just zeros. LED on Arduino, which indicates transmission is blinking. Seems like I need to enable I2C or what.... like to give logic 1 maybe somewhere. But it is guessing – Yuliya Oct 24 '17 at 11:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.