element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • 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 & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
    About the element14 Community
  • 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
      •  Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      •  Vietnam
      • 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 34873 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 2 years 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 3 years ago +1
    ohoh..I sense some automation i have to implement....
  • mayermakes
    mayermakes over 3 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…
  • zack_el
    zack_el over 2 years ago in reply to baldengineer

    imageimage

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • baldengineer
    baldengineer over 2 years ago in reply to zack_el

    I think you're using the wrong resource string.

    This works for me on a DP831. Notice how my resource string includes USB0 and the serial number:

    image

    Connect the DP832 by USB. What does this output show:

    import pyvisa
    rm = pyvisa.ResourceManager('@py')
    print(rm.list_resources())

    And what does the output of `lsusb` on the command line show?

    (Also if you press the Utility button on the DP832, it'll show you the USB resource string, in hex.)

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • zack_el
    zack_el over 2 years ago in reply to baldengineer

    Yes, I have already tried that, but it doesn't work. I don't know what could be the reason. Is there another method?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • baldengineer
    baldengineer over 2 years ago in reply to zack_el

    Specifying a baud rate shouldn't matter since it is a VCP connection.

    Did you try just with the query delay?

    In general, you shouldn't need to change the line terminations on VCP connections, so you should only try that if adding a query delay alone doesn't help.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • zack_el
    zack_el over 2 years ago in reply to baldengineer

    Unfortunately, this method does not work, or I have done something wrong!image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • baldengineer
    baldengineer over 2 years ago in reply to zack_el

    I cover multiple ways to can be solved in the video (timestamped):

    https://youtu.be/1HQxnz3P9P4?t=638

    First add a query delay and then second try changing the line terminators.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • zack_el
    zack_el over 2 years ago in reply to baldengineer

    I tried to control both devices (DL3021 and DP832) via the USB interface, but I always receive the following error message:

    Exception: VisaIOError VI_ERROR_TMO (-1073807339): Timeout expired before operation completed. In the file "/home/pi/my_project/env/PowerSupply_test.py", line 15, in <module>

    print(supply.query("*IDN?"))         

    ^^^^^^^^^^^^^^^^^^^^^ pyvisa.errors.VisaIOError: VI_ERROR_TMO (-1073807339): Timeout expired before operation completed.image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • baldengineer
    baldengineer over 2 years ago in reply to zack_el

    So keep in mind that a driver for the device and the "VISA driver" are separate things. The VISA driver talks to the OS drivers. So,if the OS cannot enumerate a device and provide a handle, then the VISA driver doesn't matter. So, this is not a NI-VISA issue.

    Regardless, I am fairly certain Rigol uses either a libusb-based interface or emulates a USB-Serial device when connected by USB for all of their devices. I have never encountered one that does not work with Linux.

    Compare the output of lsusb and what the pyvisa resource manager finds to verify what is getting enumerated.

    Also, the R&S VISA drivers work great on Raspberry Pi. I've found their driver worked slightly better than pyvisa-py, regardless of the vendor's instrument.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • zack_el
    zack_el over 2 years ago in reply to zack_el

    I was able to communicate with the RIGOL DL3021 using the RS232 interface and program it with the Raspberry Pi 5 and Python. Unfortunately, it does not work over the USB interface because the Raspberry Pi cannot identify the instrument.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • zack_el
    zack_el over 2 years ago in reply to baldengineer

    knowledge.ni.com/KnowledgeArticleDetails

    • 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 © 2026 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