Page 2 of 4

Re: Formula help?

Posted: Tue Nov 27, 2012 8:30 am
by Brucepts
The averaging sample can be set by the end user in the PTS DM software to suit their "likes", the actual algorithm that is used for the calculations is somewhat a "secret" as it's probably one of the most important parts of how the numbers are arrived at. Sensor "noise" is taken into account, Rick is the programmer so if he feels there is something he can expand on to help you out I'll leave it up to him as it's his coding that makes it work.

Sample, baud rate, speed of the computer etc all have a play in how the numbers come out, we are still learning on the PTS DM and trying to improve our numbers

Re: Formula help?

Posted: Tue Nov 27, 2012 11:35 pm
by 1960FL
First off samples per second are a big factor into how many iterations go into the averaging. Think about it like this lets just use a number like 100 samples per second this is about the slowest you could get a PTS dm to sample data.

If I take 100 samples into stack and average them the stack will flush 100% every second and depending on how you manage your stack will dictate how your numbers flow….. Smoothing. Sooo if my stack was say 200 then I would only have modified 50% of the data every second and the change on the screen will be slower or more stable. You want to use a FIFO stack (Array) so the first number in is the first number out you should push to the stack and average every sample. I/E 1 2 3 4 5 6 7 8 9 then 10 1 2 3 4 5 6 7 8 then 11 10 1 2 3 4 5 6 7 and so on. Each number in this example would just represent the sample increment. You have to push your array along so not knowing the arduino code you may have to have a stack algorithm that moves the data through the array.

To give you and idea the early PTS DM was serial and its lowest sample rate was 125/sec and with a stack of 200 the numbers are smooth yet you can see the data click off in .1 increments and it take some skill to get your depression at 28 every time..


Which arduino board are you using, the PWM output can interface to the SSR module, you right the PID code and depression control is a no brainer.


Rick

Re: Formula help?

Posted: Wed Nov 28, 2012 12:40 am
by Superdave
Using the Uno R3, this is the code that's currently on it: http://www.sdsgarage.com/Misc/Projects/Flowbench6/


I'm going to have to familiarize myself more with the sample rate, but according to this page: http://arduino.cc/en/Reference/analogRead it can go up to 10,000 times per second.


I think most of my frustration comes from the serial monitor, once i get a display installed i hope that it'll be easier to read.


Thanks for the explanation though, time to put more thought into the project, lol :lol:

Re: Formula help?

Posted: Wed Nov 28, 2012 8:35 am
by 1960FL
How are you currently reading the output of the uno?

To a PC interface? what is that made up of ?

Rick

Re: Formula help?

Posted: Wed Nov 28, 2012 8:58 am
by Superdave
Just the serial monitor in the Arduino program, i looked and couldn't find a good interface program. I'm sure something could be designed but that's far beyond my current abilities.



I'm a technical manager at a casino so i do have access to quite a few different LED signs and all kinds of stuff in the "Spare or obsolete" pile at the warehouse. I might have to dig through and see if there is anything that i could use as a display.

Re: Formula help?

Posted: Thu Nov 29, 2012 4:48 am
by giuino
Buy a 16*2 display and you're ok

I'm reading your code...

there are some mistakes
First of all you're assuming a 5v source, so you assume you're sensor voltage swings 0-5v
In real world 5v will be more 4,5-4,8v
So, first of all find a convenient power source, test it and find your 5volt value;
then on:

Code: Select all

float voltage = average * (5.0 / 1023.0);
change 5.0 with your new voltage.

Second:

Code: Select all

float kpa = ((voltage / 5) - .5)/.2;
no sense to use voltage and divide by 5... just use the averaged adc read:

Code: Select all

float kpa = (average - .5)/.2;
the delay should be only at the end of the loop no sense to stop the routine halfway

same applies to voltage2 and kpa2

don't know your sensors linearity and scale, but I think you took them from a datasheet and be ok.

Re: Formula help?

Posted: Thu Nov 29, 2012 8:25 am
by Brucepts
giuino wrote:don't know your sensors linearity and scale, but I think you took them from a datasheet and be ok.
Best to check the linearity to a water gauge and check the voltage range as is suggested. Those sensors need tweaking ;)

My 40" range maxes out around 36" and never reaches it's stated output voltage.

Re: Formula help?

Posted: Thu Nov 29, 2012 10:50 am
by giuino
Brucepts wrote:
giuino wrote:don't know your sensors linearity and scale, but I think you took them from a datasheet and be ok.
Best to check the linearity to a water gauge and check the voltage range as is suggested. Those sensors need tweaking ;)

My 40" range maxes out around 36" and never reaches it's stated output voltage.
Yes, it's always good to check these sensors, although many times I've found errors in the code itself rather than in sensors...

Re: Formula help?

Posted: Thu Nov 29, 2012 12:38 pm
by Superdave
Awesome, thanks for the advice!


I'll work that in tonight, last night I started to work on adding the 2nd MAP sensor to correct the depression numbers VS Baro.


Do you guys think it's worth correcting CFM vs air temp?



Dave

Re: Formula help?

Posted: Thu Nov 29, 2012 1:06 pm
by giuino
Superdave wrote:Awesome, thanks for the advice!


I'll work that in tonight, last night I started to work on adding the 2nd MAP sensor to correct the depression numbers VS Baro.


Do you guys think it's worth correcting CFM vs air temp?



Dave
Yes, 'cause CFM is a volume measure and volume is affected by temp...
for baro correction use always a formula embedding the adc values (not the volt output) ;)