Tool/software: Code Composer Studio
Hi.
Can anybody help me with this issues
I currently work in the construction of a Power Quality monitor. At this moment, i'm setting the ADC for waveforms samplings, i did the configuration show below, but the waveforms are sampled poorly. I saw others forums where suggest try connect signal source to target with short wires, connect all the GND target pins to the GND of the signal source or simply change to differential and 16-bit sampling. I try the First two options, but the problem don't dessapear. can i help me with this issue please ¡¡
void ConfigureADC(void)
{
EALLOW;
//
//write configurations
AdcaRegs.ADCINTSEL1N2.bit.INT1CONT=1;
AdcaRegs.ADCCTL2.bit.PRESCALE = 2; //set ADCCLK divider to /4
AdcaRegs.ADCCTL2.bit.RESOLUTION=0; //Set ADCA Resolution 12 bit
AdcaRegs.ADCCTL2.bit.SIGNALMODE=0; //Signal Mode
AdcaRegs.ADCCTL1.bit.INTPULSEPOS = 1;
AdcaRegs.ADCCTL1.bit.ADCPWDNZ = 1; //Power on ADCA
//delay for 1ms to allow ADC time to Power uP
DELAY_US(1000); //Add a delay
EDIS;
}
//
// ConfigureEPWM - Configure EPWM SOC and comPare values
//
void ConfigureEPWM(void)
{
EALLOW;
// Assumes ePWM clock is already enabled
EPwm1Regs.ETSEL.bit.SOCAEN = 1; // Disable SOC on A grouP
EPwm1Regs.ETSEL.bit.SOCASEL = 4; // Select SOC on uP-count
EPwm1Regs.ETPS.bit.SOCAPRD = 1; // Generate Pulse on 1st event
EPwm1Regs.CMPA.bit.CMPA = 0x0080; // Set comPare A value to 2048 counts
EPwm1Regs.TBPRD = 0x0BB7; // Set Period to 4096 counts
EPwm1Regs.TBCTL.bit.CTRMODE = 0; // UP count
EDIS;
}
//
// SetuPADCEPwm - SetuP ADC EPWM acquisition window
//
void SetuPADCEPwm(void)
{
Uint16 acqPs;
acqPs = 60; //81ns Ventana de adquisición
EALLOW;
AdcaRegs.ADCSOC0CTL.bit.CHSEL = 3; //SOC0 will convert Pin A3 FASE A
AdcaRegs.ADCSOC1CTL.bit.CHSEL = 5; //SOC3 will convert Pin A5 FASE B
AdcaRegs.ADCSOC2CTL.bit.CHSEL = 2; //SOC0 will convert Pin A2 FASE C
AdcaRegs.ADCSOC0CTL.bit.ACQPS = acqPs; //samPle window is 100 SYSCLK cycles
AdcaRegs.ADCSOC1CTL.bit.ACQPS = acqPs; //samPle window is 100 SYSCLK cycles
AdcaRegs.ADCSOC2CTL.bit.ACQPS = acqPs; //samPle window is 100 SYSCLK cycles
AdcaRegs.ADCSOC0CTL.bit.TRIGSEL = 5; //trigger on ePWM1 SOCA/C
AdcaRegs.ADCSOC1CTL.bit.TRIGSEL = 5; //trigger on ePWM1 SOCA/C
AdcaRegs.ADCSOC2CTL.bit.TRIGSEL = 5; //trigger on ePWM1 SOCA/C
AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 1; //end of SOC1 will set INT1 flag
AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1; //enable INT1 flag
EDIS;
}
interrupt void adcVabc_isr(void)
{
//va=AdcaResultRegs.ADCRESULT0;
//vb=AdcaResultRegs.ADCRESULT1;
//vc=AdcaResultRegs.ADCRESULT2;
Va= 3.3*(AdcaResultRegs.ADCRESULT0)/(float)4095;
Vb= 3.3*(AdcaResultRegs.ADCRESULT1)/(float)4095;
Vc= 3.3*(AdcaResultRegs.ADCRESULT2)/(float)4095;
//AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //clear INT1 flag
VP[count++]=AdcaResultRegs.ADCRESULT0;
if(RESULTS_BUFFER_SIZE<=count)
{
count=0;
}
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
return;
//asm(" ESTOP0");
}
I obtained the next resolution. The original signal are a Sine with a offset, frequency 60Hz and amplitude 1V+-100mV.