外部单片机控制部分源码
BYTE GetZVSADC()
{
ADC_CONTR = ADC_POWER|ADC_SPEEDLL|ADC_START|7;
_nop_();
_nop_();
_nop_();
_nop_();
while(!(ADC_CONTR&ADC_FLAG));
ADC_CONTR &= ~ADC_FLAG;
return ADC_RES;
}
void Init()
{
P3M1 = 0x00; //#00000000B
P3M0 = 0xfe; //#11111110B
P1M1 = 0x80; //#10000000B
P1M0 = 0x7f; //#01111111B
K1 = 1;
K2 = 1;
K3 = 1;
K4 = 1;
K5 = 1;
K6 = 1;
K7 = 1;
K8 = 1;
K9 = 1;
K10= 1;
SW = 1;
SPK= 1;
ZVS_PWM = 0;
}
void SetAll(int x)
{
K1 = x;
K2 = x;
K3 = x;
K4 = x;
K5 = x;
K6 = x;
K7 = x;
K8 = x;
K9 = x;
K10= x;
}
void test()
{
while(1){
SetAll(0);
Delay1us();
SetAll(1);
Delay1us();
}
}
void Working()
{
//单片机驱动IGBT给线圈放电
........
}
main()
{
Init();
Beep(30);
DelayMs(70);
Beep(30);
DelayMs(70);
Beep(30);
//test();
while(1){
Delay1ms();
if ( GetZVSADC() < 200 ){ //100值正好的500V,低于1000V升压电路工作
ZVS_PWM = 1;
while(GetZVSADC() < 210) 升压至1050V停止工作
Delay1ms();
}
else{
ZVS_PWM = 0;
if ( SW == 0 )//发射开关
Working();
}
}
}