Author Topic: ADALM1000 SMU with Fluke289 and Python  (Read 2424 times)

0 Members and 1 Guest are viewing this topic.

Offline View[+]FinderTopic starter

  • Supporter
  • ****
  • Posts: 220
  • Country: us
    • Sparks! A Learning Place for Curious Minds
ADALM1000 SMU with Fluke289 and Python
« on: March 18, 2022, 08:42:05 pm »
This combines the Fluke 289 DMM with the ADLAM1000 module SMU "M1k"

The Fluke 289 is a large, expensive hand-held industrial DMM; the Analog Devices AALM1000 is a tiny, under $100US source-measure unit. What do they have in common? Quality components and microAmp precision. Add a Python script to get them talking, and you have a working SMU for hobby projects, whatever. What does the Python script accomplish?

It shows how to connect Python to the Fluke 289 and get data
It shows how to connect Python to the M1k (it took me a while to figure that out)
It shows how to set the M1k to source voltage and measure current
It shows how to get four-quadrant measurements (-5V to +5V; sink 200mA or source 200mA)
It shows how to get useful data from the M1k on two channels
It shows how to print the output data
It shows how to open a CSV file and write data to it (that is the easy part)

Code: [Select]
import time
import os
from io import open
import pysmu
from pysmu import Mode
import serial

''' SMU Voltage Range Settings 'from low to hi" USER can set in range from -5V to +5V'''
lowVolt = -5
hiVolt =  5
precision = .1
''' 1.0, 0.10 or 0.01 the number of decimal placees--will affect number of samples'''

''' Setup serial USB to Fluke 289 DMM'''
DMM = serial.Serial()
DMM.port = '/dev/cu.usbserial-AC00FZQJ'    # Serial port; change to suit your USB

# Serial port setup and open for FLUKE 289 (don't change)
DMM.baudrate = 115200
DMM.bytesize = serial.EIGHTBITS
DMM.parity = serial.PARITY_NONE
DMM.stopbits = serial.STOPBITS_ONE
DMM.xonxoff = False
DMM.rtscts = False
DMM.dsrdtr = False
DMM.timeout = 0.1  # seconds
try:
    DMM.open()
except:
    print("Cannot open serial port...")
    exit()
   
'''Setup output file for data, this will be from your PC path'''
output_filename = 'dmm_out.csv'
output_directory = "/Users/donal/documents/" #''' MacOS; PC users will know what to do'''
os.chdir(output_directory)
file = open(output_filename, 'w', newline='')
file.write('Volt,Amps,V_a,I_a,V_b,I_b \n') #''' for the column headings (can be changed)'''

''' this function will get current reading from DMM set on mAmp or uAmp as needed'''
def QM():
    DMM.write(('qm' + '\r').encode('utf-8'))
    if DMM.read():
        data = (DMM.read(32).decode('utf-8'))       
    return ((data.split(','))[0][1:]) # dont change this
   
 
''' convert volt range for greater precision'''
lowVolt = int((lowVolt)/precision)
hiVolt = int((hiVolt)/precision+1)
session = pysmu.Session(ignore_dataflow=True)
#print (session) debug

smu = session.devices[0]
#smu = list_devices(session,0) more debug
#print (smu.serial)
#print (smu.fwver)

''' Set both channels to SMU mode. (different settings, just FYI'''
chan_a = smu.channels['A']
chan_b = smu.channels['B']
# CHAN_A source
#chan_a.mode = Mode.HI_Z
chan_a.mode = Mode.SVMI
#chan_a.mode = Mode.SVMI_SPLIT
#chan_a.mode = Mode.SIMV
# CHAN_B source
#chan_b.mode = Mode.HI_Z
chan_b.mode = Mode.SVMI
#chan_b.mode = Mode.SIMV
#chan_b.mode = Mode.SIMV_SPLIT

'''this sends settings to ADALM1000'''
def out_file(v_a,v_b):
    #print (volt)
    session.start(0)
    chan_a.constant(v_a)
    chan_b.constant(v_b)
    #if v_b == 5: debug
    time.sleep(2)
    amps = QM()   
    time.sleep(0)
    volt = v_a - v_b
    data = ()
    for x in smu.read(1):   
        out_data = ((x[0][0], x[0][1], x[1][0], x[1][1]))
        data = (str(out_data).replace('(',''))
        time.sleep(.1)
        if len(data) > 0:
            print (str(round(volt,2)) + ', ' + str(amps)+', '+ str(data.replace(')','')))
            file.write(str(round(volt,2)) +', ' + str(amps) +', ' + str(data).replace(')','')+'\n')

# deal with negative voltage
if lowVolt < 0 and hiVolt > 0:
    for vb in range(abs(lowVolt),0,-1):   
        v_a = 0.0
        v_b = float(vb*precision)
        out_file(v_a,v_b)
    for va in range(0,hiVolt):
        v_a = float(va*precision)
        v_b = 0.0
        out_file(v_a,v_b)
else:       
    for va in range(lowVolt,hiVolt): # when both lowVolt and hiVolt > 0
        v_a = float(va*precision)
        v_b = 0.0
        out_file(v_a,v_b)
   
# deal with both lowVolt and hiVolt negative voltage
if lowVolt < 0 and hiVolt < 0:
    for vb in range((lowVolt),abs(hiVolt),-1):   
        v_a = 0.0
        v_b = float(vb*precision)
        out_file(v_a,v_b)
       
    for va in range((hiVolt),(lowVolt)):
        v_a = float(va*precision)
        v_b = 0.0
        out_file(v_a,v_b)   

'''DONE, tidy up''' 
file.close()
chan_a.mode = Mode.HI_Z
chan_b.mode = Mode.HI_Z
chan_a.constant(0)
chan_b.constant(0)
#print (All finished")


OK, the M1k is designed for education and hobby use: a 5V 200mA SMU for demonstrating basic EE concepts. Right. And if you need 1000V or 10A, there are several SMU's from Keithley--starting at $5,000. Used on eBay go for $2,000 up. For many of my measurement tasks, a ten volt, four hundred mAmp range is more than enough.

NOTE: this is a Python script--I run it in Thonny--not an "application." Thonny is about as entry-level as one can get in an IDE. Paste the script in the code window, press 'Run' and get the printout below.{see screenshot} You'll need to set up the output file, the USB to the Fluke 289, spend $100 for the M1k, configure a breadboard measurement, etc. OR, you can just comment out the stuff you don't need right away. I'm an old dog trying to learn some new tricks, so it took time to figure out the connections with things that arent meant to be connected. The M1k has some clever software (PixelPulse2) that does the UI for the kids--easy. Fluke has FormView for industrial documentation, rock-solid but about as locked-down as one would want in plant equipment.

https://github.com/dbbotkin/ADALM1000_SMU_Fluke289
« Last Edit: March 18, 2022, 11:32:27 pm by View[+]Finder »
 
The following users thanked this post: ledtester, TopQuark

Offline spec123

  • Contributor
  • Posts: 15
  • Country: us
Re: ADALM1000 SMU with Fluke289 and Python
« Reply #1 on: November 07, 2022, 06:58:47 pm »
Hello,
Tried running the script in python. I get error message "pysmu not found!".

I'm using Windows 10 (64 bit), latest python version (python-311.0-amd64) and have installed the "libsmu-1.0.2-setup-x64.exe" and
"libsmu-1.0.2-setup-x86.exe".

Any ideas on where/how the pysmu can be found? George
 

Offline alm

  • Super Contributor
  • ***
  • Posts: 2903
  • Country: 00
Re: ADALM1000 SMU with Fluke289 and Python
« Reply #2 on: November 07, 2022, 09:37:58 pm »
I don't own an ADALM1000 or anything else that uses the same software, but it looks like the Windows installer does not install the Python modules anymore for some reason. It looks to me like the libsmu-1.0.4-win32-win64.zip file at the release page contains the Python modules (.whl/wheel files) for Python 3.7, 3.8, 3.9 and 3.10. So I would uninstall Python 3.11, install Python 3.10 and install the pysmu module from the zip file using the same command as they document for Linux/Mac, except the name of the wheel file will be a bit different. So something like python3 -m pip install pysmu-1.0.4-cp310-cp310-win_amd64.whl. If that doesn't work, try pip install pysmu-1.0.4-cp310-cp310-win_amd64.whl.

Offline spec123

  • Contributor
  • Posts: 15
  • Country: us
Re: ADALM1000 SMU with Fluke289 and Python
« Reply #3 on: November 09, 2022, 03:41:08 am »
Many thanks alm, I think you have the answer!

You are right, the libsmu zip files only contain the Python modules for Python up to 3.10.
Will try as you suggest. Should be working soon.  Thanks!
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

-->