![]() 〜マイクロコンピュータのプログラム〜 ![]() |
![]() |
'************************************************************** ' ' Rotary Encoder Counter Program for Wheelchair ' ' 2000/12/21 Koichi Hirata ' ' wchairb.bas ' '************************************************************** ' ' for AT90S2313-10PC ' 12bits Output ' '********************* ' Initial set '********************* ' Config Portb = Output Config Pind.0 = Input Config Pind.1 = Input Config Pind.2 = Output Config Pind.3 = Output Config Pind.4 = Output Config Pind.5 = Output Config Pind.6 = Output Config Pind.7 = Output Dim A As Byte '0 - 255 Dim C As Integer '-32767 - +32768 Dim D As Integer '-32767 - +32768 A = 0 C = 0 ' '********************* ' Sencing (Loop) '********************* ' Do If A = 0 And Pind.0 = 0 Then A = 1 End If If A = 1 And Pind.0 = 1 Then 'Up pulse A = 2 If Pind.1 = 1 Then C = C + 1 End If If Pind.1 = 0 Then C = C - 1 End If If C = -1 Then C = 4095 End If If C = 4096 Then C = 0 End If ' D = C If D => 2048 Then Portd.5 = 1 D = D - 2048 Else Portd.5 = 0 End If If D => 1024 Then Portd.4 = 1 D = D - 1024 Else Portd.4 = 0 End If If D => 512 Then Portd.3 = 1 D = D - 512 Else Portd.3 = 0 End If If D => 256 Then Portd.2 = 1 D = D - 256 Else Portd.2 = 0 End If If D => 128 Then Portb.7 = 1 D = D - 128 Else Portb.7 = 0 End If If D => 64 Then Portb.6 = 1 D = D - 64 Else Portb.6 = 0 End If If D => 32 Then Portb.5 = 1 D = D - 32 Else Portb.5 = 0 End If If D => 16 Then Portb.4 = 1 D = D - 16 Else Portb.4 = 0 End If If D => 8 Then Portb.3 = 1 D = D - 8 Else Portb.3 = 0 End If If D => 4 Then Portb.2 = 1 D = D - 4 Else Portb.2 = 0 End If If D => 2 Then Portb.1 = 1 D = D - 2 Else Portb.1 = 0 End If If D => 1 Then Portb.0 = 1 D = D - 1 Else Portb.0 = 0 End If End If If A = 2 And Pind.0 = 0 Then A = 0 End If Loop End |
[ Wheelchair Measuring System ] [ Barrier-free HOME ] [ NMRI HOME ] |
このページに関するお問い合わせはkhirata@nmri.go.jpまでお願いします |