LinearSensorCharacterization is an application example that performs online linear calibration of one ADC reading against a reference value received through generated packets.
It is intended to validate:
- ADC acquisition on
PA0 - Ethernet runtime loop
- generated
OrderPacketsreception - generated
DataPacketstransmission - incremental linear regression (
slopeandoffsetestimation)
This example depends on a different packet schema than ExamplePackets.
It is not compatible with the current TEST packet schema active in this branch.
The required JSON_ADE branch for this example is:
linear-sensor-char
It expects a legacy characterization-oriented JSON_ADE branch or board definition that generates the specific packet/order API used by this source.
That means:
- simply enabling
EXAMPLE_LINEAR_SENSOR_CHARACTERIZATIONis not enough - the active
Core/Inc/Code_generation/JSON_ADEcontents must match this example - the selected
BOARD_NAMEmust generate the legacy characterization symbols
At the moment, ExamplePackets and LinearSensorCharacterization are effectively tied to different JSON_ADE worlds.
Switching the JSON_ADE branch/schema to make this example build can break ExamplePackets, and vice versa.
This example is currently not directly buildable with the active BOARD_NAME=TEST packet schema.
Reason:
- the source expects generated symbols such as
OrderPackets::characterize_init - the current
TESTJSON schema does not generate those symbols - building this example with
BOARD_NAME=TESTfails at compile time
The failure is expected until a matching board schema is restored or the example is migrated to the new TEST packet definitions.
This example requires a board JSON definition that generates at least:
OrderPackets::characterize_initOrderPackets::characterize_flagDataPackets::characterization_initDataPackets::Value_initDataPackets::packets_socketDataPackets::characterization_packet
In practice, this means you need the legacy characterization schema checked out in JSON_ADE, then a full reconfigure/rebuild so the generated packet headers are replaced.
Typical sequence once that schema is restored:
cmake --preset nucleo-debug-eth -DBUILD_EXAMPLES=ON -DCMAKE_CXX_FLAGS='-DEXAMPLE_LINEAR_SENSOR_CHARACTERIZATION'
cmake --build --preset nucleo-debug-ethWhen backed by a matching packet schema, the example should:
- read the raw ADC value from
PA0 - receive a reference
real_valuethrough a generated order - update
slopeandoffsetwith incremental OLS - compute
value = slope * sensor_value + offset - publish the updated characterization packet over Ethernet
Pick one of these approaches before using this example again:
- restore the original board JSON that defined
characterize,characterization, andValue - or migrate
LinearSensorCharacterization.cppto the newTESTpacket names
After the packet schema matches again, validate it by:
- sending known reference values
- checking that
slopeandoffsetconverge correctly - verifying the emitted data packets track the fitted line