DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

How to increment a channel name

Hello, I am in the next situation:

1. Import a TDMS

2. Create a ChannelGroups

     2.1 Create Some Channels

3. Do some calculation using channels

4. Export data

5. Import another TDMS 

Repeat from steep 2.

 

Now, even if I load another TDMS, my calculation are the same for all tdms (restults from TDMS no. 1). My idea is to increment channels, but I do not know how to do this. Could you help me with an idea, please?

 

~~For Condition~~

Call DataFileLoad(test)

 

dim grp1: set grp1 = data.Root.ChannelGroups.Add("Output")
dim ch2: set ch2 = grp1.Channels.Add("Motor _Test 1",DataTypeChnString)
dim ch3: set ch3 = grp1.Channels.Add("DC _Test1",DataTypeChnString)
dim ch4: set ch4 = data.Root.ChannelGroups("Data").Channels("Time")
dim ch5: set ch5 = grp1.Channels.Add("Motor On Time _Test1",DataTypeChnString)
dim ch6: set ch6 = grp1.Channels.Add("Pauza _Test1",DataTypeChnString)

 

''''math'''

t1_time=ch4.Values(t1) ''start_motor_on_no.1

ch3.Values(i) = "DC" & "_" & j & " " & (t2_time-t1_time)/pauza*100

.....

'''end math''''

Call UIAutoRefreshSet (TRUE)

~~End for condition~~

 

There is a for condition witch allow me to load more file with variable "test".

If code run manually, uploading one by one TDMS, all works good. My problem is ch2, ch3, ch4, ch5, ch6 do not change value even if I load another file. My expectation is load TDMS 1 -> have some value for ch1-ch6-> upload TDMS 2-> Refresh-> have another value for ch1-ch6 because math is executed on another TDMS (different from TDMS 1).

I hope my explanation is good enough to create an idea about my problem.

 

Thank you in advance!

 

 

0 Kudos
Message 1 of 2
(541 Views)

Hey Alex.

 

As far I understand:

  • Your code works fine, if you apply it to one data file only. Means, your loop (with "test" as a selector) runs only once in this case. Then the program is done (with good results) and finishes.
  • Then you start it again for another sata file, and it works fine again.

Is it correct so far?

I'm wondering about the declarations in your code: do you define e.g. ch2 (by dim) and assign the channel (by set) inside the for-loop? Basically I would separate these parts: place DIM before the loop only, and SET inside. 

Did you get no errors here during the execution?

 

The "update = true" is at the end of your code; any specific reasons for this?

 

Greetings,

Vassili

 

0 Kudos
Message 2 of 2
(506 Views)