PIC BLDC三相电机研读总结及舵机测试框架.docVIP

  • 4
  • 0
  • 约7.85千字
  • 约 8页
  • 2019-08-10 发布于江西
  • 举报

PIC BLDC三相电机研读总结及舵机测试框架.doc

PIC BLDC三相电机研读总结(james14888@gmailcom) ADC中断处理 void __attribute__((__interrupt__,auto_psv)) _ADC1Interrupt(void) { uint16 u16MotorNeutralVoltage; uint16 u16MotorPhaseA; uint16 u16MotorPhaseB; uint16 u16MotorPhaseC; DesiredSpeed = ADC1BUF0; //POT u16MotorPhaseA = ADC1BUF3; //--V1 u16MotorPhaseB = ADC1BUF2; //--V2 u16MotorPhaseC = ADC1BUF1; //--V3 u16MotorNeutralVoltage = (u16MotorPhaseA + u16MotorPhaseB + u16MotorPhaseC)/3; AD1CON1bits.DONE = 0; IFS0bits.AD1IF = 0; /************** ADC SAMPLING BMEF signals comparison ****************/ if(u16MotorPhaseA u16MotorNeutralVoltage) { Comparator.PhaseAOutput = 1; } else { Comparator.PhaseAOutput = 0; } if(u16MotorPhaseB u16MotorNeutralVoltage) { Comparator.PhaseBOutput = 1; } else { Comparator.PhaseBOutput = 0; } if(u16MotorPhaseC u16MotorNeutralVoltage) { Comparator.PhaseCOutput = 1; } else { Comparator.PhaseCOutput = 0; } u16ComparatorOutputs = (Comparator.PhaseCOutput2) 0x0007; u16ComparatorOutputs |= (Comparator.PhaseBOutput1); u16ComparatorOutputs |= Comparator.PhaseAOutput; } 输出两个参量: DesiredSpeed电位器定位的目标速度 u16ComparatorOutputs 与平均电压比较的结果指示 主函数 int main(void) { PLLFBD=38; // M=40 80MHz ;40MIPS CLKDIVbits.PLLPOST=0; // N2=2 CLKDIVbits.PLLPRE=0; // N1=2 RCONbits.SWDTEN=0; while(OSCCONbits.LOCK != 1) {}; // Wait for PLL to lock ……………………… Kps = 3000; Kis = 2; PILoopControllerOutput = 0; timer3value = 0; timer3avg = 0; …………………….. for(;;) { while (!S1); // wait for S1 button to be hit while (S1) // wait till button is released DelayNmSec(20); u16CurrentPWMDutyCycle = 1; u16DesiredPWMDutyCycle = 0; DesiredSpeed = 0; ActualSpeed = 0; SpeedError = 0; SpeedIntegral = 0; PILoopControllerOutput = 0; timer3value = 0; timer3avg = 0; PWM1CON1 = 0x0777; // enable PWM outputs DelayNmSec(1); Flags.RampUpBEMF =1; Flags.RunMotor = 1; // indicationg the run motor condition …………………….

文档评论(0)

1亿VIP精品文档

相关文档