Skip to content

Data Processing

Overview

This document explains filtering, scaling and how control percentages are calculated and sent to the wheels.

File locations

  • Headers and APIs: Core/Inc/App
  • Sources: Core/Src/App

Scaling and units

  • Convert ADC counts to engineering units using calibration tables.
  • Apply offset and gain: value = (raw - offset) * gain.

Calculating percentage for wheel command

  1. Read torque command request (unsigned) as percentage from ECU.
  2. Place 's' in the beginning of the buffer to signal serial input.
  3. Use units and '+' or '-' to build the message for the inverter -> m = maximum torque -> 0 = minimum torque -> for every unit of percentage a '+' is placed after the decimal, only when the needed percentage is lower than 10. Otherwise 1 will be placed in the buffer and a '-' for every unit until 10. Example : 19 = 1+++++++++, 67 = 6+++++++, 8 = 1--, 5 = 1-----.
  4. Add f at the end of the buffer to signal the direction (forward).

Telemetry packing

  • Percentages are rounded to nearest integer before packing into telemetry frames.
  • Use unsigned representation as there is no reason for negative percentages.

Testing

  • Add unit tests for mapping boundaries and interpolation.
  • Run integration tests to validate percent -> wheel behavior under edge cases.

Released under the MIT License.