Fwd: Working depth sensor code

13 views
Skip to first unread message

David Lang

unread,
Oct 11, 2013, 6:28:26 PM10/11/13
to ope...@googlegroups.com, Dominik Fretz, Simone Chiaretta
Making sure you all are in the loop on the depth sensor update.


---------- Forwarded message ----------
From: <Walt...@aol.com>
Date: Fri, Oct 11, 2013 at 3:25 PM
Subject: Working depth sensor code
To: br...@babastik.com
Cc: er...@openrov.com, da...@openrov.com, co...@openrov.com


Hi Brian:
 
  Eric was over at my place today and we tested the attached Arduino code with a potted depth sensor.  Other than some crazy wiring issue, it works just fine.  The output of the depth sensor matches our reference pressure sensor to within ~4 inches of water.  Here's the scoop:
 
- Rather than try to debug Victor's or your code, I decided to just roll my own C code, with very little abstraction in it.
 
- After figuring out two issues, the code worked just fine.  First, you need to add some time delay after sending commands to the sensor.  That's the purpose of the 10msec delays you'll see scattered about.  Second, the math that is shown in the datasheet requires 64-bit integers, which the Arduino doesn't support.  So I do the calculations in floating point.  You'll see a lot of explicit casts in the C-code, since I don't fully understand how implicit casting works, and I didn't want to take any chances.
 
- There are a number of 1-second delays in the code, that are related to some debugging we're doing with the wiring. Right now the board works just fine, until the pressure chamber is filled absolutely to the top with water, at which point the depth sensor dies.   The sensor works just fine with a partially-filled chamber.  There may be some crazy dielectric issue with the I2C wiring.  Eric's homework is to investigate it in the test tank, and see what amount of wire immersion causes the interface to fail.
 
- The code I have included only does the linear fit for the temperature sensor right now.  I'm going to fork the code tonight and implement the second-order fit.  We did some temp sensor testing in pans of hot and cold water, and the temperature was off by ~3 deg C in +5 deg C water.  After I code up the second-order fit, we need to repeat the experiment to see if it has improved the accuracy to sufficient levels.  This will be important for diving at Tahoe, where the water is very cold.
 
- If you haven't debugged whatever issue is in the existing depth sensor code, feel free to use this code instead.  I'm going to do some cleanup on it to remove extraneous print statements and the like, and it needs to have some robustness added to it (error trapping, etc).  But functionally, it works fine.
 
- User interface stuff:   Don't know if you've worked on the user interface for the depth sensor, but it needs to have two features that I don't believe exist right now:  First, there needs to be a zero offset button that zeros the depth sensor as part of the pre-dive check.  This is important when going back and forth between sea level and Tahoe, for instance.  Second, there needs to be a switch that selects between fresh and salt water when converting from pressure to depth.  I can get you the relevant constants when you need them.
 
Have fun, and let me know what you think of my coding style (or lack thereof :-)  ).
 
-Walt
 
 



--
Walts_Depth_Sensor.ino

Dominik Fretz

unread,
Oct 11, 2013, 8:19:58 PM10/11/13
to David Lang, ope...@googlegroups.com, Simone Chiaretta, Brian Adams, Walt...@aol.com

Great news indeed!

Is anyone currently working on any ui or NodeJS code?
Because I started to get some cleanup done (see my pull request) and will continue with some ui stuff too.

I can incorporate the depth sensor in the ui too.

Regards
Dominik

Simone Chiaretta

unread,
Oct 14, 2013, 4:45:59 AM10/14/13
to Brian Adams, Dominik Fretz, David Lang, ope...@googlegroups.com, waltholm
Maybe not a good moment now, but I believe that having a modular system with plugins for everything that is not the core communication and maybe motor is better than having everything coded in the main system.
But maybe better to push out 2.5 and then start working on creating a modular plugin based architecture.

Simone


On Sat, Oct 12, 2013 at 3:48 AM, Brian Adams <br...@openrov.com> wrote:
Go for it!





--
Simone Chiaretta
Microsoft MVP ASP.NET - ASPInsider
Blog: http://codeclimber.net.nz
RSS: http://feeds2.feedburner.com/codeclimber
twitter: @simonech

tre...@comcast.net

unread,
Oct 14, 2013, 2:58:34 PM10/14/13
to ope...@googlegroups.com, Dominik Fretz, David Lang, waltholm, Brian Adams

as we look at re-architecting, take a look at the QP state machine framework for Arduino http://playground.arduino.cc/Code/QP.

Even if we don't use it, the ideas behind it are useful for organizing our code.

Jim

From: "Simone Chiaretta" <simone.c...@gmail.com>
To: "Brian Adams" <br...@openrov.com>
Cc: "Dominik Fretz" <dom...@openrov.com>, "David Lang" <da...@openrov.com>, ope...@googlegroups.com, "waltholm" <Walt...@aol.com>
Sent: Monday, October 14, 2013 1:45:59 AM
Subject: Re: Fwd: Working depth sensor code
--
You received this message because you are subscribed to the Google Groups "OpenROV" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openrov+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Reply all
Reply to author
Forward
0 new messages