Hello dknguyen
Thanks for replying
Actually what i meant by saying 'window-comparator' was a software approach.
I get the voltage in the ADC ,which is interrupt driven,and if the measured value is in between two threshold levels,the o/p is turned on.
To turn on this
TRIAC i have to pull the gate low.Its common terminal should be compulsorily tied to Vcc and Neutral.Now when the gate is 'high' the Triac is off and vice-versa.
Now the ACS712 sensor is put on the high (output) side of the TRIAC.
My MCU uses the same 5v power but its GND is lifted by 3-diode drops to get a 3.3v. (i have attached a schematic of my ckt)
What now happens is,when i turn the TRIAC on ,the ADC starts sampling the current.The code for this sampling is like this
Code:
interrupt 19 void ADC_ISR(void)
{
ADC_Read=ADCR; //+Acknowledge the Read Value to disable COCO Flag
{
if ((( ADC_Read>=306) ) && (PTAD_PTAD1==0))//*********CHANGED FOR ACSTRIAC
{
PTAD_PTAD1 = SET; //************CHANGED FOR ACSTRIAC
PTBD_PTBD1 = SET ; //red LED on
while(1); //wait here until reset
}
if ((( ADC_Read<50)) && (PTAD_PTAD1==0) ) //************CHANGED FOR ACSTRIAC
{
PTAD_PTAD1 = SET; //************CHANGED FOR ACSTRIAC
PTBD_PTBD0 = SET ; //green LED on
}
}
}
Now whenever this interrupt is invoked,the lower-than action takes place and the green led glows.
I tried sampling the ADC_Read for a number of times so that a delay is generated.Still the same thing.
For higher values also it doesn't work 100%...like if i measured a load current and respective voltage at the ADC pin i/p and set the value corresponding to this,it will take action on surge current.
Is there some approach/algorithm for sampling?.maybe i am doing something wrong here
Please get back
Thanks and regards