So I am using an Arduino MEGA 2560 board and a cutedigi RS232 shield to attempt to communicate with a Keithley 6514 Electrometer. I would like the Electrometer to output simple voltage measurements to the Arduino that will be monitored and recorded over time in the serial monitor or possibly stored directly to an SD card. Eventually I would like to combine this function with a multiplexer to take readings from various sources and record all of the data. But first I am hung up on the basic serial communication with the Keithley. I am using one of the basic tutorials that enables communication between the serial monitor on the computer and the serial port the RS232 is connected to. The Electrometer uses SCPI language coded in ASCII so as far as I am aware the two should be able to communicate but I believe my syntax is off.
Below is my code:
void setup() {
Serial.begin(9600);
Serial1.begin(9600); // port that RS232 shield is wired to
}
void loop() {
if (Serial1.available()) {
int inByte = Serial1.read();
Serial.write(inByte);
}
if (Serial.available()) {
char ser = Serial.read();
Serial1.write(ser);
}
}
Everything seems to hooked up right because when I type a command in the serial monitor, the TX light on the RS232 shield lights up. I am currently just sending the SCPI ":READ?" command which should prompt the electrometer to send its data. BAUD rate is configured to 9600 on all ends.
Any input would be greatly appreciated. I am relatively new to all of this and very much a novice in any type of coding so I realize I may be making a very simple error that I am not aware of.
Assuming that you have set the baud rate correctly and have the connections right, I would hardwire a "*IDN?" command rather than sending a command from the PC.
A link? I have attached the instruction manual for the Keithley 6514 Electrometer. There is no other information that I can provide.
I am attempting to hardwire the "*IDN?" command into the system and my code looks like such:
void setup() {
// initialize both serial ports:
Serial.begin(9600);
Serial1.begin(9600);
}
void loop() {
Serial1.println("*IDN?");
if (Serial1.available()) { // read from port 1, send to port 0:
int inByte = Serial1.read();
Serial.write(inByte);
}
}
Running this produces no response from the Keithley Electrometer. Per the instruction manual it should give the identification information in ASCII format. Is there an issue with my Serial1.read() command structure, I would assume the serial monitor would read whatever comes from the Electrometer.
Thank you for the responses and any additional input!
Here is some unwanted advice:
If the Arduino is just going to be a translator between the PC and the unit. Chuck it and get a National Instruments GPIB-USB adapter. No more hardware communication issues. GPIB is much better for controlling instruments. It must be - it has hung on since the late 60's!
Anyway, you might have a DCE/DTE problem. If you are hoking pin 2 to pin 2 and pin 3 to pin 3 as it says in the Keithley manual, try hooking pin2 to pin3 and pin 3 to pin 2. The shield may be DTE rather than DCE.
Haha ok. Well I was hoping to give it a few more swings before I scrap it since I already have the equipment ...
I tried switching the pins around and it managed to produce a response of a bunch of jibberish which is maybe better than nothing??? I have attached a picture of the response from the serial monitor using just the "*IDN?" command
You are sending hundreds of IDN? commands a second that way. Set up your software to send only one per about 5 seconds, and then listen for a while. Check out the blink without delay for an example.
I'm also trying to work on a similar project...the arduino is working properly when communication with PC but when I connect it to Electrometer it is not showing anything at all.