Working with payment terminals put us in contact with the MDB protocol. A very special protocol that gave us some headaches. For a long time now I wanted to share some of the problems we had – and insights we gained – while creating a product based around the MDB protocol. As a software company, starting with the product design we never imagined that the final product would be a fully engineered hardware terminal. But that’s what it turned out to be…
MDB Protocol Issues
One of the key features of the AXT1 is its MDB vending machine interface designed in the 80ies by Coca Cola. MDB stands for Multi Drop Bus. Simply put this is a serial bus you can connect one master and several slaves to. The MDB protocol is widely used in vending machines and it’s the way to go if you want to provide a payment terminal for vending machines.
The special thing about it – or at least special for us software people coming from 8, 16, 32 and 64 bit environments – is that it is a 9 bit protocol. Instead of using the more common 8 data bits and one optional parity bit, it uses 9 data bits and no parity bit. The 9th bit is used to address the slaves in the beginning of a communication session. The problem is that the UARTs (hardware components that takes care of the serial communication on the bus) provided by standard embedded PC boards (PCB) support 5 to 8 data bits, but 9 data bits are not supported out of the box. Therefore, connecting a “more intelligent” device such as a PC to a vending machine is not a plug and play kind of thing. But this is exactly what we wanted to do. Our payment software runs on linux and android and we undoubtedly wanted to keep it that way. The reasons for this I think are quite obvious and could fill another blog.
First Solutions and More Issues
Easy done, we thought. We simply get a linux PCB, use a UART in 8 bit mode and use the parity bit as the 9th data bit, as this guy here suggests. Not very elegant, but it works. Another option would be to get a PCB with 9 bit UART support. There are some of these out there, but this limits the choice of PCBs and creates an unnecessary dependency to the PCB used. That is in most cases not a solution.
Happy about our first implementation, we connected our terminal to a vending machine. This first test was a big disappointment. The MDB protocol specifies a time window of 5 milliseconds for a slave to answer. We found out that when running our software on an OS like linux or android, it is more or less accidental whether we could reply in this short time or not. In hindsight, it is now obvious… We thought about changing to a real time OS, but dismissed this because it would have required massive efforts to port and maintain our software. This is also in most cases not a solution.
Solution: MDB Converter
The only way to go forward was to design our own piece of hardware with a 9 bit UART and a micro controller that acts as a “gateway” between the PCB and the MDB. The MDB converter was born. The micro controller on the MDB converter takes care of all the MDB specific timing issues and uses the 9 bit UART to communication with the MBD. On the PCB side, we use a standard 8 bit UART and an internal communication protocol. As a final step, we integrated the MDB converter with a standard PCB into one piece of hardware and there it was, the MDB enabled AXT1.
Currently, we run this solution in over 500 vending machines and are very happy with the solution. It gives us the flexibility we need to extend our software while still keeping up with the MDB requirements.
Talking to our partners, we found out that most of the companies who want to connect linux, android or other modern devices to vending machines have the same problems. Therefore, we now provide the MDB converter as a standalone module. Simply connect your device to the vending machine using the MDB converter.
If you have had similar problems or are looking for a solution in this area, please share with a comment.
You can buy the MDB converter here.
Dec 2017: MDB to Raspberry Pi
It has been a while since I have written this post. It is now December 2017 and we have just launched our MDB2Pi. The MDB2Pi has the same features like the MDB converter, but can be used as Raspberry Pi HAT.
Nov 2022: MDB Converter 4
These days we have customers around the world using our MDB converter products. Many thousands of them were shipped and they work reliable every day around the world. Even some of the largest companies in the world use our products. We even upgraded to MDB Converter 4.