oh3gdo Regular Member
 Joined: 18/11/2021 Location: FinlandPosts: 47 |
| Posted: 04:50pm 03 Nov 2022 |
|
|
|
Hey, I have again a new problem. Now with Encoder.
 I did nor get pin 19 and pin 20 to go 3.3V I added 10k resistors from both to 3.3V. Now I got 3.3V, but it doesn't start the Inter sub program, when I connect Encoder signals to ground. Can somebody help me?
Option Explicit Option default integer Dim Newcode As integer Dim Oldcode As integer Dim totalcode As integer Dim Number As integer ' Total code conversion Dim g(15)=(0,1,-1,0,-1,0,0,1,-1,0,0,-1,0,-1, 1, 0) 'gray code 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
'SetPin 19,din,pullup ' set pin 19 as input 'SetPin 20,din,pullup ' set pin 18 as input 'SetTick 1000,Inter 'Start inteterrupt for every 1ms in Inter-program SetPin 19, intl, inter, pullup 'goto Inter program, when PIN 19 goes from high to down SetPin 20, intl, inter, pullup 'goto Inter program, when PIN 20 goes from high to down
progr: ' main program Pause 1000 ' small delay Print number,Pin(19), Pin(20) If Newcode=oldcode Then GoTo progr' if they have Not chaged got start
totalcode=oldcode<<2 +newcode Print Bin$(oldcode,2),Bin$(Newcode,2),Bin$(totalcode,4) Print totalcode,g(totalcode) Number=Number+g(totalcode) Print "Number" Number GoTo progr
Sub Inter' this is the interrupt program Newcode = Pin(19) + Pin(20)*2 Print "New" newcode oldcode = newcode <<2 End Sub
Pekka |