Page 1 of 2
Compare 2 Data Arrays
Posted: Sat Aug 16, 2025 11:54 am
by Abhijit
Hello!
I have got 2 Data Array like below
RS232_Data[12] (receiving this as ReceiveByteArray from 232) and then saving it to EEPROM as page
Memory_Data[12]
At power jog or reset i read the EEPROM as page to Memory_Data, so eventually i read the same data which i received from RS232 before power jog, i am able to display the receiving as well saved data on the screen and both display same.
Now I want to compare this 2 to get some decision, i tried to use the decision icon but not working as it is not allowed, tried to search the forum but found nothing or may be i am not searching correctly.
May i request to show me the direction.
Thank you.
Regards
Abhi
Re: Compare 2 Data Arrays
Posted: Sat Aug 16, 2025 12:01 pm
by medelec35
Hello.
If you can share your project file ending in fcfx, we will see if we can help you resolve this.
Re: Compare 2 Data Arrays
Posted: Sat Aug 16, 2025 12:36 pm
by Abhijit
Hi! Martin
Thank you for writing back, kindly help me to address this comparing of arrays.
Attached is the chart for your reference.
Thank you, hear you soon.
Regards
Abhi
Re: Compare 2 Data Arrays
Posted: Mon Aug 18, 2025 8:59 am
by medelec35
Hello.
I have just created 1 loop for you which will compare two sets of data
It will require a different but easier approach if you are comparing the same indexes e.g If RS232_Data[0] == Memory_Data[0]
If you are using 0 for any of the data values, then the attached will fail.
In that case you can change
InnerLoop < Length$(RS232_Data)
and OuterLoop < Length$(Memory_Data) just just the total number of elements used.
Re: Compare 2 Data Arrays
Posted: Mon Aug 18, 2025 11:02 am
by Abhijit
Hello! Martin
good morning
Thank you for writing back,
I checked your chart and tried below Calculation icon before main loop, both the arrays are ditto same, after running the chart in simulation the TotalMatchesFound return 12, and that is good or expected, and i can use that for some decision.
Code: Select all
Memory_Data[0] = 'a'
Memory_Data[1] = 'b'
Memory_Data[2] = '3'
Memory_Data[3] = 'd'
Memory_Data[4] = 'e'
Memory_Data[5] = 'f'
Memory_Data[6] = 'A'
Memory_Data[7] = 'B'
Memory_Data[8] = '0'
Memory_Data[9] = 'y'
Memory_Data[10] = '2'
Memory_Data[11] = 'Z'
RS232_Data[0] = 'a'
RS232_Data[1] = 'b'
RS232_Data[2] = '3'
RS232_Data[3] = 'd'
RS232_Data[4] = 'e'
RS232_Data[5] = 'f'
RS232_Data[6] = 'A'
RS232_Data[7] = 'B'
RS232_Data[8] = '0'
RS232_Data[9] = 'y'
RS232_Data[10] = '2'
RS232_Data[11] = 'Z'
Martin i noticed one more thing in the comparing, if two memory locations in both the arrays have same character, for example like below, then TotalMatchesFound return 14, and TotalMatchesFound count increase if there are similar characters in more then 2 locations, so if 'b' is found in 3 locations then TotalMatchesFound return 18
Memory_Data[1] = 'b'
Memory_Data[5] = 'b'
RS232_Data[1] = 'b'
RS232_Data[5] = 'b'
Martin for your knowledge i will quickly brief what exactly i am trying to do, the 12 digit value (alpha-numeric number) i receive at RS232 port from NEXTION is the article number of one of the items stored on the shelf, this article number will be assigned one location number (1-120) this is the data which will be stored in the EEPROM. If user want to know the location number of any of the articles from 1-120 he will punch the number (12 digit long), if the entered number match with the saved one then the location number will be displayed.
So comparing should return affirmative yes or no, can you suggest some way to do so.
Thank you again for your time.
Regards
Abhi
Re: Compare 2 Data Arrays
Posted: Mon Aug 18, 2025 11:34 am
by medelec35
Yes, I understand.
If you have one method of storage as in the EEPROM, how is the data you want it compared to going to be stored, that the user punches in, via keypad?
If so I would recommend sort that out first, then it can be set up to store data.
A way to do that is to use a circular buffer.
If you look a the keypads within Flowcode, look for the 3x4 for example, right-click and select help.
You will be taken to the Wiki site.
Download the Keypad Door entry example.
That should help you get further.
Give it a try and if you get stuck you van attach your project file .
Re: Compare 2 Data Arrays
Posted: Mon Aug 18, 2025 11:39 am
by mnfisher
Try something along the lines of :
Code: Select all
(bool) match = true
byte i = 0
while match && (.i < 12)
.match = array_1[.i] == array_2[.i]
.i = .i + 1
end while
return .match
Martin
Re: Compare 2 Data Arrays
Posted: Mon Aug 18, 2025 11:48 am
by Abhijit
Hi! Martin
The data storing and location finding both the entry is done by NEXTION inbuilt keyboard, and it works perfectly fine using the ReceiveByteArray and then storing the same in EEPROM using write page.
Both the actions of data to save and to search is coming from NEXTION display, and it is of same type (All instructions and parameters are in ASCII), micro need to compare the one which is already saved with the one coming from search action.
I hope i am able to explain my request.
Thank you for writing back.
Regards
Abhi
Re: Compare 2 Data Arrays
Posted: Mon Aug 18, 2025 11:50 am
by Abhijit
Hi! Martin (mnfisher)
Thank you for your suggestion, i will try it now and keep you posted.
Regards
Abhi
Re: Compare 2 Data Arrays
Posted: Mon Aug 18, 2025 5:08 pm
by Abhijit
Hi! Martin
Kindly excuse for the delayed reply, finally what i was expecting is happening in the simulation and i am sure the same shall work at actual, took some time to write as flowchart.
(bool) match = true
byte i = 0
while match && (.i < 12)
.match = array_1[.i] == array_2[.i]
.i = .i + 1
end while
return .match
Thank you again.
Regards
Abhi