What I want to do
Measure sailboat mast rotation relative to the hull so I can correct wind angle measurements from the top of the mast.
How I want to do it
One IMU/compass on the bottom of the mast and another .3m below it fixed to the hull.
Additional details
Roll and pitch will be the same on both sensors. Yaw difference is what I would like to measure in degrees.
This is a trimaran, so boat will heel (roll) up to 20 degrees, although 10 degrees is more typical.
My biggest concern is not absolute accuracy, but repeatability between the two sensors.
The greatest difference in heading between the two sensors would be 90 degrees, with 45 being more typical.
As a secondary task, wind direction is determined by two out of phase 0-8v signals which vary by wind direction. My goal is to read these, correct for mast rotation, then output corrected 0-8v signals.
The local environment should have very little in the way of magnetic materials. No iron or steel anywhere near the sensors.
Hardware
I'd like to use breakout boards. I've had mixed success hand soldering those tiny LGA packages.
If I can't find a compass module with variable I2C addresses, I may need a microcontroller with dual I2C busses.
HMC5883L is an inexpensive option with a fixed I2C address.
MPU-9250 is another option which includes a 3-axis magnetometer and a variable i2c address.
There are also more expensive boards with the newer LIS2MDL.
So...
Anyone with a good feel for the performance of these magnetometerswho would care to chime in as to the viability of this project and any hardware suggestions.
I suggest to consider a shaft angle encoder.
Your idea with two magnetometers should work, but also my first thought was an encoder for the mast rotation. That is the obvious solution to measure an angle.
The wind direction is not easy.
To which device are those 0-8V signals going ? Is there perhaps a way that the Arduino can send the mast rotation to that device ? For example via a serial port.
The signals could have a fixed frequency. One PWM signal could be controlled by the x-axis and the other PWM signal by the y-axis. But it could be something else. The signals could also be open-collector signals.
Can you provide information about the wind-direction-sensor and the device that is reading that signal ?
If you buy a cheap module from Ebay/Amazon/Aliexpress, how do you know that the HMC5883L is not a counterfeit chip ?
It is pretty safe to assume that an HMC5883L chip IS counterfeit. They were discontinued years ago.
Similar for the MPU-9250, which was more recently discontinued.
I'd love to use an absolute magnetic encoder, but it is a very harsh environment. Lots of salt water and potential for physical damage. I've used IP rated magnetic encoders from Renishaw before, but they are expensive, and prone to damage. I can't figure out a way to hook up any sort of encoder that will survive the environment.
With a magnetometer, I can hide it inside the aluminum mast and coat it with urethane or epoxy. No moving parts.
There is more information on the wind transducer here. I was wrong about the signals. They are 2-5.8v. The device reading the wind signal is this. I only need this converter because, unlike most sailboats, my mast rotates, so the reported wind direction will be off by the degrees of mast rotation.
As far as the output, I've got 8v so I thought I could use PWM to a transistor and perhaps a voltage divider to get my variable voltage. There's very little current involved.
Looking at the breakouts available from Adafruit:
There's an ICM-20948 for US$15
There's a LIS3MDL for US$10. Pololu also has a carrier for this IC and one with an IMU for $25
The BNO055 breakout for US$20
Sparkfun seems to be sold out of most magnetic sensors.
I was just thinking of putting a GPS on the mast with a MCU transmitting its heading info to the rest of the circuit. The GPS, MCU, and power can be put in a box and sealed.
Presumably the rotation is about the bar projecting upward from the mast step, in which case it would hardly be trivial to mount a shaft encoder.
So, your magnetometer idea should be workable. Keep in mind that magnetometer calibration is absolutely critical and it should be done in place.
Tilt compensation may also be required, depending on the accuracy you need. Without that compensation, heeling by 20 degrees could introduce heading errors of several degrees. For that, a magnetometer/accelerometer combination is needed (a gyro is not, but the module options are limited these days, and it appears that you need to buy a 9DOF sensor to get the 6 that you need).
Hi,
Have you Googled.
arduino magnetic encoder
Tom...
@jremington, I can see that calibration and tilt compensation is important. Part of the setup will be setting the 0 degree rotation point.
One advantage of my setup is that both sensors should see the same magnetic field. Even if there's an error at different headings, hopefully the heading delta will remain the same. I don't really care where North is (yet).
The Raymarine ITC-5 interface box I'm going in to also has an input for a passive fluxgate compass. I suppose I could spoof that as well as a follow up project. I can also get wind and boat heading information into my system via NMEA2000 (CAN bus), so that may be a future direction.
@TomGeorge, I have used Renishaw magnetic encoders in saltwater environments where they are still working after 10 years. They're great, but too expensive for my personal budget. I don't think there are any IP68 rated inexpensive encoders, and even if they were, mitigating physical damage would probably be a big obstacle.
@Idahowalker , The problem with a GPS is that it tells you which way the boat is moving, but not which way the boat or the mast are pointing. Boat leeway and mast rotation aren't measured.
Just ordered 2x Adafruit BMO055 sensors and a Teensy 4.0.
Instead of spoofing the voltage of the wind direction sensor. I'm going to read the (incorrect) wind direction value off of the NMEA 2000 CAN bus, modify the wind direction data based on the two compasses, and emulate a second (corrected) wind sensor.
The BMO055 was attractive because it has both a compass mode and a M4G (Magnet for Gyroscope)
mode.
To emulate a wind direction sensor, you have to know everything about the signal. I could not find a technical specification for that.
If you know what it must be, then we can help to make the phase shifted pwm signal.
They don't publish the specification, but I think it's pretty simple. The sensor has an 8V supply and two variable resistors. As the wind direction changes, the resistances change. Each resistor has a dead spot or cross over, but since there are two signals, one will always be good. The measured voltage across these resistors is 2-6VDC. For each of these signals, there's a linear relation between the value and the wind direction. The logic would probably just use the value closest to 4v (so furthest from the cross-over).
My first plan was to intercept these 2-6v signals, and output a corrected version to the ITC-5 NMEA 2000 (CAN bus) gateway. Spoofing the analog signal. I think this is viable, but I now think a better approach is to wire the sensor directly to the ITC-5 CAN gateway and have a more software based solution.
I will be using a Teensy 4.0 which I can connect to the CAN bus. My plan is to read the incorrect wind data (PGN 130306L) from the ITC-5 off of the CAN bus, correct it, and spoof a (different) corrected wind reading on the bus. Any instrument configured to show wind direction will see there are two options, the Raymarine ITC-5, and my corrected source. The Teensy, can also provide heading (127250L) and attitude (127257L) data. There's no support for mast angle, but I could call it rudder angle (127245L), if there's no autopilot which would get confused.
Connecting to the CAN bus should also allow translation to other busses, such as NMEA or old SeaTalk.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.