DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Determining time at a given channel value

Solved!
Go to solution

I have a simple DIAdem script question.  I have a dataset with two channels: 1.) Time and 2.) Switch_1.  "Switch_1" has boolean values (0 or 1... off or on).  Throughout the file, the "Switch_1" changes from 0 to 1 many times.  I want to wrtie a script to determine the time period that "Switch_1" is equal to 1.  Can anyone help me do this? 

0 Kudos
Message 1 of 7
(5,735 Views)

Hi Dan,

 

If I had a sample of your data, I could send you a more functional script, but here are the main components I'd recommend:

 

1) Create a "Delta Time" channel that shows the time elapsed between each point, using the ChnDeltaCalc() command

2) Set to zero all values in the "Delta Time" channel where the "Switch_1" channel = 0, using the Calculate() command

3) Return the sum of all the values in the edited "Delta Time" channel, using the CCh(Channel, 4) command

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 2 of 7
(5,709 Views)

Brad,

Attached is an example of some data that I am working with.  Can you help me with a more functional script?

-Dan

0 Kudos
Message 3 of 7
(5,630 Views)
Solution
Accepted by Dan_TestENGR

Hi Dan,

 

Sorry for the delay.  Please put the two attached scripts in the same folder somewhere, then run the "Count State Duration.VBS" in the DIAdem SCRIPT panel.  It will pop up a file dialog-- select the TDMS file you sent me.  It loads the file, calculates the delta times, splits the values by switch state into a "0" group and a "1" group, then calculates the sum of all the delta times for each group.  You can find the result in each group's "Description" property and each "Duration" channel's "Description" property.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

Download All
0 Kudos
Message 4 of 7
(5,568 Views)

Hi Brad,

I am interested in a similar calculation, but with a few variations.  I am interested in determining the delta time from when “Aliases\OUTPUTS\CHOPPER_ENGAGE” [turquoise waveform] switches from 1 to 0 [BLACK arrow] and “[2]/Targets\cRIO9081-150HP\Hardware\Chassis\NI-XNET\CAN\AF9230\Incoming\Single-Point\UCM1_STATUS10 (419389568)\SpreaderSpeed” [violet waveform] reaches 0 [RED arrow]. 

 

The performed operation occurs in 3000 cycles so I would like this analyzed for each cycle. 

 

What would be most helpful is a table with the following columns that I could analyze in Excel:

 

  • Column 1:  [1]/Targets\cRIO9081-150HP\User Channels\Counters\CycleCounter_Ctr
  • Column 2:  System or Absolute Time when CHOPPER_ENGAGE switches from 1 to 0
  • Column 3:  System or Absolute Time when SpreaderSpeed reaches 0

We started and stopped the test a few times so I have approximately [10] files to analyze but I can copy the table output to Excel each time I perform the calculation. 

 

Can you please point me in the right direction for this analysis?  

 

Thank you very much. 

Download All
0 Kudos
Message 5 of 7
(2,848 Views)

Hi Brad,

I am interested in a similar calculation, but with a few variations.  I am interested in determining the delta time from when “Aliases\OUTPUTS\CHOPPER_ENGAGE” [turquoise waveform] switches from 1 to 0 [BLACK arrow] and “[2]/Targets\cRIO9081-150HP\Hardware\Chassis\NI-XNET\CAN\AF9230\Incoming\Single-Point\UCM1_STATUS10 (419389568)\SpreaderSpeed” [violet waveform] reaches 0 [RED arrow]. 

 

The performed operation occurs in 3000 cycles so I would like this analyzed for each cycle. 

 

What would be most helpful is a table with the following columns that I could analyze in Excel:

 

  • Column 1:  [1]/Targets\cRIO9081-150HP\User Channels\Counters\CycleCounter_Ctr
  • Column 2:  System or Absolute Time when CHOPPER_ENGAGE switches from 1 to 0
  • Column 3:  System or Absolute Time when SpreaderSpeed reaches 0

 

We started and stopped the test a few times so I have approximately [10] files to analyze but I can copy the table output to Excel each time I perform the calculation. 

 

Can you please point me in the right direction as to how to analyze this?

 

Thank you very much. 

Download All
0 Kudos
Message 6 of 7
(2,848 Views)

Hi ATarman,

 

First I would recommend making a new post as this one already has a solution marked, this will lead to higher visibility!

 

As a good place to start:

  1.  Create a "Delta Time" channel that shows the time elapsed between each point, using the ChnDeltaCalc() command
  2. Some initial thoughts that I had were to utilize something like this function to determine when the value goes to 1 or zero:
    1. https://forums.ni.com/t5/DIAdem/Finding-Time-When-Waveform-Passes-Set-Threshold/td-p/3328849
    2. https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z000000P6u6SAC&l=en-US
  1. Then you can use the difference between where the points hit zero and one to calculate dt

 

 

It sounds like this will be similar to what was done on this post which may provide some insight: https://forums.ni.com/t5/DIAdem/Formula-for-finding-channel-value/td-p/1234321

0 Kudos
Message 7 of 7
(2,830 Views)