Ok this compiles... but it won't work as there are lots missing from the code, such as the "afterbranch" subroutine hasn't been included (I just gave it a label and return) I've also added some config settings, and a few missing variables...
Code:
'************************************************* ***************
'* Name : RotaryEncoder.BAS *
'* Author : Robbe Degezelle *
'* Notice : Copyright (c) 2016 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 12/04/2016 *
'* Version : 1.0 *
'* Notes : *
'* : *
'************************************************* ***************
'initialisation------
@ __CONFIG _INTRC_OSC_NOCLKOUT & _WDT_ON & _PWRTE_ON & _MCLRE_OFF & _BOD_ON
' Internal Oscillator
' Enable watch dog timer
' Enable power up timer
' Disable MCLR pin
' Enable brown out detect
ANSEL = 0 ' Set all digital
CMCON0 = 7 ' Analog comparators off
LCD_pin var GPIO.1
'variables-----------
NewVal VAR word
OldVal VAR word
Counter VAR word
CounterCC var word
word1 var word 'C
word2 var word 'CC
CurVal var word ' This seemed to be missing from your original code... again I presume it should be a word variable as you have statements like OldVal = CurVal
P4800 CON 188 '4800 baud true
N9600 con $4054 '9600 baud rate inverted
word2=000
NewVal = (GPIO & 000) >> 3
OldVal = NewVal
Counter = 000
CounterCC = 500
word1=000
'Program----------------
Main:
NewVal = (GPIO & 000) >> 3 ; zou 0,1,2 of 3 moeten geven
If NewVal <> OldVal Then
Branch CurVal, [S0,S1,S2,S3] ; indien waarde veranderd, vergelijken met oud
EndIF
goto AfterBranch
Goto Main
S0:
If OldVal = 2 Then
GoSub Clockwise
ELSE
GoSub CounterClockwise
EndIF
Goto AfterBranch
S1:
if OldVal = 0 Then
GoSub Clockwise
ELSE
GoSub CounterClockwise
EndIF
Goto AfterBranch
S2:
if OldVal = 3 Then
GoSub Clockwise
Else
GoSub CounterClockwise
EndIf
Goto AfterBranch
S3:
if OldVal = 1 Then
GoSub Clockwise
Else
GoSUb CounterClockwise
Endif
Goto AfterBranch
Clockwise:
OldVal = CurVal
Counter = Counter + 1
word1 = Counter
serout2 GPIO.0,p4800, ["B1", DEC3 word1]
gosub disp_lcd
Return
CounterClockwise:
OldVal = CurVal
CounterCC = CounterCC + 1
word2 = Countercc
serout2 GPIO.0,p4800, ["B1", DEC3 word2]
gosub disp_lcd
return
'LCD
disp_lcd:
serout2 LCD_pin, N9600, [$FE, $1] 'clear display
pause 1
serout2 LCD_pin, N9600, [$FE, $2] 'cursor returns home
pause 1
serout2 LCD_pin, N9600, ["TellerC= ", DEC Counter]
pause 1
SEROUT2 LCD_pin,N9600, [$FE, $C0] 'cursor to 2nd line
pause 1
SEROUT2 LCD_pin,N9600, ["TellerCC= ", dec CounterCC] ' corrected this line
return
AfterBranch: ' no idea what afterbranch is meant to do, as you have several goto's afterbranch but there is no such subroutine
Return
There may be other coding errors, but the syntax seems OK and like I said this now compiles, but until you add the missing subroutines, and take on board some of the comments Henrik has mentioned it won't work. Also, your post seemed to have good command of the English language, but some of the comments (hi-lighted in green) are in a different language, which makes me wonder if the code is your own work ?
Bookmarks