Author Topic: Program that can log/control many multimeters and other devices.  (Read 1676019 times)

Cyclotron and 248 Guests are viewing this topic.

Offline MrPete

  • Regular Contributor
  • *
  • Posts: 152
  • Country: us
Re: Program that can log/control many multimeters and other devices.
« Reply #6700 on: July 08, 2026, 03:19:07 pm »
@HKJ, I've run into some strangeness with respect to variables, variable initialization, and loops / script loading. Something is simply not acting the way it should (and is documented.)

AFAIK, if I initialize a variable like so:

=var foo=50
or
=globalvar bar=0.25

Whether in a script or program, every time that code is encountered, the value should be reset to the stated value. Correct?

Here are strange things I am seeing, with global variables:

* The first time it's encountered in a script, yes it is initialized properly

BUT... sometimes, or in some cases repeatably, it's not working that way when the same line is later encountered.

A. Settings variables
* I have some settings that are pre-initialized in global vars (eg testCurrent = 0.25)
* I use #popupnumber to let the user modify for that run (eg changing it to 0.05 )
* ISSUE: If I: abort the run, edit the file, load+run the file (which still contains the original preset), and click Run...

     * when the popup shows, it shows the value that the user last entered??!!

B. Big Loop
* My current big project has a big loop (a more in-depth battery tester. Repeatedly checks iR, drains N Ah, and repeats until drained)
* At the start of the loop there are a bunch of initialized global variables (global b/c they are needed in runScript() scripts)
* ISSUE: in a number of cases, the variables are NOT re-initializing for the next go-round!

* My attempted workaround, not sure if fully working yet due to C below: I am simply defining globalvar xyz; outside the loop, then assigning a value inside the loop. That seems to work better -- but should not be needed, correct?

C. SIMPLY CONFUSING
* This one I've not yet diagnosed. I am wondering if your newer debug flags might help me dig in deeper.
* AND, this used to be working without issues :( Not sure what I changed...

outside of any loop, during prelim setup, I've got (simplified a bit):
Code: [Select]
#calc
...
runScript("""# local long string that turns on logging, turns on load device, sets current, does an N second delay""");

printLog(""+timestamp()+": Done stabilizing");
if ( readVoltage(load)<termVoltage )
printLog("in test a");
whyTestStopped="Low Input Voltage: "+readVoltage(load);
printLog("in test b");
printLog("pre-Loop: TEST ABORT Before starting; Input Voltage too low. "+whyTestStopped);
printLog("in test c");
setOn(load,0);
printLog("in test d");
return;
printLog("in test e");
endif;
printLog("after test");

What I get:
* runScript all works
* I get the Done Stabilizing printLog
* Then, with logging still active, load still on -- "Abort" goes gray so presumably the script stopped.

Yet there's no exception or any other message in the debug log (other than ongoing log comm's until I stop it)
Any ideas most welcome.

I don't know how to debug this further.
(BTW is there a way to NOT log all device I/O while in debug? it's 99.9% distraction for what I'm doing now...)

 

Offline HKJTopic starter

  • Super Contributor
  • ***
  • Posts: 4898
  • Country: dk
    • Tests
Re: Program that can log/control many multimeters and other devices.
« Reply #6701 on: July 08, 2026, 05:37:09 pm »
Here are strange things I am seeing, with global variables:

* I use #popupnumber to let the user modify for that run (eg changing it to 0.05 )

This is the issue, all the popup deliver their result to a local variable, but will also check globalvar for initial value if no local var exist. The local var is then created and will override the globalvar on subsequent runs.

This is missing from the documentation.
 

Offline MrPete

  • Regular Contributor
  • *
  • Posts: 152
  • Country: us
Re: Program that can log/control many multimeters and other devices.
« Reply #6702 on: July 09, 2026, 12:16:38 am »
Here are strange things I am seeing, with global variables:

* I use #popupnumber to let the user modify for that run (eg changing it to 0.05 )

This is the issue, all the popup deliver their result to a local variable, but will also check globalvar for initial value if no local var exist. The local var is then created and will override the globalvar on subsequent runs.

This is missing from the documentation.

It sounds like you are close to diagnosing those, but not quite.

In the case of the presets / popups:
* This code is not part of any loop; it is executed once at the start of the script file
* So in simplified form, I have this type of code:

Code: [Select]
#calc
...
globalvar mySetting = 0.25;
..
// End of calc
#

#popupNumber "Prompt..." mySetting 0.05  25.0 "Mouseover tip"
...

does the globalvar and/or local var survive:
* Reloading the script file?
* Clicking reset before reload? (I may NOT have always clicked reset... don't remember)

In the case of loops
* I have no popups in the loop that has globalvar's not re-initializing.
* Is it possible that anything OTHER than a #popup UI might trigger this globalvar->local var thing? That would certainly override my globalvar initializer  :P
* I suspect you can see how this becomes quite painful!
* Any idea how to reset the localvar? or copy the globalvar to the localvar?

THANKS!
AFAIK there's no simple way to identify the global/local aspect of a given var... :(  (yes, can do getVarList() and scan it myself. ugh.
« Last Edit: July 09, 2026, 12:44:26 am by MrPete »
 

Offline HKJTopic starter

  • Super Contributor
  • ***
  • Posts: 4898
  • Country: dk
    • Tests
Re: Program that can log/control many multimeters and other devices.
« Reply #6703 on: July 09, 2026, 07:54:02 am »
It sounds like you are close to diagnosing those, but not quite.

The lifetime of a variable follows the script/program engine, when possible these are allocated once and then stays. I.e. local var can be long lived, but they are not accessible outside of their own engine (Except in called stuff and there they will not be local vars).
They will always override global vars of the same name and there is no way to get around that! I.e. you cannot read a global variable with the same name as a local variable.
TC has no way to delete/remove vars, you can only clear their contents (This can be useful for structs/arrays).
You can transfer values to a routine (if you call it) with parameters and then move the parameters to local vars

Generally functions do not create variables, popup is an exception to that, because it can have many input and output values. To avoid issues with other stuff it is safest for it to use local vars.
 

Offline MrPete

  • Regular Contributor
  • *
  • Posts: 152
  • Country: us
Re: Program that can log/control many multimeters and other devices.
« Reply #6704 on: July 09, 2026, 11:35:19 am »
The lifetime of a variable follows the script/program engine, when possible these are allocated once and then stays. I.e. local var can be long lived, but they are not accessible outside of their own engine (Except in called stuff and there they will not be local vars).
If I'm understanding this correctly...
* By defining an initialized globalvar for use in #popupnumber, what I'm actually doing in effect is setting up the "first run of this script" initializer, but NOT a value that will ever be referenced again when the script is re-run (because the globalvar becomes invisible the instant the local var is created by the #popup.)
* We haven't yet defined clearly what it takes to reset the script engine. Apparently, an Abort-then-Run sequence doesn't do it. (Trivially, exiting and restarting TC does do it ;) )

I'm also not yet clear on how this may impact re-initializing values in a loop that isn't using popup at all.

THANK YOU for thinking this through with me. I'm obviously accidentally touching some complex interactions in the way the multithreaded aspects of TC work. (Fortunately part of my background involves a lot of real time programming... this kind of stuff is typical...

Some initial conclusions:
* Be careful when defining and using globalvar's -- they are more complex than simply "a var that's visible everywhere"

* Be careful when using the calculator/programming in TC, and in particular runScript() -- the multiple contexts can require either globalvar or passed parameters to transfer or share variables... but there are subtle implications for that.
 

Offline HKJTopic starter

  • Super Contributor
  • ***
  • Posts: 4898
  • Country: dk
    • Tests
Re: Program that can log/control many multimeters and other devices.
« Reply #6705 on: July 09, 2026, 01:16:29 pm »
The lifetime of a variable follows the script/program engine, when possible these are allocated once and then stays. I.e. local var can be long lived, but they are not accessible outside of their own engine (Except in called stuff and there they will not be local vars).
If I'm understanding this correctly...
* By defining an initialized globalvar for use in #popupnumber, what I'm actually doing in effect is setting up the "first run of this script" initializer, but NOT a value that will ever be referenced again when the script is re-run (because the globalvar becomes invisible the instant the local var is created by the #popup.)

Correct for that instance.

* We haven't yet defined clearly what it takes to reset the script engine. Apparently, an Abort-then-Run sequence doesn't do it. (Trivially, exiting and restarting TC does do it ;) )

It cannot be reset (I could make a function for that), generally vars stay defined as long as that instance exist and TC tries to keep instances alive when possible.

I'm also not yet clear on how this may impact re-initializing values in a loop that isn't using popup at all.

There is not any special factors, if a local var exist it will override the global var.
The full list is: local, parent, parent of parent, ... , global
But in most cases no parent exist.

Some initial conclusions:
* Be careful when defining and using globalvar's -- they are more complex than simply "a var that's visible everywhere"

Not really, but be careful with popups that create vars.

* Be careful when using the calculator/programming in TC, and in particular runScript() -- the multiple contexts can require either globalvar or passed parameters to transfer or share variables... but there are subtle implications for that.

I believe runscript will be a child of the current instance. I.e. you also get parent vars in the list.

Another trick I can use is that vars are a separate entity (A varlist is just a struct var that is registered with the execution engine), this means I can share a varlist between multiple instances if I want. I do that in device definitions, but nowhere else.

 

Offline MrPete

  • Regular Contributor
  • *
  • Posts: 152
  • Country: us
Re: Program that can log/control many multimeters and other devices.
« Reply #6706 on: July 09, 2026, 02:42:48 pm »
The lifetime of a variable follows the script/program engine, when possible these are allocated once and then stays. I.e. local var can be long lived, but they are not accessible outside of their own engine (Except in called stuff and there they will not be local vars).
and runScript() doesn't count as "called stuff"... so local vars of the parent are available, correct?

[The script engine] cannot be reset (I could make a function for that), generally vars stay defined as long as that instance exist and TC tries to keep instances alive when possible.
Hmmm... I think that may be VERY handy. I have found that after running my script a couple of times, I need to exit and re-enter TC, or it will lock up completely on the next run, presumably some kind of java memory leak. :(

Being able to reset to a fresh state as if a new startup, with the current "load and run" script loaded, would save a lot of hassle when doing a sequence of many lab tests on a box of devices-under-test.


I'm also not yet clear on how this may impact re-initializing values in a loop that isn't using popup at all.
There is not any special factors, if a local var exist it will override the global var.
The full list is: local, parent, parent of parent, ... , global
So there really should NOT be interference in my big loop, other than the challenge of #popup settings.
#calcStart/#calcEnd and the improved error display has already helped me eliminate some other bugs. It may be that I can simply eliminate all of my globalvars and have a nice functioning system :)

I believe runscript will be a child of the current instance. I.e. you also get parent vars in the list.
I just created a test of this, with a) a normal script having b) a #calcStart that includes a c) runScript()

What I learned:
Inside (b) the #calcStart, all locals are level 1 locals.
Inside (c) the runScript(), what were level 1 are now level 2.

The only slightly strange thing is how the printLog(getVarsList(n)) output looks. Probably doesn't mean anything?...
* Global vars are emitted with no ";; " comment markers (whether listed while in script or program)
* Local vars are emitted with ";; " if defined during script, and with no ";; " if defined during program?!

The simple test is below. The "here" was actually many lines of =printLog(getVarsList(n))
Code: [Select]
=var line2var = 2;
=globalvar line3gvar = 3;

#calcStart
var line6var = 6;
globalvar line7gvar = 7;

runScript("""#
=var line10var = 10;
=globalvar line11gvar = 11;
=printLog("here");
""");
printLog("here");
#calcEnd
=printLog("here");

 

Offline HKJTopic starter

  • Super Contributor
  • ***
  • Posts: 4898
  • Country: dk
    • Tests
Re: Program that can log/control many multimeters and other devices.
« Reply #6707 on: July 09, 2026, 03:29:01 pm »
Being able to reset to a fresh state as if a new startup, with the current "load and run" script loaded, would save a lot of hassle when doing a sequence of many lab tests on a box of devices-under-test.

Generally I would not expect that to be necessary.

The only slightly strange thing is how the printLog(getVarsList(n)) output looks. Probably doesn't mean anything?...
* Global vars are emitted with no ";; " comment markers (whether listed while in script or program)
* Local vars are emitted with ";; " if defined during script, and with no ";; " if defined during program?!

It is very simple, I was lazy when I programmed the output routine. It outputs ;; and then the output, if the output is more than one line the subsequent lines will not get a ;; before them.

The idea with ;; is that "Clean" will remove these lines and nothing else. This means a script with ; for comments will not be removed, only the output from it.


I have added a deleteLocalVars({varName{,varName}}) function, it can delete a list of vars or without parameters it will delete all. Note varName means the variable name is in quotes (i.e. "myVar"), this is necessary because parameters are only the value, not the variable.

I have also added getGlobalVar(varName), it is similar to getVar(varName), but will only check the global var list.

----

I believe I will have to make a new release very soon, i.e. if anybody has stuff they want in it, now is the time to post it.
For now I have a lot of small changes/additions to TC and a few new devices.
 

Offline MrPete

  • Regular Contributor
  • *
  • Posts: 152
  • Country: us
Re: Program that can log/control many multimeters and other devices.
« Reply #6708 on: July 09, 2026, 04:35:48 pm »
@HKJ,not sure you can do more than document this. I found another source of my challenges:

Symptoms:
* the first part of my script ran,
* then it just died instantly, with no error or message. Logging continued, etc.

Thought about it,and tried this successful workaround:
* my guess: there is a limit to the size of a #calcStart/#calcEnd section
* so I inserted an end/start in places where I could. Simply
Code: [Select]
#calcEnd
#calcStart

It worked! Pretty good evidence.

For diagnosing this,and potential memory leaks or other related items...

Do you know of a way to display the size of allocated or available Ram in java/TC?
 

Offline HKJTopic starter

  • Super Contributor
  • ***
  • Posts: 4898
  • Country: dk
    • Tests
Re: Program that can log/control many multimeters and other devices.
« Reply #6709 on: July 09, 2026, 04:39:31 pm »
Symptoms:
* the first part of my script ran,
* then it just died instantly, with no error or message. Logging continued, etc.

Thought about it,and tried this successful workaround:
* my guess: there is a limit to the size of a #calcStart/#calcEnd section
* so I inserted an end/start in places where I could. Simply
Code: [Select]
#calcEnd
#calcStart

It worked! Pretty good evidence.

For diagnosing this,and potential memory leaks or other related items...

Do you know of a way to display the size of allocated or available Ram in java/TC?

There is not really supposed to a real limit, I have allocated million of samples in the table without issues and it uses the same memory pole.

Running TC in debug mode will output error messages to the dos window, they may reveal something.
 

Offline MrPete

  • Regular Contributor
  • *
  • Posts: 152
  • Country: us
Re: Program that can log/control many multimeters and other devices.
« Reply #6710 on: July 10, 2026, 02:24:08 am »
Running TC in debug mode will output error messages to the dos window, they may reveal something.
Is there any way to run in debug mode, without displaying all device IO debug info? That completely overwhelms other messages.
 

Offline flash2b

  • Super Contributor
  • ***
  • Posts: 1013
  • Country: nl
  • Everything I like about myself is better with you.
Re: Program that can log/control many multimeters and other devices.
« Reply #6711 on: July 10, 2026, 06:16:43 am »
Still a minor problem. The editable fields do not have a white background. Re-enabling on/of fill make them white but not after the first render of the menu,

The two controls are numberDual the other are number and they work just fine.

I have fixed it, but you do not get a new version just yet.

You have fixed (in TC v3.33) the :enabled: state, but the not :enabled: state, the numberDial is not consistent with the advNumber control



Other controls, like number, are like advNumber, so disabled gray text but still a white box in the input fields.

Enabling and Disabling makes it good again, but not on the first render of the menu (like the screen shot).
« Last Edit: July 10, 2026, 06:19:39 am by flash2b »
They say attention is a shovel. It's time to dig 'em out.
 

Offline HKJTopic starter

  • Super Contributor
  • ***
  • Posts: 4898
  • Country: dk
    • Tests
Re: Program that can log/control many multimeters and other devices.
« Reply #6712 on: July 10, 2026, 06:47:52 am »
Is there any way to run in debug mode, without displaying all device IO debug info? That completely overwhelms other messages.

The exception output to console is always active, i.e. running with the console open and without the debug flag would do that.
You will have to edit the debug bat file for that or create another bat file.

You can always for a exception with a calculator error, i.e. typing =1/0 on the command line will output a long exception dump to console output.
 

Offline flash2b

  • Super Contributor
  • ***
  • Posts: 1013
  • Country: nl
  • Everything I like about myself is better with you.
Re: Program that can log/control many multimeters and other devices.
« Reply #6713 on: July 10, 2026, 06:56:19 am »
Can you make the pull downs of Primary, Secondary en Tertiary slightly wider ?



I am aware of the Java problem, but if you shift Cmd and Log to there next grid position, there is enough space to make the pull downs wider.
They say attention is a shovel. It's time to dig 'em out.
 

Offline HKJTopic starter

  • Super Contributor
  • ***
  • Posts: 4898
  • Country: dk
    • Tests
Re: Program that can log/control many multimeters and other devices.
« Reply #6714 on: July 10, 2026, 08:07:33 am »
Can you make the pull downs of Primary, Secondary en Tertiary slightly wider ?

Fixed and you NumberDual issues is also fixed.
 

Offline flash2b

  • Super Contributor
  • ***
  • Posts: 1013
  • Country: nl
  • Everything I like about myself is better with you.
Re: Program that can log/control many multimeters and other devices.
« Reply #6715 on: July 10, 2026, 02:42:52 pm »
The Test Interface does not pick up the channels for AOutput, but is does for readout and PS.



My defintion has:

#interfaceType AOutput AOutput:2

If I change to PS, it works again

(may be also AInput)

Confirmed, same bug for AInput as well.
« Last Edit: July 10, 2026, 02:44:57 pm by flash2b »
They say attention is a shovel. It's time to dig 'em out.
 

Offline HKJTopic starter

  • Super Contributor
  • ***
  • Posts: 4898
  • Country: dk
    • Tests
Re: Program that can log/control many multimeters and other devices.
« Reply #6716 on: July 10, 2026, 02:57:04 pm »
The Test Interface does not pick up the channels for AOutput, but is does for readout and PS.

Fixed for both.

It is nice to have somebody checking/noticing errors, it helps me a lot.
 
The following users thanked this post: KungFuJosh

Offline flash2b

  • Super Contributor
  • ***
  • Posts: 1013
  • Country: nl
  • Everything I like about myself is better with you.
Re: Program that can log/control many multimeters and other devices.
« Reply #6717 on: July 10, 2026, 03:05:36 pm »
Well I should have caught it earlier when I did the modifications to my definitions. But you got it fixed, so great.

When I looked at the title of the menu, I spotted it and not seeing radio buttons made me wonder. I have also seen how you implemented it for many many channels with a drop down.
They say attention is a shovel. It's time to dig 'em out.
 

Offline flash2b

  • Super Contributor
  • ***
  • Posts: 1013
  • Country: nl
  • Everything I like about myself is better with you.
Re: Program that can log/control many multimeters and other devices.
« Reply #6718 on: July 10, 2026, 07:55:44 pm »
Dear HKJ,

I have added support for the Gauselink GL-TH30 with TH30 sensor 1CH Humidity & Temperature transmitter module to my existing definition.

Please add it to the next TestController release.

[ Attachment Invalid Or Does Not Exist ]
« Last Edit: July 10, 2026, 08:05:41 pm by flash2b »
They say attention is a shovel. It's time to dig 'em out.
 

Offline flash2b

  • Super Contributor
  • ***
  • Posts: 1013
  • Country: nl
  • Everything I like about myself is better with you.
Re: Program that can log/control many multimeters and other devices.
« Reply #6719 on: July 10, 2026, 08:05:29 pm »
Sorry I made an error.

Update attached

[ Attachment Invalid Or Does Not Exist ]

Edit: still not ok, see some posts below.
« Last Edit: July 10, 2026, 09:13:39 pm by flash2b »
They say attention is a shovel. It's time to dig 'em out.
 

Offline HKJTopic starter

  • Super Contributor
  • ***
  • Posts: 4898
  • Country: dk
    • Tests
Re: Program that can log/control many multimeters and other devices.
« Reply #6720 on: July 10, 2026, 08:07:49 pm »
Dear HKJ,

I have added support for the Gauselink GL-TH30 with TH30 sensor 1CH Humidity & Temperature transmitter module to my existing definition.

Please add it to the next TestController release.

Added (including update), thanks.

I hope it is a fairly cheap module, i.e. not much more expensive than a Arduino and a sensor.
 

Offline flash2b

  • Super Contributor
  • ***
  • Posts: 1013
  • Country: nl
  • Everything I like about myself is better with you.
Re: Program that can log/control many multimeters and other devices.
« Reply #6721 on: July 10, 2026, 08:17:55 pm »
This one was €11,79

All these modules have different sensors, and some lack software correction. I like finding out which sensor behave the best. It should be the SHT40 sensor, but you never know for sure that you get a genuine one. With modbus sharing you can run all of them using a single com port.  :D
« Last Edit: July 10, 2026, 08:48:20 pm by flash2b »
They say attention is a shovel. It's time to dig 'em out.
 

Offline HKJTopic starter

  • Super Contributor
  • ***
  • Posts: 4898
  • Country: dk
    • Tests
Re: Program that can log/control many multimeters and other devices.
« Reply #6722 on: July 10, 2026, 08:44:20 pm »
This one was €11,79

All these modules have different sensors, and some lack software correction. I like finding out which sensor behaves the best. It should be the SHT40 sensor, but you never know for sure that you get a genuine one. With modbus sharing you can run all of them using a single com port.  :D

I looked it up on google and it looks like it is in a box, that is not bad for the price.

Also note that the new version of TC will have a interpolation function that can be used to correct sensors with a documented output curve. Somebody was missing that a bit ago, I hope he sees that I am now supporting it.
 
The following users thanked this post: MrPete

Offline flash2b

  • Super Contributor
  • ***
  • Posts: 1013
  • Country: nl
  • Everything I like about myself is better with you.
Re: Program that can log/control many multimeters and other devices.
« Reply #6723 on: July 10, 2026, 08:56:36 pm »
This one? https://www.eevblog.com/forum/testgear/program-that-can-log-from-many-multimeters/msg6262076/#msg6262076

With temperature/humidity controller this is done in firmware.
They say attention is a shovel. It's time to dig 'em out.
 

Offline HKJTopic starter

  • Super Contributor
  • ***
  • Posts: 4898
  • Country: dk
    • Tests
Re: Program that can log/control many multimeters and other devices.
« Reply #6724 on: July 10, 2026, 09:02:36 pm »
This one? https://www.eevblog.com/forum/testgear/program-that-can-log-from-many-multimeters/msg6262076/#msg6262076

Exactly

With temperature/humidity controller this is done in firmware.

Humidity is hard to correct, because it is temperature sensitive and when non-linear it need a 2d interpolation (I have not added that).
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

-->