I've modified the HVPM_Sensorless_2833x project provided with controlSUITE in the HVMotorCtrl+PfcKit_v2.1 folder to work with a Semikron SKAI2-LV device. I'm having trouble understanding if I have the ADC's setup correctly. I've combed through the documentation and SPRU812A to try to understand what is coded and if it is performing what I need done.
First, let me walk through the code I have.
HVPM_Sensorless.c:
...
// Default ADC initialization
int ChSel[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
int TrigSel[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
int ACQPS[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
...
void main(void) {
...
// Initialize ADC for Semikron SKAI2-LV
ChSel[0] = 0; // ChSelect: ADC A0 -> CS_AnalL1; Analog Value from Current Sensor Leg-U
ChSel[1] = 8; // ChSelect: ADC B0 -> CS_AnalL3; Analog value from Current Sensor Leg-W
ChSel[2] = 2; // ChSelect: ADC A2 -> PM_AnaUL1; Phase Voltage U
ChSel[3] = 3; // ChSelect: ADC A3 -> PM_AnaUL2; Phase Voltage V
ChSel[4] = 4; // ChSelect: ADC A4 -> PM_AnaUL3; Phase Voltage W
ChSel[5] = 9; // ChSelect: ADC B1 -> PM_Ana_UDcl; Analog Voltage value from DC-Link
ChSel[6] = 10; // ChSelect: ADC B2 -> Battery_Voltage; Analog value UCC_IN voltage
ChSel[7] = 1; // ChSelect: ADC A1 -> 1V5P_REF; 1.5V Reference voltage for the current sensors
ChSel[8] = 11; // ChSelect: ADC B3 -> DCB_Temp_Inverter; Analog value from DCB temperature sensor
ChSel[9] = 12; // ChSelect: ADC B4 -> Motor_Temp_Inverter; Analog value from motor temperature sensor
ChSel[10] = 5; // ChSelect: ADC A5 -> GPxO_AnalGpxo1; Analog value from current sensor of GPxO1
ChSel[11] = 6; // ChSelect: ADC A6 -> GPxO_AnalGpxo2; Analog value from current sensor of GPxO2
ChSel[12] = 7; // ChSelect: ADC A7 -> GPxO_AnalGpxo3; Analog value from current sensor of GPxO3
ChSel[13] = 13; // ChSelect: ADC B5 -> GPAI_AnaUPot1; Analog value from GPAI1
ChSel[14] = 14; // ChSelect: ADC B6 -> GPAI_AnaUPot2; Analog value from GPAI2
ChSel[15] = 15; // ChSelect: ADC B7 -> GPAI_AnaUPot3; Analog value from GPAI3
// Initialize ADC module
ADC_MACRO_INIT(ChSel, TrigSel, ACQPS)
...
}
The ADC_MACRO_INIT definition is located in the file f2833xileg_vdc.h. In this file, the ChSel was originally only a 1x8 array, which I now have as a 1x16. As such, the code for the ADC_MACRO_INIT looks like the following:
/* ==================================================================================
File name: F2833XILEG_VDC.H
Target : TMS320F2833X family
===================================================================================*/
#ifndef __F2833XILEG_VDC_H__
#define __F2833XILEG_VDC_H__
/*------------------------------------------------------------------------------
ADC Initialization Macro Definition
------------------------------------------------------------------------------*/
extern void DSP28x_usDelay(unsigned long Count);
extern void ADC_cal();
#define CPU_CLOCK_SPEED 15.000L // 10.000L for a 100MHz CPU clock speed
#define ADC_usDELAY 50000L
#define DELAY_US(A) DSP28x_usDelay(((((long double) A * 1000.0L) / (long double)CPU_CLOCK_SPEED) - 9.0L) / 5.0L)
#define ADC_MACRO_INIT(ChSel,Trigsel,ACQPS) \
\
EALLOW; \
SysCtrlRegs.PCLKCR0.bit.ADCENCLK = 1; \
ADC_cal(); \
EDIS; \
\
AdcRegs.ADCTRL3.all = 0x00E0; /* Power up bandgap/reference/ADC circuits*/ \
DELAY_US(ADC_usDELAY); /* Delay before converting ADC channels*/ \
\
AdcRegs.ADCTRL1.bit.ACQ_PS = ACQPS[0]; \
AdcRegs.ADCTRL1.bit.CPS = 1; \
AdcRegs.ADCTRL3.bit.ADCCLKPS = 0; \
AdcRegs.ADCTRL1.bit.SEQ_CASC = 0; /* 0x0 Dual Sequencer Mode, 0x1 Cascaded Mode*/ \
AdcRegs.ADCTRL2.bit.INT_ENA_SEQ1 = 0x0; \
AdcRegs.ADCTRL2.bit.RST_SEQ1 = 0x1; \
AdcRegs.ADCTRL2.bit.RST_SEQ2 = 0x1; \
AdcRegs.ADCTRL2.bit.EPWM_SOCA_SEQ1=0x1; /* enable SOC from EPWMA trigger*/ \
\
\
AdcRegs.ADCCHSELSEQ1.bit.CONV00 = ChSel[0]; \
AdcRegs.ADCCHSELSEQ1.bit.CONV01 = ChSel[1]; \
AdcRegs.ADCCHSELSEQ1.bit.CONV02 = ChSel[2]; \
AdcRegs.ADCCHSELSEQ1.bit.CONV03 = ChSel[3]; \
AdcRegs.ADCCHSELSEQ2.bit.CONV04 = ChSel[4]; \
AdcRegs.ADCCHSELSEQ2.bit.CONV05 = ChSel[5]; \
AdcRegs.ADCCHSELSEQ2.bit.CONV06 = ChSel[6]; \
AdcRegs.ADCCHSELSEQ2.bit.CONV07 = ChSel[7]; \
\
AdcRegs.ADCMAXCONV.bit.MAX_CONV1 = 7; \
EDIS; \
\
/* Set up Event Trigger with CNT_zero enable for Time-base of EPWM1 */ \
EPwm1Regs.ETSEL.bit.SOCAEN = 1; /* Enable SOCA */ \
EPwm1Regs.ETSEL.bit.SOCASEL = 2; /* Enable period event for SOCA */ \
EPwm1Regs.ETPS.bit.SOCAPRD = 1; /* Generate SOCA on the 1st event */ \
EPwm1Regs.ETCLR.bit.SOCA = 1; /* Clear SOCA flag */
#endif // __F2833XILEG_VDC_H__
What I would like to occur, would be for the ADC sequence to rundown through all 16 channels. To that effect, I believe that I would need to have modified the code in the following sections:
…
AdcRegs.ADCTRL1.bit.SEQ_CASC = 1; /* 0x0 Dual Sequencer Mode, 0x1 Cascaded Mode*/ \
…
AdcRegs.ADCCHSELSEQ1.bit.CONV00 = ChSel[0]; \
AdcRegs.ADCCHSELSEQ1.bit.CONV01 = ChSel[1]; \
AdcRegs.ADCCHSELSEQ1.bit.CONV02 = ChSel[2]; \
AdcRegs.ADCCHSELSEQ1.bit.CONV03 = ChSel[3]; \
AdcRegs.ADCCHSELSEQ2.bit.CONV04 = ChSel[4]; \
AdcRegs.ADCCHSELSEQ2.bit.CONV05 = ChSel[5]; \
AdcRegs.ADCCHSELSEQ2.bit.CONV06 = ChSel[6]; \
AdcRegs.ADCCHSELSEQ2.bit.CONV07 = ChSel[7]; \
AdcRegs.ADCCHSELSEQ3.bit.CONV08 = ChSel[8]; \
AdcRegs.ADCCHSELSEQ3.bit.CONV09 = ChSel[9]; \
AdcRegs.ADCCHSELSEQ3.bit.CONV10 = ChSel[10]; \
AdcRegs.ADCCHSELSEQ3.bit.CONV11 = ChSel[11]; \
AdcRegs.ADCCHSELSEQ4.bit.CONV12 = ChSel[12]; \
AdcRegs.ADCCHSELSEQ4.bit.CONV13 = ChSel[13]; \
AdcRegs.ADCCHSELSEQ4.bit.CONV14 = ChSel[14]; \
AdcRegs.ADCCHSELSEQ4.bit.CONV15 = ChSel[15]; \
\
AdcRegs.ADCMAXCONV.bit.MAX_CONV1 = 15; \
…
Do I have the right idea?
The first six (6) measurements I really need all at the same time, but as that’s not possible, I have to settle for either a Hold & Sample (H/S) where the A & B inputs are Held and then sequentially sampled, or I have to cascade the whole arrangement. Can anyone suggest a better way or am I on the right path?