PDA

View Full Version : Controlling equipment with RS232 interface


lazybratsche
07-26-2011, 09:15 AM
Or, Applied Computer Archaeology.

I've got a piece of equipment in the lab with an honest-to-got RS232 9-pin serial port that I'd like to use. It's an incubator that we normally just set with a few buttons, but I want to have it automatically switch temperatures in the middle of the night. I've looked up the manual and apparently all I have to do is send a few commands via the serial port. Should be easy enough, right?

Well, first problem is that all of the lab computers old enough to have a serial port are attached to other pieces of equipment in another room. So I'm thinking I can get a USB-RS232 adapter of some sort so I can use any computer I want. Is there any chance I can pick up one of these from a electronics retailer?

Second, how do I automatically send a command at some point in the night? I've used PuTTY to dabble with linux, and i see that it can also talk to a serial port. But I don't see how I can automate it. Is there some easy way to write a script in Windows (XP or 7) to have PuTTY send a command at a given time?

engineer_comp_geek
07-26-2011, 09:30 AM
They make USB to serial adapters. You probably won't find one at ye ol local electronics store, but you can find one online pretty easily. One issue I have run into is that these tend to sometimes 'stutter" a bit, meaning that they occasionally pause while transmitting. This causes problems with some equipment (especially old PLCs) that interpret the pause as a lost or garbled message. A lot of equipment can tolerate brief pauses though. If you can still find the manual for your particular piece of equipment you might want to check if it has a "character timeout" or something like that. If it is adjustable (most aren't), set it to a higher value.

Windows has a built in scheduler. You can set it to automatically run a task or kick off a batch file or whatever at the time of your choosing. Google "windows scheduler" for more info and examples of how to use it.

Napier
07-26-2011, 01:24 PM
You could also write "copy instructions.txt > com1" into a batch file, I bet.

I have had terrible luck with usb to rs232 adapters, detailed in another thread. Now I am using a lantronix uds2100 which is an ethernet web host with serial ports. I am using Tera Term to telnet to it. Nothing is emulating or addressing "com" ports.

md2000
07-26-2011, 01:52 PM
You could also write "copy instructions.txt > com1" into a batch file, I bet.

I have had terrible luck with usb to rs232 adapters, detailed in another thread. Now I am using a lantronix uds2100 which is an ethernet web host with serial ports. I am using Tera Term to telnet to it. Nothing is emulating or addressing "com" ports.

Yes, IIRC we used to do the command
>COPY CON: COM1:
that would send keystrokes from the keyboard (console) to the com port to test it. Or, as you point out, PUTTY works too.
Some USB adaptors will default to COM4: port.
I don't recall the exact commands in good old BASIC (if that is still around) but you could also use that to read and write a com port.

The_Raven
07-26-2011, 02:19 PM
USB-Serial adapters are a mixed bag... If your machine has an open PCI slot, you can get a serial card from someplace like SIIG which will be less problematic.

Also, check the BIOS of the PC, some motherboards have RS-232 headers built in, all you need is the appropriate connector to mount in a slot.

In my experience, the USB adapters set up on high COM port numbers which older software can't see.

Kevbo
07-26-2011, 02:19 PM
They make USB to serial adapters...One issue I have run into is that these tend to sometimes 'stutter" a bit, meaning that they occasionally pause while transmitting.

This problem predates the demise of built-in-serial ports, it is a Windows problem, not a USB issue. Basically, you can't control the timing of serial messages after Win98, and it was a pain then. With DOS/Win3.1 you had full control. THE USB converters DO have some issues though.

IMO this has strongly contributed to the demise of serial ports. They required absolutely minimal hardware and had adequate bandwidth for lots of stuff, for example the OPs instrument. Only in the last couple of years has hardware come out that makes USB pretty simple to implement, but is still adds a few dollars, and the cable lengths can be very restrictive.

JoelUpchurch
07-26-2011, 02:59 PM
The biggest problem I had with USB to serial adapters was that they didn't support the BPS Rate change in the windows UI. The only ones I found that did were the Quatech models. I agree with the poster above that a PCI card is your best option.

If you want something that is a real PITA, try dealing with a piece of equipment that is designed to use a parallel port.

dropzone
07-26-2011, 07:31 PM
I think this is why God created eBay and resale shops. And scouting the curbs on Garbage Eve. Old tech is cheap and does what you want it to do. If it hasn't failed after twenty years it's not likely to anytime soon, but if it does? So what; you are out five bucks.

Or go all out and get a TRS-80 Model 100 or 102. Last software Gates wrote his own damn self, including a capable, but bog simple, port of GW-BASIC. It eats next to no power and takes up next to no space. You'll have to make your own cable, since Rick died. (http://www.club100.org/) :(

lazybratsche
07-26-2011, 07:58 PM
Thanks for the help everyone, especially for pointing out that the windows "copy" command might be all I need. I'll try to borrow an old desktop for the first few attempts at the experiment, or failing that get a USB adapter. If it's something that the lab might want to do more of in the future, I'll look into a web host with serial ports. That sound like the perfect way to control a stack of old equipment that's only a few feet away from a network connection.

Shagnasty
07-26-2011, 08:05 PM
I support a pharmaceutical manufacturing facility with lots of those interfaces controlled on newer computers. Some of them run on real serial ports while others run on USB to serial converters. I have had to redesign the interfaces on modern PC running very old multi-millionaire dollar machines a number of times. I have always been able to get it to work but I can't think of a time when it didn't take hours or days of experimentation to get it to work just right. Serial port communication is a pain in the ass and very fickle. Sometimes certain hardware and settings just refuse to work together. Don't give up. I always go with USB to serial converters for new solutions but they often have problems the first time and require reinstalls of the drivers sometimes several times. The moral to this story is that you can get it to work on a new computer with a USB to serial adapter for just a few dollars but it likely won't work the first time. Learn all about COM ports, data bits, parity, and flow control. Write those down from the existing solution but even a straight copy doesn't always work. Don't be scared to switch the COM port on the driver if one won't behave because that can solve many problems. COM ports 3 and 5 are the most consistent team players in my experience but they refuse to play sometimes too.

www.newegg.com has several inexpensive USB to serial connectors (use those terms in your search). If the first one you buy absolutely won't work, try another brand that may do the trick for your problem.

dropzone
07-26-2011, 10:37 PM
I have had to redesign the interfaces on modern PC running very old multi-millionaire dollar machines a number of times.We call that "billable time." It's the lifeblood of the industry, like lawyers answering your phone calls.

ETA: I'd edit to say "your stupid phone calls," but no lawyer has taken a call that he didn't feel was stupid. :D

ETAA: Except my brother, who claims up and down that my calls are not stupid.

Khendrask
07-27-2011, 08:12 AM
For a reliable, decent USB to Serial adapter, look at Keyspan (http://www.tripplite.com/en/products/model.cfm?txtSeriesID=849&txtModelID=3914). Those are the only ones I use for serial comms in an industrial environment, since they work with just about everything, and actually have driver software so port assignments are permanent.

It is amazingly annoying to use a garbage one that changes its COM port number every time you unplug and plug it back in.

For what it's worth, they are a bit cheaper on Amazon.

Crafter_Man
07-27-2011, 10:15 AM
B&B Electronics (http://www.bb-elec.com/) is another company to check out.

Harmonious Discord
07-27-2011, 01:48 PM
I feel for you. I had to interface equipment and computers with data collection and then statistical software. I hate serial interfaces.

jnglmassiv
07-27-2011, 07:04 PM
I've mentioned here on the boards that I work professionally in the scales and balances field. These devices are only just becoming equipped with USB ports and we have to deal with USB-serial converters all the time.

If you only need to send a couple of commands, your choice of adapter probably won't make much difference. You run into problems with lengthy transmits and a lot of back-and-forth bidirectional comms (like firmware updates). You may also find hardware handshaking issues for those few devices that require it.

If you wish to get a good adapter, looks for one that uses the FTDI chip (http://www.ftdichip.com/). The Prolific line is also well regarded. They come in any number of packages from a slew of manufacturers but the guts are basically the same. It may be hard to tell which adapters do or don't use these reliable chips but a bit of searching should clear it up for a specific device.

Fortunately, I don't write the software on the PC end of things but I do often talk to those that do. Putty is often mentioned and I'm pretty sure it should work.

lazybratsche
08-01-2011, 11:38 AM
Thanks for all of your help. I convinced my boss to order a Lantronix EDS2100, and after a morning of futzing around I'm communicating with my incubator over the network. Nice.

And now I'm trying to figure out how to control the incubator. The manual doesn't give much useful information -- I've got to change both the set temperature, and also switch it between heating and cooling. The first I've figured out just fine. For the second, I called the vender, and heard "uhhhh... whut?" from a few technicians. The guy who might be able to answer my question might be in tomorrow. *sigh*