Sending Serial String to Motor Drive

Hi

I've had a quick search and problem is I can't get my head around sending serial strings from the Arduino without using the USB port, maybe I cam getting confused. I wonder if anyone can help.

I have a custom stepper controller that is operated by sending a text string (eg "A2534") that tells it direction, steps, speed etc.

How would I physically wire the Arduino upto the serial connection on the stepper controller and how would I setup a port on the IO to send the string?

Many Thanks

I have a custom stepper controller

This means that only you have the needed info on wiring the controller. Care to share your secrets? :)

Sorry to clarify, It’s custom but I did not build it, it just has a 9 pin serial connector for RS232 control. We currently run it from Labview. I’d like to use an Arduino to replace the PC as a standalone PC is overkill.

If it uses RS232 voltage levels then you'll need to interface the +12 and -12V from RS232 to the TTL levels (0 and +5V) of the Arduino - a MAX232 chip for example can be used to do that. If it already uses TTL levels then all you need to do is connect it to digital Pins 0 and 1 of the Arduino and then Serial.print can be used to send the strings.

Pete

Ah, thanks is clearer now. So when sending strings using serial.print are they sent over both the usb serial and on pins 0 & 1, or do I have to do a specific serial port setup in the code?

If you still have the Arduino hooked up via USB then it would be better to use software serial on, e.g., pins 2 and 3 like this:

#include <SoftwareSerial.h>
#define rxPin 2
#define txPin 3

// set up a new serial port
SoftwareSerial mySerial =  SoftwareSerial(rxPin, txPin);

void setup()
{
  ..
  mySerial.begin(9600);
  ..
}

In loop() you can then use mySerial.write and mySerial.read.

Pete

You may be able to simply invert the TTL arduino output to the controller by just using an NPN transistor and two resistors.

Oh yes, sorry I forgot. The RS-232 levels are inverted compared to TTL. The +12V RS-232 corresponds to the 0V TTl and -12V RS-232 corresponds to +5V TTL.

Pete

Thanks for the help guys, a lot clearer now.