INPUT/de

From MCS Wiki AVR
< INPUT(Difference between revisions)
Jump to: navigation, search
(Funktion)
(Beispiel)
 
(7 intermediate revisions by one user not shown)
Line 17: Line 17:
 
<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="567" cellspacing="0" cellpadding="1" border="1" style="border: 2px solid rgb(0, 0, 0); border-spacing: 0px; border-collapse: collapse;"
 
{| width="567" cellspacing="0" cellpadding="1" border="1" style="border: 2px solid rgb(0, 0, 0); border-spacing: 0px; border-collapse: collapse;"
Line 25: Line 25:
  
 
| valign="top" width="86%" style="width: 470px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="86%" style="width: 470px; border: 1px solid rgb(0, 0, 0);" |  
An optional string constant printed before the prompt character.
+
Optionale String-Konstante, die vor dem Prompt-Zeichen geschrieben wird.
  
 
|- style="vertical-align: top;"
 
|- style="vertical-align: top;"
Line 32: Line 32:
  
 
| valign="top" width="86%" style="width: 470px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="86%" style="width: 470px; border: 1px solid rgb(0, 0, 0);" |  
A variable to accept the input value or a string.
+
Variable zur Aufnahme des Input-Wertes oder Strings.
  
 
|- style="vertical-align: top;"
 
|- style="vertical-align: top;"
Line 39: Line 39:
  
 
| valign="top" width="86%" style="width: 470px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="86%" style="width: 470px; border: 1px solid rgb(0, 0, 0);" |  
A channel number, which identifies an opened file. This can be a hard coded constant or a variable.
+
Kanalnummer, die eine geöffnete Datei identifiziert. Kann eine Konstante oder eine Variable sein.
  
 
|}
 
|}
Line 45: Line 45:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
The INPUT routine can be used when you have an RS-232 interface on your uP.
+
Die INPUT-Routine kann benutzt werden wenn man einen Mikrocontroller mit serieller Schnittstelle hat.  
  
The RS-232 interface can be connected to a serial communication port of your computer.
+
Die serielle Schnittstelle kann (über einen RS-232 - TTL Konverter) mit der seriellen Schnittstelle eines PCs verbunden werden.
  
This way you can use a terminal emulator and the keyboard as an input device.
+
Auf dieses Weise kann man die Tastatur des PCs mit einem Terminalemulator-Programm für Eingaben benutzen.
  
You can also use the built-in terminal emulator.
+
Man kann auch den in BASCOM integrierten Terminal-Emulator verwenden.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
For usage with the AVR-DOS file system, you can read variables from an opened file. Since these variables are stored in ASCII format, the data is converted to the proper format automatically.
+
Bei Benutzung des AVR-DOS Datei-Systems kann man Variableninhalte aus einer geöffneten Datei lesen. Da die Variablenwerte im ASCII-Format gespeichert sind werden die Daten automatisch in das richtige Format umgewandelt.
 +
 
 +
Wenn INPUT in Zusammenhang mit Dateien benutzt wird dann ist PROMPT nicht unterstützt.
  
When you use INPUT with a file, the prompt is not supported.
 
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
= <span class="f_Header">Difference with VB</span> =
+
= <span class="f_Header">Unterschied zu VB</span> =
  
In VB you can specify&nbsp;<span style="font-weight: bold;">&H</span>&nbsp;with INPUT so VB will recognize that a hexadecimal string is being used.
+
In VB kann man <span style="font-weight: bold;">&H</span>&nbsp; mit INPUT spezifizieren und VB erkennt daraus, dass ein hexadezimaler Wert benutzt wird.  
  
BASCOM implements a new statement&nbsp;: INPUTHEX.
+
BASCOM hat den neuen Befehl INPUTHEX.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 73: Line 74:
 
= <span class="f_Header">Xmega-SPI</span> =
 
= <span class="f_Header">Xmega-SPI</span> =
  
When receiving data from the SPI interface, you need to activate the SS pin. Some chips might need an active low, others might need an active high. This will depends on the slave chip.
+
Beim Empfang über das SPI-Interface muss der SS-Pin aktiviert werden. Manche Chips benötigen active low, manche Chips benötigen active high. Dies ist anhängig vom Slave-Chip.
  
When you use the SS=AUTO option, the level of SS will be changed automatic. Thus SS is made low, then the data bytes are received, and finally , SS is made high again.
+
Wenn man die SS=Auto Option benutzt dann wird der Level von SS automatisch geändert. SS wird auf Low geschaltet, Datenbytes werden empfangen und schließlich wird SS wieder high geschaltet.
  
&nbsp;
+
Datenempfang funktioniert durch Senden eines Datenbytes und Empfang der Daten, die herausgeschrieben werden (shifted out). Die Daten, die gesendet werden sind 0. Man kann das in der Library _inputspivar Routine ändern.
  
Receiving data works by sending a data byte and returning the data that is shifted out. The data that will be sent is a 0. You can alter this in the library, _inputspivar routine.
+
Man kann nicht Konstanten senden wenn man INPUT mit SPI benutzt. Also wird INPUT #10, "SPI", var &nbsp;nicht unterstützt.
  
You can not sent constants using the INPUT with SPI. So INPUT #10, "SPI", var &nbsp;is not supported.
+
INPUT in Zusammenhang mit SPI wartet auch nicht auf Empfang. Es wartet auf die Anzahl Bytes die in die Variable passen. Siehe Beispiel unter [http://avrhelp.mcselec.com/config_spix.htm CONFIG SPIx].
 
+
INPUT used with SPI will not wait for a return either. It will wait for the number of bytes that fits into the variable. See[http://avrhelp.mcselec.com/config_spix.htm CONFIG SPIx]&nbsp;for an example.
+
  
 
&nbsp;
 
&nbsp;
  
= <span class="f_Header">Number of Bytes</span> =
+
= <span class="f_Header">Anzahl Bytes</span> =
  
The compiler will receive 1 byte for a variable which was dimensioned as a BYTE.
+
Der Compiler empfängt 1 Byte für eine Variable die als BYTE dimensioniert ist.
  
It will receive 2 bytes for a WORD/INTEGER, 4 bytes for a LONG/SINGLE and 8 bytes for a DOUBLE.
+
Er empfängt 2 Bytes für WORD/INTEGER Variablen, 4 Bytes für eine LONG/SINGLE und 8 Bytes für eine DOUBLE-Variable.
  
As with all routines in BASCOM, the least significant Byte will be received first.
+
Wie bei allen BASCOM-Routinen wird das least significant Byte zuerst empfangen.
  
 
&nbsp;
 
&nbsp;
  
If you specify an array, it will receive one element.
+
Wenn ein Array angegeben wird dann wird ein Element empfangen.
  
With an optional parameter you can provide how many bytes must be received. You must use a semicolon (;) to specify this parameter. This because the comma (,) is used to receive multiple variables.
+
Mit einem optionalen Parameter kann man angeben wieviele Bytes empfangen werden sollen. Man muss ein Semikolon (;) verwenden um diesen Parameter anzugeben weil das Komma (,) benutzt wird um mehrere Variablen zu empfangen.
 
+
&nbsp;
+
  
= <span class="f_Header">Sample</span> =
+
= <span class="f_Header">Beispiel</span> =
  
 
Dim Tmparray(5) As Byte &nbsp;, Spi_send_byte As Byte , W as Word
 
Dim Tmparray(5) As Byte &nbsp;, Spi_send_byte As Byte , W as Word
Line 121: Line 118:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
= <span class="f_Header">See also</span> =
+
= <span class="f_Header">Siehe auch</span> =
  
 
[[INPUTHEX]]&nbsp;,&nbsp;[[PRINT]]&nbsp;,&nbsp;[[ECHO]]&nbsp;,&nbsp;[[WRITE]]&nbsp;,&nbsp;[[INPUTBIN]]
 
[[INPUTHEX]]&nbsp;,&nbsp;[[PRINT]]&nbsp;,&nbsp;[[ECHO]]&nbsp;,&nbsp;[[WRITE]]&nbsp;,&nbsp;[[INPUTBIN]]
Line 131: Line 128:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
= <span class="f_Header">Example</span> =
+
= <span class="f_Header">Beispiel</span> =
  
 
<br/><source lang="bascomavr">
 
<br/><source lang="bascomavr">
Line 144: Line 141:
 
   
 
   
 
$regfile = "m48def.dat" ' specify the used micro
 
$regfile = "m48def.dat" ' specify the used micro
$crystal = 4000000 ' used crystal frequency
+
$crystal = 4000000 ' Taktfrequenz
$baud = 19200 ' use baud rate
+
$baud = 19200 ' Baudrate
 
$hwstack = 32 ' default use 32 for the hardware stack
 
$hwstack = 32 ' default use 32 for the hardware stack
 
$swstack = 10 ' default use 10 for the SW stack
 
$swstack = 10 ' default use 10 for the SW stack
Line 154: Line 151:
 
Dim S As String * 15
 
Dim S As String * 15
 
   
 
   
Input "Use this to ask a question " , V
+
Input "Hier kann eine Frage stehen " , V
Input B1 'leave out for no question
+
Input B1 'Weglassen wenn keine Frage
 
   
 
   
Input "Enter integer " , C
+
Input "Eingabe von Integer " , C
 
Print C
 
Print C
 
   
 
   
 
   
 
   
Inputhex "Enter hex number (4 bytes) " , C
+
Inputhex "Eingabe einer Hex-Zahl (4 bytes) " , C
 
Print C
 
Print C
Inputhex "Enter hex byte (2 bytes) " , D
+
Inputhex "Eingabe Hex Byte (2 bytes) " , D
 
Print D
 
Print D
 
   
 
   
Input "More variables " , C , D
+
Input "Weitere Variablen " , C , D
 
Print C ; " " ; D
 
Print C ; " " ; D
 
   
 
   
Input C Noecho 'supress echo
+
Input C Noecho 'Echo unterdrücken
 
   
 
   
Input "Enter your name " , S
+
Input "Bitte Namen eingeben " , S
Print "Hello " ; S
+
Print "Hallo " ; S
 
   
 
   
Input S Noecho 'without echo
+
Input S Noecho 'Ohne Echo
 
Print S
 
Print S
 
End
 
End

Latest revision as of 01:40, 27 March 2013

Contents

Funktion

Ermöglicht Eingaben von der Tastatur, einer Datei oder über SPI.

 

 

Syntax

INPUT [" prompt" ] , var[ , varn ]

INPUT #ch, var[ , varn ]

 

 

Anmerkungen

Prompt

Optionale String-Konstante, die vor dem Prompt-Zeichen geschrieben wird.

Var,varn

Variable zur Aufnahme des Input-Wertes oder Strings.

Ch

Kanalnummer, die eine geöffnete Datei identifiziert. Kann eine Konstante oder eine Variable sein.

 

Die INPUT-Routine kann benutzt werden wenn man einen Mikrocontroller mit serieller Schnittstelle hat.

Die serielle Schnittstelle kann (über einen RS-232 - TTL Konverter) mit der seriellen Schnittstelle eines PCs verbunden werden.

Auf dieses Weise kann man die Tastatur des PCs mit einem Terminalemulator-Programm für Eingaben benutzen.

Man kann auch den in BASCOM integrierten Terminal-Emulator verwenden.

 

Bei Benutzung des AVR-DOS Datei-Systems kann man Variableninhalte aus einer geöffneten Datei lesen. Da die Variablenwerte im ASCII-Format gespeichert sind werden die Daten automatisch in das richtige Format umgewandelt.

Wenn INPUT in Zusammenhang mit Dateien benutzt wird dann ist PROMPT nicht unterstützt.


 

Unterschied zu VB

In VB kann man &H  mit INPUT spezifizieren und VB erkennt daraus, dass ein hexadezimaler Wert benutzt wird.

BASCOM hat den neuen Befehl INPUTHEX.

 

 

Xmega-SPI

Beim Empfang über das SPI-Interface muss der SS-Pin aktiviert werden. Manche Chips benötigen active low, manche Chips benötigen active high. Dies ist anhängig vom Slave-Chip.

Wenn man die SS=Auto Option benutzt dann wird der Level von SS automatisch geändert. SS wird auf Low geschaltet, Datenbytes werden empfangen und schließlich wird SS wieder high geschaltet.

Datenempfang funktioniert durch Senden eines Datenbytes und Empfang der Daten, die herausgeschrieben werden (shifted out). Die Daten, die gesendet werden sind 0. Man kann das in der Library _inputspivar Routine ändern.

Man kann nicht Konstanten senden wenn man INPUT mit SPI benutzt. Also wird INPUT #10, "SPI", var  nicht unterstützt.

INPUT in Zusammenhang mit SPI wartet auch nicht auf Empfang. Es wartet auf die Anzahl Bytes die in die Variable passen. Siehe Beispiel unter CONFIG SPIx.

 

Anzahl Bytes

Der Compiler empfängt 1 Byte für eine Variable die als BYTE dimensioniert ist.

Er empfängt 2 Bytes für WORD/INTEGER Variablen, 4 Bytes für eine LONG/SINGLE und 8 Bytes für eine DOUBLE-Variable.

Wie bei allen BASCOM-Routinen wird das least significant Byte zuerst empfangen.

 

Wenn ein Array angegeben wird dann wird ein Element empfangen.

Mit einem optionalen Parameter kann man angeben wieviele Bytes empfangen werden sollen. Man muss ein Semikolon (;) verwenden um diesen Parameter anzugeben weil das Komma (,) benutzt wird um mehrere Variablen zu empfangen.

Beispiel

Dim Tmparray(5) As Byte  , Spi_send_byte As Byte , W as Word

Input #12 , Spi_receive_byte ; 1                         ' READ 1 byte

Input #12 , Tmparray(1) ; 1 , Tmparray(2) ; B       ' read 1 byte and 'b' bytes starting at element 2

 

 

 

 

 

Siehe auch

INPUTHEX , PRINT , ECHO , WRITE , INPUTBIN

 

 

 

Beispiel


'-----------------------------------------------------------------------------------------
'name : input.bas
'copyright : (c) 1995-2005, MCS Electronics
'purpose : demo: INPUT, INPUTHEX
'micro : Mega48
'suited for demo : yes
'commercial addon needed : no
'-----------------------------------------------------------------------------------------
 
$regfile = "m48def.dat" ' specify the used micro
$crystal = 4000000 ' Taktfrequenz
$baud = 19200 ' Baudrate
$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
 
Dim V As Byte , B1 As Byte
Dim C As Integer , D As Byte
Dim S As String * 15
 
Input "Hier kann eine Frage stehen " , V
Input B1 'Weglassen wenn keine Frage
 
Input "Eingabe von Integer " , C
Print C
 
 
Inputhex "Eingabe einer Hex-Zahl (4 bytes) " , C
Print C
Inputhex "Eingabe Hex Byte (2 bytes) " , D
Print D
 
Input "Weitere Variablen " , C , D
Print C ; " " ; D
 
Input C Noecho 'Echo unterdrücken
 
Input "Bitte Namen eingeben " , S
Print "Hallo " ; S
 
Input S Noecho 'Ohne Echo
Print S
End

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