Autorun and AutoInit files
TestController has two files that can contains script that is automatically run upon start or load/reload of devices. These files can be used to create and initialize variables, open popups for specific devices and configurate devices.
The actual files are:
Autorun.txt this file will run once when TC is started.
AutoInit.txt this file will run every time TC load devices.
Contents
Viewing and editing the files
How to use the autorun.txt file
How to use the autoInit.txt file
More advanced use
A final warning
Script commands
Main page
Viewing and editing the files

The files are placed in the "Settings" directory and can be editing by any plain text editor. TC will not create these files, the user must create them.
The view option in the above menu will load and show these files or a message stating they do not exist.
The edit option will create the file and start the OS specified editor to edit them.
How to use the autorun.txt file
Because this file is only run when TC starts, it is best used for configuring settings in TC that are not automatic saved or for defining some variables.
For possible settings see the script commands page.
One example is to always use large font on the "Current values" page, the following setting will do that:
Code:
#CurrentValuesOptions 1000 large /s
It will also select a 1000 sample buffer.
One variable that is very useful to define is a NTC thermistor, to use it for fairly precise temperature measurement (Much more precise than thermocoupler) with any ohm-meter that TC supports.
To do that:
Buy one or more precision thermistors, preferable in the 10K to 100K range, where you can get a good datasheet.
Add a cable and banana jacks to the NTC and some heatshrink.
Put this line into the autorun.txt where the r and t are replaced with datasheet value for the temperature range you want:
Code:
globalvar ntc1=ntcCoef(r1,t1,r2,t2,r3,t3)
With this done add a formula on the "Math" page in TC:

The above is for a K34461 (i.e. Keysight 34461A) bench meter, but it can be for any DMM. When the meter is connected measuring with the NTC and this formula is enabled a temperature column will be added.
How to use the autoInit.txt file
This file runs when TC load devices, this makes it possible to set devices and open device related popups.
The first line in the file will usually be:
Everything after this line will first be run when the loaded devices are connected and ready.
If I always want my power supply to have the same settings when starting, I can add this to the autoinit file:
Code:
#if isLoaded("HMC8043")
HMC8043:INST OUT1
HMC8043:OUTP 0
HMC8043:INST OUT2
HMC8043:OUTP 0
HMC8043:INST OUT1
HMC8043:VOLT 5.0
HMC8043:INST OUT1
HMC8043:CURR 0.5
HMC8043:INST OUT2
HMC8043:VOLT 4.2
HMC8043:INST OUT2
HMC8043:CURR 0.3
#endif
To get these commands I configured my PS from the Setup menu in TC and then used the menu options shown below:

The #if statement must be added manually.
When I use my 34470 bench meter I may want a large readout on the computer like this:

I can make that automatic by adding:
Code:
#if isLoaded("K34470")
#Readout K34470.VoltageDC 460 45 5.1 red (204,255,153) 90 SI
#endif
Or a advanced readout for four DMM's:

Code:
#if isLoaded("K34470") && isLoaded("K34465") && isLoaded("DMM6500") && isLoaded("DMM7510")
#ShowPopupSystem GridPanel 305 58 1092 194
#GridPanel
#GridPanel 1 4
#GridPanel AdvancedDeviceReadout DMM6500 - (153,255,255)
#GridPanel AdvancedDeviceReadout DMM7510 - (204,204,255)
#GridPanel AdvancedDeviceReadout K34465 - (51,204,0)
#GridPanel AdvancedDeviceReadout K34470 - (0,255,102)
#endif
Note:
To get the #readout and #GridPanel script statement, configurate it manually and then select the function shown below:

This will list a script that restores this TC configuration. In this list you can find the lines you need and copy them.
More advanced use
Because both script and programming language can be used, it is possible to do thing dynamically, the above GridPanel popup can be automated to use any number of DMM's and automatic adjust its size depending on number of connected DMM's:



Code:
;Create a var to keep track on number of DMM's
=var dmcnt=0;
#if isLoaded("K34470")
=dmcnt=dmcnt+1;
#endif
#if isLoaded("K34465")
=dmcnt=dmcnt+1;
#endif
#if isLoaded("DMM6500")
=dmcnt=dmcnt+1;
#endif
#if isLoaded("DMM7510")
=dmcnt=dmcnt+1;
#endif
;Create the panel in the desired size, this is done indirectly, because I need expressions to adjust the panel
#if dmcnt>0
=runScript("#ShowPopupSystem GridPanel 305 0 "+(230*dmcnt)+" 210\n#GridPanel\n#GridPanel 1 "+dmcnt);
#endif
;Check and add each single active DMM to the panel
#if isLoaded("K34470")
#GridPanel AdvancedDeviceReadout K34470 - (0,255,102)
#endif
#if isLoaded("K34465")
#GridPanel AdvancedDeviceReadout K34465 - (51,204,0)
#endif
#if isLoaded("DMM6500")
#GridPanel AdvancedDeviceReadout DMM6500 - (153,255,255)
#endif
#if isLoaded("DMM7510")
#GridPanel AdvancedDeviceReadout DMM7510 - (204,204,255)
#endif
A final warning
As the above hopefully illustrate, it is possible to make TC do a lot of automatic stuff when loading devices, but be careful about overdoing it.
Another way to do the same stuff is to save it as a menu, then it has to be selected before it will do anything.
To do it as a menu:
- Write it in the log window, use "RUN" to test it.
- Then press "SAVE" and select "Save as menu"
- The menu entry will be added to the right click menu in the log window.