1

I have a device that consists of a machine and a control head, connected with a cable with Dab25 connectors at both ends. The control head contains various buttons and dials for operating the dip unctions of the machine. The control head is a little limited in the options it gives you for controlling the machine functions and its ease of use, so I would like to connect the machine to a computer and control it from the computer.

Any suggestions as to how I can reverse engineer the communication protocol from the control head? I am hoping that's it's RS232 - I think I could manage that. Otherwise, I have no idea how to do this (I'm a software guy!). So any thoughts as to how I can determine if it's RS233 or not, and if not - how I could interface a computer with it and decode the protocol ?

  • While the "duplicate" link answers "how do i reverse-engineer what i know to be RS232", this question seems to be focused on "how can i find out if my hardware uses RS232 at all" instead. "Just assume it's RS232 and look what happens" might be a bad idea as that can fry hardware easily. – Guntram Blohm supports Monica Nov 2 '14 at 17:25
  • @GuntramBlohm, thanks for your expertise here. I've retracted my duplicate link / close-vote. – Jason Geffner Nov 2 '14 at 22:04
  • I agree with @Guntram - RS-232 uses +/- 15 volts. Don't just feed it into a microcontroller. The good news is that there are DB-25-to-USB converters (FTDI) that can do the voltage translations for you so all you need to deal with is the data. – SDsolar Feb 27 '17 at 19:54
1

You won't be able to find out if it's RS232 or not without at least a bit of hardware. Also, note that true RS232 uses +/- 12V, while many USB to Serial converters work with +/- 5V, or even 3.3V if they come with devices like mobile phones. This means you're likely to fry your converter if you attach it to the head directly.

So the very first thing you should do is

  • print a pinout sheet of the various different connector types for reference
  • check the voltage on the TxD/RxD lines (Pin 2 and Pin 3) against ground (Pin 7)
  • attach an oscilloscope to those lines to verify if there's a signal on them when you press a button/turn a dial on the head; if successful, you can also get the baud rate from the period length of the signal
  • If there is a signal on those pins, and it's 12V, get a "real" serial card for your PC; if it's 5V or less, a USB/serial converter will probably work as well
  • connect the TxD pin of the head to the RxD pin of your computer, and pin 7 to the ground pin. If you do this in parallel to the original cable, this will allow you to spy on the communication between head and device. Fire up a terminal program/serial port monitor on your PC to view/capture data; Jason's link will tell you more about that.
  • Likewise, connect the RxD pin of the head to your computer's RxD to capture what the device sends to the head. Use two serial adapters in your PC to listen on both directions at the same time.

Note that, since you said there are several dials on the head, the head would need some hardware to convert the analog signal of the dial to digital and send it through some serial protocol. If i had to design this, i'd probably just use potentiometers, and assign one of the 25 lines to each dial/switch, so i'd have analog signals on the wire, and do the processing in the device. (However, digital over RS232 would be more EMI resistant, so you can't rule out the device actually does that).

To check this, you'd need a 24-channel logic analyzer (that can handle analog inputs as well, not just digital), hook up each pin to an input, and check what happens when you operate the head. But in that case, you won't be able to control the device from the PC without some external hardware anyway; you'd need some output ports and D/A converters for this. Electronics.stackexchange.com can probably help you better with that than we can.

UPDATE: How to continue when you know it's not RS232

Assuming your head is implemented in the easiest possible way to do this, it probably consists of a bunch of circuits like these:

Probable circuit diagram

(I've used the international symbols for resistor/potentiometer; the US ones are squiggly lines instead of a rectangle. Also, note that there's no connection where the red and green line cross).

The left connection is ground, the right one the "working voltage". This is often called Vcc; if one of the lines on your PCB has a Vcc or similar marking, you know which line it is. Likewise, ground is often marked GND. If the cable is shielded, the shield is normally connected to GND as well, so that's another way to identify it.

The dials are probably made with Potentiometers, green part. Imagine the dial moving the arrow to the left/right when you turn it. The analog output voltage will be 0V if you move the arrow left, 5V (or whatever your working voltage is) if you move the arrow right, or anything between if the dial isn't in its end position.

The switches could be implemented as shown in the red part; while the switch is open, the digital output has a "weak" connection via the resistor to 0V which will pull the output down to 0V as well; when you close the switch, the "stronger" connection to Vcc pulls the output up to working voltage. (Please don't quote me on "weak" and "strong" connections on an electronics site, but you get the picture ...)

Now what you have to do is identify what your working voltage is, and which line is which. Set your multimeter to ~20V DC (most probable values for Vcc are 12V and 5V), connect the black (ground) wire to ground, and the red wire to a different line on the output. Check if any switch or dial changes the voltage on this line. Following the PCB traces might speed this up. Repeat until you know which line is which. Once you find a line that has a constant voltage which is as high as - or higher - than all the others, you've found the Vcc line.

If you're prepared to shell out a bit of money, you might be interested in buying a Logic Analyzer. The advantage of those is you can measure several channels at once, and it will show you if there's a waveform signal on one of the lines; a multimeter is too slow to detect this. Warning: before connecting the logic analyzer to your hardware, make sure the input line can handle the voltage, as many logic analyzers are made for 5V computer circuits, and while connecting them to 12V or even 24V does not neccesarily fry them, better don't test that.

Once you know which output is which, it's time to connect them to a computer instead of the head. You'll need some Digital to Analog Converters - essentially, they convert a number you set them to into a voltage. If you use one of the cheap Raspberry Pi 10 Digit DA-converters, programming them a 0 will result in an output of 0V, programming a 2^10-1=1023 will set them to 5V, and if you want 1V, set them to slightly over 200. Connect your multimeter (or logic analyzer) to the output, and experiment with the software.

It's the same with the digital outputs. The Raspberry PI comes with a GPIO (general purpose input output) chip that's connected to some headers on the PCB, so you can use one of the many internet tutorials out there to program them.

Of course, it does not HAVE to be a Pi; but the Pi is (in my opinion) the fastest, cheapest and easiest way to do this. Of course, if you have some experience in Arduino programming, the Arduino will be even easier for you. Or you use a PCI card that has digital and analog outputs for your PC, but that tends to be more expensive.

When shopping for I/O cards, again, make sure they can handle the voltage you need. If your head uses 12V, a 5V D/A converter won't help you much. If your head uses 5V, you can, in theory, use a 12V D/A converter (just don't use its whole voltage range), but it's way too easy to have a software bug fry your hardware to recommend that.

Once you're comfortable with programming the digital and analog outputs, you can start making a cable to replace the cable to your head. Each line that is an output line on the head gets connected to an output line of your hardware. Setting the output of a digital line to 0V/5V emulates pressing a switch, and setting an A/D converter to some value emulates turning the wheel.

Be sure to check each line if it works as intended separately. Once they do, it's all software, hack away!

Update: How to attach the 24V output to a logic analyzer that's rated for 5V

Since your head seems to work with 24V, you can't attach a 5V input to an oscilloscope/logic analyzer directly; you need a voltage divider. In your case, this should work:

voltage divider from 24 to 5 V

| improve this answer | |
  • Thanks. I don't own an oscilloscope or logic analyzer, much less a multimeter. As I said, my EE experience is virtually zero. The closed I've come is to look over someone's shoulder while operating these instruments. I will follow your advice and buy a multimeter. I might just try the "hook it to RS232 and hope for the best" - the equipment I'd fry is cheap enough to be disposable. There are cables and software out there you can get to spy on RS232 that will deduce the baud rate for you... – Dave Nov 2 '14 at 20:18
  • ... continued... If it is sending analog over the lines and I need to build my own hardware to operate the device, do you think that would be doable by a DIY type such as myself - willing to learn, but with no experience? – Dave Nov 2 '14 at 20:20
  • You can certainly learn that if you have some fine motor skills (which you'll need when you want to solder something). All the better if you can ask the guy over whose shoulder you looked a question or two. A good idea to get started might be a raspberry pi, for which lots of tutorials and cheap hardware exist (see, for example, learn.adafruit.com/…); hardware for PCs seems to be much more expensive (omega.com/pptst/OME-PCI-1002.html). I'm not affiliated with any of them. – Guntram Blohm supports Monica Nov 2 '14 at 21:48
  • Thanks Guntram! The Raspberry Pi looks interesting. Or maybe an Arduino? I wonder if I could build something out of one of those that I could use to both reverse-engineer the communications between the control head and the machine, and then also interface it to a computer via RS232 to allow the computer to direct it to emulate the control head. – Dave Nov 3 '14 at 2:50
  • Update - I opened up the control box and looked at the circuit board. Virtually all the pins of the DB25 connector appear to be used (they have traces connected to them). So this would indicate that it can't be RS232 - correct? So where does that leave me? Would you mind pointing me in the right direction as to where I should go from here - what equipment will I need and what do I need to learn? – Dave Nov 4 '14 at 13:54
1

In addition to Guntram Blohm's answer, I would spend time looking up the data sheets for the ICs on the board. Your pictures are too blurry to read part numbers. The data sheet will usually contain information about what the part does and example circuits along with pinouts. Tracing pins from known pins on ICs to the pins on the connector will go a long way to telling you what is on the pin without ever putting meters, scopes, or analyzers physically on the device.

| improve this answer | |
  • @Dave totally agree this should be the first step... also sometimes text ID of the PCB will get some hits in google if you're lucky you can even find service manual for your device in which is usually far more then you need. either way make a list of IC's used on PCB find the datasheet's for them and try to make a partial circuit diagram between connector and IC's that will reveal a lot. be careful with transistors they're not always what they seem to be (especially on Japan tech they're sometimes fake and contains processor instead to ensure device will damage in time or can't be copied ...) – Spektre Dec 3 '14 at 12:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.