Hello all,
Situation
I'm having trouble with something that should be simple...
I'm trying to use Arduino to measure forces out from a basic force gauge that uses RS-232 data output.
The Force gauge is from a Japanese company called Imada, and reading its not-so-complete manual (penultimate page of http://www.checkline.com/products/126020/zp-manual-usb-3.pdf), I see its RS-232 uses these parameters:
19200 bps; 8 data bits; 1 stop bit; no parity bits
What I did
First, from the 9-pin plug from the Force gauge, I hooked up appropriate RX, TX, and GND wires to Arduino via MAX232.
Then, I wrote very simple code (see below) using NewSoftSerial on pins 2 and 3, and proceeded to print out what I saw on computer serial monitor.
Note that, as the manual says, since this device's communication is bi-directional, I need to send out a command first in the form of an Ascii character.
In my case, since I just want to read out measurements, I sent out:
--the ASCII character 'D' (which corresponds to command of reading out display data from the gauge)
--a carriage return
--start and stop bits handled by NewSoftSerial
PROBLEM
Everything is happening as it should from my side but I'm getting nothing in the output from the gauge!
I checked the scope at various points to see what was going in:
- Transmit: I saw: 5 Volt pulses from the Arduino's TX before the MAX232 chip
- Transmit: I saw: MINUS 8 Volt pulses to PLUS 8 Volt pulses (approx.) on the TX line from Arduino AFTER MAX232 chip
- Receive: I saw: Nothing from the gauge's RS-232
Question: What am I doing wrong in terms of sending my request for data, and why is the gauge not answering?!
I'm afraid I'm missing something very basic about RS-232, because based on what I've read, it's supposed to be simple.
The very straightforward code...
#include <NewSoftSerial.h>
NewSoftSerial mySerial(2, 3);
char c;
void setup() {
mySerial.begin(19200);
Serial.begin(19200);
pinMode(3,OUTPUT);
}
void loop() {
// First, send out an ascii-character command to request data
mySerial.println("D"); // ASCII character 'D' followed by carriage return
// Then, just read in the received data, if any
if (mySerial.available()) {
c = (char)mySerial.read();
Serial.print(c);
}
else delay(500);
}