brauche Hilfe bei Projekt mit barometrischen sensor

OP #3670068
Lesenswert?

Hallo Ihr Lieben !

Anbei befinded sich mein (NOOB) Sketch für meinen Arduino UNO or MICRO.
Ich möchte gerne folgendes daran ändern. :

Ich möchte einen Micro Switch (zum verzögerten anschalten (30 sec.) 
anrbingen und es mit einer 9 volt Batterie betreiben.

Womit ich Schwierigkeien habe :

Wie kann ich den Sensor überprüfen lassen (alle 8 Milisekunden) ob der 
vorherige wert eine Abweichung von >als 99 p (mehr oder weniger) 
aufweist und dann ein Buzzer einschalten ?

Ich habe null Ahnung von Gleichungen Calculus und alldem. ich kann nur 
ein bisschen Basic :)

Wäre super wenn mir einer helfen kann.

Bin in einem anderen Forum unterwegs aber der Zeitunterschied ist leider 
zu groß und ich muss das unbedingt fertig bekommen.

(Ich habe noch mehrere Fragen wenn Ihr nichts dagegen habt , hinzu 
möchte ich noch einen GY-521 mit anbringen aber eins nach dem anderen )

Vielen lieben Dank !
checkingavroutx
Angehängte Dateien:
#3670118
Lesenswert?

Frank Christian schrieb:

> Ich habe null Ahnung von Gleichungen Calculus und alldem.


wozu braucht man für
1
void Setup()
2
{
3
...
4
  old = bmp.readPressure();
5
...
6
}
7

8
void loop()
9
{
10

11
...
12
   new = bmp.readPressure();
13

14
   if( ( new > old + 99 ) ||
15
       ( new < old - 99 ) )
16
   {
17
     old = new;
18

19
     schalte Buzzer ein
20
   }
21
...
22
}

Calculus?

Das ist ganz normale Programmstrategie, wie man einen Wert mit einem 
Wert 'früher' vergleicht. Also im Grunde einfach das, was du hier

> Wie kann ich den Sensor überprüfen lassen (alle 8 Milisekunden)
> ob der vorherige wert eine Abweichung von >als 99 p
> (mehr oder weniger) aufweist und dann ein Buzzer einschalten ?

beschrieben hast (um die 8 Millisekunden musst du dich noch kümmern) in 
Code gefasst.


> ich kann nur
> ein bisschen Basic :)

Das kann aber nicht viel sein, wenn dir die simpelste aller simplen 
Strategien (so etwas einen Algorithmus zu nennen, würde alle Algorithmen 
beleidigen) nicht geläufig ist.
OP #3670124
Lesenswert?

Vielen Dank Mike !

das ist ein Druckbarometer ( ich bin Amerikaner , mein Deutsch hakt ein 
bischen ) ..

pa wäre glaube ich der richtige wert. ( pascal )

der ist momentan zwischen 100449 und schwankt hoch und runter.
Ich möchte gern das ein buzzer an geht wenn er ZUM vorherigen Wert >99 
oder < als 99 rauf der runtergeht..

Vielen Dank !
#3670158
Lesenswert?

Frank Christian schrieb:
> :) Programmieren lernen ist natürlich eine SACHE die mich interessiert
> und die ich versuche zu lernen.

Ich behaupte mal: nein, du versuchst es nicht zu lernen. Du suchst nur 
einen Dummen, der dir deine Arbeit macht.

> aber rauszufinden wo man das was Du mir gegeben hast einbindet ist
> natürlich schwierig Aufgund der vielen Möglichkeiten.

?
Wo bitte gibt es in
1
#include <Wire.h>
2
#include <Adafruit_BMP085.h>  // Adafruit Bibliothek einbinden
3

4
Adafruit_BMP085 bmp;
5

6
void setup(){
7

8
 // Seriellen Monitor aktivieren
9
 Serial.begin(9600);
10

11
 // Sensor initialisieren
12
 if (!bmp.begin()) {
13
  Serial.println("Keinen gültigen BMP085 Sensor gefunden!");
14
  while (true) {}
15
 }
16
}
17

18
void loop(){
19

20
 Serial.print("Luftdruck: ");
21
 // readPressure() Luftdruck in Pa auslesen und anzeigen
22
 Serial.print(bmp.readPressure());
23
 Serial.println(" Pa");
24

25
 
26
}

so viele Möglichkeiten?
Jedes Grundschulkind, das des Lesens mächtig ist, kann die Stelle 
finden. Hast du den Programmtext eigentlich schon mal gelesen und dir 
überlegt, was da eigentlich wo passiert? Es ist schon recht schwierig, 
Code zu finden, der noch banaler als die Vorgabe ist.
#3670203
Lesenswert?

Frank Christian schrieb:
> Also kann ich es mit meinem Sensor vergessen ? Oder ist es möglich ?

Es ist für die Funktion vollkommen schnuppe, ob ein Sensor fertige Pa 
liefert (oder alternativ gleich die Höhe), oder ob man selber dran 
rechnet. Insbesondere wenn der nötige Code schon vorzuliegen scheint.

Der von mir erwähnte Sensor ist genau dann strategisch im Vorteil, 
wenn ein ständiges Auslesen nicht in Frage kommt, sondern eine 
Alarmierung per Interrupt-Leitung erforderlich ist.
OP #3670233
Lesenswert?

Karl Heinz ,,, Ich wollt Dir nur sagen das ich eher sensibel bin zu 
Kommentaren wie : " Du suchst Dir nur einen Dummen"... und so weiter ...

Wenn du dich mal umsehen würdest auf dem amerikanischen Forum dann 
würdest du auch sehen das ich Gott seih Dank einige Fortschritte gemacht 
habe.(ich versuche ! )

Ich bin echt froh darüber wie die amerikaner mir immer engegen gekommen 
sind insbesondere wenn ich etwas Aufgrund meines Asperger Syndroms nicht 
hinbekommen habe. Ich habe leider nicht die Mittel und Wege mir einen 
anderen Sensor zu kaufen. Ich bin für die IT Sicherheit am Flughafen 
Köln Bonn verantwortlich ( das ist mein Gebiet ).. Dennoch würde ich 
hier nie jemand auf die Finger hauen wenn er sich mal in meinem Gebiet 
umschaut ( solange er nichts kaputt macht )
Ich repariere alles was elektrisch ist ( alles ) ... aber Programmieren 
habe ich leider nicht drauf , deswegen wäre es super wenn mir jemand 
helfen würde und mir sagen könnte wo ich diesen Code reinzustopfen 
habe..
Wenn Ihr mir ne Frage über smd Bauteile gebt , dann werde ich euch doch 
nicht ein Buch über SMD an den Knopf knallen oder ?
#3670755
Lesenswert?

Frank Christian schrieb:
> Der Sensor muss leider alle 8 Milisekunden ausgelesen werden wenn der
> Knopf gedrückt wird.

Hi Frank,

I understand you are American. Are you from the States, and thus prefer 
English?

Did you manage by now to introduce the code from Karl-Heinz into your 
sketch?

Did you manage to read out the status of the button?

For the 8ms business, did you spot the delay() function already on the 
http://arduino.cc/en/Reference/HomePage?

KR, Sebastian
OP #3671664
Lesenswert?

Hi Sebastian !

Yes ,I am from Columbus Georgia :)

I was not able to introduce the code into the sketch.

Yes the button does not seem to be a problem.

I also took a look at the Delay funtion with its significant drawbacks.

No other reading of sensors, mathematical calculations, or pin 
manipulation can go on during the delay function, so in effect, it 
brings most other activity to a halt.

Thank you Sebastian !
#3671739
Lesenswert?

Hi Frank,

Frank Christian schrieb:
> I was not able to introduce the code into the sketch.

You would simply copy the snippets that Karl-Heinz provided and paste 
them into your sketch functions. Can you explain what the remaining the 
problem is?

> Yes the button does not seem to be a problem.

Good so.

> I also took a look at the Delay funtion with its significant drawbacks.
> No other reading of sensors, mathematical calculations, or pin
> manipulation can go on during the delay function, so in effect, it
> brings most other activity to a halt.

Yes, but ... what other business would you WANT to do during these 8ms?

-- Take a deep breath here --

I suggest you describe to us (and yourselves) once more, in plain words, 
what EXACTLY you want the uC to do with the pressure sensor, the button, 
and the buzzer.

Kind regards,
Sebastian
OP #3671791
Lesenswert?

Thank you Sebastion.

I would like for it to do the following:

This device i will put it in my car (attached to a 9 volt battery)

then i hit a button on the device it will give me 30 seconds to get out 
of the car and close the doors.

After the 30 Seconds have passed it will initiate the sensor and check 
the current air pressure.

As soon as the air pressure sensor detects hat the current sensor value 
is 100 PA or more ,above the last reading , or 100 or more under the 
last reading it got 8 milliseconds ago then it will sound a buzzer.

:)  Thats it Sebastian.

Thank you for your help !
#3671945
Lesenswert?

Frank Christian schrieb:
> This device i will put it in my car (attached to a 9 volt battery)

Ok. The battery might not last as long as you wish, but that's another 
topic. Let's go with this approach for now.

> then i hit a button on the device it will give me 30 seconds to get out
> of the car and close the doors.
Ok. So, the device must keep track of the following states:
  * State A: After startup, waiting for button press
  * State B: Button pressed, waiting for 30 seconds

> After the 30 Seconds have passed it will initiate the sensor and check
> the current air pressure.
  * State C: 30 seconds passed, armed, measuring pressure variations.

> As soon as the air pressure sensor detects hat the current sensor value
> is 100 PA or more ,above the last reading , or 100 or more under the
> last reading it got 8 milliseconds ago then it will sound a buzzer.
Ok, so this is the logic in state C: We perform and store a first 
measurement. Lets call the store m1. Then we wait 8ms. Then we perform 
and store second measurement, using say m2. The we compare m2 and 
m1. If they differ less than 100 Pascal, we move the content of m2 
into m1 and go back to waiting. Otherwise we enter
  * State D: Buzzing

Is that about it?

How do you foresee your device to go back to state A? Pulling the plug?

Kind regards,
Sebastian
OP #3672022
Lesenswert?

Yes !  You are amaazing ,,, finally someone who is able to communicate 
:)!

Well i assume i have more than one choice for disabling the device..

by remote

by banging my head 3 times against the windows and it will detect it :) 
LOL

by singnig a song and it willl open ( i know its difficut hahaha )

No seriously dont worry aut disablilng ,,, i will get 54 more sensors 
one of them fingerprint from digitaalersona...

Maybe i can do somethig with that ....

Hi Sebastian , how much money can i send you over payal to code this for 
my lazy butt ?

Best regards  ,

Frank
#3672095
Lesenswert?

Frank Christian schrieb:
> Yes !
> Dont worry about disabling.

Ok, that's sorted. We have a "specification".

Now a little rewrite to establish a "detailed software design":
  * Startup
  * Wait for button press
  * Wait for 30 seconds
  * Set m1 to bmp.readPressure()
  * Loop                <<<------------------o
  *     Wait for 8ms                         |
  *     Set m2 to bmp.readPressure()         |
  *     If abs(m2-m1)>=100 Then Exit Loop ---+--o
  * Iterate Loop ----------------------------o  |
  * Activate Buzzer     <<<---------------------o
  * Wait forever

You still agree?

KR, Sebastian

PS:
Frank Christian schrieb:
> how much money can i send you over payal to code this for
> my lazy butt ?
Nay, lad, the deal is that you (pretend to) learn!
OP #3672138
Lesenswert?

Hahha ! Thank you Sebastian !

yes ! agreed upon , looking good (my humble opinion ) !

I am learning !  :) :) :)

( during the 30 seconds it should already be looking at the pressure 
values so that when i hit the button it will be armed in 30 seonds. )

Nice Sebastian ! you make things much eaasier to understand !

where can i send flowers ? or what motherboard can i fix for you ?

Unfortunately i will not have internet for another 10 hours or so ...

Thank you so much for any help  and i am waiting forward to learn more !

I love this stuff .... Until now i only knew Basic ..lol  qbasic

Microcontrollers are soooo much fun,,,

Thank you !
Frank
#3672191
Lesenswert?

Frank Christian schrieb:
> ( during the 30 seconds it should already be looking at the pressure
> values so that when i hit the button it will be armed in 30 seonds. )

O...k ... no, wait a minute. Why should it do that? I mean, it begins 
the 30 seconds grace period only AFTER you already hit the button.

So, before even coding, we are back to the specifications. Don't worry, 
thats business as usual. If fact, it's good to discuss and determine the 
specs down to the finest little detail -- that's still better (and 
cheaper) than to hack away coding and then to fiddle around just so that 
one gets to understand what one really wanted in the first place.

KR, Sebastian

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren