MM HP 3458A datalog realtime

Realtime datalog test from Raspberry Pi. Measure 10V from MM with good 3458A (-8.9ppm offset)


Download CSV file for full datalog details

Workflow:

* RPI accesses DMMs via GPIB and reads data.
* Data is formatted by python script into DSV string and written/append to file on FTP
* DSV-file is visible publicly on https://xdevs.com/datashort/10v_3458_nplc200_mm.csv
* Page http://xdevs.com/datalog_mm/ runs D3.js javascript library to read DSV file test.log to input data
* D3.js plots SVG graph online :)



# # xDevs.com Python 10V test for 3458A
# https://xdevs.com/guide/ni_gpib_rpi/
# https://xdevs.com/article/hp3458a_gpib/
# https://xdevs.com/fix/hp3458a/
import sys
import Gpib
import time
import ftplib

port = 21
ip = "ftp.xdevs.com"
password = "datashort"
user = "datashort"

inst = Gpib.Gpib(0,3, timeout=60) # 3458A GPIB Address = 3
inst.clear()

#Setup HP 3458A
#inst.write("*CLR")
inst.write("PRESET NORM")
inst.write("OFORMAT ASCII")
inst.write("DCV 10")
inst.write("TARM HOLD")
inst.write("TRIG AUTO")
inst.write("NPLC 200")
inst.write("AZERO ON")
inst.write("LFILTER ON")
inst.write("NRDGS 1,AUTO")
inst.write("MEM OFF")
inst.write("END ALWAYS")
inst.write("NDIG 9")

cnt = 0
tread = 2
temp = 38.5
inst.write("TEMP?")
temp = float(inst.read())
reflevel = 10.0000000
ppm = 0

with open('10v_3458_nplc200_mm.csv', 'a') as o:
    o.write("date;hp3458a;level;temp;ppm_level;\r\n")
    o.close()

ftp = ftplib.FTP(ip)               
ftp.login(user,password)           # connect to xDevs FTP
    
while cnt <= 10000000:
    cnt+=1
    with open('10v_3458_nplc200_mm.csv', 'a') as o:
        tread = tread - 1
        if (tread == 0):
            tread = 20
            inst.write("TARM SGL,1")
            inst.write("TEMP?")
            temp = inst.read()
        print ("Uploaded to FTP\r\n")
        file = open('10v_3458_nplc200_mm.csv','rb')
        ftp.storbinary('STOR 10v_3458_nplc200_mm.csv', file) #upload file
        file.close()
        inst.write("TARM SGL,1")
        data = inst.read()
        ppm = ((float(data) / reflevel)-1)*1E6
        inst.write("DISP OFF, \"%3.3f ppm\"" % float(ppm))
        time.sleep(1)
        print time.strftime("%d/%m/%Y-%H:%M:%S;") + ("[%8d]: %2.8f , dev %4.4f ppm, T:%3.1f" % (cnt, float(data),float(ppm),float(temp) ) )
        o.write (time.strftime("%d/%m/%Y-%H:%M:%S;") + ("%16.8f;%16.8f;%3.1f;%4.3f;\r\n" % (float(data),float(reflevel),float(temp),float(ppm) ) ))
        o.close()