Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Turn Devia-Board 90°??
05-18-2020, 12:45 PM
Post: #1
Turn Devia-Board 90°??
Hello together. I want to know if it is possible to turn the Devia-Board around 90° or have I to change the code? Want this info before start my drawings in CAD. I think the gyro calibrates itself in every position, but I'm not sure and don't want to disassemble my robot if anybody know it sure...
Find all posts by this user
Quote this message in a reply
05-18-2020, 01:32 PM
Post: #2
RE: Turn Devia-Board 90°??
(05-18-2020 12:45 PM)Greengecko Wrote:  Hello together. I want to know if it is possible to turn the Devia-Board around 90° or have I to change the code? Want this info before start my drawings in CAD. I think the gyro calibrates itself in every position, but I'm not sure and don't want to disassemble my robot if anybody know it sure...

Yes, it is possible. But you will need to add that offset to the Arduino code. But that is all.
Visit this user's website Find all posts by this user
Quote this message in a reply
05-18-2020, 02:42 PM
Post: #3
RE: Turn Devia-Board 90°??
thank you a lot. this save me a lot of time.
Find all posts by this user
Quote this message in a reply
05-21-2020, 08:40 PM
Post: #4
RE: Turn Devia-Board 90°??
I think this can't be the value that I have to change, I think the code must be changed to flip x y z values from the gyro. For better understanding I have uploaded the picture from my robot ... The Devia board is turned about 90° to the right....


Attached File(s) Thumbnail(s)
   
Find all posts by this user
Quote this message in a reply
05-22-2020, 10:15 AM (This post was last modified: 05-22-2020 10:26 AM by JJrobots JP.)
Post: #5
RE: Turn Devia-Board 90°??
I see. Looking good!
You will have to use the other axis acceleration instead the X one.
For that, go to IMU.ino file, find this function:
Code:
// This function implements a complementary filter to fusion gyro and accel info
float MPU6050_getAngle(float dt)
{
  accel_angle = atan2f((float)accel_t_gyro.value.y_accel, (float)accel_t_gyro.value.z_accel) * RAD2GRAD;
  x_gyro_value = (accel_t_gyro.value.x_gyro - x_gyro_offset) / 65.5;  // Gyro scale at 500deg/seg  => 65.5 LSB/deg/s

  // Complementary filter
  // We integrate the gyro rate value to obtain the angle in the short term and we take the accelerometer angle with a low pass filter in the long term...
  angle = 0.99 * (angle + x_gyro_value * dt) + 0.01 * accel_angle;  // Time constant = 0.99*0.01(100hz)/(1-0.99) = 0.99, around 1 sec.
  
  // Gyro bias correction
  // We supose that the long term mean of the gyro_value should tend to zero (gyro_offset). This means that the robot is not continuosly rotating.
  int16_t correction = constrain(accel_t_gyro.value.x_gyro, x_gyro_offset - 10, x_gyro_offset + 10); // limit corrections...
  x_gyro_offset = x_gyro_offset * 0.9995 + correction * 0.0005; // Time constant of this correction is around 20 sec.

  //Serial.print(angle);
  //Serial.print(" ");
  //Serial.println(x_gyro_offset);

  return angle;
}

And change it for:

Code:
// This function implements a complementary filter to fusion gyro and accel info
float MPU6050_getAngle(float dt)
{
  accel_angle = atan2f((float)accel_t_gyro.value.y_accel, (float)accel_t_gyro.value.z_accel) * RAD2GRAD;
  y_gyro_value = (accel_t_gyro.value.y_gyro - y_gyro_offset) / 65.5;  // Gyro scale at 500deg/seg  => 65.5 LSB/deg/s

  // Complementary filter
  // We integrate the gyro rate value to obtain the angle in the short term and we take the accelerometer angle with a low pass filter in the long term...
  angle = 0.99 * (angle + y_gyro_value * dt) + 0.01 * accel_angle;  // Time constant = 0.99*0.01(100hz)/(1-0.99) = 0.99, around 1 sec.
  
  // Gyro bias correction
  // We supose that the long term mean of the gyro_value should tend to zero (gyro_offset). This means that the robot is not continuosly rotating.
  int16_t correction = constrain(accel_t_gyro.value.y_gyro, y_gyro_offset - 10, y_gyro_offset + 10); // limit corrections...
  y_gyro_offset = y_gyro_offset * 0.9995 + correction * 0.0005; // Time constant of this correction is around 20 sec.

  //Serial.print(angle);
  //Serial.print(" ");
  //Serial.println(y_gyro_offset);

  return angle;
}

Due to the lockdown I can not access to a B-robot and test this modification but it should work.
YOU MAY NEED to add a - to those y_XXXXX parameters if the board is rotated 180º on that XY plane or just change the spinning direction of the motors rotating the motor connectors on the DEVIA board (connecting them backwards)
I hope this helps :-)
Visit this user's website Find all posts by this user
Quote this message in a reply
05-22-2020, 11:17 AM (This post was last modified: 05-22-2020 11:34 AM by Greengecko.)
Post: #6
RE: Turn Devia-Board 90°??
Thanks for the reply, I've changed the code with your modifications and first Arduino couldn't compile it. I've added this
Code:
float y_gyro_value;   // in deg/seg units
float y_gyro_offset = 0.0;
and the sketch was compiling. But anywhere must be set a offset value because it only balance itself only if I hold it and turn backways. I will make a video in a few minutes and you will see the result.

This is the video with first result. It goes in the right way but didn't work fine. Maybe should add somewhere an offset?

https://youtu.be/k_T39ajBIsw
Find all posts by this user
Quote this message in a reply
05-22-2020, 01:47 PM
Post: #7
RE: Turn Devia-Board 90°??
Hmm... the robot should be orientated 90 degress laying on its front/back during the calibration. I am not sure I am appreciating what the bottom or front of your design is... Could that be the reason?
Like in this video: https://www.jjrobots.com/wp-content/uplo...g-up-1.mp4
Visit this user's website Find all posts by this user
Quote this message in a reply
05-22-2020, 02:31 PM (This post was last modified: 05-22-2020 02:36 PM by Greengecko.)
Post: #8
RE: Turn Devia-Board 90°??
I've tried every four possibilities, but after calibration it still drives away without doing any control command from the app. Video is online in a few minutes. the best calibration result is like in the video

https://youtu.be/JBn5A7WpSvE

forgot to say ... in the video the segway is moving backward. the motor drivers on the board are looking forward. usb and power is on the back side
Find all posts by this user
Quote this message in a reply
05-22-2020, 03:19 PM (This post was last modified: 05-22-2020 03:26 PM by justjason.)
Post: #9
RE: Turn Devia-Board 90°??
I think you have mechanical balance issues that you need to sort out. Your center of balance needs to be above, not below the motors. Just for fun, try mounting the battery on some type of shelf / extension above the motors , say 10cm. And also, have you adjusted the offset angle ? You have seem to have all the weight on one side( battery) so the balance point looks like it will not be 0⁰. This should be adjusted in the config.
Find all posts by this user
Quote this message in a reply
05-22-2020, 03:36 PM (This post was last modified: 05-22-2020 03:37 PM by Greengecko.)
Post: #10
RE: Turn Devia-Board 90°??
Please look this Video, the robot balancing himself when I hold him and turned to a Position where the gyro thinks He is upright


https://youtu.be/Cx1LB6TrKMw

Not really correct, the nose of the segway is full filled because it should Mount the steering rod
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)