School project "Stabilized Plane seat " PLEASE HELP ME!

Hi every body,

I’m a French High school student and I have to make a project including Physics and Engineer science.
This project has to be finished for February… :confused:

Me and two friends have decided to build a Stabilized plane seat (like a camera stabilizer).

So for this project I’m using an Arduino Uno, a MPU6050 it’s the accelerometer and a structure of a drone camera stabilizer system with two servos.

I have poor skills in programming my teachers help us but they have to help other groups too so I need your help guys.

Here is what I have done so far :

#include <Servo.h> 
#include<Wire.h>

 Servo myservo1;
 Servo myservo2;
 
 
 
 const int MPU=0x68;  // I2C address of the MPU-6050
 int16_t AcX,AcY,AcZ,Tmp,GyX,GyY,GyZ;
 int Acx = 0;
 int Acy = 0;
 int angle = 120;
 int angle2=90;
 
void lire_acx();

void setup() 
{ 
myservo1.attach(4);
myservo2.attach(3);
Wire.begin();
   Wire.beginTransmission(MPU);
   Wire.write(0x6B);  // PWR_MGMT_1 register
   Wire.write(0);     // set to zero (wakes up the MPU-6050)
   Wire.endTransmission(true);      
   myservo1.write(angle2);  
   myservo2.write(angle);
   Serial.begin(9600);
   

} 

void loop()



{
lire_acx();
   /*AcY=Wire.read()<<8|Wire.read();  // 0x3D (ACCEL_YOUT_H) & 0x3E (ACCEL_YOUT_L)
   Tmp=Wire.read()<<8|Wire.read();  // 0x41 (TEMP_OUT_H) & 0x42 (TEMP_OUT_L)
   GyX=Wire.read()<<8|Wire.read();  // 0x43 (GYRO_XOUT_H) & 0x44 (GYRO_XOUT_L)
   GyY=Wire.read()<<8|Wire.read();  // 0x45 (GYRO_YOUT_H) & 0x46 (GYRO_YOUT_L)
   GyZ=Wire.read()<<8|Wire.read();  // 0x47 (GYRO_ZOUT_H) & 0x48 (GYRO_ZOUT_L)*/
   Serial.print("AcX = "); Serial.println(AcX);
   /*Serial.print(" | AcY = "); Serial.print(AcY);
   Serial.print(" | AcZ = "); Serial.print(AcZ);
   Serial.print(" | Tmp = "); Serial.print(Tmp/340.00+36.53);  //equation for temperature in degrees C from datasheet
   Serial.print(" | GyX = "); Serial.print(GyX);
   Serial.print(" | GyY = "); Serial.print(GyY);
   Serial.print(" | GyZ = "); Serial.println(GyZ);*/
   Serial.println(angle);
   Serial.println(angle2);
   //delay(00);
   



   
while( AcX<200 && AcX>-200)
{

myservo1.write(90);
lire_acx();
Serial.print("AcX = "); Serial.println(AcX);

}

if (AcX > 400)
{

 angle2 = angle2 -1;
 

 

}

else if (AcX < -400)
{
angle2 = angle2 +1;
 

}
myservo1.write(angle2);
} 


void lire_acx()
{
Wire.beginTransmission(MPU);
   Wire.write(0x3B);  // starting with register 0x3B (ACCEL_XOUT_H)
   Wire.endTransmission(false);
   Wire.requestFrom(MPU,14,true);  // request a total of 14 registers
   AcX=Wire.read()<<8|Wire.read();  // 0x3B (ACCEL_XOUT_H) & 0x3C (ACCEL_XOUT_L)  
 AcX = map(AcX, -20000, 20000, -10000, 10000);  
}

I don’t know how to continue… We have plugged the servos on a Generator because the Arduino couldn’t deliver enough power.

If somebody is familiar with all this material and can help me to make a simple program that is working I don’t want a program to complex or a perfect stabilization if you can help me make some thing similar to this one it would be great :smiley: Self-Stabilizing Platform using Arduino, Accelerometer and Gyroscope. - YouTube

I attached some pictures to allow you to see what the structure looks like

Please use [code][/code] tags, when posting code

AcX = map(AcX, -20000, 20000, -10000, 10000);

can overflow internally, while it is just the same as

AcX = AcX / 2;

Thanks for helping me :slight_smile:

I'll modify the line "AcX = map(AcX, -20000, 20000, -10000, 10000);" by "AcX = AcX / 2;" when I can thanks.

how can I continue the program for a complete stabilization for the x and Y axes? with what I have done so far my servos does not respond very well...

The application (aircraft seat stabilization) is... how do I put it?... not welcome.
What I'm trying to say is that you would not want to sit on that chair in an airplane. Pilots of commercial airliners, just like pilots of any other aircraft, are trained to perform what is called coordinated turns.
This basically means that the total acceleration (gravity plus acceleration due to turning) experienced by the passengers is normal to the floor of the aircraft, and thus the seat as well. Tilting the seat any in other direction will cause the passenger to experience lateral acceleration which is not comfortable.

Hi Shpaget and thanks for helping me :slight_smile:

I totally understand what you want to say and you must be right.

Our projects at school doesn't necessarily need to be doable in real life. we have to bring a project which include Physics and engineer science. The goal of the project is to prove the teacher you can gather your knowledge work well independently in groups without the teacher help.

I don't know if you can understand what I want to explain

I understand.
The project itself is fine, no problem there. A self stabilizing platform is a useful thing to have.
But once you present the device and explain how it works, maybe you should explain why the application is not suitable in this case.

Read this first! At least read the first 3 posts.

Then organise your code. Start with the high level:

void loop() {
  readMPU6050();
  doCalculations();
  driveServos();
  outputToUser();
}

Your main loop should look this simple. Notice how it has separate tasks which do one thing at a time and they finish doing that thing before going on to the next task. It doesn't request 14 bytes from the sensor and then read them back in little pieces spread throughout the code.

Thanks for the photos. I would suggest attaching the MPU6050 onto the platform that you are trying to stabilise. (The video linked also seems to make that mistake.)

Thank you very much MorganS! :smiley:

I tried to attached the sensor on to the platform several days ago but the servos did very strange thing and did not respond to the sensor anymore because when I send the program into the card the servos rotate to one position and then come back to the normal position but when the do this the sensor try to correct this so the all thing never stops to move because the motors never finish their initialization at the beginning so maybe I transfer the program first let do the servos "thing" then put the sensor. as long as the sensor is not on the platform when the program is sent every thing works not like i want but that's because the program isn't completed :wink:

What should I code for this line?

doCalculations();

LiamMatt:
What should I code for this line?

doCalculations();

Well, that's the core of the problem. Take your current code which examines AcX and calculates amgle2, put that into its own function.

Okay i’m back with a new code,

I found something a lot easier to understand :wink:

#include <Servo.h> 
#include<Wire.h>

    Servo myservo1;
    Servo myservo2;
    
int lire_acx();
int lire_acy();    
    
    const int MPU=0x68;  // I2C address of the MPU-6050
    int16_t AcX,AcY,AcZ,Tmp,GyX,GyY,GyZ;
    int Acx = 0;
    int Acy = 0;
    int angle =90;
    int angle2=120;
    int val;
    int prevVal;
    int valtwo;
    int prevValtwo;
  
    


void setup() 
{ 
  myservo1.attach(4);
  myservo2.attach(3);
  Wire.begin();
      Wire.beginTransmission(MPU);
      Wire.write(0x6B);  // PWR_MGMT_1 register
      Wire.write(0);     // set to zero (wakes up the MPU-6050)
      Wire.endTransmission(true);      
      myservo1.write(angle);  
      myservo2.write(angle2);
      Serial.begin(38400);
      
  
} 

void loop()



{
val=lire_acx();
      /*AcY=Wire.read()<<8|Wire.read();  // 0x3D (ACCEL_YOUT_H) & 0x3E (ACCEL_YOUT_L)
      Tmp=Wire.read()<<8|Wire.read();  // 0x41 (TEMP_OUT_H) & 0x42 (TEMP_OUT_L)
      GyX=Wire.read()<<8|Wire.read();  // 0x43 (GYRO_XOUT_H) & 0x44 (GYRO_XOUT_L)
      GyY=Wire.read()<<8|Wire.read();  // 0x45 (GYRO_YOUT_H) & 0x46 (GYRO_YOUT_L)
      GyZ=Wire.read()<<8|Wire.read();  // 0x47 (GYRO_ZOUT_H) & 0x48 (GYRO_ZOUT_L)*/
      Serial.print("AcX = "); Serial.println(AcX);
      /*Serial.print(" | AcY = "); Serial.print(AcY);
      Serial.print(" | AcZ = "); Serial.print(AcZ);
      Serial.print(" | Tmp = "); Serial.print(Tmp/340.00+36.53);  //equation for temperature in degrees C from datasheet
      Serial.print(" | GyX = "); Serial.print(GyX);
      Serial.print(" | GyY = "); Serial.print(GyY);
      Serial.print(" | GyZ = "); Serial.println(GyZ);*/
      Serial.println(angle);
      Serial.println(angle2);
      //delay(00);
      
valtwo=lire_acy();
      /*AcY=Wire.read()<<8|Wire.read();  // 0x3D (ACCEL_YOUT_H) & 0x3E (ACCEL_YOUT_L)
      Tmp=Wire.read()<<8|Wire.read();  // 0x41 (TEMP_OUT_H) & 0x42 (TEMP_OUT_L)
      GyX=Wire.read()<<8|Wire.read();  // 0x43 (GYRO_XOUT_H) & 0x44 (GYRO_XOUT_L)
      GyY=Wire.read()<<8|Wire.read();  // 0x45 (GYRO_YOUT_H) & 0x46 (GYRO_YOUT_L)
      GyZ=Wire.read()<<8|Wire.read();  // 0x47 (GYRO_ZOUT_H) & 0x48 (GYRO_ZOUT_L)
      Serial.print("AcX = "); Serial.println(AcX);*/
      Serial.print(" | AcY = "); Serial.print(AcY);
      /*Serial.print(" | AcZ = "); Serial.print(AcZ);
      Serial.print(" | Tmp = "); Serial.print(Tmp/340.00+36.53);  //equation for temperature in degrees C from datasheet
      Serial.print(" | GyX = "); Serial.print(GyX);
      Serial.print(" | GyY = "); Serial.print(GyY);
      Serial.print(" | GyZ = "); Serial.println(GyZ);*/
      Serial.println(angle);
      Serial.println(angle2);
      //delay(00);
      
  

  
  if (val != prevVal)
    {
        myservo1.write(val);
        prevVal = val;
    }
 
    delay(70);
    
    
    if (valtwo != prevValtwo)
    {
        myservo2.write(valtwo);
        prevValtwo = valtwo;
    }
    
    delay(70);
    
  }
 
  


int lire_acx()

{
   Wire.beginTransmission(MPU);
      Wire.write(0x3B);  // starting with register 0x3B (ACCEL_XOUT_H)
      Wire.endTransmission(false);
      Wire.requestFrom(MPU,14,true);  // request a total of 14 registers
      AcX=Wire.read()<<8|Wire.read();  // 0x3B (ACCEL_XOUT_H) & 0x3C (ACCEL_XOUT_L)  
    AcX = map(AcX, -20000, 20000, 0, 180); 
   return (AcX);
    
   
   }
   

int lire_acy()

{
   Wire.beginTransmission(MPU);
      Wire.write(0x3B);  // starting with register 0x3B (ACCEL_XOUT_H)
      Wire.endTransmission(false);
      Wire.requestFrom(MPU,14,true);  // request a total of 14 registers
      AcY=Wire.read()<<8|Wire.read();  // 0x3D (ACCEL_YOUT_H) & 0x3E (ACCEL_YOUT_L)  
    AcY = map(AcY, -20000, 20000, 0, 180); 
   return (AcY); 
   
   }

So everything is working fine for the X axe but the Y axe doesn’t respond to the Value sent from the sensor. When I move the sensor on the Y axe nothing happen for the Servo2… but when I move the sensor on the X axe the Servo 1 and 2 moves I think there is a problem in my Code organization but I can’t find it.

to my homie, young matt,

you could create an arduino project in its own, developing a 2 or 3 axis test stand for your experiment.

the stand could create random motion, or be connected to a joystick for user control.

it would seem to me you would need such a test stand to prove that your experiment were able to maintain stability in any condition.

Thanks for all your help guys :wink:

anyone can help me for the program itself ? I appreciate your help for the project in general but my real problem here is the code and i can't find how to separate the Servo from the same axe because for now all my servos are responding to the X axe...

Greensprings:
Are you saying that a three axis stabilized chair on an airplane would try to maintain an upright position
during a coordinated turn, with relation to the center of the earth, or in relation to the center of the plane, or the y axis of the cabbin?

This actually is an interesting question to study, and could get an A at a science fair project, and all depends on the equipment, programming and response time? I think your assumption statement may be flawed.

If the sensors are accelerometers, than they will since the artificial gravitational direction which is created by the dynamics of the coordinated turn. If the coordinated turn is implemented properly, the seat will function, because it does not have to do anything. The big question is what happens when the turn is not implemented exactly, what is the frame of reference that the chair will use to compensate?

What happens in straight and level flight around the globe, does the seat reference the earth's gravitational vector, which is always changing, the artificial gravitational vector generated by the flight dynamics or the y axis in relation to the cabin mapping. What happens when turbulence is encountered and a negative g force is experienced?

That depends entirely on the programming. The software will do exactly what it's told to do and will reference according to instructions.
The designer of the system has to make the decision.
For dealing with turbulence, I suppose a buffering system would be required.
But why would one assume a plane will be performing slipping (uncoordinated) turns as a standard procedure?

Hi,

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png or pdf?

Tom..... :slight_smile:

Hi,

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png or pdf?

Tom…

Hi Tom :smiley: I made a paint draw, I hope you’ll understand :wink:

Have you tested the servos using a servo example or an RC servo tester to verify your control signals are
working ?
Without using acelerometer code can you rotate the servos to both extremes ?

I would suggest the project start as a stabilized "something", then move to the particular application desired (too much non productive churn concerning airplanes). Break the project into its different components and work on those first.

Have you tested the servos using a servo example or an RC servo tester to verify your control signals are
working ?
Without using acelerometer code can you rotate the servos to both extremes ?

Yes they are both working fine, I used a Drone stabilized structure for a camera (pictures on my first post) :slight_smile:

Zoomkat my project doesn't only shows the final product, I have to make a Full report which explain all my project step by step so every thing, every part of the project will be explained. All french students in high school have to do that and it's supervised by our teachers. My real problem here is the program I need help to finish it and have the X and Y axes stabilized :wink:

every part of the project will be explained.

Then can you actually explain what function a "Stabilized Plane seat " will perform in an airplane? As others have hinted, it seems a somewhat strange application. What happens if the airplane maneuvers beyond the stabilization range of the seat?

My idea is to bring more comfort to passengers of an airplane during turbulence (Take off and approach in bad conditions) NOT during the whole flight!

During a coordinated turn the passenger doesn't feel uncomfortable because the total acceleration experienced by the passengers is the same as if he was on the ground The pilot is pulling the yoke at the same time is turning it http://www.free-online-private-pilot-ground-school.com/images/forces_during_turn.gif
Adding a stabilization into these normal states of flight will not bring more comfort to the passenger.

During bad weather or windy days, when the plane take off or land the pilot has to correct all the unwanted movements of the plane due to the wind, these correction made by the pilot are not the same as a coordinated turn and it's during these states of flight the people feel uncomfortable so the stabilized seat would be welcome there.
The pilot during these condition is constantly moving the Yoke in order to keep the plane align to the Runway but these correction are not for the comfort of the passengers but to land or take off safely.

is it more comprehensible? I never wanted to stabilized the seats all the time even during cruise but only when needed. watch this video it shows well how planes performs in bad weather :

And also this project will not be commercialized nothing as to be perfect. If the project couldn't be made in real life it's not dramatic I'm not evaluate on that :wink:

But I hope you'll understand what I want to achieve :slight_smile:

It sounds like you want to develop a shock absorbing active suspension system for the seat. Google searching might find similar systems used in off road or ocean racing vehicles.