From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Subtract a constant from values in a channel?

I am certain that this is not a difficult task, yet I the answer seems to be eluding me. I have a large number of channels, and I merely need to offset each channel by its respective initial value.  Since the channels are all named, I am having difficulty referencing the channels without an error.  Any assistance with writing this script would be greatly appreciated.

Thanks,
Ray Foltz
0 Kudos
Message 11 of 14
(1,487 Views)
Hello Ray!
 
I hope this script will solve your task:
Option Explicit

Dim i
Dim j
Dim n

For i=1 To GroupCount
  For j=1 To GroupChnCount(i)
    n = CNo("[" & i & "]/[" & j & "]")

    Call FormulaCalc("ch(" & n & ") := ch(" & n & ") - chd(1," & n & ")" )
  Next
Next
Matthias
Matthias Alleweldt
Project Engineer / Projektingenieur
Twigeater?  
0 Kudos
Message 12 of 14
(1,482 Views)

I know this thread is 10 years old, but it is still the first google result for "Diadem subtract by scalar". An alternative (an easier for me) method to do this is use the 3D Arithmetic channel functions and use Matrix-Scalar. Select your desired channel as the 1D matrix, enter the scalar (pay attention to the scalar's sign for subtraction), select where you store the result. Complete.

0 Kudos
Message 13 of 14
(594 Views)

Hi George,

 

To subtract a constant value from a channel.

Analysis, basic functions  Offset correction. This will do add or subtracts from all values in a channel.

to multiply use the function next to it  Scale a channel.

 

Paul

 

0 Kudos
Message 14 of 14
(593 Views)