VEE has different Direct IO containers for different interface protocol. For example if we need to send command through LAN, we'll need to create an Direct IO for TCPIP interface. Same thing happen to GPIB, Serial and USB interfaces. Figure 1 shows the different Direct IO have to be created before we can use them.
Figure1: Instrument Manager in VEE
I dont like the traditional approach that add each Direct IO everytime when I want to send command to instrument. There are several reasons:
- Lets say I want to send few commands to instrument A, and after that I need to wait for 5 seconds before I send other commands. In this case, if we use the traditional way of putting everything into the Direct IO container, including the 5 seconds wait time, then I notice the VEE program just not responding for 5 seconds. Many colleagues complain VEE hang because they dont aware of this problem.
- Imagine you need to send few commands to Instrument A, then few more commands to instrument B. After that, you need to send commands to Instrument A again. In this case, we'll need to create 3 Direct IO containers.
- If you have a VEE software which is using an instrument with GPIB interface. For some reason, you need to use the LAN interface instead (may be newer instrument with LAN interface and same SCPI command). In this case, you'll have to change all the GPIB Direct IO to LAN Direct IO.
To avoid all these problems and keep my code clean, I created a solution/function library to allow me sending command (and query) with only 1 function call. The function, named as IO_Ex, basically takes 2 parameter: the resource string and the scpi command. It will evaluate the resource string and pass the scpi command to the proper Direct IO functions. The Direct IO functions are: IO_GPIB, IO_LAN, IO_USB and IO_ASRL. These functions contain the similar program blocks just with different Direct IO type. The function perform "Read", "Write" and "Query" based on the scpi command given.
Figure 2 shows the IO_Ex program blocks. Figure 3 shows one of the Direct IO function, IO_GPIB.
Figure 2: IO_Ex program blocks
Figure 3: IO_GPIB program blocks
So, when we need to send a query to instrument, we just need to call IO_Ex function. For example:
- IO_Ex("GPIB0::5::INSTR","*IDN?")
- IO_Ex("TCPIP0::123.123.123.123::INSTR","*IDN?")
- IO_Ex("USB0::1234::5678::12345678::INSTR","*IDN?")
- IO_Ex("ASRL1","*IDN?")
Note: I think newer version of VEE has a built in function for this purpose.
0 comments:
Post a Comment