Dear Sir,
I have stored setpoint value in EEPROM memory in by keypad and I want to compare setpoint value with process value. Process value is stored in one array, say data[5]. I read the setpoint value from EEPROM and again stored in another array, say presetvalue[5]. I am using below logic to compare the both value but it is not working properly. I have used RC0 pin, which is connected to LED. When PV is higher than SV then RC0 pin will be high so LED should be glow.
for(i=0;i<5;i++) // To read the setvalue from EEPROM
{
value=eeprom_read(i);
presetvalue=value; // Stored setvalue in presetvalue[5] array
}
for(i=0;i<5;i++) // Comparison logic for setvalue and process value
{
if(data > presetvalue) // When PV>SV, RC0 pin high
{
RC0=1;
i=5;
}
else if(data==presetvalue) // If equal then compare next bit (From MSB
to LSB)
{ RC0=1; }
else if(data < presetvalue) // When PV<SV, RC0 pin low
{
RC0=0;
i=5;
}
}
Plz suggest me where may be problem.
If there is another good logic, then plz suggest me.
Thanks in advance,
I have stored setpoint value in EEPROM memory in by keypad and I want to compare setpoint value with process value. Process value is stored in one array, say data[5]. I read the setpoint value from EEPROM and again stored in another array, say presetvalue[5]. I am using below logic to compare the both value but it is not working properly. I have used RC0 pin, which is connected to LED. When PV is higher than SV then RC0 pin will be high so LED should be glow.
for(i=0;i<5;i++) // To read the setvalue from EEPROM
{
value=eeprom_read(i);
presetvalue=value; // Stored setvalue in presetvalue[5] array
}
for(i=0;i<5;i++) // Comparison logic for setvalue and process value
{
if(data > presetvalue) // When PV>SV, RC0 pin high
{
RC0=1;
i=5;
}
else if(data==presetvalue) // If equal then compare next bit (From MSB
to LSB)
{ RC0=1; }
else if(data < presetvalue) // When PV<SV, RC0 pin low
{
RC0=0;
i=5;
}
}
Plz suggest me where may be problem.
If there is another good logic, then plz suggest me.
Thanks in advance,