# DIAdem

cancel
Showing results for
Search instead for
Did you mean:

Solved!
Go to solution

## Script for finding fixed values

Hi everybody,

I am new to DIAdem scripts and I would appreciate any help I can get.

We get various channels of test data, out of which: time, speed, engine RPM, distance, etc. We need to find:

1) the time interval between a condition and a set of fixed values of distance(m) or speed(km/h).

2) get the engine RPM when the speed reaches 100km/h for the first time

For 1), the starting time is when the value in the AccelPedal channel is equal or greater than 99. In theory, the vehicle is immobilized for at least 30 s at the beginning such that, at that same instant, distance and speed should be close to zero while the value in the optional BrakePedalPos channel must be zero.

The time intervals are taken between the above mentioned starting time and the time to reach:

A) the closest distance value to: 6.1, 12.2 and 18.3 meters

B) the closest speed value to: 10, 30, 50, 80, 16.09, 32.19, 48.28, 64.37 and 80.47 km/h.

Finally, we need the average of the acceleration channel between the starting time (or row) and the time (or row) when the speed reaches 24.135 km/h.

As a final note, the data sampling rate is common to all channels but may vary from one test to another.

Felix HC

Message 1 of 3
(4,768 Views)
Solution
Accepted by topic author FelixHC

## Re: Script for finding fixed values

Felix HC

Sounds like the  ChnFind command will be your best friend.

Below is syntax that will find when are greater than 10 from the channel named "Channel" in the Channel group "Group1"

Dim intMyResult
intMyResult = ChnFind("Ch(""Group1/Channel"")>10",250)

It will return the index in channel where found. I would suggest looking up in help the specifics of the ChnFind command.

Also I like to take a Channel reference out. This allows me to treat each channel as a array (Starting at 1 not zero).

The ChnFind command is faster than using the Channel references, but not as flexible.

Channel references are taken out like this example.

dim oChn

set oChn = Data.Root.ChannelGroups("EXAMPLE").Channels("Revs")

for i = 1to oChn.Size

if oChn(i) > 10then

endif

next

This will then take out reference to the  Group  "EXAMPLE" and the Channel name "Revs"

Then you can refer to the channel values using

oChn(10) to get/set the 10 value in the Channel.

Hope this helps some.

Paul

Message 2 of 3
(4,756 Views)

## Re: Script for finding fixed values

Thank you very much Pesmith8!

Indeed the commands ChnFind and CHV are my new best friends.

Felix

Message 3 of 3
(4,731 Views)