/******************************************************************************
Program for Duel AC Fan controll.
Program written by Engr. Mithun K. Das
MCU: PIC12F675, X-Tal: 4MHz(internal)
Date: 15-Oct-2012. cell: +8801722448270.
*******************************************************************************/
unsigned int speed1, speed2,zero1,zero2;
int cnt1,cnt2,cross1,cross2;
void main()
{
CMCON=0x07;
ANSEL=0x07;// gp0 & gp1 &gp4 analog in
OSCCAL = 0xFF;
TRISIO=0b00001111; // gp2 and gp5 output
GPIO=0x00;
while(1)
{
// get speed1
ADCON0=0b00000000;
speed1 = ADC_Read(0);
cross1 = speed1*10/1023;
// get speed2
ADCON0=0b00000100;
speed2 = ADC_Read(1);
cross2 = speed2*10/1023;
// sense
ADCON0=0b00001000;
zero1 = ADC_Read(2);
if(zero1<=5)
{
GP4_bit = 0;
GP5_bit = 0;
cnt1 = 0;
cnt2 = 0;
}
else
{
cnt1++;
cnt2++;
if(cnt1>cross1)
{
GP4_bit = 1;
Delay_ms(1);
}
else
{
GP4_bit = 0;
}
if(cnt2>cross2)
{
GP5_bit = 1;
Delay_ms(1);
}
else
{
GP5_bit = 0;
}
}
}// while
}// void main