Accelerometer and Gyro Information

Questions, answers, feedback or just general conversation about anything to do with the store 'Hacker's Warehouse'.

Accelerometer and Gyro Information

Postby Tim Laren » Wed Feb 15, 2012 8:52 pm

This is for those that got the ENC-03M Gyro and/or the MMA7361L Accelerometer.
http://hacker.instanet.net/arduino/files/ENC-03M/enc-03.pdf
http://hacker.instanet.net/arduino/files/MMA7361L/MMA7361L.pdf

Both these devices have the pinout printed on the board. Both devices are a 3.3V chip with a on-board 3.3V regulator that allows the board to be powered with 5V. The Gyro also has an amplifier on-board. There is a VREF pin that should be connected to a CAP to GND.

Code: Select all
The Gyro pins should be connected as follows:
      Pin          Connect to
      VCC         +5V
      Vref         + 4.7uf cap to GND
      Out          Analog input of Arduino (or other processor)
      Gnd          GND

The Accelerometer pins should be connected as follows:
      5V            +5V
      3V3          3.3V output (I connect to the Vref of the Arduino)
      GND         GND
      GS           sensitivity            Low = 1.5g, High = 6g
      ST           Self Test               Low = generates known output, High = normal operation
      0G           Zero G                  High = 0g all axes
      SL           Sleep                   Low = sleep, High = normal operation
      Z             0-3.3V Z Output
      Y             0-3.3V Y Output
      X             0-3.3V X Output

If used together, I connect the 3.3V output to the ARef of the Arduino and set the ADC reference to external. This allows full scale readings from the devices. They are 3.3V and without the reference you will only get 3.3/5 maximum input to the ADC.

With the Accelerometer at rest you should read zero G on two axes and 1g on the other (or -1g based on orientation).

The idea of this program is to sample the sensors and then average them over the last 10 samples. I don’t remember how well the averaging worked but I just loaded it onto my board and it does print out values that look pretty close to what I want.

Attached is some test code (also listed below) for the Arduino 1.0 environment. If you are using 00.22, just open the file with notepad and paste into the Arduino environment.
http://hacker.instanet.net/arduino/files/accelerometer-gyro-code/Gyro_Accelerometer.ino
Code: Select all
int g_avg[10];
int x_avg[10];
int y_avg[10];
int z_avg[10];

int g_axis = 0;
int x_axis = 0;
int y_axis = 0;
int z_axis = 0;

const int slp_pin = 10;
const int gs_pin = 8;
const int st_pin = 9;

const int gyroPin = 0;
const int accXpin = 1;
const int accYpin = 2;
const int accZpin = 3;

int i;

void setup(){
Serial.begin(9600);
analogReference(EXTERNAL);
pinMode(slp_pin,OUTPUT);
pinMode(gs_pin,OUTPUT);
pinMode(st_pin,OUTPUT);
digitalWrite(slp_pin,HIGH);
digitalWrite(gs_pin,HIGH);
digitalWrite(st_pin,HIGH);
}

void loop(){
  digitalWrite(slp_pin, HIGH);

  for (i=0; i<10; i=i+1){
    g_avg[i] = analogRead(gyroPin);
    x_avg[i] = analogRead(accXpin);
    y_avg[i] = analogRead(accYpin);
    z_avg[i] = analogRead(accZpin);
  }
 
  for (i=0; i<10; i=i+1){
    if (i == 0) {
      g_axis = g_avg[i];
      x_axis = x_avg[i];
      y_axis = y_avg[i];
      z_axis = z_avg[i];
    }else{
      g_axis = g_axis + g_avg[i];
      x_axis = x_axis + x_avg[i];
      y_axis = y_axis + y_avg[i];
      z_axis = z_axis + z_avg[i];
    }
  }
   
  Serial.print("g-axis");
  Serial.print("\t"); 
  Serial.println(g_axis/10);

  Serial.print("x-axis");
  Serial.print("\t"); 
  Serial.println(x_axis/10);

  Serial.print("y-axis");
  Serial.print("\t"); 
  Serial.println(y_axis/10);
 
  Serial.print("z-axis");
  Serial.print("\t"); 
  Serial.println(z_axis/10);

  Serial.println(""); 
  delay(1000);
}

Image
Tim Laren
Site Admin
 
Posts: 137
Joined: Thu Mar 04, 2010 8:25 pm

Новости политики Украина Россия

Postby RaymondKeype » Fri Sep 14, 2018 1:16 pm

Всем привет! Класный у вас сайт!
Что скажете по поводу этих новостей?:
http://enewz.ru/news/22715-gospodam-iz- ... zhdan.html Господам из Брюсселя нет дела ни до жителей Алеппо, ни до сограждан
http://enewz.ru/news/17062-novoe-sekret ... sirii.html
http://enewz.ru/news/2483-na-izhevskoy- ... 0-mvt.html
Ещё много интересного по теме нашел тут: http://enewz.ru/
RaymondKeype
 
Posts: 1
Joined: Mon Sep 03, 2018 10:53 am
Location: Россия

Удивительная подборка

Postby RolandGrony » Sun Sep 16, 2018 12:42 am

Привет всем участникам форума!
Нашел прикольные новости на этом сайте: http://himaan.ru :
http://himaan.ru/foto-prikoly-interesno ... zraki.html Новые города-призраки
Священный месяц Рамадан 2015
http://himaan.ru/foto-prikoly-interesno ... estvu.html
RolandGrony
 
Posts: 3
Joined: Sat Sep 01, 2018 12:47 pm
Location: Россия

Удивительная информация

Postby Lancepeank » Tue Sep 18, 2018 11:59 pm

Здравствуйте!
Нашел удивительную фотосессию на этом сайте: http://okaybro.ru :
Осенние краски
Леа Сейду в AnOther Magazine http://okaybro.ru/foto-prikoly-interesn ... azine.html
http://okaybro.ru/foto-prikoly-interesn ... kitae.html
Lancepeank
 
Posts: 3
Joined: Tue Sep 04, 2018 5:50 am
Location: Россия


Return to Hacker's Warehouse Feedback

Who is online

Users browsing this forum: No registered users and 1 guest

cron