-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPositionControl
More file actions
62 lines (49 loc) · 876 Bytes
/
PositionControl
File metadata and controls
62 lines (49 loc) · 876 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
; Starting code with basic constants and simple subroutine
; random comment
ORG 0
Start:
LOAD VelControlOn
JPOS Velocity
LOAD PosControlOn
JPOS Position
Velocity:
; IN Switches
LOAD VelControl
OUT PWM
IN Quad
OUT Hex0
JUMP Velocity
Position:
IN Switches
; LOAD PosControlSpeed
OUT PWM
IN Quad
CALL Abs
OUT Hex0
SUB PosControl
JZERO End
JUMP Position
End:
LOAD Zero
OUT PWM
JUMP End
Abs:
JPOS Abs_r ; If already positive, return
Negate:
XOR NegOne ; Flip all bits
ADDI 1 ; Add one
Abs_r:
RETURN
; IO address constants
Switches: EQU &H000
Hex0: EQU &H004
PWM: EQU &H021
Quad: EQU &H0F1
; constants
Zero: DW 0
NegOne: DW -1
VelControlOn: DW 0
PosControlOn: DW 1
VelControl: DW &B01111
PosControlSpeed: DW &B11001
PosControl: DW 540