Like function
AIman
Posts: 531
I need to use a function that will take something and compare it to the closest match. In this case its a scanner picking up·numbers.
Numbers·will be similar but not the same and the closest matching number is what dictates where things get shipped.
Can the BS2 do this?
·
Numbers·will be similar but not the same and the closest matching number is what dictates where things get shipped.
Can the BS2 do this?
·
Comments
kind of matching algorithm you choose, and how you implement it. A common style algorithm is to simply look at how many numbers
match between a known and unknown. That in and of itself could have several implementations.
Example:
10.01.30.40.234 <-- Assume this is the number you want
10.33.36.40.234 <-- Number received
You could say that you have a 60% match because 3 of the 5 numbers match. A more aggressive approach would compare how close
the numbers that did not match were to one another. In this example assuming that 255 is the highest number, you could again look
at the data this way....
(010:010) = 0 ---> 255 - 0 = 255
(001:033) = 32 --> 255 - 32 = 223
(030:036) = 6 ---> 255 - 6 = 249
(040:040) = 0 ---> 255 - 0 = 255
(234:234) = 0 ---> 255 - 0 = 255
255+223+249+255+255 = 1237 ----> 1237 / 1275 = 97%
Note: 1275 = 255 * 5 ... (The maximum value times the number of samples)
Here, the same numbers have a 97% match to one another. So it really depends on how you want to look at your data.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Andy Lindsay
Education Department
Parallax, Inc.
The loop in FindClosestValue.bs2 can also be used for sorting packages by size assuming the BASIC Stamp is measuring it with an ultrasonic peripheral such as the Ping))) sensor.·
As Mike Green pointed out, the BASIC Stamp 2 might not have the processing speed to for some sorting situations where the list of values is very large and the speed of the conveyer belt is fast.· In that case, a BASIC Stamp with more speed and/or memory such as the BASIC Stamp 2p or 2px, or even the Propeller chip·might be in order.· External EEPROM memory may also be necessary for storing larger lists.
On the other hand, a BASIC Stamp 2 system on a given conveyer belt node probably doesn't need to store humungous lists.··Each node in an automatic sorting system is typically concerned with a subset of the data on the barcode.· The text or value can be parsed before it is sorted, significantly reducing the decision time.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Andy Lindsay
Education Department
Parallax, Inc.
Post Edited (Andy Lindsay (Parallax)) : 2/28/2007 7:53:17 PM GMT