Go Down

Topic: Sudden drop or rise? (Read 94 times) previous topic - next topic

Techno500

I am using a barometric sensor to sense a sudden drop or sudden rise in pressure in a given period.

For example the difference reading could be "-.300" or "+.300"; is it possible to read just to the right of the decimal point and use the sign to indicate fall or rising?

William

Delta_G

Math....

Keep up with the last reading.  Subtract the new reading to get the difference.  If the difference is greater than 0.3 then your condition has been satisfied. 
Ad hoc, ad loc, and quid pro quo.  So little time - so much to know!  ~Jeremy Hillary Boob Ph.D

Techno500

Math....

Keep up with the last reading.  Subtract the new reading to get the difference.  If the difference is greater than 0.3 then your condition has been satisfied. 
I have coded the difference function and have it working.  How can I detect the sign of difference value to indicate fall or rising? Now building the alarm...

klubfingers

You could determine sign by comparing to 0:
if(difference < 0) // difference is negative.
You could get rid  of the negative number with the absolute() function:
difference = abs(difference);
Getting rid of the decimal point is another matter not in my tool bag yet.

Good luck.

Robin2

There are just 3 possibilities - the difference is 0, it is +ve or it is -ve

This code should sort it out

Code: [Select]
if (difference == 0) {
   // do the zero stuff
}
else if (difference > 0) {
   // do the +ve stuff
}
else {
  // do the -ve stuff
}


...R

Techno500

Thank you klubfingers and Robin2 will try out your methods.

Attaching sample from data collection; just difference collection.


William

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy