Skip to content
bjornburton edited this page Dec 23, 2015 · 14 revisions

Holding at a certain depth requires knowing the present depth and, in terms of that present depth, the desired depth. The difference between those two can feed a PI loop which can vary the down-thrust as needed.

In dive mode the usual drive-inhibit must be suspended.

Sensing

For sensing depth we can monitor water pressure. 1 m is about 9.8 kPa in fresh water so the pressure is pretty low. We purchased a 5 psi (34 kPa) Transducer for $27. It looks like a Honeywell clone and should be ratio-metric. At ambient it sits at about 0.5 V. Ideally is will be an absolute sensor, but that's not clear yet. Surfaced should come out to about 0.8 Volts and submerged about 1.3 Volts. The AtMega328 has a 10 bit ADC for 1024 counts making roughly 5 mV/count. Without any gain, that's more than 100 counts from the ADC, ~1.25 cm each, and should be easy enough to work with.

Output

Direction will be reverse only, so that the drive-boom does not move to drive-orientation.

Calculation

Come up with guesses for the P and I and ε factors. Drive a loop using an interrupt. While cancelled, keep the integrator at zero for a low-bump transfer. When running, sample and get the difference for the error. Generate a proportional output from that difference, with guards. Multiply the difference by the I factor and sum when greater than ε for the integral part, with guards. That artificial ε limit will provide an integral dead-band to prevent hunting. Sum the proportional and integral and multiply by P, with yet more guards. The guards here will ensure 0 to −100% thrust.

Clone this wiki locally