Products > Test Equipment
External Display for Agilent 34401A (or any DMM with RS232 Output Stream)
<< < (8/8)
PioB:
Hi all,

thank you very much for your code. I just got it working on an Arduino Mega with the Adafruit graphics libraries and an SSD1306 display.


--- Code: ---#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define OLED_MOSI   9
#define OLED_CLK   10
#define OLED_DC    11
#define OLED_CS    12
#define OLED_RESET 13
Adafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);

String inData;
int trigpin = 7;  // your choice, connect to DSR, serial pin 6


void setup()
{
  pinMode(trigpin, OUTPUT);
  Serial.begin(9600); // Serial hardware to PC
  Serial1.begin(9600);  // Serial1 on Arduino Mega2560 port to DMM
  display.begin(SSD1306_SWITCHCAPVCC);
  display.display();
  delay(2000);
  display.clearDisplay();
  display.setTextColor(WHITE);
  display.setTextSize(1);
  // Trigger
  digitalWrite(trigpin, HIGH);
  inData = ""; // Clear read buffer

}

void loop()
{
  digitalWrite(trigpin, LOW); //
  delay(10); // adjust
  digitalWrite(trigpin, HIGH);

  delay(1000);  // or whatever

  while (Serial1.available() > 0)
  {
    char received = Serial1.read();
    inData += received;
    // Process message when new line character is recieved
    if (received == '\n')
    {
      Serial.print("Arduino Received: ");
      Serial.println(inData);
      inData = inData.substring(0, inData.length() - 7); // cut exponent for test, see DMM manual for string format
      display.clearDisplay();
      display.setCursor(25, 29);
      display.print(inData);
      display.print(" V"); // a string - not a number - unparsed for exponent
      display.display();
      inData = "";
    }
  }
}

--- End code ---

For future reference, here is how to put the 34401A into the "talk only" mode, took me a while: http://www.keysight.com/main/editorial.jspx?ckey=1000001249:epsg:faq&id=1000001249:epsg:faq&nid=-11143.0.00&lc=eng&cc=CO


lukaq:
small, but looks good
cellularmitosis:
ARISE FROM THE DEAD, YE THREAD!

I took a swing at this project this weekend, and spent a lot of time getting the values formatted the way I prefer.

I used a DB9 RS232-to-TTL adapter from eBay, and soldered a 10k pull-up from VCC to DSR (DB9 pin 6) to convince the 34401A to talk.

Also, the 34401A has been configured for "talk only" mode, so it just automatically spits everything out via the serial port; the Arduino doesn't have to transmit anything to the 34401A.

Details: https://gist.github.com/cellularmitosis/1582236f226e9d98075a0c971eb4168c
cellularmitosis:
Update:

I forked the Arduino SoftwareSerial library to use two stop bits, as required by the 34401A.

Also, I tied pin 6 to 9v rather than 5v and that seems to have cleared up the occasional beep / error from the 34401A.

In my case, the adapter I was using was based off the MAX232, so I just found which capacitor had 9v on it and soldered the pin 6 pull up to that cap.

https://github.com/pepaslabs/SoftwareSerial2Stop
Navigation
Message Index
Previous page
There was an error while thanking
Thanking...

Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod