Servo travel/throw

I am an absolute beginner in the field of Arduino and am attempting to create a device capable of steering a small boat to a preset heading… just that. Press a button and the current course is maintained.

Using an Arduino Uno, MPU6050 and a single servo I can get the servo to respond accurately to the sensor movements using the excellent code provided by Nevit Dilmen (thank you very much) on his blog here;

Sorry, not sure how to post the code into a window here.

At the moment a movement of -90deg to +90deg of the sensor gives a corresponding movement of -90deg to +90deg of the servo.

My aim is to achieve full -90 to +90 servo movement with only -10deg to +10deg sensor movement
Some guidance would be greatly appreciated.

Some guidance would be greatly appreciated.

You need help multiplying a value by 9? Really?

No… just help to identify which value to multiply and maybe a simple explanation to help understand the process.

As I said, I’m a complete beginner

just help to identify which value to multiply

You said:

At the moment a movement of -90deg to +90deg of the sensor gives a corresponding movement of -90deg to +90deg of the servo.

So, you are driving the servo with SOME value. Multiplying that value by 9 isn't rocket science.

Hi, Try the MAP fuction to re-scale -10-+10 to -90-+90. How do we know which value, you hav'nt shown us any of your code or values... I'm not a mind reader and my chrystal ball is broken..

Hope it helps, regards.

Mel.

As I said in opening, I am unsure how to post the long code into a window here, so included a link to the site from which I obtained the code.

I don't claim to understand the first thing about this subject, I have just cut and pasted the code and it worked. However, it needs a bit of tweaking

Hi,
Then learn! how do you hope to do anything if you’re just going to sit there!! We all have to start somewhere (in 2 months I will be 70, and was an idiot when I left school, without any passes)., look for the </> above you use this to enter your code (past it in-between <>), see the guides at the top of the forum, etc.

People don’t want to go jumping all over the internet looking for your code…

Regards

Mel.

Can’t post the code, seems it exceeds the 9000 character limit on this site.

I am attempting to learn, that is why I’m here asking what I thought was a reasonable question, in the hope of a reasonable answer or two… at least some pointers regarding where to look in the very complicated code.

tweak the myservox.write() and/or myservoy.write() calls

the parameters are currently ('goop'+90), you need (goop*9 + 90) or something like that. the 9 is a gain factor, use less if you find the servos are 'pegging'

Why did you build the boat?

-jim lee

Sorry, not sure how to post the code into a window here.

If it exceeds the 9500 character limit, you can't.

What you CAN do is use Reply (NOT the Quick Reply field), and select the Additional Options link that looks nothing like a link, and attach your code.

It's important to mention that using a gyro like the MPU6050 is inappropriate for a boat. The sensor will continually report some small bit of rotation ("drift") and over longer periods of time your boat will travel in a circle. To put that another way, the accuracy of a MPU6050 is +/- 20 degrees/second when it's not moving.

The gyro will be good for short term heading corrections -- like when a wave hits your boat -- but to maintain a long-term heading you need to use a GPS and/or magnetometer.