-
Notifications
You must be signed in to change notification settings - Fork 0
/
motor.c
65 lines (61 loc) · 1.45 KB
/
motor.c
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
63
64
65
#include "motor.h"
void Motor_Left_Stop()
{
DesiredTimeLeft = 0;
OC2R = 0;
OC2RS = 0;
}
void Motor_Right_Stop()
{
DesiredTimeRight = 0;
OC3R = 0;
OC3RS = 0;
}
void Motors_Stop(){
DesiredTimeLeft = 0;
DesiredTimeRight = 0;
OC2R = 0;
OC2RS = 0;
OC3R = 0;
OC3RS = 0;
}
void Motor_Left_Backward()
{
Motor_Left_Stop();
trisMtrLeftDirClr = ( 1 << bnMtrLeftDir );
prtMtrLeftDirClr = ( 1 << bnMtrLeftDir ); // backward
}
void Motor_Right_Backward()
{
Motor_Right_Stop();
trisMtrRightDirClr = ( 1 << bnMtrRightDir );
prtMtrRightDirSet = ( 1 << bnMtrRightDir ); // backward
}
void Motors_Backward()
{
//Motors_Stop();
trisMtrLeftDirClr = ( 1 << bnMtrLeftDir );
prtMtrLeftDirClr = ( 1 << bnMtrLeftDir ); // backward
trisMtrRightDirClr = ( 1 << bnMtrRightDir );
prtMtrRightDirSet = ( 1 << bnMtrRightDir ); // backward
}
void Motor_Left_Forward()
{
Motor_Left_Stop();
trisMtrLeftDirClr = ( 1 << bnMtrLeftDir );
prtMtrLeftDirSet = ( 1 << bnMtrLeftDir ); // forward
}
void Motor_Right_Forward()
{
Motor_Right_Stop();
trisMtrRightDirClr = ( 1 << bnMtrRightDir );
prtMtrRightDirClr = ( 1 << bnMtrRightDir ); // forward
}
void Motors_Forward()
{
//Motors_Stop();
trisMtrLeftDirClr = ( 1 << bnMtrLeftDir );
prtMtrLeftDirSet = ( 1 << bnMtrLeftDir ); // forward
trisMtrRightDirClr = ( 1 << bnMtrRightDir );
prtMtrRightDirClr = ( 1 << bnMtrRightDir ); // forward
}