element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
WorkBench Wednesdays
  • Challenges & Projects
  • element14 presents
  • WorkBench Wednesdays
  • More
  • Cancel
WorkBench Wednesdays
Documents How to Program Test Tools with Python - Workbench Wednesdays 66
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join WorkBench Wednesdays to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Engagement
  • Author Author: tariq.ahmad
  • Date Created: 28 Dec 2022 7:30 PM Date Created
  • Last Updated Last Updated: 14 Jun 2024 5:21 PM
  • Views 32485 views
  • Likes 5 likes
  • Comments 57 comments
Related
Recommended

How to Program Test Tools with Python - Workbench Wednesdays 66

If your test tools have a USB or LAN port, there is a good chance that they support SCPI. Using pyVISA, you can write automated test programs for most equipment without expensive software. This video explains terms like VISA, SCPI, and USBTMC. Then it shows how to use Python and pyVISA to connect to test equipment with a Raspberry Pi (or any Linux computer.)

Watch the Video:

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

Bonus Content:

  • PyVISA
  • RsInstrument, R&S Python Implementation (also uses pyvisa!)
  • Keysight IO Suite
  • R&S VISA
  • Standard Commands for Programmable Instruments (SCPI) Syntax. (web archive mirror IVI Foundation)
  • SCPI Specification
  • Blog post, Early peak at bode plot script
  • Snapshot of Code
  • Github link for code

Bill of Material:

Product Name Manufacturer Quantity Buy Kit
34465A Bench Multimeter, Truevolt, 6.5 digit Keysight 1 Buy Now
TL081 - JFET General Purpose, 4 MHz SOIC-8 ST Microelectronics 1 Buy Now
Bench Oscilloscope - 200 MHz, 1 GSa/s, 14-bit, AFG, DMM Multicomp Pro 1 Buy Now
MXO4 - 4 Channel Oscilloscope 200 MHz Rohde & Schwarz 1 Buy Now
HMC8043 Bench Power Supply, Programmable, 3 Output, 0 V, 32 V, 3 A Rohde & Schwarz 1 Buy Now
RPI400-KIT-US Raspberry Pi 400 Kit, BCM2711, Quad-Core, 64bit, ARM, Cortex-A72, US PSU, US Keyboard Layout Raspberry Pi 1 Buy Now
 

element14 presents

element14 Presents  |  About James |  Workbench Wednesdays

  • Remote Programming
  • VXI
  • gpib
  • USBTMC
  • visa
  • lxi
  • IVI
  • scpi
  • Share
  • History
  • More
  • Cancel
  • Sign in to reply

Top Comments

  • baldengineer
    baldengineer over 1 year ago in reply to zack_el +3
    For some reason, posting these instructions here causes errors. You need to create a udev rule. Here's how to do it: www.baldengineer.com/accessing-usb-instruments-with-pyvisa-on-linux.html
  • mayermakes
    mayermakes over 2 years ago +1
    ohoh..I sense some automation i have to implement....
  • mayermakes
    mayermakes over 2 years ago in reply to baldengineer +1
    if anyone has a gripe with using a pi, I can warmly recommend doing it with a Beaglebone black. this also gave me the idea of maybe developing some sort of plug and play box with a pocketbeagle that reads…
  • ilmStephen
    ilmStephen 7 months ago

    Thanks for the breakdown of VISA drivers! I have some questions about the Multicomp MP720016 PC oscilloscope shown at 11:26. What settings did you set in the DS-Wave software to get it to talk over telnet? Are you using the USB port or RJ45? I've tried ping and ipconfig and PuTTY telnet on Windows 11 but I can't connect. Thanks in advance, there doesn't seem to be much info on these two products online.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • halnaabi
    halnaabi over 1 year ago in reply to Jan Cumps

    Type "help", "copyright", "credits" or "license" for more information.
    >>> import serial; ser = serial.Serial('COM3', 115200, timeout=5); ser.write(b'*IDN?\n\r'); ser.close()
    7
    >>> import serial; ser = serial.Serial('COM3', 115200, timeout=5); ser.write(b'*IDN?\n'); ser.close()
    6
    >>> import serial; ser = serial.Serial('COM3', 115200, timeout=5); ser.write(b'*IDN?'); ser.close()
    5
    >>> import serial; ser = serial.Serial('COM3', 115200, timeout=5); ser.write(b'RST'); ser.close()
    3
    >>>

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 1 year ago in reply to halnaabi

    Try to add a newline.

    SCPI Command Terminators:

    A command string sent to the instrument must terminate with a <new line> (<NL>) character. 

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • halnaabi
    halnaabi over 1 year ago in reply to baldengineer

    Unfortunately not, 

    import serial; ser = serial.Serial('COM3', 115200, timeout=5); ser.write(b'*IDN?')

    Output: 

    4 or 5

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • baldengineer
    baldengineer over 1 year ago in reply to halnaabi

    Does it work when you connect through a serial terminal and type commands?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • halnaabi
    halnaabi over 1 year ago in reply to baldengineer

    import serial
    import time
    
    # Define serial port settings
    port = 'COM3'
    baud_rate = 115200 #9600
    timeout = 1
    
    # Open serial port
    ser = serial.Serial(port, baud_rate, timeout=timeout)
    
    try:
        # Send SCPI command to query instrument identification
        command = "*IDN?\n" #\n\r
        ser.write(command.encode())  # Send the command as bytes
        time.sleep(0.3)
    
        # Read response from the DMM
        response = ser.read_all().decode()
        print("Instrument Identification:", response.strip())
    except serial.SerialException as e:
        print("Serial communication error:", e)
    finally:
        # Close serial port
        ser.close()

    Output: 

    Instrument Identification: 
    
    Process finished with exit code 0

    A serial connection is established successfully, but the digital multimeter (DMM) does not respond to the commands sent to it

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • baldengineer
    baldengineer over 1 year ago in reply to halnaabi

    I would try using a serial terminal to connect to it first. That way you might be able to figure out what it is doing.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • halnaabi
    halnaabi over 1 year ago

    Thank you for sharing this informative video! I found it really helpful in understanding how to program and test tools with Python.

    I have a question regarding the VICTOR 8246A DMM. Despite my efforts, I couldn't locate any proper documentation for this model, especially concerning remote connectivity. I'm attempting to establish a remote connection with the instrument but haven't had much luck. Do you have any advice or resources you could recommend?

    Thanks in advance for any assistance you can provide!

    Here is the Hello World code: 

    import pyvisa
    from time import sleep  # for delays
    
    # Initialize the PyVISA resource manager
    ResourceManager = pyvisa.ResourceManager()
    
    # List all connected resources
    print("Resources detected\n{}\n".format(ResourceManager.list_resources()))
    #Resources detected ('ASRL4::INSTR', 'USB0::###############', 'ASRL3::INSTR')
    
    
    # Open a connection to the DMM (Digital Multimeter) device
    DMM = ResourceManager.open_resource('ASRL3::INSTR')
    
    # Set the baud rate for the serial interface
    DMM.baud_rate = 115200
    DMM.query_delay = 0.3
    DMM.write_termination = '\n'
    DMM.read_termination = '\n'
    
    # Print information about the connected device
    print(DMM) # SerialInstrument at ASRL3::INSTR
    
    # Send command to the DMM to query its identification
    print(DMM.query("*IDN?"))
    
    # Close the connection to the DMM
    DMM.close()

    Here is the error that I got: 

    , line 251, in handle_return_value raise errors.VisaIOError(rv)
    pyvisa.errors.VisaIOError: VI_ERROR_TMO (-1073807339): Timeout expired before operation completed.
    

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • zack_el
    zack_el over 1 year ago in reply to baldengineer

    you are the best Muscle tone3

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • baldengineer
    baldengineer over 1 year ago in reply to zack_el

    I am glad it is working! I sincerely apologize because I forgot about the udev rule.

    I set it up so long ago that I forgot the step was necessary! (And it should have been in the video!)

    Like I said in the video, getting to "*IDN?" is probably the hardest step of all!

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube