HF-MAX22200 Driver 0.1.0-dev
HF-MAX22200 C++ Driver
Loading...
Searching...
No Matches
c21_cycle_test.cpp File Reference

Real-hardware Parker C21 24 V solenoid cycle test on MAX22200 CH0. More...

#include <cinttypes>
#include <cstdio>
#include <memory>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_log.h"
#include "esp32_max22200_bus.hpp"
#include "esp32_max22200_test_config.hpp"
#include "max22200.hpp"
#include "max22200_registers.hpp"
#include "max22200_types.hpp"
Include dependency graph for c21_cycle_test.cpp:

Namespaces

namespace  cfg
 

Macros

#define ESP32_MAX22200_ENABLE_DETAILED_SPI_LOGGING   0
 
#define ESP32_MAX22200_ENABLE_VERBOSE_BUS_LOGGING   1
 

Functions

void app_main ()
 

Variables

constexpr uint8_t cfg::kChannel = 0
 OUT0 / SOL_CH0.
 
constexpr uint16_t cfg::kHitCurrent_mA = 102
 24 V / 235 Ω ≈ 102 mA
 
constexpr uint16_t cfg::kHoldCurrent_mA = 51
 50 % of hit per C21 table
 
constexpr float cfg::kHitTime_ms = 100.0f
 C21 minimum hit pulse.
 
constexpr ChopFreq cfg::kChopFreq = ChopFreq::FMAIN_DIV4
 ≥ 1 kHz floor
 
constexpr uint32_t cfg::kOnDuration_ms = 2000
 
constexpr uint32_t cfg::kOffDuration_ms = 2000
 
constexpr uint32_t cfg::kCycleCount = 0
 0 = run forever
 
constexpr uint32_t cfg::kTelemetryPeriod_ms = 100
 10 Hz
 
constexpr bool cfg::kEnableSlewRateControl = true
 
constexpr bool cfg::kEnableOpenLoadDetection = false
 
constexpr bool cfg::kEnablePlungerMovementDet = false
 
constexpr bool cfg::kEnableHitCurrentCheck = false
 

Detailed Description

Real-hardware Parker C21 24 V solenoid cycle test on MAX22200 CH0.

Drives a single Parker C21-series 24 V solenoid (235 Ω coil → 102 mA peak / 51 mA hold per the C21 Hit-and-Hold table) on MAX22200 channel 0 in CDR (current-controlled hit-and-hold) mode and cycles it ON / OFF periodically. A 10 Hz telemetry task scrapes:

  • STATUS register (ACTIVE flag, channels-on bitmask, fault summary)
  • FAULT register (per-channel OCP / HHF / OLF / DPM bitmasks)
  • last CMD-echo byte (fault flags the chip stuffs into MISO on every cmd transfer, datasheet Figure 7)
  • nFAULT pin (open-drain, asserts LOW on any unmasked fault)

Default cycle profile: ON for 2000 ms (102 mA hit pulse for 100 ms then 51 mA hold) OFF for 2000 ms (channel released) telemetry @ 10 Hz throughout run forever (Ctrl-] to stop)

Edit the cfg namespace below for a different C21 variant or cycle cadence.

Wiring (Flux V1 / generic ESP32-S3 dev rig)
See main/esp32_max22200_test_config.hpp for the full pinout. SPI: MISO=GPIO35, MOSI=GPIO37, SCLK=GPIO36, CS=GPIO38; Control: ENABLE=GPIO2, CMD=GPIO39, FAULT_N=GPIO42, TRIGA=GPIO40, TRIGB=GPIO41. Coil between OUT0 and +VM (low-side switching).
Build / flash
From examples/esp32: ./scripts/build_app.sh c21_cycle_test Debug ./scripts/flash_app.sh flash_monitor c21_cycle_test Debug
DPM polarity reminder (datasheet §"Detection of Plunger Movement")
FAULT.DPM bit = 1 → drop NOT revealed → plunger STUCK (fault) FAULT.DPM bit = 0 → current dip seen → plunger MOVING (healthy) See c21_dpm_tuning_test for live tuning.
Author
HardFOC
Date
2026

Macro Definition Documentation

◆ ESP32_MAX22200_ENABLE_DETAILED_SPI_LOGGING

#define ESP32_MAX22200_ENABLE_DETAILED_SPI_LOGGING   0

◆ ESP32_MAX22200_ENABLE_VERBOSE_BUS_LOGGING

#define ESP32_MAX22200_ENABLE_VERBOSE_BUS_LOGGING   1

Function Documentation

◆ app_main()

void app_main ( void )