Author Topic: Program that can log from many multimeters.  (Read 517640 times)

fricci and 5 Guests are viewing this topic.

Offline HKJTopic starter

  • Super Contributor
  • ***
  • Posts: 2937
  • Country: dk
    • Tests
Re: Program that can log from many multimeters.
« Reply #3475 on: May 30, 2024, 03:54:52 pm »
#idString GS,A3
#name GS A3
#handle A3
#driver Modbus
#port comfixedbaud
#baudrate 19200E81
#value Firmware Unit INT
#initCmd address 5
#scpiCmd Firmware? holding? 0x8000
#askValues Firmware;

Note Firmware? and Firmware is not the same string (? in difference). Yes, I know it was me making that mistake in my example, sorry about that.

Use: #askValues Firmware?;

;; A3: Tx <Firmware?>
;; A3: Tx <holding?  0x8000>
;; COM6: Tx: 05 03 80 00 00 01 AC 4E
;; COM6: Rx: 05 03 02 01 20 49 CC
;; A3: Rx <288>
;; 288

What you see here is TC stepping through the different driver levels with the multitude of TX/RX lines:
;; A3: Tx <Firmware?>  You orginal command
;; A3: Tx <holding?  0x8000> Procesed by #scpiCmd
;; COM6: Tx: 05 03 80 00 00 01 AC 4E Processed by Modbus driver and feed to the serial interface
;; COM6: Rx: 05 03 02 01 20 49 CC Received from the serial interface
;; A3: Rx <288> Processed by the Modbus driver
;; 288  The final result.
 
The following users thanked this post: fricci

Online fricci

  • Contributor
  • Posts: 11
  • Country: it
Re: Program that can log from many multimeters.
« Reply #3476 on: May 30, 2024, 07:35:51 pm »
It works!  :)

Thank you very much for your help!
 

Offline jmurray

  • Contributor
  • Posts: 34
  • Country: au
Re: Program that can log from many multimeters.
« Reply #3477 on: May 31, 2024, 12:29:32 am »
Is there a way around this? I've tried declaring it as a string but that doesn't seem to stop Test Controller splitting it on the semicolon.

I do not remember where I split the commands, but you can try two different ways:
Use \x3b instead of ;
Use ascii driver.

Hi HKJ,

Thanks for the suggestions.
I have tried the following:
  • \x3b instead of ; with standard SCPI driver
  • Ascii driver
  • \x3b instead of ; with Ascii driver

Unfortunately in all cases, Test Controller still splits a single line command into multiple separate commands to transmit.

In reading further, I think I may have misunderstood your suggestion to use the Ascii driver - Are you suggesting I define a custom #scpiCmd to handle this issue? If I could do that with the normal SCPI driver I could probably live with it, but having to list all the existing functional SCPI commands that receive a response under the Ascii driver is a bit painful.
Trying to define it as an Ascii driver also decimates the #otherData functions unfortunately.

For reference, the instrument in question is an Agilent E4360A, so the SCPI implementation is not an unusual one from a questionable manufacturer.
I realise that because Test Controller already inherently splits on the ; it is potentially a major headache to find a work-around - without knowing how your program is structured I don't really know what to suggest.

I'd like to think the best solution would be to declare a #pgm# for use with the standard SCPI driver, but only if there was some way to wrap a string with quotes that would ensure that Test Controller transmits that string exactly instead of splitting it on the semicolon.
I'm very interested in any other suggestions you might have.

Thanks!
 

Offline thephil

  • Regular Contributor
  • *
  • Posts: 70
  • Country: de
    • Techbotch
Re: Program that can log from many multimeters.
« Reply #3478 on: June 01, 2024, 02:06:15 pm »
I am working on a TC config file for the UNI-T UDP3305S power supply (https://github.com/philpagel/udp3305s) and I have a basic question:

Is there a best practice for #initCmd and #finalCmd? E.g. should I turn off all outputs on exit? And/or lock/unlock the keypad?

Oh – and I can't get the connection via RS232 to work: If I use a terminal program, I can issue commands and they work, but TC doesn't detect it. I had a look at the documentation and is says that I can add additional parameters to the baud rate setting but I'm not sure I understand the example. Is this correct?


   _________ Baud rate           
  |   ______ Parity on(O)/off(o) ???
  |  | _____ Data bits
  |  || ____ Stop bits ???
  |  ||| ___ DTS: high(D)/low(d)   
  |  |||| __ RTS: high(R)/low(r)
__|__|||||                   
19200O71Dr


The docs also say "The last letter can be H for DTR flow control (Windows only) or h or RTS flow control." So 19200O71Drh would be valid, too?

I am on LINUX – do I have to configure the correct serial device ( /dev/ttyUSB0) somewhere?

Thanks for your input.

Phil
« Last Edit: June 01, 2024, 03:35:53 pm by thephil »
It's never too late to have a happy childhood!
 

Offline HKJTopic starter

  • Super Contributor
  • ***
  • Posts: 2937
  • Country: dk
    • Tests
Re: Program that can log from many multimeters.
« Reply #3479 on: June 02, 2024, 07:50:11 am »
Is there a best practice for #initCmd and #finalCmd? E.g. should I turn off all outputs on exit? And/or lock/unlock the keypad?

If you make you definition to fully control the device I will recommend disabling/enabling  keyboard in #initCmd/#finalCmd
Both #finalCmd and #outputOff turns outputs off.


Oh – and I can't get the connection via RS232 to work: If I use a terminal program, I can issue commands and they work, but TC doesn't detect it. I had a look at the documentation and is says that I can add additional parameters to the baud rate setting but I'm not sure I understand the example. Is this correct?


   _________ Baud rate           
  |   ______ Parity on(O)/off(o) ???
  |  | _____ Data bits
  |  || ____ Stop bits ???
  |  ||| ___ DTS: high(D)/low(d)   
  |  |||| __ RTS: high(R)/low(r)
__|__|||||                   
19200O71Dr


The docs also say "The last letter can be H for DTR flow control (Windows only) or h or RTS flow control." So 19200O71Drh would be valid, too?

The parity letters are: N:none, E:Even, O:Odd, M:Mark, S:Space
If you specify flowcontrol, there is no point in specifying if the signal is high/low.

I am on LINUX – do I have to configure the correct serial device ( /dev/ttyUSB0) somewhere?

You have to enable access to the serial device for the user on linux. In TC you specify the serial port in the address field (Right click with the mouse when editing to get the correct names).

 
The following users thanked this post: thephil

Offline HKJTopic starter

  • Super Contributor
  • ***
  • Posts: 2937
  • Country: dk
    • Tests
Re: Program that can log from many multimeters.
« Reply #3480 on: June 02, 2024, 07:54:39 am »
I'd like to think the best solution would be to declare a #pgm# for use with the standard SCPI driver, but only if there was some way to wrap a string with quotes that would ensure that Test Controller transmits that string exactly instead of splitting it on the semicolon.
I'm very interested in any other suggestions you might have.

I will see if I can do anything.
 

Offline thephil

  • Regular Contributor
  • *
  • Posts: 70
  • Country: de
    • Techbotch
Re: Program that can log from many multimeters.
« Reply #3481 on: June 02, 2024, 01:54:39 pm »
Excellent! Serial connection is working no, too.

It looks like my config is now fully functional. But there is one thing I cannot figure out. Upon startup, testcontroller gives me an error or warning:

Code: [Select]
> TestController.jar
Starting
Unknown mode: NORMAL
Known modes:

And nothing after that. I believe, that it has to do with my output selection radio buttons. But I am not sure:

Code: [Select]
#cmdSetup radio Output_Mode
:read: SOURce:Mode?
:readFormat:
:write: SOURCE:Mode #
:string:
:updatealloff:
:updatedelayed: 0.5
Normal NORMAL
Serial SER
Parallel PARA

Any hints where to look and how to track this down? I tried with #metaDebug but that didn't really show anything suspicious.

Apart form the message, everything seems to be working fine...
It's never too late to have a happy childhood!
 

Offline thephil

  • Regular Contributor
  • *
  • Posts: 70
  • Country: de
    • Techbotch
Re: Program that can log from many multimeters.
« Reply #3482 on: June 02, 2024, 03:11:29 pm »
Now I am trying to define the generic interface:

Code: [Select]
#interfaceType PS:1 PS:2 PS:3                   
#interface setVoltage APPLY CH(channel),(value)V                                     
#interface setCurrent APPLY CH(channel),(value)A                                     
#interface getVoltage APPLY? CH(channel),VOLT                                         
:readmath: getElement(value,1, ",")                                                   
#interface getCurrent APPLY? CH(channel),VOLT                                         
:readmath: getElement(value,1, ",")                                                   
#interface setOn OUTPUT:STATE CH(channel),(value)                                     
#interface getOn OUTPUT:STATE? CH(channel)                                           
:string:

That seems to work. However, I have two more "channels" for serial and parallel mode, respectively. Unfortunately, they are not referred to as "CH4" and "CH5" but "SER" and "PAR". So e.g. #setVoltage would have to be APPLY SER,(value)V. At the moment I have no idea how to accomplish that...

Any hints welcome.
It's never too late to have a happy childhood!
 

Offline HKJTopic starter

  • Super Contributor
  • ***
  • Posts: 2937
  • Country: dk
    • Tests
Re: Program that can log from many multimeters.
« Reply #3483 on: June 02, 2024, 06:14:22 pm »
It looks like my config is now fully functional. But there is one thing I cannot figure out. Upon startup, testcontroller gives me an error or warning:

Code: [Select]
> TestController.jar
Starting
Unknown mode: NORMAL
Known modes:

That error is from either: #askMode value? or #modeFromValue getElement(value,0)
 
The following users thanked this post: thephil

Offline HKJTopic starter

  • Super Contributor
  • ***
  • Posts: 2937
  • Country: dk
    • Tests
Re: Program that can log from many multimeters.
« Reply #3484 on: June 02, 2024, 06:21:04 pm »
Now I am trying to define the generic interface:

Code: [Select]
#interfaceType PS:1 PS:2 PS:3                   
#interface setVoltage APPLY CH(channel),(value)V                                     
#interface setCurrent APPLY CH(channel),(value)A                                     
#interface getVoltage APPLY? CH(channel),VOLT                                         
:readmath: getElement(value,1, ",")                                                   
#interface getCurrent APPLY? CH(channel),VOLT                                         
:readmath: getElement(value,1, ",")                                                   
#interface setOn OUTPUT:STATE CH(channel),(value)                                     
#interface getOn OUTPUT:STATE? CH(channel)                                           
:string:

That seems to work. However, I have two more "channels" for serial and parallel mode, respectively. Unfortunately, they are not referred to as "CH4" and "CH5" but "SER" and "PAR". So e.g. #setVoltage would have to be APPLY SER,(value)V. At the moment I have no idea how to accomplish that...

Any hints welcome.

You need to use a bit scripting and then channels must be called 4 and 5:
https://lygte-info.dk/project/TestControllerFunctions%20UK.html#getElement

Instead of CH(channel)
use CH(getElement(channel,"1 1 2 3 SER PAR"))
The reason for the two 1 is because the list is zero based, this way both 0 and 1 will return 1.

 
The following users thanked this post: thephil

Online fricci

  • Contributor
  • Posts: 11
  • Country: it
Re: Program that can log from many multimeters.
« Reply #3485 on: Yesterday at 03:17:00 pm »
Can I use conditional if...then...else statements in a device definition file?

Any chance to add a modbus slave ID field in the "Load devices" tab? It is something strictly related to the device's address, then it would be nice if I could add it there.
 

Offline HKJTopic starter

  • Super Contributor
  • ***
  • Posts: 2937
  • Country: dk
    • Tests
Re: Program that can log from many multimeters.
« Reply #3486 on: Yesterday at 04:55:53 pm »
Can I use conditional if...then...else statements in a device definition file?

No, or mostly no. There is some conditions that can be used.
With #meta/#metadef you can add conditional sections for different devices thats mostly the same.
In the #askValues you can test for modes.

You can do:
#scpiCmd name #pgm#
#scpiCmd name? #pgm#
https://lygte-info.dk/project/TestControllerConfigDevice%20UK.html#Protocol_is_nearly_SCPI,_but_there_is_a_few_issues_(SCPIx)

and then use the full programming language, including if https://lygte-info.dk/project/Calculator%20UK.html#Programming
It looks something like this:
Code: [Select]
#scpiCmd MyInit #pgm#
if (portType!="GPIB")
  deviceWrite(handle,"SYST:REM;");
endif;

This command can then be used:
 #initCmd *RST;MyInit;


Any chance to add a modbus slave ID field in the "Load devices" tab? It is something strictly related to the device's address, then it would be nice if I could add it there.

The address field goes to the comm driver and not to the device driver, this makes it a bit difficult to add a extra value to it and pass it to the modbus driver. This makes it a bit difficult.
 
The following users thanked this post: fricci

Online fricci

  • Contributor
  • Posts: 11
  • Country: it
Re: Program that can log from many multimeters.
« Reply #3487 on: Yesterday at 05:33:27 pm »
The reason why I asked for  conditional statements is because I would like to show modbus error messages.

Suppose to write:
#scpiCmd Ratio? holding? 0x4001
:readmath: getElement("OK,Illegal Function,Illegal Data Address,Illegal Data Value,Slave Device Failure,Acknowledge,Slave Device Busy,Negative Acknowledge,Memory Parity Error,Gateway Path Unavailable,Gateway Target Device Failed to Respond",abs(value),"[,]")

This works perfectly in case of error, but it misses to return the correct numeric value when there is not any error. What I need is something like:
if value<0 then
 :readmath: getElement(...............)
else
:readmath:  abs(value)
endif

Do you have any suggestion to get this result?
 

Online fricci

  • Contributor
  • Posts: 11
  • Country: it
Re: Program that can log from many multimeters.
« Reply #3488 on: Yesterday at 06:01:45 pm »
The address field goes to the comm driver and not to the device driver, this makes it a bit difficult to add a extra value to it and pass it to the modbus driver. This makes it a bit difficult.
Just as I thought....
So, having a number of modbus devices to connect, the best choice it to write an equal number of definition files (with identical contents except with a slightly different #idString and a different slave ID hardcoded).
I suppose I cannot use the Setup menu to select the slave ID of each device....... using a single device definition file.
 

Offline HKJTopic starter

  • Super Contributor
  • ***
  • Posts: 2937
  • Country: dk
    • Tests
Re: Program that can log from many multimeters.
« Reply #3489 on: Yesterday at 06:05:06 pm »
The reason why I asked for  conditional statements is because I would like to show modbus error messages.

Suppose to write:
#scpiCmd Ratio? holding? 0x4001
:readmath: getElement("OK,Illegal Function,Illegal Data Address,Illegal Data Value,Slave Device Failure,Acknowledge,Slave Device Busy,Negative Acknowledge,Memory Parity Error,Gateway Path Unavailable,Gateway Target Device Failed to Respond",abs(value),"[,]")

This works perfectly in case of error, but it misses to return the correct numeric value when there is not any error. What I need is something like:
if value<0 then
 :readmath: getElement(...............)
else
:readmath:  abs(value)
endif

Do you have any suggestion to get this result?

There is a if operator you can use in this case, the ? operator:
:readmath:  value<0?getElement(...............):abs(value)
 
The following users thanked this post: fricci

Offline HKJTopic starter

  • Super Contributor
  • ***
  • Posts: 2937
  • Country: dk
    • Tests
Re: Program that can log from many multimeters.
« Reply #3490 on: Yesterday at 06:08:21 pm »
So, having a number of modbus devices to connect, the best choice it to write an equal number of definition files (with identical contents except with a slightly different #idString and a different slave ID hardcoded).
I suppose I cannot use the Setup menu to select the slave ID of each device....... using a single device definition file.

Use the #meta/#metadef system, it can easily be packed into one definition file.
https://lygte-info.dk/project/TestControllerConfigDevice%20UK.html#Creating_multiple_devices_from_one_configuration_file

You will want to use the #replacetext function
 

Online fricci

  • Contributor
  • Posts: 11
  • Country: it
Re: Program that can log from many multimeters.
« Reply #3491 on: Yesterday at 08:09:03 pm »
Great!  :)
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf