= TI S6350 communication overview = In order to use the [wiki:S6350 TI reader] within RealBasic we had to implement some of the serial protocol ourselves. You must first generate a command [wiki:S6350serialcom#TIS6350protocolheader encapsulated in the TI protocol] and have the payload of the command be the [wiki:ISO15693] command. Only 3 of the [wiki:ISO15693] commands are used to track RFID's, [wiki:S6350serialcom#InventoryAllSlots Inventory All Slots], [wiki:S6350serialcom#Inventory1slot Inventory 1 Slot] and [wiki:S6350serialcom#SilenceTag Silence Tag]. = TI S6350 protocol header = To use [wiki:ISO15693] commands with the TI reader the command must be encapsulated in a TI command followed by a [wiki:S6350serialcom#Checksum checksum]. An example of the TI command structure follows: {{{ Byte 1 is the Start of Frame, always 01 Byte 2 and 3 is the length of the command including the 2 byte check sum that is added to the end, Least Significant Byte first Byte 4 and 5 is the node address, leave at 00 as we do not reference nodes Byte 6 is the command flags, no flags present Byte 7 is the command, &h60 means it is an ISO15693 command which will be in the data portion of the packet Byte 8 is the config byte for the reader Byte 9 through x are for the data which can be an ISO15693 command Bytes x+1 and x+2 are the checksum }}} = Inventory All Slots = This sends an ISO15693 inventory command for the TI S6350 reader. It does an inventory of all time slots, this supports [wiki:S6350serialcom#Collisions anti-collision] but is too slow to use during a race as it takes about .3 seconds to return results. This command is used to scan in racers before a race starts. By using the inventory all slots command everyone can line up on the finish line and one inventory done to add them to the race. The breakdown of the command is as follows: {{{ Byte 1 is the Start of Frame, always 01 Byte 2 and 3 is the length of the command including the 2 byte check sum that is added to the end, Least Significant Byte first Byte 4 and 5 is the node address, leave at 00 as we do not reference nodes Byte 6 is the command flags, no flags present Byte 7 is the command, &h60 means it is an ISO15693 command which will be in the data portion of the packet Byte 8 is the config byte for the reader, &h11 means 100% modulation and 1/4 data mode Byte 9 is the ISO15693 command flags, &h07 means 2 sub carriers, high data rate, inventory_flag set, nb_slots_flag set to all 16 slots Byte 10 is the ISO15693 command, &h01 means inventory Byte 11 is the optional mask that is not set Bytes 12 and 13 are the checksum The resulting command could look like this: chrB(&h01) + chrB(&h0D) + chrB(&h00) + chrB(&h00) + chrB(&h00) + chrB(&h00) + chrB(&h60) + chrB(&h11) + chrB(&h07) + chrB(&h01) + chrB(&h00) + chrB(&h7B) + chrB(&h84) }}} The [wiki:S6350serialcom#InventoryResponse response] returned for this command will have all the [wiki:ISO15693tags#UID UID's] listed. The [wiki:ISO15693tags#UID UID's] will be in reverse byte order. = Inventory 1 slot = This sends an ISO15693 inventory command for the TI S6350 reader. This does an inventory of just the first time slot, which allows for a faster inventory responses but can not handle collisions. A collision is when two tags or more tags are in the field at the same time. To minimize [wiki:S6350serialcom#Collisions collisions] [wiki:S6350serialcom#SilenceTag silence] the tag after it is detected. This command is used to detect RFID's during a race. The response time to this command is approximately 2ms giving us sufficient accuracy for tracking RFID's. The breakdown of the command is as follows: {{{ Byte 1 is the Start of Frame, always 01 Byte 2 and 3 is the length of the command including the 2 byte check sum that is added to the end, Least Significant Byte first Byte 4 and 5 is the node address, leave at 00 as we do not reference nodes Byte 6 is the command flags, no flags present Byte 7 is the command, &h60 means it is an ISO15693 command which will be in the data portion of the packet Byte 8 is the config byte for the reader, &h11 means 100% modulation and 1/4 data mode Byte 9 is the ISO15693 command flags, &h27 means 2 sub carriers, high data rate, inventory_flag set, nb_slots_flag set to 1 slot Byte 10 is the ISO15693 command, &h01 means inventory Byte 11 is the optional mask that is not set Bytes 12 and 13 are the checksum The resulting command could look like this: ChrB(&h01) + ChrB(&h0D) + ChrB(&h00) + ChrB(&h00) + ChrB(&h00) + ChrB(&h00) + ChrB(&h60) + ChrB(&h11) + ChrB(&h27) + ChrB(&h01) + ChrB(&h00) + ChrB(&h5B) + ChrB(&hA4) }}} The [wiki:S6350serialcom#InventoryResponse response] to this command will only have 1 [wiki:ISO15693tags#UID UID]. The [wiki:ISO15693tags#UID UID] will be in reverse byte order. = Inventory Response = The response from the TI S6350 will look like this: {{{ Byte 1 is the Start of Frame, always 01 Byte 2 and 3 is the length of the command including the 2 byte check sum that is added to the end, Least Significant Byte first Byte 4 and 5 is the node address, leave at 00 as we do not reference nodes Byte 6 is the command flags, no flags present Byte 7 is the command, &h60 means it is an ISO15693 command which will be in the data portion of the packet Bytes 8&9 are ISO settings. Bytes 10&11 are padding Bytes '12+n' is the data with the UIDs (reverse byte order and 2 bytes of &h00 padding each) Last 2 Bytes are the checksum Sample Response with 4 UIDs. 01 35 00 00 00 00 60 41 82 00 00 00 00 80 14 C0 12 00 00 07 E0 00 00 B6 E7 53 13 00 00 07 E0 00 00 79 14 C0 12 00 00 07 E0 00 00 7F 14 C0 12 00 00 07 E0 C6 39 }}} [wiki:ISO15693tags#UID UID's] are in reverse byte order. They are padded with 2 extra bytes of the value &h00. The following [wiki:ISO15693tags#UID UID's] were in the above response: * E007000012C0147F * E007000012C01479 * E00700001353E7B6 * E007000012C01480 = Silence Tag = The [wiki:ISO15693tags#UID UID] passed must be a string in the reverse byte order that it is received in the string assembled by this can be sent directly to the serial port to silence the given RFID tag The breakdown of the command is as follows: {{{ Byte 1 is the Start of Frame, always 01 Byte 2 and 3 is the length of the command including the 2 byte check sum that is added to the end, Least Significant Byte first Byte 4 and 5 is the node address, leave at 00 as we do not reference nodes Byte 6 is the command flags, no flags present Byte 7 is the command, &h60 means it is an ISO15693 command which will be in the data portion of the packet Byte 8 is the config byte for the reader, &h11 means 100% modulation and 1/4 data mode Byte 9 is the ISO15693 command flags, &h23 means 2 sub carriers, high data rate, and address flag is set Byte 10 is the ISO15693 command, &h02 means be quiet Byte 11-18 are the UID that needs to shut up Byte 19 and 20 are the checksum that is added later An example would be: ChrB(&h01) + ChrB(&h14) + ChrB(&h00) + ChrB(&h00) + ChrB(&h00) + ChrB(&h00) + ChrB(&h60) + ChrB(&h11) + ChrB(&h23) + ChrB(&h02) + UID + Checksum }}} = Collisions = The [wiki:ISO15693] protocol allows for 16 time slots for communicating with an RFID reader. A collision occurs when 2 or more tags use the same time slot. By default each tag will use the 1st time slot unless a collision occurs. In the event of a collision the tags will randomly move to a different time slot. The [wiki:S6350serialcom#InventoryAllSlots Inventory All Slots] command can handle this as it checks each of the 16 slots for a RFID. Unfortunately doing this operation is slow, it takes about .3 seconds, far too long for a lap counter to get accurate lap times. The solution is to use the [wiki:S6350serialcom#Inventory1slot Inventory 1 slot] command during races. This command will just check the 1st time slot for a tag. To prevent collisions you must [wiki:S6350serialcom#SilenceTag silence] the tag immediately after it is detected. If a tag is [wiki:S6350serialcom#SilenceTag silenced] it will not transmit again until it leaves and reenters the antenna loop. The response time to this command is < 2ms giving us sufficient accuracy for lap counting. = Checksum = The checksum used by the TI S6350 is very basic. It is a 2 byte checksum. The first byte is the XOR of the string. The second byte is teh XOR of &hFF and the first byte. Here is an example of the code to do this: {{{ dim data as string dim checksum as string dim xornumber1 as integer dim xornumber2 as integer 'Do a XOR of all the bytes of the string for byte 1 of the checksum 'Do not worry about xornumber having a zero initially, this does not impact the XOR operation for i as Integer=1 to len(data) xornumber1 = xornumber1 xor ascB(mid(data,i,1)) next 'calculates byte 2 of the checksum xornumber2 = &hFF xor xornumber1 'put the two together for the complete checksum checksum = chrB(xornumber1) + chrB(xornumber2) }}}