10-12-2011 03:14 AM
Hi brad,
Thanks for the response.
I've attached a sample of the data to be analysed.
Auto steps as follows :
Auto select all channels beginning with 'D' or message box to manually select.
divide channel by 3600000, then Integrate - store result in new channel with original channel name but appended with '_Ah'
Auto maxvalue for each new channel and sum all maxvalues together..
I would like to auto select a range of values to be analysed but I will try do this as i learn !
Regards
AdeK
Solved! Go to Solution.
10-12-2011 06:31 PM
Hi AdeK,
I don't see the attached data file(s).
Brad Turpin
DIAdem Product Support Engineer
National Instruments
10-14-2011 04:09 AM
Hi Brad,
I'll try to attach the file again- this time I'll zip it !
Adek
10-19-2011 04:24 AM
Hi Brad,
I am continuing to try to understand how to automate the integration calculation. I've tried using the 'for each' loop (for an unknown number of channels), but the integrate function doesn't seem to recognise the variable for the channel ..
Will continue experimenting, but if you can point me in the right direction, maybe all with become clear...
I will await your reply.
AdeK
Option
Explicit'Forces the explicit declaration of all the variables in a script.
dim
oMyChannels, oMyChn
Set
oMyChannels = Data.GetChannels("Analogue & HS CAN/D*")
For
Each oMyChn inoMyChannels
CallChnIntegrate("[1]/Time (s)","oMyChn","/Integrated") '... XW,Y,ECallChnPropValSet("Integrated","name","Integrated""&oMyChn.Name&")
Next
10-19-2011 08:55 AM
Hi adek,
I apologize for not answering quickly after you posted your data set. The For Each loop in your posted code looks fine, except that that you have "oMyChn" as the second parameter, when you should have just oMyChn as the second parameter. If you have an old version of DIAdem, you might have to use oMyChn.Properties("Number").Value instead, but the last several version should accept oMyChn.
Let me know if that doesn't clear up the error,
Brad Turpin
DIAdem Product Support Engineer
National Instruments
10-19-2011 11:34 AM
Hello Brad,
I have altered the script and now it runs, but the new channels which I thought would be named 'Integrated DF1' upto 'integrated DV_88 etc, are named :
Integrated"&oMyChn.Name& upto Integrated"&oMyChn.Name&98 ,therefore the ChnPropValSet is not working correctly..
Can you help with this ?
Thanks again for your help.
AdeK
10-19-2011 12:01 PM
Hi adek,
Here's a VBScript that does what I understood you to be asking for-- it integrates all the "D*" channels, naming the new channels with an "_Ah" suffix and divides them each by 3600000, finally summing all the maxima of the integral channels. Note that some of the integral channels have a negative maximum, so there's some positive and negative cancelling going on in that summation.
Dim Group, Channels, TimeChannel, DataChannel, NewChannel, Sum Set Group = Data.Root.ChannelGroups(1) Set TimeChannel = Group.Channels(1) Set Channels = Data.GetChannels(Group.Name & "/D*") Call Group.Activate For Each DataChannel In Channels Call ChnIntegrate(TimeChannel, DataChannel, DataChannel.Name & "_Ah") Set NewChannel = Group.Channels(DataChannel.Name & "_Ah") Call ChnLinScale(NewChannel, NewChannel, 1/3600000, 0) Sum = Sum + CMax(NewChannel) Next ' DataChannel MsgBox Sum
Brad Turpin
DIAdem Product Support Engineer
National Instruments
10-20-2011 03:34 AM
Hi Brad,
The code works perfectly, all I need to do now is understand the steps to it's creation !
Thanks again.
AdeK