本帖最后由 snakeemail 于 2009-12-15 23:23 编辑
1.当电流在0-300,风扇的PWM为0,当电流大于300的时候,风扇的PWM为51.这样当电流在300附件变化时,风扇的PWM也来回变化。现在用软件实现的滞回比较器实现。
2. a.0-300,PWM=0 , b200-1000,PWM=51, C: 900-2000 ,PWM=100 D:电流>1900,PWM=200
void ZhiHui(unsigned int Data)
{
static unsigned int a = 0;
static unsigned int b = 300;
unsigned int OCR0A = 0;
if((Data>a) && (Data <=b))
return;
if((Data>0) && (Data<=300)) {
OCR0A = 0;
a = 0;
b = 300;
}
else if((Data>200) && (Data<=1000)) {
OCR0A = 51;
a = 200;
b = 1000;
}
else if((Data>900) && (Data<=2000)) {
OCR0A = 100;
a = 900;
Data = 2000;
}
else{
OCR0A = 200;
a = 1900;
b = 65535;
}
} |