Active front wing - 1 axis gyro/servo

Hi there,

New to Arduino and zero coding experience so any help much appreciated

I'm trying to make an active front wing for my powerboat, normally at 0 angle of attack then if the bow of the boat begins to raise up too much, beyond maybe 10 degrees the wing will point down to bring it back level.

I've got an Arduino Uno, MPu6050 gyro and a 25kg servo.

So far just copy and pasting code from online then attemping to adapt it. Seems to work but not getting a linear response at all, can't make sense of it.
Would ideally like to have the servo move the wing to around 60 degrees when the mpu6050 is at 10 degrees (x axis roll). Then slowly go back to 0 as the mpu6050 goes back level.

Here's the code I've got at the moment:

#include <Wire.h>

#include <MPU6050.h>

#include <Servo.h>   

Servo sg90;          

int servo_pin = 2;

MPU6050 sensor ;

int16_t ax, ay, az ;

int16_t gx, gy, gz ;

void setup ( )

{ 

sg90.attach ( servo_pin );

Wire.begin ( );

Serial.begin  (9600); 



Serial.println  ( "Initializing the sensor" ); 

sensor.initialize ( ); 

Serial.println (sensor.testConnection ( ) ? "Successfully Connected" : "Connection failed"); 

delay (1000); 

Serial.println ( "Taking Values from the sensor" );

delay (1000);

}




void loop ( ) 

{ 

sensor.getMotion6 (&ax, &ay, &az, &gx, &gy, &gz);

gx = map (gx, -17000, 17000, 0, 180) ;
Serial.println (gx);
sg90.write (gx); 
delay (100);

}

Hi, @roflhat1
Welcome to the forum.

Please read the post at the start of any forum , entitled "How to use this Forum".

This will help with advice on how to present your code and problems.

How will you compensate for the acceleration/deceleration of the boat?

Tom... :smiley: :+1: :coffee: :australia:

Cheers, didn't see that button at first!

The boat generally doesn't change angle too much when decelerating. When accelerating the bow does tend to lift, but the front wing being angled down should help then too. It's really to prevent blowovers at full speed, around 75mph which hurts.

If it works I was thinking of splitting the front wing into halves and then operating each side seperately so it could aid cornering too

What does the serial output look like?

The numbers change, sometimes makes the servo move and other times it doesn't but I'm unsure why

Can you record it and post what you get?

Now gone back to this exact code, sometimes seems to work but it's intermittent, bad connection maybe?

Where is the power for the servo coming from?

You really can’t even lower a dinky servo like the one pictured from the 5 volt pin on an Arduino.

If you don’t have enough power, it cou,d cause strange symptoms.

a7

There will be an issue that a boat tends to move up and down with normal operation ( waves etc) , so getting a meaningful signal maybe hard .

I’m assuming this is a model boat btw …

Power for the servo is just coming from the 5v, seems to be moving ok at the moment although not under load.

Tried putting a battery as the power source and the whole system worked much better, pretty much perfect. So just need to find a way to adjust the code so it only works from the gyro x axis and not the others.

Not a model boat, a thundercat inflatable 4m. Will only be used for high speed runs which I only do when it's very calm

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.

@roflhat1,
I have deleted your new topic and opened this one as your new question is clearly a continuation of this topic. Please ask your new question here.

Thank you.

Thanks mate

Got the wing just about up and running. Just wondering what sort of batteries folk would recommend? Tried a rectangular 9v but it's not even up to moving it at 0mph. Needs to work at 70+mph. Hardware I'm not sure is up to the task either but will find out...

You realize 25kgcm is only 2.45 Newton meters, 1.8 lb ft?
And the wind force at 75 mph is 9 times what it is at 25?

With #15 in mind, if it becomes a problem, use an assisted control surface.
Other than that there are a few systems floating around on youtube for r/c aircraft stability controllers which may help you out.
Just use say elevator stability section of the code.

9V smoke alarm batteries are not suitable in any way, shape or form for any gear with servos.
Use a 4 x AA pack or similar.

I worked out that there should be 4.5kg on each half of the wing at 75mph. The bar going through them is close to the centre of area so hopefully the servo isn't having to move too much weight/force

Thanks, will probably order a 5 or 6 AA pack

Perhaps the bar is going through near the centre of lift BUT that bar needs to be rotated at some distance from the centre.

5 or 6 AA could be too much depending on the servo used and the type of AA.
Most standard servos have a top limit of 6v.

Hi,
You need to remember that the servo will use power moving to a position, but will also use power to keep that position if any torque is present.
What torque do you expect at 70mph?

Tom.. :smiley: :+1: :coffee: :australia:

Have a look at motorised spoilers on existing cars - they tend to use geared DC motors (12v) running through a gearbox .

If you are getting 4.5 kg on the spoiler , using some maths will your down force will be less than that ?