Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Issue in two integer array comparison

Status
Not open for further replies.

ecaits

Member level 4
Joined
Jan 16, 2014
Messages
76
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Activity points
579
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,
 

you are comparing each element of the array and setting RCO

consider comparing array with elements 1,2,3,4,5 with array 1,4,2,6,1
1. first elements are the same 1=1 RC0=0
2. second 2 < 4 RC0 = 1
3. third 3 > 2 RC0=0
4. fourth 4 < 6 RC0=1
5. fifth 5>1 RCO=0

RC0 is set 0 or 1 depending on corresponding elements of the array

is this what you want to do? if not what?

could you give us some examples of your data and explain what results you would expect?
 

You want to store a flag in eeprom and read it on restart or do you want to store 5 bytes in eeprom and read it on restart? Is it a password you are storing or some limit value like temperature? What you want to store in eeprom, signed / unsigned 8 bit or 16 bit, signed / unsigned 8 / 16 bit, etc...

You want to compare value already stored in eeprom with what value after restart? From where do you get the data which you compare with data in eeprom?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top