Test Controller, virtual devices

Virtual

Test controller has a collection of virtual devices, what is the purpose of these?

Contents
    Purpose
    Virtual square generator (VQG)
    Virtual sines generator (VSG)
    Virtual ramp generator (VRG)
    Virtual log generator (VLG)
    Virtual pattern generator (VPG)
    Virtual user generator (VUG)
    Virtual battery generator (VBG)
Main page



Purpose

The first ones where designed to test with, they are much faster for generating varying data than it is to use some physical device. With perfectly controlled waveforms I could also check that the calculations are correct (Both math and current values).

I let them stay in for a way to easily generate test data and play with test controller. When started without any devices defined it will ask if you want some virtual devices and on yes it will load them and start logging, making all pages accessible with data on them.

But they have one purpose more: They can control physical devices with a simple script. This means any parameter that can be controlled from TestController can easily be varied in a square/sinus/ramp/log-ramp/etc. values while logging data.
It is possible to load multiple copies of the same generator if multiple different control values of the same type are needed. For this to work multiple copies of the generator must be added to the "Load devices" list.

To use a script clear the log window and copy the script to the log window, configure the virtual generator and press the run button.
The scripts shown below will be available in the log windows right click menu if the generator and a power supply (ARB for log generator) is loaded. The script are not exclusive for power supplies, but can easily be modified to handle other devices:
Code:
; Replace this line:
=setVoltage(ps,VUG.Value);

; With something like:
handle:scpiCommand (VUG.Value)
; To control any scpi controllable parameter



Virtual square generator (VQG)

VQGChart

This generator can do any type of square waves or pulses. This can be used as on/off control or to change between two levels.

VQG

The setting menu has time and level settings.

Code:
#logcmds 0
=var ps=getDevice("PS");
=setCurrent(ps,3);
=setOn(ps,1);
#log 1
#while logInterval>0
=setVoltage(ps,VQG.Square);
#haslogged
#endwhile
Script to control a power supply.



Virtual sines generator (VSG)

VSGChart

Makes sine waves at low frequencies, they can be moved above the zero line with a offset setting.

VSG

The setting menu has period, offset and range settings.

Code:
#logcmds 0
=var ps=getDevice("PS");
=setCurrent(ps,3);
=setOn(ps,1);
#log 1
#while logInterval>0
=setVoltage(ps,VSG.Sine);
#haslogged
#endwhile
Script to control a power supply. Remember to add a offset to VSG making all values above zero.



Virtual ramp generator (VRG)

VRGChart

The ramp generator can me used for sawtooth or ramp waveforms.

VRG

The setting menu has time and level settings.

Code:
#logcmds 0
=var ps=getDevice("PS");
=setCurrent(ps,3);
=setOn(ps,1);
#log 1
#while logInterval>0
=setVoltage(ps,VRG.Ramp);
#haslogged
#endwhile
Script to control a power supply.



Virtual log  generator (VLG)

VLGChart

This generator makes a logarithmic raising or falling curve.

VLGChartLog

Using a logarithmic scale it is very obvious the output is logarithmic.

VLG

The setting menu has time and level settings.

Code:
#logcmds 0
=var arb=getDevice("ARB")
=setOn(arb,1);
#log 1
#while logInterval>0
=setFrequency(arb,VLG.Log)
#haslogged
#endwhile
Script to control the frequency on a ARB generator.


Virtual pattern generator (VPG)

VPGChart

With this generator any sequence of different levels can be generated, either with a ramp or abrupt jump between.

VPG

In the settings up to 10 levels can be defined with time, value and how to change to it. The generator supports entries up to 999, but only the first 10 can be defined from the configuration setup, the rest must be defined with SCPI commands.
It is easy to read the current settings with a SCPI command and then later use that answer to restore the same sequence (See ENTRIES command).

Code:
#logcmds 0
=var ps=getDevice("PS");
=setCurrent(ps,3);
=setOn(ps,1);
#log 1
#while logInterval>0 && deviceRead("VPG","busy?")
=setVoltage(ps,VPG.Value);
#haslogged
#endwhile
Script to control a power supply.



Virtual user generator (VUG)

VUGChart

With this generator any expression can be used to generate a curve.

VUG

The curve is in two section, one up, one down, it is possible to set either one to zero time.
When the down expression is empty the up expression is used with inverted sign.
Either upTime or downTime can be zero, this means either down or up expression is the only one used.
The expression can use x (0-1) and cycle that starts at 1 and increment for each cycle.
The cycle count will start over at 1 each time a new log is started.

VUGChart1

Using the result from the expressions (sin(x*pi)+cycles) directly, due to the +cycles the values will increase for each cycle.

VUGChart2

The "Level Jump disable" option will stitch the parts together without any jump between, in this case it basically eliminates the +cycles offset from the expression.

VUGChart3

Not all expressions are working well with the "Level Jump disabled" setting. Above is (exp(x*2)), it looks fine when it jumps to zero each cycle.

VUGChart4

But when disabling the "Level Jump" it will be a ever increasing curve.

Code:
#logcmds 0
=var ps=getDevice("PS");
=setCurrent(ps,3);
=setOn(ps,1);
#log 1
#while logInterval>0
=setVoltage(ps,VUG.Value);
#haslogged
#endwhile
Script to control a power supply.



Virtual battery generator (VBG)

VBGChart

This generator uses my battery test data to simulate a battery.

Duracell%20Plus%20Power%20AA-Capacity

Example of my battery data. I may not include all curves sometimes I expect interpolation to handle it fine enough.

VBG

The settings allows to simulate lower capacity for a faster test cycle and adjust the actual battery capacity at any time. More batteries can be used in series and extra internal resistance can be added to simulate an old battery or do a rough simulation of a smaller battery.
There is a couple of different batteries to select between, the selected models are focused on getting a wide selection of chemistries and size, not on specific brands.
I list curves from my tests that are used in the "Model" line, the generator will interpolate between these curves. Currents much above the highest included test current will set the voltage to zero. Discharge is not supported all the way to 0 volt, but is interpolated slightly further than the curves on my website.
The capacity listen is when discharging to the listed end voltage at low current, in many applications a higher end voltage or higher current is needed and the usable capacity will be lower.
To make the battery discharge specify a negative current.
The simulation only works for fairly steady current drain, it will not handle pulse drain and do not model charging very well.

Code:
#logcmds 0
vbg:soc 1
=var ps=getDevice("PS");
=setCurrent(ps,3);
=setOn(ps,1);
#log 1
#while VBG.Capacity>0
=setVoltage(ps,VBG.Voltage);
VBG:Current (-readCurrent(ps))
#haslogged
#endwhile
=setVoltage(ps,0);
#log 0
="Battery empty"
Script to reflect a battery to a power supply, the current drain is reflected back to VBG and means the charge status will match the used current.
Note: This script only works when "Capacity" is enabled, not with "UsedCap".