I have MS5837-30BA sensors (Bluerobotics Bar30 is made on its basis, only much cheaper). With a couple of these sensors, I measure the draft of the vessel, and monitor the loading of the boat. All this is done separately from the autopilot. I saw that this sensor is supported in ArduSub.
Is it possible to add support in the version for boats (Arduover)?
It would be relatively easy to enable the barometer, the only potential issue that I see is that the EKF would start trying to use it as well so it would affect the altitude estimate. I suspect that doesn’t matter much.
Can you explain how you measure the draft (how deep in the water the boat is) with one or two of these? I can imagine that with two you could measure the water pressure difference… one would be attached low on the underside of the hull and the other would be floating at the water line?
From the picture I think it is clear how you can understand how I use. For my model, I made hydrostatic curves that help me to load the boat.
After the sensors are initialized, the atmospheric pressure is taken as zero, after the launch of the boat takes place (it was once, the sensors are powered separately and permanently, everything is easier for small boats). Then the pressure is recalculated from the “new zero” and transferred to the depth.
Part of the code for the calculation
if (!digitalRead(13)) {
// we calculate the absolute pressure readings
atT = mBAR * 0.001019716212978;
cmH2O = mBAR * 1.019744288922;
} else {
// we calculate the value of the relative pressure
atT = (mBAR - deltamBAR) * 0.001019716212978;
cmH2O = (mBAR - deltamBAR) * 1.019744288922;
}
I think your best option for this would be to do it on an arduino then send the draft to ardupilot as a rangefinder, either i2c or mavlink, you could use the up orientation so that its separate from the depth rangefinder that is using the down orientation. you can use lua to send it back to mission planner as rangefinder orientation 24.
I want to use the same sensor in the submarine I’m building. @rmackay9 , what wold be involved in adding the driver to Rover? Does it have to go in hwdef.dat? Does it have to do with AP_BARO_MS56XX_ENABLED? I have only one of these sensors.
@McKey, the boat im building is a traditional submarine with a single propeller, a rudder and dive planes. I do not believe ArduSub supports this configuration. I put more details about my build here: Conventional Submarines - ArduRover - #11 by iter
I have been looking to replicate this for a sub to use for depth control, the 5837 would be ideal but it’s expensive so I have ordered some i2c barometric pressure modules that I’m going to convert into a depth sensor by attaching an external tube then sealing the whole sensor in epoxy. I have ordered a BMP280 module, bmp180 module, ms5611 module and bmp388l module to test.
I’ve given up on all these sensors because the tube nozzles are constantly clogged. A large tube is inconvenient on my scale. I switched to a different type (I wrote a post, there is a link on Github). But this type is not suitable for underwater vessels.
@ McKey - I appreciate your efforts to get the MS5837 supported in ArduRover - it actually appears in the current baro selection drop down list - but does it have specific driver support ?
If not, have you ever managed to obtain telemetric pressure measurements from one of the MS5873 in Mission Planner or QGC via an arduino sketch?
I ordered the bar02 version (just the sensor board) because it fits the need for a non-tethered sub where the high pressure range of the bar30 is not required. There is a protocol to connect it to an FC running ardusub Guide to Using the Bar02 with an Arduino
Supply voltage of the bar02 is up to 5.0 V - which is what measure on the I2C port - do I need a logic voltage shifter to bring the supply voltage down to 3,3V which is standard for SCL and SDA wires on I2C ports?
I tried to set up an arduino script to read only “depth” from the bluerobotics bar30 and send it as an PWM to a GPIO “rangefinder” to ardurover - the script is based on @geofrancis arduino script that reads the GL041 MT sonar to ardupilot as an PWM signal.
Wiring looks like spaghetti - the logic level on the nano is 5V but its 3.3V on the bar30 and the GPIO PIN on the FC - so I included two logic level shifters which I plan to omit by switching to a generic 3.3V board for the arduino script later.
I am a little unclear on where you stand with this. Did you test it? Are you just looking for a code review? I looked at the arduino code and here is what I think:
If you have the sensor connected to the arduino properly you should see print statements that tell you the depth, so I would test this out before wiring it up to a FC. The sensor code seems fine, it appears to use the bluerobotics library example code.
What kind of rangefinder are you trying to emulate for the FC side? (What value of RNGFND1_TYPE)? You are outputting a PWM signal whose duty cycle is proportional to depth. If you filter this you could get an analog signal. It is a very different kind of PWM than common rangefinders like the HC-SR04 use however. So whether this will work depends on what you are trying to emulate.
Arduino Nano:
MS5837-bar30 connected to arduino nano - script code_pilot_MS5873-30BA_depth_only_PWM - script prints correct values for pressure (mbar), temperature (°C), depth (m) and altitude (m above sea level) on USB serial. I checked PWM output on pin 9 on the oscilloscope. PWM signal is crisp - amplitude 5V, frequency 490 Hz, signal duration at atmospheric pressure is 2 ms - ASCII code on the scope reads ok - applied pressure to the bar30 modulates (shortens) PWM signal duration.
FC:
Nora+ - ardurover 4.5.3 - servo output 13 set to -1 (GPIO 62) based on hwdef.dat - PIN62 is input for rangefinder2 - RNGFND_TYPE 5 (PWM) - PIN9 arduino connected to pin 62 FC - servo rail has power (VDD from arduino 5V PIN) - baro, arduino and FC servo rail have all common GND (arduino GND).
Issue:
Readings on quick tab for rangefinder2 (m) is allways zero - applying controlled pressure to the bar30 → no change.
I attach current parameter file and the bluerobotics script - perhaps its usefull.
Rover 4.5.3 and up list the MS5837 among the supported barometers - I just connected the MS5837-bar02 and -bar30 (bluerobotics PCB’s) via I2C - both are recognized as MS5637 - but neither is detected as MS5837. Pressure measurements are misleading - at a real pressure of 3000 mbar readings are 2000 mbar.
It appears to me that rover - at least currently - doesnt support the MS5837 - if so, would’nt it be appropriate to remove MS5837 from the list of supported barometers?
Looks like rangefinder type 5 is for the garmin lidar lite- specifications there say the PWM signal is a pulse with duration of 10 us/cm. So not a duty-cycle based signal, rather a pulse timed one. I think using arduino code like geofrancis’s here that sets the pin high, delays, sets the pin low is more appropriate. That said I’m suprised you are getting nothing with the current setup, I would have expected a misleading reading but not zero (2ms pulse is 2 meters I believe) so there could be something else.
@meholden I followed your suggestion and modified the arduino code based on geofrancis code
I changed to the bar02 - which is my favourite because heart rate goes up when the sub diappears completely in the murky pond water below 2 to 3 m diving depth.
Good news - with your assistance I get readings in mission planner quick tab. I checked the accuracy of the bar02 using a digital pressure gauge and compared readings on the pressure gauge / arduino serial monitor and rangefinder2 in MP.
I appologize for poor formatting - just a copy - paste from the Excel sheet…
I will decrease max distance from 10 to 2 m (PWM max duration 2 ms // by 10 mcrs / cm distance) and check how this turns out. Extending PWM duration beyond 2 ms is no option @ 500 Hz frequency. MS5837-02BA_PWM_digital.cpp (1.1 KB)