Peter, Jon and I are building a Programmable Electronic Load. In this series of blogs I'm building a LabVIEW library of reusable components
In this first article: Initialising the instrument |
LabVIEW has a set of blocks to build flows with serial communication devices. Those blocks work well with our instrument.
However, inspired by the example for the Rigol DP8xxx family, I'm going to create more abstract blocks.
You can then use these in a LabVIEW flow.
To show the difference between using the serial blocks or a low level integration, check these two flows:
The first one uses the Serial blocks. You set all communication parameters and then can shoot SCPI commands and read them back.
You'll see that this is simple, but has no device or error management
When you look at the same flow using a (built in this blog) abstract block, it looks like this:
This block hides the communication settings that aren't configurable (the serial settings are fixed in the instrument's firmware).
It has additional support for device management (you can check if it's really our electronic load, you can reset it) and it supports LabVIEW device error management.
Initialize component
Here is the internal flow of that Initialize component:
I'll break this down into the lower levels. Note that each block that has a selector (the little rectangle in the middle of the top bar of a block) represents multiple flows.
The image just shows one of the possible ones (e.g. for the first block, it shows the process if the option to validate the instrument's IDN is set to True).
You expose the in and out parameters on the block's icon:
The elements that don't have a spot on the icon are private to the block. You can't set them from external.
For the Initialize block, the input parameters are
- VISA resource name eload
- delay before read (ms)
- ID Query (T/F)
- Reset (T/F)
- eror in (no error)
The output parameters are
- VISA resource name out
- error out
After running this block, the following functionality is performed:
- The VISA device that you pass to this block (it's serial so this will always be a COM port) will be opened, using the internal Serial settings of the block.
- If ID Query is set to True, the block will compare the instrument's ID string with "THEBREADBOARD,ELECTRONICLOAD".
If the instrument's string doesn't start with this string, the block will throw an error:
-1074003951: The ID Query failed. This may mean that you selected the wrong instrument or your instrument did not respond.
You may also be using a model that is not officially supported by this driver.
If you are sure that you have selected the correct instrument and it is responding, try disabling the ID Query. - If Reset is true, the block will execute the Reset block (this custom block will be discussed later). This will shoot a *RST SCPI command to the device.
Else it calls the Default block (also discussed later). That one sends a *CLS command. - If an error is detected, the VISA resource is closed and error info is passed to the caller.
Else the block passes the initiated device back to the calling flow.
Initialising the VISA resource
The first step in the block is to retrieve the VISA resource from the calling flow. You can also pass it the error stack from previous processes.
It will then initiate communication with the device, using the serial settings defined within this block (9600, 8, 1, N).
Query the Identifier
The image shows the two possible flows.
The first one is executed if you pass True for ID Query. The second one (that does nothing) when you pass False.
An *IDN? command is sent via the lower level VISA Serial block that comes with LabVIEW, the block waits 500 ms (passed via delay before read (ms)), reads the SCPI reply from the instrument and checks if the identifier starts with our check string.
If there's a match, this block doesn't touch the error info. If the identifier is not ok, we push an eror message on the stack and set the status to error.
It then hands over control to the next block.
Reset
Here are again two possibilities.
If you pass True to the Reset (True) signal, the flow calls the custom Default Instrument Setup block.
If you pass False to the Reset (True) signal, the flow calls the custom Reset block.
These two blocks are part of the library that we're building here and will be siscussed later.
Error
Also two possibilities. If the previous actions were successful, the block does nothing.
Else it closes the VISA resource and clears the VISA resource name out parameter.
Then control is handed back to the calling flow.
Top Comments