Sending serial triggers over pins 1 & 2 (Arduino uno)

So I have a device that can be controlled with serial, here are the specs from the manual:

Pin Characteristics Description Function
1 nc
2 output TX serial transmitting signal
3 input RX serial receiving signal
4 combined with pin 6
5 ground ground
6 combined with pin 4
7 nc
8 nc
9 nc

Serial interface parameters
• Bits per second: 9600
• Data bits: 8
• Parity: none
• Stop bits: 1
• Protocol: none

Serial cable
The interface is designed for a serial cable with 1:1 interconnection, and Sub-D 9-pin plug / socket
connectors.

Command set for the serial interface
SCPI commands for the serial interface - overview

  1. *ESR?
  2. *IDN?
  3. ADJUST:?
  4. ADJUST:START
  5. HEATER:1:OFF
  6. HEATER:1:ON
    ...

So can I connect a serial cable to pins 1, 2 and ground then just use Serial.println(HEATER:1:ON) to turn the devices heater on, or is it not so simple?

Any help appreciated!
Thanks!

So can I connect a serial cable to pins 1, 2 and ground

I guess you meant pins 0 and 1 as well as GND.

Serial.println(HEATER:1:ON)

I would try to use double quotes around the string constant.

The interface is designed for a serial cable with 1:1 interconnection, and Sub-D 9-pin plug / socket
connectors.

Sounds like being a RS232 connection. This is not voltage compatible with the TTL level the Arduino uses. If you put a MAX232 (or similar) in between, you should succeed.

Looks like it. Add quotation marks:

Serial.println("HEATER:1:ON");

Is it expecting RS232 levels (~ +/-5 to +/15) or just TTL levels (0 & 5V)?

@pylon, why aren't you in bed :wink:

Ahh, I guess I was getting a bit confused because everyone refers to RS232 as serial, so I guess I will need to use the Max232 or get a RS232 shield. I was hoping I wouldn't have to buy any components to get this working, oh well!

I will have a look around and see how much it would cost to make something up.

Thanks!

Not much
http://www.dipmicro.com/store/MAX232
this & 5 0.1uF caps
cheap shipping too

Or complete boards
http://www.nkcelectronics.com/rs232-to-ttl-converter-board-33v232335.html
http://www.nkcelectronics.com/RS232-to-TTL-converter-board-DTE-with-Male-DB9-33V-to-5V_p_369.html

So I bought this TTL-RS232 converter:

http://www.amazon.co.uk/MAX232-RS232-Converter-Adapter-Board/dp/B00471S6MC

But I am still having some trouble getting the peripheral to communicate.

Here is the code I'm using:

void setup()
{
  // start serial port at 9600 bps:
  Serial.begin(9600);

}

void loop()
{

  Serial.println("HEATER:1:OFF.");

  delay(2000);

  Serial.println("HEATER:1:ON.");
  delay(2000);
}

Here are some pictures of it wired up.

The rx and tx lights on the arduino don't even light up.


Do I need to connect something to RTS CTS?
Do I need to initiate the pins 0 and 1?

Thanks,
Steve

The Rx & Tx lights are driven by the USB/Serial adapter, they will only light up when USB comm's happen.

RTS/CTS - shouldn't need anything.
0/1 are 'initiated' by the Serial.begin( ); library.

Try swapping the 0/1 wires also - so you have Rx to Tx, and Tx to Rx.

You can try a loopback test - connect pins 2 & 3 on the RS232, send a character out & see if you get it back. Use the LED on D13 to indicate if data in agrees with data out.

Ok so I can confirm that the TTL RS232 converter is working.

I have connected the arduino and converter VIA serial to a laptop running a serial port monitor.

Here is the string I am receiving from the board:

48 45 41 54 45 52 3A 31 3A 4F 46 46 0D 0A HEATER:1:OFF..

Here is what I want to receive (this is what the official software that I am trying to emulate sends):

48 45 41 54 45 52 3A 31 3A 4F 46 46 0D HEATER:1:OFF.

Here is the code I am running:

void setup()
{
  // start serial port at 9600 bps:
  Serial.begin(9600);

}

void loop()
{

  Serial.println("HEATER:1:OFF");
  delay(2000);


}

When I changed the println to print the message changes to:

48 45 41 54 45 52 3A 31 3A 4F 46 46 HEATER:1:OFF

So how do I get the ASCII message sent to be exactly like the one I need (the one in bold)?

Any help is very much appreciated,

CAT

So how do I get the ASCII message sent to be exactly like the one I need (the one in bold)?

Look at an ASCII table. What does the 0D correspond to?

It's a line feed - '\n'.

  Serial.println("HEATER:1:OFF\n");

Yeh I looked up what the ASCII values corresponded to, I just didn't know how you were meant to manually insert them.

I changed it to your suggestion and now I am reading this in the serial monitor:

48 45 41 54 45 52 3A 31 3A 4F 46 46 0A 0D 0A HEATER:1:OFF...

rather than:

48 45 41 54 45 52 3A 31 3A 4F 46 46 0D HEATER:1:OFF.

This got it working I think:

  Serial.print("HEATER:1:OFF");
  Serial.print('\r');

This got it working I think:

or

Serial.print("HEATER:1:OFF\r");