TLE92466ED Driver 0.1.0-dev
Modern C++20 driver for Infineon TLE92466ED Six-Channel Low-Side Solenoid Driver
Loading...
Searching...
No Matches
solenoid_control_test.cpp File Reference

Real Hardware Solenoid Control Test with ADC-Based Current Control. More...

#include <stdio.h>
#include <memory>
#include <cmath>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_log.h"
#include "esp_system.h"
#include "esp_adc/adc_oneshot.h"
#include "esp_adc/adc_cali.h"
#include "esp_adc/adc_cali_scheme.h"
#include "tle92466ed.hpp"
#include "esp32_tle92466ed_bus.hpp"
#include "esp32_tle92466ed_test_config.hpp"
Include dependency graph for solenoid_control_test.cpp:

Classes

struct  ADCConfig
 ADC Configuration. More...
 
struct  Solenoid1Config
 Solenoid 1 Configuration (Single Channel) More...
 
struct  Solenoid2Config
 Solenoid 2 Configuration (Parallel Pair) More...
 

Functions

static bool initialize_adc () noexcept
 Initialize ADC for voltage reading.
 
static float read_adc_voltage_mv () noexcept
 Read ADC voltage in millivolts.
 
static float read_adc_percentage () noexcept
 Read ADC percentage (0.0 to 100.0)
 
template<typename SolenoidConfig >
static uint16_t calculate_current_from_percentage (float percentage) noexcept
 Calculate current from percentage for a solenoid.
 
static bool initialize_solenoids () noexcept
 Initialize solenoids.
 
static void print_solenoid_telemetry (const char *name, Channel channel, bool parallel_mode) noexcept
 Print comprehensive telemetry for a solenoid.
 
static void print_device_telemetry () noexcept
 Print device-level telemetry.
 
static void update_solenoid_currents () noexcept
 Update solenoid currents based on ADC reading.
 
static void set_solenoids_enabled (bool enabled) noexcept
 Enable/disable solenoids.
 
void app_main ()
 

Variables

static const char * TAG = "SolenoidControl"
 
static std::unique_ptr< Esp32Tle92466edSpiBusg_hal
 
static tle92466ed::Driver< Esp32Tle92466edSpiBus > * g_driver = nullptr
 
static adc_oneshot_unit_handle_t g_adc_handle = nullptr
 
static adc_cali_handle_t g_adc_cali_handle = nullptr
 

Detailed Description

Real Hardware Solenoid Control Test with ADC-Based Current Control.

This test demonstrates real-world solenoid control using actual hardware:

  • Two solenoids: one single channel, one parallel pair
  • ADC-based current control (0-3.3V maps to 0-100% current range)
  • Independent min/max current limits per solenoid
  • Real-time current adjustment based on ADC reading
  • Proper parallel channel operation validation

Hardware Requirements:

  • Two solenoids connected to TLE92466ED outputs
  • ADC input (potentiometer or voltage source) on ESP32-C6 ADC pin
  • Proper power supply for solenoids (VBAT)
Author
N3b3x
Date
2025-10-21
Version
2.0.0

Function Documentation

◆ app_main()

void app_main ( )

◆ calculate_current_from_percentage()

template<typename SolenoidConfig >
static uint16_t calculate_current_from_percentage ( float percentage)
staticnoexcept

Calculate current from percentage for a solenoid.

◆ initialize_adc()

static bool initialize_adc ( )
staticnoexcept

Initialize ADC for voltage reading.

◆ initialize_solenoids()

static bool initialize_solenoids ( )
staticnoexcept

Initialize solenoids.

◆ print_device_telemetry()

static void print_device_telemetry ( )
staticnoexcept

Print device-level telemetry.

◆ print_solenoid_telemetry()

static void print_solenoid_telemetry ( const char * name,
Channel channel,
bool parallel_mode )
staticnoexcept

Print comprehensive telemetry for a solenoid.

◆ read_adc_percentage()

static float read_adc_percentage ( )
staticnoexcept

Read ADC percentage (0.0 to 100.0)

◆ read_adc_voltage_mv()

static float read_adc_voltage_mv ( )
staticnoexcept

Read ADC voltage in millivolts.

◆ set_solenoids_enabled()

static void set_solenoids_enabled ( bool enabled)
staticnoexcept

Enable/disable solenoids.

◆ update_solenoid_currents()

static void update_solenoid_currents ( )
staticnoexcept

Update solenoid currents based on ADC reading.

Variable Documentation

◆ g_adc_cali_handle

adc_cali_handle_t g_adc_cali_handle = nullptr
static

◆ g_adc_handle

adc_oneshot_unit_handle_t g_adc_handle = nullptr
static

◆ g_driver

tle92466ed::Driver<Esp32Tle92466edSpiBus>* g_driver = nullptr
static

◆ g_hal

std::unique_ptr<Esp32Tle92466edSpiBus> g_hal
static

◆ TAG

const char* TAG = "SolenoidControl"
static