Customizing Tractor

Tractor is our open-source platform for automating production testing. It's designed to let you build out a comprehensive test plan for your product in minutes. Measurements such as gain, frequency response, THD and others can be made quickly. 

But what if you need to test something that isn't supported by Tractor out of the box? If your testing needs are complex, then writing your own software is one option. This can allow you to control every aspect of testing down to the smallest detail. But another option is to add the test to Tractor. 

You don't need to be a software whiz to do this. If you can recognize patterns and do a tiny bit of programming, you can probably create your own test. 

Suppose, for example, you wanted to measure the noise in a power amplifier between 30 and 40 kHz to look for a problem that occurs on some units due to an engineering issue. Normally, Tractor works at a fixed 48 kHz sampling rate. You'd need at least an 80 kHz sampling rate to make the RMS measurement from 30 to 40 kHz. 

Let's see how we could solve this.

1) Install Visual Studio 2022 from Microsoft. The community edition is free and will work fine. It's located here. You'll be building the Tractor app which is written in C#, so make sure to install the C# options. 

2) Download the Tractor source from Github. It's located here. On this page, you'll see a green button called "Code", and if you click on that, you'll see the option to download a ZIP file of the project. Click the "Download ZIP" option.

3) Unzip the zip into the directory of your choice.

4) Start Visual Studio 2022, and do a File-Open Project and select the QA Tractor.SLN file in the unzipped directory.

5) From the main menu in Visual Studio, pick Build->Build Solution. You will probably get two errors about the "mark of the web." This might sound scary, but this is Visual Studio telling you that the files came from the web and to be careful. You will need to mark the files as safe. Using the file explorer, navigate to each file in the directory you unzipped. Right click on the file, select "properties" and tick the "unblock"

6) Close Visual Studio, and re-start it. And then re-load the QA Tractor.sln file. The project should now build. Press the green "START" button at the top of the Visual Studio tool bar and the application should run. 

7) OK, so let's add a method to permit us to switch the QA40x to a higher sample rate. On the right side of Visual Studio, look for the Solution Explorer. Drill down as shown below until you locate the file QA40x.cs. Double click on that to open the source to that file. 


8) When the file opens, around line 53 add the following lines:

public void SetSampleRate(int sampleRate)


When added it, should appear as follows:

 9) Run the application again, and verify it starts. 

10) Next, go back into the solution explorer and locate the file RmsLevelA01.cs. 


11) Right click on this and select Copy. And then, select the parent directory called "GainLevel". Right click on that and select paste. You should now have a copy of that file as shown:

 12) Right click on the file we just copied and re-name it to MyRmsLevelA01.cs

13) Now, if you try to run, you'll have several errors. That is because you've duplicated a class name. So, open the MyRmsLevelA01.cs file and change the class name on line 11 to MyRmsLevelA01:

14) Next, there is still an error. We need to change the name of the constructor as shown:

15) Next, start Tractor again, and add a test. Set the Test Category to LevelGain, and you'll now see the test we added as an option.

16) If you add the test to your test plan, it will work exactly as it did before, which isn't very helpful. But now, let's add code to set the analyzer to a higher sample rate. To do this, navigate to around line 43 of the MyRmsLevelA01.cs file and add the following line:


The above line will call the code we added in the QA40x.cs file at the top of this post. Note that the line following this line is using an IAudioAnalyzer cast, while this line we added is using a QA40x cast. That means this test is specific to the QA40x products and wouldn't work on the QA401.

The result should appear as follows:

Let's talk about what is happening above. The DoTest() method is called when it's time for this test to run. In line 40, we put the analyzer into a default state. The next line sets some common parameters like FFT length, muting, etc. 

The line 43 we added then sets the sample rate to 96ksps, using the method (function) we added earlier. 

17) Next, move up to lines 23 and 26 in the file, and set the MaxValue for the RMS measurement Start and Stop to be 48000 as shown. Without this change, we'd still be at the higher sample rate but we couldn't enter frequencies higher than 20 kHz.

18) Now run the app, and you should be able to add the test and set the RMS measurement window from 30k to 40k. 

19) Now run the test, and you'll should see the sample rate get set to 96k on the analyzer, and the RMS measurement you requested will be made in the band you specified. 

And because this is your custom test, you can change everything you need about the test to function as needed. You could even add code to control other instruments, such as power supplies.