RS232 Communications
Moderators: adafruit_support_bill, adafruit

RS232 Communications

by axs527 on Tue Apr 02, 2013 11:42 am

Hey Everyone,

I am a biologist and have basic understanding of microcontrollers and have worked with Arduino for sometime. I have a centrifugation device that I can control through hyperterminal RS232 via my PC. What I want to do is to build an Arduino setup that can bypass its routine, sense the safety(s), key strokes and execute a separate routine.

I have the RS232 shield ordered http://www.cutedigi.com/arduino-shields ... duino.html

The centrifuge communicates at the following settings in Hyperterminal:
Baud 9600,
Data bits: 8,
Parity: N,
Stop Bits: 1
Flow Control : Xon/Xoff

As for the homework, plugging in an RS232 cable itself puts the centrifuge in diagnostics mode which by passes its routine. I have the list of commands from the mfg that can control the safety(s), centrifuge rpm etc, through Hyperterminal.

1st: Is this possible?
2nd: Would I be reinventing the wheel?
3rd: If it can be done, can someone without expertise in digital electronics handle this?

I appreciate the help and understand that this tech is not latest (to say the least) but thats the reason I need to bypass the routine of this centrifuge.
Cheers!

Ray
axs527
 
Posts: 2
Joined: Tue Apr 02, 2013 11:22 am

Re: RS232 Communications

by adafruit_support_mike on Tue Apr 02, 2013 2:12 pm

axs527 wrote:1st: Is this possible?

It certainly should be. From your description, it sounds like a "making the Arduino speak the right language" problem.

axs527 wrote:2nd: Would I be reinventing the wheel?

If you can find another Arduino-based RS-232 controller for your specific centrifuge online, yes. I doubt that's the case, though.

Personally, I bundle "don't reinvent the wheel" in with all the grammar and composition rules they teach in high school.. rules of thumb that are handy 90% of the time, but don't stand up to scrutiny very well. I treat them more as default values than rules: if you can't articulate a reason for doing something else, follow them. If you can articulate a reason for doing something else, do whatever you want.

axs527 wrote:3rd: If it can be done, can someone without expertise in digital electronics handle this?

Barring unforeseen hardware issues you didn't mention, yes.

Communication protocols provide something called 'abstraction barriers' in hardware design. If my circuit needs to interact with a circuit directly -- I'm running wires into the chassis and creating signals within that device -- I have to know a lot about the circut I'm planning to fiddle with. If I use a communication protocol like 5v I2C, everything I need to know about that device is contained in the 5v I2C spec. I don't have to worry about talking to the other device any more, I just have to worry about talking to the I2C bus.

In this case, you just need to talk to the RS-232 bus, and the shield will handle all the voltage-and-connection stuff for you. If the shield comes with a code library, that will contain most of the "getting the Arduino to talk to the RS-232 bus" stuff. Your job will be to work at a signals-and-meanings level, which should be high-level code.
When you void a product warranty, you give up your right to sue the manufacturer if something goes wrong and accept full responsibility for whatever happens next. And then you truly own the product.
User avatar
adafruit_support_mike
 
Posts: 9212
Joined: Thu Feb 11, 2010 1:51 pm

Re: RS232 Communications

by abqlewis on Tue Apr 02, 2013 8:54 pm

This project sounds kinda fun and very useful. I'm a little jealous.

I've never done something exactly like this, but pretty close. If I could, I just wanted to confirm to myself that I understand what you have planned.

From your description, you want to make a semi-standalone Arduino assembly (you'll have to run power to it) that runs a cable from the RS232 header you're getting, to the serial connector on the centrifuge. RS232 defines the electrical connection, but the commands (which are typically ASCII, alphanumeric strings going back and forth) are not standardized. So whether you will get the control you want is somewhat up to the centrifuge manufacturer.
You've already confirmed that you can "bypass its routine", which I interpret as taking control of the device by plugging in a serial cable.
You say "sense the safety(s)", that could include receiving safety status through the rs232 port, or sensing some other safety signal like a lid latch closed, or measuring the rpm of the centrifuge. If it's the RS232 status, it wouldn't require much extra, since you've already setup rs232, but it would be dependent on whatever capabilities the manufacture setup for the centrifuge. If it is the external sensing, it could add complexity, but it's do-able.
By "key strokes", I can assume you intend to have buttons on the Arduino that when pushed will cause the micro-controller to spit out the correct serial commands (and take into consideration the safety interlocks) that will cause the centrifuge to operate a specific way. This would be something like Excel macros - you push 1 button, and the centrifuge could spin up to a specific RPM (or even multiple RPMs in some profile) for a specific time and then spin down and stop.
If "key strokes" means keys on the centrifuge control panel, you would have to confirm that the manufacturer provides status for key presses.

One of my concerns with your proposed setup, is the rs232 shield you have selected uses the TX/RX pins on the micro-controller. That in itself isn't bad (and is probably normal), because the TX/RX pins are the micro-controller's serial port. But on the Arduino, this is also the way it communicates (indirectly) with the USB port. Having the USB and the centrifuge hooked up at the same time could cause problems, which would make uploading new programs (which happens a lot during development) more difficult. It would also mean that you couldn't throw messages to the serial monitor, which is the main way I would be debugging.

When I have created serial controllers, I've installed Perl or Python on a PC. I can open a serial port (COMx:) and read and write commands to and from, under program control. This gives me a high-level language, a GUI builder (for virtual buttons), and provides a decent debug capability. Most new PCs don't come with an RS232 port, but USB-to-RS232 converters are available and cheap. If I didn't want to dedicate a whole PC, I could just use a Raspberry Pi (haven't done this yet, but I am anxious to find a problem that I can use it as a solution).

My $0.02
abqlewis
 
Posts: 67
Joined: Fri Dec 11, 2009 1:19 am

Re: RS232 Communications

by axs527 on Wed Apr 03, 2013 4:19 pm

Thanks for the reply mstone and abqlewis!
mstone@yawp.com wrote:Barring unforeseen hardware issues you didn't mention, yes.


What kind of hardware issues are we talking about? Any specific information will help. I agree with your inclusion of 'reinventing' the wheel because, a part of my job as a biologist entails reinventing the wheel for specific applications because the casual rule of thumb dont always work in task specific applications.

abqlewis wrote:This project sounds kinda fun and very useful. I'm a little jealous.


:) Im glad you think so :) . I thought about the port interference issue regarding the USB and the RS232. My plan was to run the new routine through the PC and then upload that same routine onto the arduino and let it run the centrifuge.

I like the idea of having buttons on the arduino to run specific routines, but what was referring to was sensing key strokes from the centrifuge's keypad. I am fully capable of running the new routine through my PC using hyperterminal, but I wanted a module that anyone can plug in to the RS232 port of the centrifuge and it run a new specific routine.

As for using a Raspberry Pi, I havent had much experience on that platform but I dont want a full PC interface because, getting away from it is the whole idea behind this project.

I will start looking up the architecture and bus in the centrifuge and find what communication protocol it works on.
Thanks again!
Cheers!
R
axs527
 
Posts: 2
Joined: Tue Apr 02, 2013 11:22 am

Re: RS232 Communications

by adafruit_support_mike on Thu Apr 04, 2013 1:36 pm

axs527 wrote:What kind of hardware issues are we talking about?

That's a blanket term for the difference between "here's how it should work in theory" and "here's how it works in practice". To paraphrase Helmuth vol Moltke, few hardware designs survive first contact with the actual hardware.

The scope of 'the unexpected' is practically infinite, so trying to list all the things that could potentially make you step back and rethink would just induce unnecessary worry. If you do run into trouble, come on back and we'll see what we can do to help.
When you void a product warranty, you give up your right to sue the manufacturer if something goes wrong and accept full responsibility for whatever happens next. And then you truly own the product.
User avatar
adafruit_support_mike
 
Posts: 9212
Joined: Thu Feb 11, 2010 1:51 pm

Re: RS232 Communications

by phedlund on Thu Apr 04, 2013 1:57 pm

I have done a lot of 232 work over the years. The Arduino actually has 4 serial ports to use. One thing I might point out.
Make sure when you connect the 232 it does not use any of the handshaking pins on the 232 to do things.
When you said that it goes into a different mode when the 232 is connected hints that the device is seeing a change on one of the
handshake lines. I know there are many fine free terminal programs out there but I would recommend you use Terminal by Bray. It allows up to 24 buttons on the screen to be used as keystroke macros. This should help shorten your development time. When you are ready to put the code in the arduino, simply setup a switch/case statement for the buttons to send the strings.

switch (button)
{
case button1:
Serial.print("abc");
break;
case button2:
Serial.print("def");
break;
default :
digitalWrite(ErrorLamp,HIGH)
break;
}
phedlund
 
Posts: 14
Joined: Fri Jan 18, 2013 2:06 pm