|

楼主 |
发表于 2019-12-20 20:56:03
|
显示全部楼层
补图
补图
补源码:
#include "STC15F60.h"
#include "intrins.h"
#define LOAD_RUN P26
#define TIG_SYNC P25
#define WAVE_EN P24
#define TEMP_HIGH P22
#define CURR_LOW_PWR P21
#define TEMP_HIGH_LED P20
#define RUN_LED P33
#define SW_1ms P10
#define SW_10ms P11
#define SW_100ms P12
#define SW_1000ms P13
#define SW_EXT_TIG P14
#define SW_WAVE P15
#define RUN 0
#define STOP 1
bit EXT_MARK ; //外置触发标记
bit TEMP_HIGH_MARK; //过热标记 0过热,1正常。
//精准定时
void Delay1ms() //@24.000MHz
{
unsigned char i, j;
i = 24;
j = 85;
do
{
while (--j);
} while (--i);
}
void Delay10ms() //@24.000MHz
{ unsigned char i, j, k;
_nop_();
_nop_();
i = 1;
j = 234;
k = 113;
do
{
do
{
while (--k);
} while (--j);
} while (--i);
}
void Delay100ms() //@24.000MHz
{
unsigned char i, j, k;
_nop_();
_nop_();
i = 10;
j = 31;
k = 147;
do
{
do
{
while (--k);
} while (--j);
} while (--i);
}
void Delay1000ms() //@24.000MHz
{
unsigned char i, j, k;
_nop_();
_nop_();
i = 92;
j = 50;
k = 238;
do
{
do
{
while (--k);
} while (--j);
} while (--i);
}
//---------------
void DISP()
{ char SW ;
while(1)
{
while(!TEMP_HIGH){
EA = 0;
P0 = 0xFF;
SW = P0;
LOAD_RUN = STOP;
RUN_LED = STOP;
TEMP_HIGH_LED = !TEMP_HIGH_LED;
Delay100ms();
Delay100ms();
}
EA = 1;
TEMP_HIGH_LED = 1;
if(SW != P1 ) {
LOAD_RUN = STOP;
WAVE_EN = STOP;
SW = P1;
P0 = P1;
} else if(EXT_MARK == 1) {
LOAD_RUN = !TIG_SYNC;
}
}
}
//---------------
void main()
{
P0M0 = 0x00;
P0M1 = 0x00;
P1M0 = 0x00;
P1M1 = 0x00;
P2M0 = 0x00;
P2M1 = 0x00;
P3M0 = 0x00;
P3M1 = 0x00;
P4M0 = 0x00;
P4M1 = 0x00;
P5M0 = 0x00;
P5M1 = 0x00;
P6M0 = 0x00;
P6M1 = 0x00;
P7M0 = 0x00;
P7M1 = 0x00;
EXT_MARK = 0; //默认内部触发
WAVE_EN = STOP; //波形输入高电平
LOAD_RUN = STOP; //关驱动器
CURR_LOW_PWR = 0;
TEMP_HIGH = 1;
P32 = 1;
IT0 = 1; //设置INT0的中断类型 (1:仅下降沿)
EX0 = 1; //使能INT0中断
EA = 1;
P0 = P1;
DISP();
}
void exint0() interrupt 0 //INT0中断入口
{ EA = 0; //关中断
LOAD_RUN = STOP;
CURR_LOW_PWR = 0;
RUN_LED = STOP ;
if(SW_EXT_TIG == 0) //外部触发
{
EXT_MARK = !EXT_MARK;
RUN_LED = !EXT_MARK;
TIG_SYNC = 1;
if(EXT_MARK == 0){LOAD_RUN = STOP;}
Delay1ms();
}
if(SW_WAVE == 0) //波形触发
{
WAVE_EN=!WAVE_EN;
CURR_LOW_PWR = !CURR_LOW_PWR;
RUN_LED = WAVE_EN ;
LOAD_RUN = !LOAD_RUN;
Delay1ms();
}
if(SW_1ms == 0) //1毫秒
{RUN_LED = RUN ;
Delay100ms();
Delay1ms();
LOAD_RUN = RUN;
Delay1ms();
LOAD_RUN = STOP;
Delay10ms();
LOAD_RUN = RUN;
Delay1ms();
LOAD_RUN = STOP;
Delay10ms();
LOAD_RUN = RUN;
Delay1ms();
LOAD_RUN = STOP;
Delay100ms();
RUN_LED = STOP ;
}
if(SW_10ms == 0) //10毫秒
{RUN_LED = RUN ;
Delay100ms();
Delay1ms();
LOAD_RUN = RUN;
Delay10ms();
LOAD_RUN = STOP;
Delay10ms();
Delay10ms();
Delay10ms();
Delay10ms();
Delay10ms();
LOAD_RUN = RUN;
Delay10ms();
LOAD_RUN = STOP;
Delay10ms();
Delay10ms();
Delay10ms();
Delay10ms();
Delay10ms();
LOAD_RUN = RUN;
Delay10ms();
LOAD_RUN = STOP;
Delay10ms();
Delay10ms();
Delay10ms();
Delay10ms();
Delay100ms();
RUN_LED = STOP ;
}
if(SW_100ms == 0) //100毫秒
{RUN_LED = RUN ;
Delay100ms();
LOAD_RUN = RUN;
Delay100ms();
LOAD_RUN = STOP;
Delay100ms();
Delay100ms();
Delay100ms();
Delay100ms();
Delay100ms();
LOAD_RUN = RUN;
Delay100ms();
LOAD_RUN = STOP;
Delay100ms();
Delay100ms();
Delay100ms();
Delay100ms();
Delay100ms();
LOAD_RUN = RUN;
Delay100ms();
LOAD_RUN = STOP;
Delay100ms();
Delay100ms();
Delay100ms();
RUN_LED = STOP ;
}
if(SW_1000ms == 0) //1000毫秒
{RUN_LED = RUN ;
Delay1ms();
LOAD_RUN = RUN;
CURR_LOW_PWR = 1;
Delay1000ms();
CURR_LOW_PWR = 0;
LOAD_RUN = STOP;
Delay1000ms();
Delay1000ms();
Delay1000ms();
LOAD_RUN = RUN;
CURR_LOW_PWR = 1;
Delay1000ms();
CURR_LOW_PWR = 0;
LOAD_RUN = STOP;
Delay1000ms();
Delay1000ms();
Delay1000ms();
LOAD_RUN = RUN;
CURR_LOW_PWR = 1;
Delay1000ms();
CURR_LOW_PWR = 0;
LOAD_RUN = STOP;
Delay100ms();
RUN_LED =STOP ;
Delay1000ms();
}
//EA = 1;
}
|
|