Dobrý den, potřeboval bych pomoci s mým programem který řídí hodiny servem když ho zaptu tak servo divně bzučí a nehýbe se, samotné generování pulsů je prováděno v hlavní smyčce na konci portb.1. děkuji
$regfile = "m16def.dat"
$crystal = 4000000
$baud = 9600
$hwstack = 32
$swstack = 10
$sim
Declare Sub Noc
Dim A As Byte '16407
Dim B As Byte
Dim C As Byte
Dim D As Bit
Dim E As Long
Dim F As Long
Dim G As Long
Dim I As Long
Config Timer1 = Timer , Prescale = 256 , Compare A = Disconnect , Clear Timer = 1
Compare1a = 16407
Enable Interrupts
Enable Compare1a
On Compare1a Poc
Config Portb.1 = Output
Config Porta.0 = Input
Config Porta.1 = Input
Config Porta.2 = Input
Config Porta.3 = Input
F = 800
A = 0
B = 0
C = 0
I = 0
G = 0
D = 1
Do
If Pina.0 = 0 Then
A = 0
B = 0
C = 0
F = 800
End If
If Pina.1 = 0 Then
A = 0
B = 0
C = 4
F = 1500
End If
If Pina.2 = 0 Then
A = 0
B = 59
C = 7
F = 1950
End If
Portb.1 = 1
Waitus F
Portb.1 = 0
Waitms 20
Loop
Sub Noc
Incr A
If A > 59 Then
A = 0
Incr B
End If
If B > 59 Then
B = 0
Incr C
End If
If C = 14 Then
C = 0
D = 1
End If
End Sub
Poc:
If D = 1 Then
Incr A
Incr E
If E = 32 Then
Incr F
E = 0
End If
If A > 59 Then
A = 0
Incr B
End If
If B > 59 Then
B = 0
Incr C
End If
If C = 8 Then
A = 0
B = 0
C = 0
D = 0
F = 800
End If
Print C ; ":" ; B ; ":" ; A
Print Chr(13)
Print F
G = 0
Else
Call Noc
End If
Return
administrator: přejmenováno z "hodiny bascom"