The Pico SCPI labTool (PST) allows you to connect your PC to equipment to control and monitor all sorts of things. It runs on a Raspberry Pico. It would be nice if the PST could supports device dependent SCPI registers. They can be used to notify a LabVIEW flow from the device. I'd be happy if we can notify LabVIEW when a GPIO input changed logic level.
|
part 1: PST.. Experimental event / trigger support for Pico SCPI labTool - 1: investigate
part 2: PST.. Experimental event / trigger support for Pico SCPI labTool - 2: design the registers
part 3: PST.. Experimental event / trigger support for Pico SCPI labTool - 3: Instrument Specific Registers Test
part 4: PST.. Experimental event / trigger support for Pico SCPI labTool - 4: let TinyUSB USBTMC code use SCPI-LIB's Status Byte register
part 5: PST.. Experimental event / trigger support for Pico SCPI labTool - 5: Propagation to IEEE488.2 SCPI Registers Test
part 6: PST.. Experimental event / trigger support for Pico SCPI labTool - 6: Service Request from Instrument to LabVIEW flow
part 7: PST.. Experimental event / trigger support for Pico SCPI labTool - 7: Test Service Request from Instrument to LabVIEW flow
What does SCPI / LabVIEW need?
The first article I read is NI's Using Instrument Status Registers and Service Requests in LabVIEW. It explains the patterns that can be used to detect events on the PST. quote:
Watching and Responding to Events Watching and responding to events is the catch-all for handling various instrument events whose condition is set in one of the event registers. All IEEE 488.2-compliant instruments can watch for and respond to standard events such as instrument error conditions. However, many instruments also have instrument-specific status registers with which you can respond to measurement-specific events. For example, when using a DMM, you might want to be notified when a voltage overload condition occurs. On an oscilloscope, you might want to be notified when a trigger event occurs. |
For the PST, it will be useful if it can flag to LabVIEW if an input went high or low. This could be used in scenarios where a test setup has to wait for a user button press. Or if a sensor with logic level output is activated (proximity detector, optocoupler, …). The mechanism isn't real time, like a microcontroller interrupt event handler. But it's a settled SCPI pattern to detect and act on device events. LabVIEW has good handling for it.
What functionality is desired?
- register that one (or more) digital inputs should listen to status changes
- set a flag when such an event happens
- ability to enable / disable / clear
- support for more than 1 event?
Proof of successful implementation is when the firmware supports the register(s), and SCPI commands to deal with this.
The NI VISA Interactive Tester can be used to verify if these registers comply with the standards.
The experimental functionality will be ready for prime time when an example LabVIEW flow can perform those activities, using the standard blocks and patterns for this type of processing.
Prepare the SCPI parser configuration
You can follow along with this github issue, and see changes in this feature branch (will disappear once the development is merged with a project branch).
The SCPI parser has the mandatory IEEE 488.2 registers. It also allows instrument specific registers, if you change the parser's config.
The expected way to do that, is to create a file named scpi_user_config.h. The parser lib will include this file if you set the symbol PRIVATE SCPI_USER_CONFIG=1.
For Pico C SDK projects, you can set this define in the CMake file:
# enable use of scpi_user_config.h, to support custom device specific registers target_compile_definitions(pico_scpi_usbtmc_labtool PRIVATE SCPI_USER_CONFIG=1)
The parser lib will now include your custom definitions during the build. The first thing we tell the parser, is that we want to add instrument specific registers.
#ifndef _SCPI_USER_CONFIG_H #define _SCPI_USER_CONFIG_H #define USE_CUSTOM_REGISTERS 1
This will take care that the register API of the library gets to know our registers, and can talk to them.
If we don't define the complete set of needed registers, compilation will fail.
For the time being, I created an empty definition for all of these. It's a valid test to see if the user configuration mechanism works:
#define USER_REGISTERS #define USER_REGISTER_GROUPS #define USER_REGISTER_DETAILS #define USER_REGISTER_GROUP_DETAILS // TODO define custom status registers #endif // _SCPI_USER_CONFIG_H
I tested this, and the end result is that the build works, and that the firmware works as before. It's ready to support the user registers, but there are none defined yet.
That is the point where I wanted to get at, for this initial investigation.
Top Comments