RS-232 Bill Enable Masking
The RS-232 bill validator protocol allows you to programmatically control exactly which bills are enabled and disabled. For example, if after 10PM you no longer want to accept denominations over $20, you can instruct the bill acceptor to simply reject notes $20 and higher.
This is a nice alternative to writing a fully escrow-enabled host application which is more complex than the typical passive host. In the post we will be discussing the latter.
Referring to the RS-232 bill validator protocol specification, page 4, we see that data byte 0 from the master controls this parameter. As a review we are talking about the Data Fields region in bold below.
| STX | Length | MSG Type and Ack Number | Data Fields | ETX | Checksum |
That means it is the 4th byte in the byte array transmitted by the master to the slave. The format of this byte is as follows:
- Bit 0 : Bill 1 (e.g. USA $1)
- Bit 1: Bill 2 (e.g. USA $2 or CAN $10. note that 2$ USA are not commonly accepted)
- Bit 2: Bill 3 (e.g. USA $5)
- Bit 3: Bill 4 (e.g. USA $10)
- Bit 4: Bill 5 (e.g. USA $20)
- Bit 5: Bill 6 (e.g. USA $50)
- Bit 6: Bill 7 (e.g. USA $100)
Notice that only 7 bits of that byte are used. This is because RS-232 is a 7-bit protocol and so we can only support 7 separate denominations. Of course, if you have more than 7 denominations you should talk to our engineering team as we can always make things work.
Back to the bits bytes!
Let's review a byte in binary with a focus on the terms most and least significant byte. As the you may remember, MSB is the most significant bit in a byte. This means that if the bit is set to 1, the decimal value will be greater than if the LSB was set to 1. For the sake of simplicity we will be ignoring endianess as our API handles this for us.
</a>Each bit from LSB to MSB corresponds to a bill number. With that in mind, here are some examples.
Once you have your mask, all you need to do is apply it. This settings is available through the API as a configuration constant that is polled during every message loop. By default this is 100 milliseconds but may be adjusted between 50 milliseconds and 5 seconds. The syntax for setting this value in the Java API is:
RS232Configuration.INSTANCE.setEnableMask(29) // should do the trick.
That's all for today, have fun!
Feel free to comment on the post but keep it clean and on topic.blog comments powered by Disqus