Modify Maury’s ATS Instrument Drivers in Microsoft Visual Studio Environment Introduction Maury’s ATS software package comes with a large number of instrument drivers that support most of the test and measurement equipments from different vendors (HP/Agilent, Rohde & Schwarz, Anritsu, and so on) already on the market today. However, depending on the end user application, specific driver may need some minor modification in order for the driver to complete the task the way the user wants. Maury provides source codes for all instrument drivers that come with ATS software, except tuner driver, so that any users can modify, test, and recompile the driver according to user’s test routines. This application note describes detailed procedures on how to modify an instrument driver from an existing one. Note: All ATS instrument drivers are written in C/C++ language and starting ATS software version 5.0, all drivers are compiled using Microsoft Visual Studio 2005. The user can use any version available, but the procedure in this document will be described for use with Microsoft Visual Studio 2005. How does the driver communicate with the instrument and the main software? Except power supply and volt/current meter driver, all drivers such as VNAs, Signal Generator, Spectrum Analyzers, Power Meter, etc. are compiled into executable (*.exe) files. Only power supply drivers and volt/current meters are compiled as dynamic link library (*.dll) files and are called by a single “Bias.exe” file. This way, one executable file can control multiple power supply (up to six; one input, one output and four auxiliary biases) or power supply with multiple channels at the same time, making it a lot easier and simpler for the main SNP software to handle the measurement. Figure 1. Normal instrument drivers as executable files Figure 2. Power supply drivers calling dll files All drivers in ATS software are named according to the instrument’s category, and below are a list of categories that are used in ATS software, and the naming convention of the driver in each category. • ACP Analyzer – acp*.exe • Current Meter – im*.dll • Noise Figure Meter – nfm*.exe • Power Meter – pm*.exe • Power Supply – ps*.dll • Spectrum Analyzer – sa*.exe • Signal Generator – src*.exe • RF switch – sw*.exe • Tuner – tun*.exe (No source code access for the user) • Volt Meter – vm*.dll • VNA – vna*.exe The User driver (user*.exe) is also supported so that user can control any other instruments not in the category above and write custom routines using the template (userdemo.c) provided in ATS software and compile it into executable file. Every source code includes header section which describes the instrument information and the modules required for SNP main application. User can modify or add custom routines in each module or function to make it work the way the user want. Most of the time, it only require minor changes of SCPI commands or add additional commands for particular instrument for special purposes, so all the user need is the programming manual of the instrument and the SCPI commands that need to be sent to the instrument. Figure 3. Require function for all Signal Generator drivers. Instruments fall into different category will have different required functions. Modify the function usually is just copy and paste the block for send and receive GPIB command, or just simply change the SCPI command, since different instrument model use different command. Below is the example of how the GPIB commands are being sent and received to the signal source. strcpy(command,"*IDN?"); i = write_string(src_data->source.bin_address,command); if (i) return(1); i = read_string(src_data->source.bin_address,id,50); if (i) return(1); Modify and Compile drivers as executable (.exe) File • Start Microsoft Visual Studio 2005. • Open the source code (*.c or *.cpp) of the driver to be modified from the Drivers directory (by default C:\Program files\Maury\ATSxxx\Drivers). • Rename the file and save it in the same directory. • From Visual Studio, Select FileÆOpenÆProject/Solution, and browse for “DrvTest.sln”, by default, it will be in the directory C:\Program files\Maury\ATSxxx\Drivers\DrvTest. Note: If ATS software is older than version 5.1, only “DrvTest.dsw” is available, which is for older version of Visual Studio. But, it can still be loaded into the Visual Studio 2005 and converts it to the 2005 format. • After loading the solution, There will be four files under the solution “DrvTest”, gpib_ni.c, Two *.c files and one *.rc file. • • Leave only the gpib_ni.c and delete the rest of the files under “DrvTest” project. Right click on “DrvTest”, select AddÆExisting item, and open the file that have been renamed for modification. Also *main.c and *main.rc from the same category need to be • • • • • loaded into the project for compiling the driver. For example, if the driver to be modify is acp*.c, acpmain.c and acpmain.rc also need to be loaded into the project. Double click on the *.c file (example src83700.c) and start modification. After finishing modification, save the file and select BuildÆRebuild solution. Make sure it compiles successfully without any errors. Depending on the build configuration (Debug or Release), an executable file named “DrvTest.exe” will be created under, by default, C:\Programfiles\Maury\ATSxxx\Drivers\DrvTest\Debug (or) Release. Test or debug the driver and make sure it works the way it supposes to. Rename the file DrvTest.exe to any file name and copy it to the Drivers directory, and it will be ready to use for the SNP main application. Modify and Compile Drivers as Dynamic Link Library (.dll) File • Start Microsoft Visual Studio 2005. • Open the source code (ps*.c, vm*.c, or im*.c) of the driver to be modified from the Drivers directory, by default, C:\Program files\Maury\ATSxxx\Drivers. • Rename the file and save it in the same directory. • From Visual Studio, Select FileÆOpenÆProject/Solution, and browse for “DrvTestDll.sln”, by default C:\Program files\Maury\ATSxxx\Drivers\DrvTestDLL. Note: If ATS software is older than version 5.1, only “DrvTestDll.dsw” is available, which is for older version of Visual Studio. But, it can still be loaded into the Visual Studio 2005 and converts it to the 2005 format. • After loading the solution, There will be four files under the “Source Files” of the solution “DrvTestDLL”, gpib_ni.c, DrvDlg.c, DrvDlg.rc, and another *.c file, which is the source code for the driver. • • • • • • • Delete the driver source file (example ps662x.c) and leave the rest of the files unchanged. Right click on “Source Files”, select AddÆExisting item, and open the file that have been renamed for modification. Double click to open the source codes and start modification. After finishing modification, save the file and select BuildÆRebuild solution. Make sure it compiles successfully without any errors. Depending on the build configuration (Debug or Release), an executable file named “DrvTestDll.dll” will be created under, by default, C:\Programfiles\Maury\ATSxxx\Drivers\DrvTestDLL\Debug (or) Release. Test or debug the DLL and make sure it works the way it supposes to. Rename the file DrvTestDll.dll to any desired file name and copy it to the Drivers directory and it will be ready to be called by Bias.exe. Test and debug modified driver In order to debug the driver, the build configuration needs to set it to “Debug” mode. User can also put break point (F9) at any line within a function and step through line by line (F10) and see the send/receive of GPIB commands in debug mode. Test and debug for normal executable driver • After successfully compiled the driver, user can enter the debug mode from DebugÆStart Debugging, or by just pressing F5 key. • Stand alone driver test window will pop-up and user can test every routine in each function to make sure that the instrument is behaving the way the user programmed. Test and debug DLL for power supply driver • After successfully built the DrvTestDll.dll, User can debug it using “Bias.exe” by selecting from DebugÆStart Debugging or just simply press F5 key. • If debugging for the first time, a window will pop-up and asking for executable file that calls the DLLs, and browse for “Bias.exe”, by default, in will be in the directory C:\Program files\Maury\ATSxxx\Drivers, then press OK. • A warning message “No Debugging Information” window will pop-up and select “Yes”, since “Bias.exe” was compiled in released mode. If “Bias.exe” was compiled in debug mode, the warning message should not appear. • Stand alone test driver for ‘Bias.exe” window will appear and Select TestÆFind to open the bias instruments setting window, and browse for the DLL to debug and configure the instrument correctly (see the sequence below). • Once the DLL and instrument parameter are properly configure, user can test and debug the routine in each function to make sure that the instrument behave the way the user want. Conclusion Maury instrument drivers are very flexible and easy to modify so that anyone with little or no programming experience can write or modify the driver and programs any instrument from existing templates. All the user need is the programming manual and Microsoft Visual Studio for compiling the driver. However the user must be familiar with the test routines and know what command he/she wants to send to the instrument and what parameter to be expect in return.
© Copyright 2026 Paperzz