FRE1976
Hello,

I am new to Toolbox and try to programm all the math chanels I have from other software.

I am stuck with, for shure, a simple thing: I am trying to calculate the average of a chanel, wich has been gated for a certain condition.
In the UserGuide, I have only found moving average filter, but no average, at least not in the apendix.

Any help would be appreciated!

Andrei
Quote 0 0
Mark_F
Hi Andrei,

The moving average function would be the averaging function.

What specifically are you trying to do?  Are you looking to smooth the channel?

Please let us know and we will do our best to assist.

Thank you,
Mark

M272, 2JZ, EJ25 Power!

Quote 0 0
FRE1976
Hey Mark,

Thank you for your answer!

Moving average is something that is good for smoothing for example damper trace.
I am looking for a function wich can calculate the average value of a chanel, in Toolbox with a Tabular Outing report, it is a mean value.

I gate, for example, the steering angle when driving in the pitlane, with certain conditions, and i would like to have the average/mean value of the chanel in order to use it as a offset.

Thank you!
Andrei
Quote 0 0
Mark_F
Hi Andrei,

If you are looking to assign a constant to each dataset, you can do so by going to Tools> Constants and calling that channel in your math to use as an offset.

Now, if you wish, you could do a math channel with registers to take the value at the desired place in the track (it sounds like this would be on drive out of pit lane) and then store that into the registers as the offset math you wish to use for math.

One is built in and would require a bit of work to set constants, the other requires a bit of math, but should be automatic.

However, this all sounds like a bandaid instead of a solution.  Are you utilizing a system that allows for zeroing of sensors?  An omega logger ( L2, ICD...etc) should allow for math to be created to allow for a pitlane zeroing.  If you are utilizing a Sigma system, you can set it up to use NV RAM to store a zero created via conditions if you do not wish to use the zeroing in workshop.  Also, you could make it without NV RAM and just have it reset every outing.

Let us know and we will work towards a solution that is best for you,
Mark

M272, 2JZ, EJ25 Power!

Quote 0 0
FRE1976
Hello Mark,

as I have told, I am new to PI.

The car is a Bentley GT3 with ICD.
How can I set it up to calculate an offset?

But, on the other hand, I am still interested in calculating a mean/average value of a chanel over a lap, or for certain conditions because we did not zero the chanels during the first test.
There have been issues with the beacon wich only worked on the last test day when the beacon was placed in a slow corner (around 70 km/h speed) [smile]

Now, I try to get offsets for damper traces, steering angle and so on in order to correct my data.

I have a condition called "[Pits]", and I gate for example steering angle during this condition "[a_steer_pits]".
Now I want to calculate an average of this chanel and then create a new chanel called [a_steer] = [a_steer_raw] - [a_steer_pits]

Thank you,
Andrei

Quote 0 0
Mark_F
For the offset, you will want to go to the zeroing node and create the group you want to zero.  In there you can set up a zero.  After further review, it appears to use the zeroing in the pit lane, you would still need to use a button, but you could have it hit while the driver is driving down the pitlane.  You can have different groups respond to different zeroing strategies. 
Either do a press for pit lane for steering and have a long hold as the dampers in the paddock.

Beacon - In this situation, I would look at the beacon receiver to ensure it's face is parallel with the beacon transmitter.  If you are using a small beacon, then check to see the distance from the track.  If you are using a monster beacon, it should overcome most distances a typical track would offer between a barrier and track surface.  There is the rare case that the beacon receiver gets washed out by the sun, but this is rare and would not occur the whole day.  In this situation, a slight shading of the sensor can help, but focus on the beacon faces being as parallel to each other as possible.

If you only have a single session that was not zeroed, I would shortcut this, saving time and effort, and just manually put in the offset in the math channel.  This happened with one outing, and you will have zeroed data going forward.

Easiest way would be to zoom into the area that the car was driving down the pitlane, and then look at the mean at the bottom of the screen in a Time/Distance chart and use that value.

To overlay two different channels on the same T/D graph you will want to enable Y Axis enable.  This allows for full customization of the channel layout and display on an X/Y Chart.  You can cram a bunch of information into a chart this way and see issues quickly.

Let me know how it goes!
Mark

M272, 2JZ, EJ25 Power!

Quote 0 0
FRE1976
Hello Mark,

thank you for taking the time.

Well, unfortunately, sometimes cars are going out of the pits w/o zeroing the chanels.

But, forgetting about all of this, I still do not know how can I calculate the mean/average value of a chanel.
This is the value I need, but calculated:
PI_mean.jpg 

For axample U_Batt_Avg = xxx[V_Batt_ECU]

Thank you!
Quote 0 0
FRE1976
In the mean time, I have got an answer from Josh Wesley of Cosworth.
Unfortunately, I am not able to verify his solution as it is working with advanced math and our licence does not include it.
I will ask him if it is OK to post his solution.

But now, I am looking for something else. I am able to get a roll gradient in a graph, but how do I get it into a table, for each lap of an outing?

Thank you!
Quote 0 0
JBracken

Hi Andrei,

With regard to calculating the average of a Math Channel, I have managed to create a series of Math Channels to allow you to do this with Global Math (rather than Advanced Math) that should be able to achieve what you are after – the average will be calculated throughout the lap with the last data point in the lap being the overall lap average.


I have created three math channels to help make this process more useful and scalable. One to act as a lap counter which increments, the second to reset at the end of each lap to be used as a trigger in the third math channels which calculates the average. Something very important to consider would be the rates at which things are calculated. The easiest way to do this would be to have the rates being based on the channels in the calculation. Please see Math Channels below.

  

_Lap Number

 

/* Enter the channel definition here (this text is treated as a comment).

    Use Ctrl-Space to access context-sensitive popup lists and Ctrl-] to

    match brackets and parentheses. */

 

register @count;

register @old;

register @new;

@new = [lapDistance];

@count = choose( @new < @old, @count+1, @count); // EOL if lap distance has gone down

@old = @new;

@count;

 

_EOL Reset

  

/* Enter the channel definition here (this text is treated as a comment).

    Use Ctrl-Space to access context-sensitive popup lists and Ctrl-] to

    match brackets and parentheses. */

 

register @old;

register @new;

register @reset;

@new = [_Lap Number];

@reset = choose( @new > @old, 1, 0); // reset on increased lap number

@old = @new;

@reset;

 

_Average

  

/* Enter the channel definition here (this text is treated as a comment).

    Use Ctrl-Space to access context-sensitive popup lists and Ctrl-] to

    match brackets and parentheses. */

 

register @new;

register @old;

register @sum;

register @average;

register @count;

 

@new = [ACT];  // Replace ACT with the channel to average

// update sum

@sum = @sum + @old;

// reset the sum and count when the end of lap has been detected

@sum = choose( [_EOL Reset] , 0, @sum);

@count = choose( [_EOL Reset] , 0, @count);

// only update the average once the we have had the first sample of the lap

@average = choose( @sum > 0 , (@sum / @count), 0);

@old = @new;

@count = @count+1;

@average;


Please find attached a Pi Toolbox Workbook which contains the Math Channels to get you started. I hope this helps, let me know how you get on.

Thanks and kind regards,

James

James Bracken BEng (Hons)
Senior Applications Engineer
HiL Group and RCA

E:  james.bracken@cosworth.com
T:  +44 (0) 1954 253749
M: +44 (0) 7775 028513

Quote 0 0
Sebast

Hi All,

I’m trying the same as Andrei. So, my aim is to find the max (as well as min, average, very first value, very last value, …) of a channel (for one lap) and use this value as a constant over the lap.

Thank you for the answer James, it helped me for some points.

While I use James’ scrip for the average value, I get the average of the previous samples (moving average from the start). However, I want to get a constant value over the lap. How can I get it?

I’m looking forward to read from you,

Seb

Quote 0 0
david
Is there a way to get the min,max or first and last value of a lap a constant over the lap?

This is very usefull for fuel_cons calculation if you have only the fuel_level. and ongoing calculation with this result.

In Outing Report i can just on time a channel. So i need three Report to see the min,max and diff values...
Quote 0 0
JBracken
Hi David, Seb,

It is possible to implement what you are asking but not with standard Math Channels. This is because Math Channels at each sample over the course of the outing (hence why you can get a moving average but not a constant value). To do this, you would need to have / purchase a Pi Toolxbox with Advanced Maths enabled.

Thanks and kind regards,

James
James Bracken BEng (Hons)
Senior Applications Engineer
HiL Group and RCA

E:  james.bracken@cosworth.com
T:  +44 (0) 1954 253749
M: +44 (0) 7775 028513

Quote 0 0
Sebast
Hi James,

Could you explain the process to do it with the Advanced Maths.
I have access to it.

Thanks,
Seb
Quote 0 0
JBracken
Hi Seb,

No problem, please allow me some time to put this together such that I can explain it properly. I will come back to you soonest with an explanation.

Thanks and kind regards,

James
James Bracken BEng (Hons)
Senior Applications Engineer
HiL Group and RCA

E:  james.bracken@cosworth.com
T:  +44 (0) 1954 253749
M: +44 (0) 7775 028513

Quote 0 0
Sebast
Hi James,

Ok, no worries. Thanks a lot.

I'm looking forward to read from you.
Seb
Quote 0 0