麦克纳姆轮

 使用直流减速电机

L298N驱动模块

驱动方式:

A为向前转,V为向后转。本案例中使用引脚如下:

左前 PC8 PC9

左后 PC6 PC7

右前 PD8 PD9

右后 PC4 PC5

 头文件中define几个轮子不同的转动方向

1 #define Left_Front_A     GPIOC->ODR |=  (0x1 << 8);GPIOC->ODR &= ~(0x1 << 9);
2 #define Left_Front_V     GPIOC->ODR &= ~(0x1 << 8);GPIOC->ODR |= 0x1 << 9;
3 #define Left_Back_A     GPIOC->ODR |=  (0x1 << 6);GPIOC->ODR &= ~(0x1 << 7);
4 #define Left_Back_V     GPIOC->ODR &= ~(0x1 << 6);GPIOC->ODR |= 0x1 << 7;
5 #define Right_Front_A    GPIOD->ODR |=  (0x1 << 8);GPIOD->ODR &= ~(0x1 << 9);
6 #define Right_Front_V    GPIOD->ODR &= ~(0x1 << 8);GPIOD->ODR |= 0x1 << 9;
7 #define Right_Back_A     GPIOC->ODR |=  (0x1 << 4);GPIOC->ODR &= ~(0x1 << 5);
8 #define Right_Back_V     GPIOC->ODR &= ~(0x1 << 4);GPIOC->ODR |= 0x1 << 5;

c文件中定义几种不同的转动方式:

 1 /*
 2 *********************************************************
 3 *麦克纳姆轮 向前
 4 *
 5 *
 6 *********************************************************
 7 */
 8 void whell_go(void)
 9 {
10     Left_Front_A;
11     Left_Back_A;
12     Right_Front_A;
13     Right_Back_A;
14 }
15 
16 /*
17 *********************************************************
18 *麦克纳姆轮 向后
19 *
20 *
21 *********************************************************
22 */
23 void whell_back(void)
24 {
25     Left_Front_V;
26     Left_Back_V;
27     Right_Front_V;
28     Right_Back_V;
29 }
30 
31 /*
32 *********************************************************
33 *麦克纳姆轮 向右
34 *
35 *
36 *********************************************************
37 */
38 void whell_right(void)
39 {
40     Left_Front_V;
41     Left_Back_A;
42     Right_Front_A;
43     Right_Back_V;
44 }
45 
46 /*
47 *********************************************************
48 *麦克纳姆轮 向左
49 *
50 *
51 *********************************************************
52 */
53 void whell_left(void)
54 {
55     Left_Front_A;
56     Left_Back_V;
57     Right_Front_V;
58     Right_Back_V;
59 }
60 
61 /*
62 *********************************************************
63 *麦克纳姆轮 左转
64 *
65 *
66 *********************************************************
67 */
68 void whell_turn_left(void)
69 {
70     Left_Front_V;
71     Left_Back_V;
72     Right_Front_A;
73     Right_Back_A;
74 }
75 
76 /*
77 *********************************************************
78 *麦克纳姆轮 右转
79 *
80 *
81 *********************************************************
82 */
83 void whell_turn_right(void)
84 {
85     Left_Front_A;
86     Left_Back_A;
87     Right_Front_V;
88     Right_Back_V;
89 }

猜你喜欢

转载自www.cnblogs.com/qifeng1024/p/11670960.html