Witam,
Mam taki problem: licznik impulsów na AVRze nie działa. Zauważyłem jednak że wszystko się liczy gdy zamiast impulsów +5V dochodzą impulsy zwarcia do masy czyli daję na PINB.0 sygnał GND i już tam się liczy. Co mam zmienić w programie by reagował nie na masę tylko na +5V?
Pozdrawiam
oto mój kod w Bascomie:
Proszę umieszczać listingi programów w znacznikach "Code". [c_p]
Mam taki problem: licznik impulsów na AVRze nie działa. Zauważyłem jednak że wszystko się liczy gdy zamiast impulsów +5V dochodzą impulsy zwarcia do masy czyli daję na PINB.0 sygnał GND i już tam się liczy. Co mam zmienić w programie by reagował nie na masę tylko na +5V?
Pozdrawiam
oto mój kod w Bascomie:
'-----------------------------------------------------------------------------------------
'name : encoder.bas
'copyright : (c) 1995-2005, MCS Electronics
'purpose : demonstration of encoder function
'micro : Mega128
'suited for demo : yes
'commercial addon needed : no
'An encoder has 2 outputs and a ground
'We connect the outputs to pinb.0 and pinb.1
'You may choose different pins as long as they are at the same PORT
'The pins must be configured to work as input pins
'This function works for all PIN registers
'-----------------------------------------------------------------------------------------
$regfile = "m128def.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
Dim A As Byte
Dim Message As String * 16
Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = Porta.4 , Db5 = Porta.5 , Db6 = Porta.6 , Db7 = Porta.7 , E = Porta.3 , Rs = Porta.2 'konfiguracja linii mikrokontrolera‚ do których dołączono wyświetlacz LCD
Print "Encoder test"
Dim B As Integer
Dim C As Integer
'we have dimmed a byte because we need to maintain the state of the encoder
Portb = &B11 ' activate pull up registers
Do
B = Encoder(pinb.0 , Pinb.1 , Links , Rechts , 1)
' ^--- 1 means wait for change which blocks programflow
' ^--------^---------- labels which are called
' ^-------^---------------------------- port PINs
Print B
Waitms 10
Loop
End
'so while you can choose PINB0 and PINB7,they must be both member of PINB
'this works on all PIN registers
Links:
C = C + 1
Print C
Initlcd
Cls
Cursor Off
Lcd C
Lowerline
Lcd C
Print C
Return
Rechts:
C = C - 1
Print C
Initlcd
Cls
Cursor Off
Lcd C
Lowerline
Lcd C
Print C
Return
EndProszę umieszczać listingi programów w znacznikach "Code". [c_p]