File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -383,7 +383,19 @@ class Ping360 : public PingSensor
383383 void adjustTransmitDuration ()
384384 {
385385 if (_autoTransmitDuration) {
386- int autoDuration = round (5.1 + 2.833 *(range () - 2 ));
386+ /*
387+ * Per firmware engineer:
388+ * 1. Starting point is TxPulse in usec = ((one-way range in metres) * 4000) / (Velocity of sound in metres per second)
389+ * 2. Then check that TxPulse is wide enough for currently selected sample interval in usec, i.e.,
390+ * if TxPulse < (1.25 * sample interval) then TxPulse = (1.25 * sample interval)
391+ * 3. Perform limit checking
392+ */
393+
394+ // 1
395+ int autoDuration = round (4000 *range ()/_speed_of_sound);
396+ // 2 (transmit duration is microseconds, samplePeriod() is nanoseconds)
397+ autoDuration = std::max (static_cast <int >(1.25 *samplePeriod ()/1000 ), autoDuration);
398+ // 3
387399 _transmit_duration = std::max (static_cast <int >(_firmwareMinTransmitDuration),
388400 std::min (transmitDurationMax (), autoDuration));
389401 emit transmitDurationChanged ();
You can’t perform that action at this time.
0 commit comments