element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Members
    Members
    • Benefits of Membership
    • Achievement Levels
    • Members Area
    • Personal Blogs
    • Feedback and Support
    • What's New on element14
  • Learn
    Learn
    • Learning Center
    • eBooks
    • STEM Academy
    • Webinars, Training and Events
    • More
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • More
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • More
  • Products
    Products
    • Arduino
    • Dev Tools
    • Manufacturers
    • Raspberry Pi
    • RoadTests & Reviews
    • Avnet Boards Community
    • More
  • 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
Raspberry Pi
  • Products
  • More
Raspberry Pi
Blog SCPI on a Linux Board - Part 5a: LabVIEW Driver for LAB Switch: Open, Close and Switch functions
  • Blog
  • Forum
  • Documents
  • Events
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Raspberry Pi requires membership for participation - click to join
Blog Post Actions
  • Subscribe by email
  • More
  • Cancel
  • Share
  • Subscribe by email
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Jan Cumps
  • Date Created: 7 Aug 2018 11:31 AM Date Created
  • Views 952 views
  • Likes 8 likes
  • Comments 20 comments
  • piface digital
  • raspberry pi
  • labview
  • scpi
  • diytestinstruch
  • piface
Related
Recommended

SCPI on a Linux Board - Part 5a: LabVIEW Driver for LAB Switch: Open, Close and Switch functions

Jan Cumps
Jan Cumps
7 Aug 2018

I'm building a SCPI programmable Lab switch with a Raspberry Pi and PiFace Digital.

Communication is over TCP/IP.

In this post: the LabVIEW drivers

 

What is this Lab Switch?

 

This is a lab instrument. A switch that can be controlled via commands, over the network.

The switch hardware is a combination of two off-the-shelf components: a Raspberry PiRaspberry Pi and a PiFace DigitalPiFace Digital.

All inputs and outputs of the PiFace Digital are accessable via commands. You can read the inputs and set the outputs. All on the 3V3 logic level.

Two of the outputs are connected to a relay. You can use them to switch in and out signals or devices in your automated lab setup.

 

What is this LabVIEW Driver?

 

The driver is a library of controls that help you to talk to the Lab Switch.

You use these controls in your LabVIEW process flows. They allow you to make a connection, control the hardware, then close the used resources.

The LabVIEW blocks that are finished are the Open and Close block to start and finish communication with the Pi, and the Switch control.

The Read component to retrieve the status of both inputs and outputs is on the todo list.

 

Here's an example that shows how these blocks can fit in a process.

I'm using a GUI here to talk to the instrument, because it's helpful to show visibly that the drivers work.

In an automated flow the inputs will very likely be some logic.

 

 

This video shows the example in action:

 

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

 

 

The article builds upon the previous posts. They explain what software needs to run.

You'll need to run the SCPI and Instrument service on your Pi. You can find the sources in previous posts.

(they are not attached I see. I'll do that if there's interest in this subject)

Here are the commands to execute them. No sudo needed on ubuntu.

 

./linux_piface_digital_service_cpp 2223 &
./linux_scpi_socket 2222 2223 &

 

 

Init block

 

 

 

In this block you set the connection parameters. At runtime, LabVIEW will use these to initiate the communication with your instrument.

It will verify that the ID of the instrument is what's expected (if you switch on the ID Query button).

On exit, you have an active instrument connection (VISA resource in LabVIEW lingo) that can be used to send commands and get info.

 

 

The three blocks that are surrounded by a structure have different subflows based on the conditions.

The first block queries the instrument ID if the ID Query is set to true, as shown above.

When you switch  ID Query off, the structure does nothing:

The other two conditional blocks perform a reset if requested (not implemented   because it's todo) and close the instrument connection if any error was thrown while connecting or querying the id.

 

 

If you make a GUI for your automation, you typically copy the Visa Name in control and paste it on your flow's screen. Then connect that control to the init block.

For a flow without a GUI, you would put the connection string in a constant or property, then pass it on.

It's not recommended to change the setting in the Init block's GUI itself, because that can be shared across projects and flows.

 

Close block

 

This block, typically the last one in a process, nicely closes the instrument resources. It releases the connection.

 

I'm not showing the GUI for this one because all inputs are expected to come from the process flow.

 

Switch Control block

 

This block controls the outputs of the PiFace.

There are controls for Enable and Pin. In your flow, you either copy them to your GUI orfeed them the info from other flow elements.

Like in the other blocks, please do not alter these elements in the Switch Control GUI themselves. It's a shared object.

 

This block will send the requested state and pin number to the Pi. It forms a SCPI command string and shoots that over the network.

A typical string would be like this:

:DIGITAL:OUTPUT0 ON

 

 

You can use this block anytime you need to control one of the instrument's outputs.

The outputs 0 and 1 on the PiFace are linked to the two relays on that hat. Very useful to switch in and out some components or circuits in your setup.

 

Example

 

Let's have a look at the example from the begin again.

I've coloured the controls that are copied from the library building blocks orange. The ones added for this flow are in a purple rectangle.

 

In the beginning of the flow, there's an init block that gets the connection parameters from the GUI element we copied from that init's block GUI.

We then enter a set of while loops that allow us to keep on controlling the process until you check the Exit button.

The values for Enable and Pin are retrieved, and sent to the Switch Control when you press Apply.

If you have the exit check button on, this will also cause the flow to go to the Close block and stop.

As long as you keep that checkbox off, you can keep on controlling the instrument.

Check the video above to see how it works.

 

The LabVIEW library is attached to this post.

 

related blog
SCPI on a Linux Board - Letter of Intent

SCPI on a Linux Board - Part 1: Proof of Concept

SCPI on a Linux Board - Part 2a: PiFace Digital C programming

SCPI on a Linux Board - Part 2b: PiFace Digital C++ programming
SCPI on a Linux Board - Part 3: TCP/IP Socket C++ programming
SCPI on a Linux Board - Part 4: TCP/IP SCPI and Instrument Service
SCPI on a Linux Board - Part 4b: TCP/IP SCPI and Instrument Service 100% Working
SCPI on a Linux Board - Part 4c: TCP/IP SCPI and Instrument Service - Run as a Daemon
SCPI on a Linux Board - Part 5a: LabVIEW Driver for LAB Switch: Open, Close and Switch functions
Attachments:
PiFace.zip
3463.linux_piface_digital_service_cpp.zip
Anonymous

Top Comments

  • 14rhb
    14rhb over 3 years ago +3

    Hi Jan,

     

    You can't beat a good bit of Labview automation and remote interfacing  . I'm realling enjoying your series of blogs and am learning along the way also - thank you.

     

    I used Labwindows CVI in…

  • shabaz
    shabaz over 3 years ago +2

    Hi Jan,

     

    Awesome project : ) That's a unique demo too! I like how your computer desktop actually becomes a desktop

  • genebren
    genebren over 3 years ago +2

    Hi Jan,

     

    Very nicely done.  You have developed some great tools and great LabVIEW skills!

     

    Gene

Parents
  • shabaz
    shabaz over 3 years ago

    Hi Jan,

     

    Awesome project : ) That's a unique demo too! I like how your computer desktop actually becomes a desktop

    • Cancel
    • Up +2 Down
    • Reply
    • More
    • Cancel
Comment
  • shabaz
    shabaz over 3 years ago

    Hi Jan,

     

    Awesome project : ) That's a unique demo too! I like how your computer desktop actually becomes a desktop

    • Cancel
    • Up +2 Down
    • Reply
    • More
    • Cancel
Children
  • Jan Cumps
    Jan Cumps over 3 years ago in reply to shabaz

    a vertical one. I taped the Pi to my screen.

    • Cancel
    • Up +2 Down
    • Reply
    • More
    • Cancel
Element14

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 © 2022 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

  • Facebook
  • Twitter
  • linkedin
  • YouTube