DEBOUNCE/de

(Difference between revisions)
Jump to: navigation, search
((**COPIED FROM ENGLISH PAGE**) =)
(Remarks)
Line 15: Line 15:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
= <span class="f_Header">Remarks</span> =
+
= <span class="f_Header">Anmerkungen</span> =
 
<div style="padding: 0px; margin: 0px 0px 0px 4px;">
 
<div style="padding: 0px; margin: 0px 0px 0px 4px;">
 
{| width="563" cellspacing="0" cellpadding="1" border="1" style="border: 2px solid rgb(0, 0, 0); border-spacing: 0px; border-collapse: collapse;"
 
{| width="563" cellspacing="0" cellpadding="1" border="1" style="border: 2px solid rgb(0, 0, 0); border-spacing: 0px; border-collapse: collapse;"
Line 23: Line 23:
  
 
| valign="top" width="87%" style="width: 473px; height: 16px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="87%" style="width: 473px; height: 16px; border: 1px solid rgb(0, 0, 0);" |  
A port pin like PINB.0 , to examine.
+
Portpin wie zum Beispiel PINB.0
  
 
|- style="vertical-align: top;"
 
|- style="vertical-align: top;"
 
| valign="top" width="15%" style="width: 81px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="15%" style="width: 81px; border: 1px solid rgb(0, 0, 0);" |  
State
+
state
  
 
| valign="top" width="87%" style="width: 473px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="87%" style="width: 473px; border: 1px solid rgb(0, 0, 0);" |  
0 for jumping when PINx.y is low , 1 for jumping when PINx.y is high
+
 
 +
0 für Sprung wenn der Portpin PINx.y low ist , 1 für Sprung wenn der Portpin PINx.y High ist.
  
 
|- style="vertical-align: top;"
 
|- style="vertical-align: top;"
 
| valign="top" width="15%" style="width: 81px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="15%" style="width: 81px; border: 1px solid rgb(0, 0, 0);" |  
Label
+
label
  
 
| valign="top" width="87%" style="width: 473px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="87%" style="width: 473px; border: 1px solid rgb(0, 0, 0);" |  
The label to GOTO when the specified state is detected
+
Sprungmarke zu der gesprungen werden soll wenn der angegebene Zustand erkannt wird.
  
 
|- style="vertical-align: top;"
 
|- style="vertical-align: top;"
Line 44: Line 45:
  
 
| valign="top" width="87%" style="width: 473px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="87%" style="width: 473px; border: 1px solid rgb(0, 0, 0);" |  
The label to GOSUB when the specified state is detected
+
Sprungmarke ist Unterprogramm.
  
 
|}
 
|}
Line 50: Line 51:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
When you specify the optional parameter SUB, a GOSUB to label is performed instead of a GOTO.
+
Wenn optional SUB angegeben wird dann wird ein GOSUB zu der Sprungmarke statt eines GOTO ausgeführt.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
The DEBOUNCE statement tests the condition of the specified pin and if true there will be a delay for 25 mS and the condition will be checked again. (eliminating bounce of a switch)
+
Der DEBOUNCE-Befehl prüft den Zustand des angegebenen Pins. Wenn die Bedingung (0 bzw. 1) erfüllt ist dann wird 25ms gewartet und dann wird die Bedingung noch einmal geprüft. Dadurch wird das Prellen abgewartet.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
When the condition is still true and there was no branch before, it branches to specified the label.
+
Wenn die Bedingung immer noch erfüllt ist dann erfolgt ein Sprung zur angegebenen Sprungmarke.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
When the condition is not true, or the logic level on the pin is not of the specified level, the code on the next line will be executed.
+
Wenn die Bedingung nicht wahr ist oder der Logik-Level am Pin nicht dem angegebenen Level entspricht dan wird die nächste Zeile ausgeführt.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
When DEBOUNCE is executed again, the state of the switch must have gone back in the original position before it can perform another branch. So if you are waiting for a pin to go low, and the pin goes low, the pin must change to high, before a new low level will result in another branch.
+
Wenn DEBOUNCE wieder ausgeführt wird dann muss der Zustand des Tasters zwischendurch im Grundzustand gewesen sein bevor ein Sprung erfolgen kann. Wenn man zum Beispiel auf Low wartet und der Pin auf Low geht dann muss der Pin einmal wieder High sein bevor ein neuer Low-Level einen Sprung auslösen kann.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
Each DEBOUNCE statement, which uses a different port, uses 1 BIT of the internal memory to hold its state. And as the bits are stored in SRAM, it means that even while you use only 1 pin/bit, a byte is used for storage of the bit.
+
Jeder DEBOUNCE-Befehl der einen anderen Port benutzt verbraucht 1 Bit des internen Speichers um den Zustand zu speichern. Da die Bits im SRAM gespeichert werden bedeutet das, dass auch bei Benutzung nur eines Pins/Bits ein Byte Speicher verbraucht wird um das Bit zu speichern.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
DEBOUNCE will not wait for the input value to met the specified condition. You need to use BITWAIT if you want to wait until a bit will have a certain value.
+
DEBOUNCE wartet nicht bis der Eingabewert die angegebene Bedingung erfüllt. Man kann BITWAIT benutzen wenn man warten möchte bis ein Bit einen bestimmten Wert hat.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
So DEBOUNCE will not halt your program while a BITWAIT can halt your program if the bit will never have the specified value. You can combine BITWAIT and DEBOUNCE statements by preceding a DEBOUNCE with a BITWAIT statement.
+
DEBOUNCE hält das Programm also nicht an während ein BITWAIT das Programm anhält bis der Wert erreicht ist. Man kann BITWAIT und DEBOUNCE kombinieren indem man ein BITWAIT vor ein DEBOUNCE schreibt.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>

Revision as of 01:15, 5 March 2013

Contents

Funktion

Entprellen eines Portpins, an den ein Taster angeschlossen ist.

 

 

Syntax

DEBOUNCE Px.y , state , label [ , SUB]

 

 

Anmerkungen

Px.y

Portpin wie zum Beispiel PINB.0

state

0 für Sprung wenn der Portpin PINx.y low ist , 1 für Sprung wenn der Portpin PINx.y High ist.

label

Sprungmarke zu der gesprungen werden soll wenn der angegebene Zustand erkannt wird.

SUB

Sprungmarke ist Unterprogramm.

 

Wenn optional SUB angegeben wird dann wird ein GOSUB zu der Sprungmarke statt eines GOTO ausgeführt.

 

Der DEBOUNCE-Befehl prüft den Zustand des angegebenen Pins. Wenn die Bedingung (0 bzw. 1) erfüllt ist dann wird 25ms gewartet und dann wird die Bedingung noch einmal geprüft. Dadurch wird das Prellen abgewartet.

 

Wenn die Bedingung immer noch erfüllt ist dann erfolgt ein Sprung zur angegebenen Sprungmarke.

 

Wenn die Bedingung nicht wahr ist oder der Logik-Level am Pin nicht dem angegebenen Level entspricht dan wird die nächste Zeile ausgeführt.

 

Wenn DEBOUNCE wieder ausgeführt wird dann muss der Zustand des Tasters zwischendurch im Grundzustand gewesen sein bevor ein Sprung erfolgen kann. Wenn man zum Beispiel auf Low wartet und der Pin auf Low geht dann muss der Pin einmal wieder High sein bevor ein neuer Low-Level einen Sprung auslösen kann.

 

Jeder DEBOUNCE-Befehl der einen anderen Port benutzt verbraucht 1 Bit des internen Speichers um den Zustand zu speichern. Da die Bits im SRAM gespeichert werden bedeutet das, dass auch bei Benutzung nur eines Pins/Bits ein Byte Speicher verbraucht wird um das Bit zu speichern.

 

DEBOUNCE wartet nicht bis der Eingabewert die angegebene Bedingung erfüllt. Man kann BITWAIT benutzen wenn man warten möchte bis ein Bit einen bestimmten Wert hat.

 

DEBOUNCE hält das Programm also nicht an während ein BITWAIT das Programm anhält bis der Wert erreicht ist. Man kann BITWAIT und DEBOUNCE kombinieren indem man ein BITWAIT vor ein DEBOUNCE schreibt.

 

 

See also

CONFIG DEBOUNCE , BITWAIT

 

 

Example


'-----------------------------------------------------------------------------------------
'name : deboun.bas
'copyright : (c) 1995-2005, MCS Electronics
'purpose : demonstrates DEBOUNCE
'micro : Mega48
'suited for demo : yes
'commercial addon needed : no
'-----------------------------------------------------------------------------------------
 
$regfile = "m48def.dat" ' specify the used micro
$crystal = 4000000 ' used crystal frequency
$baud = 19200 ' use baud rate
$hwstack = 32 ' default use 32 for the hardware stack
$swstack = 10 ' default use 10 for the SW stack
$framesize = 40 ' default use 40 for the frame space
 
Config Debounce = 30 'when the config statement is not used a default of 25mS will be used but we override to use 30 mS
 
 
'Debounce Pind.0 , 1 , Pr 'try this for branching when high(1)
Debounce Pind.0 , 0 , Pr , Sub
Debounce Pind.0 , 0 , Pr , Sub
' ^----- label to branch to
' ^---------- Branch when P1.0 goes low(0)
' ^---------------- Examine P1.0
 
'When Pind.0 goes low jump to subroutine Pr
'Pind.0 must go high again before it jumps again
'to the label Pr when Pind.0 is low
 
Debounce Pind.0 , 1 , Pr 'no branch
Debounce Pind.0 , 1 , Pr 'will result in a return without gosub
End
 
Pr:
Print "PIND.0 was/is low"
Return

Languages   English Deutsch  
Personal tools
Namespaces
Variants
Actions
Navigation
In other languages
Language