|
|
|
|
C51 COMPILER V9.56.0.0 PWM 04/06/2022 21:56:10 PAGE 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
C51 COMPILER V9.56.0.0, COMPILATION OF MODULE PWM
|
|
|
|
|
OBJECT MODULE PLACED IN pwm.OBJ
|
|
|
|
|
COMPILER INVOKED BY: D:\Keil_v5\C51\BIN\C51.EXE pwm.c OPTIMIZE(8,SPEED) BROWSE DEBUG OBJECTEXTEND TABS(2)
|
|
|
|
|
|
|
|
|
|
line level source
|
|
|
|
|
|
|
|
|
|
1 #include "pwm.h"
|
|
|
|
|
2
|
|
|
|
|
3 unsigned char pwm_val_left =0;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
4 unsigned char push_val_left =0;// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD>ձ<EFBFBD>N/20
|
|
|
|
|
5 unsigned char pwm_val_right =0;
|
|
|
|
|
6 unsigned char push_val_right=0;// <EFBFBD>ҵ<EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD>ձ<EFBFBD>N/20
|
|
|
|
|
7 unsigned char pwm_left=0;
|
|
|
|
|
8
|
|
|
|
|
9 bit Right_moto_stop=1;
|
|
|
|
|
10 bit Left_moto_stop =1;
|
|
|
|
|
11
|
|
|
|
|
12 unsigned int time1=0;
|
|
|
|
|
13
|
|
|
|
|
14
|
|
|
|
|
15
|
|
|
|
|
16 /************************************************************************/
|
|
|
|
|
17 //<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
18 void delay(unsigned int k)
|
|
|
|
|
19 {
|
|
|
|
|
20 1 unsigned int x,y;
|
|
|
|
|
21 1 for(x=0;x<k;x++)
|
|
|
|
|
22 1 for(y=0;y<2000;y++);
|
|
|
|
|
23 1 }
|
|
|
|
|
24 /************************************************************************/
|
|
|
|
|
25 //ǰ<EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD>
|
|
|
|
|
26 void run(void)
|
|
|
|
|
27 {
|
|
|
|
|
28 1 push_val_left=3; //<EFBFBD>ٶȵ<EFBFBD><EFBFBD>ڱ<EFBFBD><EFBFBD><EFBFBD> 0-20<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0<EFBFBD><EFBFBD>С<EFBFBD><EFBFBD>20<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
29 1 push_val_right=pwm_left;
|
|
|
|
|
30 1 Left_moto_go ; //<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD>
|
|
|
|
|
31 1 Right_moto_go ; //<EFBFBD>ҵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD>
|
|
|
|
|
32 1 }
|
|
|
|
|
33
|
|
|
|
|
34 void backrun(void)
|
|
|
|
|
35 {
|
|
|
|
|
36 1 push_val_left=3; //<EFBFBD>ٶȵ<EFBFBD><EFBFBD>ڱ<EFBFBD><EFBFBD><EFBFBD> 0-20<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0<EFBFBD><EFBFBD>С<EFBFBD><EFBFBD>20<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
37 1 push_val_right=4;
|
|
|
|
|
38 1 Left_moto_back; //<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD>
|
|
|
|
|
39 1 Right_moto_back; //<EFBFBD>ҵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD>
|
|
|
|
|
40 1 }
|
|
|
|
|
41
|
|
|
|
|
42
|
|
|
|
|
43 //<EFBFBD><EFBFBD>ת
|
|
|
|
|
44 void leftrun(void)
|
|
|
|
|
45 {
|
|
|
|
|
46 1 push_val_left=0;
|
|
|
|
|
47 1 push_val_right=4;
|
|
|
|
|
48 1 Right_moto_go ; //<EFBFBD>ҵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD>
|
|
|
|
|
49 1 }
|
|
|
|
|
50
|
|
|
|
|
51
|
|
|
|
|
52 //<EFBFBD><EFBFBD>ת
|
|
|
|
|
53 void rightrun(void)
|
|
|
|
|
54 {
|
|
|
|
|
55 1 push_val_right=0;
|
|
|
|
|
C51 COMPILER V9.56.0.0 PWM 04/06/2022 21:56:10 PAGE 2
|
|
|
|
|
|
|
|
|
|
56 1 push_val_left=4;
|
|
|
|
|
57 1 Left_moto_go ; //<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD>
|
|
|
|
|
58 1 }
|
|
|
|
|
59
|
|
|
|
|
60
|
|
|
|
|
61 void pwm_out_left_moto(void)
|
|
|
|
|
62 {
|
|
|
|
|
63 1 if(Left_moto_stop)
|
|
|
|
|
64 1 {
|
|
|
|
|
65 2 if(pwm_val_left<=push_val_left)
|
|
|
|
|
66 2 {
|
|
|
|
|
67 3 Left_moto_pwm=1;
|
|
|
|
|
68 3 }
|
|
|
|
|
69 2 else
|
|
|
|
|
70 2 {
|
|
|
|
|
71 3 Left_moto_pwm=0;
|
|
|
|
|
72 3 }
|
|
|
|
|
73 2 if(pwm_val_left>=20)
|
|
|
|
|
74 2 pwm_val_left=0;
|
|
|
|
|
75 2 }
|
|
|
|
|
76 1 else
|
|
|
|
|
77 1 {
|
|
|
|
|
78 2 Left_moto_pwm=0;
|
|
|
|
|
79 2 }
|
|
|
|
|
80 1 }
|
|
|
|
|
81 /******************************************************************/
|
|
|
|
|
82 /* <EFBFBD>ҵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
83 void pwm_out_right_moto(void)
|
|
|
|
|
84 {
|
|
|
|
|
85 1 if(Right_moto_stop)
|
|
|
|
|
86 1 {
|
|
|
|
|
87 2 if(pwm_val_right<=push_val_right)
|
|
|
|
|
88 2 {
|
|
|
|
|
89 3 Right_moto_pwm=1;
|
|
|
|
|
90 3 }
|
|
|
|
|
91 2 else
|
|
|
|
|
92 2 {
|
|
|
|
|
93 3 Right_moto_pwm=0;
|
|
|
|
|
94 3 }
|
|
|
|
|
95 2 if(pwm_val_right>=20)
|
|
|
|
|
96 2 pwm_val_right=0;
|
|
|
|
|
97 2 }
|
|
|
|
|
98 1 else
|
|
|
|
|
99 1 {
|
|
|
|
|
100 2 Right_moto_pwm=0;
|
|
|
|
|
101 2 }
|
|
|
|
|
102 1 }
|
|
|
|
|
103
|
|
|
|
|
104 void timer1()interrupt 3
|
|
|
|
|
105 {
|
|
|
|
|
106 1 TH1=0XFc; //1Ms<EFBFBD><EFBFBD>ʱ
|
|
|
|
|
107 1 TL1=0X18;
|
|
|
|
|
108 1 time1++;
|
|
|
|
|
109 1 // pwm_val_left++;
|
|
|
|
|
110 1 pwm_val_right++;
|
|
|
|
|
111 1 // pwm_out_left_moto();
|
|
|
|
|
112 1 pwm_out_right_moto();
|
|
|
|
|
113 1 }
|
|
|
|
|
114
|
|
|
|
|
115
|
|
|
|
|
116
|
|
|
|
|
117
|
|
|
|
|
C51 COMPILER V9.56.0.0 PWM 04/06/2022 21:56:10 PAGE 3
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MODULE INFORMATION: STATIC OVERLAYABLE
|
|
|
|
|
CODE SIZE = 172 ----
|
|
|
|
|
CONSTANT SIZE = ---- ----
|
|
|
|
|
XDATA SIZE = ---- ----
|
|
|
|
|
PDATA SIZE = ---- ----
|
|
|
|
|
DATA SIZE = 7 ----
|
|
|
|
|
IDATA SIZE = ---- ----
|
|
|
|
|
BIT SIZE = 2 ----
|
|
|
|
|
END OF MODULE INFORMATION.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
|