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

Gertjan and 593 Guests are viewing this topic.

Offline flash2b

  • Frequent Contributor
  • **
  • Posts: 938
  • Country: nl
  • Everything I like about myself is better with you.
Re: Program that can log/control many multimeters and other devices.
« Reply #6275 on: April 25, 2026, 05:31:32 pm »
I need to convert a string into a multiple 16bit values

Lets say my string is "abcde" the output should be 0x6162 0x6364 0x6500, how do I do that ?

It is like the reverse version of holdingBytes?

I have no luck with with <<8 and substring...

It is called packing ascii into 16bit big-endian order with zero-padding. 
« Last Edit: April 25, 2026, 05:35:22 pm by flash2b »
They say attention is a shovel. It's time to dig 'em out.
 

Offline HKJTopic starter

  • Super Contributor
  • ***
  • Posts: 4776
  • Country: dk
    • Tests
Re: Program that can log/control many multimeters and other devices.
« Reply #6276 on: April 25, 2026, 05:37:49 pm »
I need to convert a string into a multiple 16bit values

Lets say my string is "abcde" the output should be 0x6162 0x6364 0x6500, how do I do that ?

It is like the reverse version of holdingBytes?

I have no luck with with <<8 and substring...

It is called packing ascii into 16bit big-endian order with zero-padding.

You need to cast to bytes, but it looks like I am missing a substring function for bytes.
I.e. first use substring to get two chars, then cast it to bytes, then cast the bytes to int

A question: Can I use substring for this or do I need to make a subbyte function? It is easy to check the datatype in substring and modify the behavior if a byte array is used as argument, but it is not completely logical.
« Last Edit: April 25, 2026, 05:47:05 pm by HKJ »
 

Offline flash2b

  • Frequent Contributor
  • **
  • Posts: 938
  • Country: nl
  • Everything I like about myself is better with you.
Re: Program that can log/control many multimeters and other devices.
« Reply #6277 on: April 25, 2026, 05:47:48 pm »
I have tried that but I get Java exceptions

Code: [Select]
C1= int(bytes(substring( value ,0,1)))
C2= int(bytes(substring( value ,1,2)))
C3= (C1<<8)+C2

My input is a string and can have any length. However I only need to decode a portion of it that since the device has only place for 6 16bit packed value that I need to write with Modbus function 10.

« Last Edit: April 25, 2026, 05:51:57 pm by flash2b »
They say attention is a shovel. It's time to dig 'em out.
 

Offline HKJTopic starter

  • Super Contributor
  • ***
  • Posts: 4776
  • Country: dk
    • Tests
Re: Program that can log/control many multimeters and other devices.
« Reply #6278 on: April 25, 2026, 05:53:53 pm »
I have tried that but I get Java exceptions

Code: [Select]
C1= int(bytes(substring( value ,0,1)))
C2= int(bytes(substring( value ,1,2)))
C3= (C1<<8)+C2

My input is a string and can have any length. However I only need to decode a portion of it that since the device has only place for 6 16bit packed value that I need to write with Modbus function 10.

It would be more useful if you include the exception.
 

Offline flash2b

  • Frequent Contributor
  • **
  • Posts: 938
  • Country: nl
  • Everything I like about myself is better with you.
Re: Program that can log/control many multimeters and other devices.
« Reply #6279 on: April 25, 2026, 06:19:51 pm »
I got it working now

Code: [Select]
#scpiCmd writeDisplayText #pgm#
C1= int(bytes(substring( value ,0,1)))
C2= int(bytes(substring( value ,1,2)))
C3= int(bytes(substring( value ,2,3)))
C4= int(bytes(substring( value ,3,4)))
C5= int(bytes(substring( value ,4,5)))
C6= int(bytes(substring( value ,5,6)))
deviceWrite(handle,"holding 0x17 2");
deviceWrite(handle,"holding 0x05 "+ ((C1<<8)+C2) + " " + ((C3<<8)+C4) + " " + ((C5<<8)+C6) )

I have trouble to understand if I can have an expression in a function or that only variables. It is now both.

Can I do the above without the extra variables C1..C6 ?
« Last Edit: April 25, 2026, 06:25:27 pm by flash2b »
They say attention is a shovel. It's time to dig 'em out.
 

Offline HKJTopic starter

  • Super Contributor
  • ***
  • Posts: 4776
  • Country: dk
    • Tests
Re: Program that can log/control many multimeters and other devices.
« Reply #6280 on: April 25, 2026, 06:31:36 pm »
I got it working now

Code: [Select]
#scpiCmd writeDisplayText #pgm#
C1= int(bytes(substring( value ,0,1)))
C2= int(bytes(substring( value ,1,2)))
C3= int(bytes(substring( value ,2,3)))
C4= int(bytes(substring( value ,3,4)))
C5= int(bytes(substring( value ,4,5)))
C6= int(bytes(substring( value ,5,6)))
deviceWrite(handle,"holding 0x17 2");
deviceWrite(handle,"holding 0x05 "+ ((C1<<8)+C2) + " " + ((C3<<8)+C4) + " " + ((C5<<8)+C6) )

I have trouble to understand if I can have an expression in a function or that only variables. It is now both.

Can I do the above without the extra variables C1..C6 ?

You may get away with:
Code: [Select]
for i=1 to (length(value)+1)/2 do
deviceWrite(handle+":"+i*2,"holding 0x05 "+ int(bytes(substring( value ,i*2,i*2+2))));
endfor

I have not tested the code, i.e. it probably has a lot of errors, but the idea is valid.
« Last Edit: April 25, 2026, 06:34:10 pm by HKJ »
 

Offline flash2b

  • Frequent Contributor
  • **
  • Posts: 938
  • Country: nl
  • Everything I like about myself is better with you.
Re: Program that can log/control many multimeters and other devices.
« Reply #6281 on: April 25, 2026, 06:43:16 pm »
length is not a function, Java says. (Function not found length)

it should be for i=0 I guess.
« Last Edit: April 25, 2026, 06:50:22 pm by flash2b »
They say attention is a shovel. It's time to dig 'em out.
 

Offline HKJTopic starter

  • Super Contributor
  • ***
  • Posts: 4776
  • Country: dk
    • Tests
Re: Program that can log/control many multimeters and other devices.
« Reply #6282 on: April 25, 2026, 06:56:03 pm »
length is not a function, Java says. (Function not found length)

it should be for i=0 I guess.

Sorry, it is strlen() or size()
 

Offline flash2b

  • Frequent Contributor
  • **
  • Posts: 938
  • Country: nl
  • Everything I like about myself is better with you.
Re: Program that can log/control many multimeters and other devices.
« Reply #6283 on: April 25, 2026, 07:06:23 pm »
It is strlen().

Well also the holding register needs to count up and it now produces little endian  |O

I will fiddle with it, what I posted with the variables works for me but there is always ways to improve.

They say attention is a shovel. It's time to dig 'em out.
 

Offline HKJTopic starter

  • Super Contributor
  • ***
  • Posts: 4776
  • Country: dk
    • Tests
Re: Program that can log/control many multimeters and other devices.
« Reply #6284 on: April 25, 2026, 07:22:05 pm »
Well also the holding register needs to count up and it now produces little endian  |O

I added it to the handle, that was wrong, you have to add it to the address.

I will fiddle with it, what I posted with the variables works for me but there is always ways to improve.

There is often multiple ways to solve a issue with the programming language. I try to make it as flexible as possible.
 

Offline flash2b

  • Frequent Contributor
  • **
  • Posts: 938
  • Country: nl
  • Everything I like about myself is better with you.
Re: Program that can log/control many multimeters and other devices.
« Reply #6285 on: April 25, 2026, 07:39:14 pm »
Well also the holding register needs to count up and it now produces little endian  |O

I added it to the handle, that was wrong, you have to add it to the address.


Yes I caught that, but it needs to be written one time, so 1 holding with multiple values not multiple holding with 1 (16bit) value.

Reading it back I can do with holdingBytes? so that is easy.
They say attention is a shovel. It's time to dig 'em out.
 

Offline HKJTopic starter

  • Super Contributor
  • ***
  • Posts: 4776
  • Country: dk
    • Tests
Re: Program that can log/control many multimeters and other devices.
« Reply #6286 on: April 25, 2026, 08:22:07 pm »
Yes I caught that, but it needs to be written one time, so 1 holding with multiple values not multiple holding with 1 (16bit) value.

Reading it back I can do with holdingBytes? so that is easy.

I am not sure if you can collect the values in a string and use that as a parameter, but you can make a string with the full command and execute it (executeString()).
 

Offline HKJTopic starter

  • Super Contributor
  • ***
  • Posts: 4776
  • Country: dk
    • Tests
Re: Program that can log/control many multimeters and other devices.
« Reply #6287 on: April 26, 2026, 10:00:58 am »
I have uploaded a new test version, it support shared modbus.
It works the same was as GPIB and is configured in the same popup.

To use it a definition must have: "#port comfixedbaud modbus" or something similar, always specify com port first and modbus second!


This means I have been into the GPIB code and I do not have a GPIB setup at the current time, could somebody please verify it still works.


And a warning: Using multiple devices on the same modbus interface will reduce the maximum logging rate. TC has to fit all the communication onto the same wire, this means parallel reading do not work for these devices.
« Last Edit: April 26, 2026, 10:05:23 am by HKJ »
 
The following users thanked this post: flash2b

Offline flash2b

  • Frequent Contributor
  • **
  • Posts: 938
  • Country: nl
  • Everything I like about myself is better with you.
Re: Program that can log/control many multimeters and other devices.
« Reply #6288 on: April 26, 2026, 10:56:58 am »
I added parameter: Modbus Z Serial COM10 9600 to the submenu

My device is on Address: Z:1

But it does not see it, or connect to it.

My defintion has: #port comfixedbaud modbus

What do I need to do additional ?
« Last Edit: April 26, 2026, 11:05:46 am by flash2b »
They say attention is a shovel. It's time to dig 'em out.
 

Offline HKJTopic starter

  • Super Contributor
  • ***
  • Posts: 4776
  • Country: dk
    • Tests
Re: Program that can log/control many multimeters and other devices.
« Reply #6289 on: April 26, 2026, 11:05:13 am »
I added parameter: Modbus Z Serial COM10 9600 to the submenu

My device is on Address: Z:1

But it does not see it, or connect to it.

My defintion has: #port comfixedbaud modbus

What do I need to do additional ?

Select modbus for the device, i.e. click on the "Type" for the device and select modbus, instead of serial.
Put Z:1 in the address field.

 

Offline flash2b

  • Frequent Contributor
  • **
  • Posts: 938
  • Country: nl
  • Everything I like about myself is better with you.
Re: Program that can log/control many multimeters and other devices.
« Reply #6290 on: April 26, 2026, 11:06:51 am »
we were typing at the same time.

I needed to set Type to Modbus ...... !! and it connects !  :-+

I am so happy with this feature, thank you HKJ will start testing with multiple devices on the same modbus.

 :-+
They say attention is a shovel. It's time to dig 'em out.
 

Offline flash2b

  • Frequent Contributor
  • **
  • Posts: 938
  • Country: nl
  • Everything I like about myself is better with you.
Re: Program that can log/control many multimeters and other devices.
« Reply #6291 on: April 26, 2026, 11:18:50 am »
Is the update on https://lygte-info.dk/project/TestControllerInterfaceDefinitions%20UK.html not published yet ?

There is a little typo: #interfaceType thermomenter thermomenter:2 thermomenter:3 thermomenter:4 , should be 4 times: thermometer which then also can be updated with it together.

They say attention is a shovel. It's time to dig 'em out.
 

Offline HKJTopic starter

  • Super Contributor
  • ***
  • Posts: 4776
  • Country: dk
    • Tests
Re: Program that can log/control many multimeters and other devices.
« Reply #6292 on: April 26, 2026, 11:44:12 am »
Is the update on https://lygte-info.dk/project/TestControllerInterfaceDefinitions%20UK.html not published yet ?

Most of the time I first publish the updated documentation when I release the official version of TC.


There is a little typo: #interfaceType thermomenter thermomenter:2 thermomenter:3 thermomenter:4 , should be 4 times: thermometer which then also can be updated with it together.

Oops, fixed.
 

Offline flash2b

  • Frequent Contributor
  • **
  • Posts: 938
  • Country: nl
  • Everything I like about myself is better with you.
Re: Program that can log/control many multimeters and other devices.
« Reply #6293 on: April 26, 2026, 11:52:53 am »
That's what I thought.

There is a slight delay when TC connects to the new shared modbus interface when it shows: "Modbus interface created for shared communication" but other than that I works as before. I need to change some slaveIDs on my modbus devices and will then be able to string them together on the same port of my modbus interface. Some have dip switches while most I need to configure them with a command.


« Last Edit: April 26, 2026, 12:17:20 pm by flash2b »
They say attention is a shovel. It's time to dig 'em out.
 

Offline HKJTopic starter

  • Super Contributor
  • ***
  • Posts: 4776
  • Country: dk
    • Tests
Re: Program that can log/control many multimeters and other devices.
« Reply #6294 on: April 26, 2026, 12:18:12 pm »
There is a slight delay when TC connections to the new shared modbus interface when it shows: "Modbus interface created for shared communication" but other than that I works as before. I need to change some slaveIDs on my modbus devices and will then be able to string them together on the same port of my modbus interface. Some have dip switches while most I need to configure them with a command.

I do not know about a delay with one device, but with more devices there will be a delay.
I used a command to change address of device 1, then connected next device and did the same, before wiring them all to the same bus.
In my test setup I am running with 3 NT18B07
 

Offline dreamer

  • Newbie
  • Posts: 3
  • Country: ru
Re: Program that can log/control many multimeters and other devices.
« Reply #6295 on: April 27, 2026, 10:01:07 am »
Thank you, I will try! :)
 

Offline flash2b

  • Frequent Contributor
  • **
  • Posts: 938
  • Country: nl
  • Everything I like about myself is better with you.
Re: Program that can log/control many multimeters and other devices.
« Reply #6296 on: April 27, 2026, 01:57:30 pm »
I tried the new shared modbus function and it works !



The NT48A08 is now on address: 002 on the same RS485 port via COM5 to USB. My temperature reading script outputting the value on the DM18C04 still works, so test passed !

(Again) extremely happy !
« Last Edit: April 27, 2026, 02:30:44 pm by flash2b »
They say attention is a shovel. It's time to dig 'em out.
 

Offline HKJTopic starter

  • Super Contributor
  • ***
  • Posts: 4776
  • Country: dk
    • Tests
Re: Program that can log/control many multimeters and other devices.
« Reply #6297 on: April 27, 2026, 02:00:30 pm »
I tried the new shared modbus function and it works !

The NT48A08 is now on address: 002 on the same RS485 port via COM5 to USB. My temperature reading script outputting the value on the DM18C04 still works, so test passed !

And did you put the display on the same bus?

You serial numbers are not really good, they are the same for multiple devices and that confuses TC in some cases (It will still work, but they will change name each time you restart, if you have multiple devices with the same name)
« Last Edit: April 27, 2026, 02:02:47 pm by HKJ »
 

Offline flash2b

  • Frequent Contributor
  • **
  • Posts: 938
  • Country: nl
  • Everything I like about myself is better with you.
Re: Program that can log/control many multimeters and other devices.
« Reply #6298 on: April 27, 2026, 02:12:12 pm »
Yes they are on the same bus: Port1

My Modbus devices generally do not supply a serial number via a register nor do they have a printed serial# on the device themself (Ebyte does put a serial on the device as a sticker). So I generally set the serial in the definition (with some comments) and that is no problem if there is only one device. I have seen TC change the handle with a suffix when there were 2 devices with the same serial# and the same handles attached.

What is a better way to have a serial# when the device does not offer it over a interface command ?
« Last Edit: April 27, 2026, 02:19:34 pm by flash2b »
They say attention is a shovel. It's time to dig 'em out.
 

Offline HKJTopic starter

  • Super Contributor
  • ***
  • Posts: 4776
  • Country: dk
    • Tests
Re: Program that can log/control many multimeters and other devices.
« Reply #6299 on: April 27, 2026, 02:21:51 pm »
Yes they are on the same bus: Port1

My Modbus devices generally do not supply a serial number via a register nor do they have a printed serial# on the device themself (Ebyte does put a serial on the device as a sticker). So I generally set the serial in the definition (with some comments) and that is no problem if there is only one device. I have seen TC change the handle with a suffix when there were 2 devices with the same serial# attached.

What is a better way to have a serial# when the device does not offer it over a interface command ?

Leave it empty, if people what to add their own it is fine.
TC will base the _999 number on serial port, inet or modbus address if no serial number is found, this usually mean the number stays the same.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf