
|
INFO - FAQ - CC2-Forum - CCPro-Forum |
|
Try this, '----------------------------------------------------------------------------------------------------' 'This program works around the input bug of the CCIUM2.01.' 'Via a terminal program positive or negative variables can be entered.' 'Type in the positive or negative variable on a terminal program and press enter,' 'exam. 1234 ENTER, or -1234 ENTER.' 'The variable will be displayed on the CCIUM2.01 LCD.' 'Feel free to use and share this software in any way you want!' '----------------------------------------------------------------------------------------------------' '*************** INS and OUTS ***************' define lcd_backlight_off port[16] '*******************************************' '**************** VARIABLES ****************' define data byte[1] define digit byte[2] define number word[2] '*******************************************' '**************** CONSTANTS ****************' '*******************************************' '****************** SETUP ******************' put 0 'needed because of a bug in CCIUM2.01 rs232 communication' gosub initialize_lcd '*******************************************' '***************** PROGRAM *****************' #start print" Enter Number" gosub input_number_via_232 print"#ON_LCD#"; print"#CLR#"; print"#L101#"; print"Number = "; print number; print"#OFF#"; goto start '*******************************************' '*************** SUBROUTINES ***************' #input_number_via_232 number = 0 digit = 0 get data 'get 8 bit ascii code' if data = 8 then goto input_number_via_232 'look for ascii code for BACKSPACE' if data = 13 then return 'look for ascii code for ENTER' if data = 45 then goto input_negative_dec 'look for ascii code for -' #input_positive_dec digit = digit + 1 data = data - 48 'translate ascii code into decimal' if number <> 0 then number = number * 10 + data else number = data 'build number' #input_positive_backspace_loop get data 'get 8 bit ascii code' if data = 8 then number = number / 10 'debuild nuumber if ascii code for BACKSPACE is recieved' if data = 8 then digit = digit - 1 if digit = 0 then goto input_number_via_232 'go back if no more digits are displayed' if data = 8 then goto input_positive_backspace_loop if data = 13 then return 'look for ascii code for ENTER' goto input_positive_dec #input_negative_dec digit = digit + 1 #input_negative_backspace_loop get data 'get 8 bit ascii code' if data = 8 then number = number / 10 'debuild number if ascii code for BACKSPACE is recieved' if data = 8 then digit = digit - 1 if digit = 0 then goto input_number_via_232 'go back if - is no longer displayed' if data = 8 then goto input_negative_backspace_loop if data = 13 then number = number * -1 'look for ascii code for ENTER and make number negative if so' if data = 13 then return 'look for ascii code for ENTER' data = data - 48 'translate ascii code into decimal' if number <> 0 then number = number * 10 + data else number = data 'build number' goto input_negative_dec '------------------------------------------------------------------------------------------------------------------' #initialize_lcd print"#ON_LCD#"; 'Initializes the lcd on the CCIAB2.0' print"#INIT#"; print"#CLR#"; lcd_backlight_off = 0 '= 1 turns the lcd backlight off' print"#OFF#"; return '*******************************************' '****************** DATA *******************' '*******************************************' > Hallo! > mein aktuelles Projekt (Steuerung/Positionierung einer Bahn) ist inzwischen relativ weit gediehen. > Leider hänge ich inzwischen mal wieder an einem Problem: > > Ich kommuniziere mit dem Controller in der Bahn bisher immer über PUT/GET Befehle, was auch grandios funktioniert. Da ich für die Soll-Position nun aber Zahlen größer 256 übertragen muss, versuche ich den INPUT Befehl zu verwenden. Selbst mit einem Terminal-Proramm funktioniert das leider nicht. z.B. INPUT zahl ... PRINT zahl gibt immer Zahlen kleiner 2 heraus. > Kann mir jemand erklären woran das liegt? Hat vieleicht jemand eine Idee wie man größere Zahlen an die serielle Schnittstelle schreiben kann? > > Danke für die Mühe > > Chris |
| Antwort schreiben |