-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbernadete3kg_2017_beta.lst
3134 lines (3130 loc) · 98.7 KB
/
bernadete3kg_2017_beta.lst
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
CCS PCH C Compiler, Version 4.104, 5967 23-nov-17 20:52
Filename: C:\Users\Nícolas\Desktop\Robótica\Programação\2017\Modificações - Programa Lobo + Bernadete\Versão Final - Lobo + Bernadete\bernadete3kg_2017_beta.lst
ROM used: 4682 bytes (29%)
Largest free fragment is 11698
RAM used: 33 (4%) at main() level
54 (7%) worst case
Stack: 7 worst case (5 in main + 2 for interrupts)
*
0000: GOTO 1184
*
0008: MOVWF 04
000A: MOVFF FD8,05
000E: MOVFF FE0,06
0012: MOVLB 0
0014: MOVFF FE9,0C
0018: MOVFF FEA,07
001C: MOVFF FE1,08
0020: MOVFF FE2,09
0024: MOVFF FD9,0A
0028: MOVFF FDA,0B
002C: MOVFF FF3,12
0030: MOVFF FF4,13
0034: MOVFF FFA,14
0038: MOVFF 00,0E
003C: MOVFF 01,0F
0040: MOVFF 02,10
0044: MOVFF 03,11
0048: BTFSS F9D.5
004A: GOTO 0054
004E: BTFSC F9E.5
0050: GOTO 012A
0054: BTFSS F9D.0
0056: GOTO 0060
005A: BTFSC F9E.0
005C: GOTO 00E4
0060: BTFSS FF2.5
0062: GOTO 006C
0066: BTFSC FF2.2
0068: GOTO 00AE
006C: MOVFF 0E,00
0070: MOVFF 0F,01
0074: MOVFF 10,02
0078: MOVFF 11,03
007C: MOVFF 0C,FE9
0080: MOVFF 07,FEA
0084: BSF 07.7
0086: MOVFF 08,FE1
008A: MOVFF 09,FE2
008E: MOVFF 0A,FD9
0092: MOVFF 0B,FDA
0096: MOVFF 12,FF3
009A: MOVFF 13,FF4
009E: MOVFF 14,FFA
00A2: MOVF 04,W
00A4: MOVFF 06,FE0
00A8: MOVFF 05,FD8
00AC: RETFIE 0
.................... /*-------------------------Versão 8.5-----------------------------------------*/
.................... #include<18f4431.h>
.................... //////// Standard Header file for the PIC18F4431 device ////////////////
.................... #device PIC18F4431
.................... #list
....................
.................... #device adc=10 //Seta a resolução do conversor A/D em 10 bits
.................... #fuses HS, NOWDT, NOPROTECT, NOBROWNOUT, PUT, NOLVP, FCMEN
.................... #use delay(clock=20000000)
*
02D0: CLRF FEA
02D2: MOVLW 22
02D4: MOVWF FE9
02D6: MOVF FEF,W
02D8: BZ 02F4
02DA: MOVLW 06
02DC: MOVWF 01
02DE: CLRF 00
02E0: DECFSZ 00,F
02E2: BRA 02E0
02E4: DECFSZ 01,F
02E6: BRA 02DE
02E8: MOVLW 7B
02EA: MOVWF 00
02EC: DECFSZ 00,F
02EE: BRA 02EC
02F0: DECFSZ FEF,F
02F2: BRA 02DA
02F4: RETLW 00
.................... #use rs232(BAUD=9600, UART1, XMIT=PIN_C6, RCV=PIN_C7, PARITY= N, BITS = 8, STREAM = BT)
.................... #priority RDA, TIMER1, TIMER0
.................... /*--------------------------Inclusão de Bibliotecas---------------------------*/
.................... #include "sumo3kg_library.c" //Biblioteca entre "": mesmo diretório do projeto
.................... #include "sumo3kg_library.h"
.................... #ifndef pinos_sumo3kg_
.................... #define pinos_sumo3kg_
....................
.................... #define lobo 1
.................... #define bernadete 0
.................... /*----------------------------Canais conversor A/D----------------------------*/
.................... #define linha_direita 5
.................... #define linha_esquerda 6
.................... #define distancia_direita 0
.................... #define distancia_central 2
.................... #define distancia_esquerda 3
.................... /*----------------------------Pinagem dos sensores----------------------------*/
.................... /*
.................... #define linha_direita PIN_A6
.................... #define linha_esquerda PIN_A5
.................... #define distancia_esquerda PIN_A3
.................... #define distancia_central PIN_A0
.................... #define distancia_direita PIN_A4
.................... */
.................... /*---------------------------Pinagem dos Motores------------------------------*/
.................... #define motor_esquerda PIN_B6 /*arbitrario*/
.................... #define motor_direita PIN_B7 /*arbitrario*/
.................... /*-------------------------Modo teste do programa-----------------------------*/
.................... #define teste_controlado 0
.................... /*-----------------------------------Luta-------------------------------------*/
.................... #define luta 1
.................... /*------------------------Habilitação da ponte H------------------------------*/
.................... #define ENA_state 1
.................... #define ENB_state 1
.................... /*----------------------------Limiar Sensores---------------------------------*/
.................... #define limiar_distancia 470 /*****LIMIAR BERNADETE, REVER****/
.................... #define limiar_linha 800 /*****FAZER TESTES COM ELETRÔNICA****/
.................... /*-------------------------Frequência PWM-------------------------------------*/
.................... #define POWER_PWM_PERIOD 311 //simular no Proteus. Freq = +/- 16kHz
.................... /*--------------------Habilitar função dos motores/TIMER0---------------------*/
.................... #define ON 1
.................... #define OFF 0
.................... /*--------------------------LEDs de uso geral---------------------------------*/
.................... #define LED1 PIN_D0
.................... #define LED2 PIN_D1
.................... #define LED3 PIN_D2
.................... #define LED4 PIN_D3
.................... /*--------------------------Protótipos----------------------------------------*/
.................... void Habilita_Motores(int1 estado);
.................... void Portas_IO();
.................... void Configura_AD();
.................... int1 Leitura(int16 threshold, int8 canal);
.................... void MoverMotores(int16 duty_esquerda, int16 duty_direita, char sentido);
.................... int8 Seta_Sensores(char tipo);
.................... void Motor_esq(int16 duty_esq, char sentido_esq);
.................... void Motor_dir(int16 duty_dir, char sentido_dir);
.................... #endif
....................
....................
.................... int8 sensores = 0;
.................... int8 sensor_anterior =0;
.................... void Configura_Timer0(int1 estado)
.................... {
.................... if(estado == 1)
*
02A2: DECFSZ 20,W
02A4: BRA 02B2
.................... {
.................... setup_timer_0(RTCC_INTERNAL | RTCC_DIV_2 | RTCC_8_BIT);
02A6: MOVLW C0
02A8: MOVWF FD5
.................... set_timer0(0);
02AA: CLRF FD7
02AC: CLRF FD6
.................... enable_interrupts(INT_TIMER0);
02AE: BSF FF2.5
....................
....................
.................... }
.................... else
02B0: BRA 02B4
.................... {
.................... disable_interrupts(INT_TIMER0);
02B2: BCF FF2.5
....................
.................... }
.................... }
02B4: RETLW 00
....................
.................... void Configura_Timer1(int1 estado)
.................... {
.................... if(estado == 1)
02B6: DECFSZ 20,W
02B8: BRA 02CA
.................... {
.................... setup_timer_1(T1_INTERNAL | T1_DIV_BY_2);
02BA: MOVLW 95
02BC: MOVWF FCD
.................... set_timer1(43035);
02BE: MOVLW A8
02C0: MOVWF FCF
02C2: MOVLW 1B
02C4: MOVWF FCE
.................... enable_interrupts(INT_TIMER1);
02C6: BSF F9D.0
....................
.................... }
....................
.................... else
02C8: BRA 02CC
.................... {
.................... disable_interrupts(INT_TIMER1);
02CA: BCF F9D.0
.................... }
.................... }
02CC: GOTO 11DC (RETURN)
....................
.................... void Habilita_Motores(int1 estado)
.................... {
.................... if(estado == ON)
*
023C: DECFSZ 20,W
023E: BRA 026E
.................... {
.................... setup_power_pwm_pins(PWM_BOTH_ON,PWM_BOTH_ON,PWM_BOTH_ON,PWM_BOTH_ON); // Configura os 4 módulos PWM.
0240: MOVLW 5F
0242: MOVWF F6F
.................... setup_power_pwm(PWM_FREE_RUN, 1, 0, POWER_PWM_PERIOD, 0, 1,33);
0244: MOVLW FF
0246: MOVWF F6B
0248: CLRF F6E
024A: CLRF F7F
024C: MOVLW 80
024E: MOVWF F7E
0250: MOVLW 21
0252: MOVWF F6D
0254: CLRF F7D
0256: CLRF F7C
0258: MOVLW 37
025A: MOVWF F7B
025C: MOVLW 01
025E: MOVWF F7A
0260: CLRF F71
0262: CLRF F70
....................
.................... if(ENA_state)
.................... {
.................... output_high(motor_esquerda); //Manda sinal para habilitar a ponteH do motor 1.
0264: BCF F93.6
0266: BSF F8A.6
.................... }
.................... else
.................... {
.................... output_low(motor_esquerda); //Manda sinal para desabilitar a ponteH do motor 1.
.................... }
....................
.................... if(ENB_state)
.................... {
.................... output_high(motor_direita); //Manda sinal para habilitar a ponteH do motor 2.
0268: BCF F93.7
026A: BSF F8A.7
.................... }
.................... else
.................... {
.................... output_low(motor_direita); //Manda sinal para desabilitar a ponteH do motor 2
.................... }
.................... }
....................
.................... else
026C: BRA 0278
.................... {
.................... setup_power_pwm_pins(PWM_OFF, PWM_OFF, PWM_OFF, PWM_OFF);
026E: CLRF F6F
.................... output_low(motor_esquerda);
0270: BCF F93.6
0272: BCF F8A.6
.................... output_low(motor_direita);
0274: BCF F93.7
0276: BCF F8A.7
.................... }
.................... }
0278: GOTO 11CC (RETURN)
....................
.................... void Portas_IO()
.................... {
....................
.................... /*set_tris_x(0bRX7 RX6 RX5 RX4 RX3 RX2 RX1 RX0);*/
.................... /*Pinos não utilizados serão setados como saída*/
....................
.................... set_tris_a(0b11111111);
*
0220: MOVLW FF
0222: MOVWF F92
.................... set_tris_b(0b00000000); //todos são saída, mas e os pinos de gravação (PGC E PGD) ?
0224: MOVLW 00
0226: MOVWF F93
.................... set_tris_c(0b10000110); //pinos RC3 e RC5 não são utilizados
0228: MOVLW 86
022A: MOVWF F94
.................... set_tris_d(0b00000000);
022C: MOVLW 00
022E: MOVWF F95
.................... set_tris_e(0b1111);
0230: BSF F96.1
0232: BSF F96.1
0234: BSF F96.1
0236: BSF F96.1
.................... }
0238: GOTO 11C4 (RETURN)
....................
.................... void Configura_AD()
.................... {
.................... setup_adc_ports(ALL_ANALOG);
*
027C: BSF FB9.0
027E: BCF FC1.6
0280: BCF FC1.7
0282: MOVLW FF
0284: MOVWF FB8
.................... setup_adc(ADC_CLOCK_INTERNAL);
0286: ANDLW 00
0288: MOVWF F9A
028A: MOVF FC0,W
028C: ANDLW 80
028E: IORLW 07
0290: MOVWF FC0
0292: BCF FC2.2
0294: BCF FC2.3
0296: BCF FC2.4
0298: BCF FC2.5
029A: BSF FC0.7
029C: BSF FC2.0
.................... }
029E: GOTO 11D0 (RETURN)
....................
.................... void Motor_esq(int16 duty_esq, char sentido_esq)
.................... {
.................... switch(sentido_esq)
.................... {
*
06F6: MOVF 28,W
06F8: XORLW 66
06FA: BZ 0708
06FC: XORLW 04
06FE: BZ 077C
0700: XORLW 12
0702: BTFSC FD8.2
0704: BRA 07F0
0706: BRA 0800
.................... case 'f': set_power_pwm0_duty((int16)((POWER_PWM_PERIOD *4) * (duty_esq*0.01)));
0708: MOVFF 27,2A
070C: MOVFF 26,29
0710: RCALL 0596
0712: MOVFF 03,2C
0716: MOVFF 02,2B
071A: MOVFF 01,2A
071E: MOVFF 00,29
0722: MOVLW 0A
0724: MOVWF 30
0726: MOVLW D7
0728: MOVWF 2F
072A: MOVLW 23
072C: MOVWF 2E
072E: MOVLW 78
0730: MOVWF 2D
0732: RCALL 05CC
0734: CLRF 2C
0736: MOVLW 80
0738: MOVWF 2B
073A: MOVLW 1B
073C: MOVWF 2A
073E: MOVLW 89
0740: MOVWF 29
0742: MOVFF 03,30
0746: MOVFF 02,2F
074A: MOVFF 01,2E
074E: MOVFF 00,2D
0752: RCALL 05CC
0754: MOVFF 03,2C
0758: MOVFF 02,2B
075C: MOVFF 01,2A
0760: MOVFF 00,29
0764: RCALL 06BE
0766: BSF F6E.1
0768: MOVFF 01,F79
076C: MOVFF 02,F78
0770: BCF F6E.1
.................... set_power_pwm2_duty((int16)(0));
0772: BSF F6E.1
0774: CLRF F77
0776: CLRF F76
0778: BCF F6E.1
.................... break;
077A: BRA 0800
.................... case 'b': set_power_pwm0_duty((int16)(0));
077C: BSF F6E.1
077E: CLRF F79
0780: CLRF F78
0782: BCF F6E.1
.................... set_power_pwm2_duty((int16)((POWER_PWM_PERIOD *4) * (duty_esq*0.01)));
0784: MOVFF 27,2A
0788: MOVFF 26,29
078C: RCALL 0596
078E: MOVFF 03,2C
0792: MOVFF 02,2B
0796: MOVFF 01,2A
079A: MOVFF 00,29
079E: MOVLW 0A
07A0: MOVWF 30
07A2: MOVLW D7
07A4: MOVWF 2F
07A6: MOVLW 23
07A8: MOVWF 2E
07AA: MOVLW 78
07AC: MOVWF 2D
07AE: RCALL 05CC
07B0: CLRF 2C
07B2: MOVLW 80
07B4: MOVWF 2B
07B6: MOVLW 1B
07B8: MOVWF 2A
07BA: MOVLW 89
07BC: MOVWF 29
07BE: MOVFF 03,30
07C2: MOVFF 02,2F
07C6: MOVFF 01,2E
07CA: MOVFF 00,2D
07CE: RCALL 05CC
07D0: MOVFF 03,2C
07D4: MOVFF 02,2B
07D8: MOVFF 01,2A
07DC: MOVFF 00,29
07E0: RCALL 06BE
07E2: BSF F6E.1
07E4: MOVFF 01,F77
07E8: MOVFF 02,F76
07EC: BCF F6E.1
.................... break;
07EE: BRA 0800
.................... case 'p': set_power_pwm0_duty((int16)(0));
07F0: BSF F6E.1
07F2: CLRF F79
07F4: CLRF F78
07F6: BCF F6E.1
.................... set_power_pwm2_duty((int16)(0));
07F8: BSF F6E.1
07FA: CLRF F77
07FC: CLRF F76
07FE: BCF F6E.1
.................... }
.................... }
0800: RETLW 00
....................
.................... void Motor_dir(int16 duty_dir, char sentido_dir)
.................... {
.................... switch(sentido_dir)
.................... {
0802: MOVF 28,W
0804: XORLW 62
0806: BZ 0814
0808: XORLW 04
080A: BZ 0888
080C: XORLW 16
080E: BTFSC FD8.2
0810: BRA 08FC
0812: BRA 090C
.................... case 'b': set_power_pwm4_duty((int16)((POWER_PWM_PERIOD *4) * (duty_dir*0.01)));
0814: MOVFF 27,2A
0818: MOVFF 26,29
081C: RCALL 0596
081E: MOVFF 03,2C
0822: MOVFF 02,2B
0826: MOVFF 01,2A
082A: MOVFF 00,29
082E: MOVLW 0A
0830: MOVWF 30
0832: MOVLW D7
0834: MOVWF 2F
0836: MOVLW 23
0838: MOVWF 2E
083A: MOVLW 78
083C: MOVWF 2D
083E: RCALL 05CC
0840: CLRF 2C
0842: MOVLW 80
0844: MOVWF 2B
0846: MOVLW 1B
0848: MOVWF 2A
084A: MOVLW 89
084C: MOVWF 29
084E: MOVFF 03,30
0852: MOVFF 02,2F
0856: MOVFF 01,2E
085A: MOVFF 00,2D
085E: RCALL 05CC
0860: MOVFF 03,2C
0864: MOVFF 02,2B
0868: MOVFF 01,2A
086C: MOVFF 00,29
0870: RCALL 06BE
0872: BSF F6E.1
0874: MOVFF 01,F75
0878: MOVFF 02,F74
087C: BCF F6E.1
.................... set_power_pwm6_duty((int16)(0));
087E: BSF F6E.1
0880: CLRF F73
0882: CLRF F72
0884: BCF F6E.1
.................... break;
0886: BRA 090C
.................... case 'f': set_power_pwm4_duty((int16)(0));
0888: BSF F6E.1
088A: CLRF F75
088C: CLRF F74
088E: BCF F6E.1
.................... set_power_pwm6_duty((int16)((POWER_PWM_PERIOD *4) * (duty_dir*0.01)));
0890: MOVFF 27,2A
0894: MOVFF 26,29
0898: RCALL 0596
089A: MOVFF 03,2C
089E: MOVFF 02,2B
08A2: MOVFF 01,2A
08A6: MOVFF 00,29
08AA: MOVLW 0A
08AC: MOVWF 30
08AE: MOVLW D7
08B0: MOVWF 2F
08B2: MOVLW 23
08B4: MOVWF 2E
08B6: MOVLW 78
08B8: MOVWF 2D
08BA: RCALL 05CC
08BC: CLRF 2C
08BE: MOVLW 80
08C0: MOVWF 2B
08C2: MOVLW 1B
08C4: MOVWF 2A
08C6: MOVLW 89
08C8: MOVWF 29
08CA: MOVFF 03,30
08CE: MOVFF 02,2F
08D2: MOVFF 01,2E
08D6: MOVFF 00,2D
08DA: RCALL 05CC
08DC: MOVFF 03,2C
08E0: MOVFF 02,2B
08E4: MOVFF 01,2A
08E8: MOVFF 00,29
08EC: RCALL 06BE
08EE: BSF F6E.1
08F0: MOVFF 01,F73
08F4: MOVFF 02,F72
08F8: BCF F6E.1
.................... break;
08FA: BRA 090C
.................... case 'p': set_power_pwm4_duty((int16)(0));
08FC: BSF F6E.1
08FE: CLRF F75
0900: CLRF F74
0902: BCF F6E.1
.................... set_power_pwm6_duty((int16)(0));
0904: BSF F6E.1
0906: CLRF F73
0908: CLRF F72
090A: BCF F6E.1
.................... }
.................... }
090C: RETLW 00
....................
.................... void MoverMotores(int16 duty_esquerda, int16 duty_direita, char sentido)
.................... {
.................... switch(sentido)
.................... {
090E: MOVF 25,W
0910: XORLW 66
0912: BZ 0926
0914: XORLW 04
0916: BZ 0944
0918: XORLW 03
091A: BZ 0962
091C: XORLW 09
091E: BZ 0980
0920: XORLW 18
0922: BZ 099E
0924: BRA 09B4
.................... case 'f':
.................... Motor_esq(duty_esquerda, 'f');
0926: MOVFF 22,27
092A: MOVFF 21,26
092E: MOVLW 66
0930: MOVWF 28
0932: RCALL 06F6
.................... Motor_dir(duty_direita, 'f');
0934: MOVFF 24,27
0938: MOVFF 23,26
093C: MOVLW 66
093E: MOVWF 28
0940: RCALL 0802
.................... break;
0942: BRA 09C8
....................
.................... case 'b':
.................... Motor_esq(duty_esquerda, 'b');
0944: MOVFF 22,27
0948: MOVFF 21,26
094C: MOVLW 62
094E: MOVWF 28
0950: RCALL 06F6
.................... Motor_dir(duty_direita, 'b');
0952: MOVFF 24,27
0956: MOVFF 23,26
095A: MOVLW 62
095C: MOVWF 28
095E: RCALL 0802
.................... break;
0960: BRA 09C8
....................
.................... case 'a': /*arbitrario*/
.................... Motor_esq(duty_esquerda,'b');
0962: MOVFF 22,27
0966: MOVFF 21,26
096A: MOVLW 62
096C: MOVWF 28
096E: RCALL 06F6
.................... Motor_dir(duty_direita,'f');
0970: MOVFF 24,27
0974: MOVFF 23,26
0978: MOVLW 66
097A: MOVWF 28
097C: RCALL 0802
.................... break;
097E: BRA 09C8
....................
.................... case 'h': /*arbitrario*/
.................... Motor_esq(duty_esquerda,'f');
0980: MOVFF 22,27
0984: MOVFF 21,26
0988: MOVLW 66
098A: MOVWF 28
098C: RCALL 06F6
.................... Motor_dir(duty_direita,'b');
098E: MOVFF 24,27
0992: MOVFF 23,26
0996: MOVLW 62
0998: MOVWF 28
099A: RCALL 0802
.................... break;
099C: BRA 09C8
....................
.................... case 'p':
.................... Motor_dir(0,'p');
099E: CLRF 27
09A0: CLRF 26
09A2: MOVLW 70
09A4: MOVWF 28
09A6: RCALL 0802
.................... Motor_esq(0,'p');
09A8: CLRF 27
09AA: CLRF 26
09AC: MOVLW 70
09AE: MOVWF 28
09B0: RCALL 06F6
.................... break;
09B2: BRA 09C8
....................
.................... default:
.................... Motor_dir(0,'p');
09B4: CLRF 27
09B6: CLRF 26
09B8: MOVLW 70
09BA: MOVWF 28
09BC: RCALL 0802
.................... Motor_esq(0,'p');
09BE: CLRF 27
09C0: CLRF 26
09C2: MOVLW 70
09C4: MOVWF 28
09C6: RCALL 06F6
.................... }
....................
.................... }
09C8: RETLW 00
....................
.................... int1 Leitura(int16 threshold, int8 canal)
.................... {
*
0318: CLRF 27
031A: CLRF 26
.................... int16 leitura = 0;
.................... switch(canal)
.................... {
031C: MOVF 25,W
031E: ADDLW F9
0320: BC 0354
0322: ADDLW 07
0324: GOTO 03C4
.................... case 5: set_adc_channel(linha_direita); break;
0328: MOVLW 10
032A: MOVWF F99
032C: MOVLW 05
032E: MOVWF FC2
0330: BRA 0354
.................... case 6 :set_adc_channel(linha_esquerda); break;
0332: MOVLW 04
0334: MOVWF F99
0336: MOVLW 09
0338: MOVWF FC2
033A: BRA 0354
.................... case 0: set_adc_channel(distancia_direita); break;
033C: CLRF F99
033E: MOVLW 01
0340: MOVWF FC2
0342: BRA 0354
.................... case 3: set_adc_channel(distancia_esquerda); break;
0344: CLRF F99
0346: MOVLW 0D
0348: MOVWF FC2
034A: BRA 0354
.................... case 2: set_adc_channel(distancia_central); break;
034C: CLRF F99
034E: MOVLW 09
0350: MOVWF FC2
0352: BRA 0354
.................... //default: leitura = 0;
.................... }
....................
.................... delay_us(10);
0354: MOVLW 10
0356: MOVWF 00
0358: DECFSZ 00,F
035A: BRA 0358
035C: NOP
.................... leitura = read_adc();
035E: BSF FC2.1
0360: BTFSC FC2.1
0362: BRA 0360
0364: MOVFF FC3,26
0368: MOVFF FC4,27
....................
.................... if(canal == 5 || canal == 6) /*Sensores de linha*/
036C: MOVF 25,W
036E: SUBLW 05
0370: BZ 0378
0372: MOVF 25,W
0374: SUBLW 06
0376: BNZ 0396
.................... {
.................... if(leitura < threshold)
0378: MOVF 27,W
037A: SUBWF 24,W
037C: BNC 038E
037E: BNZ 0386
0380: MOVF 23,W
0382: SUBWF 26,W
0384: BC 038E
.................... {
.................... return 1;
0386: MOVLW 01
0388: MOVWF 01
038A: BRA 03C2
.................... }
....................
.................... else
038C: BRA 0394
.................... {
.................... return 0;
038E: MOVLW 00
0390: MOVWF 01
0392: BRA 03C2
.................... }
.................... }
....................
.................... else if(canal == 0 || canal == 2 || canal == 3) /*Sensores de distância*/
0394: BRA 03C2
0396: MOVF 25,F
0398: BZ 03A6
039A: MOVF 25,W
039C: SUBLW 02
039E: BZ 03A6
03A0: MOVF 25,W
03A2: SUBLW 03
03A4: BNZ 03C2
.................... {
.................... if(leitura < threshold)
03A6: MOVF 27,W
03A8: SUBWF 24,W
03AA: BNC 03BC
03AC: BNZ 03B4
03AE: MOVF 23,W
03B0: SUBWF 26,W
03B2: BC 03BC
.................... {
.................... return 1;
03B4: MOVLW 01
03B6: MOVWF 01
03B8: BRA 03C2
.................... }
....................
.................... else
03BA: BRA 03C2
.................... {
.................... return 0;
03BC: MOVLW 00
03BE: MOVWF 01
03C0: BRA 03C2
.................... }
.................... }
.................... }
03C2: RETLW 00
....................
.................... int8 Seta_Sensores(char tipo)
.................... {
.................... int i;
.................... switch(tipo)
.................... {
*
03F6: MOVF 21,W
03F8: XORLW 6C
03FA: BZ 0408
03FC: XORLW 08
03FE: BZ 0464
0400: XORLW 05
0402: BTFSC FD8.2
0404: BRA 04DE
0406: BRA 056A
....................
.................... case 'l': /*apenas sensores de linha ligados*/
....................
.................... if(Leitura(limiar_linha,linha_esquerda))
0408: MOVLW 03
040A: MOVWF 24
040C: MOVLW 20
040E: MOVWF 23
0410: MOVLW 06
0412: MOVWF 25
0414: RCALL 0318
0416: MOVF 01,F
0418: BZ 041E
.................... {
.................... bit_set(sensores,4);
041A: BSF 17.4
.................... }
....................
.................... else
041C: BRA 0420
.................... {
.................... bit_clear(sensores,4);
041E: BCF 17.4
.................... }
....................
.................... if(Leitura(limiar_linha,linha_direita))
0420: MOVLW 03
0422: MOVWF 24
0424: MOVLW 20
0426: MOVWF 23
0428: MOVLW 05
042A: MOVWF 25
042C: RCALL 0318
042E: MOVF 01,F
0430: BZ 0436
.................... {
.................... bit_set(sensores,3);
0432: BSF 17.3
.................... }
....................
.................... else
0434: BRA 0438
.................... {
.................... bit_clear(sensores,3);
0436: BCF 17.3
.................... }
....................
.................... for(i = 0; i < 3; i++) //zera os 3 bits dos sensores de ditância
0438: CLRF 22
043A: MOVF 22,W
043C: SUBLW 02
043E: BNC 045C
.................... {
.................... bit_clear(sensores,i);
0440: MOVLW 01
0442: MOVWF 00
0444: MOVF 22,W
0446: MOVWF 01
0448: BZ 0452
044A: BCF FD8.0
044C: RLCF 00,F
044E: DECFSZ 01,F
0450: BRA 044A
0452: MOVF 00,W
0454: XORLW FF
0456: ANDWF 17,F
.................... }
0458: INCF 22,F
045A: BRA 043A
.................... return sensores;
045C: MOVFF 17,01
0460: BRA 0594
.................... break;
0462: BRA 0594
....................
.................... case 'd': /*apenas sensores de ditância ligados*/
....................
.................... if(Leitura(limiar_distancia,distancia_esquerda))
0464: MOVLW 01
0466: MOVWF 24
0468: MOVLW D6
046A: MOVWF 23
046C: MOVLW 03
046E: MOVWF 25
0470: RCALL 0318
0472: MOVF 01,F
0474: BZ 047A
.................... {
.................... bit_set(sensores,2);
0476: BSF 17.2
.................... }
....................
.................... else
0478: BRA 047C
.................... {
.................... bit_clear(sensores,2);
047A: BCF 17.2
.................... }
....................
.................... if(Leitura(limiar_distancia,distancia_central))
047C: MOVLW 01
047E: MOVWF 24
0480: MOVLW D6
0482: MOVWF 23
0484: MOVLW 02
0486: MOVWF 25
0488: RCALL 0318
048A: MOVF 01,F
048C: BZ 0492
.................... {
.................... bit_set(sensores,1);
048E: BSF 17.1
.................... }
....................
.................... else
0490: BRA 0494
.................... {
.................... bit_clear(sensores,1);
0492: BCF 17.1
.................... }
....................
.................... if(Leitura(limiar_distancia,distancia_direita))
0494: MOVLW 01
0496: MOVWF 24
0498: MOVLW D6
049A: MOVWF 23
049C: CLRF 25
049E: RCALL 0318
04A0: MOVF 01,F
04A2: BZ 04A8
.................... {
.................... bit_set(sensores,0);
04A4: BSF 17.0
.................... }
....................
.................... else
04A6: BRA 04AA
.................... {
.................... bit_clear(sensores,0);
04A8: BCF 17.0
.................... }
.................... for(i =3; i >= 3 && i <5; i++)
04AA: MOVLW 03
04AC: MOVWF 22
04AE: MOVF 22,W
04B0: SUBLW 02
04B2: BC 04D6
04B4: MOVF 22,W
04B6: SUBLW 04
04B8: BNC 04D6
.................... {
.................... bit_clear(sensores,i);
04BA: MOVLW 01
04BC: MOVWF 00
04BE: MOVF 22,W
04C0: MOVWF 01
04C2: BZ 04CC
04C4: BCF FD8.0
04C6: RLCF 00,F
04C8: DECFSZ 01,F
04CA: BRA 04C4
04CC: MOVF 00,W
04CE: XORLW FF
04D0: ANDWF 17,F
.................... }
04D2: INCF 22,F
04D4: BRA 04AE
.................... return sensores;
04D6: MOVFF 17,01
04DA: BRA 0594
.................... break;
04DC: BRA 0594
....................
....................
.................... case 'a': /*todos os sensores ligados*/
....................
.................... if(Leitura(limiar_linha,linha_esquerda))
04DE: MOVLW 03
04E0: MOVWF 24
04E2: MOVLW 20
04E4: MOVWF 23
04E6: MOVLW 06
04E8: MOVWF 25
04EA: RCALL 0318
04EC: MOVF 01,F