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 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
Raspberry Pi
  • Products
  • More
Raspberry Pi
Raspberry Pi Forum Pico SCPI Lab Switch project: automate your test setup with a standards compliant multi-channel switch
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Raspberry Pi to participate - click to join for free!
Featured Articles
Announcing Pi
Technical Specifications
Raspberry Pi FAQs
Win a Pi
Raspberry Pi Wishlist
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 9 replies
  • Subscribers 660 subscribers
  • Views 2756 views
  • Users 0 members are here
  • raspberry
  • pico_usbtmc_scpi
  • pico
  • scpi
Related

Pico SCPI Lab Switch project: automate your test setup with a standards compliant multi-channel switch

Jan Cumps
Jan Cumps over 2 years ago

SCPI programmable LAB switch with USBTMC interface

Automated test setups often need switches:

  • to turn signals on and off
  • to enable or disable supplies
  • to add or remove output loads
  • to connect a measurement instrument to several circuit nodes and collect data
  • that integrate seamlessly with LabVIEW and pyvisa test setups
  • ...

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

LabVIEW compatible. This video shows the WIP VI Virtual Instrument driver

In this blog series, I develop a lab switch that can do that. Programmable via SCPI. Plug-and-play compatible with the VISA test & measurement device standards. It supports the USBTMC standard and is IEEE 488.2 compliant. It can control any 3.3V compatible relay/switch circuit.


image

The core is a Raspberry Pico. Firmware is 97% based on SCPI and USBTMC cross-platform libraries. 3% (less than 30 lines of source code) is Pico specific.

image

The number of switches you can control is only limited by the amount of available GPIOs on the PICO.

image
image: WIP VI Virtual Instrument driver example

Command supported:

  • all standard SCPI commands (*IDN?, *RST, SYST:ERR...)
  • control a switch: DIGI:OUTP# 0|1
  • poll a switch state: DIGI:OUTP#?

The firmware is SCPI and IEEE488.2 compliant.
Free to use - also for commercial applications (except the LabVIEW driver). No restrictions and no promises. Please respect the licenses of the 3rd party libraries that are used in the project.
Check the last post for source code, PyVISA and LabVIEW test beds, and the Pico ready-to-load firmware binary.

link to all posts

  • Sign in to reply
  • Cancel
  • Jan Cumps
    Jan Cumps over 2 years ago

    Because I used the same SCPI commands as in my earlier Linux/SCPI project on a Raspberry Pi:  SCPI on a Linux Board - Part 5a: LabVIEW Driver for LAB Switch: Open, Close and Switch functions ,
    that project's LabVIEW Virtual Instrument blocks worked straight away with the Pico project. I only had to select a different VISA resource string.


    image
    Because the Pico firmware registers as an USBTMC device, it automatically popped up in the Visa resource selection box.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • bidrohini
    bidrohini over 2 years ago

    Quite an advance project with Rapberry Pi Pico, I must say. 

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • neuromodulator
    neuromodulator over 2 years ago

    I've been playing  a bit with TinyUSB to make an USBTMC device, and I was wondering if you have tried to make a composite device that uses USBTMC and CDC. Since CDC uses IAD, I needed to define class/sub-class/protocol to 0xEF, 0x02, 0x01. But when I tried it, NI-max did not detect the USBTMC device. Then I set the class/subclass/protocol to 0x00, 0x00, 0x00, and everything worked just fine. But as this appears to be non-standard, I'm not sure if it would work well on machines that are not Windows 10. 

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • Jan Cumps
    Jan Cumps over 2 years ago in reply to neuromodulator

    I have never tried to make composite tinyUSB firmware. 

    The commercial devices I have at home with composite, are usually debuggers. I have USBTMC scopes, psu and dmm.  But they don't enumerate with additional (CDC or other) interfaces. I don't know if TMC and CDC can live together on the same USB...

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Cancel
  • dang74
    dang74 over 2 years ago

    Thanks Jan.  This is a nice economical method for creating Labview controlled switches.  I remember back in the day we would buy I/O cards directly from National Instruments.  Your method is definitely easier on the wallet.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • shabaz
    shabaz over 2 years ago in reply to neuromodulator

    I don't know if this is useful for your application or not, and maybe you've already considered it; it might be simpler to be able to select one of the modes on power-up, since it may be unlikely that the user wants both methods of communication. It could be selectable by holding down a button, but another option that I've used a few times for similarish-scenarios (not USBTMC related) is for the microcontroller on power-up to wait a few seconds for a connection using one protocol. If it doesn't see that, then it switches to the other protocol. 

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • neuromodulator
    neuromodulator over 2 years ago in reply to Jan Cumps

    I suppose in the worse case, if its not supported, one could expose them as connected to a virtual hub. I haven't tried that yet though, not sure how much work that may require. In the meantime I'll just use the 0x00, 0x00, 0x00 class/subclass/protocol, as its working well to make a composite device with 3 different interfaces (USBTMC, CDC, MSC)

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • neuromodulator
    neuromodulator over 2 years ago in reply to shabaz

    Actually my plan was to use CDC for configuration CLI, USBTMC for control, and a MSC to host a redirecting html file. Another alternative to keep things simple would be to expose the CLI to a USB-USART bridge, and use just 2 ports, 1 for USBTMC and another for CDC CLI (and not use MSC at all). Another alternative would be to use a hub IC and connect everything to one single output, but this could eventually also be achieved through software. A similart alternative to your proposition could also be implemented I suppose, the systems starts as CLI, and if no access to the CDC is detected within a few seconds, then the USB restarts as USBTMC.

    Many alternatives that I'll have to evaluate, as of now, my (eventually non-compliant) USBTMC-CDC-MSC composite device seems to be working. So unless it fails on Linux or Windows 11, I'll probably keep it like that.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • ggabe
    ggabe over 2 years ago

    Great project, Jan. I built one with a 16 relay board. It's super convenient that the TMC device can be referred from pyvisa by name regardless what USB port it's plugged in. In contrast with ASRL devices, where names will change with the USB location. I built two other SCPI devicest, a DAC and a function generator, I'm considering to port their firmware to TMC for this reason.    

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • 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