freemanantony
Member level 4
- Joined
- May 19, 2010
- Messages
- 70
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,286
- Location
- Chennai, India
- Activity points
- 2,005
hai everybody,
i have done code for current measurement in Pic 16F886 and after measuring current need to switch off output if the current measured is more than the maximum current, but when comparing if the current is less than maximum current it is not hitting the else condition. i am attaching my code here
adc_val, curent_R and MAX_CURENT are unsigned long variables
can anyone help me on this ?
i have done code for current measurement in Pic 16F886 and after measuring current need to switch off output if the current measured is more than the maximum current, but when comparing if the current is less than maximum current it is not hitting the else condition. i am attaching my code here
Code:
R_Phase_curr: ADCON0 = 0xA9 ; //0x69 //0xA9 // reading R_ phase current// Changed ADC conversion clock to Fosc/32 from Fosc/8
delay(10);
adc_do();
current_R = adc_val;
if(current_R > MAX_CURRENT) if(current_R > MAX_CURRENT)
{
R_Phase_ol = 1;
ALERT_FR = 1;
}
else if (current_R < MAX_CURRENT)
{
R_Phase_ol = 0;
ALERT_FR = 0;
}
can anyone help me on this ?