|
HF-MAX22200 Driver 0.1.0-dev
HF-MAX22200 C++ Driver
|
DPM (Detection of Plunger Movement) tuning + CSV-logging cycle test. More...
#include <cinttypes>#include <cstdio>#include <memory>#include "freertos/FreeRTOS.h"#include "freertos/task.h"#include "esp_log.h"#include "esp_timer.h"#include "esp32_max22200_bus.hpp"#include "esp32_max22200_test_config.hpp"#include "max22200.hpp"#include "max22200_registers.hpp"#include "max22200_types.hpp"Namespaces | |
| namespace | cfg |
Functions | |
| void | app_main () |
Variables | |
| constexpr bool | cfg::kEnableSlewRate = true |
| constexpr float | cfg::kDpmStartCurrent_mA = 20.0f |
| constexpr float | cfg::kDpmThreshold_mA = 4.0f |
| constexpr float | cfg::kDpmDebounce_ms = 0.05f |
| constexpr uint32_t | cfg::kPollPeriod_us = 1000 |
| constexpr uint32_t | cfg::kEnergisePoll_ms = 200 |
| constexpr uint32_t | cfg::kReleasePoll_ms = 50 |
DPM (Detection of Plunger Movement) tuning + CSV-logging cycle test.
Cycles a Parker C21 24V solenoid on MAX22200 channel 0, with DPM enabled and configured via the parameters at the top of this file. During every ENERGISE phase the FAULT register is polled at high rate (~1 kHz) for the first ~200 ms so we can capture exactly when (and whether) DPM fires within the HIT window.
The MAX22200 does NOT expose continuous current measurements over SPI — DPM is a binary "did we see a current dip" flag handled by the chip's analogue front-end. So instead of plotting the actual current waveform we plot the DPM event timing across many cycles.
Per the datasheet (CFG_DPM section):
Recommended starting tune for C21 (102 mA hit / 51 mA hold):
CSV output format on every cycle: cycle,phase,t_us,fault_byte,status_byte,dpm_fired
Pipe the serial output through a logger and grep for CSV, lines to plot in your tool of choice (matplotlib, Excel, octave, etc.).
At the end of N cycles a summary prints the DPM hit-rate and the distribution of "time-to-fire" so you can see whether your ISTART/IPTH/TDEB tune is catching real plunger movements.
FAULT.DPM[ch] = 0 → current dip seen → plunger MOVED (healthy) FAULT.DPM[ch] = 1 → drop NOT revealed → plunger STUCK (fault)A free-moving valve should produce zero DPM fires across many cycles. To validate the DPM logic, hold the plunger still by hand during a cycle — then DPM should fire (DPM=1) for that cycle.