Kod: Zaznacz cały
Pozycjonowanie:
'przetważanie przechyłu na współczynnik kierowany do obliczeń mocy silników
If Kat_x >= 0 Then Wsx = Kat_x * 3
If Kat_x < 0 Then Wsx = Kat_x * -3
If Kat_y >= 0 Then Wsy = Kat_y * 3
If Kat_y < 0 Then Wsy = Kat_y * -3
'wspłóczynnik x i y nieprzekracza 70
If Wsx > 70 Then Wsx = 70
If Wsy > 70 Then Wsy = 70
'jeśli prosto to błąd=0
If Kat_x = 0 Then
Blad_d = 0
Blad_b = 0
End If
If Kat_y = 0 Then
Blad_a = 0
Blad_c = 0
End If
'sterowanie ledami
If Kat_x = 0 Then Led2 = 1
If Kat_y = 0 Then Led3 = 1
If Kat_x <> 0 Then Led2 = 0
If Kat_y <> 0 Then Led3 = 0
'sortowanie wartości błędu w zależności od przechylenia
If Kat_x < 0 Then Blad_d = Wsx
If Kat_x > 0 Then Blad_b = Wsx
If Kat_y > 0 Then Blad_c = Wsy
If Kat_y < 0 Then Blad_a = Wsy
'wpisywanie wartości do PWM
Moc_a = Blad_a + Moc
Moc_b = Blad_b + Moc
Moc_c = Blad_c + Moc
Moc_d = Blad_d + Moc
Return
Kod: Zaznacz cały
Przerwanie_t2:
Incr Licznik
'PWM
If Licznik >= Moc_a Then Reset Ma Else Set Ma
If Licznik >= Moc_b Then Reset Mb Else Set Mb
If Licznik >= Moc_c Then Reset Mc Else Set Mc
If Licznik >= Moc_d Then Reset Md Else Set Md
Return