am13e23019-adc-current-read.ino

BeagleConnect QuadESC: 4-Channel BLDC Controller · File : am13e23019-adc-current-read.ino · Language : C · Use case : Lire les valeurs brutes du convertisseur ADC pour la mesure du courant moteur.

Analog data acquisition via the internal ADC to monitor the card's 12 current channels.

The TI AM13E23019 has a high-resolution ADC. This reading must be synchronized with the motor PWM to avoid noise. Use digital filters to stabilize current measurements from DRV8323S drivers.

am13e23019-adc-current-read.ino

#include <ti/devices/am13e2x/inc/am13e2x.h>
#include <ti/drv/adc/adc.h>
#include <ti/drv/adc/soc/adc_soc.h>
#include <ti/drv/uart/UART_stdio.h>

ADC_Handle adcHandle;
ADC_Params adcParams;
uint16_t adcValue;

void init_adc(void) {
    ADC_Params_init(&adcParams);
    adcParams.channel = ADC_CHANNEL_0; // Supposons le canal courant moteur 1
    adcParams.resolution = ADC_RESOLUTION_12BIT;
    
    adcHandle = ADC_open(ADC_INSTANCE_0, &adcParams);
    if (adcHandle == NULL) {
        UART_printf("Erreur ADC\n");
    }
}

void read_current(void) {
    if (ADC_read(adcHandle, &adcValue) == ADC_STATUS_SUCCESS) {
        // Conversion en Ampères (exemple théorique, nécessite calibration)
        float voltage = (adcValue / 4095.0f) * 3.3f;
        float current = (voltage - 1.65f) * 10.0f; // Offset 1.65V, gain 10V/A
        UART_printf("Courant: %.2f A\n", current);
    }
}

← Back to the board