Receiving the Card Number
When the PIC sends data, it needs to be captured. This is done by the Sub “MSComm1_OnComm()”. Every time there is a specific event, the sent data is first transformed in a hexadecimal number and then stored in a string called “Storage”. Once the length equals 16, the entire account number has been sent and the ID-number is known. To check for a match with existing ID’s, we took only the last 8 numbers because Excel or Visual Basic gives problems if we want to compare the whole thing. This can be justified by the fact that the first 6 numbers for bank cards are usually the same anyway.
Checking for a match
This is executed by the sub “sjeck”. As mentioned before, the database in Excel consists of the allowed people. First of all, the excel-object is created and then opened. Now we check if there is data present in the file, if so all the ID-numbers are placed in an array “IDnumbers” and checked for a match with the received “CardNumber”. When the same number has been found, the other information of the person is assigned to specific variables (“FirstName”, “StartDay”, “EndDay”,…). Next “sjeck2” is performed which controls if the day and time limits are not exceeded. Visual Basic has functions which give us the actual date and time (“Weekday” an “Hour). The result of these is an integer which does not represent a problem for comparing the hours but the day limits stored in the database need to be subjected to a conversion. The self-declared function “Conversion” accomplishes this task by turning a string, containing a weekday, into a number from 1 to 7. In both cases: check ok or not ok, a specific message is back sent to the PIC.
Result to PIC
We have 2 Sub’s “Send” and “SendNot”. Both use the function “ToSend” which takes care of the fact that always 16 characters are back sent to the microcontroller and, depending on the result, makes sure that the name of the person is centered on the LCD display. If the chipcard holder is allowed, the character “255” is transported to the PIC together with his or her firstname. If he or she doesn’t have