1 |
CCS PCM C Compiler, Version 3.221, 27853 03-IX-05 19:25 |
1 |
CCS PCM C Compiler, Version 3.221, 27853 03-IX-05 19:25 |
2 |
|
2 |
|
3 |
Filename: D:\MLAB\_Z\DART01A\SW\1_01\DART.LST |
3 |
Filename: D:\MLAB\_Z\DART01A\SW\1_01\DART.LST |
4 |
|
4 |
|
5 |
ROM used: 1096 words (27%) |
5 |
ROM used: 1096 words (27%) |
6 |
Largest free fragment is 2048 |
6 |
Largest free fragment is 2048 |
7 |
RAM used: 25 (14%) at main() level |
7 |
RAM used: 25 (14%) at main() level |
8 |
43 (25%) worst case |
8 |
43 (25%) worst case |
9 |
Stack: 6 worst case (3 in main + 3 for interrupts) |
9 |
Stack: 6 worst case (3 in main + 3 for interrupts) |
10 |
|
10 |
|
11 |
* |
11 |
* |
12 |
0000: MOVLW 00 |
12 |
0000: MOVLW 00 |
13 |
0001: MOVWF 0A |
13 |
0001: MOVWF 0A |
14 |
0002: GOTO 25F |
14 |
0002: GOTO 25F |
15 |
0003: NOP |
15 |
0003: NOP |
16 |
0004: MOVWF 7F |
16 |
0004: MOVWF 7F |
17 |
0005: SWAPF 03,W |
17 |
0005: SWAPF 03,W |
18 |
0006: CLRF 03 |
18 |
0006: CLRF 03 |
19 |
0007: MOVWF 21 |
19 |
0007: MOVWF 21 |
20 |
0008: MOVF 7F,W |
20 |
0008: MOVF 7F,W |
21 |
0009: MOVWF 20 |
21 |
0009: MOVWF 20 |
22 |
000A: MOVF 0A,W |
22 |
000A: MOVF 0A,W |
23 |
000B: MOVWF 28 |
23 |
000B: MOVWF 28 |
24 |
000C: CLRF 0A |
24 |
000C: CLRF 0A |
25 |
000D: SWAPF 20,F |
25 |
000D: SWAPF 20,F |
26 |
000E: MOVF 04,W |
26 |
000E: MOVF 04,W |
27 |
000F: MOVWF 22 |
27 |
000F: MOVWF 22 |
28 |
0010: MOVF 77,W |
28 |
0010: MOVF 77,W |
29 |
0011: MOVWF 23 |
29 |
0011: MOVWF 23 |
30 |
0012: MOVF 78,W |
30 |
0012: MOVF 78,W |
31 |
0013: MOVWF 24 |
31 |
0013: MOVWF 24 |
32 |
0014: MOVF 79,W |
32 |
0014: MOVF 79,W |
33 |
0015: MOVWF 25 |
33 |
0015: MOVWF 25 |
34 |
0016: MOVF 7A,W |
34 |
0016: MOVF 7A,W |
35 |
0017: MOVWF 26 |
35 |
0017: MOVWF 26 |
36 |
0018: MOVF 7B,W |
36 |
0018: MOVF 7B,W |
37 |
0019: MOVWF 27 |
37 |
0019: MOVWF 27 |
38 |
001A: BCF 03.7 |
38 |
001A: BCF 03.7 |
39 |
001B: BCF 03.5 |
39 |
001B: BCF 03.5 |
40 |
001C: MOVLW 8C |
40 |
001C: MOVLW 8C |
41 |
001D: MOVWF 04 |
41 |
001D: MOVWF 04 |
42 |
001E: BTFSS 00.3 |
42 |
001E: BTFSS 00.3 |
43 |
001F: GOTO 022 |
43 |
001F: GOTO 022 |
44 |
0020: BTFSC 0C.3 |
44 |
0020: BTFSC 0C.3 |
45 |
0021: GOTO 039 |
45 |
0021: GOTO 039 |
46 |
0022: BTFSS 0B.5 |
46 |
0022: BTFSS 0B.5 |
47 |
0023: GOTO 026 |
47 |
0023: GOTO 026 |
48 |
0024: BTFSC 0B.2 |
48 |
0024: BTFSC 0B.2 |
49 |
0025: GOTO 03B |
49 |
0025: GOTO 03B |
50 |
0026: MOVF 22,W |
50 |
0026: MOVF 22,W |
51 |
0027: MOVWF 04 |
51 |
0027: MOVWF 04 |
52 |
0028: MOVF 23,W |
52 |
0028: MOVF 23,W |
53 |
0029: MOVWF 77 |
53 |
0029: MOVWF 77 |
54 |
002A: MOVF 24,W |
54 |
002A: MOVF 24,W |
55 |
002B: MOVWF 78 |
55 |
002B: MOVWF 78 |
56 |
002C: MOVF 25,W |
56 |
002C: MOVF 25,W |
57 |
002D: MOVWF 79 |
57 |
002D: MOVWF 79 |
58 |
002E: MOVF 26,W |
58 |
002E: MOVF 26,W |
59 |
002F: MOVWF 7A |
59 |
002F: MOVWF 7A |
60 |
0030: MOVF 27,W |
60 |
0030: MOVF 27,W |
61 |
0031: MOVWF 7B |
61 |
0031: MOVWF 7B |
62 |
0032: MOVF 28,W |
62 |
0032: MOVF 28,W |
63 |
0033: MOVWF 0A |
63 |
0033: MOVWF 0A |
64 |
0034: SWAPF 21,W |
64 |
0034: SWAPF 21,W |
65 |
0035: MOVWF 03 |
65 |
0035: MOVWF 03 |
66 |
0036: SWAPF 7F,F |
66 |
0036: SWAPF 7F,F |
67 |
0037: SWAPF 7F,W |
67 |
0037: SWAPF 7F,W |
68 |
0038: RETFIE |
68 |
0038: RETFIE |
69 |
0039: BCF 0A.3 |
69 |
0039: BCF 0A.3 |
70 |
003A: GOTO 0A5 |
70 |
003A: GOTO 0A5 |
71 |
003B: BCF 0A.3 |
71 |
003B: BCF 0A.3 |
72 |
003C: GOTO 0D3 |
72 |
003C: GOTO 0D3 |
73 |
.................... // DART01A verze programu 1.01 |
73 |
.................... // DART01A verze programu 1.01 |
74 |
.................... // (c)miho 2005 |
74 |
.................... // (c)miho 2005 |
75 |
.................... // |
75 |
.................... // |
76 |
.................... // 1.00 Uvodni verze |
76 |
.................... // 1.00 Uvodni verze |
77 |
.................... // 1.01 Doplneno nasatvovani parametru rozjezdu P2 u standardniho algoritmu |
77 |
.................... // 1.01 Doplneno nasatvovani parametru rozjezdu P2 u standardniho algoritmu |
78 |
.................... |
78 |
.................... |
79 |
.................... #include "DART.h" |
79 |
.................... #include "DART.h" |
80 |
.................... // DART01A verze programu 1.00 |
80 |
.................... // DART01A verze programu 1.00 |
81 |
.................... // (c)miho 2005 |
81 |
.................... // (c)miho 2005 |
82 |
.................... |
82 |
.................... |
83 |
.................... #include <16F88.h> // standardni definice konstant |
83 |
.................... #include <16F88.h> // standardni definice konstant |
84 |
.................... //////// Header file for the PIC16F88 |
84 |
.................... //////// Header file for the PIC16F88 |
85 |
.................... #device PIC16F88 |
85 |
.................... #device PIC16F88 |
86 |
.................... #list |
86 |
.................... #list |
87 |
.................... #include <16F88_Reg.h> // standardni definice vsech FSR |
87 |
.................... #include <16F88_Reg.h> // standardni definice vsech FSR |
88 |
.................... #list |
88 |
.................... #list |
89 |
.................... |
89 |
.................... |
90 |
.................... |
90 |
.................... |
91 |
.................... #device adc=8 // AD prevodnik jen na 8 bitu |
91 |
.................... #device adc=8 // AD prevodnik jen na 8 bitu |
92 |
.................... #define xclock 4168000 // muj konkretni PIC je trochu rychlejsi |
92 |
.................... #define xclock 4168000 // muj konkretni PIC je trochu rychlejsi |
93 |
.................... #use delay(clock=xclock,restart_wdt) |
93 |
.................... #use delay(clock=xclock,restart_wdt) |
94 |
* |
94 |
* |
95 |
00FD: MOVLW 11 |
95 |
00FD: MOVLW 11 |
96 |
00FE: SUBWF 3F,F |
96 |
00FE: SUBWF 3F,F |
97 |
00FF: BTFSS 03.0 |
97 |
00FF: BTFSS 03.0 |
98 |
0100: GOTO 10F |
98 |
0100: GOTO 10F |
99 |
0101: MOVLW 3F |
99 |
0101: MOVLW 3F |
100 |
0102: MOVWF 04 |
100 |
0102: MOVWF 04 |
101 |
0103: MOVLW FC |
101 |
0103: MOVLW FC |
102 |
0104: ANDWF 00,F |
102 |
0104: ANDWF 00,F |
103 |
0105: BCF 03.0 |
103 |
0105: BCF 03.0 |
104 |
0106: RRF 00,F |
104 |
0106: RRF 00,F |
105 |
0107: RRF 00,F |
105 |
0107: RRF 00,F |
106 |
0108: MOVF 00,W |
106 |
0108: MOVF 00,W |
107 |
0109: BTFSC 03.2 |
107 |
0109: BTFSC 03.2 |
108 |
010A: GOTO 10F |
108 |
010A: GOTO 10F |
109 |
010B: GOTO 10D |
109 |
010B: GOTO 10D |
110 |
010C: CLRWDT |
110 |
010C: CLRWDT |
111 |
010D: DECFSZ 00,F |
111 |
010D: DECFSZ 00,F |
112 |
010E: GOTO 10C |
112 |
010E: GOTO 10C |
113 |
010F: BCF 0A.3 |
113 |
010F: BCF 0A.3 |
114 |
0110: GOTO 2A8 (RETURN) |
114 |
0110: GOTO 2A8 (RETURN) |
115 |
* |
115 |
* |
116 |
020D: MOVLW 3E |
116 |
020D: MOVLW 3E |
117 |
020E: MOVWF 04 |
117 |
020E: MOVWF 04 |
118 |
020F: MOVF 00,W |
118 |
020F: MOVF 00,W |
119 |
0210: BTFSC 03.2 |
119 |
0210: BTFSC 03.2 |
120 |
0211: GOTO 223 |
120 |
0211: GOTO 223 |
121 |
0212: MOVLW 01 |
121 |
0212: MOVLW 01 |
122 |
0213: MOVWF 78 |
122 |
0213: MOVWF 78 |
123 |
0214: MOVLW BF |
123 |
0214: MOVLW BF |
124 |
0215: MOVWF 77 |
124 |
0215: MOVWF 77 |
125 |
0216: CLRWDT |
125 |
0216: CLRWDT |
126 |
0217: DECFSZ 77,F |
126 |
0217: DECFSZ 77,F |
127 |
0218: GOTO 216 |
127 |
0218: GOTO 216 |
128 |
0219: DECFSZ 78,F |
128 |
0219: DECFSZ 78,F |
129 |
021A: GOTO 214 |
129 |
021A: GOTO 214 |
130 |
021B: MOVLW 58 |
130 |
021B: MOVLW 58 |
131 |
021C: MOVWF 77 |
131 |
021C: MOVWF 77 |
132 |
021D: DECFSZ 77,F |
132 |
021D: DECFSZ 77,F |
133 |
021E: GOTO 21D |
133 |
021E: GOTO 21D |
134 |
021F: NOP |
134 |
021F: NOP |
135 |
0220: CLRWDT |
135 |
0220: CLRWDT |
136 |
0221: DECFSZ 00,F |
136 |
0221: DECFSZ 00,F |
137 |
0222: GOTO 212 |
137 |
0222: GOTO 212 |
138 |
0223: RETLW 00 |
138 |
0223: RETLW 00 |
139 |
.................... #fuses INTRC_IO, WDT, NOPUT, NOPROTECT, NOBROWNOUT, MCLR, NOLVP, NOCPD, NODEBUG, CCPB3 |
139 |
.................... #fuses INTRC_IO, WDT, NOPUT, NOPROTECT, NOBROWNOUT, MCLR, NOLVP, NOCPD, NODEBUG, CCPB3 |
140 |
.................... |
140 |
.................... |
141 |
.................... |
141 |
.................... |
142 |
.................... |
142 |
.................... |
143 |
.................... #define BEEP0 PIN_A6 // pipak, prvni vystup |
143 |
.................... #define BEEP0 PIN_A6 // pipak, prvni vystup |
144 |
.................... #define BEEP1 PIN_A7 // pipak, druhy vystup |
144 |
.................... #define BEEP1 PIN_A7 // pipak, druhy vystup |
145 |
.................... #define PWM PIN_B3 // PWM vystup pro menic |
145 |
.................... #define PWM PIN_B3 // PWM vystup pro menic |
146 |
.................... #define REFPOWER PIN_B1 // napajeni zdroje Vref |
146 |
.................... #define REFPOWER PIN_B1 // napajeni zdroje Vref |
147 |
.................... #define MOTOR PIN_B2 // zapinani motoru |
147 |
.................... #define MOTOR PIN_B2 // zapinani motoru |
148 |
.................... #define SW0 PIN_B7 // konfiguracni prepinac 0 |
148 |
.................... #define SW0 PIN_B7 // konfiguracni prepinac 0 |
149 |
.................... #define SW1 PIN_B6 // konfiguracni prepinac 1 |
149 |
.................... #define SW1 PIN_B6 // konfiguracni prepinac 1 |
150 |
.................... |
150 |
.................... |
151 |
.................... |
151 |
.................... |
152 |
.................... void InitRS232() |
152 |
.................... void InitRS232() |
153 |
.................... // Inicializace HW RS232 (pro ladici vystupy) |
153 |
.................... // Inicializace HW RS232 (pro ladici vystupy) |
154 |
.................... { |
154 |
.................... { |
155 |
.................... SPBRG=xclock/9600/16-1; // ryclost 9600Bd |
155 |
.................... SPBRG=xclock/9600/16-1; // ryclost 9600Bd |
156 |
* |
156 |
* |
157 |
00F1: MOVLW 1A |
157 |
00F1: MOVLW 1A |
158 |
00F2: BSF 03.5 |
158 |
00F2: BSF 03.5 |
159 |
00F3: MOVWF 19 |
159 |
00F3: MOVWF 19 |
160 |
.................... RCSTA=0b10000000; // enable USART |
160 |
.................... RCSTA=0b10000000; // enable USART |
161 |
00F4: MOVLW 80 |
161 |
00F4: MOVLW 80 |
162 |
00F5: BCF 03.5 |
162 |
00F5: BCF 03.5 |
163 |
00F6: MOVWF 18 |
163 |
00F6: MOVWF 18 |
164 |
.................... TXSTA=0b00100100; // BRGH=1, TX enable |
164 |
.................... TXSTA=0b00100100; // BRGH=1, TX enable |
165 |
00F7: MOVLW 24 |
165 |
00F7: MOVLW 24 |
166 |
00F8: BSF 03.5 |
166 |
00F8: BSF 03.5 |
167 |
00F9: MOVWF 18 |
167 |
00F9: MOVWF 18 |
168 |
.................... } |
168 |
.................... } |
169 |
00FA: BCF 03.5 |
169 |
00FA: BCF 03.5 |
170 |
00FB: BCF 0A.3 |
170 |
00FB: BCF 0A.3 |
171 |
00FC: GOTO 28A (RETURN) |
171 |
00FC: GOTO 28A (RETURN) |
172 |
.................... |
172 |
.................... |
173 |
.................... |
173 |
.................... |
174 |
.................... void Putc(char c) |
174 |
.................... void Putc(char c) |
175 |
.................... // Posilani znaku pres HW RS232 |
175 |
.................... // Posilani znaku pres HW RS232 |
176 |
.................... { |
176 |
.................... { |
177 |
.................... while(TRMT==0); // cekej na prazdny TX buffer |
177 |
.................... while(TRMT==0); // cekej na prazdny TX buffer |
178 |
* |
178 |
* |
179 |
0111: BSF 03.5 |
179 |
0111: BSF 03.5 |
180 |
0112: BTFSC 18.1 |
180 |
0112: BTFSC 18.1 |
181 |
0113: GOTO 116 |
181 |
0113: GOTO 116 |
182 |
0114: BCF 03.5 |
182 |
0114: BCF 03.5 |
183 |
0115: GOTO 111 |
183 |
0115: GOTO 111 |
184 |
.................... TXREG=c; // predej data |
184 |
.................... TXREG=c; // predej data |
185 |
0116: BCF 03.5 |
185 |
0116: BCF 03.5 |
186 |
0117: MOVF 42,W |
186 |
0117: MOVF 42,W |
187 |
0118: MOVWF 19 |
187 |
0118: MOVWF 19 |
188 |
.................... } |
188 |
.................... } |
189 |
0119: RETLW 00 |
189 |
0119: RETLW 00 |
190 |
.................... |
190 |
.................... |
191 |
.................... |
191 |
.................... |
192 |
.................... // Globalni promenna pro data posilana na SSP |
192 |
.................... // Globalni promenna pro data posilana na SSP |
193 |
.................... // Nastavuje se funkci MotorPatternSet() |
193 |
.................... // Nastavuje se funkci MotorPatternSet() |
194 |
.................... // Vyuziva se v prerusovaci rutine IntSSP() |
194 |
.................... // Vyuziva se v prerusovaci rutine IntSSP() |
195 |
.................... unsigned int8 MotorPattern; // aktualni data pro SSP jednotku |
195 |
.................... unsigned int8 MotorPattern; // aktualni data pro SSP jednotku |
196 |
.................... |
196 |
.................... |
197 |
.................... |
197 |
.................... |
198 |
.................... void MotorPatternSet(unsigned int Gear) |
198 |
.................... void MotorPatternSet(unsigned int Gear) |
199 |
.................... // Na zaklade rychlostniho stupne nastavi MotorPattern pro SSP |
199 |
.................... // Na zaklade rychlostniho stupne nastavi MotorPattern pro SSP |
200 |
.................... // Rychlost 0 znamena stop, rychlost 8 je maximum |
200 |
.................... // Rychlost 0 znamena stop, rychlost 8 je maximum |
201 |
.................... { |
201 |
.................... { |
202 |
.................... // Tabulka rychlost -> pattern pro SSP |
202 |
.................... // Tabulka rychlost -> pattern pro SSP |
203 |
.................... unsigned int8 const ExpTab[8] = {0x02,0x06,0x0e,0x1e,0x3e,0x7e,0xfe,0xff}; |
203 |
.................... unsigned int8 const ExpTab[8] = {0x02,0x06,0x0e,0x1e,0x3e,0x7e,0xfe,0xff}; |
204 |
.................... |
204 |
.................... |
205 |
.................... // Vyber patternu |
205 |
.................... // Vyber patternu |
206 |
.................... if (Gear==0) // stav 0 znamena stop |
206 |
.................... if (Gear==0) // stav 0 znamena stop |
207 |
* |
207 |
* |
208 |
00AA: MOVF 45,F |
208 |
00AA: MOVF 45,F |
209 |
00AB: BTFSS 03.2 |
209 |
00AB: BTFSS 03.2 |
210 |
00AC: GOTO 0B9 |
210 |
00AC: GOTO 0B9 |
211 |
.................... { |
211 |
.................... { |
212 |
.................... output_low(MOTOR); // klidovy stav |
212 |
.................... output_low(MOTOR); // klidovy stav |
213 |
00AD: BSF 03.5 |
213 |
00AD: BSF 03.5 |
214 |
00AE: BCF 06.2 |
214 |
00AE: BCF 06.2 |
215 |
00AF: BCF 03.5 |
215 |
00AF: BCF 03.5 |
216 |
00B0: BCF 06.2 |
216 |
00B0: BCF 06.2 |
217 |
.................... SSPSTAT = 0; |
217 |
.................... SSPSTAT = 0; |
218 |
00B1: BSF 03.5 |
218 |
00B1: BSF 03.5 |
219 |
00B2: CLRF 14 |
219 |
00B2: CLRF 14 |
220 |
.................... SSPCON1 = 0; // SPI stop |
220 |
.................... SSPCON1 = 0; // SPI stop |
221 |
00B3: BCF 03.5 |
221 |
00B3: BCF 03.5 |
222 |
00B4: CLRF 14 |
222 |
00B4: CLRF 14 |
223 |
.................... disable_interrupts(INT_SSP); // neni preruseni od SSP |
223 |
.................... disable_interrupts(INT_SSP); // neni preruseni od SSP |
224 |
00B5: BSF 03.5 |
224 |
00B5: BSF 03.5 |
225 |
00B6: BCF 0C.3 |
225 |
00B6: BCF 0C.3 |
226 |
.................... } |
226 |
.................... } |
227 |
.................... else // rizeny vykon |
227 |
.................... else // rizeny vykon |
228 |
00B7: GOTO 0D1 |
228 |
00B7: GOTO 0D1 |
229 |
00B8: BCF 03.5 |
229 |
00B8: BCF 03.5 |
230 |
.................... { |
230 |
.................... { |
231 |
.................... if (Gear>7) // stav 8 a vice znamena plny vykon |
231 |
.................... if (Gear>7) // stav 8 a vice znamena plny vykon |
232 |
00B9: MOVF 45,W |
232 |
00B9: MOVF 45,W |
233 |
00BA: SUBLW 07 |
233 |
00BA: SUBLW 07 |
234 |
00BB: BTFSC 03.0 |
234 |
00BB: BTFSC 03.0 |
235 |
00BC: GOTO 0BF |
235 |
00BC: GOTO 0BF |
236 |
.................... { |
236 |
.................... { |
237 |
.................... Gear=8; // plny plyn |
237 |
.................... Gear=8; // plny plyn |
238 |
00BD: MOVLW 08 |
238 |
00BD: MOVLW 08 |
239 |
00BE: MOVWF 45 |
239 |
00BE: MOVWF 45 |
240 |
.................... } |
240 |
.................... } |
241 |
.................... |
241 |
.................... |
242 |
.................... MotorPattern=ExpTab[--Gear]; // prevod z hodnoty plynu na data pro SSP |
242 |
.................... MotorPattern=ExpTab[--Gear]; // prevod z hodnoty plynu na data pro SSP |
243 |
00BF: DECF 45,F |
243 |
00BF: DECF 45,F |
244 |
00C0: MOVF 45,W |
244 |
00C0: MOVF 45,W |
245 |
00C1: CALL 03D |
245 |
00C1: CALL 03D |
246 |
00C2: MOVWF 78 |
246 |
00C2: MOVWF 78 |
247 |
00C3: MOVWF 2A |
247 |
00C3: MOVWF 2A |
248 |
.................... output_low(MOTOR); // klidovy stav |
248 |
.................... output_low(MOTOR); // klidovy stav |
249 |
00C4: BSF 03.5 |
249 |
00C4: BSF 03.5 |
250 |
00C5: BCF 06.2 |
250 |
00C5: BCF 06.2 |
251 |
00C6: BCF 03.5 |
251 |
00C6: BCF 03.5 |
252 |
00C7: BCF 06.2 |
252 |
00C7: BCF 06.2 |
253 |
.................... SSPSTAT = 0; |
253 |
.................... SSPSTAT = 0; |
254 |
00C8: BSF 03.5 |
254 |
00C8: BSF 03.5 |
255 |
00C9: CLRF 14 |
255 |
00C9: CLRF 14 |
256 |
.................... SSPCON1 = 0x22; // SPI OSC/64 |
256 |
.................... SSPCON1 = 0x22; // SPI OSC/64 |
257 |
00CA: MOVLW 22 |
257 |
00CA: MOVLW 22 |
258 |
00CB: BCF 03.5 |
258 |
00CB: BCF 03.5 |
259 |
00CC: MOVWF 14 |
259 |
00CC: MOVWF 14 |
260 |
.................... |
260 |
.................... |
261 |
.................... SSPBUF=MotorPattern; // prvni data pro vyslani |
261 |
.................... SSPBUF=MotorPattern; // prvni data pro vyslani |
262 |
00CD: MOVF 2A,W |
262 |
00CD: MOVF 2A,W |
263 |
00CE: MOVWF 13 |
263 |
00CE: MOVWF 13 |
264 |
.................... enable_interrupts(INT_SSP); // az budou vyslana prijde interrupt od SSP |
264 |
.................... enable_interrupts(INT_SSP); // az budou vyslana prijde interrupt od SSP |
265 |
00CF: BSF 03.5 |
265 |
00CF: BSF 03.5 |
266 |
00D0: BSF 0C.3 |
266 |
00D0: BSF 0C.3 |
267 |
.................... } |
267 |
.................... } |
268 |
.................... } |
268 |
.................... } |
269 |
00D1: BCF 03.5 |
269 |
00D1: BCF 03.5 |
270 |
00D2: RETLW 00 |
270 |
00D2: RETLW 00 |
271 |
.................... |
271 |
.................... |
272 |
.................... |
272 |
.................... |
273 |
.................... // Obsluha preruseni od SSP jednotky, posila data z promenne MotorRun do SSP. |
273 |
.................... // Obsluha preruseni od SSP jednotky, posila data z promenne MotorRun do SSP. |
274 |
.................... #INT_SSP |
274 |
.................... #INT_SSP |
275 |
.................... void IntSSP() |
275 |
.................... void IntSSP() |
276 |
.................... { |
276 |
.................... { |
277 |
.................... SSPBUF=MotorPattern; // znova hdnota PWM patternu na SSP |
277 |
.................... SSPBUF=MotorPattern; // znova hdnota PWM patternu na SSP |
278 |
* |
278 |
* |
279 |
00A5: MOVF 2A,W |
279 |
00A5: MOVF 2A,W |
280 |
00A6: MOVWF 13 |
280 |
00A6: MOVWF 13 |
281 |
.................... } |
281 |
.................... } |
282 |
.................... |
282 |
.................... |
283 |
.................... |
283 |
.................... |
284 |
00A7: BCF 0C.3 |
284 |
00A7: BCF 0C.3 |
285 |
00A8: BCF 0A.3 |
285 |
00A8: BCF 0A.3 |
286 |
00A9: GOTO 026 |
286 |
00A9: GOTO 026 |
287 |
.................... void MotorSet(unsigned int Gear) |
287 |
.................... void MotorSet(unsigned int Gear) |
288 |
* |
288 |
* |
289 |
0224: CLRF 29 |
289 |
0224: CLRF 29 |
290 |
0225: BTFSC 0B.7 |
290 |
0225: BTFSC 0B.7 |
291 |
0226: BSF 29.7 |
291 |
0226: BSF 29.7 |
292 |
0227: BCF 0B.7 |
292 |
0227: BCF 0B.7 |
293 |
.................... // Nastavi vykon motoru dle hodnoty Gear a zahaji posilani PWM dat pres SSP pod prerusenim |
293 |
.................... // Nastavi vykon motoru dle hodnoty Gear a zahaji posilani PWM dat pres SSP pod prerusenim |
294 |
.................... // od SSP jednotky |
294 |
.................... // od SSP jednotky |
295 |
.................... // 0 stop |
295 |
.................... // 0 stop |
296 |
.................... // 1-7 pocet 1/8 vykonu |
296 |
.................... // 1-7 pocet 1/8 vykonu |
297 |
.................... // >7 plny vykon |
297 |
.................... // >7 plny vykon |
298 |
.................... { |
298 |
.................... { |
299 |
.................... // Nastav PWM pattern |
299 |
.................... // Nastav PWM pattern |
300 |
.................... MotorPatternSet(Gear); // nastav PWM pattern pro SSP |
300 |
.................... MotorPatternSet(Gear); // nastav PWM pattern pro SSP |
301 |
0228: MOVF 3E,W |
301 |
0228: MOVF 3E,W |
302 |
0229: MOVWF 45 |
302 |
0229: MOVWF 45 |
303 |
022A: CALL 0AA |
303 |
022A: CALL 0AA |
304 |
022B: BTFSC 29.7 |
304 |
022B: BTFSC 29.7 |
305 |
022C: BSF 0B.7 |
305 |
022C: BSF 0B.7 |
306 |
.................... |
306 |
.................... |
307 |
.................... // Povol preruseni |
307 |
.................... // Povol preruseni |
308 |
.................... enable_interrupts(GLOBAL); // povol preruseni |
308 |
.................... enable_interrupts(GLOBAL); // povol preruseni |
309 |
022D: MOVLW C0 |
309 |
022D: MOVLW C0 |
310 |
022E: IORWF 0B,F |
310 |
022E: IORWF 0B,F |
311 |
.................... } |
311 |
.................... } |
312 |
022F: RETLW 00 |
312 |
022F: RETLW 00 |
313 |
.................... |
313 |
.................... |
314 |
.................... |
314 |
.................... |
315 |
.................... void InitT0() |
315 |
.................... void InitT0() |
316 |
.................... // Inicializace casovace T0 (cca 1000x za sekundu) |
316 |
.................... // Inicializace casovace T0 (cca 1000x za sekundu) |
317 |
.................... { |
317 |
.................... { |
318 |
.................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_4); // T0 z internich hodin 1/4 |
318 |
.................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_4); // T0 z internich hodin 1/4 |
319 |
* |
319 |
* |
320 |
018A: BSF 03.5 |
320 |
018A: BSF 03.5 |
321 |
018B: MOVF 01,W |
321 |
018B: MOVF 01,W |
322 |
018C: ANDLW C0 |
322 |
018C: ANDLW C0 |
323 |
018D: IORLW 01 |
323 |
018D: IORLW 01 |
324 |
018E: MOVWF 01 |
324 |
018E: MOVWF 01 |
325 |
.................... enable_interrupts(INT_RTCC); // generuj preruseni od T0 |
325 |
.................... enable_interrupts(INT_RTCC); // generuj preruseni od T0 |
326 |
018F: BCF 03.5 |
326 |
018F: BCF 03.5 |
327 |
0190: BSF 0B.5 |
327 |
0190: BSF 0B.5 |
328 |
.................... enable_interrupts(GLOBAL); // povol preruseni |
328 |
.................... enable_interrupts(GLOBAL); // povol preruseni |
329 |
0191: MOVLW C0 |
329 |
0191: MOVLW C0 |
330 |
0192: IORWF 0B,F |
330 |
0192: IORWF 0B,F |
331 |
.................... } |
331 |
.................... } |
332 |
0193: BCF 0A.3 |
332 |
0193: BCF 0A.3 |
333 |
0194: GOTO 2DD (RETURN) |
333 |
0194: GOTO 2DD (RETURN) |
334 |
.................... |
334 |
.................... |
335 |
.................... |
335 |
.................... |
336 |
.................... // Globalni promenna pro mereni casu |
336 |
.................... // Globalni promenna pro mereni casu |
337 |
.................... // Nastavuje se procedurou TimeSet() |
337 |
.................... // Nastavuje se procedurou TimeSet() |
338 |
.................... // Testuje se funkci TimeIf() |
338 |
.................... // Testuje se funkci TimeIf() |
339 |
.................... // Modifikuje se pri preruseni od casovace IntTo() |
339 |
.................... // Modifikuje se pri preruseni od casovace IntTo() |
340 |
.................... unsigned int16 TimeTime; |
340 |
.................... unsigned int16 TimeTime; |
341 |
.................... |
341 |
.................... |
342 |
.................... |
342 |
.................... |
343 |
.................... void TimerSet(unsigned int16 Time) |
343 |
.................... void TimerSet(unsigned int16 Time) |
344 |
.................... // Nastavi casovac na zadany pocet ms |
344 |
.................... // Nastavi casovac na zadany pocet ms |
345 |
.................... // Test uplynuti casu se dela pomoci TimerIf() |
345 |
.................... // Test uplynuti casu se dela pomoci TimerIf() |
346 |
.................... { |
346 |
.................... { |
347 |
.................... // Nastav hodnotu |
347 |
.................... // Nastav hodnotu |
348 |
.................... disable_interrupts(INT_RTCC); // nesmi prijit preruseni |
348 |
.................... disable_interrupts(INT_RTCC); // nesmi prijit preruseni |
349 |
* |
349 |
* |
350 |
0230: BCF 0B.5 |
350 |
0230: BCF 0B.5 |
351 |
.................... TimeTime=Time; // pri nastavovani hodnoty |
351 |
.................... TimeTime=Time; // pri nastavovani hodnoty |
352 |
0231: MOVF 3F,W |
352 |
0231: MOVF 3F,W |
353 |
0232: MOVWF 2C |
353 |
0232: MOVWF 2C |
354 |
0233: MOVF 3E,W |
354 |
0233: MOVF 3E,W |
355 |
0234: MOVWF 2B |
355 |
0234: MOVWF 2B |
356 |
.................... enable_interrupts(INT_RTCC); // promenne (o delce vice nez 8 bitu) |
356 |
.................... enable_interrupts(INT_RTCC); // promenne (o delce vice nez 8 bitu) |
357 |
0235: BSF 0B.5 |
357 |
0235: BSF 0B.5 |
358 |
.................... } |
358 |
.................... } |
359 |
0236: RETLW 00 |
359 |
0236: RETLW 00 |
360 |
.................... |
360 |
.................... |
361 |
.................... |
361 |
.................... |
362 |
.................... int1 TimerIf() |
362 |
.................... int1 TimerIf() |
363 |
.................... // Vraci TRUE pokud casovac jiz dobehl |
363 |
.................... // Vraci TRUE pokud casovac jiz dobehl |
364 |
.................... { |
364 |
.................... { |
365 |
.................... int1 Flag; // pomocna promenna |
365 |
.................... int1 Flag; // pomocna promenna |
366 |
.................... |
366 |
.................... |
367 |
.................... // Otestuj casovac |
367 |
.................... // Otestuj casovac |
368 |
.................... disable_interrupts(INT_RTCC); // nesmi prijit preruseni |
368 |
.................... disable_interrupts(INT_RTCC); // nesmi prijit preruseni |
369 |
0237: BCF 0B.5 |
369 |
0237: BCF 0B.5 |
370 |
.................... Flag=(TimeTime==0); // behem testu promenne |
370 |
.................... Flag=(TimeTime==0); // behem testu promenne |
371 |
0238: MOVF 2B,F |
371 |
0238: MOVF 2B,F |
372 |
0239: BTFSS 03.2 |
372 |
0239: BTFSS 03.2 |
373 |
023A: GOTO 23E |
373 |
023A: GOTO 23E |
374 |
023B: MOVF 2C,F |
374 |
023B: MOVF 2C,F |
375 |
023C: BTFSC 03.2 |
375 |
023C: BTFSC 03.2 |
376 |
023D: GOTO 240 |
376 |
023D: GOTO 240 |
377 |
023E: MOVLW 00 |
377 |
023E: MOVLW 00 |
378 |
023F: GOTO 241 |
378 |
023F: GOTO 241 |
379 |
0240: MOVLW 01 |
379 |
0240: MOVLW 01 |
380 |
0241: MOVWF 78 |
380 |
0241: MOVWF 78 |
381 |
0242: BTFSC 78.0 |
381 |
0242: BTFSC 78.0 |
382 |
0243: GOTO 246 |
382 |
0243: GOTO 246 |
383 |
0244: BCF 3E.0 |
383 |
0244: BCF 3E.0 |
384 |
0245: GOTO 247 |
384 |
0245: GOTO 247 |
385 |
0246: BSF 3E.0 |
385 |
0246: BSF 3E.0 |
386 |
.................... enable_interrupts(INT_RTCC); // ted uz muze |
386 |
.................... enable_interrupts(INT_RTCC); // ted uz muze |
387 |
0247: BSF 0B.5 |
387 |
0247: BSF 0B.5 |
388 |
.................... |
388 |
.................... |
389 |
.................... // Navratova hodnota |
389 |
.................... // Navratova hodnota |
390 |
.................... return Flag; // TRUE znamena dobehl casovac |
390 |
.................... return Flag; // TRUE znamena dobehl casovac |
391 |
0248: MOVLW 00 |
391 |
0248: MOVLW 00 |
392 |
0249: BTFSC 3E.0 |
392 |
0249: BTFSC 3E.0 |
393 |
024A: MOVLW 01 |
393 |
024A: MOVLW 01 |
394 |
024B: MOVWF 78 |
394 |
024B: MOVWF 78 |
395 |
.................... } |
395 |
.................... } |
396 |
024C: RETLW 00 |
396 |
024C: RETLW 00 |
397 |
.................... |
397 |
.................... |
398 |
.................... |
398 |
.................... |
399 |
.................... // Globalni promenne pro akceleraci |
399 |
.................... // Globalni promenne pro akceleraci |
400 |
.................... // Nastavuje se metodou MotorStart() |
400 |
.................... // Nastavuje se metodou MotorStart() |
401 |
.................... // Pouziva se v obsluze preruseni IntT0() |
401 |
.................... // Pouziva se v obsluze preruseni IntT0() |
402 |
.................... unsigned int8 MotorTime; // aktualni casovac pro rozjezd |
402 |
.................... unsigned int8 MotorTime; // aktualni casovac pro rozjezd |
403 |
.................... unsigned int8 MotorDelay; // spozdeni mezi razenim rychlosti |
403 |
.................... unsigned int8 MotorDelay; // spozdeni mezi razenim rychlosti |
404 |
.................... unsigned int8 MotorGear; // rychlostni stupen |
404 |
.................... unsigned int8 MotorGear; // rychlostni stupen |
405 |
.................... |
405 |
.................... |
406 |
.................... |
406 |
.................... |
407 |
.................... void MotorStart(unsigned int8 Delay) |
407 |
.................... void MotorStart(unsigned int8 Delay) |
408 |
.................... // Provede rizeny rozjezd motoru |
408 |
.................... // Provede rizeny rozjezd motoru |
409 |
.................... // Parametrem je prodleva mezi razenim rychlosti v ms |
409 |
.................... // Parametrem je prodleva mezi razenim rychlosti v ms |
410 |
.................... { |
410 |
.................... { |
411 |
.................... disable_interrupts(INT_RTCC); |
411 |
.................... disable_interrupts(INT_RTCC); |
412 |
024D: BCF 0B.5 |
412 |
024D: BCF 0B.5 |
413 |
.................... MotorGear=1; |
413 |
.................... MotorGear=1; |
414 |
024E: MOVLW 01 |
414 |
024E: MOVLW 01 |
415 |
024F: MOVWF 2F |
415 |
024F: MOVWF 2F |
416 |
.................... MotorDelay=Delay; |
416 |
.................... MotorDelay=Delay; |
417 |
0250: MOVF 3E,W |
417 |
0250: MOVF 3E,W |
418 |
0251: MOVWF 2E |
418 |
0251: MOVWF 2E |
419 |
.................... MotorTime=MotorDelay; |
419 |
.................... MotorTime=MotorDelay; |
420 |
0252: MOVF 2E,W |
420 |
0252: MOVF 2E,W |
421 |
0253: MOVWF 2D |
421 |
0253: MOVWF 2D |
422 |
.................... enable_interrupts(INT_RTCC); |
422 |
.................... enable_interrupts(INT_RTCC); |
423 |
0254: BSF 0B.5 |
423 |
0254: BSF 0B.5 |
424 |
0255: CLRF 29 |
424 |
0255: CLRF 29 |
425 |
0256: BTFSC 0B.7 |
425 |
0256: BTFSC 0B.7 |
426 |
0257: BSF 29.7 |
426 |
0257: BSF 29.7 |
427 |
0258: BCF 0B.7 |
427 |
0258: BCF 0B.7 |
428 |
.................... |
428 |
.................... |
429 |
.................... MotorPatternSet(1); |
429 |
.................... MotorPatternSet(1); |
430 |
0259: MOVLW 01 |
430 |
0259: MOVLW 01 |
431 |
025A: MOVWF 45 |
431 |
025A: MOVWF 45 |
432 |
025B: CALL 0AA |
432 |
025B: CALL 0AA |
433 |
025C: BTFSC 29.7 |
433 |
025C: BTFSC 29.7 |
434 |
025D: BSF 0B.7 |
434 |
025D: BSF 0B.7 |
435 |
.................... } |
435 |
.................... } |
436 |
025E: RETLW 00 |
436 |
025E: RETLW 00 |
437 |
.................... |
437 |
.................... |
438 |
.................... |
438 |
.................... |
439 |
.................... #INT_TIMER0 |
439 |
.................... #INT_TIMER0 |
440 |
.................... void IntT0() |
440 |
.................... void IntT0() |
441 |
.................... // Preruseni od casovace cca 1000x za sekundu |
441 |
.................... // Preruseni od casovace cca 1000x za sekundu |
442 |
.................... { |
442 |
.................... { |
443 |
.................... // Odpocitavani casovace |
443 |
.................... // Odpocitavani casovace |
444 |
.................... if (TimeTime) TimeTime--; |
444 |
.................... if (TimeTime) TimeTime--; |
445 |
* |
445 |
* |
446 |
00D3: MOVF 2B,W |
446 |
00D3: MOVF 2B,W |
447 |
00D4: IORWF 2C,W |
447 |
00D4: IORWF 2C,W |
448 |
00D5: BTFSC 03.2 |
448 |
00D5: BTFSC 03.2 |
449 |
00D6: GOTO 0DB |
449 |
00D6: GOTO 0DB |
450 |
00D7: MOVF 2B,W |
450 |
00D7: MOVF 2B,W |
451 |
00D8: BTFSC 03.2 |
451 |
00D8: BTFSC 03.2 |
452 |
00D9: DECF 2C,F |
452 |
00D9: DECF 2C,F |
453 |
00DA: DECF 2B,F |
453 |
00DA: DECF 2B,F |
454 |
.................... |
454 |
.................... |
455 |
.................... // Obsluha akcelerace |
455 |
.................... // Obsluha akcelerace |
456 |
.................... if (MotorTime) MotorTime--; // dekrementuj casovac rozjezdu |
456 |
.................... if (MotorTime) MotorTime--; // dekrementuj casovac rozjezdu |
457 |
00DB: MOVF 2D,F |
457 |
00DB: MOVF 2D,F |
458 |
00DC: BTFSS 03.2 |
458 |
00DC: BTFSS 03.2 |
459 |
00DD: DECF 2D,F |
459 |
00DD: DECF 2D,F |
460 |
.................... if ((MotorGear>0) && (MotorGear<8) && (!MotorTime)) // dalsi rychlostni stupen |
460 |
.................... if ((MotorGear>0) && (MotorGear<8) && (!MotorTime)) // dalsi rychlostni stupen |
461 |
00DE: MOVF 2F,F |
461 |
00DE: MOVF 2F,F |
462 |
00DF: BTFSC 03.2 |
462 |
00DF: BTFSC 03.2 |
463 |
00E0: GOTO 0EE |
463 |
00E0: GOTO 0EE |
464 |
00E1: MOVF 2F,W |
464 |
00E1: MOVF 2F,W |
465 |
00E2: SUBLW 07 |
465 |
00E2: SUBLW 07 |
466 |
00E3: BTFSS 03.0 |
466 |
00E3: BTFSS 03.0 |
467 |
00E4: GOTO 0EE |
467 |
00E4: GOTO 0EE |
468 |
00E5: MOVF 2D,F |
468 |
00E5: MOVF 2D,F |
469 |
00E6: BTFSS 03.2 |
469 |
00E6: BTFSS 03.2 |
470 |
00E7: GOTO 0EE |
470 |
00E7: GOTO 0EE |
471 |
.................... { |
471 |
.................... { |
472 |
.................... MotorTime=MotorDelay; // znovu nastav casovac |
472 |
.................... MotorTime=MotorDelay; // znovu nastav casovac |
473 |
00E8: MOVF 2E,W |
473 |
00E8: MOVF 2E,W |
474 |
00E9: MOVWF 2D |
474 |
00E9: MOVWF 2D |
475 |
.................... MotorGear++; // dalsi rychlost |
475 |
.................... MotorGear++; // dalsi rychlost |
476 |
00EA: INCF 2F,F |
476 |
00EA: INCF 2F,F |
477 |
.................... MotorPatternSet(MotorGear); // nastav rychlost |
477 |
.................... MotorPatternSet(MotorGear); // nastav rychlost |
478 |
00EB: MOVF 2F,W |
478 |
00EB: MOVF 2F,W |
479 |
00EC: MOVWF 45 |
479 |
00EC: MOVWF 45 |
480 |
00ED: CALL 0AA |
480 |
00ED: CALL 0AA |
481 |
.................... } |
481 |
.................... } |
482 |
.................... } |
482 |
.................... } |
483 |
.................... |
483 |
.................... |
484 |
.................... |
484 |
.................... |
485 |
.................... // Cteni dat z AD prevodniku, zadava se cislo kanalu |
485 |
.................... // Cteni dat z AD prevodniku, zadava se cislo kanalu |
486 |
00EE: BCF 0B.2 |
486 |
00EE: BCF 0B.2 |
487 |
00EF: BCF 0A.3 |
487 |
00EF: BCF 0A.3 |
488 |
00F0: GOTO 026 |
488 |
00F0: GOTO 026 |
489 |
.................... int8 ReadAD(int8 Ch) |
489 |
.................... int8 ReadAD(int8 Ch) |
490 |
.................... { |
490 |
.................... { |
491 |
.................... // Pokud merim Vref zapnu si jeho napajeni |
491 |
.................... // Pokud merim Vref zapnu si jeho napajeni |
492 |
.................... if (Ch==4) output_high(REFPOWER); |
492 |
.................... if (Ch==4) output_high(REFPOWER); |
493 |
* |
493 |
* |
494 |
0195: MOVF 3E,W |
494 |
0195: MOVF 3E,W |
495 |
0196: SUBLW 04 |
495 |
0196: SUBLW 04 |
496 |
0197: BTFSS 03.2 |
496 |
0197: BTFSS 03.2 |
497 |
0198: GOTO 19D |
497 |
0198: GOTO 19D |
498 |
0199: BSF 03.5 |
498 |
0199: BSF 03.5 |
499 |
019A: BCF 06.1 |
499 |
019A: BCF 06.1 |
500 |
019B: BCF 03.5 |
500 |
019B: BCF 03.5 |
501 |
019C: BSF 06.1 |
501 |
019C: BSF 06.1 |
502 |
.................... |
502 |
.................... |
503 |
.................... // Inicializace a cislo kanalu |
503 |
.................... // Inicializace a cislo kanalu |
504 |
.................... ADCON1=0x30; // Vref+-, bez deleni hodin, Left Justify |
504 |
.................... ADCON1=0x30; // Vref+-, bez deleni hodin, Left Justify |
505 |
019D: MOVLW 30 |
505 |
019D: MOVLW 30 |
506 |
019E: BSF 03.5 |
506 |
019E: BSF 03.5 |
507 |
019F: MOVWF 1F |
507 |
019F: MOVWF 1F |
508 |
.................... ADCON0=0x41+(Ch<<3); // on, Tosc/8, cislo kanalu |
508 |
.................... ADCON0=0x41+(Ch<<3); // on, Tosc/8, cislo kanalu |
509 |
01A0: BCF 03.5 |
509 |
01A0: BCF 03.5 |
510 |
01A1: RLF 3E,W |
510 |
01A1: RLF 3E,W |
511 |
01A2: MOVWF 77 |
511 |
01A2: MOVWF 77 |
512 |
01A3: RLF 77,F |
512 |
01A3: RLF 77,F |
513 |
01A4: RLF 77,F |
513 |
01A4: RLF 77,F |
514 |
01A5: MOVLW F8 |
514 |
01A5: MOVLW F8 |
515 |
01A6: ANDWF 77,F |
515 |
01A6: ANDWF 77,F |
516 |
01A7: MOVF 77,W |
516 |
01A7: MOVF 77,W |
517 |
01A8: ADDLW 41 |
517 |
01A8: ADDLW 41 |
518 |
01A9: MOVWF 1F |
518 |
01A9: MOVWF 1F |
519 |
.................... |
519 |
.................... |
520 |
.................... // Mereni |
520 |
.................... // Mereni |
521 |
.................... delay_us(50); // doba na prepnuti kanalu |
521 |
.................... delay_us(50); // doba na prepnuti kanalu |
522 |
01AA: CLRWDT |
522 |
01AA: CLRWDT |
523 |
01AB: MOVLW 10 |
523 |
01AB: MOVLW 10 |
524 |
01AC: MOVWF 77 |
524 |
01AC: MOVWF 77 |
525 |
01AD: DECFSZ 77,F |
525 |
01AD: DECFSZ 77,F |
526 |
01AE: GOTO 1AD |
526 |
01AE: GOTO 1AD |
527 |
01AF: NOP |
527 |
01AF: NOP |
528 |
01B0: NOP |
528 |
01B0: NOP |
529 |
.................... ADCON0 |= 4; // start prevodu |
529 |
.................... ADCON0 |= 4; // start prevodu |
530 |
01B1: BSF 1F.2 |
530 |
01B1: BSF 1F.2 |
531 |
.................... delay_us(50); // doba na prevod |
531 |
.................... delay_us(50); // doba na prevod |
532 |
01B2: CLRWDT |
532 |
01B2: CLRWDT |
533 |
01B3: MOVLW 10 |
533 |
01B3: MOVLW 10 |
534 |
01B4: MOVWF 77 |
534 |
01B4: MOVWF 77 |
535 |
01B5: DECFSZ 77,F |
535 |
01B5: DECFSZ 77,F |
536 |
01B6: GOTO 1B5 |
536 |
01B6: GOTO 1B5 |
537 |
01B7: NOP |
537 |
01B7: NOP |
538 |
01B8: NOP |
538 |
01B8: NOP |
539 |
.................... |
539 |
.................... |
540 |
.................... // Vypnu napajeni Vref (vzdycky) |
540 |
.................... // Vypnu napajeni Vref (vzdycky) |
541 |
.................... output_low(REFPOWER); |
541 |
.................... output_low(REFPOWER); |
542 |
01B9: BSF 03.5 |
542 |
01B9: BSF 03.5 |
543 |
01BA: BCF 06.1 |
543 |
01BA: BCF 06.1 |
544 |
01BB: BCF 03.5 |
544 |
01BB: BCF 03.5 |
545 |
01BC: BCF 06.1 |
545 |
01BC: BCF 06.1 |
546 |
.................... |
546 |
.................... |
547 |
.................... // Navrat hodnoty |
547 |
.................... // Navrat hodnoty |
548 |
.................... return ADRESH; |
548 |
.................... return ADRESH; |
549 |
01BD: MOVF 1E,W |
549 |
01BD: MOVF 1E,W |
550 |
01BE: MOVWF 78 |
550 |
01BE: MOVWF 78 |
551 |
.................... } |
551 |
.................... } |
552 |
01BF: RETLW 00 |
552 |
01BF: RETLW 00 |
553 |
.................... |
553 |
.................... |
554 |
.................... |
554 |
.................... |
555 |
.................... void main() |
555 |
.................... void main() |
556 |
.................... { |
556 |
.................... { |
557 |
* |
557 |
* |
558 |
025F: CLRF 04 |
558 |
025F: CLRF 04 |
559 |
0260: MOVLW 1F |
559 |
0260: MOVLW 1F |
560 |
0261: ANDWF 03,F |
560 |
0261: ANDWF 03,F |
561 |
0262: BSF 03.5 |
561 |
0262: BSF 03.5 |
562 |
0263: BCF 1F.4 |
562 |
0263: BCF 1F.4 |
563 |
0264: BCF 1F.5 |
563 |
0264: BCF 1F.5 |
564 |
0265: MOVF 1B,W |
564 |
0265: MOVF 1B,W |
565 |
0266: ANDLW 80 |
565 |
0266: ANDLW 80 |
566 |
0267: MOVWF 1B |
566 |
0267: MOVWF 1B |
567 |
0268: MOVLW 07 |
567 |
0268: MOVLW 07 |
568 |
0269: MOVWF 1C |
568 |
0269: MOVWF 1C |
569 |
026A: MOVF 05,W |
569 |
026A: MOVF 05,W |
570 |
026B: CLRWDT |
570 |
026B: CLRWDT |
571 |
026C: MOVF 1C,W |
571 |
026C: MOVF 1C,W |
572 |
026D: BCF 03.5 |
572 |
026D: BCF 03.5 |
573 |
026E: BCF 0D.6 |
573 |
026E: BCF 0D.6 |
574 |
.................... unsigned int8 Debug; // Promenna pro rezim cinnosti (stav prepinacu) |
574 |
.................... unsigned int8 Debug; // Promenna pro rezim cinnosti (stav prepinacu) |
575 |
.................... unsigned int8 i; |
575 |
.................... unsigned int8 i; |
576 |
.................... |
576 |
.................... |
577 |
.................... // Hodiny |
577 |
.................... // Hodiny |
578 |
.................... OSCCON = 0x62; // 4 MHz interni RC oscilator |
578 |
.................... OSCCON = 0x62; // 4 MHz interni RC oscilator |
579 |
026F: MOVLW 62 |
579 |
026F: MOVLW 62 |
580 |
0270: BSF 03.5 |
580 |
0270: BSF 03.5 |
581 |
0271: MOVWF 0F |
581 |
0271: MOVWF 0F |
582 |
.................... |
582 |
.................... |
583 |
.................... // Digitalni vystupy |
583 |
.................... // Digitalni vystupy |
584 |
.................... output_low(PWM); // PWM vystup |
584 |
.................... output_low(PWM); // PWM vystup |
585 |
0272: BCF 06.3 |
585 |
0272: BCF 06.3 |
586 |
0273: BCF 03.5 |
586 |
0273: BCF 03.5 |
587 |
0274: BCF 06.3 |
587 |
0274: BCF 06.3 |
588 |
.................... output_low(MOTOR); // Proud do motoru |
588 |
.................... output_low(MOTOR); // Proud do motoru |
589 |
0275: BSF 03.5 |
589 |
0275: BSF 03.5 |
590 |
0276: BCF 06.2 |
590 |
0276: BCF 06.2 |
591 |
0277: BCF 03.5 |
591 |
0277: BCF 03.5 |
592 |
0278: BCF 06.2 |
592 |
0278: BCF 06.2 |
593 |
.................... output_low(REFPOWER); // Napajeni Vref |
593 |
.................... output_low(REFPOWER); // Napajeni Vref |
594 |
0279: BSF 03.5 |
594 |
0279: BSF 03.5 |
595 |
027A: BCF 06.1 |
595 |
027A: BCF 06.1 |
596 |
027B: BCF 03.5 |
596 |
027B: BCF 03.5 |
597 |
027C: BCF 06.1 |
597 |
027C: BCF 06.1 |
598 |
.................... port_b_pullups(TRUE); // Zbyvajici vyvody portu B |
598 |
.................... port_b_pullups(TRUE); // Zbyvajici vyvody portu B |
599 |
027D: BSF 03.5 |
599 |
027D: BSF 03.5 |
600 |
027E: BCF 01.7 |
600 |
027E: BCF 01.7 |
601 |
.................... |
601 |
.................... |
602 |
.................... // Watch Dog |
602 |
.................... // Watch Dog |
603 |
.................... PSA=0; // preddelic prirazen casovaci |
603 |
.................... PSA=0; // preddelic prirazen casovaci |
604 |
027F: BCF 01.3 |
604 |
027F: BCF 01.3 |
605 |
.................... WDTCON=0x0E; // Watch Dog cca 130ms |
605 |
.................... WDTCON=0x0E; // Watch Dog cca 130ms |
606 |
0280: MOVLW 0E |
606 |
0280: MOVLW 0E |
607 |
0281: BCF 03.5 |
607 |
0281: BCF 03.5 |
608 |
0282: BSF 03.6 |
608 |
0282: BSF 03.6 |
609 |
0283: MOVWF 05 |
609 |
0283: MOVWF 05 |
610 |
.................... |
610 |
.................... |
611 |
.................... // Analogove vstupy |
611 |
.................... // Analogove vstupy |
612 |
.................... ANSEL = 0x1F; // AN0 az AN4 |
612 |
.................... ANSEL = 0x1F; // AN0 az AN4 |
613 |
0284: MOVLW 1F |
613 |
0284: MOVLW 1F |
614 |
0285: BSF 03.5 |
614 |
0285: BSF 03.5 |
615 |
0286: BCF 03.6 |
615 |
0286: BCF 03.6 |
616 |
0287: MOVWF 1B |
616 |
0287: MOVWF 1B |
617 |
.................... |
617 |
.................... |
618 |
.................... // nastaveni RS232 |
618 |
.................... // nastaveni RS232 |
619 |
.................... InitRS232(); // inicializace HW RS232 (nutno pockat cca 10ms) |
619 |
.................... InitRS232(); // inicializace HW RS232 (nutno pockat cca 10ms) |
620 |
0288: BCF 03.5 |
620 |
0288: BCF 03.5 |
621 |
0289: GOTO 0F1 |
621 |
0289: GOTO 0F1 |
622 |
.................... |
622 |
.................... |
623 |
.................... // Pipnuti (a cekani) |
623 |
.................... // Pipnuti (a cekani) |
624 |
.................... for (i=1;i<30;i++) // pocet 1/2 period |
624 |
.................... for (i=1;i<30;i++) // pocet 1/2 period |
625 |
028A: MOVLW 01 |
625 |
028A: MOVLW 01 |
626 |
028B: MOVWF 31 |
626 |
028B: MOVWF 31 |
627 |
028C: MOVF 31,W |
627 |
028C: MOVF 31,W |
628 |
028D: SUBLW 1D |
628 |
028D: SUBLW 1D |
629 |
028E: BTFSS 03.0 |
629 |
028E: BTFSS 03.0 |
630 |
028F: GOTO 2AC |
630 |
028F: GOTO 2AC |
631 |
.................... { |
631 |
.................... { |
632 |
.................... int1 beep; // stavova promenna pro pipak |
632 |
.................... int1 beep; // stavova promenna pro pipak |
633 |
.................... |
633 |
.................... |
634 |
.................... output_bit(BEEP0,beep); |
634 |
.................... output_bit(BEEP0,beep); |
635 |
0290: BTFSC 32.0 |
635 |
0290: BTFSC 32.0 |
636 |
0291: GOTO 294 |
636 |
0291: GOTO 294 |
637 |
0292: BCF 05.6 |
637 |
0292: BCF 05.6 |
638 |
0293: GOTO 295 |
638 |
0293: GOTO 295 |
639 |
0294: BSF 05.6 |
639 |
0294: BSF 05.6 |
640 |
0295: BSF 03.5 |
640 |
0295: BSF 03.5 |
641 |
0296: BCF 05.6 |
641 |
0296: BCF 05.6 |
642 |
.................... beep=~beep; |
642 |
.................... beep=~beep; |
643 |
0297: MOVLW 01 |
643 |
0297: MOVLW 01 |
644 |
0298: BCF 03.5 |
644 |
0298: BCF 03.5 |
645 |
0299: XORWF 32,F |
645 |
0299: XORWF 32,F |
646 |
.................... output_bit(BEEP1,beep); |
646 |
.................... output_bit(BEEP1,beep); |
647 |
029A: BTFSC 32.0 |
647 |
029A: BTFSC 32.0 |
648 |
029B: GOTO 29E |
648 |
029B: GOTO 29E |
649 |
029C: BCF 05.7 |
649 |
029C: BCF 05.7 |
650 |
029D: GOTO 29F |
650 |
029D: GOTO 29F |
651 |
029E: BSF 05.7 |
651 |
029E: BSF 05.7 |
652 |
029F: BSF 03.5 |
652 |
029F: BSF 03.5 |
653 |
02A0: BCF 05.7 |
653 |
02A0: BCF 05.7 |
654 |
.................... delay_us(1000); |
654 |
.................... delay_us(1000); |
655 |
02A1: CLRWDT |
655 |
02A1: CLRWDT |
656 |
02A2: MOVLW 09 |
656 |
02A2: MOVLW 09 |
657 |
02A3: BCF 03.5 |
657 |
02A3: BCF 03.5 |
658 |
02A4: MOVWF 3E |
658 |
02A4: MOVWF 3E |
659 |
02A5: MOVLW 6C |
659 |
02A5: MOVLW 6C |
660 |
02A6: MOVWF 3F |
660 |
02A6: MOVWF 3F |
661 |
02A7: GOTO 0FD |
661 |
02A7: GOTO 0FD |
662 |
02A8: DECFSZ 3E,F |
662 |
02A8: DECFSZ 3E,F |
663 |
02A9: GOTO 2A5 |
663 |
02A9: GOTO 2A5 |
664 |
.................... } |
664 |
.................... } |
665 |
02AA: INCF 31,F |
665 |
02AA: INCF 31,F |
666 |
02AB: GOTO 28C |
666 |
02AB: GOTO 28C |
667 |
.................... |
667 |
.................... |
668 |
.................... // Rozhodnuti o rezimu cinnosti (cteni stavu prepinacu) |
668 |
.................... // Rozhodnuti o rezimu cinnosti (cteni stavu prepinacu) |
669 |
.................... Debug=0; |
669 |
.................... Debug=0; |
670 |
02AC: CLRF 30 |
670 |
02AC: CLRF 30 |
671 |
.................... if (~input(SW0)) Debug|=1; // precti bit 0 |
671 |
.................... if (~input(SW0)) Debug|=1; // precti bit 0 |
672 |
02AD: BSF 03.5 |
672 |
02AD: BSF 03.5 |
673 |
02AE: BSF 06.7 |
673 |
02AE: BSF 06.7 |
674 |
02AF: BCF 03.5 |
674 |
02AF: BCF 03.5 |
675 |
02B0: BTFSS 06.7 |
675 |
02B0: BTFSS 06.7 |
676 |
02B1: BSF 30.0 |
676 |
02B1: BSF 30.0 |
677 |
.................... if (~input(SW1)) Debug|=2; // precti bit 1 |
677 |
.................... if (~input(SW1)) Debug|=2; // precti bit 1 |
678 |
02B2: BSF 03.5 |
678 |
02B2: BSF 03.5 |
679 |
02B3: BSF 06.6 |
679 |
02B3: BSF 06.6 |
680 |
02B4: BCF 03.5 |
680 |
02B4: BCF 03.5 |
681 |
02B5: BTFSS 06.6 |
681 |
02B5: BTFSS 06.6 |
682 |
02B6: BSF 30.1 |
682 |
02B6: BSF 30.1 |
683 |
.................... output_low(SW0); // nastav L aby se snizila spotreba |
683 |
.................... output_low(SW0); // nastav L aby se snizila spotreba |
684 |
02B7: BSF 03.5 |
684 |
02B7: BSF 03.5 |
685 |
02B8: BCF 06.7 |
685 |
02B8: BCF 06.7 |
686 |
02B9: BCF 03.5 |
686 |
02B9: BCF 03.5 |
687 |
02BA: BCF 06.7 |
687 |
02BA: BCF 06.7 |
688 |
.................... output_low(SW1); // na obou vstupech |
688 |
.................... output_low(SW1); // na obou vstupech |
689 |
02BB: BSF 03.5 |
689 |
02BB: BSF 03.5 |
690 |
02BC: BCF 06.6 |
690 |
02BC: BCF 06.6 |
691 |
02BD: BCF 03.5 |
691 |
02BD: BCF 03.5 |
692 |
02BE: BCF 06.6 |
692 |
02BE: BCF 06.6 |
693 |
.................... |
693 |
.................... |
694 |
.................... // Zobrazeni rezimu (na ladici seriovy vystup) |
694 |
.................... // Zobrazeni rezimu (na ladici seriovy vystup) |
695 |
.................... printf(Putc,"\fMode:%d",Debug); |
695 |
.................... printf(Putc,"\fMode:%d",Debug); |
696 |
02BF: CLRF 3E |
696 |
02BF: CLRF 3E |
697 |
02C0: MOVF 3E,W |
697 |
02C0: MOVF 3E,W |
698 |
02C1: CALL 049 |
698 |
02C1: CALL 049 |
699 |
02C2: INCF 3E,F |
699 |
02C2: INCF 3E,F |
700 |
02C3: MOVWF 77 |
700 |
02C3: MOVWF 77 |
701 |
02C4: MOVWF 42 |
701 |
02C4: MOVWF 42 |
702 |
02C5: CALL 111 |
702 |
02C5: CALL 111 |
703 |
02C6: MOVLW 06 |
703 |
02C6: MOVLW 06 |
704 |
02C7: SUBWF 3E,W |
704 |
02C7: SUBWF 3E,W |
705 |
02C8: BTFSS 03.2 |
705 |
02C8: BTFSS 03.2 |
706 |
02C9: GOTO 2C0 |
706 |
02C9: GOTO 2C0 |
707 |
02CA: MOVF 30,W |
707 |
02CA: MOVF 30,W |
708 |
02CB: MOVWF 3F |
708 |
02CB: MOVWF 3F |
709 |
02CC: MOVLW 18 |
709 |
02CC: MOVLW 18 |
710 |
02CD: MOVWF 40 |
710 |
02CD: MOVWF 40 |
711 |
02CE: GOTO 12F |
711 |
02CE: GOTO 12F |
712 |
.................... |
712 |
.................... |
713 |
.................... // Inicializace PWM |
713 |
.................... // Inicializace PWM |
714 |
.................... PR2 = 0x1F; // perioda PWM casovace |
714 |
.................... PR2 = 0x1F; // perioda PWM casovace |
715 |
02CF: MOVLW 1F |
715 |
02CF: MOVLW 1F |
716 |
02D0: BSF 03.5 |
716 |
02D0: BSF 03.5 |
717 |
02D1: MOVWF 12 |
717 |
02D1: MOVWF 12 |
718 |
.................... T2CON = 0x04; // povoleni casovace T2 bez preddelicu a postdelicu |
718 |
.................... T2CON = 0x04; // povoleni casovace T2 bez preddelicu a postdelicu |
719 |
02D2: MOVLW 04 |
719 |
02D2: MOVLW 04 |
720 |
02D3: BCF 03.5 |
720 |
02D3: BCF 03.5 |
721 |
02D4: MOVWF 12 |
721 |
02D4: MOVWF 12 |
722 |
.................... CCP1CON = 0x0C; // PWM mode, lsb bity nulove |
722 |
.................... CCP1CON = 0x0C; // PWM mode, lsb bity nulove |
723 |
02D5: MOVLW 0C |
723 |
02D5: MOVLW 0C |
724 |
02D6: MOVWF 17 |
724 |
02D6: MOVWF 17 |
725 |
.................... CCPR1L = 0; // na zacatku nulova data |
725 |
.................... CCPR1L = 0; // na zacatku nulova data |
726 |
02D7: CLRF 15 |
726 |
02D7: CLRF 15 |
727 |
.................... output_low(PWM); // PWM vystup |
727 |
.................... output_low(PWM); // PWM vystup |
728 |
02D8: BSF 03.5 |
728 |
02D8: BSF 03.5 |
729 |
02D9: BCF 06.3 |
729 |
02D9: BCF 06.3 |
730 |
02DA: BCF 03.5 |
730 |
02DA: BCF 03.5 |
731 |
02DB: BCF 06.3 |
731 |
02DB: BCF 06.3 |
732 |
.................... |
732 |
.................... |
733 |
.................... // Inicializace casovace |
733 |
.................... // Inicializace casovace |
734 |
.................... InitT0(); // nastav casovac na cca 1ms |
734 |
.................... InitT0(); // nastav casovac na cca 1ms |
735 |
02DC: GOTO 18A |
735 |
02DC: GOTO 18A |
736 |
.................... |
736 |
.................... |
737 |
.................... // ALG=1 Test menice PWM a rozjezdoveho PWM |
737 |
.................... // ALG=1 Test menice PWM a rozjezdoveho PWM |
738 |
.................... // ======================================== |
738 |
.................... // ======================================== |
739 |
.................... // P1 nastavuje primo stridu hlavniho PWM menice |
739 |
.................... // P1 nastavuje primo stridu hlavniho PWM menice |
740 |
.................... // P2 nastavuje rychlostni stupen spinace motoru (rychlostni stupne 0-8) |
740 |
.................... // P2 nastavuje rychlostni stupen spinace motoru (rychlostni stupne 0-8) |
741 |
.................... // Trvale nacita P1 a P2 a nastavuje podle nich akcni hodnoty menicu |
741 |
.................... // Trvale nacita P1 a P2 a nastavuje podle nich akcni hodnoty menicu |
742 |
.................... if (Debug==1) |
742 |
.................... if (Debug==1) |
743 |
02DD: DECFSZ 30,W |
743 |
02DD: DECFSZ 30,W |
744 |
02DE: GOTO 318 |
744 |
02DE: GOTO 318 |
745 |
.................... { |
745 |
.................... { |
746 |
.................... unsigned int8 Data1; // poteniometr P1 = PWM |
746 |
.................... unsigned int8 Data1; // poteniometr P1 = PWM |
747 |
.................... unsigned int8 Data2; // poteniometr P2 = Rozjezd |
747 |
.................... unsigned int8 Data2; // poteniometr P2 = Rozjezd |
748 |
.................... |
748 |
.................... |
749 |
.................... while (1) |
749 |
.................... while (1) |
750 |
.................... { |
750 |
.................... { |
751 |
.................... // watch dog |
751 |
.................... // watch dog |
752 |
.................... restart_wdt(); |
752 |
.................... restart_wdt(); |
753 |
02DF: CLRWDT |
753 |
02DF: CLRWDT |
754 |
.................... |
754 |
.................... |
755 |
.................... // mereni vstupu |
755 |
.................... // mereni vstupu |
756 |
.................... Data1=ReadAD(0); // nacti parametr pro PWM |
756 |
.................... Data1=ReadAD(0); // nacti parametr pro PWM |
757 |
02E0: CLRF 3E |
757 |
02E0: CLRF 3E |
758 |
02E1: CALL 195 |
758 |
02E1: CALL 195 |
759 |
02E2: MOVF 78,W |
759 |
02E2: MOVF 78,W |
760 |
02E3: MOVWF 33 |
760 |
02E3: MOVWF 33 |
761 |
.................... Data1>>=2; // redukuj rozsah na 0 az 63 |
761 |
.................... Data1>>=2; // redukuj rozsah na 0 az 63 |
762 |
02E4: RRF 33,F |
762 |
02E4: RRF 33,F |
763 |
02E5: RRF 33,F |
763 |
02E5: RRF 33,F |
764 |
02E6: MOVLW 3F |
764 |
02E6: MOVLW 3F |
765 |
02E7: ANDWF 33,F |
765 |
02E7: ANDWF 33,F |
766 |
.................... Data2=ReadAD(1); // nacti parametr pro rozjezd |
766 |
.................... Data2=ReadAD(1); // nacti parametr pro rozjezd |
767 |
02E8: MOVLW 01 |
767 |
02E8: MOVLW 01 |
768 |
02E9: MOVWF 3E |
768 |
02E9: MOVWF 3E |
769 |
02EA: CALL 195 |
769 |
02EA: CALL 195 |
770 |
02EB: MOVF 78,W |
770 |
02EB: MOVF 78,W |
771 |
02EC: MOVWF 34 |
771 |
02EC: MOVWF 34 |
772 |
.................... Data2>>=4; // redukuj rozsah na 0 az 15 |
772 |
.................... Data2>>=4; // redukuj rozsah na 0 az 15 |
773 |
02ED: SWAPF 34,F |
773 |
02ED: SWAPF 34,F |
774 |
02EE: MOVLW 0F |
774 |
02EE: MOVLW 0F |
775 |
02EF: ANDWF 34,F |
775 |
02EF: ANDWF 34,F |
776 |
.................... |
776 |
.................... |
777 |
.................... // zobrazeni |
777 |
.................... // zobrazeni |
778 |
.................... printf(Putc,"\nPWM:%03u RUN:%03u",Data1,Data2); |
778 |
.................... printf(Putc,"\nPWM:%03u RUN:%03u",Data1,Data2); |
779 |
02F0: CLRF 3E |
779 |
02F0: CLRF 3E |
780 |
02F1: MOVF 3E,W |
780 |
02F1: MOVF 3E,W |
781 |
02F2: CALL 056 |
781 |
02F2: CALL 056 |
782 |
02F3: INCF 3E,F |
782 |
02F3: INCF 3E,F |
783 |
02F4: MOVWF 77 |
783 |
02F4: MOVWF 77 |
784 |
02F5: MOVWF 42 |
784 |
02F5: MOVWF 42 |
785 |
02F6: CALL 111 |
785 |
02F6: CALL 111 |
786 |
02F7: MOVLW 05 |
786 |
02F7: MOVLW 05 |
787 |
02F8: SUBWF 3E,W |
787 |
02F8: SUBWF 3E,W |
788 |
02F9: BTFSS 03.2 |
788 |
02F9: BTFSS 03.2 |
789 |
02FA: GOTO 2F1 |
789 |
02FA: GOTO 2F1 |
790 |
02FB: MOVF 33,W |
790 |
02FB: MOVF 33,W |
791 |
02FC: MOVWF 40 |
791 |
02FC: MOVWF 40 |
792 |
02FD: CLRF 41 |
792 |
02FD: CLRF 41 |
793 |
02FE: CALL 1C0 |
793 |
02FE: CALL 1C0 |
794 |
02FF: MOVLW 09 |
794 |
02FF: MOVLW 09 |
795 |
0300: MOVWF 3F |
795 |
0300: MOVWF 3F |
796 |
0301: MOVF 3F,W |
796 |
0301: MOVF 3F,W |
797 |
0302: CALL 056 |
797 |
0302: CALL 056 |
798 |
0303: INCF 3F,F |
798 |
0303: INCF 3F,F |
799 |
0304: MOVWF 77 |
799 |
0304: MOVWF 77 |
800 |
0305: MOVWF 42 |
800 |
0305: MOVWF 42 |
801 |
0306: CALL 111 |
801 |
0306: CALL 111 |
802 |
0307: MOVLW 0E |
802 |
0307: MOVLW 0E |
803 |
0308: SUBWF 3F,W |
803 |
0308: SUBWF 3F,W |
804 |
0309: BTFSS 03.2 |
804 |
0309: BTFSS 03.2 |
805 |
030A: GOTO 301 |
805 |
030A: GOTO 301 |
806 |
030B: MOVF 34,W |
806 |
030B: MOVF 34,W |
807 |
030C: MOVWF 40 |
807 |
030C: MOVWF 40 |
808 |
030D: CLRF 41 |
808 |
030D: CLRF 41 |
809 |
030E: CALL 1C0 |
809 |
030E: CALL 1C0 |
810 |
.................... delay_ms(20); |
810 |
.................... delay_ms(20); |
811 |
030F: MOVLW 14 |
811 |
030F: MOVLW 14 |
812 |
0310: MOVWF 3E |
812 |
0310: MOVWF 3E |
813 |
0311: CALL 20D |
813 |
0311: CALL 20D |
814 |
.................... |
814 |
.................... |
815 |
.................... // nastaveni parametru PWM |
815 |
.................... // nastaveni parametru PWM |
816 |
.................... CCPR1L = Data1; |
816 |
.................... CCPR1L = Data1; |
817 |
0312: MOVF 33,W |
817 |
0312: MOVF 33,W |
818 |
0313: MOVWF 15 |
818 |
0313: MOVWF 15 |
819 |
.................... |
819 |
.................... |
820 |
.................... // nastaveni parametru RUN |
820 |
.................... // nastaveni parametru RUN |
821 |
.................... MotorSet(Data2); |
821 |
.................... MotorSet(Data2); |
822 |
0314: MOVF 34,W |
822 |
0314: MOVF 34,W |
823 |
0315: MOVWF 3E |
823 |
0315: MOVWF 3E |
824 |
0316: CALL 224 |
824 |
0316: CALL 224 |
825 |
.................... } |
825 |
.................... } |
826 |
0317: GOTO 2DF |
826 |
0317: GOTO 2DF |
827 |
.................... } |
827 |
.................... } |
828 |
.................... |
828 |
.................... |
829 |
.................... // ALG=2 Testovani rozjezdu |
829 |
.................... // ALG=2 Testovani rozjezdu |
830 |
.................... // ======================== |
830 |
.................... // ======================== |
831 |
.................... // P2 nastavuje cas mezi stupni razeni pro rozjezd v ms |
831 |
.................... // P2 nastavuje cas mezi stupni razeni pro rozjezd v ms |
832 |
.................... // Po resetu 2 sekundy pocka, 2 sekundy jede a nakonec zastavi motor |
832 |
.................... // Po resetu 2 sekundy pocka, 2 sekundy jede a nakonec zastavi motor |
833 |
.................... if (Debug==2) |
833 |
.................... if (Debug==2) |
834 |
0318: MOVF 30,W |
834 |
0318: MOVF 30,W |
835 |
0319: SUBLW 02 |
835 |
0319: SUBLW 02 |
836 |
031A: BTFSS 03.2 |
836 |
031A: BTFSS 03.2 |
837 |
031B: GOTO 369 |
837 |
031B: GOTO 369 |
838 |
.................... { |
838 |
.................... { |
839 |
.................... int8 Data; |
839 |
.................... int8 Data; |
840 |
.................... int8 Start; |
840 |
.................... int8 Start; |
841 |
.................... |
841 |
.................... |
842 |
.................... Start=0; // uvodni stav |
842 |
.................... Start=0; // uvodni stav |
843 |
031C: CLRF 36 |
843 |
031C: CLRF 36 |
844 |
.................... while(1) |
844 |
.................... while(1) |
845 |
.................... { |
845 |
.................... { |
846 |
.................... // Nacti a zobraz parametr |
846 |
.................... // Nacti a zobraz parametr |
847 |
.................... Data=ReadAD(1); // potenciometr P2 = rozjezd |
847 |
.................... Data=ReadAD(1); // potenciometr P2 = rozjezd |
848 |
031D: MOVLW 01 |
848 |
031D: MOVLW 01 |
849 |
031E: MOVWF 3E |
849 |
031E: MOVWF 3E |
850 |
031F: CALL 195 |
850 |
031F: CALL 195 |
851 |
0320: MOVF 78,W |
851 |
0320: MOVF 78,W |
852 |
0321: MOVWF 35 |
852 |
0321: MOVWF 35 |
853 |
.................... printf(Putc,"\nRUN:%3ums ",Data); // zobraz |
853 |
.................... printf(Putc,"\nRUN:%3ums ",Data); // zobraz |
854 |
0322: CLRF 3E |
854 |
0322: CLRF 3E |
855 |
0323: MOVF 3E,W |
855 |
0323: MOVF 3E,W |
856 |
0324: CALL 06D |
856 |
0324: CALL 06D |
857 |
0325: INCF 3E,F |
857 |
0325: INCF 3E,F |
858 |
0326: MOVWF 77 |
858 |
0326: MOVWF 77 |
859 |
0327: MOVWF 42 |
859 |
0327: MOVWF 42 |
860 |
0328: CALL 111 |
860 |
0328: CALL 111 |
861 |
0329: MOVLW 05 |
861 |
0329: MOVLW 05 |
862 |
032A: SUBWF 3E,W |
862 |
032A: SUBWF 3E,W |
863 |
032B: BTFSS 03.2 |
863 |
032B: BTFSS 03.2 |
864 |
032C: GOTO 323 |
864 |
032C: GOTO 323 |
865 |
032D: MOVF 35,W |
865 |
032D: MOVF 35,W |
866 |
032E: MOVWF 40 |
866 |
032E: MOVWF 40 |
867 |
032F: MOVLW 10 |
867 |
032F: MOVLW 10 |
868 |
0330: MOVWF 41 |
868 |
0330: MOVWF 41 |
869 |
0331: CALL 1C0 |
869 |
0331: CALL 1C0 |
870 |
0332: MOVLW 6D |
870 |
0332: MOVLW 6D |
871 |
0333: MOVWF 42 |
871 |
0333: MOVWF 42 |
872 |
0334: CALL 111 |
872 |
0334: CALL 111 |
873 |
0335: MOVLW 73 |
873 |
0335: MOVLW 73 |
874 |
0336: MOVWF 42 |
874 |
0336: MOVWF 42 |
875 |
0337: CALL 111 |
875 |
0337: CALL 111 |
876 |
0338: MOVLW 20 |
876 |
0338: MOVLW 20 |
877 |
0339: MOVWF 42 |
877 |
0339: MOVWF 42 |
878 |
033A: CALL 111 |
878 |
033A: CALL 111 |
879 |
.................... delay_ms(10); // prodleva pro terminal |
879 |
.................... delay_ms(10); // prodleva pro terminal |
880 |
033B: MOVLW 0A |
880 |
033B: MOVLW 0A |
881 |
033C: MOVWF 3E |
881 |
033C: MOVWF 3E |
882 |
033D: CALL 20D |
882 |
033D: CALL 20D |
883 |
.................... |
883 |
.................... |
884 |
.................... // Uvodni pauza |
884 |
.................... // Uvodni pauza |
885 |
.................... if (Start==0) // spousti se 1x na zacatku |
885 |
.................... if (Start==0) // spousti se 1x na zacatku |
886 |
033E: MOVF 36,F |
886 |
033E: MOVF 36,F |
887 |
033F: BTFSS 03.2 |
887 |
033F: BTFSS 03.2 |
888 |
0340: GOTO 347 |
888 |
0340: GOTO 347 |
889 |
.................... { |
889 |
.................... { |
890 |
.................... Start++; // dalsi stav je cekani |
890 |
.................... Start++; // dalsi stav je cekani |
891 |
0341: INCF 36,F |
891 |
0341: INCF 36,F |
892 |
.................... TimerSet(2000); // na dokonceni uvodni prodlevy |
892 |
.................... TimerSet(2000); // na dokonceni uvodni prodlevy |
893 |
0342: MOVLW 07 |
893 |
0342: MOVLW 07 |
894 |
0343: MOVWF 3F |
894 |
0343: MOVWF 3F |
895 |
0344: MOVLW D0 |
895 |
0344: MOVLW D0 |
896 |
0345: MOVWF 3E |
896 |
0345: MOVWF 3E |
897 |
0346: CALL 230 |
897 |
0346: CALL 230 |
898 |
.................... } |
898 |
.................... } |
899 |
.................... |
899 |
.................... |
900 |
.................... // Rozjezd |
900 |
.................... // Rozjezd |
901 |
.................... if ((Start==1) && TimerIf()) |
901 |
.................... if ((Start==1) && TimerIf()) |
902 |
0347: DECFSZ 36,W |
902 |
0347: DECFSZ 36,W |
903 |
0348: GOTO 359 |
903 |
0348: GOTO 359 |
904 |
0349: CALL 237 |
904 |
0349: CALL 237 |
905 |
034A: MOVF 78,F |
905 |
034A: MOVF 78,F |
906 |
034B: BTFSC 03.2 |
906 |
034B: BTFSC 03.2 |
907 |
034C: GOTO 359 |
907 |
034C: GOTO 359 |
908 |
.................... { |
908 |
.................... { |
909 |
.................... Start++; |
909 |
.................... Start++; |
910 |
034D: INCF 36,F |
910 |
034D: INCF 36,F |
911 |
.................... printf(Putc,"R"); |
911 |
.................... printf(Putc,"R"); |
912 |
034E: MOVLW 52 |
912 |
034E: MOVLW 52 |
913 |
034F: MOVWF 42 |
913 |
034F: MOVWF 42 |
914 |
0350: CALL 111 |
914 |
0350: CALL 111 |
915 |
.................... MotorStart(Data); // rozjezd s nastavenim prodlevy |
915 |
.................... MotorStart(Data); // rozjezd s nastavenim prodlevy |
916 |
0351: MOVF 35,W |
916 |
0351: MOVF 35,W |
917 |
0352: MOVWF 3E |
917 |
0352: MOVWF 3E |
918 |
0353: CALL 24D |
918 |
0353: CALL 24D |
919 |
.................... |
919 |
.................... |
920 |
.................... TimerSet(2000); // nastav celkovy cas jizdy |
920 |
.................... TimerSet(2000); // nastav celkovy cas jizdy |
921 |
0354: MOVLW 07 |
921 |
0354: MOVLW 07 |
922 |
0355: MOVWF 3F |
922 |
0355: MOVWF 3F |
923 |
0356: MOVLW D0 |
923 |
0356: MOVLW D0 |
924 |
0357: MOVWF 3E |
924 |
0357: MOVWF 3E |
925 |
0358: CALL 230 |
925 |
0358: CALL 230 |
926 |
.................... } |
926 |
.................... } |
927 |
.................... |
927 |
.................... |
928 |
.................... // Zastaveni |
928 |
.................... // Zastaveni |
929 |
.................... if ((Start==2) && TimerIf()) |
929 |
.................... if ((Start==2) && TimerIf()) |
930 |
0359: MOVF 36,W |
930 |
0359: MOVF 36,W |
931 |
035A: SUBLW 02 |
931 |
035A: SUBLW 02 |
932 |
035B: BTFSS 03.2 |
932 |
035B: BTFSS 03.2 |
933 |
035C: GOTO 367 |
933 |
035C: GOTO 367 |
934 |
035D: CALL 237 |
934 |
035D: CALL 237 |
935 |
035E: MOVF 78,F |
935 |
035E: MOVF 78,F |
936 |
035F: BTFSC 03.2 |
936 |
035F: BTFSC 03.2 |
937 |
0360: GOTO 367 |
937 |
0360: GOTO 367 |
938 |
.................... { |
938 |
.................... { |
939 |
.................... Start++; |
939 |
.................... Start++; |
940 |
0361: INCF 36,F |
940 |
0361: INCF 36,F |
941 |
.................... printf(Putc,"S"); |
941 |
.................... printf(Putc,"S"); |
942 |
0362: MOVLW 53 |
942 |
0362: MOVLW 53 |
943 |
0363: MOVWF 42 |
943 |
0363: MOVWF 42 |
944 |
0364: CALL 111 |
944 |
0364: CALL 111 |
945 |
.................... MotorSet(0); // pokud dobehl casovac zastav motor |
945 |
.................... MotorSet(0); // pokud dobehl casovac zastav motor |
946 |
0365: CLRF 3E |
946 |
0365: CLRF 3E |
947 |
0366: CALL 224 |
947 |
0366: CALL 224 |
948 |
.................... } |
948 |
.................... } |
949 |
.................... |
949 |
.................... |
950 |
.................... // watch dog |
950 |
.................... // watch dog |
951 |
.................... restart_wdt(); |
951 |
.................... restart_wdt(); |
952 |
0367: CLRWDT |
952 |
0367: CLRWDT |
953 |
.................... } |
953 |
.................... } |
954 |
0368: GOTO 31D |
954 |
0368: GOTO 31D |
955 |
.................... } |
955 |
.................... } |
956 |
.................... |
956 |
.................... |
957 |
.................... // ALG=3 Test nabijeciho algoritmu |
957 |
.................... // ALG=3 Test nabijeciho algoritmu |
958 |
.................... // =============================== |
958 |
.................... // =============================== |
959 |
.................... // P1 nastavuje pozadovane napeti na clancich (meri se Vref vuci napajeni) |
959 |
.................... // P1 nastavuje pozadovane napeti na clancich (meri se Vref vuci napajeni) |
960 |
.................... // Nacitani P1 probiha stale dokola, pro rizeni je pouzit stejny |
960 |
.................... // Nacitani P1 probiha stale dokola, pro rizeni je pouzit stejny |
961 |
.................... // algoritmus jako pro standardni jizdu |
961 |
.................... // algoritmus jako pro standardni jizdu |
962 |
.................... if (Debug==3) |
962 |
.................... if (Debug==3) |
963 |
0369: MOVF 30,W |
963 |
0369: MOVF 30,W |
964 |
036A: SUBLW 03 |
964 |
036A: SUBLW 03 |
965 |
036B: BTFSS 03.2 |
965 |
036B: BTFSS 03.2 |
966 |
036C: GOTO 3C0 |
966 |
036C: GOTO 3C0 |
967 |
.................... { |
967 |
.................... { |
968 |
.................... unsigned int8 PwmOut; // akcni hodnota pro PWM |
968 |
.................... unsigned int8 PwmOut; // akcni hodnota pro PWM |
969 |
.................... unsigned int8 Req; // pozadovana hodnota z P1 |
969 |
.................... unsigned int8 Req; // pozadovana hodnota z P1 |
970 |
.................... unsigned int8 Vref; // merena hodnota vref |
970 |
.................... unsigned int8 Vref; // merena hodnota vref |
971 |
.................... |
971 |
.................... |
972 |
.................... // Inicializace stavove promenne |
972 |
.................... // Inicializace stavove promenne |
973 |
.................... PwmOut=0; |
973 |
.................... PwmOut=0; |
974 |
036D: CLRF 37 |
974 |
036D: CLRF 37 |
975 |
.................... |
975 |
.................... |
976 |
.................... // Hlavni smycka |
976 |
.................... // Hlavni smycka |
977 |
.................... while (1) |
977 |
.................... while (1) |
978 |
.................... { |
978 |
.................... { |
979 |
.................... // watch dog |
979 |
.................... // watch dog |
980 |
.................... restart_wdt(); |
980 |
.................... restart_wdt(); |
981 |
036E: CLRWDT |
981 |
036E: CLRWDT |
982 |
.................... |
982 |
.................... |
983 |
.................... // pozadovana hodnota (potenciometr P1) |
983 |
.................... // pozadovana hodnota (potenciometr P1) |
984 |
.................... Req=ReadAD(0); |
984 |
.................... Req=ReadAD(0); |
985 |
036F: CLRF 3E |
985 |
036F: CLRF 3E |
986 |
0370: CALL 195 |
986 |
0370: CALL 195 |
987 |
0371: MOVF 78,W |
987 |
0371: MOVF 78,W |
988 |
0372: MOVWF 38 |
988 |
0372: MOVWF 38 |
989 |
.................... Req=50+(ReadAD(0)>>1); // 50 az 177 |
989 |
.................... Req=50+(ReadAD(0)>>1); // 50 az 177 |
990 |
0373: CLRF 3E |
990 |
0373: CLRF 3E |
991 |
0374: CALL 195 |
991 |
0374: CALL 195 |
992 |
0375: BCF 03.0 |
992 |
0375: BCF 03.0 |
993 |
0376: RRF 78,W |
993 |
0376: RRF 78,W |
994 |
0377: ADDLW 32 |
994 |
0377: ADDLW 32 |
995 |
0378: MOVWF 38 |
995 |
0378: MOVWF 38 |
996 |
.................... |
996 |
.................... |
997 |
.................... // napeti na napajeni (vref) |
997 |
.................... // napeti na napajeni (vref) |
998 |
.................... Vref=ReadAD(4); |
998 |
.................... Vref=ReadAD(4); |
999 |
0379: MOVLW 04 |
999 |
0379: MOVLW 04 |
1000 |
037A: MOVWF 3E |
1000 |
037A: MOVWF 3E |
1001 |
037B: CALL 195 |
1001 |
037B: CALL 195 |
1002 |
037C: MOVF 78,W |
1002 |
037C: MOVF 78,W |
1003 |
037D: MOVWF 39 |
1003 |
037D: MOVWF 39 |
1004 |
.................... |
1004 |
.................... |
1005 |
.................... // ricici algoritmus |
1005 |
.................... // ricici algoritmus |
1006 |
.................... if ((Vref<Req) &&(PwmOut<30)) PwmOut++; |
1006 |
.................... if ((Vref<Req) &&(PwmOut<30)) PwmOut++; |
1007 |
037E: MOVF 38,W |
1007 |
037E: MOVF 38,W |
1008 |
037F: SUBWF 39,W |
1008 |
037F: SUBWF 39,W |
1009 |
0380: BTFSC 03.0 |
1009 |
0380: BTFSC 03.0 |
1010 |
0381: GOTO 386 |
1010 |
0381: GOTO 386 |
1011 |
0382: MOVF 37,W |
1011 |
0382: MOVF 37,W |
1012 |
0383: SUBLW 1D |
1012 |
0383: SUBLW 1D |
1013 |
0384: BTFSC 03.0 |
1013 |
0384: BTFSC 03.0 |
1014 |
0385: INCF 37,F |
1014 |
0385: INCF 37,F |
1015 |
.................... if ((Vref>=Req)&&(PwmOut> 0)) PwmOut--; |
1015 |
.................... if ((Vref>=Req)&&(PwmOut> 0)) PwmOut--; |
1016 |
0386: MOVF 38,W |
1016 |
0386: MOVF 38,W |
1017 |
0387: SUBWF 39,W |
1017 |
0387: SUBWF 39,W |
1018 |
0388: BTFSS 03.0 |
1018 |
0388: BTFSS 03.0 |
1019 |
0389: GOTO 38D |
1019 |
0389: GOTO 38D |
1020 |
038A: MOVF 37,F |
1020 |
038A: MOVF 37,F |
1021 |
038B: BTFSS 03.2 |
1021 |
038B: BTFSS 03.2 |
1022 |
038C: DECF 37,F |
1022 |
038C: DECF 37,F |
1023 |
.................... Vref+=10; |
1023 |
.................... Vref+=10; |
1024 |
038D: MOVLW 0A |
1024 |
038D: MOVLW 0A |
1025 |
038E: ADDWF 39,F |
1025 |
038E: ADDWF 39,F |
1026 |
.................... if ((Vref<(Req))&&(PwmOut<30)) PwmOut++; // urychleni nabehu |
1026 |
.................... if ((Vref<(Req))&&(PwmOut<30)) PwmOut++; // urychleni nabehu |
1027 |
038F: MOVF 38,W |
1027 |
038F: MOVF 38,W |
1028 |
0390: SUBWF 39,W |
1028 |
0390: SUBWF 39,W |
1029 |
0391: BTFSC 03.0 |
1029 |
0391: BTFSC 03.0 |
1030 |
0392: GOTO 397 |
1030 |
0392: GOTO 397 |
1031 |
0393: MOVF 37,W |
1031 |
0393: MOVF 37,W |
1032 |
0394: SUBLW 1D |
1032 |
0394: SUBLW 1D |
1033 |
0395: BTFSC 03.0 |
1033 |
0395: BTFSC 03.0 |
1034 |
0396: INCF 37,F |
1034 |
0396: INCF 37,F |
1035 |
.................... |
1035 |
.................... |
1036 |
.................... // nastaveni parametru PWM |
1036 |
.................... // nastaveni parametru PWM |
1037 |
.................... if (PwmOut>24) PwmOut=24; // saturace |
1037 |
.................... if (PwmOut>24) PwmOut=24; // saturace |
1038 |
0397: MOVF 37,W |
1038 |
0397: MOVF 37,W |
1039 |
0398: SUBLW 18 |
1039 |
0398: SUBLW 18 |
1040 |
0399: BTFSC 03.0 |
1040 |
0399: BTFSC 03.0 |
1041 |
039A: GOTO 39D |
1041 |
039A: GOTO 39D |
1042 |
039B: MOVLW 18 |
1042 |
039B: MOVLW 18 |
1043 |
039C: MOVWF 37 |
1043 |
039C: MOVWF 37 |
1044 |
.................... CCPR1L = PwmOut; // pouziti vystupu |
1044 |
.................... CCPR1L = PwmOut; // pouziti vystupu |
1045 |
039D: MOVF 37,W |
1045 |
039D: MOVF 37,W |
1046 |
039E: MOVWF 15 |
1046 |
039E: MOVWF 15 |
1047 |
.................... |
1047 |
.................... |
1048 |
.................... // zobrazeni |
1048 |
.................... // zobrazeni |
1049 |
.................... printf(Putc,"\nALG:%03u %03u %03u",Req,Vref,PwmOut); |
1049 |
.................... printf(Putc,"\nALG:%03u %03u %03u",Req,Vref,PwmOut); |
1050 |
039F: CLRF 3E |
1050 |
039F: CLRF 3E |
1051 |
03A0: MOVF 3E,W |
1051 |
03A0: MOVF 3E,W |
1052 |
03A1: CALL 07D |
1052 |
03A1: CALL 07D |
1053 |
03A2: INCF 3E,F |
1053 |
03A2: INCF 3E,F |
1054 |
03A3: MOVWF 77 |
1054 |
03A3: MOVWF 77 |
1055 |
03A4: MOVWF 42 |
1055 |
03A4: MOVWF 42 |
1056 |
03A5: CALL 111 |
1056 |
03A5: CALL 111 |
1057 |
03A6: MOVLW 05 |
1057 |
03A6: MOVLW 05 |
1058 |
03A7: SUBWF 3E,W |
1058 |
03A7: SUBWF 3E,W |
1059 |
03A8: BTFSS 03.2 |
1059 |
03A8: BTFSS 03.2 |
1060 |
03A9: GOTO 3A0 |
1060 |
03A9: GOTO 3A0 |
1061 |
03AA: MOVF 38,W |
1061 |
03AA: MOVF 38,W |
1062 |
03AB: MOVWF 40 |
1062 |
03AB: MOVWF 40 |
1063 |
03AC: CLRF 41 |
1063 |
03AC: CLRF 41 |
1064 |
03AD: CALL 1C0 |
1064 |
03AD: CALL 1C0 |
1065 |
03AE: MOVLW 20 |
1065 |
03AE: MOVLW 20 |
1066 |
03AF: MOVWF 42 |
1066 |
03AF: MOVWF 42 |
1067 |
03B0: CALL 111 |
1067 |
03B0: CALL 111 |
1068 |
03B1: MOVF 39,W |
1068 |
03B1: MOVF 39,W |
1069 |
03B2: MOVWF 40 |
1069 |
03B2: MOVWF 40 |
1070 |
03B3: CLRF 41 |
1070 |
03B3: CLRF 41 |
1071 |
03B4: CALL 1C0 |
1071 |
03B4: CALL 1C0 |
1072 |
03B5: MOVLW 20 |
1072 |
03B5: MOVLW 20 |
1073 |
03B6: MOVWF 42 |
1073 |
03B6: MOVWF 42 |
1074 |
03B7: CALL 111 |
1074 |
03B7: CALL 111 |
1075 |
03B8: MOVF 37,W |
1075 |
03B8: MOVF 37,W |
1076 |
03B9: MOVWF 40 |
1076 |
03B9: MOVWF 40 |
1077 |
03BA: CLRF 41 |
1077 |
03BA: CLRF 41 |
1078 |
03BB: CALL 1C0 |
1078 |
03BB: CALL 1C0 |
1079 |
.................... delay_ms(10); |
1079 |
.................... delay_ms(10); |
1080 |
03BC: MOVLW 0A |
1080 |
03BC: MOVLW 0A |
1081 |
03BD: MOVWF 3E |
1081 |
03BD: MOVWF 3E |
1082 |
03BE: CALL 20D |
1082 |
03BE: CALL 20D |
1083 |
.................... } |
1083 |
.................... } |
1084 |
03BF: GOTO 36E |
1084 |
03BF: GOTO 36E |
1085 |
.................... } |
1085 |
.................... } |
1086 |
.................... |
1086 |
.................... |
1087 |
.................... // ALG=0 Standardni jizda |
1087 |
.................... // ALG=0 Standardni jizda |
1088 |
.................... // ====================== |
1088 |
.................... // ====================== |
1089 |
.................... // P1 nastavuje pozadovane napeti na clancich |
1089 |
.................... // P1 nastavuje pozadovane napeti na clancich |
1090 |
.................... // P2 nastavuje prodlevu razeni pri rozjezdu, nacita se jen 1x na zacatku |
1090 |
.................... // P2 nastavuje prodlevu razeni pri rozjezdu, nacita se jen 1x na zacatku |
1091 |
.................... // Po resetu cca 14.5 sekundy akumuluje do kondenzatoru a pak provede |
1091 |
.................... // Po resetu cca 14.5 sekundy akumuluje do kondenzatoru a pak provede |
1092 |
.................... // rozjezd motoru. Po celou dobu probiha rizeni zateze slunecnich clanku. |
1092 |
.................... // rozjezd motoru. Po celou dobu probiha rizeni zateze slunecnich clanku. |
1093 |
.................... // Parametry P1 a P2 jsou chapany stejne jako v algoritmech 2 a 3. |
1093 |
.................... // Parametry P1 a P2 jsou chapany stejne jako v algoritmech 2 a 3. |
1094 |
.................... if (Debug==0) |
1094 |
.................... if (Debug==0) |
1095 |
03C0: MOVF 30,F |
1095 |
03C0: MOVF 30,F |
1096 |
03C1: BTFSS 03.2 |
1096 |
03C1: BTFSS 03.2 |
1097 |
03C2: GOTO 447 |
1097 |
03C2: GOTO 447 |
1098 |
.................... { |
1098 |
.................... { |
1099 |
.................... unsigned int8 PwmOut; // akcni hodnota pro PWM |
1099 |
.................... unsigned int8 PwmOut; // akcni hodnota pro PWM |
1100 |
.................... unsigned int8 Req; // pozadovana hodnota z P1 |
1100 |
.................... unsigned int8 Req; // pozadovana hodnota z P1 |
1101 |
.................... unsigned int8 Vref; // merena hodnota vref |
1101 |
.................... unsigned int8 Vref; // merena hodnota vref |
1102 |
.................... int8 Delay; // pozadovana honota prodlevy razeni z P2 |
1102 |
.................... int8 Delay; // pozadovana honota prodlevy razeni z P2 |
1103 |
.................... int1 Run; |
1103 |
.................... int1 Run; |
1104 |
.................... |
1104 |
.................... |
1105 |
.................... // Nacti parametr rozjezdu |
1105 |
.................... // Nacti parametr rozjezdu |
1106 |
.................... Delay=ReadAD(1); // potenciometr P2 = rozjezd |
1106 |
.................... Delay=ReadAD(1); // potenciometr P2 = rozjezd |
1107 |
03C3: MOVLW 01 |
1107 |
03C3: MOVLW 01 |
1108 |
03C4: MOVWF 3E |
1108 |
03C4: MOVWF 3E |
1109 |
03C5: CALL 195 |
1109 |
03C5: CALL 195 |
1110 |
03C6: MOVF 78,W |
1110 |
03C6: MOVF 78,W |
1111 |
03C7: MOVWF 3D |
1111 |
03C7: MOVWF 3D |
1112 |
.................... printf(Putc," RUN:%3ums ",Delay); // zobraz |
1112 |
.................... printf(Putc," RUN:%3ums ",Delay); // zobraz |
1113 |
03C8: CLRF 3E |
1113 |
03C8: CLRF 3E |
1114 |
03C9: MOVF 3E,W |
1114 |
03C9: MOVF 3E,W |
1115 |
03CA: CALL 095 |
1115 |
03CA: CALL 095 |
1116 |
03CB: INCF 3E,F |
1116 |
03CB: INCF 3E,F |
1117 |
03CC: MOVWF 77 |
1117 |
03CC: MOVWF 77 |
1118 |
03CD: MOVWF 42 |
1118 |
03CD: MOVWF 42 |
1119 |
03CE: CALL 111 |
1119 |
03CE: CALL 111 |
1120 |
03CF: MOVLW 05 |
1120 |
03CF: MOVLW 05 |
1121 |
03D0: SUBWF 3E,W |
1121 |
03D0: SUBWF 3E,W |
1122 |
03D1: BTFSS 03.2 |
1122 |
03D1: BTFSS 03.2 |
1123 |
03D2: GOTO 3C9 |
1123 |
03D2: GOTO 3C9 |
1124 |
03D3: MOVF 3D,W |
1124 |
03D3: MOVF 3D,W |
1125 |
03D4: MOVWF 40 |
1125 |
03D4: MOVWF 40 |
1126 |
03D5: MOVLW 10 |
1126 |
03D5: MOVLW 10 |
1127 |
03D6: MOVWF 41 |
1127 |
03D6: MOVWF 41 |
1128 |
03D7: CALL 1C0 |
1128 |
03D7: CALL 1C0 |
1129 |
03D8: MOVLW 6D |
1129 |
03D8: MOVLW 6D |
1130 |
03D9: MOVWF 42 |
1130 |
03D9: MOVWF 42 |
1131 |
03DA: CALL 111 |
1131 |
03DA: CALL 111 |
1132 |
03DB: MOVLW 73 |
1132 |
03DB: MOVLW 73 |
1133 |
03DC: MOVWF 42 |
1133 |
03DC: MOVWF 42 |
1134 |
03DD: CALL 111 |
1134 |
03DD: CALL 111 |
1135 |
03DE: MOVLW 20 |
1135 |
03DE: MOVLW 20 |
1136 |
03DF: MOVWF 42 |
1136 |
03DF: MOVWF 42 |
1137 |
03E0: CALL 111 |
1137 |
03E0: CALL 111 |
1138 |
.................... delay_ms(10); // prodleva pro terminal |
1138 |
.................... delay_ms(10); // prodleva pro terminal |
1139 |
03E1: MOVLW 0A |
1139 |
03E1: MOVLW 0A |
1140 |
03E2: MOVWF 3E |
1140 |
03E2: MOVWF 3E |
1141 |
03E3: CALL 20D |
1141 |
03E3: CALL 20D |
1142 |
.................... |
1142 |
.................... |
1143 |
.................... // Inicializace stavove promenne |
1143 |
.................... // Inicializace stavove promenne |
1144 |
.................... PwmOut=0; |
1144 |
.................... PwmOut=0; |
1145 |
03E4: CLRF 3A |
1145 |
03E4: CLRF 3A |
1146 |
.................... TimerSet(14000); // casovani startu |
1146 |
.................... TimerSet(14000); // casovani startu |
1147 |
03E5: MOVLW 36 |
1147 |
03E5: MOVLW 36 |
1148 |
03E6: MOVWF 3F |
1148 |
03E6: MOVWF 3F |
1149 |
03E7: MOVLW B0 |
1149 |
03E7: MOVLW B0 |
1150 |
03E8: MOVWF 3E |
1150 |
03E8: MOVWF 3E |
1151 |
03E9: CALL 230 |
1151 |
03E9: CALL 230 |
1152 |
.................... Run=1; |
1152 |
.................... Run=1; |
1153 |
03EA: BSF 32.1 |
1153 |
03EA: BSF 32.1 |
1154 |
.................... |
1154 |
.................... |
1155 |
.................... // Hlavni smycka |
1155 |
.................... // Hlavni smycka |
1156 |
.................... while (1) |
1156 |
.................... while (1) |
1157 |
.................... { |
1157 |
.................... { |
1158 |
.................... // watch dog |
1158 |
.................... // watch dog |
1159 |
.................... restart_wdt(); |
1159 |
.................... restart_wdt(); |
1160 |
03EB: CLRWDT |
1160 |
03EB: CLRWDT |
1161 |
.................... |
1161 |
.................... |
1162 |
.................... // pozadovana hodnota (potenciometr P1) |
1162 |
.................... // pozadovana hodnota (potenciometr P1) |
1163 |
.................... Req=ReadAD(0); |
1163 |
.................... Req=ReadAD(0); |
1164 |
03EC: CLRF 3E |
1164 |
03EC: CLRF 3E |
1165 |
03ED: CALL 195 |
1165 |
03ED: CALL 195 |
1166 |
03EE: MOVF 78,W |
1166 |
03EE: MOVF 78,W |
1167 |
03EF: MOVWF 3B |
1167 |
03EF: MOVWF 3B |
1168 |
.................... Req=50+(ReadAD(0)>>1); // 50 az 177 |
1168 |
.................... Req=50+(ReadAD(0)>>1); // 50 az 177 |
1169 |
03F0: CLRF 3E |
1169 |
03F0: CLRF 3E |
1170 |
03F1: CALL 195 |
1170 |
03F1: CALL 195 |
1171 |
03F2: BCF 03.0 |
1171 |
03F2: BCF 03.0 |
1172 |
03F3: RRF 78,W |
1172 |
03F3: RRF 78,W |
1173 |
03F4: ADDLW 32 |
1173 |
03F4: ADDLW 32 |
1174 |
03F5: MOVWF 3B |
1174 |
03F5: MOVWF 3B |
1175 |
.................... |
1175 |
.................... |
1176 |
.................... // napeti na napajeni (vref) |
1176 |
.................... // napeti na napajeni (vref) |
1177 |
.................... Vref=ReadAD(4); |
1177 |
.................... Vref=ReadAD(4); |
1178 |
03F6: MOVLW 04 |
1178 |
03F6: MOVLW 04 |
1179 |
03F7: MOVWF 3E |
1179 |
03F7: MOVWF 3E |
1180 |
03F8: CALL 195 |
1180 |
03F8: CALL 195 |
1181 |
03F9: MOVF 78,W |
1181 |
03F9: MOVF 78,W |
1182 |
03FA: MOVWF 3C |
1182 |
03FA: MOVWF 3C |
1183 |
.................... |
1183 |
.................... |
1184 |
.................... // ricici algoritmus |
1184 |
.................... // ricici algoritmus |
1185 |
.................... if ((Vref<Req) &&(PwmOut<30)) PwmOut++; |
1185 |
.................... if ((Vref<Req) &&(PwmOut<30)) PwmOut++; |
1186 |
03FB: MOVF 3B,W |
1186 |
03FB: MOVF 3B,W |
1187 |
03FC: SUBWF 3C,W |
1187 |
03FC: SUBWF 3C,W |
1188 |
03FD: BTFSC 03.0 |
1188 |
03FD: BTFSC 03.0 |
1189 |
03FE: GOTO 403 |
1189 |
03FE: GOTO 403 |
1190 |
03FF: MOVF 3A,W |
1190 |
03FF: MOVF 3A,W |
1191 |
0400: SUBLW 1D |
1191 |
0400: SUBLW 1D |
1192 |
0401: BTFSC 03.0 |
1192 |
0401: BTFSC 03.0 |
1193 |
0402: INCF 3A,F |
1193 |
0402: INCF 3A,F |
1194 |
.................... if ((Vref>=Req)&&(PwmOut> 0)) PwmOut--; |
1194 |
.................... if ((Vref>=Req)&&(PwmOut> 0)) PwmOut--; |
1195 |
0403: MOVF 3B,W |
1195 |
0403: MOVF 3B,W |
1196 |
0404: SUBWF 3C,W |
1196 |
0404: SUBWF 3C,W |
1197 |
0405: BTFSS 03.0 |
1197 |
0405: BTFSS 03.0 |
1198 |
0406: GOTO 40A |
1198 |
0406: GOTO 40A |
1199 |
0407: MOVF 3A,F |
1199 |
0407: MOVF 3A,F |
1200 |
0408: BTFSS 03.2 |
1200 |
0408: BTFSS 03.2 |
1201 |
0409: DECF 3A,F |
1201 |
0409: DECF 3A,F |
1202 |
.................... Vref+=10; |
1202 |
.................... Vref+=10; |
1203 |
040A: MOVLW 0A |
1203 |
040A: MOVLW 0A |
1204 |
040B: ADDWF 3C,F |
1204 |
040B: ADDWF 3C,F |
1205 |
.................... if ((Vref<(Req))&&(PwmOut<30)) PwmOut++; // urychleni nabehu |
1205 |
.................... if ((Vref<(Req))&&(PwmOut<30)) PwmOut++; // urychleni nabehu |
1206 |
040C: MOVF 3B,W |
1206 |
040C: MOVF 3B,W |
1207 |
040D: SUBWF 3C,W |
1207 |
040D: SUBWF 3C,W |
1208 |
040E: BTFSC 03.0 |
1208 |
040E: BTFSC 03.0 |
1209 |
040F: GOTO 414 |
1209 |
040F: GOTO 414 |
1210 |
0410: MOVF 3A,W |
1210 |
0410: MOVF 3A,W |
1211 |
0411: SUBLW 1D |
1211 |
0411: SUBLW 1D |
1212 |
0412: BTFSC 03.0 |
1212 |
0412: BTFSC 03.0 |
1213 |
0413: INCF 3A,F |
1213 |
0413: INCF 3A,F |
1214 |
.................... |
1214 |
.................... |
1215 |
.................... // nastaveni parametru PWM |
1215 |
.................... // nastaveni parametru PWM |
1216 |
.................... if (PwmOut>24) PwmOut=24; // saturace |
1216 |
.................... if (PwmOut>24) PwmOut=24; // saturace |
1217 |
0414: MOVF 3A,W |
1217 |
0414: MOVF 3A,W |
1218 |
0415: SUBLW 18 |
1218 |
0415: SUBLW 18 |
1219 |
0416: BTFSC 03.0 |
1219 |
0416: BTFSC 03.0 |
1220 |
0417: GOTO 41A |
1220 |
0417: GOTO 41A |
1221 |
0418: MOVLW 18 |
1221 |
0418: MOVLW 18 |
1222 |
0419: MOVWF 3A |
1222 |
0419: MOVWF 3A |
1223 |
.................... CCPR1L = PwmOut; // pouziti vystupu |
1223 |
.................... CCPR1L = PwmOut; // pouziti vystupu |
1224 |
041A: MOVF 3A,W |
1224 |
041A: MOVF 3A,W |
1225 |
041B: MOVWF 15 |
1225 |
041B: MOVWF 15 |
1226 |
.................... |
1226 |
.................... |
1227 |
.................... // zobrazeni |
1227 |
.................... // zobrazeni |
1228 |
.................... printf(Putc,"\nALG:%03u %03u %03u",Req,Vref,PwmOut); |
1228 |
.................... printf(Putc,"\nALG:%03u %03u %03u",Req,Vref,PwmOut); |
1229 |
041C: CLRF 3E |
1229 |
041C: CLRF 3E |
1230 |
041D: MOVF 3E,W |
1230 |
041D: MOVF 3E,W |
1231 |
041E: CALL 07D |
1231 |
041E: CALL 07D |
1232 |
041F: INCF 3E,F |
1232 |
041F: INCF 3E,F |
1233 |
0420: MOVWF 77 |
1233 |
0420: MOVWF 77 |
1234 |
0421: MOVWF 42 |
1234 |
0421: MOVWF 42 |
1235 |
0422: CALL 111 |
1235 |
0422: CALL 111 |
1236 |
0423: MOVLW 05 |
1236 |
0423: MOVLW 05 |
1237 |
0424: SUBWF 3E,W |
1237 |
0424: SUBWF 3E,W |
1238 |
0425: BTFSS 03.2 |
1238 |
0425: BTFSS 03.2 |
1239 |
0426: GOTO 41D |
1239 |
0426: GOTO 41D |
1240 |
0427: MOVF 3B,W |
1240 |
0427: MOVF 3B,W |
1241 |
0428: MOVWF 40 |
1241 |
0428: MOVWF 40 |
1242 |
0429: CLRF 41 |
1242 |
0429: CLRF 41 |
1243 |
042A: CALL 1C0 |
1243 |
042A: CALL 1C0 |
1244 |
042B: MOVLW 20 |
1244 |
042B: MOVLW 20 |
1245 |
042C: MOVWF 42 |
1245 |
042C: MOVWF 42 |
1246 |
042D: CALL 111 |
1246 |
042D: CALL 111 |
1247 |
042E: MOVF 3C,W |
1247 |
042E: MOVF 3C,W |
1248 |
042F: MOVWF 40 |
1248 |
042F: MOVWF 40 |
1249 |
0430: CLRF 41 |
1249 |
0430: CLRF 41 |
1250 |
0431: CALL 1C0 |
1250 |
0431: CALL 1C0 |
1251 |
0432: MOVLW 20 |
1251 |
0432: MOVLW 20 |
1252 |
0433: MOVWF 42 |
1252 |
0433: MOVWF 42 |
1253 |
0434: CALL 111 |
1253 |
0434: CALL 111 |
1254 |
0435: MOVF 3A,W |
1254 |
0435: MOVF 3A,W |
1255 |
0436: MOVWF 40 |
1255 |
0436: MOVWF 40 |
1256 |
0437: CLRF 41 |
1256 |
0437: CLRF 41 |
1257 |
0438: CALL 1C0 |
1257 |
0438: CALL 1C0 |
1258 |
.................... delay_ms(10); |
1258 |
.................... delay_ms(10); |
1259 |
0439: MOVLW 0A |
1259 |
0439: MOVLW 0A |
1260 |
043A: MOVWF 3E |
1260 |
043A: MOVWF 3E |
1261 |
043B: CALL 20D |
1261 |
043B: CALL 20D |
1262 |
.................... |
1262 |
.................... |
1263 |
.................... // rozjezd |
1263 |
.................... // rozjezd |
1264 |
.................... if (TimerIf()&&Run) |
1264 |
.................... if (TimerIf()&&Run) |
1265 |
043C: CALL 237 |
1265 |
043C: CALL 237 |
1266 |
043D: MOVF 78,F |
1266 |
043D: MOVF 78,F |
1267 |
043E: BTFSC 03.2 |
1267 |
043E: BTFSC 03.2 |
1268 |
043F: GOTO 446 |
1268 |
043F: GOTO 446 |
1269 |
0440: BTFSS 32.1 |
1269 |
0440: BTFSS 32.1 |
1270 |
0441: GOTO 446 |
1270 |
0441: GOTO 446 |
1271 |
.................... { |
1271 |
.................... { |
1272 |
.................... Run=0; |
1272 |
.................... Run=0; |
1273 |
0442: BCF 32.1 |
1273 |
0442: BCF 32.1 |
1274 |
.................... MotorStart(Delay); // prodleva razeni z P2 |
1274 |
.................... MotorStart(Delay); // prodleva razeni z P2 |
1275 |
0443: MOVF 3D,W |
1275 |
0443: MOVF 3D,W |
1276 |
0444: MOVWF 3E |
1276 |
0444: MOVWF 3E |
1277 |
0445: CALL 24D |
1277 |
0445: CALL 24D |
1278 |
.................... } |
1278 |
.................... } |
1279 |
.................... } |
1279 |
.................... } |
1280 |
0446: GOTO 3EB |
1280 |
0446: GOTO 3EB |
1281 |
.................... } |
1281 |
.................... } |
1282 |
.................... } |
1282 |
.................... } |
1283 |
.................... |
1283 |
.................... |
1284 |
0447: SLEEP |
1284 |
0447: SLEEP |
1285 |
|
1285 |
|
1286 |
Configuration Fuses: |
1286 |
Configuration Fuses: |
1287 |
Word 1: 2F3C WDT NOPUT MCLR NOBROWNOUT NOLVP NOCPD NOWRT NODEBUG CCPB3 NOPROTECT INTRC_IO |
1287 |
Word 1: 2F3C WDT NOPUT MCLR NOBROWNOUT NOLVP NOCPD NOWRT NODEBUG CCPB3 NOPROTECT INTRC_IO |
1288 |
Word 2: 3FFF FCMEN IESO |
1288 |
Word 2: 3FFF FCMEN IESO |