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
Open Arduino
  • Challenges & Projects
  • Project14
  • Open Arduino
  • More
  • Cancel
Open Arduino
Blog Arduino in Test Instrumentation - Part 1: SCPI Lib
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Open Arduino to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Jan Cumps
  • Date Created: 6 Apr 2018 1:00 PM Date Created
  • Views 7393 views
  • Likes 12 likes
  • Comments 16 comments
  • diytestequipch
  • openarduinoch
  • scpi
  • arduino_test_instrumentation
Related
Recommended

Arduino in Test Instrumentation - Part 1: SCPI Lib

Jan Cumps
Jan Cumps
6 Apr 2018
image

Open Arduino

Enter Your Project for a chance to win a grand prize for the most innovative use of Arduino or a $200 shopping cart! The Birthday Special: Arduino Projects for Arduino Day!

Back to The Project14 homepage image

Project14 Home
Monthly Themes
Monthly Theme Poll

 

Arduino in Test Instrumentation

 

To celebrate Project 14's birthday, I'm going to make a programmable switch with an Arduino UNO.

In this post I try out the SCPI library.

image

 

SCPI Library Installation

 

I'm using a SCPI lib that's written for Arduino: Open Instrument Control.

You can download the GIT archive as a zip.

To install it in the Arduino environment, first check in the Arduino gui where your sketchbook folder is (Via File -> Preferences).

Extract the GIT archive in a temporary location. Copy the src/ArduinoSCPIParser folder to the sketchbook/libraries subfolder

On my PC: D:\users\jancu\Documents\Arduino\libraries\ArduinoSCPIParser.

 

You'll have to comment out one line in the scpiparser.cpp source, or you get compilation errors:

 

// #include <WProgram.h>

 

This is because the SCPI library we're using isn't adapted to the recent Arduino software versions.

 

Test the SCPI Library

 

There are two examples in the SCPI lib. We're using Meter.ino.

Open the example in the Arduino GUI (File -> Open, then navigate to the place where you extracted the GIT archive and open src/Examples/Meter/Meter.ino).

Connect your UNO, select Tools -> Board -> Arduino/Genuino UNO.

Select Tools -> Port -> <the COM port of your Arduino>.

Select Sketch -> Upload.

 

Your Arduino is now programmed with the Meter example and the SCPI lib.

To test the basic setup, open the serial monitor:

Tools -> Serial Monitor

Enter the SCPI command *IDN? and press Send.

The monitor should log the result: OIC,Embedded SCPI Example,1,10.

 

image

 

 

Related Blog
Arduino in Test Instrumentation - Intro: SCPI Programmable Switch
Arduino in Test Instrumentation - Part 1: SCPI Lib
Arduino in Test Instrumentation - Part 2: Firmware
Arduino in Test Instrumentation - Part 3a: LabVIEW Driver Intitialisation Block
Arduino in Test Instrumentation - Part 3b: LabVIEW Driver Switch Control Block
Arduino in Test Instrumentation - Part 3c: LabVIEW Driver Read Status Block
Arduino in Test Instrumentation - Outro: LabVIEW Example
  • Sign in to reply

Top Comments

  • genebren
    genebren over 7 years ago +4
    Jan, Nice update on your project. I look forward to following your progress on this project. Maybe this will convince me to look further into Arduino as a potential for future projects. Good luck on your…
  • mcb1
    mcb1 over 7 years ago in reply to Jan Cumps +2
    I tend to have my Arduino in C:\Development\Arduino\ *whatever version* I have multiple versions of the IDE which worked out useful when there was a bug ... it worked on a earlier version so it wasn't…
  • jomoenginer
    jomoenginer over 7 years ago in reply to mcb1 +2
    If the library will not be used in other applications, you could just add a 'src' folder where the .ino file is located and add your code there. You would then need to reference the files with the 'src…
  • Andrew J
    Andrew J over 4 years ago in reply to jc2048

    My 32KB 4Duino (Leonardo equivalent) kept grinding to a halt.  The issue is that when you ask the framework if there are any errors, it pops one off the stack if it exists OR it creates a new empty one and returns that.  These are all allocated in dynamic memory and that empty one is never deallocated.  Problem being that to determine if an error occurred you have to ask and you always get one!  The solution is to either (a) deallocate the memory for that empty error in your own code; or (b) change the framework to manage errors a bit better.  Given it’s not being maintained, then (b) is not a totally unsuitable approach.  Strange actually, because it properly manages the SCPI tokens it creates, just not the error tokens.  I don’t know if the Vrekrer implementation has fixed this - did it not use this one as a base or was that yet another library??? I forget, as you say there’s a few out there now.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • jc2048
    jc2048 over 4 years ago in reply to Jan Cumps

    That's an interesting idea. I'll have a look at that.

     

    I hadn't considered the error status return at all, but I'm sure it can be wangled somehow.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • jc2048
    jc2048 over 4 years ago in reply to Andrew J

    I'm getting a little bit confused with all this [there are too many Jans in the world, aren't there!].

     

    I need it to be lightweight to run on an UNO, so you're saying that rules out the Breuer one [which, from my cursory glance at the git page, does look like it's done reasonably well].

     

    I was curious about the Vrecker one, mainly because it appears in the Library Manager so it's very easy to use in an Arduino project.

     

    It sounds like I should stick with the original one. How did you find the memory leak? Did you do that with the Arduino IDE somehow, or were you using a different processor and other tools?

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 4 years ago in reply to jc2048

    You could use the error handler for that purpose, maybe: If the parser detects an error, throw it over the wall to the meter?

    And whatever the meter sends back, relay to the host?

     

    In general, it would work.

    You'd have to refine the error querying. Because you will have to be able to report error status on any of the two instruments when SYST:ERR queries are fired.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Andrew J
    Andrew J over 4 years ago in reply to jc2048

    You will want something to do that in that case Jon.  The library Jan and I have used here works, but it does have a memory leak in the error handling code (easily fixed) and I found it necessary to write a fair bit of processing code with it.  It’s not maintained but I don’t think that’s an issue as it’s pretty simple and quick to get going.  The library you point out didn’t convince me that much so I haven’t tried it.  The Jan Breuer library scpi-parser looks very complete but may be too big for an Arduino depending upon the rest of the sketch.  The examples are enough to get you going but, not being a C/C++ programmer of any experience, I’ve had to trawl through the code to work out what I need to do as it isn’t well commented and the documentation, although much better than most libraries out there, is still a bit lightweight and possibly not up to date.

     

    For something simple, I’d go with the one discussed originally by Jan.  I may well swap back to it.  I also could provide a more comprehensive working example for you as well if you need it.

    • Cancel
    • Vote Up +1 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