Notifications
Clear all

Hello from Kentucky

6 Posts
3 Users
5 Reactions
785 Views
(@rockygentry)
Member
Joined: 2 years ago
Posts: 3
Topic starter  

Hello,

A novice in robotics, I am working with mechanical gyros and control systems.

I look forward to learning more about this fascinating technology, seeking advice and sharing what I learn.

Sincerely,

Jeffrey


   
Quote
(@rockygentry)
Member
Joined: 2 years ago
Posts: 3
Topic starter  
I am running a mechanical gyroscope controlled with an Ardiuno Ono, Servo, and MPU-6050. 
It is portable, the accelerometer is getting vibration feedback and violently shaking the project through the Servo.
Can I isolate the vibration and smooth the movement of the Servo with a change in my sketch?
 
Please advise.
 
Sincerely,
Jeffrey 

 

 

 

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

Adafruit_MPU6050 mpu;
int x = 0;
int y = 0;
int z = 0;

Servo servo1;
Servo servo2;
Servo servo3;
Servo servo4;

int value  = 0;

void setup(void) {
  Serial.begin(115200);

  // Try to initialize!
  if (!mpu.begin()) {
    Serial.println("Failed to find MPU6050 chip");
    while (1) {
      delay(10);
    }
  }
  Serial.println("MPU6050 Found!");

  // set accelerometer range to +-8G
  mpu.setAccelerometerRange(MPU6050_RANGE_8_G);

  // set gyro range to +- 500 deg/s
  mpu.setGyroRange(MPU6050_RANGE_500_DEG);

  // set filter bandwidth to 21 Hz
  mpu.setFilterBandwidth(MPU6050_BAND_21_HZ);

  delay(100);
  servo1.attach(7);
  servo2.attach(6);
  servo3.attach(5);
  servo4.attach(4);

  servo1.write(0);
  servo2.write(0);
  servo3.write(0);
  servo4.write(0);
}

void loop() {
  /* Get new sensor events with the readings */
  sensors_event_t a, g, temp;
  mpu.getEvent(&a, &g, &temp);

  x = a.acceleration.x;
  y = a.acceleration.y;
  z = a.acceleration.z;

//Serial.print(x);Serial.print(" ");Serial.println(y);
if (x < 10 && x > 0 && y < 4 && y > -4){
  Serial.println("up");
   value = map(x,  0, 10, 0, 180);
   servo1.write(value);
   Serial.print(value);
  }
else if (x > -10 && x < 0 && y < 4 && y > -4){
  Serial.println("down");
  value = map(x,  -10, 0, 180, 0);
  servo2.write(value);
  Serial.print(value);
  }

if (y < 10 && y > 0 && x < 4 && x > -4){
  Serial.println("Right");
  value = map(y,  0, 10, 0, 180);
  servo3.write(value);
  Serial.print(value);
  }
else if (y > -10 && y < 0  && x < 4 && x > -4){
  Serial.println("left");
  value = map(y,  -10, 0, 180, 0);
  servo4.write(value);
  Serial.print(value);
  }
}




 
 
 
 
 
 
 
 
 
 
 
 
 

   
ReplyQuote
(@davee)
Member
Joined: 3 years ago
Posts: 1721
 

Hi @rockygentry,

   I don't know if you have made any progress, but hoped you might appreciate a comment.

I haven't used the kit you describe, but maybe I can imagine the problem you describe.

I assume you trying to build something like a self levelling platform. If so, essentially, you will need to add some some software between getting new sensor values  and updating the servo drive. I suspect this will be a classic control problem, which often requires more complex solutions than simple filtering.

I suggest you look on the Internet for more information ..

I haven't viewed these particular videos but I note Paul McWhorter has produced some that might be helpful, for example

//www.youtube.com/watch?v=7YIOqv4TJNo 

9-Axis IMU LESSON 25: Proportional Control System for Self Leveling Platform

Good luck, Dave


   
ReplyQuote
(@rockygentry)
Member
Joined: 2 years ago
Posts: 3
Topic starter  

@davee

Thank you Dave, this is very helpful!

@rockygentry


   
ReplyQuote
Inst-Tech
(@inst-tech)
Member
Joined: 2 years ago
Posts: 554
 

@davee, Indeed, Paul McWhorter's video emphasizing the PID control is the ticket to precise control as you can tune the parameters of the PID to optimize process stability.. In the industrial arena, we were quite familiar with PID controls, fuzzy logic, and pseudo -neural networks..His video is right on the money!

thanks for your feedback, and the link to the video..

regards,

LouisR

LouisR


   
ReplyQuote
(@davee)
Member
Joined: 3 years ago
Posts: 1721
 

Hi @inst-tech and @rockygentry,

   Thanks @inst-tech for the confirmation and thanks @rockygentry for your kind reply - I hope my answer will prove useful. As I said, I haven't watched that particular video, but I have seen seen some of his other ones, and (like those by our host, Bill), they have all been well researched and presented.

I picked that particular video as the title most closely matched what I guessed you were trying to do. If that is the case, then my experience suggests Paul has a very thorough and systematic approach, and I would expect complex topics such as this one to be distributed over several videos. I recommend you examine Paul's entire list, since I suspect you will find others which are also helpful.

Good luck with your project. Dave


   
Inst-Tech reacted
ReplyQuote