NI Home
Cart Cart | Help
Hello Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI
You are here: 
NI Home > NI Developer Zone > NI Discussion Forums


Reply
Member
sahani
Posts: 18
0 Kudos
Accepted Solution

Calculation in diadem

Hi, 

 

I am Trying to automate  the Report Generation by using the VB  script, I can do all the calculation in the Excel sheet but how I can implement the same in the Vb script.

 

I want to take a mean of 2 cell in X channel and output the sum in channel Y.   Y= X+(X-1)  / 2

then Multiply the channel Y with  9.8 to give the output in Channel Z.  Z= Y * 9.8 

 

I need to do all the calculation in all the cells. 

 

also I need to query a set of command in the Specific channel with 100 and 0 as the start and end points in the channel.

 

If any body can know I can implement this in the VB  scripts, It would be a great help. 

 

Thanks

Veer

Trusted Enthusiast
Brad_Turpin
Posts: 2,372
0 Kudos

Re: Calculation in diadem

Hi Veer,

 

Would it be acceptable to take the mean of 3 adjacent cells?  If so, you can use the ANALYSIS function "Smooth" in the "Curve Fitting" palette with a smoothing width of 1.  Then you can use the ANALYSIS function "Scale" in the "Basic Mathematics" palette to multiply the result by 9.8.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

Member
sahani
Posts: 18
0 Kudos

Re: Calculation in diadem

Hi Brad, 

 

thanks for the Solution, I done the calculation and it works properly. 

but I need some more help to do the rest of the calculation on my data. 

 

I have got Speed in Kmph and I need it to convert it in m/s which i can do manually in excel by V (Speed in m/s) =[V(kmph)*1000)/3600]

 

Then Calculate the stopping Distance of the vehicle by  d=-(((V^2)-(U^2))/(2*G))

   V= speed in m/s

  U = intial speed before U ie V-1 in m/s

 G= the accelaration I found out from the previous channel as per suggested by you.

 

then Save the d as a new channel and get the mean of all the data in the channel but only from 100 kmph to 0 kmph.

I need the query the speed channel for 100 kmph and 0 kmph or where the acceleration changes its sign from +ve to -ve.

 

We have done all these calculation in Excel but now I need to automate this in diadem  with dialog box which I have created, but I am finding diffculty in doing the calculation in Diadem.

 

if you can give me any idea on any of these would be a great help.

 

Thanks

Veer 

Trusted Enthusiast
Brad_Turpin
Posts: 2,372
0 Kudos

Re: Calculation in diadem

Hi sahani,

 

Let's take these steps one at a time.  First, in order to rescale your channel from km/h to m/s, you can use the ANALYSIS dialog "Scale"  in the "Basic Mathematics" palette, just enter "1000/3600" into the "Factor" field and leave the "Offset" field 0.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

Member
sahani
Posts: 18
0 Kudos

Re: Calculation in diadem

Hi Brad, 

 

I have now done the Kmph to m/s and it is correct, but now I want to go ahead with the remaining task and do the rest fo the calculation.

 

So, if you have any idea how I can achieve the rest. that would be a great help.

 

Regards

Veer

Trusted Enthusiast
Brad_Turpin
Posts: 2,372
0 Kudos

Re: Calculation in diadem

Hi Veer,

 

To do the distance calculation we'll need to either use the Channel Calculator or the Calculation Manager in DIAdem-- both of which will refer to your starting channels in the Data Portal by name or index.  So I need to see your data set before I can send you code that will work-- would you please post your data file to this forum or email it to me at brad.turpin@ni.com?

 

Also, left me confirm what I think you're saying with that "V-1" reference.  Do you want to calculate the stopping distance for each measured velocity value, based on the previous velocity value one row up?

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

Member
sahani
Posts: 18
0 Kudos

Re: Calculation in diadem

Hi Brad, 

 

I Can now calculate the stopping distance from the speed and initial speed. 

but still I am Struggling to query the speed channel for 100 kmph and the 0 Kmph, so that I can do summation on the all the stopping distance corresponding the the interval between the 100 kmph to 0 kmph.

 

There are 5 different start ( 100 kmph ) , stop ( 0 kmph) in the speed channel and I need to calculate summation of all  the stopping distance between all the 5 intervals.

 

Thanks

 

Regards

Veer

Trusted Enthusiast
Brad_Turpin
Posts: 2,372
0 Kudos

Re: Calculation in diadem

Hi Veer,

 

You never answered my question from yesterday about the "V-1" reference in your post, so I went ahead with my assumption that you meant the previous speed value.  This would give you the incremental distance between each speed data point-- I hope that's what you want.

 

You need to run the "ADO" DataPlugin in order to be able to load that Excel file you mailed me.  Then you can run the VBScript in the attached ZIP file to run through the calculations.

 

Does you data start in an ASCII file that you load into Excel?

Brad Turpin

DIAdem Product Support Engineer

National Instruments

Member
sahani
Posts: 18
0 Kudos

Re: Calculation in diadem

Hi Brad, 

 

I have emailed you today morning and I have mentioned that "V-1" is the previous speed in the previous one row up.

 

We generate DAT files and convert it to excel format to do all the calculation.  Yes, I want the each incremental distance between each speed data point which I can calculate now which I have programmed in diadem by using the Diadem help section.

 

but One more thing I need to do is to  to Add all the incremenatal distance of the speed Data but only for a interval from 100 kmph to 0 kmph. 

this occurs for 5 times and I need to calculate the total incremental distance all the 5 stops and this is a only one data files. 

 

I have checked in the Diadem help and I can calculate the mean distance by using the flags and using the analysis in stastical analysis tab, but It does only for 1 interval and I need to calculate 5 interval and also if u see the excel sheet there are some data points between 0 kmph to 100 kmph in incremental order of speed which I should be able to ignore and just do the summation only between 100 kmph to 0 kmph.

 

I haven't checked your vb script yet , I will check tommor morning in office because I don't have diadem software in my Laptop, I am based in UK.

 

Thanks for all your help and will inform you about the outcome of the program.

 

Regards

Veer 

Trusted Enthusiast
Brad_Turpin
Posts: 2,372
0 Kudos

Re: Calculation in diadem

Hi Veer,

 

Would you please send me a raw DAT file so that I can gear the VBScript I'm developing for you to work on your raw data files, right out of the box?  Thanks for the V-1 clarification here and in email.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

By using this web site, you accept the Terms of Use for this web site. Please read these Terms of Use carefully before using any part of this site. Please go here for information on ni.com's copyright infringement policy.
My Profile | Privacy | Legal | Contact NI © 2011 National Instruments Corporation. All rights reserved.    |    E-Mail this Page E-Mail this Page