使用2808/2812/28335等芯片,PI算法采用TI的例程,电机可以正常运行,但是电机的吱吱声(电磁噪声)太响,不知道如何改善?
请高人解惑!!!
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
使用2808/2812/28335等芯片,PI算法采用TI的例程,电机可以正常运行,但是电机的吱吱声(电磁噪声)太响,不知道如何改善?
请高人解惑!!!
整理后,还是有噪声,
是不是电流采样有问题导致的,
我的AD采样设置如下:然后在EPWM1中断中直接读取的 IsaSmp = AdcResult.ADCRESULT3; 不知道这样有没有问题?
extern void DSP28x_usDelay(Uint32 Count);
// *IMPORTANT*
// The Device_cal function, which copies the ADC calibration values from TI reserved
// OTP into the ADCREFSEL and ADCOFFTRIM registers, occurs automatically in the
// Boot ROM. If the boot ROM code is bypassed during the debug process, the
// following function MUST be called for the ADC to function according
// to specification. The clocks to the ADC MUST be enabled before calling this
// function.
// See the device data manual and/or the ADC Reference
// Manual for more information.
EALLOW;
SysCtrlRegs.PCLKCR0.bit.ADCENCLK = 1;
(*Device_cal)();
EDIS;
// To powerup the ADC the ADCENCLK bit should be set first to enable
// clocks, followed by powering up the bandgap, reference circuitry, and ADC core.
// Before the first conversion is performed a 5ms delay must be observed
// after power up to give all analog circuits time to power up and settle
// Please note that for the delay function below to operate correctly the
// CPU_RATE define statement in the F2806x_Examples.h file must
// contain the correct CPU clock period in nanoseconds.
EALLOW;
AdcRegs.ADCCTL1.bit.ADCBGPWD = 1; // Power ADC BG
AdcRegs.ADCCTL1.bit.ADCREFPWD = 1; // Power reference
AdcRegs.ADCCTL1.bit.ADCPWDN = 1; // Power ADC
AdcRegs.ADCCTL1.bit.ADCENABLE = 1; // Enable ADC
AdcRegs.ADCCTL1.bit.ADCREFSEL = 0; // Select interal BG
EDIS;
DELAY_US(ADC_usDELAY); // Delay before converting ADC channels
EALLOW;
AdcRegs.ADCCTL2.bit.CLKDIV2EN = 1;
EDIS;
DELAY_US(ADC_usDELAY); // Delay before converting ADC channels
EALLOW;
AdcRegs.ADCCTL1.bit.TEMPCONV = 0; // Disable internal temperature sensor
AdcRegs.ADCCTL1.bit.INTPULSEPOS = 1; // ADCINT1 trips after AdcResults latch
AdcRegs.ADCCTL1.bit.ADCREFSEL = 0; // Page485 选择外部VREF
AdcRegs.ADCCTL2.bit.ADCNONOVERLAP = 1; //Enable non-overlap mode
AdcRegs.INTSEL1N2.bit.INT1E = 1; //Enabled ADCINT1
AdcRegs.INTSEL1N2.bit.INT1CONT = 0; //0-Disable ADCINT1 Continuous mode
AdcRegs.INTSEL1N2.bit.INT1SEL = 0; //setup EOC0 to trigger ADCINT1 to fire
// AdcRegs.ADCSAMPLEMODE.bit.SIMULEN0 = 1; // 同时采样
AdcRegs.ADCSOC0CTL.bit.CHSEL = 0; //set SOC0 channel select to ADCINA0
AdcRegs.ADCSOC1CTL.bit.CHSEL = 1; //set SOC0 channel select to ADCINA1
AdcRegs.ADCSOC2CTL.bit.CHSEL = 2; //set SOC0 channel select to ADCINA2
AdcRegs.ADCSOC3CTL.bit.CHSEL = 3; //set SOC0 channel select to ADCINA3
AdcRegs.ADCSOC4CTL.bit.CHSEL = 4; //set SOC0 channel select to ADCINA4
AdcRegs.ADCSOC5CTL.bit.CHSEL = 5; //set SOC0 channel select to ADCINA5
AdcRegs.ADCSOC6CTL.bit.CHSEL = 6; //set SOC0 channel select to ADCINA6
AdcRegs.ADCSOC7CTL.bit.CHSEL = 7; //set SOC0 channel select to ADCINA7
AdcRegs.ADCSOC8CTL.bit.CHSEL = 8; //set SOC0 channel select to ADCINA8
AdcRegs.ADCSOC9CTL.bit.CHSEL = 9; //set SOC0 channel select to ADCINA9
AdcRegs.ADCSOC13CTL.bit.CHSEL = 13; //set SOC0 channel select to ADCINA13
AdcRegs.ADCSOC15CTL.bit.CHSEL = 15; //set SOC0 channel select to ADCINA15
AdcRegs.ADCSOC0CTL.bit.TRIGSEL = 5; //set SOC0 start trigger on software
AdcRegs.ADCSOC1CTL.bit.TRIGSEL = 5; //set SOC1 start trigger on software
AdcRegs.ADCSOC2CTL.bit.TRIGSEL = 5; //set SOC2 start trigger on software
AdcRegs.ADCSOC3CTL.bit.TRIGSEL = 5; //set SOC3 start trigger on software
AdcRegs.ADCSOC4CTL.bit.TRIGSEL = 5; //set SOC4 start trigger on software
AdcRegs.ADCSOC5CTL.bit.TRIGSEL = 5; //set SOC5 start trigger on software
AdcRegs.ADCSOC6CTL.bit.TRIGSEL = 5; //set SOC6 start trigger on software
AdcRegs.ADCSOC7CTL.bit.TRIGSEL = 5; //set SOC7 start trigger on software
AdcRegs.ADCSOC8CTL.bit.TRIGSEL = 5; //set SOC8 start trigger on software
AdcRegs.ADCSOC9CTL.bit.TRIGSEL = 5; //set SOC9 start trigger on software
AdcRegs.ADCSOC13CTL.bit.TRIGSEL = 5; //set SOC13 start trigger on software
AdcRegs.ADCSOC15CTL.bit.TRIGSEL = 5; //set SOC15 start trigger on software
AdcRegs.ADCSOC0CTL.bit.ACQPS = 6; //set SOC0 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)
AdcRegs.ADCSOC1CTL.bit.ACQPS = 6;
AdcRegs.ADCSOC2CTL.bit.ACQPS = 6;
AdcRegs.ADCSOC3CTL.bit.ACQPS = 6;
AdcRegs.ADCSOC4CTL.bit.ACQPS = 6;
AdcRegs.ADCSOC5CTL.bit.ACQPS = 6;
AdcRegs.ADCSOC6CTL.bit.ACQPS = 6;
AdcRegs.ADCSOC7CTL.bit.ACQPS = 6;
AdcRegs.ADCSOC8CTL.bit.ACQPS = 6;
AdcRegs.ADCSOC9CTL.bit.ACQPS = 6;
AdcRegs.ADCSOC13CTL.bit.ACQPS = 6;
AdcRegs.ADCSOC15CTL.bit.ACQPS = 6;
AdcRegs.ADCINTSOCSEL1.bit.SOC7 = 1; // 软件触发源ADCINT1
AdcRegs.ADCINTSOCSEL2.bit.SOC15 = 2; // ADCINT2 will trigger SOC0. TRIGSEL field is ignored.
// 使用ADCSOCFRC1启动
// AdcRegs.ADCSOCFRC1.all = 0X0101; //0000 0001 0000 0001
AdcRegs.ADCSOCFRC1.bit.SOC7 = 1;
AdcRegs.ADCSOCFRC1.bit.SOC15 = 1;
EDIS;
EALLOW;
// Assumes ePWM1 clock is already enabled in InitSysCtrl();
EPwm1Regs.ETSEL.bit.SOCAEN = 1; // Enable SOC on A group
EPwm1Regs.ETSEL.bit.SOCASEL = 4; // Select SOC from from CPMA on upcount
EPwm1Regs.ETPS.bit.SOCAPRD = 1; // Generate pulse on 1st event
EPwm1Regs.CMPA.half.CMPA = 0x0200; // 0x0080; // Set compare A value
EPwm1Regs.TBPRD = 0x9c3; // 0x7CF; // Set period for ePWM1 - 100us
EPwm1Regs.TBCTL.bit.CTRMODE = 0; // count up and start
EDIS;