I'm new to serial communication. For a project I have to develop software for a vending machine. The vending machine basically consists of a host computer (a windows xp machine) and various peripherals. One of those peripherals is a coin acceptor. According to the documentation of the vending machine, the host computer communicates with the coin acceptor using the serial port. The only documentation I have is this document called "Multi-Drop Bus / Internal Communication Protocol" (the version I have can be found here: http://www.coin-acceptor.com.cn/Upload/EditorFiles/technicalfile/Mdb_version_4-2.pdf).
According to the docs it seems I have to create a serial port connection using a baud rate of 9600, 1 start bit, 1 stop bit, 1 mode bit and 8 data bits (page 29 in the linked document). The vending machine docs state that the coin acceptor is on COM port 6. I tried to create a connection like this using HyperTerminal and Putty. My first question is:
How do I properly create a connection to a device that supports this MDB 'protocol'? Putty and HyperTerminal don't allow me to set a "mode bit". I didn't find anything about the flow control and parity bit in the document. Can this be done using Putty or HyperTerminal? Or do I need some other tool to communicate over MDB?
My second question is about how to send a command to the device. I looked through the commands and saw a RESET command. According to the document, upon receiving the RESET command the device should reset itself and respond with an ACK. According to pages 33 and 63 of the document, if I want to send the RESET command to the coin acceptor, I can send the HEX value 08H over the serial line. Page 33 states that the coin changer listens to commands sent to addresses 08H until 10H (if I'm interpreting the document correctly, that is). Page 63 states that the RESET command is 08H with no data bytes. So can I just type "08H" into Putty and hit "enter" to send this command to the device? Or how can I send this command to the device over the serial line? Is this even the right approach or am I looking in the completely wrong place? The vending machine docs only contain this document for the coin acceptor. Thank you for the help!
Kind regards
Chris
Related
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
While the circuit diagram is shown below
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.
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.
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.
I am controlling a device over serial connection using LabVIEW (version 7.0). It is connected using USB, and is installed as a virtual serial port on the computer (running Windows XP). Every now and then my device crashes when my program sends a command, and it is unable to accept any more input (the device itself also stops working) until it has timed out.
I've looked at the serial port traffic using Portmon. Whenever the device crashes the serial driver sends the command I send using my program four times instead of just once, with an IOCTL_SERIAL_GET_COMMSTATUS command in between. I cannot see what this last command returns, but I assume something happens in the communication earlier on. I'm thinking my configuration of the port is not entirely right, but I have no idea how or why. I open and close the connection to my device every time I want to write something to it.
For completeness' sake: it has a baud rate of 9600, 8 bits, no parity, 1 stop bit, and no flow control. I'm aware that the correct settings of these parameters depend on the device, but the manufacturer has not supplied any recommended settings.
The driver is a DLL of some sort? If so, this is the most likely source of your problem, and you likely will need to contact the author of the driver. LabVIEW does have crashing bugs, but by far the most common source of crashes in simple communications apps is a buggy third-party DLL.
In other words, I doubt this is a LabVIEW problem at all and that you would have the same difficulty if you wrote a C program to talk to this driver. I only know what you've posted here about your system, but after many years of chasing down such issues, I would start with the device manufacturer/driver author.
If you have evidence to the contrary, please share.
I have a Microsoft Surface Book that I've dual booted Linux Mint on. I'm writing a program that needs to read in data from a serial port, but my serial ports don't seem to be working. The behavior is consistent across Mint and Windows (Testing done through Cygwin). It gets a bit of data the first 2-5 seconds that the device is plugged in (viewing the data through screen, same thing happens if I just use pyserial to print data incoming from serial port), then nothing.
What could be happening? I think I've isolated the problem to the serial ports - the Surface Book has 2 USB ports and the same thing happens on both of them, and I've tested the hardware that I'm plugging into it on 2 other computers (One Linux and one Mac OS), and it works fine on both of those.
Your MS Surface, seemingly, has a yellow triangle exclamation mark icon (over the adapter icon) without any driver to install/download. And properties in the device status box window say This device cannot start. (Code 10) or A device which does not exist was specified. Right?
If it's so you should wait for an update from MS. It's notorious problem.
I ended up getting the computer replaced on warranty for an unrelated issue months later, and what do you know, on the new computer the serial ports work fine. That indicates to me some sort of hardware problem, given that the issue persisted across OS's.
maybe this will help:
see Arduino examples for serial port communication - search google:
arduino serial c++
arduino serial c#
arduino serial c++ linux
the point is to open port properly you need to open a file, not a port. not with usual c - assembly write to port code.
another option you are using an unintentionally bought fake USB to serial cable with a Fake PL2303 chip
then you need to install the old version of the driver.
search in google:
Fake PL2303 + your os name:
install driver Fake PL2303 windows 10
another option is maybe it conserves energy and closes the port because it feels it is unused.
in windows> device manager,> properties of a device - usually USB root hub > power management - allow the computer to turn off this device to save power - uncheck it.
https://superuser.com/questions/408683/why-my-usb-mouse-gets-suspended-after-3-seconds-of-inactivity
https://blogs.msdn.microsoft.com/usbcoreblog/2013/11/08/help-after-installing-windows-8-1-my-usb-device-doesnt-charge-or-it-disconnects-and-reconnects-frequently/
also, you could look in windows events - to see what happens. usually, failures like this are registered in the events log.
an unlikely option is it consumes too much current, like a short circuit. and the device protection circuit shuts the chip off. also probably it does not have such circuit. one possibility is to try with an external powered hub.
the most probable of these is the power saving mechanism
I was experiencing the same problem - came across the solution on another site. The USB 3 ports on Surface Book aren't compatible with something or other to do with Com Port but running the device through a cheap USB hub solved my problem straight away and it was instantly recognised by the Arduino IDE
So has anyone done this?
I'd like to store a hex file on an SD card and just blast it to any boards I have with the catarina bootloader on them when I connect to my uploader device.
This seems to be the correct protocol to talk to the catarina bootloader (the command definitions are at the end.) http://www.atmel.com/images/doc1644.pdf
If I manually force it into programming mode from COM4 by setting it to 1200 baud and closing the port, then opening COM5 and sending it one of the commands I do get a response as I would expect but even if I put it in programming mode by sending "P" it dropps back out after a second or two and doesn't stay in programming mode as I would expect.
It seems that the timeout gets reset/extended if certain commands are sent so I guess that makes sense.
I have 16 Arduinos that are in very tight spaces and hard to get to when I need to reprogram them with my FTDI cable. I would like to have or create some sort of centralized place where I can connect my FTDI cable, make some sort of selection (switch of some sort), which will then connect the pins my cable is on to the selected arduino.
Does anyone have any thoughts on how this can be accomplished? I've toyed with transistors, but that takes a lot of them and didn't quite work.
Are there any premade solutions that are out there that I have yet to find?
Thanks very much!
Here is a thought! TCP to Serial.
Sound complicated.
Not really.
Note from AVRDUDE's manual the following
For programmers that attach to a serial port using some kind of higher
level protocol (as opposed to bit-bang style programmers), port can be
specified as net:host:port. In this case, instead of trying to open a
local device, a TCP network connection to (TCP) port on host is
established. The remote endpoint is assumed to be a terminal or
console server that connects the network stream to a local serial port
where the actual programmer has been attached to. The port is assumed
to be properly configured, for example using a transparent 8-bit data
connection without parity at 115200 Baud for a STK500.
With this, One could place your Arduino's behind your choice of TCP to Serial Server. Which is available in several forms. Cisco has a gang TS (but that is expensive, unless used). lantronix (and others have single end point devices. But then for Linux, there is "Net2Ser" which can serve up all your ttyS (aka Serial/COM ports).
With the later you could use a raspberry or TP-Link TL-WR703N (
In the latest IDE 1.5.6r2 add one entry for each TCP-to-Serial Port to ./Arduino/hardware/arduino/avr/programmers.txt file. While replacing the IP and Port with corresponding values.
TCP2001.name=TCP 2001
TCP2001.communication=serial
TCP2001.protocol=stk500v1
TCP2001.program.protocol=stk500v1
TCP2001.program.tool=avrdude
TCP2001.program.extra_params=-Pnet:192.168.1.100:2001
TCP2002.name=TCP 2002
TCP2002.communication=serial
TCP2002.protocol=stk500v1
TCP2002.program.protocol=stk500v1
TCP2002.program.tool=avrdude
TCP2002.program.extra_params=-Pnet:192.168.1.100:2002
...
Additionally change "protocol" to "upload.protocol" the following line in ./Arduino/hardware/arduino/avr/platform.txt
tools.avrdude.program.pattern="{cmd.path}" "-C{config.path}" {program.verbose} -p{build.mcu} -c{protocol} {program.extra_params} "-Uflash:w:{build.path}/{build.project_name}.hex:i"
to
tools.avrdude.program.pattern="{cmd.path}" "-C{config.path}" {program.verbose} -p{build.mcu} -c{upload.protocol} {program.extra_params} "-Uflash:w:{build.path}/{build.project_name}.hex:i"
With this you can use "Upload Using Programmer" with the selected programmer to send over TCP, rather then use the Upload.
That all said, it will only work on Linux.
avrdude: ser_open(): network connects are currently notimplemented for Win32 environments