3

I am trying to communicate with a Vending machine using MDB Protocol with the help of Arduino Mega and I am partially successful in doing so.

The circuit that I am using is attached here

Breadboard Layout of Circuit

While the circuit diagram is shown below

Circuit Diagram

The Arduino Mega is communicating with laptop via Serial 1 and the vending machine communication is done via Serial 2 of Arduino Mega.
USART is being use for communication.

The strange issue that I am facing is, the communication with the vending machine starts sending data only when brown colored wires A and B are initially not connected(which are connecting Arduino TX to Vending Machine RX). Once I see the data coming from Vending Machine, I short wires A and B and Arduino Starts sending data to the vending machine too.
But if Wires A and B are connected on the start of a vending machine, the vending machine doesn't send any data to Arduino and hence no communication takes place. I want to make it work without manually connecting wire A and B every time.


I have tried replacing Optocoupler PC817C with

  • PC814
  • 4N35
  • 6N137 High Speed Optocoupler

I tried replacing Hex Inverter with

  • 74HC04AP

I tried putting a mechanical and then solid-state relay between wires A and B and tried connecting them via external input but nothing happens
I tired adding an optocoupler as a switch between wires A and B and tried controlling it via firmware.

I even tried replacing the hex inverter with hex buffer HCF4050BE and a NOT Gate but regardless of any combination of mentioned components the issue remains the same, it only works if Wires A and B are initially not connected and then shorted once data starts coming from the vending machine.

I am using MateDealer's code.
I want to automate this manual process and need a simple solution for that.

Nauman Shakir
  • 135
  • 1
  • 3
  • 15
  • 1
    https://stackoverflow.com/tour btw. nice question, only on a wrong site. you should ask this at https://electronics.stackexchange.com/ – Juraj Dec 12 '19 at 12:51
  • I am no expert in electronic, why do you go over two inverters? – Juraj Dec 18 '19 at 10:46
  • @juraj they are going over 3 inverters, as the optocoupler inverts as well. The other direction (MDB_RX - RX1) is inverted once. It's perhaps a kind of fake RS232toTTLSerial inverter. – datafiddler Dec 18 '19 at 16:29
  • @Juraj it simply doesn't work without two inverters. Maybe the inverters adds a favorable delay which makes the communication happen. – Nauman Shakir Dec 22 '19 at 06:55
  • @datafiddler the optocoupler that I am using is a non-inverting one. – Nauman Shakir Dec 22 '19 at 06:56
  • ask at https://electronics.stackexchange.com/ – Juraj Dec 22 '19 at 07:08
  • @Nauman Shakir: that depends on your wiring: When the inverter's signal 3Y is HIGH, you pull the J2.5 (MDB TX) LOW, if I understand that correct, and something else (?) pulls it HIGH somehow. – datafiddler Dec 22 '19 at 09:53

2 Answers2

1

Some time ago I had a communication trouble between a PIC18F452 and a vending Machine that uses MDB protocol.

In that time I found that the communication since PIC toward Machine is negative to communicacion since Machine to PIC. This is because the electronic into vending machine that receive data had a optoacoplade circuit that inverts signal.

I remember that I saw that when I read the MDB protocol documentation, the section when is the electronic diagram VMC.

I advice that check that section, this can explaine why when you conect the A and B wire job, because you are invert twice signal.

sagueso
  • 11
  • 1
0

Resolved

The issue was due to a missed state machine element. My Device is a LEVEL-1 MDB Device and the vending machine that I am using requires the slave devices(whether they are at LEVEL-1 or LEVEL-2) to even respond to LEVEL-2 SETUP poll which is not a standard case in MDB Specifications Document.

Why it was working when TX wire was de-attached?

My logic analyzer was displaying some random hex values when TX line was removed and that random stuff caused the device to work.
By responding to the extra setup configuration poll of my vending machine I was able to make it work smoothly.
Below is the picture showing the configuration data sent by VMC which was discarded by my device making it behave strangely.

enter image description here

Nauman Shakir
  • 135
  • 1
  • 3
  • 15