BioAmp-EXG-Pill icon indicating copy to clipboard operation
BioAmp-EXG-Pill copied to clipboard

Claw constrain and arithmetic overflow fix

Open kevinjwalters opened this issue 6 months ago • 1 comments

  • Using constrain to guarantee servo angles are valid and between the desired 90 to180 (inclusive) range.
  • Enlarging sum variable to avoid overflow, now int32_t (from inttypes.h)
  • Adding some explcit (tradtitional C style) casts for float conversions.
  • Converted getEnvelop() to return float and using a locally defined mapf for improved conversion resolution.

Tested on the Arduino Uno (from pro kit). And on an Uno R4 WiFi as I happened to have it plugged in.

Fixes #38.

kevinjwalters avatar Jan 03 '24 13:01 kevinjwalters

I was thinking about float for getEnvelop() and use of mapf. This will change how the servo reacts - my testing so far has been without servo attached. The current integer code may have a slightly unintentional effect of smoothing the movement of the servo due to the effective quantisation and small number of values, e.g. if value is varying between certain values with a <1.0 range these can all map to N degrees setting and servo will settle not make any small movements.

Worth testing with a real setup using a servo to see how it behaves.

kevinjwalters avatar Jan 15 '24 12:01 kevinjwalters