Author Topic: EEVacademy #9 - Implementing SCPI in C++  (Read 8748 times)

0 Members and 1 Guest are viewing this topic.

Offline EEVblogTopic starter

  • Administrator
  • *****
  • Posts: 37728
  • Country: au
    • EEVblog
EEVacademy #9 - Implementing SCPI in C++
« on: October 19, 2018, 12:13:18 am »
David explains how to implement a SCPI "Skippy" instrument control command parser in C++

 

Offline riyadh144

  • Supporter
  • ****
  • Posts: 111
Re: EEVacademy #9 - Implementing SCPI in C++
« Reply #1 on: October 19, 2018, 06:11:29 am »
Thank you very much for this it is very helpful, as an FYI, there is a wonderful library that I used to implement a SCPI interface for a testing instrument I am making, it is super complete and not hard to use, it is written in C and so it is easily portable to anything.
 http://j123b567.github.io/scpi-parser/basic/.

We need more David2 videos he is very knowledgeable and gives an alternate view.
 
The following users thanked this post: thexeno

Offline prasimix

  • Supporter
  • ****
  • Posts: 2023
  • Country: hr
    • EEZ
Re: EEVacademy #9 - Implementing SCPI in C++
« Reply #2 on: October 20, 2018, 04:03:21 pm »
I'm wondering what was David's primary motivation for making his own SCPI parser. @riyadh144 already mentioned one that is mature and "field proven": It is used as basis for H24005 SCPI support (feel free to test everything online here just to got an idea: "front panel" display is clickable, load can be apply by clicking and hover over left and right).
We learned over the time that serious SCPI support is not a simple task (like any other good piece of software anyway), and even with decent SCPI parser one could be a pretty busy to make everything well done, and safe what is of paramount importance for any PSU as sourcing type of T&M device.

Offline SilverSolder

  • Super Contributor
  • ***
  • Posts: 6126
  • Country: 00
Re: EEVacademy #9 - Implementing SCPI in C++
« Reply #3 on: October 21, 2018, 12:16:02 am »

The Python language could be a good choice for SCPI and even GPIB programming.

It works on pretty much any computer (including Raspberry Pi), easy to learn, very suited for data / scientific / technical processing.

It is an interpreted language, so you can sit and play with all the GPIB instruments from the command line without compiling an application (unlike C++)

C++ is a bit of a firebreathing monster if you don't intend to become a professional, full time programmer.
 

Offline Dave

  • Super Contributor
  • ***
  • Posts: 1352
  • Country: si
  • I like to measure things.
Re: EEVacademy #9 - Implementing SCPI in C++
« Reply #4 on: October 21, 2018, 11:29:56 am »
Python, being an interpreted language, is a slow and resource consuming behemoth that is completely unsuitable for a piece of test equipment, which should primarily be responsive.
<fellbuendel> it's arduino, you're not supposed to know anything about what you're doing
<fellbuendel> if you knew, you wouldn't be using it
 

Offline filssavi

  • Frequent Contributor
  • **
  • Posts: 433
Re: EEVacademy #9 - Implementing SCPI in C++
« Reply #5 on: October 21, 2018, 12:08:44 pm »
Python, being an interpreted language, is a slow and resource consuming behemoth that is completely unsuitable for a piece of test equipment, which should primarily be responsive.


Honestly no offence but of you can’t make a responsive python application for a modern instrument (so likely cortex core A9 at 600 MHz to a GHz (NXP Im.x Xilinx zynq class MPU) then you are doing something really really wrong and you should quit programming altogether.

So stop spreading FUD about python...

It isn’t the fastest languages in town, but that is fine, it isn’t meant to be but if your responsiveness benchmark is the human eye (60Hz at best) you don’t need it
 
The following users thanked this post: nugglix

Offline Berni

  • Super Contributor
  • ***
  • Posts: 4946
  • Country: si
Re: EEVacademy #9 - Implementing SCPI in C++
« Reply #6 on: October 21, 2018, 03:51:43 pm »
I like C and its my most used language, but i have to admit something like python is indeed more suitable. Sure C is fast but its also clumsy for working with strings and quicly doing something usefull with the data in just a few lines if code.

SCPI is in itself ineficent because its human readable ASCII. A lot if instruments like DMMs dont give a lot of data anyway and pretty much no scope can saturate a 1Gbit LAN connection so even a slow laguage can keep up with the flow of data.

I personaly like C# for this as its a nice middle ground between fast C and flexible scripting like Python
 

Offline apblog

  • Regular Contributor
  • *
  • Posts: 108
  • Country: us
Re: EEVacademy #9 - Implementing SCPI in C++
« Reply #7 on: October 22, 2018, 04:39:05 am »
I just wanted to say that this code is a good first effort, but a bit misguided as far as parsers go.

I suggest reading the first few chapters of the dragon book to get an idea of how to think about a problem like this.

“Compilers: Principles, Techniques, and Tools”, Aho, et. al.

 
The following users thanked this post: chimerahitman, nugglix

Offline Dave

  • Super Contributor
  • ***
  • Posts: 1352
  • Country: si
  • I like to measure things.
Re: EEVacademy #9 - Implementing SCPI in C++
« Reply #8 on: October 23, 2018, 05:00:36 pm »
Python, being an interpreted language, is a slow and resource consuming behemoth that is completely unsuitable for a piece of test equipment, which should primarily be responsive.
Honestly no offence but of you can’t make a responsive python application for a modern instrument (so likely cortex core A9 at 600 MHz to a GHz (NXP Im.x Xilinx zynq class MPU) then you are doing something really really wrong and you should quit programming altogether.

So stop spreading FUD about python...

It isn’t the fastest languages in town, but that is fine, it isn’t meant to be but if your responsiveness benchmark is the human eye (60Hz at best) you don’t need it
Using a Cortex A9 for something as basic as a power supply seems rather excessive. For something that has to do a reasonable amount of processing, I could see it being useful, but for setting a bunch of DACs and occasionally reading an ADC, it seems way too costly (you also need an expensive PCB and other bells and whistles to go with it).

Python would be a very nice choice for coding the PC-side interface, though.
<fellbuendel> it's arduino, you're not supposed to know anything about what you're doing
<fellbuendel> if you knew, you wouldn't be using it
 

Offline metrologist

  • Super Contributor
  • ***
  • Posts: 2199
  • Country: 00
Re: EEVacademy #9 - Implementing SCPI in C++
« Reply #9 on: October 23, 2018, 06:58:15 pm »
Thanks for this. I will review again when I have more time. A few observations, I think the proper form of the example keyword is :HELLo. Also, sens is usually optional, so does that make the following keywords within the sense subsystem root keywords?
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf