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
NI LabVIEW Community
  • Products
  • Dev Tools
  • NI LabVIEW Community
  • More
  • Cancel
NI LabVIEW Community
LabVIEW Challenge Blogs Learning LabVIEW: 5 - Setting up the Raspberry Pi PICO and Accessing Instruments
  • Blog
  • LabVIEW Challenge Blogs
  • Forum
  • Documents
  • Quiz
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join NI LabVIEW Community to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Andrew J
  • Date Created: 13 Oct 2023 1:54 PM Date Created
  • Views 3302 views
  • Likes 8 likes
  • Comments 10 comments
  • test automation
  • labview 2023
  • ni
  • development
  • learning
  • labview
  • scpi
Related
Recommended

Learning LabVIEW: 5 - Setting up the Raspberry Pi PICO and Accessing Instruments

Andrew J
Andrew J
13 Oct 2023
Image to capture the idea of learning LabVIEW

Introduction

At some stage, I'm going to actually have to interact with a physical instrument.  LabVIEW does this with VISA drivers (Virtual Instrument Software Architecture) which will allow control over Ethernet/LXI, GPIB, Serial, USB and other protocols - NI has an overview in this white paper.  A lot (majority?) of reasonably well-branded instruments and SBCs will support at least one of these connection options so should be accessible to LabVIEW although there must be some means of actually interacting - a protocol.  Again, a lot of well-branded instruments will support a SCPI (Standard Commands for Programmable Instruments) standard however, an SBC, e.g. Arduino or Raspberry Pi, will almost certainly require some form of firmware to be installed to do this.  Now, it doesn't need to be SCPI, that's just a standard, and could instead be a proprietary syntax especially where memory remains tight.  

Challengers have been issued with a Raspberry Pi Pico so it makes sense to use that, as well as bench instruments I have (which are already SCPI drivable via a USB interface.)  In order to use the Pico I will install firmware developed by Jan Cumps, details to follow below.  This post looks at getting that installed and checked and then takes a look at what is required to actually interact with an instrument.

Table of Contents

  • Introduction
  • Setting up the Pi Pico
    • Preparing the Development Environment
    • Installing the Firmware
    • Testing the Firmware
  • LabVIEW and Instruments
  • Summary

Setting up the Pi Pico

There are two stages to this: setting up a development environment for the Pi Pico and installing Jan's firmware.

Preparing the Development Environment

I'm describing this for a Windows environment so I'm afraid with Linux and MacOS some additional research will be required.  By far the easiest way to do this is to use the Raspberry Pi Pico Windows Installer.  Take a look at the Getting Started with pico document, section 9.2 on page 39.  This provides a link to Github where the installer can be found: download the latest release, available on the Github landing page, run it and follow the installation instructions - it will install Microsoft Visual Studio Code for the IDE, if it isn't already, and the Pico SDK amongst the other necessary tools.  Note that the same document provides instructions for MacOS, manual installation instructions for Windows and information for using other IDEs.  When prompted, I installed the examples, built the blinky application and tested it - there is an on-board LED.

I found no issues with this approach but I did already have VS Code installed, with CMake and Build Tools for Visual Studio. This blog post by Shabaz was useful for additional information and looks like it would also be a good place to ask questions as there's some good experience on E14 now with using the Pico.

Installing the Firmware

Unsurprisingly, none of the examples that come with the SDK provide a USB/SCPI interface.  Fortunately, Jan Cumps has developed the Pico SCPI LabTool (PST) to provide such a feature.  I shall be climbing on the shoulders of giants and using that.

Shabaz has provided a detailed post for installing the PST firmware here and you want to start from the point where the development environment is setup.  He describes installing the PST for the CLion IDE and this is where I stumbled a little as I am using Visual Studio Code.  It took me a while to figure it out, as it's somewhat different, obviously, and some of what I cover below may be because I wasn't wholly sure about what I was doing but it was how I ended up with it working.

Remember where the Pico SDK was installed and where the scpi-parser library was cloned as I'll need that information.

For the Github commands, I didn't bother with the command line as detailed by Shabaz but used GitKraken.  

After cloning the PST firmware then open Visual Studio and load the PST project.  Make sure the correct compiler is selected.

Image showing Visual Studio Code with the Project loaded

Next, some Settings need to be changed:

Image showing how to open Settings in Visual Studio Code

Add paths to the SCPI library and the Pico SDK.  Its a bit garbled in the screenshot, it seems to be a bug in VSC or an issue with running it in a VM:

Image showing how to add Paths to the CMake settings in Visual Studio Code

At this point, the PST should build (click the Build button at the bottom of the window) and the .uf2 file loaded to the USB connected Pico.  The issue that took me the longest to work out was that the directory structure must be specified with a forward slash (/) and not a backslash (\) which is contrary to Windows - this may be because I'm running a VM on MacOS??

Testing the Firmware

Once installed, I can use NI tools to test it.  Firstly, make sure the Visa Interactive Control application is installed - the download is here.  Then it's worth running NI Max which was installed with LabVIEW.  The Pico must be plugged in and not set to map to a drive.

Image showing NI Max open with the Pico selected.  Instructions to change its name and launch Visa Interactive Control application

The very small font is a result of the application not playing well in the VM with a Retina screen.  It's worth giving the Instrument a unique name (called an Alias in LabVIEW) to help identify it and this name can be used in a LabVIEW application rather than the VISA Resource Name which is not at all distinguishing.  Launching the Visa Interactive Control (Open Visa Test Panel in NI Max):

Image showing the USB Settings tab of the Visa Test Panel with the Pico details populated

Image showing the Visa Test Panel having run a *IDN? command to the Pico

The result shows that the firmware is installed and running and responding to commands.  This means the LabVIEW ought to be able to talk to it.  Note the name of the instrument on the window title bar - the Canonical name in LabVIEW terms - and you'll see why assigning an alias is a good idea (although it isn't used by the Visa Test Panel for some reason.)

LabVIEW and Instruments

So, now that I can verify that the Pico is accessible using the Visa Test Panel, I want to create a simple program in LabVIEW to do the same thing and make sure that I understand at least the basics of what is required.  In this video, I create the program, debug it and prove that it's actually quite a simple task to achieve.

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

Summary

  • Use the Raspberry Pi Pico Getting Starting Guide and Windows Installer to set up the Pico for development.
  • Build on Jan's work by installing his SCPI library to the Pico rather than create my own.
  • Use NI-Max to give the VISA device an alias that readily identifies it.  Without doing this, every connected instrument will have an unintelligible VISA Resource Name and it will be nigh-on impossible to tell them apart.  NI-Max can also be used to set common settings as well, for example the baud rate for instruments that are connected serially.
  • Use Visa Test Panel (VISA Interactive Control) to test that a connection can be made.
  • It's not complicated to get LabVIEW interacting with an instrument:  open - one or more write and read commands - close.
  • Must remember to configure String controls used for a SCPI command to handle control characters correctly.
  • Use NI I-O Trace to see what is actually happening between LabVIEW and the instrument to aid debugging; also LabVIEW has debugging features built in to aid in seeing what is actually happening when a program runs.

Next: Anatomy of a VI.

  • Sign in to reply

Top Comments

  • Jan Cumps
    Jan Cumps over 1 year ago in reply to Andrew J +1
    Saw the video . It wasn't available yesterday.
  • taifur
    taifur over 1 year ago

    Very informative video.

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

    Yep, been following the posts, it's good work.  I will get around to doing something with it: right now, I've got loads of documenting to do for the Challenge which I want to break the back of first.  

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

    The service request functionality is now available in the latest release (.uf2 prebuilt firmware included), with example in the LabVIEW driver package.

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

    It can be implemented on a USBTMC, VXI or GPIB layer, as far as I understand. Because it relies on these protocols to let the instrument initiate a conversation.

    I've implemented SCPI instruments with sockets and serial USB on a Pi. Never with the above protocols. But should be possible.

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

    That will be interesting to incorporate into the framework, some form of eventable Command Director.  It may be a bit of an ignorant question, but is this likely to get ported to a regular PI?  I can’t imagine it would be too difficult.

    • 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