Author Topic: 34401a interface to PC - RS232 or GPIB?  (Read 26258 times)

0 Members and 1 Guest are viewing this topic.

Offline free_electron

  • Super Contributor
  • ***
  • Posts: 8517
  • Country: us
    • SiliconValleyGarage
Re: 34401a interface to PC - RS232 or GPIB?
« Reply #50 on: November 07, 2014, 11:22:24 pm »
 :palm:  why can;t any of these home-brew gpib adapters follow the standard. it ain;t that hard. simply put the two line driver chips on there. they are like 2 $ ... and all these problems go away.
Professional Electron Wrangler.
Any comments, or points of view expressed, are my own and not endorsed , induced or compensated by my employer(s).
 

Offline cellularmitosis

  • Supporter
  • ****
  • Posts: 1111
  • Country: us
Re: 34401a interface to PC - RS232 or GPIB?
« Reply #51 on: July 16, 2017, 06:03:19 am »
I just got logging via RS-232 working on my 34401A this evening.

While reading through the manual I discovered "talk only" mode, which is by far the easiest way to get started with logging data.

Using the menus, configure the 34401A to use RS-232.  Then, configure the 34401A's GPIB address to be 31.  This puts the device into "talk only" mode, which allows you to configure and operate the device as you normally would via the front-panel, but it automatically spits out all of the readings to the serial port.  This makes it operate similarly to the cheap hand-held DMM's which have a serial data-logging option.

Attached is an example of this working with CuteCom, and I've also attached a simple Python script which will log the values to a CSV file (you'll need to rename the file extension from .txt to .py).

Code: [Select]
#!/usr/bin/env python

import serial
import sys
import time

ser = serial.Serial(
    port = sys.argv[1],
    baudrate = 9600,
    bytesize=serial.EIGHTBITS,
    stopbits = serial.STOPBITS_TWO,
    parity = serial.PARITY_NONE,
    timeout = 10
)

sys.stdout.write("timestamp,value\n"); sys.stdout.flush()

last_sample_timestamp = time.time()

while True:
    line = ser.readline()
    now = time.time()

    # The FTDI chip seems to buffer up a certain amount of outgoing bytes if
    # there is no listener to recieve them.  Thus, when we first run this
    # script, we will get an initial flood of queued readings.  Throw those
    # away, because we don't have a timestamp for them.
    if now - last_sample_timestamp < 0.1:
        continue
    last_sample_timestamp = now

    microvolts = float(line.rstrip()) * 1000000
    sys.stdout.write("%0.3f,%0.1f\n" % (now, microvolts)); sys.stdout.flush()
« Last Edit: July 16, 2017, 06:04:54 am by cellularmitosis »
LTZs: KX FX MX CX PX Frank A9 QX
 

Offline alm

  • Super Contributor
  • ***
  • Posts: 2862
  • Country: 00
Re: 34401a interface to PC - RS232 or GPIB?
« Reply #52 on: July 16, 2017, 06:58:05 am »
Funny how the RS-232 mode is affected by the GPIB address. That would probably not be obvious to me.


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf