Sample Program

Pulse Motor Driverr Program Ver 0.1 for Wheelchair Model


'**************************************************************
'
'  Pulse Motor Driverr Program Ver 0.1 for Wheelchair Model
'
'    2001/7/4 Koichi Hirata
'
'    pulse01.bas
'
'**************************************************************
'
' for AT90S2313-10PC
'
'*********************
' Initial set
'*********************
'
Config Portb = Output
Config Portd = Input
'
Dim I As Byte
Dim T As Byte
Dim A As Single                                               '0 - 255
Dim F As Single                                               '0 - 255
'
'*********************
' Sencing (Loop)
'*********************
'
Do
If Pind.2 = 0 And Pind.1 = 0 And Pind.0 = 0 Then Goto Motionstop
If Pind.2 = 0 And Pind.1 = 0 And Pind.0 = 1 Then T = 80
If Pind.2 = 0 And Pind.1 = 1 And Pind.0 = 0 Then T = 70
If Pind.2 = 0 And Pind.1 = 1 And Pind.0 = 1 Then T = 60
If Pind.2 = 1 And Pind.1 = 0 And Pind.0 = 0 Then T = 50
If Pind.2 = 1 And Pind.1 = 0 And Pind.0 = 1 Then T = 40
If Pind.2 = 1 And Pind.1 = 1 And Pind.0 = 0 Then T = 30
If Pind.2 = 1 And Pind.1 = 1 And Pind.0 = 1 Then T = 20
If Pind.3 = 1 Then Goto Revmode
'
Portb.0 = 1 : Portb.1 = 0 : Portb.2 = 0 : Portb.3 = 1
Waitms T
Portb.0 = 1 : Portb.1 = 1 : Portb.2 = 0 : Portb.3 = 0
Waitms T
Portb.0 = 0 : Portb.1 = 1 : Portb.2 = 1 : Portb.3 = 0
Waitms T
Portb.0 = 0 : Portb.1 = 0 : Portb.2 = 1 : Portb.3 = 1
Waitms T
Goto Motionstop
'
Revmode:

Portb.0 = 0 : Portb.1 = 0 : Portb.2 = 1 : Portb.3 = 1
Waitms T
Portb.0 = 0 : Portb.1 = 1 : Portb.2 = 1 : Portb.3 = 0
Waitms T
Portb.0 = 1 : Portb.1 = 1 : Portb.2 = 0 : Portb.3 = 0
Waitms T
Portb.0 = 1 : Portb.1 = 0 : Portb.2 = 0 : Portb.3 = 1
Waitms T

Motionstop:
'
Loop
End

[ Microcomputer ] [ Hirata HOME ] [ Power and Energy Engineering Division ] [ NMRI HOME ]
Contact khirata@nmri.go.jp