From e0d383c98675f7d84ac722f916778550137ac809 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 4 Nov 2017 20:40:23 +1100 Subject: [PATCH] AP_Volz_Protocol: add a 30% safety margin over baudrate we don't want to fill the buffer if we don't get full uart utilisation --- libraries/AP_Volz_Protocol/AP_Volz_Protocol.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libraries/AP_Volz_Protocol/AP_Volz_Protocol.cpp b/libraries/AP_Volz_Protocol/AP_Volz_Protocol.cpp index ba5c652b72..d211aecab2 100644 --- a/libraries/AP_Volz_Protocol/AP_Volz_Protocol.cpp +++ b/libraries/AP_Volz_Protocol/AP_Volz_Protocol.cpp @@ -142,9 +142,14 @@ void AP_Volz_Protocol::update_volz_bitmask(uint32_t new_bitmask) } } + // have a safety margin of 20% to allow for not having full uart + // utilisation. We really don't want to start filling the uart + // buffer or we'll end up with servo lag + const float safety = 1.3; + // each channel take about 425.347us to transmit so total time will be ~ number of channels * 450us // rounded to 450 to make sure we don't go over the baud rate. - uint64_t channels_micros = count * 450; + uint32_t channels_micros = count * 450 * safety; // limit the minimum to 2500 will result a max refresh frequency of 400hz. if (channels_micros < 2500) {