Sample Program

Pulse Motor Driver Control Program Ver 0.2


'**************************************************************
'
'  Pulse Motor Driver Control Program Ver 0.2
'
'    2001/7/9 Koichi Hirata, H. Sakakibara
'
'    motwc02.bas
'
'**************************************************************
'
' for AT90S2313-10PC
'
'*********************
' Initial set
'*********************
'
Config Portb = Output
Config Portd = Input
'Dim T As Integer
'
'*********************
' Loop
'*********************
'
Do
'
Gosub Stopmotion
Wait 3                                                        'Wait 2sec
Gosub Fwd_2
Wait 3
Gosub Fwd_3
Wait 3
Gosub Fwd_4
Wait 3
Gosub Fwd_5
Wait 3
Gosub Fwd_6
Wait 3
Gosub Stopmotion
Wait 1
Gosub Turn_r
Wait 5
Waitms 900
Gosub Fwd_2
Wait 3
Gosub Fwd_3
Wait 3
Gosub Fwd_4
Wait 3
Gosub Fwd_5
Wait 3
Gosub Fwd_6
Wait 3
Gosub Stopmotion
Wait 1
Gosub Turn_l
Wait 5
Waitms 900
'
Loop
'
Fwd_7:
Portb.3 = 1 : Portb.2 = 1 : Portb.1 = 1 : Portb.0 = 1         'Left Wheel
Portb.7 = 0 : Portb.6 = 1 : Portb.5 = 1 : Portb.4 = 1         'Right Wheel
Return                                                        '
'
Fwd_6:
Portb.3 = 1 : Portb.2 = 1 : Portb.1 = 1 : Portb.0 = 0         'Left Wheel
Portb.7 = 0 : Portb.6 = 1 : Portb.5 = 1 : Portb.4 = 0         'Right Wheel
Return                                                        '
'
Fwd_5:
Portb.3 = 1 : Portb.2 = 1 : Portb.1 = 0 : Portb.0 = 1         'Left Wheel
Portb.7 = 0 : Portb.6 = 1 : Portb.5 = 0 : Portb.4 = 1         'Right Wheel
Return                                                        '
'
Fwd_4:
Portb.3 = 1 : Portb.2 = 1 : Portb.1 = 0 : Portb.0 = 0         'Left Wheel
Portb.7 = 0 : Portb.6 = 1 : Portb.5 = 0 : Portb.4 = 0         'Right Wheel
Return                                                        '
'
Fwd_3:
Portb.3 = 1 : Portb.2 = 0 : Portb.1 = 1 : Portb.0 = 1         'Left Wheel
Portb.7 = 0 : Portb.6 = 0 : Portb.5 = 1 : Portb.4 = 1         'Right Wheel
Return                                                        '
'
Fwd_2:
Portb.3 = 1 : Portb.2 = 0 : Portb.1 = 1 : Portb.0 = 0         'Left Wheel
Portb.7 = 0 : Portb.6 = 0 : Portb.5 = 1 : Portb.4 = 0         'Right Wheel
Return                                                        '
'
Fwd_1:
Portb.3 = 1 : Portb.2 = 0 : Portb.1 = 0 : Portb.0 = 1         'Left Wheel
Portb.7 = 0 : Portb.6 = 0 : Portb.5 = 0 : Portb.4 = 1         'Right Wheel
Return                                                        '
'
Stopmotion:
Portb.3 = 0 : Portb.2 = 0 : Portb.1 = 0 : Portb.0 = 0         'Left Wheel
Portb.7 = 0 : Portb.6 = 0 : Portb.5 = 0 : Portb.4 = 0         'Right Wheel
Return                                                        '
'
Rev_1:
Portb.3 = 0 : Portb.2 = 0 : Portb.1 = 0 : Portb.0 = 1         'Left Wheel
Portb.7 = 1 : Portb.6 = 0 : Portb.5 = 0 : Portb.4 = 1         'Right Wheel
Return                                                        '
'
Rev_2:
Portb.3 = 0 : Portb.2 = 0 : Portb.1 = 1 : Portb.0 = 0         'Left Wheel
Portb.7 = 1 : Portb.6 = 0 : Portb.5 = 1 : Portb.4 = 0         'Right Wheel
Return                                                        '
'
Rev_3:
Portb.3 = 0 : Portb.2 = 0 : Portb.1 = 1 : Portb.0 = 1         'Left Wheel
Portb.7 = 1 : Portb.6 = 0 : Portb.5 = 1 : Portb.4 = 1         'Right Wheel
Return                                                        '
'
Rev_4:
Portb.3 = 0 : Portb.2 = 1 : Portb.1 = 0 : Portb.0 = 0         'Left Wheel
Portb.7 = 1 : Portb.6 = 1 : Portb.5 = 0 : Portb.4 = 0         'Right Wheel
Return                                                        '
'
Rev_5:
Portb.3 = 0 : Portb.2 = 1 : Portb.1 = 0 : Portb.0 = 1         'Left Wheel
Portb.7 = 1 : Portb.6 = 1 : Portb.5 = 0 : Portb.4 = 1         'Right Wheel
Return                                                        '
'
Rev_6:
Portb.3 = 0 : Portb.2 = 1 : Portb.1 = 1 : Portb.0 = 0         'Left Wheel
Portb.7 = 1 : Portb.6 = 1 : Portb.5 = 1 : Portb.4 = 0         'Right Wheel
Return                                                        '
'
Rev_7:
Portb.3 = 0 : Portb.2 = 0 : Portb.1 = 1 : Portb.0 = 1         'Left Wheel
Portb.7 = 1 : Portb.6 = 0 : Portb.5 = 1 : Portb.4 = 1         'Right Wheel
Return                                                        '
'
Turn_r:
Portb.3 = 1 : Portb.2 = 1 : Portb.1 = 0 : Portb.0 = 0         'Left Wheel
Portb.7 = 1 : Portb.6 = 1 : Portb.5 = 0 : Portb.4 = 0         'Right Wheel
Return
'                                                        '
Turn_l:
Portb.3 = 0 : Portb.2 = 1 : Portb.1 = 0 : Portb.0 = 0         'Left Wheel
Portb.7 = 0 : Portb.6 = 1 : Portb.5 = 0 : Portb.4 = 0         'Right Wheel
Return                                                        '
'
End

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