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. Thank you Gough Lui for validating the design. |
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
Test Setup
I connected a push button to PST Digital In PIN 2 (GPIO27). That is the user button of shabaz' Pico Euroard. It pulls the pin low when pressed. I added a 10K pull-up resistor.
if you use push buttons or other mechanical contacts (relays, contactors) on an input pin, you should add a hardware debounce circuit, and a pull-up. The PST (intentionally!) does not use the internal Pico pull-up capability or a software debounce algorithm. |
As software test bed, I use NI VISA Interactive Control. The application allows me to easily submit SCPI commands, and can test the STB register and service requests.
Test scenario will systematically check
- if a change in status of the Digital Pin 2 (button push) has the desired effect on registers.
- does filtering work?
- can I propagate an event to the Operation Status register?
Test Instrument Specific Registers
test 1: DIGITAL IN CONDITION register
condition:
- If the user button is released, DIGI IN PIN2 is 1. Bit 2 of the DIGITAL IN CONDITION register must be 1
- If the user button is pressed, DIGI IN PIN2 is 0. Bit 2 of the DIGITAL IN CONDITION register must be 0
result;
1: button released
STATus:OPERation:DIGItal:INPut:CONDition?
4
2: button pressed
STATus:OPERation:DIGItal:INPut:CONDition?
0
pass
test 2: DIGITAL IN TRANSITION filters and DIGITAL IN EVENT register
condition:
- DIGITAL IN EVENT register Bit 2 should be 0
- If the user button is pressed or released, DIGITAL IN EVENT register Bit 2 should stay 0
- set DIGITAL IN NEGATIVE TRANSITION register Bit 2, validate if it is set
- DIGITAL IN EVENT register Bit 2 should stay 0
- Press the user button and release it. DIGITAL IN EVENT register Bit 2 should be 1
- Read Clear test: Query should clear the register. DIGITAL IN EVENT register Bit 2 should be 0.
result:
1: query initial state:
STATus:OPERation:DIGItal:INPut:EVENt?
0
2: push and release button, state should not alter because filter condition not met:
STATus:OPERation:DIGItal:INPut:EVENt?
0
3: enable negative transition bit 2, and query the register to see if it is set:
STATus:OPERation:DIGItal:INPut:NTRansition 4
STATus:OPERation:DIGItal:INPut:NTRansition?
4
4: query state again. Should be 0 because filter condition not met:
STATus:OPERation:DIGItal:INPut:EVENt?
0
5: push and release button, Should report that Bit 2 is 1 because filter condition (transition from 1 to 0) met:
STATus:OPERation:DIGItal:INPut:EVENt?
4
6: Query again. Should report that Bit 2 is 0 because a query clears the register:
STATus:OPERation:DIGItal:INPut:EVENt?
0
test 3: DIGITAL IN ENABLE register and propagation to IEEE488.2 OPERATION STATUS register
This is the handover from instrument specific register (PST registers) to the IEEE488.2 / SCPI standard registers. Can an event propagate to the OPERATION STATUS register, if enabled?
Propagation rule for DIGITAL IN: for enabled bits, the event register summary should propagate to OPERATION STATUS register Bit 0.
condition:
- By default, our exercise should not propagate. All previous tests should have been contained in the DIGITAL IN registers. OPERATION STATUS register Bit 1 should be 0
- set DIGITAL IN ENABLE register Bit 2 to 1 and read it back
- Query OPERATION STATUS register again. Bit 0 should still be 0.
- Press and release the user button. OPERATION STATUS register Bit 0 should stay 1
- Read Clear test: Query should clear the register. OPERATION STATUS register Bit 0 should be 0.
result:
1: query initial state:
STATus:OPERation:EVENt?
0
2: Enable propagation to OPERATION STATUS register by setting bit 2 of the DIGITAL IN ENABLE register to 1. Check if it is set:
STATus:OPERation:DIGItal:INPut:ENABle 4
STATus:OPERation:DIGItal:INPut:ENABle?
4
3: OPERATION STATUS register Bit 0 should still be 0, because we haven't generated an event yet after enabling the propagation:
STATus:OPERation:EVENt?
0
4: Press and release the button. This generates a negative transition, and should now propagate. Query if the OPERATION STATUS register Bit 0 is 1.
STATus:OPERation:EVENt?
1
5: Query if the OPERATION STATUS register read has cleared the register. Bit 0 should be 0.
STATus:OPERation:EVENt?
0
pass
Minimal SCPI commands to make a negative transition trickle through:
# set filter neg trans pin2
STATus:OPERation:DIGItal:INPut:NTRansition 4\n# enable propagation pin2
STATus:OPERation:DIGItal:INPut:ENABle 4\n
Can be tested with
STATus:OPERation:EVENt?\n
To make the fan-out work again, the event registers have to be reset.
Either by reading them, or by submitting the *CLS (clear Status) SCPI command.