Skip to content

Commit

Permalink
ping360: Improve pulse duration equation
Browse files Browse the repository at this point in the history
Duplicate pulse duration as requested to improve visualization

Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
  • Loading branch information
patrickelectric committed Aug 26, 2019
1 parent 4e2bd31 commit b2c4a9b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/sensor/ping360.h
Expand Up @@ -404,16 +404,16 @@ class Ping360 : public PingSensor
if (_autoTransmitDuration) {
/*
* Per firmware engineer:
* 1. Starting point is TxPulse in usec = ((one-way range in metres) * 4000) / (Velocity of sound in metres per second)
* 1. Starting point is TxPulse in usec = ((one-way range in metres) * 8000) / (Velocity of sound in metres per second)
* 2. Then check that TxPulse is wide enough for currently selected sample interval in usec, i.e.,
* if TxPulse < (1.25 * sample interval) then TxPulse = (1.25 * sample interval)
* if TxPulse < (2.5 * sample interval) then TxPulse = (2.5 * sample interval)
* 3. Perform limit checking
*/

// 1
int autoDuration = round(4000*range()/_speed_of_sound);
int autoDuration = round(8000*range()/_speed_of_sound);
// 2 (transmit duration is microseconds, samplePeriod() is nanoseconds)
autoDuration = std::max(static_cast<int>(1.25*samplePeriod()/1000), autoDuration);
autoDuration = std::max(static_cast<int>(2.5*samplePeriod()/1000), autoDuration);
// 3
_transmit_duration = std::max(static_cast<int>(_firmwareMinTransmitDuration),
std::min(transmitDurationMax(), autoDuration));
Expand Down

0 comments on commit b2c4a9b

Please sign in to comment.