go_away

Author Topic: Data Logger - Agilent DMM to Arduino to PC  (Read 2045 times)

0 Members and 1 Guest are viewing this topic.

Offline quantumvoltTopic starter

  • Jr. Member
  • **
  • Posts: 8
  • Helpful? 0
Data Logger - Agilent DMM to Arduino to PC
« on: June 01, 2013, 05:28:41 PM »
Hi. I am new here. I want to make a simple one-way data transfer from a HP Agilent 34401A DMM to Arduino Uno to a laptop by using software serial on a digital pin to receive data from DMM to Arduino and hardware serial to echo data from Arduino to PC.

When I tried 'Preview', I lost my post ("You don't have access to ..." - lost a lot of work  >:(  :-\  :'( ) , so I will be overly careful and try to post the DMM's user's manual first:

http://cp.literature.agilent.com/litweb/pdf/34401-90004.pdf


Please see pg. 83 on Ext TRIG and VM Comp (measurement complete).

Thanks,
Roy

Offline quantumvoltTopic starter

  • Jr. Member
  • **
  • Posts: 8
  • Helpful? 0
Re: Data Logger - Agilent DMM to Arduino to PC
« Reply #1 on: June 01, 2013, 05:48:42 PM »
Well, it came through. Thanks.

Half the job is data from Arduino to PC. By removing the 'call'-code in http://arduino.cc/en/Tutorial/SerialCallResponseASCII my serial COM-port window on the laptop echoes a High/Low state from a breadboard toggle switch hooked to an Arduino digital input.

What I would like to know is:

How do I write a loop where Arduino is listening all the time - on a digital input pin - for a low pulse from the DMM's 'VoltMeter Measurement Complete' - BNC plug indicating that a measurement is complete (see pg. 83 in manual) and then reads the measurement data from the DMM's 9-pins RS232 output plug on another digital input pin. The data must be forwarded to the PC.

If you do not mind, I'll post this question first. I will then supply some technical information I have found in a separate post below.

Thanks.
Roy



Offline jwatte

  • Supreme Robot
  • *****
  • Posts: 1,343
  • Helpful? 81
Re: Data Logger - Agilent DMM to Arduino to PC
« Reply #2 on: June 01, 2013, 10:11:33 PM »
Wouldn't it be better to just read the software serial port all the time and forward whatever comes into it onto the hardware serial port?

This code on the Arduino site does just that: http://arduino.cc/en/Tutorial/SoftwareSerialExample

Offline quantumvoltTopic starter

  • Jr. Member
  • **
  • Posts: 8
  • Helpful? 0
Re: Data Logger - Agilent DMM to Arduino to PC
« Reply #3 on: June 02, 2013, 02:55:46 AM »
Thanks a lot. That sketch compiles and works after I downloaded latest Arduino version. Simple is good.

When I toggle a switch between RX-Software digpin 10 and GND (which I understand Arduino reads as falling and rising edges of pulses?), I get different strange characters in different numbers dependent on bouncing.

Next step is code for reading the RS232 from the DMM. Here is the documentation:

Agilent 34401A Digital Multimeter:
Baud Rate:
9600 (selectable)
Data bits:
8 (selectable)
Parity:
None (selectable)
Start bits:
1 (fixed)
Stop bits:
2 (fixed)
Flow control:
DTR/DSR (fixed)


Anyone can help with this? Also I need conversion from -15 Volt to +5, and + 15 Volt to 0. Is this correct?
I have also read that minimum 2-way setup is 3 cables. I will only need 2: System ground and DMM TX to Arduino RX via the inverting level shifter?

Thanks,
Roy

Offline quantumvoltTopic starter

  • Jr. Member
  • **
  • Posts: 8
  • Helpful? 0
Re: Data Logger - Agilent DMM to Arduino to PC
« Reply #4 on: June 02, 2013, 06:21:29 AM »
I have found schematics for the level shifter. they are all over the web:



http://techref.massmind.org/techref/io/serial/ttl-rs232sx.gif



http://www.uchobby.com/wp-content/uploads/2007/06/ttl2rs232.gif


These two are identical except from the LED's and direction. One can also replace the charge capacitor and diode with a negative 5 Volt (or a 555 timer charge pump). Is this correct?

I have ordered a converter based on MAX232 and a fleeBay Nokia cable that can be hacked, but I want to build the discrete circuit above to learn and to get something running quick.

Thanks,
Roy

Offline jwatte

  • Supreme Robot
  • *****
  • Posts: 1,343
  • Helpful? 81
Re: Data Logger - Agilent DMM to Arduino to PC
« Reply #5 on: June 02, 2013, 01:40:33 PM »
Is the DMM 15V ? If so, yes, you will have to level shift, as it will be +15V/-5V, low-one. The Arduino is 5V TTL, high-one.

The circuit you're showing goes both ways. You don't need that for just reading. Here's a simpler circuit:

Input level converter and inverter.


Note that it uses a fairly uncommon symbol for the N-channel mosfet transistor. The source is the pin with the arrow, and it's N-channel.
« Last Edit: June 02, 2013, 01:42:41 PM by jwatte »

Offline quantumvoltTopic starter

  • Jr. Member
  • **
  • Posts: 8
  • Helpful? 0
Re: Data Logger - Agilent DMM to Arduino to PC
« Reply #6 on: June 02, 2013, 05:15:51 PM »
Thanks again. I keep thinking 2-ways, but as you say - all I need is an inverting single transistor level shifter. I have no FET's, so I just copy a common emitter NPN with the voltage divider on input and the 10k load from one of the circuits above. I will only need a negative supply if the DMM is set to receive. Correct?

I understand that Arduino reads one and one byte - so I do not have to bother about bits. In my case the byte is 11 bits - 1 start bit, 8 data bits and 2 stop bits. Technically Arduino (8-n-1) reads less - it interprets the first bit after an initial falling edge (from a longer period idle high) as the start bit and then samples 8 bits in the middle of the bit's time duration based on 9600 Baud timing referred to time for the start bit? The stop bit is just a feature to set the line idling high? And 2 stop bits- i.e. high for two periods - is just a feature to make a period longer than a bit between 2 consecutive bytes, so  in case the readings are immediately following each other Arduino will 'rest' one clock period before reading the next byte?

So all I need to read is:

void loop() // run over and over
{
  if (mySerial.available())
    Serial.write(mySerial.read());
}

This reads byte for byte and sends them to the PC. In the PC I get a string of undetermined start, length and stop. To get my data, I have to look for the ASCII "+" and "-"  followed by a carriage return / line feed as described in the data format.


Single reading (RS-232)

Output Data Format
< 80 ASCII character string
SD.DDDDDDDDESDD<nl>
SD.DDDDDDDDESDD,...,...,<nl>
SD.DDDDDDDDESDD<cr><nl>
SD.DDDDDDDDESDD,...,...,<cr><nl>
S Negative sign or positive sign
D Numeric digits
E Exponent
<nl> newline character
<cr> carriage return character



Is this all?

Thanks again,
Roy

Offline jwatte

  • Supreme Robot
  • *****
  • Posts: 1,343
  • Helpful? 81
Re: Data Logger - Agilent DMM to Arduino to PC
« Reply #7 on: June 02, 2013, 10:24:07 PM »
Quote
I will only need a negative supply if the DMM is set to receive. Correct?

Correct.

Your suggestion for the rest of the project sounds right, too. Good luck, and please post pictures when you're done :-)

Btw: Everyone should have a bag of BS170 laying around. I suggest you pay digikey.com a visit soon ;-)

Offline quantumvoltTopic starter

  • Jr. Member
  • **
  • Posts: 8
  • Helpful? 0
Re: Data Logger - Agilent DMM to Arduino to PC
« Reply #8 on: June 03, 2013, 02:59:56 AM »
Hah  ;D , any small signal NPN is OK. I am a theoretical mathematician by profession and even if my only electronics hands-on was tube radios / crystal radios in the 1960's, I do know that engineering-logic must be sloppy in order to be read. If you demanded infinite decimal precision in 0 and 1 (as in Integer or Boolean) - no circuit ever made would have been able to detect a single state as True or False.

Anyway - it works.  A day wasted / learning due to two problems:

1. No or little sloppiness with HP Agilent. Unless the DMM gets DSR True, it sends out nothing. So a jumper from DSR Pin 6 to Data Carrier detected DCD / CD was the cure on the web. Didn't work. Found solution after loooong time search and think: DSR hooked to logic High (+9V battery via 10 kOhm - I guess 3 AA cells would have been better since the BNC-plugs on the DMM carries 5 VOLT?). I later found on the net that all kinds of magic is necessary to make RS232 run (you can even buy Jumper-Boxes  ???).

2. May be some sloppiness in the Arduino Sketch http://arduino.cc/en/Tutorial/SoftwareSerialExample. Early on it sets    Serial.begin(57600);,    then later     mySerial.begin(4800); . I understand that these are two different UARTs (Is that the right word?)    However - the Arduino compiler (IDE?) sets up the PC-window in 9600 Baud. In order to get anything readable I had to set BOTH Baud rates in the sketch to 9600.

Anyway - I am happy. Time to buy a DB-9 (I didn't have one, so I am tapping the thin pins with leads in tape ...).  And using Processing I can make a presentation statistics screen running real time (I have also ordered an SD-card reader for a few pennies in case I have no computer running when I need to log data). The voltage source I am working with drifts from 5.0 Volt with less then 5 microVolts, and I need to document it and also study time series' against temperature etc. in order to see if I shall refine it further or put it in a feedback controlled oven (some 45 - 65 deg C). We'll see ...

So thank you very much. I will try to put in a Helpful-point for you.

Regards,
Roy

Offline quantumvoltTopic starter

  • Jr. Member
  • **
  • Posts: 8
  • Helpful? 0
Re: Data Logger - Agilent DMM to Arduino to PC
« Reply #9 on: June 03, 2013, 03:09:39 AM »
PS  Tried an hour to upload pictures. It says "Restrictions: 6 per post, maximum total size 600KB, maximum individual size 300KB". I checked 'Properties' on my pictures - size 4.72 MB.

Too tired today ... But IT WORKS. Thanks again.

Roy

Offline jwatte

  • Supreme Robot
  • *****
  • Posts: 1,343
  • Helpful? 81
Re: Data Logger - Agilent DMM to Arduino to PC
« Reply #10 on: June 03, 2013, 10:08:21 AM »
Glad you got it working!

You can change the Terminal window in the Arduino IDE to run at 57600 instead of 9600 if you want, although there's probably no pressing need to do that.

If the software serial doesn't work at 4800, but works at 9600, then that means that's the speed of the data the DMM sends out.

The two baud rate values are largely independent, although it's a good idea to have the baud rate from (Arduino -> PC) >= (DMM -> Arduino) for obvious overflow reasons.

Offline quantumvoltTopic starter

  • Jr. Member
  • **
  • Posts: 8
  • Helpful? 0
Re: Data Logger - Agilent DMM to Arduino to PC
« Reply #11 on: June 03, 2013, 07:35:15 PM »
Yes, yes and yes to Baud rates. When you know it - everything is simple. I still will argue that Arduino's only raison d'etre is simplicity - so if the IDE defaults the window to 9600 AND 99% of code examples that floats around the web use 9600 - it is either stupid or unkind to make basic tutorials meant for ready-to-play with other Baud rates.

I made a video. All info necessary for replicating this experiment is in this tread. Maybe other lab instruments' serial ports require different jumper magic. That will have to be solved then. Also - there is no way to reduce the amount of data coming except from using external single triggering. It works- Arduino sets the EXT TRIG low for a few microseconds or more, and one measurement is taken. When you want it, send a high pulse to DSR. Arduino can also easily flip-flop a good quality relay (no digital switch for me) that alternates the measurement between the voltage source and diode / base-emitter junction relative temperature sensor circuit for correlation calculation.

There is also a lot of Processing code, tutorials and videos for serial data acquisition, plots and GUI on the internet.

Regards,
Roy

DMM Serial to Arduino to PC

Offline jwatte

  • Supreme Robot
  • *****
  • Posts: 1,343
  • Helpful? 81
Re: Data Logger - Agilent DMM to Arduino to PC
« Reply #12 on: June 04, 2013, 10:24:43 AM »
Automation for the win :-)

 


Get Your Ad Here