Vending Machine MDB questions

6,435 views
Skip to first unread message

Dan Royer

unread,
Apr 16, 2014, 1:37:26 PM4/16/14
to notti...@googlegroups.com
Hi Nottinghack!

I have just upgraded the vending machine at the Vancouver Hackspace.  The new model supports MDB and I'd like to monkey with that.  Someone sent me a video of your RFID hack and so here I am.

I read the pages on your wiki including the implementation details.  I'm looking to build a similar device to connect to a Raspberry Pi running inside the vending machine.

I read the MDB 4.2 doc and followed their instructions (p54) to build a two-way serial interface.  I set up an Arduino running SoftwareSerial to listen for bits coming from MDB and so far I'm getting nothing.
I could Dark Souls my way through this, but I'm lazy and you've already solved this riddle.

I don't have a nanode yet, but I can fumble my way through building most anything.  Would you be willing to share a wiring schematic of your device?


Dan Royer

unread,
Apr 16, 2014, 1:42:07 PM4/16/14
to notti...@googlegroups.com
So of course it's two seconds after I ask that I spot the overlooked http://wiki.nottinghack.org.uk/images/a/a2/VMC-Nanode_Schematic.png link. :P

Dan Royer

unread,
Apr 16, 2014, 2:56:46 PM4/16/14
to notti...@googlegroups.com
This is some really bare metal work!  Your Kung Fu is greater than mine.

I like the way you use the network to send debug messages.  I'm trying to run two serial connections at once - one to the MDB, one back to the Arduino window so I can log the output and parse what's going on.  Is that possible or are the two serials going to step on each other?




On Wed, Apr 16, 2014 at 11:37 AM, James Hayward <jhaywa...@gmail.com> wrote:
Hi Dan

The serial on the MDB spec is horrible!  It is 9 bit, so not supported by either softwareSerial or even the Arduino hardware library.  It is probably not your wiring that is causing you issues!  (although you need to make sure you optically isolate the device from the vending machine as it is relatively high voltage)

The AVR chip itself natively supports it 9bit serial, so we ypassed the Arduino libraries and used that.

All our code is on github:

The firmware is here:  https://github.com/NottingHack/Vend

If you have any other questions, feel free to post back, and we'd love to see pictures!

James


--
You received this message because you are subscribed to the Google Groups "Nottingham Hackspace - Nottinghack" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nottinghack...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "Nottingham Hackspace - Nottinghack" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/nottinghack/IWPDt1gMi5M/unsubscribe.
To unsubscribe from this group and all its topics, send an email to nottinghack...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Dan Royer :: Marginally Clever :: Raising Robot Literacy :: +1.604.916.2281

Matt Lloyd

unread,
Apr 16, 2014, 3:04:42 PM4/16/14
to NottingHack Google Groups
You need to use MDB on the hardware serial.
You could use software serial to send out debug message over two other pins but your not going to be able to do it over an arduino's native USB<>Serial link


'RepRap' Matt

Daniel S

unread,
Apr 17, 2014, 2:26:03 AM4/17/14
to notti...@googlegroups.com
I'd also suggest you use the hardware serial of the AVR for talking to the vending machine and softserial for normal serial output - it'll likely be a lot easier than trying to get softserial to work with 9bit serial.

We've used the hardware serial to talk MDB, and softserial for the RFID reader without any issues, so you shouldn't have any problems using the two at once.

Also, a Nanode is just an Arduino compatible & ENC28J60 based Ethernet shield combined on a single board.

Daniel

Dan Royer

unread,
Apr 17, 2014, 3:29:27 AM4/17/14
to notti...@googlegroups.com
I've got one Arduino ("mdb") connected with the optoisolators, using hardware serial to talk to the VM.  I'm using software serial to talk to a second arduino ("bridge") that's sending all the data via hardware serial to the PC running a serial terminal in Arduino software.  In effect mdb is passing everything to bridge to my computer.  Sample output version was binary garbage until we figured out the bridge software serial RX needed a pull-up resistor.  v2 I was getting binary data like this:

00001000    00000001
00001000    00000000
00001000    00000001
00001000    00000000
00001000    00000001
00001000    00000000
00110000    00000001
00110000    00000000
00110000    00000001
00110000    00000000
00110000    00000001
00110000    00000000
00001000    00000001
00001000    00000000
00001000    00000001
00001000    00000000
00001000    00000001
00001000    00000000
00110000    00000001
00110000    00000000
00110000    00000001
00110000    00000000
00110000    00000001
00110000    00000000
00001000    00000001
00001000    00000000
00001000    00000001
00001000    00000000
00001000    00000001
00001000    00000000
00110000    00000001
00110000    00000000
00110000    00000001
00110000    00000000
00110000    00000001
00110000    00000000
00001000    00000001
00001000    00000000
00001000    00000001
00001000    00000000
00001000    00000001
00001000    00000000
00110000    00000001
00110000    00000000
00110000    00000001
00110000    00000000
00110000    00000001
00110000    00000000
00001000    00000001
00001000    00000000
00001000    00000001
00001000    00000000
00001000    00000001
00001000    00000000
00010000    00000001
00010000    00000000
00010000    00000001
00010000    00000000
00010000    00000001
00010000    00000000
01100000    00000001
01100000    00000000
01100000    00000001
01100000    00000000
01100000    00000001
01100000    00000000
01000000    00000001
01000000    00000000
01000000    00000001
01000000    00000000
01000000    00000001
01000000    00000000
01001000    00000001
01001000    00000000
01001000    00000001
01001000    00000000
01001000    00000001
01001000    00000000
01010000    00000001
01010000    00000000
01010000    00000001
01010000    00000000
01010000    00000001
01010000    00000000
00100000    00000001
00100000    00000000
00100000    00000001
00100000    00000000
00100000    00000001
00100000    00000000

The mode and the data bytes were being sent in reverse!  I flipped that around and added a bit of logic to display [address]: [message] and got this in version 3.


00010000: 00010000
00010000: 00010000
01100000: 01100000
01100000: 01100000
01100000: 01100000
01000000: 01000000
01000000: 01000000
01000000: 01000000
01001000: 01001000
01001000: 01001000
01001000: 01001000
01010000: 01010000
01010000: 01010000
01010000: 01010000
00100000: 00100000
00100000: 00100000
00100000: 00100000
00001000: 00001000
00001000: 00001000
00001000: 00001000
00110000: 00110000
00110000: 00110000
00110000: 00110000

Better, but still gibberish to a human.  A few #defines and a couple of switch statements later and I had version 4.


Changer: CHK
Changer: CHK
Changer: CHK
Bill validator: CHK
Bill validator: CHK
Bill validator: CHK
Cashless Device #1: CHK
Cashless Device #1: CHK
Cashless Device #1: CHK
cashless device 2: CHK
cashless device 2: CHK
cashless device 2: CHK
universal satellite device 1: CHK
universal satellite device 1: CHK
universal satellite device 1: CHK
universal satellite device 2: CHK
universal satellite device 2: CHK
universal satellite device 2: CHK
universal satellite device 3: CHK
universal satellite device 3: CHK
universal satellite device 3: CHK
Display: CHK
Display: CHK
Display: CHK

Odd.. there's no commands.  Oh, they're smashed into the address?  That's wierd.  Well... version 5.


Changer: Self-reset
Changer: Self-reset
Changer: Self-reset
Bill validator: Self-reset
Bill validator: Self-reset
Bill validator: Self-reset
Cashless Device #1: Self-reset
Cashless Device #1: Self-reset
Cashless Device #1: Self-reset
Cashless device 2: Self-reset
Cashless device 2: Self-reset
Cashless device 2: Self-reset
Universal satellite device 1: Self-reset
Universal satellite device 1: Self-reset
Universal satellite device 1: Self-reset
Universal satellite device 2: Self-reset
Universal satellite device 2: Self-reset
Universal satellite device 2: Self-reset
Universal satellite device 3: Self-reset
Universal satellite device 3: Self-reset
Universal satellite device 3: Self-reset
Display: Self-reset
Display: Self-reset
Display: Self-reset

...and that's as far as I'm gonna get tonight.  While I have this device plugged in the VM is insisting that it is out of service.
My theory is that the VMS thinks my silent peripheral is dead broke.  Have you seen this?



James Hayward

unread,
Apr 18, 2014, 7:33:08 AM4/18/14
to notti...@googlegroups.com
Version 4 looks correct - it expects the peripheral to respond before it'll go any further.  The peripheral will ACK the poll, then the VMC will ask it about it's capabilities (if I remember correctly).

Have you got the MDB spec to work from?

Dan Royer

unread,
Apr 18, 2014, 10:06:46 AM4/18/14
to notti...@googlegroups.com
V4.2
To post to this group, send email to notti...@googlegroups.com.

Daniel S

unread,
Apr 18, 2014, 11:17:48 AM4/18/14
to notti...@googlegroups.com
I can't remember what our vending machine does if it can't find any MDB devices - but it doesn't sound at all surprising that you'd get an out of service message (if it can't find any payment device, there's not much it can do?).
As far as the VM is concerned, a silent device should be indistinguishable from no device.

Daniel

Dan Royer

unread,
Apr 18, 2014, 11:39:32 AM4/18/14
to notti...@googlegroups.com
Maybe I have my wires crossed and when I plugged in the board I also disconnected every other device in the daisy chain.


To post to this group, send email to notti...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dan Royer

unread,
Apr 18, 2014, 11:39:51 AM4/18/14
to notti...@googlegroups.com
Woo!  Got on hackaday.  Gave you guys mad props in the article and in the github repo.

eliot.p...@gmail.com

unread,
Apr 18, 2014, 1:44:39 PM4/18/14
to notti...@googlegroups.com
Can someone share some more info on the component choices used in the adapter board. One of the other MDB projects I read up on just uses 2 identical optocouplers http://blog.bouni.de/blog/2012/07/09/the-mdb-protocol-part-2/

So I'm wondering about the optocouplers you selected and the attached logic.

Thanks!

Daniel S

unread,
Apr 18, 2014, 2:43:39 PM4/18/14
to notti...@googlegroups.com
The choice of optocouplers was a combination of what we had and what worked - I don't think there's any particular reason why they're different.
The inverting schmitt trigger on the TX line was necessary to invert the TTL serial signal from the Arduino / to avoid breaking the bus. The two on the RX line only serve to clean up the incoming the signal, and probably aren't necessary (never tried without once we got it all working). As there 6 inverting schmitt triggers on the chip, it didn't require any extra parts anyway,

Daniel


--
You received this message because you are subscribed to the Google Groups "Nottingham Hackspace - Nottinghack" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nottinghack...@googlegroups.com.

Dan Royer

unread,
Apr 18, 2014, 7:31:53 PM4/18/14
to notti...@googlegroups.com
So this is odd.... if I

  UCSR0B |= (1<<RXEN0);  // Enable RX
  UCSR0B |= (1<<TXEN0);  // Enable TX

from the arduino to MDB the machine goes into "out of service" mode.
if I only turn on the receive

  UCSR0B |= (1<<RXEN0);  // Enable RX

then everything is fine.  Amy i missing a resistor or something?  I suspect I'm accidentally talking back to the MDB and not realizing it.  I tried commenting out all transmit code.  the only difference seems to be when I enable this bit.

Ideas?

Dan


 


--
You received this message because you are subscribed to a topic in the Google Groups "Nottingham Hackspace - Nottinghack" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/nottinghack/IWPDt1gMi5M/unsubscribe.
To unsubscribe from this group and all its topics, send an email to nottinghack...@googlegroups.com.

To post to this group, send email to notti...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Daniel S

unread,
Apr 18, 2014, 8:32:29 PM4/18/14
to notti...@googlegroups.com
I'm not sure - how exactly have you connected it? In particular, how is the Arduino TX connected to the master receive? i'd guess that if the Arduino serial out was connected directly to the optocoupluer - without being inverted - it'd cause this problem,

Daniel

Dan Royer

unread,
Apr 18, 2014, 9:35:24 PM4/18/14
to notti...@googlegroups.com
That sounds like a likely culprit.  Ill try to invert it.

Dan

Andrew Livick

unread,
Sep 16, 2014, 3:18:15 PM9/16/14
to notti...@googlegroups.com
Hello Nottingham Hackspace,

I cam across  this google group thread as I am trying to develop a MDB cashless device. I was a little overwhelmed by the information that I found on your wiki (https://wiki.nottinghack.org.uk/wiki/Vending_Machine/Cashless_Device), so I was hoping someone might be able to help me in the right direction for my next step. I am using a Raspberry Pi that has an ATMEGA32U4 break out board connected to it (https://www.sparkfun.com/products/11117), which is capable of 9 bit USART which I believe is needed for MDB communication. I am able to get an example code working to toggle one of the GPIO pins high/low on the breakout board. I am now unsure what steps to continue down to work on the actual MDB protocol code development. For now I am really just trying to get some kind of program running on the ATMEGA to talk the MDB protocol.

Any guidance would be appreciated.

Thanks,
Andrew 

Daniel S

unread,
Sep 17, 2014, 12:22:19 PM9/17/14
to notti...@googlegroups.com
Hi Andrew,

More details of our actual cashless device are here:
https://wiki.nottinghack.org.uk/wiki/Vending_Machine/Cashless_Device_Implementation

And the code it runs is here:
https://github.com/NottingHack/Vend

I guess it would be USB connection to breakout board, then hardware serial on to the vending machine?

Daniel

Andrew Livick

unread,
Sep 17, 2014, 12:38:02 PM9/17/14
to notti...@googlegroups.com
Daniel,
Thanks for the response. I am actually going from the Raspberry Pi GPIO/SPI lines to the ATMEGA breakout board's SPI pins and from there it will be hardware serial to the vending machine (via the breakout board GPIO pins). I going to be using the Raspberry PI for some other functionality, so right now I am just concerned with trying to implement the MDB protocol on the ATMEGA32U4 microcontroller. This is where I am stuck, where I think I need to implement the peripheral MDB state machine somehow.

I had looked at the wiki before, but wasn't able to follow it as much because I thought there was an extra piece of hardware in between i thought, the Nanode? I believe there are 6 pins in the MDB connections:
1 - 34 VDC
2 - DC Power Return (Ground?)
3 - Not Connected
4 - Master Receive
5 - Master Terminal
6 - Communications Common

So I am guessing I need to Master Terminal to send out the serial commands to the VMC and Master Receive to receive commands from the VMC? I am not sure what the Communications Common is, and I am not sure exactly how I send/receive the serial commands for the protocol. Like if I want to send out the "Poll" which has a code of "12H" (0x12??), how is that accomplished?

Any insight is appreciated. I am little all over the place with all the information.

Thanks,
Andrew

Daniel S

unread,
Sep 17, 2014, 1:50:56 PM9/17/14
to notti...@googlegroups.com
For our vending machine / cashless device, the connection is basically:
Server -(Ethernet)-> Nanode -> Level converter / PSU -> Vending machine

The level converter is this:
https://wiki.nottinghack.org.uk/images/a/a2/VMC-Nanode_Schematic.png
This board essentially implements the interface in section 4.4 of the MDB 3.0 spec, as well as including a 34v->5v PSU (if your AVR is drawing its power from the RPI, I guess you won't need the PSU part).

The master transmit needs to go to the RX on the AVR, and the master receive to the TX pin - the schematic in section 4.4 should really help here - just build that.

To send a POLL (or any command), you set the TXB80 bit in UCSR0B appropriately depending on if the 9th bit ("mode bit") should be set or not, then write your byte to be sent to the UDR0 register. The relevant section of the spec here is 2.1, and the serial TX in our code is:

https://github.com/NottingHack/Vend/blob/master/Vend.ino#L284
(this is for Arduno, but the hardware serial isn't accessed using Arduino libraries).

Daniel

Andrew Livick

unread,
Oct 1, 2014, 4:51:21 PM10/1/14
to notti...@googlegroups.com
Daniel,
Thank you for your response. It was helpful. I have just now been able to get back to looking into this project. I went through the Vend.ino code and I see TXB80, UCSR0B, and UDR0 being used but I am not quite sure where they are defined? I am assuming that UCSR0B and UDR0 are registers within the AVR libraries somewhere? 

I was trying to figure out which defines/libraries that are included in your Vend.ino that wouldn't be needed in order to just send/receive MDB commands, as I wouldn't need to communicate with any other components (at this point). I am guessing I can just implement the MDB protocol on the AVR (assuming it has outside power). Is that a false assumption? I don't need to create some fully functioning independent at this point. Just looking to send/receive some test MDB commands from the AVR.

Thanks,
Andrew

Daniel S

unread,
Oct 4, 2014, 3:34:37 AM10/4/14
to notti...@googlegroups.com
Hi Andrew,


Thank you for your response. It was helpful. I have just now been able to get back to looking into this project. I went through the Vend.ino code and I see TXB80, UCSR0B, and UDR0 being used but I am not quite sure where they are defined? I am assuming that UCSR0B and UDR0 are registers within the AVR libraries somewhere? 
 
Pretty much - yes. UCSR0B and UDR0 are the registers, TXB80 is the specific bit in the UCSR0B register used to specify if the 9th bit in the transmitted serial frame should be set or not. The atmega328 datasheet will have more details on these (although, as you're not using a 328, I guess they could be named differently?) Regardless of which atmega, I think these are defined in "<avr/io.h>" (if at all).
 

I was trying to figure out which defines/libraries that are included in your Vend.ino that wouldn't be needed in order to just send/receive MDB commands, as I wouldn't need to communicate with any other components (at this point). I am guessing I can just implement the MDB protocol on the AVR (assuming it has outside power). Is that a false assumption? I don't need to create some fully functioning independent at this point. Just looking to send/receive some test MDB commands from the AVR.

I'd say most, if not all, of the libraries included would be unnecessary just to get a basic MDB implementation working. They're there for the network shield, rfid reader (softserial) and LCD display.
All MDB requires is 9bit serial, and that doesn't need any special libraries (and hardware-wise, two opto-isolators + something to invert the output from the AVR tx pin before the tx opto-isolator).
And I don't see any reason why you wouldn't be able to fully implement MDB on the avr.

Andrew Livick

unread,
Oct 6, 2014, 4:19:19 PM10/6/14
to notti...@googlegroups.com
Daniel,

Thank you again for all the info. It has been very helpful. I was looking over your diagram and reading back over some over you comments, particularly:

"The master transmit needs to go to the RX on the AVR, and the master receive to the TX pin - the schematic in section 4.4 should really help here - just build that."

So where would the Communications Common line connect to the AVR? I am not even really sure what that line/pin is for? The MDB spec doesn't seem to really mention it. 

Thanks,
Andrew

jfowkes

unread,
Oct 6, 2014, 6:00:03 PM10/6/14
to notti...@googlegroups.com
It's the ground from the master.

Communications to/from the master are opto-isolated by the 6N137 and the 4N25. So the master GND needs to come though to those ICs.

I think. I actually know very little about the vending machine. That's just what it looks like from the schematic.

Andrew Livick

unread,
Oct 6, 2014, 6:59:48 PM10/6/14
to notti...@googlegroups.com
I thought it might be but there are 6 connectors, but only 5 wires.

1 - 34 VDC
2 - DC Power Return (Ground?)
3 - Not Connected
4 - Master Receive
5 - Master Terminal
6 - Communications Common

When I did a measurement from the vending machine I think both DC Power Return and Communications Common came back as 0, but thought one (maybe Comms Common) might be something else.

jfowkes

unread,
Oct 7, 2014, 4:31:56 AM10/7/14
to notti...@googlegroups.com
I shouldn't have said GND from the master. It's the communications ground/return from the master. There might be any number of reasons why the master has a different set of voltage levels from the other devices. It's just meant to avoid problems around that. Probably also to separate power and communication circuits, which is generally a good thing.

I imagine in your setup 0V and communications common will just be connected at the master end.

Probably wait for Daniel to confirm what I've been saying or correct me before attaching wires to things though.

Daniel S

unread,
Oct 7, 2014, 1:40:47 PM10/7/14
to notti...@googlegroups.com
I agree with jfowkes. The master receive/transmit and communications common should be connected to the opto-isolators, and nothing else directly.

Also, if your AVR is going to be powered from the Pi, you can ignore the DC Power Return and 34VDC lines altogether

Daniel

James Hayward

unread,
Apr 16, 2014, 2:37:00 PM4/16/14
to notti...@googlegroups.com
Hi Dan

The serial on the MDB spec is horrible!  It is 9 bit, so not supported by either softwareSerial or even the Arduino hardware library.  It is probably not your wiring that is causing you issues!  (although you need to make sure you optically isolate the device from the vending machine as it is relatively high voltage)

The AVR chip itself natively supports it 9bit serial, so we ypassed the Arduino libraries and used that.

All our code is on github:

The firmware is here:  https://github.com/NottingHack/Vend

If you have any other questions, feel free to post back, and we'd love to see pictures!

James
On 16 April 2014 18:42, Dan Royer <d...@marginallyclever.com> wrote:
So of course it's two seconds after I ask that I spot the overlooked http://wiki.nottinghack.org.uk/images/a/a2/VMC-Nanode_Schematic.png link. :P



On Wednesday, April 16, 2014 10:37:26 AM UTC-7, Dan Royer wrote:
Hi Nottinghack!

I have just upgraded the vending machine at the Vancouver Hackspace.  The new model supports MDB and I'd like to monkey with that.  Someone sent me a video of your RFID hack and so here I am.

I read the pages on your wiki including the implementation details.  I'm looking to build a similar device to connect to a Raspberry Pi running inside the vending machine.

I read the MDB 4.2 doc and followed their instructions (p54) to build a two-way serial interface.  I set up an Arduino running SoftwareSerial to listen for bits coming from MDB and so far I'm getting nothing.
I could Dark Souls my way through this, but I'm lazy and you've already solved this riddle.

I don't have a nanode yet, but I can fumble my way through building most anything.  Would you be willing to share a wiring schematic of your device?


--
You received this message because you are subscribed to the Google Groups "Nottingham Hackspace - Nottinghack" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nottinghack...@googlegroups.com.

Daniel Chan

unread,
Aug 19, 2015, 3:38:45 PM8/19/15
to Nottingham Hackspace - Nottinghack
Thank you for all the information you've put online! I was wondering if you have the Gerber file (or anything equivalent - something I can give to a PCB manufacturer) for this schematic as I need to source the PCB, but I don't have the direct knowledge to make it myself.  Thanks so much!  (as a related note - what is the "C?" on this board? I'm going to University for Engineering next year so I'm sure I'll learn about it soon, but right now I'm just curious)  Thank you so much!

James Hayward

unread,
Aug 19, 2015, 3:40:20 PM8/19/15
to notti...@googlegroups.com
Hi Daniel

C means capacitor - looks like we weren't sure what values to have there at that point.

I don't think we ever had a OCB of this, but I'll be corrected if I'm wrong - I think it was made up on veroboard

J

--
You received this message because you are subscribed to the Google Groups "Nottingham Hackspace - Nottinghack" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nottinghack...@googlegroups.com.
To post to this group, send email to notti...@googlegroups.com.

Dan Royer

unread,
Aug 19, 2015, 4:28:48 PM8/19/15
to notti...@googlegroups.com
I've seen an MDB to RS232 converter on Aliexprses for $50ea.  Haven't tried them yet.  I have a breadboarded circuit that works.

Where I'm stuck is that I'm using an Arduino UNO and the serial doesn't seem to deliver all the data.   What board should I use if I want
(a) serial to the MDB vending machine
(b) serial to the DEX audit records
and
(c) an interface to the web

I'm a coder by trade and familiar with Arduino.


--
You received this message because you are subscribed to a topic in the Google Groups "Nottingham Hackspace - Nottinghack" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/nottinghack/IWPDt1gMi5M/unsubscribe.
To unsubscribe from this group and all its topics, send an email to nottinghack...@googlegroups.com.

To post to this group, send email to notti...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Daniel Chan

unread,
Aug 19, 2015, 5:17:03 PM8/19/15
to Nottingham Hackspace - Nottinghack
In order to build your circuit, what capacitor values did you use for the Capacitors with value = ? 

I saw that MDB to RS232 converter, but the description made me think it would only interface peripherals to the PC (using the PC to emulate the main board), and I want to do the opposite (pretend to be a peripheral to the MDB)- based on your understanding do you think it could be used to communicate to the MDB board?

If I get this circuit built, I'm planning on trying this tutorial, and I can update you if I find the answers to any of your questions.   I'd consider using a Raspberry Pi in conjunction with the Arduino - it ups the total processing power you have to work with considerably, and you can use the Arduino as a slave to the pi pretty easily.

-Daniel

Dan Royer

unread,
Aug 19, 2015, 6:21:46 PM8/19/15
to notti...@googlegroups.com
I wrote that tutorial.  The two arduino method works and it's a giant pain to update your code.  I see no reason why the MDB to  RS232 to Arduino wouldn't work, but I haven't tried it yet.

I'm hoping Nottinghack can propose a hardware solution that's easy for all of us.  I have yet to get a vending machine to believe my arduino is a cashless device and put credit on the screen.

Daniel S

unread,
Aug 19, 2015, 6:27:36 PM8/19/15
to notti...@googlegroups.com
Firstly, James is correct - we never built or designed a PCB for this, it's all still just on protoboard:
https://www.flickr.com/photos/nottinghack/16602331015/in/photostream/

The exact values of the two capacitors aren't too critical, I think we've used a 100uF (>60v) capacitor between 0v and pin1 of the lm2576t, and a 1000uF for the one between 0v and pin 4.
(I've been meaning to redraw that diagram for a while...)

BTW, if I were rebuilding it today, I'd probably replace half of the circuit with something like:
http://www.ebay.co.uk/itm/131561284630
It'd be cheaper than buying the lm2576t + required inductors/capacitors separately, and easier too. It'd replace the red section in this diagram:

​All that part of the circuit does is power the Arduino; if you're planning to power the Arduino from a Pi (or PC, whatever), then that part of the circuit is not required at all (the circuit will get its power from the Arduino, rather than powering it).


> Where I'm stuck is that I'm using an Arduino UNO and the serial doesn't
> seem to deliver all the data.   What board should I use if I want
> (a) serial to the MDB vending machine
> (b) serial to the DEX audit records
> and
> (c) an interface to the web

I've got no idea what b) is, but for a), we're using a Nanonde, which is basically just an Uno with a built in ENC28J60 based ethernet shield (exactly the same microcontroller, even the same bootloader as an Uno).
For c), well, our (very basic) web interface is hosted on a regular Linux server, and talks to the Nanode over Ethernet / UDP/IP.

Daniel

Daniel S

unread,
Aug 19, 2015, 6:52:44 PM8/19/15
to notti...@googlegroups.com
I'm assuming you can get suitable MDB<>rs232 converter boards, however it will need to be designed to function as a peripheral - I'm pretty sure one designed to connect a coin mech / note acceptor to a PC isn't going to work.

I don't know if I'm misunderstanding or not, but for "MDB to  RS232 to Arduino", that's probably making life more difficult? Wouldn't either MDB->RS232->Pi (no Arduino in the mix), or MDB->Opto-isoloators->Arduino be easier?


> I'm hoping Nottinghack can propose a hardware solution that's easy for
> all of us.  I have yet to get a vending machine to believe my arduino
> is a cashless device and put credit on the screen.
I can only tell you what's worked for us on our single vending machine. None of us (that worked on it, at least) have any background in vending machines, etc., we only know what we've learnt from google and playing with our vending machine.

Daniel

James Hayward

unread,
Aug 19, 2015, 6:56:38 PM8/19/15
to notti...@googlegroups.com
Unless I've misunderstood, Dan from Vancouver can't get his arduino to talk to the vending machine over serial like ours does.

J

Dan Royer

unread,
Aug 19, 2015, 7:32:40 PM8/19/15
to notti...@googlegroups.com
I can get an Arduino to talk over hardware serial to a vending machine.
If the hardware serial is busy talking to the vending machine it cannot also talk to my PC.  That makes debugging really really hard.

My solution was to put MDB > hardware serial via protoboard > Arduino 1 > software serial >Arduino 2 > hardware serial via usb > PC

Which works... but you can only update the code on the Arduino near the PC.  to update the Arduino near MDB you have to disconnect it from the vending machine, upload, reconnect, rinse repeat.  This is painfully slow.

How did you guys do it?  Did I miss something really obvious?

VanDan

Daniel S

unread,
Aug 20, 2015, 1:48:43 AM8/20/15
to notti...@googlegroups.com
No, we have the same issue - we can't upload new firmware to the Arduino when it's still connected to the vending machine.
I think very early on (when it was all still on breadboard) we had a few LEDs attached to the Arduino, which lit up at key times to indicate state, which helped with debugging. Later on we had it reporting debug messages via Ethernet.

As you've already solved the debug message problem with a second Arduino, could you just stick a DPST switch between the vending machine and the hardware serial line of the first Arduino? Switch off to allow firmware upload, switch on to talk to the vending machine (and power it all from the PC, not the vending machine for now)

Daniel

Dan Royer

unread,
Aug 20, 2015, 2:05:21 AM8/20/15
to notti...@googlegroups.com
Hrm.  Interesting.  Yeah... I may have to do just that.  I tried passing data from A1 to A2 and doing all the heavy lifting on A2, IIRC the transmit delay was failing the response timeout.

Soroush Motahari

unread,
Nov 27, 2015, 4:37:01 PM11/27/15
to Nottingham Hackspace - Nottinghack
Hi Nottinghack,

I've been working on implementing a cashless device on our vending machine here at Hacker Dojo in Mountain View, CA. Yours and Dan's work at Vancouver Hackerspace has been tremendous help so thank you all very much! I'm using an Arduino Uno and a Raspberry Pi for my project. I've successfully been able to communicate with the vending machine, but I've hit a road block.

So everything works well through the setup process. But after the setup, when I move on to the disabled state, the vending machine never sends me the "Reader Enable" command. It just keeps sending me Poll commands. Did you guys have a similar problem or have any idea why this might be happening? I've attached a screenshot of the command/response cycle between the cashless device and the VMC.
Screen Shot 2015-11-27 at 1.29.29 PM.png

James Hayward

unread,
Nov 27, 2015, 4:47:37 PM11/27/15
to notti...@googlegroups.com
Hi Soroush

It may just be your screenshot, but you don't seem to be sending any data with the READER CONFIG DATA reply - are you?

If so, what data are you sending?

J

Soroush Motahari

unread,
Nov 27, 2015, 5:09:47 PM11/27/15
to Nottingham Hackspace - Nottinghack
Here's the config data I'm sending (I didn't print it out in the log):

0x01 Code for reader config data
0x01 Feature level 1
0x18 Country/Currency code for US dollar (High)
0x40 Country/Currency code for US dollar (Low)
0x05 Scaling factor
0x02 Decimal places
0x05 Max response time
0x00 Miscellaneous options

I've tried using feature level 2 and 3. I also tried country code 00 01 for the US, all with the same result.

Dan Royer

unread,
Nov 27, 2015, 6:55:18 PM11/27/15
to notti...@googlegroups.com
I've got past this point, but not much. I get a level 2? Request for the peripheral manufacturer code and version. I don't know what to tell the vmc.  so far I have failed to find a convincing lie.
You received this message because you are subscribed to a topic in the Google Groups "Nottingham Hackspace - Nottinghack" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/nottinghack/IWPDt1gMi5M/unsubscribe.
To unsubscribe from this group and all its topics, send an email to nottinghack...@googlegroups.com.

Soroush Motahari

unread,
Dec 4, 2015, 2:26:10 PM12/4/15
to Nottingham Hackspace - Nottinghack
I found I had a tiny bug in my checksum function so I wasn't getting the expansion command to complete the setup process. It's now letting me enable. 

For the peripheral id data I sent back the same data that the vending machine sent me for its own manufacturer code and version and it accepted it! Maybe it'll work for you too.

Clint Tepe

unread,
Jan 19, 2016, 4:58:00 PM1/19/16
to Nottingham Hackspace - Nottinghack
Hi Dan, I really appreciate you sharing your MarginallyClever MDB-Sniffer code on GitHub. My experience with vending machines is somewhat lacking, but I am interested in simply reading data from an MDB device using an Arduino. I presume your code still works for MDB v4.2? Is the dual Arduino setup with an optocoupler circuit to connect one to the MDB serial cable still the best way to go? I saw the bit about using a DC-DC adapter to simplify the circuit. At this point I just want to receive data, no need to send anything back to it.

Clint Tepe

unread,
Jan 19, 2016, 4:58:21 PM1/19/16
to Nottingham Hackspace - Nottinghack
Just curious if there have been any updates to this circuit other than the DC-DC converter suggestion? Would there happen to an EagleCAD / Fritzing etc file for this circuit?

Thanks!

Dan Royer

unread,
Jan 19, 2016, 5:18:15 PM1/19/16
to notti...@googlegroups.com
I have made update to the circuit but I'm not ready to publish them yet.
I would like to release a PCB for purchase some time this year.

Currently I'm stuck with my MDB code.  The vending machine validates my arduino as a cashless device and then sends a request for the manufacture code and serial number.  I've tried many different codes and SNs, all of which are (apparently) bad, because the VMC then sends a reset command and starts the authentication process over again.  Anyone know what that's about?

Dan

James Hayward

unread,
Jan 20, 2016, 3:46:15 AM1/20/16
to notti...@googlegroups.com
Hi Dan

The Manufacturer code is three uppercase letters, and the serial number needs to be 12 numbers.  For ours we used "NHL" and "000000000001".

I assume you are going to release the circuit open source as well?  No issue with you selling PCBs, but anything based on our designs would also have to be open source.

Thanks

James

Dan Royer

unread,
Jan 20, 2016, 3:32:16 PM1/20/16
to notti...@googlegroups.com
Ach, you're right. Guess I won't be making a PCB.  Not worth the effort if everyone's going to download and make it themselves :(

Dan Royer

unread,
Jan 20, 2016, 6:48:43 PM1/20/16
to notti...@googlegroups.com
James, where in the Vend.ino code is the NHL manufacturer code?  https://github.com/NottingHack/Vend/blob/master/Vend.ino#L865 doesn't appear handle the case.  Am I looking at the wrong branch?

James Hayward

unread,
Jan 21, 2016, 2:44:30 AM1/21/16
to notti...@googlegroups.com

It's in the header file - same repository

Dan Royer

unread,
Jan 21, 2016, 4:48:21 AM1/21/16
to notti...@googlegroups.com
Right.... I wanted to compare your solution (correct) with what I'm doing (wrong).  the MANUFACTURER_CODE, SERIAL_NUMBER, and MODEL_NUMBER are never used in Vend.ino.  What am I missing?

James Hayward

unread,
Jan 21, 2016, 6:43:44 AM1/21/16
to notti...@googlegroups.com
Nothing I think.  It seems we never get asked by our machine for that data.

What command are you receiving from the VMC?

J

Dan Royer

unread,
Jan 21, 2016, 2:45:55 PM1/21/16
to notti...@googlegroups.com
RESET
POLL
> Sending POLL Ack
SETUP CONFIG
Feature level=2
Columns      =20
Rows         =2
Display Flags=00000001
> Sending Config Reply
SETUP MIN/MAX
Max=50.00 Min=1.00 Ack
Setup Complete
Enter Disabled mode

EXPANSION REQUEST ID
* boom *

if I ignore the expansion request id then I get a new RESET every 2 seconds.
Is this similar to what you see?

James Hayward

unread,
Jan 21, 2016, 3:01:27 PM1/21/16
to notti...@googlegroups.com

Our VMC is feature level 1, I don't think we ever see an expansion request

Let me check

Dan Royer

unread,
Jan 21, 2016, 4:56:40 PM1/21/16
to notti...@googlegroups.com
It seems my problem was sending the serial, model number, and version numbers as numbers it didn't like that.  eg, 000001 was bad, but "000001" was OK.

I've finally got it through the entire setup process and happily ACKing now.
Next step is to get credit appearing on the LCD.

James Hayward

unread,
Jan 21, 2016, 5:00:27 PM1/21/16
to notti...@googlegroups.com
yay!

Are you telling the VMC that you are a level 1 card device, or higher?

J

Dan Royer

unread,
Jan 21, 2016, 7:33:10 PM1/21/16
to notti...@googlegroups.com
Victory!  Now to get it online. :)

Muhammad Ali

unread,
Aug 30, 2016, 3:40:05 AM8/30/16
to Nottingham Hackspace - Nottinghack
@Dan royer,

can you please share your project details ? also what you have used instead of Nanode for the connectivity to the server. Also can you please help me integrating Cashless NFC reader to the VMC Via Arduino as I am also trying to do the same project.

gfr20...@gmail.com

unread,
Mar 26, 2018, 12:23:29 PM3/26/18
to Nottingham Hackspace - Nottinghack
check this link https://github.com/perdidor/Arduino-MDB-UART

вторник, 30 августа 2016 г., 10:40:05 UTC+3 пользователь Muhammad Ali написал:

Cleophas Barwareng

unread,
Apr 17, 2018, 3:57:28 AM4/17/18
to Nottingham Hackspace - Nottinghack
Hi Soroush, I tried sending back the Peripheral ID I that I received from the machine but nothing happened. It just kept on looping at the Request ID. Do you think you can share your code where you implement your Expansion (0x17) Command?

Francis Teo

unread,
May 4, 2018, 9:04:13 AM5/4/18
to Nottingham Hackspace - Nottinghack

Hi Guys,

I am new to this VMC stuff but not new to arduino.
I have got a quick question - is it possible to bypass the keypad?
That is if i wanted to simulate a keypad selection - is there a way to send the codes directly?

Appreciate any response.

Many thanks
Francis

Matt Lloyd

unread,
May 4, 2018, 9:42:40 AM5/4/18
to notti...@googlegroups.com
Keypads are not on the MDB bus 
So it will be down to each individual machine how they work. 
you would have to reverse engineer the keypad for your machine. 

Matt

Francis Teo

unread,
May 4, 2018, 10:47:35 AM5/4/18
to notti...@googlegroups.com
Hi Matt,

Wow - really impress by your fast response.
Thank you. So I supposed it is very proprietary? 
Quite a difficult task it seems.

Francis 

Matt Lloyd

unread,
May 4, 2018, 10:50:25 AM5/4/18
to NottingHack Google Groups
I suspect most keypads will be a simple matrix connection, the principles of which and possible Arduino starting projects are easily googled



Matt


Daniel Chan

unread,
May 8, 2018, 9:55:06 PM5/8/18
to notti...@googlegroups.com
Sorry for jumping on this party late - but as Matt said, it's not too hard to spoof the keypad! The one my machine used basically just connected two wires to press a button, so I did that with a couple relays that I could control directly from the arduino. 


Matt



To unsubscribe from this group and stop receiving emails from it, send an email to nottinghack+unsubscribe@googlegroups.com.

To post to this group, send email to notti...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Nottingham Hackspace - Nottinghack" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nottinghack+unsubscribe@googlegroups.com.

To post to this group, send email to notti...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Nottingham Hackspace - Nottinghack" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nottinghack+unsubscribe@googlegroups.com.

To post to this group, send email to notti...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "Nottingham Hackspace - Nottinghack" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/nottinghack/IWPDt1gMi5M/unsubscribe.
To unsubscribe from this group and all its topics, send an email to nottinghack+unsubscribe@googlegroups.com.

Tushar Borhade

unread,
Aug 3, 2018, 7:56:38 AM8/3/18
to Nottingham Hackspace - Nottinghack
The github link is not working!
Can someone provide me the source code?

social justice earthworm jim

unread,
Aug 3, 2018, 12:50:15 PM8/3/18
to Nottingham Hackspace - Nottinghack
Looks like it's been moved to the "Vend" folder in https://github.com/NottingHack/instrumentation-arduino

Matt Lloyd

unread,
Aug 3, 2018, 12:51:43 PM8/3/18
to NottingHack Google Groups
We are working on this again there is a new pcbs design

And new code will be coming soon (to instrumentation-arduion again)


Matt



--
You received this message because you are subscribed to the Google Groups "Nottingham Hackspace - Nottinghack" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nottinghack...@googlegroups.com.

Tushar Borhade

unread,
Aug 4, 2018, 1:12:50 AM8/4/18
to notti...@googlegroups.com
Thank you. Anyone tried sniffer?
I have tried it but having issue to read from CD! not getting correct data.
Also I have tried C code see here..https://github.com/Bouni/MateDealer/issues/7
I think the issue is in hardware need to use high impedance circuit!



Matt



To unsubscribe from this group and stop receiving emails from it, send an email to nottinghack+unsubscribe@googlegroups.com.

To post to this group, send email to notti...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Nottingham Hackspace - Nottinghack" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nottinghack+unsubscribe@googlegroups.com.

To post to this group, send email to notti...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Regard's
Tushar Borhade
M: +919664626098

Tushar Borhade

unread,
Aug 4, 2018, 2:01:23 AM8/4/18
to Nottingham Hackspace - Nottinghack
I checked them! Awesome! The SAM will work great!
I can see there are two circuit for RX.Waiting for details.
Message has been deleted

kondordv

unread,
Apr 28, 2024, 3:25:33 AMApr 28
to Nottingham Hackspace - Nottinghack
Hi guys,
   I'm new here, it seems to be interesting progress with vending machine. There is long time ago nobody updated, is it everything clarified? What's the last schematic to communicate arduino with MDB? I would like to participate actively here with some tests, but I need first to get the hardware communication with MDB.

  thanks,

Daniel

unread,
Apr 28, 2024, 4:46:59 AMApr 28
to Nottingham Hackspace - Nottinghack
Unless anything's changed recently (last few months), the current state is that we have two vending machines:

1. Original one purchased 2011: https://wiki.nottinghack.org.uk/wiki/Vending_Machine/Westomatic
This is using a cashless device (v1) based off a Nanode (essentially and Arduino uno with built in Ethernet), the firmware for it is here:
https://github.com/NottingHack/instrumentation-arduino/tree/main/Vend

2. "New" one purchased 2018: https://wiki.nottinghack.org.uk/wiki/Vending_Machine/BevMax45
This is using the new cashless device (v2) based off the SAMD21 in the email chain, the schematics for it (nh-vend v0.2.pdf) are here:
https://github.com/NottingHack/nv-vend-PCB (but note the 1 issue logged)

And firmware is here:
https://github.com/NottingHack/instrumentation-arduino/tree/main/Vend2

The cashless device for both v1 & v2 are detailed here:
https://wiki.nottinghack.org.uk/wiki/Vending_Machine/Cashless_Device_Implementation

I'm not aware of any hardware changes being made since 2018, and both vending machines are still in use and using those cashless devices.
I think the only thing really left to do is to is update the first machine to use the v2 cashless device (unless that's happened and I missed it), but as the current one still works, I guess there's no urgency

And because everyone loves stats, here are some:
https://hms.nottinghack.org.uk/statistics/snackspace-monthly - amongst other things, shows how many things are being purchased from each machine per month

Both are only counting sales made through the cashless device, not those made using cash

Daniel
Message has been deleted

kondordv

unread,
Apr 29, 2024, 1:24:59 PMApr 29
to Nottingham Hackspace - Nottinghack
Thanks a lot Daniel for the current status and yes, I'm one who love stats but I have a long way to reach that part.
First of all I want to see any communication between my NV9 Spectral bank note validator and my arduino Mega 2560. I see your code Vend is very large some part of it hard to understand by me, especially the 9 bit adapt. Also that code Vend.ino has some .h files to be included not present in the folder, how to get them?
Could you tell me please what to do first to get the serial communication between my arduino and NV9 Spectral and to monitor this communication on arduino terminal? Here it will be needed 2 serial using.

  thanks again,

Daniel S

unread,
Apr 30, 2024, 1:33:57 PMApr 30
to notti...@googlegroups.com
For the first one (Vend.ino), the includes should belong to other libraries also in that that repo, under:
https://github.com/NottingHack/instrumentation-arduino/tree/main/libraries
IIRC the repo is set up so that if you configure the root of the repo to be your arduino sketchbook folder, everything should build. I'm not sure what version it needs, though. 

I'm not sure about communicating with an mdb note validator, this project only ever worked as a cashless device for a vending machine.
If you're wanting to see communications between other devices, maybe this would help:
https://github.com/MarginallyClever/MDB-Sniffer

Daniel

On Mon, Apr 29, 2024 at 6:24 PM 'kondordv' via Nottingham Hackspace - Nottinghack <notti...@googlegroups.com> wrote:
Hi Daniel,

     thanks a lot for your answer, and yes I'm the one who like a lot stats, really lovely your stats, but it is a long way for me to have that.
     I had a look over Vend.ino file and it seems that some included files are not located, and not found in your folder, how to make available all included files? I am right now in the point of trying to communicate arduino Mega 2560 with my note validator NV9 Spectral. So after implementing hardware electronics to adapt MDB to TTL what arduino file to use to see first communication with NV9 spectral?

  thank you,

On Sunday, April 28, 2024 at 11:46:59 AM UTC+3 Daniel wrote:
Reply all
Reply to author
Forward
0 new messages