auto heading

Hi to all,

I'm new to this newsgroup and to the robotics too :-)

I have a boat with three motors: one on the rear and two on both sides. These two are on-off type, so I can turn on or turn off but I can't change the speed. The boat has an electronic compass and a gyro on-board.

Well, I need to implement an auto heading feature. One can set the hdg via an RS485 link and the microcontroller on the boat should rotate the boat itself and should maintain the track also in presence of wind or other "noises".

I have some questions:

1) How should I use the data provided from both compass and gyro?

2) What kind of algorithm is more suitable for this application? PI, PID, other.....

Thank you, Marco / iw2nzm

Reply to
marcotrapanese
Loading thread data ...

To keep things simple, start by just using the compass with a low-pass filter to reduce the noise. If you need better results, the Kalman filter would be a good next choice.

Basically, the compass gives a stable long-term estimate of your heading but its either noisy or unresponsive to quick motion. The gyro provides good short-term info, but they tend to drift over time.

Its hard to say without more info. That said, water provides plenty of damping, so I doubt you'd need a derivative control term. You could probably get away with manually tuning a PI control that drives a low-frequency (~0.5Hz) PWM on your motors (assuming you don't have a proper PWM controller for them). A well-chosen integral control might even suffice (no P term).

To explore the control more throughly, you could generate "Bode plots" by applying constant-period control signals to the motors. For example, measure the time delay (phase) and angular change (amplitude) to a series of [right 1s], [left 1s] commands. Then repeat for 2s, 4s, ... pulses. Also repeat at a few fixed forward velocities (stopped, nominal cruise, fastest). Plotting this information for a few different settings reveals significant information about the system dynamics.

Basic things to look for:

- a good PWM frequency will be slightly less than what causes a "significant turn"

- keep the proportional gain low enough that "the phase does not exceed

180 degrees" (i.e. the delay is less than 1s in the 1s pulse sequence)

I've rambled enough.

- Daniel

Reply to
D Herring

Ok.

Does "the gyro tends to drift" mean that after some time I get an angular velocity also if I go straight? If so, how one should use gyros? Or better... where can I find some literature on this concept?

Well, I guess you're right. I'll try first this way.

It's a good idea!

I think I have to select the "good" PWM frequency once I set output at 50%. So I will get a "significant turn" at 50%, over this I can rotate faster and below I can make fine movements. Am I right?

Of course, otherwise it's prone to oscillate....

I thank you very much!!!!

Marco / iw2nzm

Reply to
Marco Trapanese

Since the compass measures the earth's magnetic field, it will always point in "the right general direction" (assuming there is no interference from iron, other magnets, or electrical circuits).

The gyro, on the other hand, does not have an external reference. Any miscalibration will cause its internal reference to rotate slowly. Over time, it will "drift" and the internal angular reference will show increasing deviation from an external reference. Observe this by leaving the gyro in a fixed position and watching its output. Really good units (e.g. submarine equipment) don't drift much at all (they can measure the angular precession of the earth turning), but I've never had the benefit of using one. The cheap stuff I've used drifted at rates around 1 degree per minute, depending on the temperature.

To mix the gyro and compass measurements, start with a fixed-gain filter like

H[t] = (1-a-b)*H[t-T] + a*CH[t] + b*(GH[t]-GH[t-T]) where t - current time T - sampling interval (assuming both sensors are measured at the same time) H - heading (H[t-T] is the previously calculated heading) CH - compass heading GH - gyro heading (GH[t-T] is the previous measurement) a,b - weighting coefficients where 0

Reply to
D Herring

Now, I'm quite sure too because you put me on the right way :-)

Marco / iw2nzm

Reply to
marcotrapanese

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.