Hej mam taki problem. Chciałbym sobie napisać prosty program do sterowania głośnością we wzmacniaczu. Silnik jaki chce zastosować to unipolarny krokowiec. Założenie jest proste naciskam przycisk na pilocie, silnik obraca się w prawo puszczam przycisk, silnik nie obraca sie i ważne brak napiecia na uzwojeniach ( wał obraca sie luźno). Napisałem juz programik, który tak działa, ale silnik nie obraca się płynnie co kilka kroków jest mała przerwa i kręci sie dalej.
Możecie mi pomóc, ewentualnie coś podpowiedzieć może źle to napisałem.
Siedzie juz kilka godzin i nie moge sobie z tym poradzić.
Możecie mi pomóc, ewentualnie coś podpowiedzieć może źle to napisałem.
Siedzie juz kilka godzin i nie moge sobie z tym poradzić.
$regfile = "m8def.dat"
$crystal = 8000000
Config Pinb.0 = Output
Config Pinb.1 = Output
Config Pinb.2 = Output
Config Pinb.3 = Output
Declare Sub Opoznienie1
Declare Sub Opoznienie2
Declare Sub Main
Declare Sub Obroty_prawo
Declare Sub Obroty_lewo
Config Rc5 = Pind.2
Dim Address As Byte , Command As Byte
Dim Steps As Byte
Enable Interrupts
Reset Portb.0
Reset Portb.1
Reset Portb.2
Reset Portb.3
Sub Main
Do
Reset Portb.0 : Reset Portb.1 : Reset Portb.2 : Reset Portb.3
Command = 255
Getrc5(address , Command)
Command = Command And &B01111111
If Command = 16 Then
Gosub Obroty_prawo
End If
If Command = 17 Then
Gosub Obroty_lewo
End If
Loop
End Sub
Sub Obroty_lewo:
Do
Set Portb.0 : Reset Portb.1 : Reset Portb.2 : Reset Portb.3
Call Opoznienie2
Set Portb.0 : Set Portb.1 : Reset Portb.2 : Reset Portb.3
Call Opoznienie2
Reset Portb.0 : Set Portb.1 : Reset Portb.2 : Reset Portb.3
Call Opoznienie2
Reset Portb.0 : Set Portb.1 : Set Portb.2 : Reset Portb.3
Call Opoznienie2
Reset Portb.0 : Reset Portb.1 : Set Portb.2 : Reset Portb.3
Call Opoznienie2
Reset Portb.0 : Reset Portb.1 : Set Portb.2 : Set Portb.3
Call Opoznienie2
Reset Portb.0 : Reset Portb.1 : Reset Portb.2 : Set Portb.3
Call Opoznienie2
Set Portb.0 : Reset Portb.1 : Reset Portb.2 : Set Portb.3
Call Opoznienie2
Loop Until Command = 17
End Sub
Sub Obroty_prawo:
Do
Set Portb.0 : Reset Portb.1 : Reset Portb.2 : Set Portb.3
Call Opoznienie1
Reset Portb.0 : Reset Portb.1 : Reset Portb.2 : Set Portb.3
Call Opoznienie1
Reset Portb.0 : Reset Portb.1 : Set Portb.2 : Set Portb.3
Call Opoznienie1
Reset Portb.0 : Reset Portb.1 : Set Portb.2 : Reset Portb.3
Call Opoznienie1
Reset Portb.0 : Set Portb.1 : Set Portb.2 : Reset Portb.3
Call Opoznienie1
Reset Portb.0 : Set Portb.1 : Reset Portb.2 : Reset Portb.3
Call Opoznienie1
Set Portb.0 : Set Portb.1 : Reset Portb.2 : Reset Portb.3
Call Opoznienie1
Set Portb.0 : Reset Portb.1 : Reset Portb.2 : Reset Portb.3
Call Opoznienie1
Loop Until Command = 16
End Sub
Opoznienie1:
Waitms 40
Return
Opoznienie2:
Waitms 40
Return