MATLAB Arduino Tutorial 2 - Connecting and calibrating a 3-axis accelerometer

preview_player
Показать описание

Configuration:
- Matlab R2012a
- Arduino 1.0.1
- USB 2.0
- Freescale MMA7341L

Рекомендации по теме
Комментарии
Автор

Thank you so much Sir. Also please make a video on strapdown inertial navigation system (SINS) using the outputs of strapdown gyros and accelerometer in matlab and simulink. And then perform DCM(direct cosine matrix) to calculate position and velocity of an aircraft

sahithiannamaraju
Автор

Thank you for your question. We sent you a reply message. Sincerely, MatlabArduinoOrg

matlabarduino
Автор

Thanks for the tutorial! I am looking to measure very low amplitude, low frequency vibrations. Would the MMA7341L be appropriate for this - could you suggest a more appropriate model? Thank you for you time

oli
Автор

Hey
I am using a 9DOF Sensor Stick to read Accelerometer, Magnetometer and Gyroscope i have written a code via Arduino IDE and it works fine.

I need a matlab communication so i used your tutorial which is great by the way there seems to be a problem.

I keep getting this warning
" Warning: Unsuccessful read: A timeout occurred before the Terminator was reached."

Please note that i am reading 9 values so i inherited your idea.

Looking forward

ahmedaboubakr
Автор

Very good job. Do you intend to use also other sensors, such as MPU6050? thx

PotmeHunt
Автор

Thank you for your question Duy. All the code is actually displayed in the videos. As a matter of policy, these videos are meant to encourage the audience to create and further curate their own code repository. In the same vein, we encourage you to write your own code - should you run into technical issues, we are happy to provide support to the extent possible. Sincerely, MatlabArduinoOrg

matlabarduino
Автор

Where can I find the Stop_Call_Vector code?

Thank you for these tutorials also, it's awesome to see it run.

joshuam
Автор

Great Tutorial! thanks a lot!
I've been struggling with the "out" structure in the readAcc function.
In the Tutorial #1, the details about the "out" structure with its field "s" haven't been given...and what I'm missing is the reference between the serial object created "s", ith the function "setupSerial" and the object "s" enclosed in the readAcc function...I guess (i'm not an expert at all!! sorry...!)

What do I have to do?! since i get the message "Undefined function or variable 'out'"..
Thanks for the help!

gianlucalongoni
Автор

isn't it possible to do everything using matlab only rather than connecting uploading using Arduino Idle?

sameqy
Автор

i followed your steps exactly, and I have the same sensor (MMA7341L) and I followed the same exact code and yet my accelerometer does not display the same way as yours, in fact its way off, and when i continue on to video 3 and I follow the same code as well it doesn't plot like any of the graphs your showing and the data that i am getting don't make any sense, is there anything else you connected to the accelerometer? also the mma7341l takes a maximum of 3.6V, why do you connect it to the 5V pin on the arduino UNO? I will send you the code for the arduino and matlab for calibrating the accelerometer and I would appreciate it if you would look at it and let me know what am i doing wrong.
thnx

maggieperez
Автор

Hi!! for @0:39 I need to declare the analog in pin. However I am using a ardupilot board which has an onboard accelerometer using I2C bus. what should I put there instead?

thank you

fzjune
Автор

Hey having a small issue with the code, when i try to run the calCo function I get this error 'Undefined function 'calibrate' for input arguments of type 'serial'., any help would be greatly appreciated, thanks

JakeB
Автор

Hey, ,, well my problem was that i was using to many serialprint during testing with the arduino serial monitor when i removed them everything worked just fine :D:D

Its the same one used in the video i didn't change a bit.

Hope this helps

I should also use this data and do something like tracking a 3d object orientation ....

Any ideas or references to the math used ????

AhmedMohamed-bjqj
Автор

I realize this is 4 years old, but I have this issue:

Warning: Unsuccessful read: A timeout occurred before the Terminator was reached.
In an assignment A(I) = B, the number of elements in B and I must be the same.

Error in readAcc (line 5)
readings(1) = fscanf(out.s, '%u');

Error in calibrate (line 9)
[gx_z gy_z gz_z] = readAcc(out, calCo);


Any suggestions?

rj
Автор

Hi Matlab Arduino. I couldn't find the files stop_call_vector/magnitude.m in your video. Did I miss something?

rmtrajaismail
Автор

Hello Matlab Arduino, you can't imagine how your tuto helps me:)
unfortunately I have one issue. During the calibration phase for Y Matlab freeze and the simulation is blocked. Have you any idea ? because Z and X calibration is working well. 

Thank you

thetoto
Автор

Hi wondering if anyone here can help me. I am building a balancing machine and want to use accelerometers. I really am lost when it comes to electronics and wondering if someone could take the time to tell me how to set up accelerometers and what hardware/software will be required to acquire data. Thanks to all and great tutorial.

banditcountry
Автор

GOD, I have been here for hours trying to figure this out! I just want to pull a value from Arduino to it! The code is confusing....

amedmesa
Автор

Why do not you post the matlab's and arduino's file? You only introduce tools, this is not a tutorial

TheTuylipden
Автор

Hello 

I have a 9DOF IMU that i programmed using Arduino IDE to read the data and display it on a serial monitor on Arduino

Now i need to read these data in Matlab continuously so i could plot a graph 

I read 10 times each time 18 values 

void loop()
{
  if(Serial.available() > 0) //Check if any data has been sent by the PC
  {
    mode = Serial.read();//Check if there is a request for Sensors Values
    if(mode == 'R')//Used to set different modes for various operations. R is used to read Sensors Values: 
    {
      //Calculate Offset ONLY ONCE AT THE BEGINING
      Calculate_Offset();
        
      for (int i = 0 ; i<10 ; i++)
      { 
        //Read the Accelerometer
        Read_ADXL345();
        Serial.println(Acc_Data[0]);
        Serial.println(Acc_Data[1]);
        Serial.println(Acc_Data[2]);
        
        //Accelerometer Offset Compensation & Scaling
       
        Serial.println(Acc_Data[0]);
        Serial.println(Acc_Data[1]);
        Serial.println(Acc_Data[2]);
        
        //Read the Magnetometer
        Read_HMC5883L();
        Serial.println(Mag_Data[0]);
        Serial.println(Mag_Data[1]);
        Serial.println(Mag_Data[2]);
        
        //Magnetometer Offset Compensation & Scaling
       
        Serial.println(Mag_Data[0]);
        Serial.println(Mag_Data[1]);
        Serial.println(Mag_Data[2]);
        
        //Read the Gyroscope
        Read_ITG3200();
        Serial.println(Gyro_Data[0]);
        Serial.println(Gyro_Data[1]);
        Serial.println(Gyro_Data[2]);
        
        //Gyroscope Offset Compensation & Scaling
       
        Serial.println(Gyro_Data[0]);
        Serial.println(Gyro_Data[1]);
        Serial.println(Gyro_Data[2]);
      }
    }
  }
}


function [a] = ReadSensorStick(out)
%UNTITLED2 Summary of this function goes here
%   Detailed explanation goes here

    fprintf(out.s, 'R');
    
    for i=1:18
          a = fscanf(out.s, '%f');
    end
end

ahmedaboubakr