Subversion Repositories svnkaklik

Compare Revisions

No changes between revisions

Regard whitespace Rev 134 → Rev 135

/roboti/istrobot/laserus/3Orbis/macro.ini
--- roboti/istrobot/laserus/3Orbis/main.BAK (nonexistent)
+++ roboti/istrobot/laserus/3Orbis/main.BAK (revision 135)
@@ -0,0 +1,288 @@
+#include ".\main.h"
+
+#define KOLMO1 225 // predni kolecko sroubem dopredu
+#define KOLMO2 30 // predni kolecko je hlavou sroubu dozadu
+#define STRED 128 // sredni poloha zataceciho kolecka
+#define BEAR1 10//10 // 3 stupne zataceni
+#define BEAR2 25//25
+#define BEAR3 45//45
+#define R 100 // Rozumna rychlost
+#define R17 200 // X nasobek rozumne rychlosti
+#define PRED_CIHLOU 100 // rychlost pri dalkove detekci cihly
+//#define L1 1 // cara vlevo
+#define L2 2 // cara vlevo
+#define L3 3 // cara vlevo
+#define S 0 // cara mezi sensory
+//#define R1 -1 // cara vpravo
+#define R2 -2 // cara vpravo
+#define R3 -3 // cara vpravo
+
+// servo
+#define SERVO PIN_B5
+
+// kroutitka
+#define CERVENA 4 // AN4
+//#define CERNA 5 // AN5
+//#define ZELENA 6 // AN6
+#define MODRA 2 // AN2
+
+// IR
+#define IRTX PIN_B2
+#define CIHLA PIN_A3
+
+//motory
+#define FR output_low(PIN_A7); output_high(PIN_A6) // Vpred
+#define FL output_low(PIN_A1); output_high(PIN_A0)
+#define BR output_low(PIN_A6); output_high(PIN_A7) // Vzad
+#define BL output_low(PIN_A0); output_high(PIN_A1)
+#define STOPR output_low(PIN_A6);output_low(PIN_A7)
+#define STOPL output_low(PIN_A0);output_low(PIN_A1)
+
+//HID
+#define LED1 PIN_B1 //oranzova
+#define LED2 PIN_B2 //zluta
+
+#define STROBE PIN_B0
+//#define SW1 PIN_A2 // Motory On/off
+
+unsigned int8 sensors; // pomocna promenna pro cteni cidel na caru
+signed int8 line = S; // na ktere strane byla detekovana cara
+//unsigned int8 dira; // pocita dobu po kterou je ztracena cara
+unsigned int8 uhel; // urcuje aktualni uhel zataceni
+unsigned int8 speed; // maximalni povolena rychlost
+unsigned int8 turn; // rychlost toceni
+unsigned int8 rovinka; // pocitadlo na zjisteni rovinky
+
+signed int16 Lmotor; // promene, ktere urcuji velikost vykonu na levem
+signed int16 Rmotor; // a pravem motoru
+
+// makro pro PWM pro motory
+#define GO(motor, direction, power) if(get_timer0()<=power) \
+{direction##motor;} else {stop##motor;}
+////////////////////////////////////////////////////////////////////////////////
+#int_TIMER2
+TIMER2_isr() // ovladani serva
+{
+ unsigned int8 n;
+
+ output_high(SERVO);
+ delay_us(1000);
+ for(n=uhel; n>0; n--) Delay_us(2);
+ output_low(SERVO);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int8 IRcheck() // potvrdi detekci cihly
+{
+ output_high(IRTX); // vypne vysilac IR
+ delay_ms(10);
+
+ output_low(STROBE);
+ sensors = spi_read(0); // cteni senzoru
+ sensors=~sensors;
+ output_high(STROBE);
+
+ if(bit_test(sensors,7)) // otestuje, jestli je stale detekovan IR signal
+ {
+ output_low(IRTX); // zapne vysilac IR
+ delay_ms(10);
+
+ output_low(STROBE);
+ sensors = spi_read(0); // cteni senzoru
+ sensors=~sensors;
+ output_high(STROBE);
+
+ if(!bit_test(sensors,7)) // otestuje, jestli je detekovana cihla
+ {
+ output_high(IRTX); // vypne vysilac IR
+ delay_ms(10);
+
+ output_low(STROBE);
+ sensors = spi_read(0); // cteni senzoru
+ sensors=~sensors;
+ output_high(STROBE);
+
+ output_low(IRTX); // zapne vysilac IR
+
+ if(bit_test(sensors,7)) return 1; // vrat 1, kdyz je stale cihla
+ }
+ };
+ output_low(IRTX); // zapne vysilac IR
+ return 0; // vrat 0, kdyz je detekovano ruseni
+}
+////////////////////////////////////////////////////////////////////////////////
+#include ".\objizdka_centrovani.c"
+////////////////////////////////////////////////////////////////////////////////
+void main()
+{
+
+ unsigned int8 n;
+ unsigned int8 i,j;
+ unsigned int8 last_sensors;
+ unsigned int8 RozumnaRychlost;
+
+ setup_adc_ports(sAN5|sAN2|sAN4|sAN6|VSS_VDD); // AD pro kroutitka
+ setup_adc(ADC_CLOCK_INTERNAL);
+ setup_spi(SPI_MASTER|SPI_H_TO_L|SPI_XMIT_L_TO_H|SPI_CLK_DIV_16);
+ setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
+ setup_timer_1(T1_DISABLED|T1_DIV_BY_8);
+ setup_timer_2(T2_DIV_BY_16,140,16);
+ setup_oscillator(OSC_8MHZ|OSC_INTRC);
+
+ STOPR; STOPL; // zastav motory
+ Lmotor=0;Rmotor=0;
+
+ uhel = STRED; // nastav zadni kolecko na stred
+ rovinka = 0;
+
+ enable_interrupts(INT_TIMER2);
+ enable_interrupts(GLOBAL);
+
+ output_low(IRTX); // zapni IR vysilac
+
+ delay_ms(2000); // musime pockat na diagnostiku slave CPU
+
+ //nastaveni rychlosti
+ set_adc_channel(CERVENA);
+
+ Delay_ms(1);
+ RozumnaRychlost=R+(read_adc()>>2); // rychlost rovne +63; kroutitko dava 0-63
+ set_adc_channel(MODRA);
+ Delay_ms(1);
+ turn=speed-32+(read_adc()>>2); // rychlost toceni +-32; kroutitko dava 0-63
+
+ speed=R17;
+
+ while(true)
+ {
+
+ GO(L,F,Lmotor);GO(R,F,Rmotor); // zapni motory PWM podle promenych Lmotor a Rmotor
+
+ delay_us(2000); // cekani na SLAVE, nez pripravi data od cidel
+
+ last_sensors=sensors;
+
+ output_low(STROBE); // vypni zobrazovani na posuvnem registru
+ sensors = spi_read(0); // cteni senzoru
+ sensors=~sensors; // neguj prijata data
+ output_high(STROBE); // zobraz data na posuvnem registru
+
+ i=0; // havarijni kod
+ for (n=0; n<=6; n++)
+ {
+ if(bit_test(sensors,n)) i++;
+ }
+ if (i>4) // zastavi, kdyz je cerno pod vice nez tremi cidly
+ {
+ BL; BR;
+ delay_ms(300);
+ STOPR; STOPL;
+ While(true);
+ };
+
+/*
+ if (!input(CIHLA)) // dalkova detekce cihly
+ {
+ speed=PRED_CIHLOU;
+ }
+ else
+ {
+ speed=RozumnaRychlost;
+ }
+*/
+ if (bit_test(sensors,7)) // detekce cihly
+ {
+ BR;BL;
+ Delay_ms(400);
+ STOPR;STOPL;
+// if (1==IRcheck()) // kontrola, jestli nebylo rusene cidlo
+ {
+ Delay_ms(100);
+ cikcak();
+ delay_ms(100);
+ objizdka(); // objede cihlu
+ }
+ }
+
+ if (speed > RozumnaRychlost) speed--; // postupne zpomaleni na Roz. Rychl.
+
+ if(bit_test(sensors,3)) //...|...//
+ {
+ uhel=STRED;
+ Lmotor=speed;
+ Rmotor=speed;
+ line=S;
+ if (rovinka < 255) rovinka++;
+ continue;
+ }
+
+ if(bit_test(sensors,0)) //|......// // z duvodu zkraceni doby reakce se cidla nevyhodnocuji poporade ale od krajnich k prostrednimu
+ {
+ uhel=STRED - BEAR3;
+ Lmotor=0;
+ Rmotor=turn;
+ line=L3;
+ continue;
+ }
+
+ if(bit_test(sensors,6)) //......|//
+ {
+ uhel=STRED + BEAR3;
+ Rmotor=0;
+ Lmotor=turn;
+ line=R3;
+ continue;
+ }
+
+ if(bit_test(sensors,1)) //.|.....//
+ {
+ uhel=STRED - BEAR2;
+ Lmotor=speed-70;
+ Rmotor=speed;
+ line=L2;
+ continue;
+ }
+
+ if(bit_test(sensors,5)) //.....|.//
+ {
+ uhel=STRED + BEAR2;
+ Rmotor=speed-70;
+ Lmotor=speed;
+ line=R2;
+ continue;
+ }
+
+ if (bit_test(sensors,2)) //..|....//
+ {
+ uhel=STRED - BEAR1;
+ Lmotor=speed-20;
+ Rmotor=speed;
+ line=L2;
+ if (rovinka<255) rovinka++;
+ continue;
+ }
+
+ if (bit_test(sensors,4)) //....|..//
+ {
+ uhel=STRED + BEAR1;
+ Rmotor=speed-20;
+ Lmotor=speed;
+ line=L2;
+ if (rovinka<255) rovinka++;
+ continue;
+ }
+
+
+ if ((L3==line) || (R3==line)) // Brzdeni pri vyjeti z trate
+ {
+ if (rovinka>50)
+ {
+ BL; BR;
+ Delay_ms(100);
+ if (rovinka > 250 || speed > 170) delay_ms(50);
+ };
+ rovinka=0;
+ speed=R17;
+ };
+ }
+}
/roboti/istrobot/laserus/3Orbis/main.HEX
0,0 → 1,148
:1000000000308A006C2A0000FF00030E8301A1006B
:100010007F08A0000A08A8008A01A00E0408A20018
:100020007708A3007808A4007908A5007A08A6003C
:100030007B08A700831383128C308400801C222845
:100040008C183528220884002308F7002408F800BB
:100050002508F9002608FA002708FB0028088A006E
:10006000210E8300FF0E7F0E09008A1147280830F9
:10007000BD02031C46283D3084000310800C00089C
:100080000319462844286400800B43280034831653
:1000900086128312861664000930BC006D30BD00E4
:1000A0003720BC0B4E282C08BB00BB0803195E2868
:1000B0006400000000000000BB0355288316861270
:1000C000831286128C108A1122283A30840000088C
:1000D00003197C280230F800BF30F7006400F70BEA
:1000E0006E28F80B6C289630F700F70B7528000087
:1000F00000006400800B6A280034B901E130AC00D4
:100100006430BA0065202B08023C031D89280330A7
:10011000AB00AB08031D8E280330AB002B08FE3C60
:10012000031D9428FD30AB000330BA006520831610
:100130000610831206101308930183161418A228C0
:1001400083129D2883121308AA00AA098316061099
:10015000831206140330BA0065202B08033C031DEC
:10016000DB280108A03C031CBE288316051083125F
:1001700005108316851083128514C6288316051072
:100180008312051083168510831285100108A03C88
:10019000031CD32883168513831285138316051336
:1001A00083120517DB2883160513831205138316A4
:1001B0008513831285132B08FD3C031D09290108B3
:1001C000A03C031CEC288316051383120513831629
:1001D000851383128517F4288316051383120513DC
:1001E00083168513831285130108A03C031C012983
:1001F000831685108312851083160510831205144B
:1002000009298316051083120510831685108312A1
:100210008510AB08031D1E298316051083120510D7
:100220008316851083128510831605138312051318
:100230008316851383128513B90A1F29B90139085A
:10024000633C031C592983160610831206101308F9
:100250009301831614182E29831229298312130857
:10026000AA00AA098316061083120614AA1D3A29A9
:10027000AB01AA282A1C3F290330AB00AA282A1F59
:100280004429FD30AB00AA28AA1C49290330AB0041
:10029000AA28AA1E4E29FD30AB00AA282A1D5329E0
:1002A0000330AB00AA282A1E5829FD30AB00AA282B
:1002B000AA28003483168510831285108316051032
:1002C00083120514831605138312051383168513F1
:1002D000831285170230B9009630BA006520B90B39
:1002E0006C2983160510831205108316851083125E
:1002F00085148316851383128513831605138312C1
:1003000005176430BA0065208316051083120510A6
:100310008316851083128510831605138312051327
:1003200083168513831285138030AC0083168510E5
:100330008312851083160510831205148316851306
:100340008312851383160513831205170230B90033
:10035000BE30BA006520B90BA8294930AC0083161D
:1003600005108312051083168510831285108316DD
:100370008513831285138316051383120517BE3068
:10038000BA0065208030AC00831685138312851374
:1003900083160513831205178316851083128510A3
:1003A00083160510831205140230B9009630BA0086
:1003B0006520B90BD6294930AC008316851383120A
:1003C00085138316051383120517831605108312F0
:1003D00005108316851083128510BE30BA00652083
:1003E0008030AC00831685138312851383160513A2
:1003F0008312051783168510831285108316051046
:10040000831205146430BA0065202A08FE390319E6
:10041000182A1308930183161418102A83120B2A22
:1004200083121308AA00AA090330BA006520052A1E
:100430008316051083120510831685108312851408
:1004400083160513831205138316851383128517EC
:10045000FA30BA006520E130AC00831685108312B3
:100460008510831605108312051483160513831255
:10047000051383168513831285172A08FE3903197D
:10048000502A1308930183161418482A8312432A0A
:1004900083121308AA00AA090330BA0065203D2A76
:1004A000831605108312051083168510831285109C
:1004B0008316051383120513831685138312851380
:1004C0000230B9009630BA006520B90B622AFD30BF
:1004D000AB007D208A11CF2B84011F308305703043
:1004E00083168F001F129F121B0880399B00073054
:1004F0009C008312AB0183161F129F121B088039C8
:1005000074389B001F1383121F179F1783169F13A6
:1005100083121F14941283160611861406123130AA
:10052000831294000030831694000108C7390838FC
:1005300081003030831290007830F8000638920045
:100540008C308316920072308F00051383120513CE
:1005500083168513831285138316051083120510E5
:100560008316851083128510B101B001B301B20169
:100570008030AC00AF0183168C14C03083128B0422
:1005800083160611831206110830B900FA30BA003A
:100590006520B90BC62A2030F8001F08C739780437
:1005A0009F000130BA0065201F151F19D52A1E08AB
:1005B000F700F70CF70C3F30F7057708643EB800FA
:1005C0001030F8001F08C73978049F000130BA00C6
:1005D000652020302D02B9001F151F19ED2A1E08B5
:1005E000F700F70CF70C3F30F70577083907AE0036
:1005F000C830AD000108801F002BB11F082B022B53
:10060000B11B112BB108031D082B3002031C112B49
:100610008316851083128510831605108312051426
:10062000192B83160510831205108316851083126B
:1006300085100108801F1F2BB31F272B212BB31BF5
:10064000302BB308031D272B3202031C302B8316DB
:100650008513831285138316051383120517382B10
:1006600083160513831205138316851383128513CE
:1006700064000130BA0065200930B900A9018B1B64
:10068000A9178B136D30BD003720A91B8B17B90B31
:100690003E2B2A08B7008316061083120610130893
:1006A000930183161418562B8312512B83121308AF
:1006B000AA00AA098316061083120614B501B40114
:1006C0003408063C031C722B2A08F7003408F80093
:1006D00003196E2B0310F70CF80B6A2B7718B50A69
:1006E000B40A602B3508043C03189E2B83160510B2
:1006F0008312051083168510831285148316051343
:100700008312051383168513831285170230B900EF
:100710009630BA006520B90B882B83160513831217
:100720000513831685138312851383160510831210
:10073000051083168510831285109D2BAA1FCF2BC1
:1007400083160513831205138316851383128517E9
:1007500083160510831205108316851083128514E5
:100760000230B900C830BA006520B90BB22B83162D
:1007700005138312051383168513831285138316BD
:1007800005108312051083168510831285106430BE
:10079000BA0065207D206430BA0065205A292D08F2
:1007A0003802031CAD03AA1DE72B8030AC00FA0110
:1007B0002D08B0007A08B100FA012D08B2007A08BD
:1007C000B300AB012F0FE52BE62BAF0AFA2A2A1C48
:1007D000F52B5330AC00B101B001FA012E08B20084
:1007E0007A08B3000330AB00FA2A2A1F032CAD307D
:1007F000AC00B301B201FA012E08B0007A08B100D2
:10080000FD30AB00FA2AAA1C152C6730AC0046302C
:100810002D02FA01B0007A08B100FA012D08B200E9
:100820007A08B3000230AB00FA2AAA1E272C9930AE
:10083000AC0046302D02FA01B2007A08B300FA018A
:100840002D08B0007A08B100FE30AB00FA2A2A1D4C
:100850003D2C7630AC0014302D02FA01B0007A083D
:10086000B100FA012D08B2007A08B3000230AB00E3
:100870002F0F3B2C3C2CAF0AFA2A2A1E532C8A300D
:10088000AC0014302D02FA01B2007A08B300FA016C
:100890002D08B0007A08B1000230AB002F0F512CA8
:1008A000522CAF0AFA2A2B08033C03195B2C2B08A5
:1008B000FD3C031D802C2F08323C03187D2C831631
:1008C0000510831205108316851083128514831674
:1008D000051383120513831685138312851764305D
:1008E000BA0065202F08FA3C031C7A2C2D08AA3C7C
:1008F00003187D2C3230BA006520AF01C830AD003E
:04090000FA2A63006C
:04400E00383FFC3FFC
:00000001FF
;PIC16F88
/roboti/istrobot/laserus/3Orbis/main.LST
0,0 → 1,1625
CCS PCM C Compiler, Version 3.245, 27853 30-IV-06 21:17
 
Filename: D:\KAKLIK\programy\PIC_C\roboti\3Orbis\main.lst
 
ROM used: 1154 words (28%)
Largest free fragment is 2048
RAM used: 32 (18%) at main() level
35 (20%) worst case
Stack: 5 worst case (3 in main + 2 for interrupts)
 
*
0000: MOVLW 00
0001: MOVWF 0A
0002: GOTO 26C
0003: NOP
0004: MOVWF 7F
0005: SWAPF 03,W
0006: CLRF 03
0007: MOVWF 21
0008: MOVF 7F,W
0009: MOVWF 20
000A: MOVF 0A,W
000B: MOVWF 28
000C: CLRF 0A
000D: SWAPF 20,F
000E: MOVF 04,W
000F: MOVWF 22
0010: MOVF 77,W
0011: MOVWF 23
0012: MOVF 78,W
0013: MOVWF 24
0014: MOVF 79,W
0015: MOVWF 25
0016: MOVF 7A,W
0017: MOVWF 26
0018: MOVF 7B,W
0019: MOVWF 27
001A: BCF 03.7
001B: BCF 03.5
001C: MOVLW 8C
001D: MOVWF 04
001E: BTFSS 00.1
001F: GOTO 022
0020: BTFSC 0C.1
0021: GOTO 035
0022: MOVF 22,W
0023: MOVWF 04
0024: MOVF 23,W
0025: MOVWF 77
0026: MOVF 24,W
0027: MOVWF 78
0028: MOVF 25,W
0029: MOVWF 79
002A: MOVF 26,W
002B: MOVWF 7A
002C: MOVF 27,W
002D: MOVWF 7B
002E: MOVF 28,W
002F: MOVWF 0A
0030: SWAPF 21,W
0031: MOVWF 03
0032: SWAPF 7F,F
0033: SWAPF 7F,W
0034: RETFIE
0035: BCF 0A.3
0036: GOTO 047
.................... #include ".\main.h"
.................... #include <16F88.h>
.................... //////// Standard Header file for the PIC16F88 device ////////////////
.................... #device PIC16F88
.................... #list
....................
.................... #device adc=8
....................
.................... #FUSES NOWDT //No Watch Dog Timer
.................... #FUSES INTRC_IO
.................... #FUSES NOPUT //No Power Up Timer
.................... #FUSES MCLR //Master Clear pin enabled
.................... #FUSES NOBROWNOUT //Reset when brownout detected
.................... #FUSES NOLVP //Low Voltage Programming on B3(PIC16) or B5(PIC18)
.................... #FUSES NOCPD //No EE protection
.................... #FUSES NOWRT //Program memory not write protected
.................... #FUSES NODEBUG //No Debug mode for ICD
.................... #FUSES NOPROTECT //Code not protected from reading
.................... #FUSES NOFCMEN //Fail-safe clock monitor enabled
.................... #FUSES NOIESO //Internal External Switch Over mode enabled
....................
.................... #use delay(clock=8000000,RESTART_WDT)
0037: MOVLW 08
0038: SUBWF 3D,F
0039: BTFSS 03.0
003A: GOTO 046
003B: MOVLW 3D
003C: MOVWF 04
003D: BCF 03.0
003E: RRF 00,F
003F: MOVF 00,W
0040: BTFSC 03.2
0041: GOTO 046
0042: GOTO 044
0043: CLRWDT
0044: DECFSZ 00,F
0045: GOTO 043
0046: RETLW 00
*
0065: MOVLW 3A
0066: MOVWF 04
0067: MOVF 00,W
0068: BTFSC 03.2
0069: GOTO 07C
006A: MOVLW 02
006B: MOVWF 78
006C: MOVLW BF
006D: MOVWF 77
006E: CLRWDT
006F: DECFSZ 77,F
0070: GOTO 06E
0071: DECFSZ 78,F
0072: GOTO 06C
0073: MOVLW 96
0074: MOVWF 77
0075: DECFSZ 77,F
0076: GOTO 075
0077: NOP
0078: NOP
0079: CLRWDT
007A: DECFSZ 00,F
007B: GOTO 06A
007C: RETLW 00
....................
....................
....................
.................... #define KOLMO1 225 // predni kolecko sroubem dopredu
.................... #define KOLMO2 30 // predni kolecko je hlavou sroubu dozadu
.................... #define STRED 128 // sredni poloha zataceciho kolecka
.................... #define BEAR1 10//10 // 3 stupne zataceni
.................... #define BEAR2 25//25
.................... #define BEAR3 45//45
.................... #define R 100 // Rozumna rychlost
.................... #define R17 200 // X nasobek rozumne rychlosti
.................... #define PRED_CIHLOU 100 // rychlost pri dalkove detekci cihly
.................... //#define L1 1 // cara vlevo
.................... #define L2 2 // cara vlevo
.................... #define L3 3 // cara vlevo
.................... #define S 0 // cara mezi sensory
.................... //#define R1 -1 // cara vpravo
.................... #define R2 -2 // cara vpravo
.................... #define R3 -3 // cara vpravo
....................
.................... // servo
.................... #define SERVO PIN_B5
....................
.................... // kroutitka
.................... #define CERVENA 4 // AN4
.................... //#define CERNA 5 // AN5
.................... //#define ZELENA 6 // AN6
.................... #define MODRA 2 // AN2
....................
.................... // IR
.................... #define IRTX PIN_B2
.................... #define CIHLA PIN_A3
....................
.................... //motory
.................... #define FR output_low(PIN_A7); output_high(PIN_A6) // Vpred
.................... #define FL output_low(PIN_A1); output_high(PIN_A0)
.................... #define BR output_low(PIN_A6); output_high(PIN_A7) // Vzad
.................... #define BL output_low(PIN_A0); output_high(PIN_A1)
.................... #define STOPR output_low(PIN_A6);output_low(PIN_A7)
.................... #define STOPL output_low(PIN_A0);output_low(PIN_A1)
....................
.................... //HID
.................... #define LED1 PIN_B1 //oranzova
.................... #define LED2 PIN_B2 //zluta
....................
.................... #define STROBE PIN_B0
.................... //#define SW1 PIN_A2 // Motory On/off
....................
.................... unsigned int8 sensors; // pomocna promenna pro cteni cidel na caru
.................... signed int8 line = S; // na ktere strane byla detekovana cara
*
0279: BCF 03.5
027A: CLRF 2B
.................... //unsigned int8 dira; // pocita dobu po kterou je ztracena cara
.................... unsigned int8 uhel; // urcuje aktualni uhel zataceni
.................... unsigned int8 speed; // maximalni povolena rychlost
.................... unsigned int8 turn; // rychlost toceni
.................... unsigned int8 rovinka; // pocitadlo na zjisteni rovinky
....................
.................... signed int16 Lmotor; // promene, ktere urcuji velikost vykonu na levem
.................... signed int16 Rmotor; // a pravem motoru
....................
.................... // makro pro PWM pro motory
.................... #define GO(motor, direction, power) if(get_timer0()<=power) \
.................... {direction##motor;} else {stop##motor;}
.................... ////////////////////////////////////////////////////////////////////////////////
.................... #int_TIMER2
.................... TIMER2_isr() // ovladani serva
.................... {
.................... unsigned int8 n;
....................
.................... output_high(SERVO);
*
0047: BSF 03.5
0048: BCF 06.5
0049: BCF 03.5
004A: BSF 06.5
.................... delay_us(1000);
004B: CLRWDT
004C: MOVLW 09
004D: MOVWF 3C
004E: MOVLW 6D
004F: MOVWF 3D
0050: CALL 037
0051: DECFSZ 3C,F
0052: GOTO 04E
.................... for(n=uhel; n>0; n--) Delay_us(2);
0053: MOVF 2C,W
0054: MOVWF 3B
0055: MOVF 3B,F
0056: BTFSC 03.2
0057: GOTO 05E
0058: CLRWDT
0059: NOP
005A: NOP
005B: NOP
005C: DECF 3B,F
005D: GOTO 055
.................... output_low(SERVO);
005E: BSF 03.5
005F: BCF 06.5
0060: BCF 03.5
0061: BCF 06.5
.................... }
....................
.................... ////////////////////////////////////////////////////////////////////////////////
0062: BCF 0C.1
0063: BCF 0A.3
0064: GOTO 022
.................... int8 IRcheck() // potvrdi detekci cihly
.................... {
.................... output_high(IRTX); // vypne vysilac IR
.................... delay_ms(10);
....................
.................... output_low(STROBE);
.................... sensors = spi_read(0); // cteni senzoru
.................... sensors=~sensors;
.................... output_high(STROBE);
....................
.................... if(bit_test(sensors,7)) // otestuje, jestli je stale detekovan IR signal
.................... {
.................... output_low(IRTX); // zapne vysilac IR
.................... delay_ms(10);
....................
.................... output_low(STROBE);
.................... sensors = spi_read(0); // cteni senzoru
.................... sensors=~sensors;
.................... output_high(STROBE);
....................
.................... if(!bit_test(sensors,7)) // otestuje, jestli je detekovana cihla
.................... {
.................... output_high(IRTX); // vypne vysilac IR
.................... delay_ms(10);
....................
.................... output_low(STROBE);
.................... sensors = spi_read(0); // cteni senzoru
.................... sensors=~sensors;
.................... output_high(STROBE);
....................
.................... output_low(IRTX); // zapne vysilac IR
....................
.................... if(bit_test(sensors,7)) return 1; // vrat 1, kdyz je stale cihla
.................... }
.................... };
.................... output_low(IRTX); // zapne vysilac IR
.................... return 0; // vrat 0, kdyz je detekovano ruseni
.................... }
.................... ////////////////////////////////////////////////////////////////////////////////
.................... #include ".\objizdka_centrovani_R.c"
.................... #define DOLEVA 0
.................... #define DOPRAVA 1
....................
.................... void cikcak()
.................... {
.................... unsigned int8 i=0;
*
007D: CLRF 39
....................
.................... uhel=KOLMO1; // aby se dalo tocit na miste
007E: MOVLW E1
007F: MOVWF 2C
.................... Delay_ms(100);
0080: MOVLW 64
0081: MOVWF 3A
0082: CALL 065
....................
.................... if (line==L2) line=L3; // poznamenej, kde byla cara pred brzdenim
0083: MOVF 2B,W
0084: SUBLW 02
0085: BTFSS 03.2
0086: GOTO 089
0087: MOVLW 03
0088: MOVWF 2B
.................... if (line==S) line=L3;
0089: MOVF 2B,F
008A: BTFSS 03.2
008B: GOTO 08E
008C: MOVLW 03
008D: MOVWF 2B
.................... if (line==R2) line=R3;
008E: MOVF 2B,W
008F: SUBLW FE
0090: BTFSS 03.2
0091: GOTO 094
0092: MOVLW FD
0093: MOVWF 2B
....................
.................... Delay_ms(3); // prodleva na cteni senzoru pred prenosem
0094: MOVLW 03
0095: MOVWF 3A
0096: CALL 065
....................
.................... output_low(STROBE); // zapni zobrazovani na posuvnem registru
0097: BSF 03.5
0098: BCF 06.0
0099: BCF 03.5
009A: BCF 06.0
.................... sensors = spi_read(0); // cteni senzoru
009B: MOVF 13,W
009C: CLRF 13
009D: BSF 03.5
009E: BTFSC 14.0
009F: GOTO 0A2
00A0: BCF 03.5
00A1: GOTO 09D
00A2: BCF 03.5
00A3: MOVF 13,W
00A4: MOVWF 2A
.................... sensors=~sensors;
00A5: COMF 2A,F
.................... output_high(STROBE); // vypni zobrazovani na posuvnem registru
00A6: BSF 03.5
00A7: BCF 06.0
00A8: BCF 03.5
00A9: BSF 06.0
....................
.................... while(true)
.................... {
.................... Delay_ms(3);
00AA: MOVLW 03
00AB: MOVWF 3A
00AC: CALL 065
....................
.................... if (line==L3)
00AD: MOVF 2B,W
00AE: SUBLW 03
00AF: BTFSS 03.2
00B0: GOTO 0DB
.................... {
.................... GO(L,B,160);GO(R,F,160);
00B1: MOVF 01,W
00B2: SUBLW A0
00B3: BTFSS 03.0
00B4: GOTO 0BE
00B5: BSF 03.5
00B6: BCF 05.0
00B7: BCF 03.5
00B8: BCF 05.0
00B9: BSF 03.5
00BA: BCF 05.1
00BB: BCF 03.5
00BC: BSF 05.1
00BD: GOTO 0C6
00BE: BSF 03.5
00BF: BCF 05.0
00C0: BCF 03.5
00C1: BCF 05.0
00C2: BSF 03.5
00C3: BCF 05.1
00C4: BCF 03.5
00C5: BCF 05.1
00C6: MOVF 01,W
00C7: SUBLW A0
00C8: BTFSS 03.0
00C9: GOTO 0D3
00CA: BSF 03.5
00CB: BCF 05.7
00CC: BCF 03.5
00CD: BCF 05.7
00CE: BSF 03.5
00CF: BCF 05.6
00D0: BCF 03.5
00D1: BSF 05.6
00D2: GOTO 0DB
00D3: BSF 03.5
00D4: BCF 05.6
00D5: BCF 03.5
00D6: BCF 05.6
00D7: BSF 03.5
00D8: BCF 05.7
00D9: BCF 03.5
00DA: BCF 05.7
.................... };
.................... if (line==R3)
00DB: MOVF 2B,W
00DC: SUBLW FD
00DD: BTFSS 03.2
00DE: GOTO 109
.................... {
.................... GO(R,B,160);GO(L,F,160);
00DF: MOVF 01,W
00E0: SUBLW A0
00E1: BTFSS 03.0
00E2: GOTO 0EC
00E3: BSF 03.5
00E4: BCF 05.6
00E5: BCF 03.5
00E6: BCF 05.6
00E7: BSF 03.5
00E8: BCF 05.7
00E9: BCF 03.5
00EA: BSF 05.7
00EB: GOTO 0F4
00EC: BSF 03.5
00ED: BCF 05.6
00EE: BCF 03.5
00EF: BCF 05.6
00F0: BSF 03.5
00F1: BCF 05.7
00F2: BCF 03.5
00F3: BCF 05.7
00F4: MOVF 01,W
00F5: SUBLW A0
00F6: BTFSS 03.0
00F7: GOTO 101
00F8: BSF 03.5
00F9: BCF 05.1
00FA: BCF 03.5
00FB: BCF 05.1
00FC: BSF 03.5
00FD: BCF 05.0
00FE: BCF 03.5
00FF: BSF 05.0
0100: GOTO 109
0101: BSF 03.5
0102: BCF 05.0
0103: BCF 03.5
0104: BCF 05.0
0105: BSF 03.5
0106: BCF 05.1
0107: BCF 03.5
0108: BCF 05.1
.................... };
.................... if (line==S) {STOPL;STOPR; i++;} else i=0;
0109: MOVF 2B,F
010A: BTFSS 03.2
010B: GOTO 11E
010C: BSF 03.5
010D: BCF 05.0
010E: BCF 03.5
010F: BCF 05.0
0110: BSF 03.5
0111: BCF 05.1
0112: BCF 03.5
0113: BCF 05.1
0114: BSF 03.5
0115: BCF 05.6
0116: BCF 03.5
0117: BCF 05.6
0118: BSF 03.5
0119: BCF 05.7
011A: BCF 03.5
011B: BCF 05.7
011C: INCF 39,F
011D: GOTO 11F
011E: CLRF 39
....................
.................... if (i>=100) break; // pokud je dostatecne dlouho cara vprostred, vypadni
011F: MOVF 39,W
0120: SUBLW 63
0121: BTFSS 03.0
0122: GOTO 159
....................
.................... output_low(STROBE); // zapni zobrazovani na posuvnem registru
0123: BSF 03.5
0124: BCF 06.0
0125: BCF 03.5
0126: BCF 06.0
.................... sensors = spi_read(0); // cteni senzoru
0127: MOVF 13,W
0128: CLRF 13
0129: BSF 03.5
012A: BTFSC 14.0
012B: GOTO 12E
012C: BCF 03.5
012D: GOTO 129
012E: BCF 03.5
012F: MOVF 13,W
0130: MOVWF 2A
.................... sensors=~sensors;
0131: COMF 2A,F
.................... output_high(STROBE); // vypni zobrazovani na posuvnem registru
0132: BSF 03.5
0133: BCF 06.0
0134: BCF 03.5
0135: BSF 06.0
....................
.................... if(bit_test(sensors,3)) //...|...//
0136: BTFSS 2A.3
0137: GOTO 13A
.................... {
.................... line=S;
0138: CLRF 2B
.................... continue;
0139: GOTO 0AA
.................... }
....................
.................... if(bit_test(sensors,0)) //|......// // z duvodu zkraceni doby reakce se cidla nevyhodnocuji poporade ale od krajnich k prostrednimu
013A: BTFSS 2A.0
013B: GOTO 13F
.................... {
.................... line=L3;
013C: MOVLW 03
013D: MOVWF 2B
.................... continue;
013E: GOTO 0AA
.................... }
....................
.................... if(bit_test(sensors,6)) //......|//
013F: BTFSS 2A.6
0140: GOTO 144
.................... {
.................... line=R3;
0141: MOVLW FD
0142: MOVWF 2B
.................... continue;
0143: GOTO 0AA
.................... }
....................
.................... if(bit_test(sensors,1)) //.|.....//
0144: BTFSS 2A.1
0145: GOTO 149
.................... {
.................... line=L3;
0146: MOVLW 03
0147: MOVWF 2B
.................... continue;
0148: GOTO 0AA
.................... }
....................
.................... if(bit_test(sensors,5)) //.....|.//
0149: BTFSS 2A.5
014A: GOTO 14E
.................... {
.................... line=R3;
014B: MOVLW FD
014C: MOVWF 2B
.................... continue;
014D: GOTO 0AA
.................... }
....................
.................... if (bit_test(sensors,2)) //..|....//
014E: BTFSS 2A.2
014F: GOTO 153
.................... {
.................... line=L3;
0150: MOVLW 03
0151: MOVWF 2B
.................... continue;
0152: GOTO 0AA
.................... }
....................
.................... if (bit_test(sensors,4)) //....|..//
0153: BTFSS 2A.4
0154: GOTO 158
.................... {
.................... line=R3;
0155: MOVLW FD
0156: MOVWF 2B
.................... continue;
0157: GOTO 0AA
.................... }
.................... }
0158: GOTO 0AA
.................... }
0159: RETLW 00
.................... ////////////////////////////////////////////////////////////////////////////////
.................... void objizdka()
.................... {
.................... FL;BR; // doprava 90
015A: BSF 03.5
015B: BCF 05.1
015C: BCF 03.5
015D: BCF 05.1
015E: BSF 03.5
015F: BCF 05.0
0160: BCF 03.5
0161: BSF 05.0
0162: BSF 03.5
0163: BCF 05.6
0164: BCF 03.5
0165: BCF 05.6
0166: BSF 03.5
0167: BCF 05.7
0168: BCF 03.5
0169: BSF 05.7
.................... Delay_ms(300);
016A: MOVLW 02
016B: MOVWF 39
016C: MOVLW 96
016D: MOVWF 3A
016E: CALL 065
016F: DECFSZ 39,F
0170: GOTO 16C
.................... BL;FR; // brzdi z toceni
0171: BSF 03.5
0172: BCF 05.0
0173: BCF 03.5
0174: BCF 05.0
0175: BSF 03.5
0176: BCF 05.1
0177: BCF 03.5
0178: BSF 05.1
0179: BSF 03.5
017A: BCF 05.7
017B: BCF 03.5
017C: BCF 05.7
017D: BSF 03.5
017E: BCF 05.6
017F: BCF 03.5
0180: BSF 05.6
.................... Delay_ms(100);
0181: MOVLW 64
0182: MOVWF 3A
0183: CALL 065
.................... STOPL;STOPR;
0184: BSF 03.5
0185: BCF 05.0
0186: BCF 03.5
0187: BCF 05.0
0188: BSF 03.5
0189: BCF 05.1
018A: BCF 03.5
018B: BCF 05.1
018C: BSF 03.5
018D: BCF 05.6
018E: BCF 03.5
018F: BCF 05.6
0190: BSF 03.5
0191: BCF 05.7
0192: BCF 03.5
0193: BCF 05.7
....................
.................... uhel=STRED;
0194: MOVLW 80
0195: MOVWF 2C
.................... FL;FR;
0196: BSF 03.5
0197: BCF 05.1
0198: BCF 03.5
0199: BCF 05.1
019A: BSF 03.5
019B: BCF 05.0
019C: BCF 03.5
019D: BSF 05.0
019E: BSF 03.5
019F: BCF 05.7
01A0: BCF 03.5
01A1: BCF 05.7
01A2: BSF 03.5
01A3: BCF 05.6
01A4: BCF 03.5
01A5: BSF 05.6
.................... Delay_ms(380); // rovne
01A6: MOVLW 02
01A7: MOVWF 39
01A8: MOVLW BE
01A9: MOVWF 3A
01AA: CALL 065
01AB: DECFSZ 39,F
01AC: GOTO 1A8
....................
.................... uhel=STRED-55;
01AD: MOVLW 49
01AE: MOVWF 2C
.................... STOPL;FR;
01AF: BSF 03.5
01B0: BCF 05.0
01B1: BCF 03.5
01B2: BCF 05.0
01B3: BSF 03.5
01B4: BCF 05.1
01B5: BCF 03.5
01B6: BCF 05.1
01B7: BSF 03.5
01B8: BCF 05.7
01B9: BCF 03.5
01BA: BCF 05.7
01BB: BSF 03.5
01BC: BCF 05.6
01BD: BCF 03.5
01BE: BSF 05.6
.................... Delay_ms(190); // doleva
01BF: MOVLW BE
01C0: MOVWF 3A
01C1: CALL 065
....................
.................... uhel=STRED;
01C2: MOVLW 80
01C3: MOVWF 2C
.................... FR;FL;
01C4: BSF 03.5
01C5: BCF 05.7
01C6: BCF 03.5
01C7: BCF 05.7
01C8: BSF 03.5
01C9: BCF 05.6
01CA: BCF 03.5
01CB: BSF 05.6
01CC: BSF 03.5
01CD: BCF 05.1
01CE: BCF 03.5
01CF: BCF 05.1
01D0: BSF 03.5
01D1: BCF 05.0
01D2: BCF 03.5
01D3: BSF 05.0
.................... Delay_ms(300); // rovne
01D4: MOVLW 02
01D5: MOVWF 39
01D6: MOVLW 96
01D7: MOVWF 3A
01D8: CALL 065
01D9: DECFSZ 39,F
01DA: GOTO 1D6
....................
.................... uhel=STRED-55;
01DB: MOVLW 49
01DC: MOVWF 2C
.................... FR;STOPL;
01DD: BSF 03.5
01DE: BCF 05.7
01DF: BCF 03.5
01E0: BCF 05.7
01E1: BSF 03.5
01E2: BCF 05.6
01E3: BCF 03.5
01E4: BSF 05.6
01E5: BSF 03.5
01E6: BCF 05.0
01E7: BCF 03.5
01E8: BCF 05.0
01E9: BSF 03.5
01EA: BCF 05.1
01EB: BCF 03.5
01EC: BCF 05.1
.................... Delay_ms(190); // doleva
01ED: MOVLW BE
01EE: MOVWF 3A
01EF: CALL 065
....................
.................... uhel=STRED;
01F0: MOVLW 80
01F1: MOVWF 2C
.................... FR;FL;
01F2: BSF 03.5
01F3: BCF 05.7
01F4: BCF 03.5
01F5: BCF 05.7
01F6: BSF 03.5
01F7: BCF 05.6
01F8: BCF 03.5
01F9: BSF 05.6
01FA: BSF 03.5
01FB: BCF 05.1
01FC: BCF 03.5
01FD: BCF 05.1
01FE: BSF 03.5
01FF: BCF 05.0
0200: BCF 03.5
0201: BSF 05.0
.................... Delay_ms(100); // rovne
0202: MOVLW 64
0203: MOVWF 3A
0204: CALL 065
....................
.................... While((sensors & 0b11111110)!=0) //dokud neni cara
.................... {
0205: MOVF 2A,W
0206: ANDLW FE
0207: BTFSC 03.2
0208: GOTO 218
.................... sensors = spi_read(0); // cteni senzoru
0209: MOVF 13,W
020A: CLRF 13
020B: BSF 03.5
020C: BTFSC 14.0
020D: GOTO 210
020E: BCF 03.5
020F: GOTO 20B
0210: BCF 03.5
0211: MOVF 13,W
0212: MOVWF 2A
.................... sensors=~sensors;
0213: COMF 2A,F
.................... Delay_ms(3); // cekani na SLAVE nez pripravi data od cidel
0214: MOVLW 03
0215: MOVWF 3A
0216: CALL 065
.................... }
0217: GOTO 205
.................... BL;BR; // zabrzdi
0218: BSF 03.5
0219: BCF 05.0
021A: BCF 03.5
021B: BCF 05.0
021C: BSF 03.5
021D: BCF 05.1
021E: BCF 03.5
021F: BSF 05.1
0220: BSF 03.5
0221: BCF 05.6
0222: BCF 03.5
0223: BCF 05.6
0224: BSF 03.5
0225: BCF 05.7
0226: BCF 03.5
0227: BSF 05.7
.................... Delay_ms(250);
0228: MOVLW FA
0229: MOVWF 3A
022A: CALL 065
....................
.................... uhel=KOLMO1;
022B: MOVLW E1
022C: MOVWF 2C
.................... FL;BR; // doprava
022D: BSF 03.5
022E: BCF 05.1
022F: BCF 03.5
0230: BCF 05.1
0231: BSF 03.5
0232: BCF 05.0
0233: BCF 03.5
0234: BSF 05.0
0235: BSF 03.5
0236: BCF 05.6
0237: BCF 03.5
0238: BCF 05.6
0239: BSF 03.5
023A: BCF 05.7
023B: BCF 03.5
023C: BSF 05.7
.................... While((sensors & 0b11111110)!=0) //dokud neni cara
.................... {
023D: MOVF 2A,W
023E: ANDLW FE
023F: BTFSC 03.2
0240: GOTO 250
.................... sensors = spi_read(0); // cteni senzoru
0241: MOVF 13,W
0242: CLRF 13
0243: BSF 03.5
0244: BTFSC 14.0
0245: GOTO 248
0246: BCF 03.5
0247: GOTO 243
0248: BCF 03.5
0249: MOVF 13,W
024A: MOVWF 2A
.................... sensors=~sensors;
024B: COMF 2A,F
.................... Delay_ms(3); // cekani na SLAVE nez pripravi data od cidel
024C: MOVLW 03
024D: MOVWF 3A
024E: CALL 065
.................... }
024F: GOTO 23D
.................... STOPL;STOPR; // zabrzdi
0250: BSF 03.5
0251: BCF 05.0
0252: BCF 03.5
0253: BCF 05.0
0254: BSF 03.5
0255: BCF 05.1
0256: BCF 03.5
0257: BCF 05.1
0258: BSF 03.5
0259: BCF 05.6
025A: BCF 03.5
025B: BCF 05.6
025C: BSF 03.5
025D: BCF 05.7
025E: BCF 03.5
025F: BCF 05.7
.................... Delay_ms(300);
0260: MOVLW 02
0261: MOVWF 39
0262: MOVLW 96
0263: MOVWF 3A
0264: CALL 065
0265: DECFSZ 39,F
0266: GOTO 262
.................... // delay_ms(250);
....................
.................... line=R3;
0267: MOVLW FD
0268: MOVWF 2B
.................... cikcak();
0269: CALL 07D
.................... }
026A: BCF 0A.3
026B: GOTO 3CF (RETURN)
....................
....................
.................... ////////////////////////////////////////////////////////////////////////////////
.................... void main()
.................... {
026C: CLRF 04
026D: MOVLW 1F
026E: ANDWF 03,F
026F: MOVLW 70
0270: BSF 03.5
0271: MOVWF 0F
0272: BCF 1F.4
0273: BCF 1F.5
0274: MOVF 1B,W
0275: ANDLW 80
0276: MOVWF 1B
0277: MOVLW 07
0278: MOVWF 1C
....................
.................... unsigned int8 n;
.................... unsigned int8 i,j;
.................... unsigned int8 last_sensors;
.................... unsigned int8 RozumnaRychlost;
....................
.................... setup_adc_ports(sAN5|sAN2|sAN4|sAN6|VSS_VDD); // AD pro kroutitka
*
027B: BSF 03.5
027C: BCF 1F.4
027D: BCF 1F.5
027E: MOVF 1B,W
027F: ANDLW 80
0280: IORLW 74
0281: MOVWF 1B
.................... setup_adc(ADC_CLOCK_INTERNAL);
0282: BCF 1F.6
0283: BCF 03.5
0284: BSF 1F.6
0285: BSF 1F.7
0286: BSF 03.5
0287: BCF 1F.7
0288: BCF 03.5
0289: BSF 1F.0
.................... setup_spi(SPI_MASTER|SPI_H_TO_L|SPI_XMIT_L_TO_H|SPI_CLK_DIV_16);
028A: BCF 14.5
028B: BSF 03.5
028C: BCF 06.2
028D: BSF 06.1
028E: BCF 06.4
028F: MOVLW 31
0290: BCF 03.5
0291: MOVWF 14
0292: MOVLW 00
0293: BSF 03.5
0294: MOVWF 14
.................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
0295: MOVF 01,W
0296: ANDLW C7
0297: IORLW 08
0298: MOVWF 01
.................... setup_timer_1(T1_DISABLED|T1_DIV_BY_8);
0299: MOVLW 30
029A: BCF 03.5
029B: MOVWF 10
.................... setup_timer_2(T2_DIV_BY_16,140,16);
029C: MOVLW 78
029D: MOVWF 78
029E: IORLW 06
029F: MOVWF 12
02A0: MOVLW 8C
02A1: BSF 03.5
02A2: MOVWF 12
.................... setup_oscillator(OSC_8MHZ|OSC_INTRC);
02A3: MOVLW 72
02A4: MOVWF 0F
....................
.................... STOPR; STOPL; // zastav motory
02A5: BCF 05.6
02A6: BCF 03.5
02A7: BCF 05.6
02A8: BSF 03.5
02A9: BCF 05.7
02AA: BCF 03.5
02AB: BCF 05.7
02AC: BSF 03.5
02AD: BCF 05.0
02AE: BCF 03.5
02AF: BCF 05.0
02B0: BSF 03.5
02B1: BCF 05.1
02B2: BCF 03.5
02B3: BCF 05.1
.................... Lmotor=0;Rmotor=0;
02B4: CLRF 31
02B5: CLRF 30
02B6: CLRF 33
02B7: CLRF 32
....................
.................... uhel = STRED; // nastav zadni kolecko na stred
02B8: MOVLW 80
02B9: MOVWF 2C
.................... rovinka = 0;
02BA: CLRF 2F
....................
.................... enable_interrupts(INT_TIMER2);
02BB: BSF 03.5
02BC: BSF 0C.1
.................... enable_interrupts(GLOBAL);
02BD: MOVLW C0
02BE: BCF 03.5
02BF: IORWF 0B,F
....................
.................... output_low(IRTX); // zapni IR vysilac
02C0: BSF 03.5
02C1: BCF 06.2
02C2: BCF 03.5
02C3: BCF 06.2
....................
.................... delay_ms(2000); // musime pockat na diagnostiku slave CPU
02C4: MOVLW 08
02C5: MOVWF 39
02C6: MOVLW FA
02C7: MOVWF 3A
02C8: CALL 065
02C9: DECFSZ 39,F
02CA: GOTO 2C6
....................
.................... //nastaveni rychlosti
.................... set_adc_channel(CERVENA);
02CB: MOVLW 20
02CC: MOVWF 78
02CD: MOVF 1F,W
02CE: ANDLW C7
02CF: IORWF 78,W
02D0: MOVWF 1F
....................
.................... Delay_ms(1);
02D1: MOVLW 01
02D2: MOVWF 3A
02D3: CALL 065
.................... RozumnaRychlost=R+(read_adc()>>2); // rychlost rovne +63; kroutitko dava 0-63
02D4: BSF 1F.2
02D5: BTFSC 1F.2
02D6: GOTO 2D5
02D7: MOVF 1E,W
02D8: MOVWF 77
02D9: RRF 77,F
02DA: RRF 77,F
02DB: MOVLW 3F
02DC: ANDWF 77,F
02DD: MOVF 77,W
02DE: ADDLW 64
02DF: MOVWF 38
.................... set_adc_channel(MODRA);
02E0: MOVLW 10
02E1: MOVWF 78
02E2: MOVF 1F,W
02E3: ANDLW C7
02E4: IORWF 78,W
02E5: MOVWF 1F
.................... Delay_ms(1);
02E6: MOVLW 01
02E7: MOVWF 3A
02E8: CALL 065
.................... turn=speed-32+(read_adc()>>2); // rychlost toceni +-32; kroutitko dava 0-63
02E9: MOVLW 20
02EA: SUBWF 2D,W
02EB: MOVWF 39
02EC: BSF 1F.2
02ED: BTFSC 1F.2
02EE: GOTO 2ED
02EF: MOVF 1E,W
02F0: MOVWF 77
02F1: RRF 77,F
02F2: RRF 77,F
02F3: MOVLW 3F
02F4: ANDWF 77,F
02F5: MOVF 77,W
02F6: ADDWF 39,W
02F7: MOVWF 2E
....................
.................... speed=R17;
02F8: MOVLW C8
02F9: MOVWF 2D
....................
.................... while(true)
.................... {
....................
.................... GO(L,F,Lmotor);GO(R,F,Rmotor); // zapni motory PWM podle promenych Lmotor a Rmotor
02FA: MOVF 01,W
02FB: BTFSS 00.7
02FC: GOTO 300
02FD: BTFSS 31.7
02FE: GOTO 308
02FF: GOTO 302
0300: BTFSC 31.7
0301: GOTO 311
0302: MOVF 31,F
0303: BTFSS 03.2
0304: GOTO 308
0305: SUBWF 30,W
0306: BTFSS 03.0
0307: GOTO 311
0308: BSF 03.5
0309: BCF 05.1
030A: BCF 03.5
030B: BCF 05.1
030C: BSF 03.5
030D: BCF 05.0
030E: BCF 03.5
030F: BSF 05.0
0310: GOTO 319
0311: BSF 03.5
0312: BCF 05.0
0313: BCF 03.5
0314: BCF 05.0
0315: BSF 03.5
0316: BCF 05.1
0317: BCF 03.5
0318: BCF 05.1
0319: MOVF 01,W
031A: BTFSS 00.7
031B: GOTO 31F
031C: BTFSS 33.7
031D: GOTO 327
031E: GOTO 321
031F: BTFSC 33.7
0320: GOTO 330
0321: MOVF 33,F
0322: BTFSS 03.2
0323: GOTO 327
0324: SUBWF 32,W
0325: BTFSS 03.0
0326: GOTO 330
0327: BSF 03.5
0328: BCF 05.7
0329: BCF 03.5
032A: BCF 05.7
032B: BSF 03.5
032C: BCF 05.6
032D: BCF 03.5
032E: BSF 05.6
032F: GOTO 338
0330: BSF 03.5
0331: BCF 05.6
0332: BCF 03.5
0333: BCF 05.6
0334: BSF 03.5
0335: BCF 05.7
0336: BCF 03.5
0337: BCF 05.7
....................
.................... delay_us(2000); // cekani na SLAVE, nez pripravi data od cidel
0338: CLRWDT
0339: MOVLW 01
033A: MOVWF 3A
033B: CALL 065
033C: MOVLW 09
033D: MOVWF 39
033E: CLRF 29
033F: BTFSC 0B.7
0340: BSF 29.7
0341: BCF 0B.7
0342: MOVLW 6D
0343: MOVWF 3D
0344: CALL 037
0345: BTFSC 29.7
0346: BSF 0B.7
0347: DECFSZ 39,F
0348: GOTO 33E
....................
.................... last_sensors=sensors;
0349: MOVF 2A,W
034A: MOVWF 37
....................
.................... output_low(STROBE); // vypni zobrazovani na posuvnem registru
034B: BSF 03.5
034C: BCF 06.0
034D: BCF 03.5
034E: BCF 06.0
.................... sensors = spi_read(0); // cteni senzoru
034F: MOVF 13,W
0350: CLRF 13
0351: BSF 03.5
0352: BTFSC 14.0
0353: GOTO 356
0354: BCF 03.5
0355: GOTO 351
0356: BCF 03.5
0357: MOVF 13,W
0358: MOVWF 2A
.................... sensors=~sensors; // neguj prijata data
0359: COMF 2A,F
.................... output_high(STROBE); // zobraz data na posuvnem registru
035A: BSF 03.5
035B: BCF 06.0
035C: BCF 03.5
035D: BSF 06.0
....................
.................... i=0; // havarijni kod
035E: CLRF 35
.................... for (n=0; n<=6; n++)
035F: CLRF 34
0360: MOVF 34,W
0361: SUBLW 06
0362: BTFSS 03.0
0363: GOTO 372
.................... {
.................... if(bit_test(sensors,n)) i++;
0364: MOVF 2A,W
0365: MOVWF 77
0366: MOVF 34,W
0367: MOVWF 78
0368: BTFSC 03.2
0369: GOTO 36E
036A: BCF 03.0
036B: RRF 77,F
036C: DECFSZ 78,F
036D: GOTO 36A
036E: BTFSC 77.0
036F: INCF 35,F
.................... }
0370: INCF 34,F
0371: GOTO 360
.................... if (i>4) // zastavi, kdyz je cerno pod vice nez tremi cidly
0372: MOVF 35,W
0373: SUBLW 04
0374: BTFSC 03.0
0375: GOTO 39E
.................... {
.................... BL; BR;
0376: BSF 03.5
0377: BCF 05.0
0378: BCF 03.5
0379: BCF 05.0
037A: BSF 03.5
037B: BCF 05.1
037C: BCF 03.5
037D: BSF 05.1
037E: BSF 03.5
037F: BCF 05.6
0380: BCF 03.5
0381: BCF 05.6
0382: BSF 03.5
0383: BCF 05.7
0384: BCF 03.5
0385: BSF 05.7
.................... delay_ms(300);
0386: MOVLW 02
0387: MOVWF 39
0388: MOVLW 96
0389: MOVWF 3A
038A: CALL 065
038B: DECFSZ 39,F
038C: GOTO 388
.................... STOPR; STOPL;
038D: BSF 03.5
038E: BCF 05.6
038F: BCF 03.5
0390: BCF 05.6
0391: BSF 03.5
0392: BCF 05.7
0393: BCF 03.5
0394: BCF 05.7
0395: BSF 03.5
0396: BCF 05.0
0397: BCF 03.5
0398: BCF 05.0
0399: BSF 03.5
039A: BCF 05.1
039B: BCF 03.5
039C: BCF 05.1
.................... While(true);
039D: GOTO 39D
.................... };
....................
.................... /*
.................... if (!input(CIHLA)) // dalkova detekce cihly
.................... {
.................... speed=PRED_CIHLOU;
.................... }
.................... else
.................... {
.................... speed=RozumnaRychlost;
.................... }
.................... */
.................... if (bit_test(sensors,7)) // detekce cihly
039E: BTFSS 2A.7
039F: GOTO 3CF
.................... {
.................... BR;BL;
03A0: BSF 03.5
03A1: BCF 05.6
03A2: BCF 03.5
03A3: BCF 05.6
03A4: BSF 03.5
03A5: BCF 05.7
03A6: BCF 03.5
03A7: BSF 05.7
03A8: BSF 03.5
03A9: BCF 05.0
03AA: BCF 03.5
03AB: BCF 05.0
03AC: BSF 03.5
03AD: BCF 05.1
03AE: BCF 03.5
03AF: BSF 05.1
.................... Delay_ms(400);
03B0: MOVLW 02
03B1: MOVWF 39
03B2: MOVLW C8
03B3: MOVWF 3A
03B4: CALL 065
03B5: DECFSZ 39,F
03B6: GOTO 3B2
.................... STOPR;STOPL;
03B7: BSF 03.5
03B8: BCF 05.6
03B9: BCF 03.5
03BA: BCF 05.6
03BB: BSF 03.5
03BC: BCF 05.7
03BD: BCF 03.5
03BE: BCF 05.7
03BF: BSF 03.5
03C0: BCF 05.0
03C1: BCF 03.5
03C2: BCF 05.0
03C3: BSF 03.5
03C4: BCF 05.1
03C5: BCF 03.5
03C6: BCF 05.1
.................... // if (1==IRcheck()) // kontrola, jestli nebylo rusene cidlo
.................... {
.................... Delay_ms(100);
03C7: MOVLW 64
03C8: MOVWF 3A
03C9: CALL 065
.................... cikcak();
03CA: CALL 07D
.................... delay_ms(100);
03CB: MOVLW 64
03CC: MOVWF 3A
03CD: CALL 065
.................... objizdka(); // objede cihlu
03CE: GOTO 15A
.................... }
.................... }
....................
.................... if (speed > RozumnaRychlost) speed--; // postupne zpomaleni na Roz. Rychl.
03CF: MOVF 2D,W
03D0: SUBWF 38,W
03D1: BTFSS 03.0
03D2: DECF 2D,F
....................
.................... if(bit_test(sensors,3)) //...|...//
03D3: BTFSS 2A.3
03D4: GOTO 3E7
.................... {
.................... uhel=STRED;
03D5: MOVLW 80
03D6: MOVWF 2C
.................... Lmotor=speed;
03D7: CLRF 7A
03D8: MOVF 2D,W
03D9: MOVWF 30
03DA: MOVF 7A,W
03DB: MOVWF 31
.................... Rmotor=speed;
03DC: CLRF 7A
03DD: MOVF 2D,W
03DE: MOVWF 32
03DF: MOVF 7A,W
03E0: MOVWF 33
.................... line=S;
03E1: CLRF 2B
.................... if (rovinka < 255) rovinka++;
03E2: INCFSZ 2F,W
03E3: GOTO 3E5
03E4: GOTO 3E6
03E5: INCF 2F,F
.................... continue;
03E6: GOTO 2FA
.................... }
....................
.................... if(bit_test(sensors,0)) //|......// // z duvodu zkraceni doby reakce se cidla nevyhodnocuji poporade ale od krajnich k prostrednimu
03E7: BTFSS 2A.0
03E8: GOTO 3F5
.................... {
.................... uhel=STRED - BEAR3;
03E9: MOVLW 53
03EA: MOVWF 2C
.................... Lmotor=0;
03EB: CLRF 31
03EC: CLRF 30
.................... Rmotor=turn;
03ED: CLRF 7A
03EE: MOVF 2E,W
03EF: MOVWF 32
03F0: MOVF 7A,W
03F1: MOVWF 33
.................... line=L3;
03F2: MOVLW 03
03F3: MOVWF 2B
.................... continue;
03F4: GOTO 2FA
.................... }
....................
.................... if(bit_test(sensors,6)) //......|//
03F5: BTFSS 2A.6
03F6: GOTO 403
.................... {
.................... uhel=STRED + BEAR3;
03F7: MOVLW AD
03F8: MOVWF 2C
.................... Rmotor=0;
03F9: CLRF 33
03FA: CLRF 32
.................... Lmotor=turn;
03FB: CLRF 7A
03FC: MOVF 2E,W
03FD: MOVWF 30
03FE: MOVF 7A,W
03FF: MOVWF 31
.................... line=R3;
0400: MOVLW FD
0401: MOVWF 2B
.................... continue;
0402: GOTO 2FA
.................... }
....................
.................... if(bit_test(sensors,1)) //.|.....//
0403: BTFSS 2A.1
0404: GOTO 415
.................... {
.................... uhel=STRED - BEAR2;
0405: MOVLW 67
0406: MOVWF 2C
.................... Lmotor=speed-70;
0407: MOVLW 46
0408: SUBWF 2D,W
0409: CLRF 7A
040A: MOVWF 30
040B: MOVF 7A,W
040C: MOVWF 31
.................... Rmotor=speed;
040D: CLRF 7A
040E: MOVF 2D,W
040F: MOVWF 32
0410: MOVF 7A,W
0411: MOVWF 33
.................... line=L2;
0412: MOVLW 02
0413: MOVWF 2B
.................... continue;
0414: GOTO 2FA
.................... }
....................
.................... if(bit_test(sensors,5)) //.....|.//
0415: BTFSS 2A.5
0416: GOTO 427
.................... {
.................... uhel=STRED + BEAR2;
0417: MOVLW 99
0418: MOVWF 2C
.................... Rmotor=speed-70;
0419: MOVLW 46
041A: SUBWF 2D,W
041B: CLRF 7A
041C: MOVWF 32
041D: MOVF 7A,W
041E: MOVWF 33
.................... Lmotor=speed;
041F: CLRF 7A
0420: MOVF 2D,W
0421: MOVWF 30
0422: MOVF 7A,W
0423: MOVWF 31
.................... line=R2;
0424: MOVLW FE
0425: MOVWF 2B
.................... continue;
0426: GOTO 2FA
.................... }
....................
.................... if (bit_test(sensors,2)) //..|....//
0427: BTFSS 2A.2
0428: GOTO 43D
.................... {
.................... uhel=STRED - BEAR1;
0429: MOVLW 76
042A: MOVWF 2C
.................... Lmotor=speed-20;
042B: MOVLW 14
042C: SUBWF 2D,W
042D: CLRF 7A
042E: MOVWF 30
042F: MOVF 7A,W
0430: MOVWF 31
.................... Rmotor=speed;
0431: CLRF 7A
0432: MOVF 2D,W
0433: MOVWF 32
0434: MOVF 7A,W
0435: MOVWF 33
.................... line=L2;
0436: MOVLW 02
0437: MOVWF 2B
.................... if (rovinka<255) rovinka++;
0438: INCFSZ 2F,W
0439: GOTO 43B
043A: GOTO 43C
043B: INCF 2F,F
.................... continue;
043C: GOTO 2FA
.................... }
....................
.................... if (bit_test(sensors,4)) //....|..//
043D: BTFSS 2A.4
043E: GOTO 453
.................... {
.................... uhel=STRED + BEAR1;
043F: MOVLW 8A
0440: MOVWF 2C
.................... Rmotor=speed-20;
0441: MOVLW 14
0442: SUBWF 2D,W
0443: CLRF 7A
0444: MOVWF 32
0445: MOVF 7A,W
0446: MOVWF 33
.................... Lmotor=speed;
0447: CLRF 7A
0448: MOVF 2D,W
0449: MOVWF 30
044A: MOVF 7A,W
044B: MOVWF 31
.................... line=L2;
044C: MOVLW 02
044D: MOVWF 2B
.................... if (rovinka<255) rovinka++;
044E: INCFSZ 2F,W
044F: GOTO 451
0450: GOTO 452
0451: INCF 2F,F
.................... continue;
0452: GOTO 2FA
.................... }
....................
....................
.................... if ((L3==line) || (R3==line)) // Brzdeni pri vyjeti z trate
0453: MOVF 2B,W
0454: SUBLW 03
0455: BTFSC 03.2
0456: GOTO 45B
0457: MOVF 2B,W
0458: SUBLW FD
0459: BTFSS 03.2
045A: GOTO 480
.................... {
.................... if (rovinka>50)
045B: MOVF 2F,W
045C: SUBLW 32
045D: BTFSC 03.0
045E: GOTO 47D
.................... {
.................... BL; BR;
045F: BSF 03.5
0460: BCF 05.0
0461: BCF 03.5
0462: BCF 05.0
0463: BSF 03.5
0464: BCF 05.1
0465: BCF 03.5
0466: BSF 05.1
0467: BSF 03.5
0468: BCF 05.6
0469: BCF 03.5
046A: BCF 05.6
046B: BSF 03.5
046C: BCF 05.7
046D: BCF 03.5
046E: BSF 05.7
.................... Delay_ms(100);
046F: MOVLW 64
0470: MOVWF 3A
0471: CALL 065
.................... if (rovinka > 250 || speed > 170) delay_ms(50);
0472: MOVF 2F,W
0473: SUBLW FA
0474: BTFSS 03.0
0475: GOTO 47A
0476: MOVF 2D,W
0477: SUBLW AA
0478: BTFSC 03.0
0479: GOTO 47D
047A: MOVLW 32
047B: MOVWF 3A
047C: CALL 065
.................... };
.................... rovinka=0;
047D: CLRF 2F
.................... speed=R17;
047E: MOVLW C8
047F: MOVWF 2D
.................... };
.................... }
0480: GOTO 2FA
.................... }
0481: SLEEP
 
Configuration Fuses:
Word 1: 3F38 NOWDT NOPUT MCLR NOBROWNOUT NOLVP NOCPD NOWRT NODEBUG CCPB0 NOPROTECT INTRC_IO
Word 2: 3FFC NOFCMEN NOIESO
/roboti/istrobot/laserus/3Orbis/main.PJT
0,0 → 1,41
[PROJECT]
Target=main.HEX
Development_Mode=
Processor=0x688F
ToolSuite=CCS
 
[Directories]
Include=C:\Program Files\PICC\devices\;C:\Program Files\PICC\dr
Library=
LinkerScript=
 
[Target Data]
FileList=D:\KAKLIK\programy\PIC_C\roboti\3Orbis\main.c
BuildTool=C-COMPILER
OptionString=+FM
AdditionalOptionString=
BuildRequired=1
 
[main.c]
Type=4
Path=
FileList=
BuildTool=
OptionString=
AdditionalOptionString=
 
[mru-list]
1=main.c
 
[Windows]
0=0000 main.c 0 0 796 451 3 0
 
[Opened Files]
1=D:\KAKLIK\programy\PIC_C\roboti\3Orbis\main.c
2=D:\KAKLIK\programy\PIC_C\roboti\3Orbis\main.h
3=C:\Program Files\PICC\devices\16F88.h
4=D:\KAKLIK\programy\PIC_C\roboti\3Orbis\objizdka_centrovani_R.c
5=
[Units]
Count=1
1=D:\KAKLIK\programy\PIC_C\roboti\3Orbis\main.c (main)
/roboti/istrobot/laserus/3Orbis/main.SYM
0,0 → 1,76
015-016 CCP_1
015 CCP_1_LOW
016 CCP_1_HIGH
020 @INTERRUPT_AREA
021 @INTERRUPT_AREA
022 @INTERRUPT_AREA
023 @INTERRUPT_AREA
024 @INTERRUPT_AREA
025 @INTERRUPT_AREA
026 @INTERRUPT_AREA
027 @INTERRUPT_AREA
028 @INTERRUPT_AREA
029 @INTERRUPT_AREA
02A sensors
02B line
02C uhel
02D speed
02E turn
02F rovinka
030-031 Lmotor
032-033 Rmotor
034 main.n
035 main.i
036 main.j
037 main.last_sensors
038 main.RozumnaRychlost
039 cikcak.i
039 objizdka.@SCRATCH
039 main.@SCRATCH
03A @delay_ms1.P1
03A cikcak.@SCRATCH
03A main.@SCRATCH
03B TIMER2_isr.n
03C TIMER2_isr.@SCRATCH
03D @delay_us1.P1
077 @SCRATCH
078 @SCRATCH
078 _RETURN_
079 @SCRATCH
07A @SCRATCH
07B @SCRATCH
09C.6 C1OUT
09C.7 C2OUT
 
0065 @delay_ms1
0037 @delay_us1
0047 TIMER2_isr
007D cikcak
015A objizdka
026C main
026C @cinit
 
Project Files:
D:\KAKLIK\programy\PIC_C\roboti\3Orbis\main.c
D:\KAKLIK\programy\PIC_C\roboti\3Orbis\main.h
C:\Program Files\PICC\devices\16F88.h
D:\KAKLIK\programy\PIC_C\roboti\3Orbis\objizdka_centrovani_R.c
 
Units:
D:\KAKLIK\programy\PIC_C\roboti\3Orbis\main.c (main)
 
Compiler Settings:
Processor: PIC16F88
Pointer Size: 8
ADC Range: 0-255
Opt Level: 9
Short,Int,Long: 1,8,16
 
Output Files:
Errors: D:\KAKLIK\programy\PIC_C\roboti\3Orbis\main.err
INHX8: D:\KAKLIK\programy\PIC_C\roboti\3Orbis\main.hex
Symbols: D:\KAKLIK\programy\PIC_C\roboti\3Orbis\main.sym
List: D:\KAKLIK\programy\PIC_C\roboti\3Orbis\main.lst
Debug/COFF: D:\KAKLIK\programy\PIC_C\roboti\3Orbis\main.cof
Call Tree: D:\KAKLIK\programy\PIC_C\roboti\3Orbis\main.tre
Statistics: D:\KAKLIK\programy\PIC_C\roboti\3Orbis\main.sta
/roboti/istrobot/laserus/3Orbis/main.c
0,0 → 1,288
#include ".\main.h"
 
#define KOLMO1 225 // predni kolecko sroubem dopredu
#define KOLMO2 30 // predni kolecko je hlavou sroubu dozadu
#define STRED 128 // sredni poloha zataceciho kolecka
#define BEAR1 10//10 // 3 stupne zataceni
#define BEAR2 25//25
#define BEAR3 45//45
#define R 100 // Rozumna rychlost
#define R17 200 // X nasobek rozumne rychlosti
#define PRED_CIHLOU 100 // rychlost pri dalkove detekci cihly
//#define L1 1 // cara vlevo
#define L2 2 // cara vlevo
#define L3 3 // cara vlevo
#define S 0 // cara mezi sensory
//#define R1 -1 // cara vpravo
#define R2 -2 // cara vpravo
#define R3 -3 // cara vpravo
 
// servo
#define SERVO PIN_B5
 
// kroutitka
#define CERVENA 4 // AN4
//#define CERNA 5 // AN5
//#define ZELENA 6 // AN6
#define MODRA 2 // AN2
 
// IR
#define IRTX PIN_B2
#define CIHLA PIN_A3
 
//motory
#define FR output_low(PIN_A7); output_high(PIN_A6) // Vpred
#define FL output_low(PIN_A1); output_high(PIN_A0)
#define BR output_low(PIN_A6); output_high(PIN_A7) // Vzad
#define BL output_low(PIN_A0); output_high(PIN_A1)
#define STOPR output_low(PIN_A6);output_low(PIN_A7)
#define STOPL output_low(PIN_A0);output_low(PIN_A1)
 
//HID
#define LED1 PIN_B1 //oranzova
#define LED2 PIN_B2 //zluta
 
#define STROBE PIN_B0
//#define SW1 PIN_A2 // Motory On/off
 
unsigned int8 sensors; // pomocna promenna pro cteni cidel na caru
signed int8 line = S; // na ktere strane byla detekovana cara
//unsigned int8 dira; // pocita dobu po kterou je ztracena cara
unsigned int8 uhel; // urcuje aktualni uhel zataceni
unsigned int8 speed; // maximalni povolena rychlost
unsigned int8 turn; // rychlost toceni
unsigned int8 rovinka; // pocitadlo na zjisteni rovinky
 
signed int16 Lmotor; // promene, ktere urcuji velikost vykonu na levem
signed int16 Rmotor; // a pravem motoru
 
// makro pro PWM pro motory
#define GO(motor, direction, power) if(get_timer0()<=power) \
{direction##motor;} else {stop##motor;}
////////////////////////////////////////////////////////////////////////////////
#int_TIMER2
TIMER2_isr() // ovladani serva
{
unsigned int8 n;
 
output_high(SERVO);
delay_us(1000);
for(n=uhel; n>0; n--) Delay_us(2);
output_low(SERVO);
}
 
////////////////////////////////////////////////////////////////////////////////
int8 IRcheck() // potvrdi detekci cihly
{
output_high(IRTX); // vypne vysilac IR
delay_ms(10);
 
output_low(STROBE);
sensors = spi_read(0); // cteni senzoru
sensors=~sensors;
output_high(STROBE);
 
if(bit_test(sensors,7)) // otestuje, jestli je stale detekovan IR signal
{
output_low(IRTX); // zapne vysilac IR
delay_ms(10);
 
output_low(STROBE);
sensors = spi_read(0); // cteni senzoru
sensors=~sensors;
output_high(STROBE);
 
if(!bit_test(sensors,7)) // otestuje, jestli je detekovana cihla
{
output_high(IRTX); // vypne vysilac IR
delay_ms(10);
 
output_low(STROBE);
sensors = spi_read(0); // cteni senzoru
sensors=~sensors;
output_high(STROBE);
 
output_low(IRTX); // zapne vysilac IR
 
if(bit_test(sensors,7)) return 1; // vrat 1, kdyz je stale cihla
}
};
output_low(IRTX); // zapne vysilac IR
return 0; // vrat 0, kdyz je detekovano ruseni
}
////////////////////////////////////////////////////////////////////////////////
#include ".\objizdka_centrovani_R.c"
////////////////////////////////////////////////////////////////////////////////
void main()
{
 
unsigned int8 n;
unsigned int8 i,j;
unsigned int8 last_sensors;
unsigned int8 RozumnaRychlost;
 
setup_adc_ports(sAN5|sAN2|sAN4|sAN6|VSS_VDD); // AD pro kroutitka
setup_adc(ADC_CLOCK_INTERNAL);
setup_spi(SPI_MASTER|SPI_H_TO_L|SPI_XMIT_L_TO_H|SPI_CLK_DIV_16);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED|T1_DIV_BY_8);
setup_timer_2(T2_DIV_BY_16,140,16);
setup_oscillator(OSC_8MHZ|OSC_INTRC);
 
STOPR; STOPL; // zastav motory
Lmotor=0;Rmotor=0;
 
uhel = STRED; // nastav zadni kolecko na stred
rovinka = 0;
 
enable_interrupts(INT_TIMER2);
enable_interrupts(GLOBAL);
 
output_low(IRTX); // zapni IR vysilac
 
delay_ms(2000); // musime pockat na diagnostiku slave CPU
 
//nastaveni rychlosti
set_adc_channel(CERVENA);
 
Delay_ms(1);
RozumnaRychlost=R+(read_adc()>>2); // rychlost rovne +63; kroutitko dava 0-63
set_adc_channel(MODRA);
Delay_ms(1);
turn=speed-32+(read_adc()>>2); // rychlost toceni +-32; kroutitko dava 0-63
 
speed=R17;
 
while(true)
{
 
GO(L,F,Lmotor);GO(R,F,Rmotor); // zapni motory PWM podle promenych Lmotor a Rmotor
 
delay_us(2000); // cekani na SLAVE, nez pripravi data od cidel
 
last_sensors=sensors;
 
output_low(STROBE); // vypni zobrazovani na posuvnem registru
sensors = spi_read(0); // cteni senzoru
sensors=~sensors; // neguj prijata data
output_high(STROBE); // zobraz data na posuvnem registru
 
i=0; // havarijni kod
for (n=0; n<=6; n++)
{
if(bit_test(sensors,n)) i++;
}
if (i>4) // zastavi, kdyz je cerno pod vice nez tremi cidly
{
BL; BR;
delay_ms(300);
STOPR; STOPL;
While(true);
};
 
/*
if (!input(CIHLA)) // dalkova detekce cihly
{
speed=PRED_CIHLOU;
}
else
{
speed=RozumnaRychlost;
}
*/
if (bit_test(sensors,7)) // detekce cihly
{
BR;BL;
Delay_ms(400);
STOPR;STOPL;
// if (1==IRcheck()) // kontrola, jestli nebylo rusene cidlo
{
Delay_ms(100);
cikcak();
delay_ms(100);
objizdka(); // objede cihlu
}
}
 
if (speed > RozumnaRychlost) speed--; // postupne zpomaleni na Roz. Rychl.
 
if(bit_test(sensors,3)) //...|...//
{
uhel=STRED;
Lmotor=speed;
Rmotor=speed;
line=S;
if (rovinka < 255) rovinka++;
continue;
}
 
if(bit_test(sensors,0)) //|......// // z duvodu zkraceni doby reakce se cidla nevyhodnocuji poporade ale od krajnich k prostrednimu
{
uhel=STRED - BEAR3;
Lmotor=0;
Rmotor=turn;
line=L3;
continue;
}
 
if(bit_test(sensors,6)) //......|//
{
uhel=STRED + BEAR3;
Rmotor=0;
Lmotor=turn;
line=R3;
continue;
}
 
if(bit_test(sensors,1)) //.|.....//
{
uhel=STRED - BEAR2;
Lmotor=speed-70;
Rmotor=speed;
line=L2;
continue;
}
 
if(bit_test(sensors,5)) //.....|.//
{
uhel=STRED + BEAR2;
Rmotor=speed-70;
Lmotor=speed;
line=R2;
continue;
}
 
if (bit_test(sensors,2)) //..|....//
{
uhel=STRED - BEAR1;
Lmotor=speed-20;
Rmotor=speed;
line=L2;
if (rovinka<255) rovinka++;
continue;
}
 
if (bit_test(sensors,4)) //....|..//
{
uhel=STRED + BEAR1;
Rmotor=speed-20;
Lmotor=speed;
line=L2;
if (rovinka<255) rovinka++;
continue;
}
 
 
if ((L3==line) || (R3==line)) // Brzdeni pri vyjeti z trate
{
if (rovinka>50)
{
BL; BR;
Delay_ms(100);
if (rovinka > 250 || speed > 170) delay_ms(50);
};
rovinka=0;
speed=R17;
};
}
}
/roboti/istrobot/laserus/3Orbis/main.cof
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/roboti/istrobot/laserus/3Orbis/main.err
0,0 → 1,2
No Errors
0 Errors, 0 Warnings.
/roboti/istrobot/laserus/3Orbis/main.h
0,0 → 1,18
#include <16F88.h>
#device adc=8
 
#FUSES NOWDT //No Watch Dog Timer
#FUSES INTRC_IO
#FUSES NOPUT //No Power Up Timer
#FUSES MCLR //Master Clear pin enabled
#FUSES NOBROWNOUT //Reset when brownout detected
#FUSES NOLVP //Low Voltage Programming on B3(PIC16) or B5(PIC18)
#FUSES NOCPD //No EE protection
#FUSES NOWRT //Program memory not write protected
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOFCMEN //Fail-safe clock monitor enabled
#FUSES NOIESO //Internal External Switch Over mode enabled
 
#use delay(clock=8000000,RESTART_WDT)
 
/roboti/istrobot/laserus/3Orbis/main.sta
0,0 → 1,35
 
ROM used: 1154 (28%)
1154 (28%) including unused fragments
 
2 Average locations per line
3 Average locations per statement
 
RAM used: 32 (18%) at main() level
35 (20%) worst case
 
Lines Stmts % Files
----- ----- --- -----
289 190 49 D:\KAKLIK\programy\PIC_C\roboti\3Orbis\main.c
19 0 0 D:\KAKLIK\programy\PIC_C\roboti\3Orbis\main.h
279 0 0 C:\Program Files\PICC\devices\16F88.h
140 200 34 D:\KAKLIK\programy\PIC_C\roboti\3Orbis\objizdka_centrovani_R.c
----- -----
1454 780 Total
 
Page ROM % RAM Functions:
---- --- --- --- ----------
0 24 2 1 @delay_ms1
0 16 1 1 @delay_us1
0 30 3 2 TIMER2_isr
0 221 19 2 cikcak
0 274 24 1 objizdka
0 534 46 7 main
 
Segment Used Free
--------- ---- ----
00000-00003 4 0
00004-00036 51 0
00037-007FF 1099 894
00800-00FFF 0 2048
 
/roboti/istrobot/laserus/3Orbis/main.tre
0,0 → 1,36
ÀÄmain
ÃÄmain 0/534 Ram=7
³ ÃÄ??0??
³ ÃÄ@delay_ms1 0/24 Ram=1
³ ÃÄ@delay_ms1 0/24 Ram=1
³ ÃÄ@delay_ms1 0/24 Ram=1
³ ÃÄ@delay_ms1 0/24 Ram=1
³ ÃÄ@delay_us1 0/16 Ram=1
³ ÃÄ@delay_ms1 0/24 Ram=1
³ ÃÄ@delay_ms1 0/24 Ram=1
³ ÃÄ@delay_ms1 0/24 Ram=1
³ ÃÄcikcak 0/221 Ram=2
³ ³ ÃÄ@delay_ms1 0/24 Ram=1
³ ³ ÃÄ@delay_ms1 0/24 Ram=1
³ ³ ÀÄ@delay_ms1 0/24 Ram=1
³ ÃÄ@delay_ms1 0/24 Ram=1
³ ÃÄobjizdka 0/274 Ram=1
³ ³ ÃÄ@delay_ms1 0/24 Ram=1
³ ³ ÃÄ@delay_ms1 0/24 Ram=1
³ ³ ÃÄ@delay_ms1 0/24 Ram=1
³ ³ ÃÄ@delay_ms1 0/24 Ram=1
³ ³ ÃÄ@delay_ms1 0/24 Ram=1
³ ³ ÃÄ@delay_ms1 0/24 Ram=1
³ ³ ÃÄ@delay_ms1 0/24 Ram=1
³ ³ ÃÄ@delay_ms1 0/24 Ram=1
³ ³ ÃÄ@delay_ms1 0/24 Ram=1
³ ³ ÃÄ@delay_ms1 0/24 Ram=1
³ ³ ÃÄ@delay_ms1 0/24 Ram=1
³ ³ ÀÄcikcak 0/221 Ram=2
³ ³ ÃÄ@delay_ms1 0/24 Ram=1
³ ³ ÃÄ@delay_ms1 0/24 Ram=1
³ ³ ÀÄ@delay_ms1 0/24 Ram=1
³ ÃÄ@delay_ms1 0/24 Ram=1
³ ÀÄ@delay_ms1 0/24 Ram=1
ÀÄTIMER2_isr 0/30 Ram=2
ÀÄ@delay_us1 0/16 Ram=1
/roboti/istrobot/laserus/3Orbis/objizdka_centrovani.BAK
0,0 → 1,131
#define DOLEVA 0
#define DOPRAVA 1
 
void cikcak()
{
unsigned int8 i=0;
 
uhel=KOLMO1; // aby se dalo tocit na miste
Delay_ms(100);
 
if (line==L2) line=L3; // poznamenej, kde byla cara pred brzdenim
if (line==S) line=L3;
if (line==R2) line=R3;
 
Delay_ms(3); // prodleva na cteni senzoru pred prenosem
 
output_low(STROBE); // zapni zobrazovani na posuvnem registru
sensors = spi_read(0); // cteni senzoru
sensors=~sensors;
output_high(STROBE); // vypni zobrazovani na posuvnem registru
 
while(true)
{
Delay_ms(3);
 
if (line==L3)
{
GO(L,B,160);GO(R,F,160);
};
if (line==R3)
{
GO(R,B,160);GO(L,F,160);
};
if (line==S) {STOPL;STOPR; i++;} else i=0;
 
if (i>=100) break; // pokud je dostatecne dlouho cara vprostred, vypadni
 
output_low(STROBE); // zapni zobrazovani na posuvnem registru
sensors = spi_read(0); // cteni senzoru
sensors=~sensors;
output_high(STROBE); // vypni zobrazovani na posuvnem registru
 
if(bit_test(sensors,3)) //...|...//
{
line=S;
continue;
}
 
if(bit_test(sensors,0)) //|......// // z duvodu zkraceni doby reakce se cidla nevyhodnocuji poporade ale od krajnich k prostrednimu
{
line=L3;
continue;
}
 
if(bit_test(sensors,6)) //......|//
{
line=R3;
continue;
}
 
if(bit_test(sensors,1)) //.|.....//
{
line=L3;
continue;
}
 
if(bit_test(sensors,5)) //.....|.//
{
line=R3;
continue;
}
 
if (bit_test(sensors,2)) //..|....//
{
line=L3;
continue;
}
 
if (bit_test(sensors,4)) //....|..//
{
line=R3;
continue;
}
}
}
////////////////////////////////////////////////////////////////////////////////
void objizdka()
{
BL;FR;
Delay_ms(300);
FL;BR;
Delay_ms(100);
STOPL;STOPR;
 
uhel=STRED;
FL;FR;
Delay_ms(360); // rovne
 
uhel=STRED+55;
STOPR;FL;
Delay_ms(190); // doprava
 
uhel=STRED;
FR;FL;
Delay_ms(300); // rovne
 
uhel=STRED+55;
FL;STOPR;
Delay_ms(190); // doprava
 
uhel=STRED;
FR;FL;
Delay_ms(60); // rovne
 
While((sensors & 0b11111110)!=0) //dokud neni cara
{
sensors = spi_read(0); // cteni senzoru
sensors=~sensors;
Delay_ms(3); // cekani na SLAVE nez pripravi data od cidel
}
BL;BR;
Delay_ms(300);
 
uhel=STRED-55;
FR;STOPL; // doleva
delay_ms(250);
 
line=L3;
cikcak();
}
 
/roboti/istrobot/laserus/3Orbis/objizdka_centrovani.c
0,0 → 1,131
#define DOLEVA 0
#define DOPRAVA 1
 
void cikcak()
{
unsigned int8 i=0;
 
uhel=KOLMO1; // aby se dalo tocit na miste
Delay_ms(100);
 
if (line==L2) line=L3; // poznamenej, kde byla cara pred brzdenim
if (line==S) line=L3;
if (line==R2) line=R3;
 
Delay_ms(3); // prodleva na cteni senzoru pred prenosem
 
output_low(STROBE); // zapni zobrazovani na posuvnem registru
sensors = spi_read(0); // cteni senzoru
sensors=~sensors;
output_high(STROBE); // vypni zobrazovani na posuvnem registru
 
while(true)
{
Delay_ms(3);
 
if (line==L3)
{
GO(L,B,160);GO(R,F,160);
};
if (line==R3)
{
GO(R,B,160);GO(L,F,160);
};
if (line==S) {STOPL;STOPR; i++;} else i=0;
 
if (i>=100) break; // pokud je dostatecne dlouho cara vprostred, vypadni
 
output_low(STROBE); // zapni zobrazovani na posuvnem registru
sensors = spi_read(0); // cteni senzoru
sensors=~sensors;
output_high(STROBE); // vypni zobrazovani na posuvnem registru
 
if(bit_test(sensors,3)) //...|...//
{
line=S;
continue;
}
 
if(bit_test(sensors,0)) //|......// // z duvodu zkraceni doby reakce se cidla nevyhodnocuji poporade ale od krajnich k prostrednimu
{
line=L3;
continue;
}
 
if(bit_test(sensors,6)) //......|//
{
line=R3;
continue;
}
 
if(bit_test(sensors,1)) //.|.....//
{
line=L3;
continue;
}
 
if(bit_test(sensors,5)) //.....|.//
{
line=R3;
continue;
}
 
if (bit_test(sensors,2)) //..|....//
{
line=L3;
continue;
}
 
if (bit_test(sensors,4)) //....|..//
{
line=R3;
continue;
}
}
}
////////////////////////////////////////////////////////////////////////////////
void objizdka()
{
BL;FR;
Delay_ms(300);
FL;BR;
Delay_ms(100);
STOPL;STOPR;
 
uhel=STRED;
FL;FR;
Delay_ms(360); // rovne
 
uhel=STRED+55;
STOPR;FL;
Delay_ms(190); // doprava
 
uhel=STRED;
FR;FL;
Delay_ms(300); // rovne
 
uhel=STRED+55;
FL;STOPR;
Delay_ms(190); // doprava
 
uhel=STRED;
FR;FL;
Delay_ms(200); // rovne
 
While((sensors & 0b11111110)!=0) //dokud neni cara
{
sensors = spi_read(0); // cteni senzoru
sensors=~sensors;
Delay_ms(3); // cekani na SLAVE nez pripravi data od cidel
}
BL;BR;
Delay_ms(300);
 
uhel=STRED-55;
FR;STOPL; // doleva
delay_ms(250);
 
line=L3;
cikcak();
}
 
/roboti/istrobot/laserus/3Orbis/objizdka_centrovani_R.BAK
0,0 → 1,139
#define DOLEVA 0
#define DOPRAVA 1
 
void cikcak()
{
unsigned int8 i=0;
 
uhel=KOLMO1; // aby se dalo tocit na miste
Delay_ms(100);
 
if (line==L2) line=L3; // poznamenej, kde byla cara pred brzdenim
if (line==S) line=L3;
if (line==R2) line=R3;
 
Delay_ms(3); // prodleva na cteni senzoru pred prenosem
 
output_low(STROBE); // zapni zobrazovani na posuvnem registru
sensors = spi_read(0); // cteni senzoru
sensors=~sensors;
output_high(STROBE); // vypni zobrazovani na posuvnem registru
 
while(true)
{
Delay_ms(3);
 
if (line==L3)
{
GO(L,B,160);GO(R,F,160);
};
if (line==R3)
{
GO(R,B,160);GO(L,F,160);
};
if (line==S) {STOPL;STOPR; i++;} else i=0;
 
if (i>=100) break; // pokud je dostatecne dlouho cara vprostred, vypadni
 
output_low(STROBE); // zapni zobrazovani na posuvnem registru
sensors = spi_read(0); // cteni senzoru
sensors=~sensors;
output_high(STROBE); // vypni zobrazovani na posuvnem registru
 
if(bit_test(sensors,3)) //...|...//
{
line=S;
continue;
}
 
if(bit_test(sensors,0)) //|......// // z duvodu zkraceni doby reakce se cidla nevyhodnocuji poporade ale od krajnich k prostrednimu
{
line=L3;
continue;
}
 
if(bit_test(sensors,6)) //......|//
{
line=R3;
continue;
}
 
if(bit_test(sensors,1)) //.|.....//
{
line=L3;
continue;
}
 
if(bit_test(sensors,5)) //.....|.//
{
line=R3;
continue;
}
 
if (bit_test(sensors,2)) //..|....//
{
line=L3;
continue;
}
 
if (bit_test(sensors,4)) //....|..//
{
line=R3;
continue;
}
}
}
////////////////////////////////////////////////////////////////////////////////
void objizdka()
{
FL;BR; // doprava 90
Delay_ms(300);
BL;FR; // brzdi z toceni
Delay_ms(100);
STOPL;STOPR;
 
uhel=STRED;
FL;FR;
Delay_ms(370); // rovne
 
uhel=STRED-55;
STOPL;FR;
Delay_ms(190); // doleva
 
uhel=STRED;
FR;FL;
Delay_ms(300); // rovne
 
uhel=STRED-55;
FR;STOPL;
Delay_ms(190); // doleva
 
uhel=STRED;
FR;FL;
Delay_ms(100); // rovne
 
While((sensors & 0b11111110)!=0) //dokud neni cara
{
sensors = spi_read(0); // cteni senzoru
sensors=~sensors;
Delay_ms(3); // cekani na SLAVE nez pripravi data od cidel
}
BL;BR; // zabrzdi
Delay_ms(250);
 
uhel=KOLMO1;
FL;BR; // doprava
While((sensors & 0b11111110)!=0) //dokud neni cara
{
sensors = spi_read(0); // cteni senzoru
sensors=~sensors;
Delay_ms(3); // cekani na SLAVE nez pripravi data od cidel
}
STOPL;STOPR; // zabrzdi
Delay_ms(300);
// delay_ms(250);
 
line=R3;
cikcak();
}
 
/roboti/istrobot/laserus/3Orbis/objizdka_centrovani_R.c
0,0 → 1,139
#define DOLEVA 0
#define DOPRAVA 1
 
void cikcak()
{
unsigned int8 i=0;
 
uhel=KOLMO1; // aby se dalo tocit na miste
Delay_ms(100);
 
if (line==L2) line=L3; // poznamenej, kde byla cara pred brzdenim
if (line==S) line=L3;
if (line==R2) line=R3;
 
Delay_ms(3); // prodleva na cteni senzoru pred prenosem
 
output_low(STROBE); // zapni zobrazovani na posuvnem registru
sensors = spi_read(0); // cteni senzoru
sensors=~sensors;
output_high(STROBE); // vypni zobrazovani na posuvnem registru
 
while(true)
{
Delay_ms(3);
 
if (line==L3)
{
GO(L,B,160);GO(R,F,160);
};
if (line==R3)
{
GO(R,B,160);GO(L,F,160);
};
if (line==S) {STOPL;STOPR; i++;} else i=0;
 
if (i>=100) break; // pokud je dostatecne dlouho cara vprostred, vypadni
 
output_low(STROBE); // zapni zobrazovani na posuvnem registru
sensors = spi_read(0); // cteni senzoru
sensors=~sensors;
output_high(STROBE); // vypni zobrazovani na posuvnem registru
 
if(bit_test(sensors,3)) //...|...//
{
line=S;
continue;
}
 
if(bit_test(sensors,0)) //|......// // z duvodu zkraceni doby reakce se cidla nevyhodnocuji poporade ale od krajnich k prostrednimu
{
line=L3;
continue;
}
 
if(bit_test(sensors,6)) //......|//
{
line=R3;
continue;
}
 
if(bit_test(sensors,1)) //.|.....//
{
line=L3;
continue;
}
 
if(bit_test(sensors,5)) //.....|.//
{
line=R3;
continue;
}
 
if (bit_test(sensors,2)) //..|....//
{
line=L3;
continue;
}
 
if (bit_test(sensors,4)) //....|..//
{
line=R3;
continue;
}
}
}
////////////////////////////////////////////////////////////////////////////////
void objizdka()
{
FL;BR; // doprava 90
Delay_ms(300);
BL;FR; // brzdi z toceni
Delay_ms(100);
STOPL;STOPR;
 
uhel=STRED;
FL;FR;
Delay_ms(380); // rovne
 
uhel=STRED-55;
STOPL;FR;
Delay_ms(190); // doleva
 
uhel=STRED;
FR;FL;
Delay_ms(300); // rovne
 
uhel=STRED-55;
FR;STOPL;
Delay_ms(190); // doleva
 
uhel=STRED;
FR;FL;
Delay_ms(100); // rovne
 
While((sensors & 0b11111110)!=0) //dokud neni cara
{
sensors = spi_read(0); // cteni senzoru
sensors=~sensors;
Delay_ms(3); // cekani na SLAVE nez pripravi data od cidel
}
BL;BR; // zabrzdi
Delay_ms(250);
 
uhel=KOLMO1;
FL;BR; // doprava
While((sensors & 0b11111110)!=0) //dokud neni cara
{
sensors = spi_read(0); // cteni senzoru
sensors=~sensors;
Delay_ms(3); // cekani na SLAVE nez pripravi data od cidel
}
STOPL;STOPR; // zabrzdi
Delay_ms(300);
// delay_ms(250);
 
line=R3;
cikcak();
}
 
/roboti/istrobot/laserus/3Orbis/objizdka_cidla.c
0,0 → 1,64
void objizdka()
{
int8 shure=0;
unsigned int16 n;
 
// toceni na miste dokud nezmizi cihla
//------------------------------------
uhel=KOLMO1; // nastav zataceci kolecko kolmo na osu robota
Delay_ms(100);
BL;FR;
Delay_ms(200); // minimalni toceni, kdyby se zastavilo sikmo k cihle
 
While(bit_test(sensors,7)) // toc, dokud neni cihla z primeho senzoru
{
sensors = spi_read(0); // cteni senzoru
sensors=~sensors;
Delay_ms(4); // cekani na SLAVE nez pripravi data od cidel
}
STOPL; STOPR;
 
for (n=0;n<1000;n++) // vystred se na hranu cihly
{
if(!input(CIHLA))
{
GO(L,B,180);GO(R,F,160); // zapni motory PWM podle promenych Lmotor a Rmotor
} else
{
GO(L,F,180);GO(R,B,160); // zapni motory PWM podle promenych Lmotor a Rmotor
};
delay_ms(1);
}
STOPR;STOPL;
 
uhel=STRED; // dopredu
delay_ms(100);
FR; FL;
delay_ms(500);
BL;BR;
delay_ms(200);
STOPL;STOPR;
 
uhel=STRED+BEAR3; // doprava
delay_ms(100);
FL;
delay_ms(400);
uhel=STRED+BEAR2; // min doprava
FL;FR;
delay_ms(100);
uhel=STRED+BEAR1; // jeste min doprava
FL;FR;
delay_ms(200);
While((sensors & 0b11111110)!=0) //dokud neni cara
{
sensors = spi_read(0); // cteni senzoru
sensors=~sensors;
Delay_ms(4); // cekani na SLAVE nez pripravi data od cidel
}
BL; BR;
delay_ms(400);
 
uhel=STRED-BEAR3; // doleva
}
 
////////////////////////////////////////////////////////////////////////////////
/roboti/istrobot/laserus/873/Reg.H
0,0 → 1,298
// Komplete definition of all Special Feature Registers
// of PIC16F87 and PIC16F88
// (c)miho 2005
 
#nolist
 
// SFR Registers in Memory Bank 0
#byte INDF = 0x00
#byte TMR0 = 0x01
#byte PCL = 0x02
#byte STATUS = 0x03
#bit IRP = STATUS.7
#bit RP1 = STATUS.6
#bit RP0 = STATUS.5
#bit TO = STATUS.4
#bit PD = STATUS.3
#bit Z = STATUS.2
#bit DC = STATUS.1
#bit C = STATUS.0
#byte FSR = 0x04
#byte PORTA = 0x05
#byte PORTB = 0x06
#byte PCLATH = 0x0A
#byte INTCON = 0x0B
#bit GIE = INTCON.7
#bit PEIE = INTCON.6
#bit TMR0IE = INTCON.5
#bit INT0IE = INTCON.4
#bit RBIE = INTCON.3
#bit TMR0IF = INTCON.2
#bit INT0IF = INTCON.1
#bit RBIF = INTCON.0
#byte PIR1 = 0x0C
#bit ADIF = PIR1.6
#bit RCIF = PIR1.5
#bit TXIF = PIR1.4
#bit SSPIF = PIR1.3
#bit CCP1IF = PIR1.2
#bit TMR2IF = PIR1.1
#bit TMR1IF = PIR1.0
#byte PIR2 = 0x0D
#bit OSFIF = PIR2.7
#bit CMIF = PIR2.6
#bit EEIF = PIR2.4
#byte TMR1L = 0x0E
#byte TMR1H = 0x0F
#byte T1CON = 0x10
#bit T1RUN = T1CON.6
#bit T1CKPS1 = T1CON.5
#bit T1CKPS0 = T1CON.4
#bit T1OSCEN = T1CON.3
#bit T1SYNC = T1CON.2
#bit TMR1CS = T1CON.1
#bit TMR1ON = T1CON.0
#byte TMR2 = 0x11
#byte T2CON = 0x12
#bit TOUTPS3 = T2CON.6
#bit TOUTPS2 = T2CON.5
#bit TOUTPS1 = T2CON.4
#bit TOUTPS0 = T2CON.3
#bit TMR2ON = T2CON.2
#bit T2CKPS1 = T2CON.1
#bit T2CKPS0 = T2CON.0
#byte SSPBUF = 0x13
#byte SSPCON1 = 0x14
#bit WCOL = SSPCON1.7
#bit SSPOV = SSPCON1.6
#bit SSPEN = SSPCON1.5
#bit CKP = SSPCON1.4
#bit SSPM3 = SSPCON1.3
#bit SSPM2 = SSPCON1.2
#bit SSPM1 = SSPCON1.1
#bit SSPM0 = SSPCON1.0
#byte CCPR1L = 0x15
#byte CCPR1H = 0x16
#byte CCP1CON = 0x17
#bit CCP1X = CCP1CON.5
#bit CCP1Y = CCP1CON.4
#bit CCP1M3 = CCP1CON.3
#bit CCP1M2 = CCP1CON.2
#bit CCP1M1 = CCP1CON.1
#bit CCP1M0 = CCP1CON.0
#byte RCSTA = 0x18
#bit SPEN = RCSTA.7
#bit RX9 = RCSTA.6
#bit SREN = RCSTA.5
#bit CREN = RCSTA.4
#bit ADDEN = RCSTA.3
#bit FERR = RCSTA.2
#bit OERR = RCSTA.1
#bit RX9D = RCSTA.0
#byte TXREG = 0x19
#byte RCREG = 0x1A
#byte ADRESH = 0x1E // F88 only
#byte ADCON0 = 0x1F // F88 only
#bit ADCS1 = ADCON0.7
#bit ADCS0 = ADCON0.6
#bit CHS2 = ADCON0.5
#bit CHS1 = ADCON0.4
#bit CHS0 = ADCON0.3
#bit GO = ADCON0.2
#bit ADON = ADCON0.0
 
// SFR Registers in Memory Bank 1
#byte INDF_1 = 0x80 // miror
#byte OPTION = 0x81
#bit RBPU = OPTION.7
#bit INTEDG = OPTION.6
#bit T0CS = OPTION.5
#bit T0SE = OPTION.4
#bit PSA = OPTION.3
#bit PS2 = OPTION.2
#bit PS1 = OPTION.1
#bit PS0 = OPTION.0
#byte PCL = 0x82
#byte STATUS_1 = 0x83 // mirror
#bit IRP_1 = STATUS_1.7
#bit RP1_1 = STATUS_1.6
#bit RP0_1 = STATUS_1.5
#bit TO_1 = STATUS_1.4
#bit PD_1 = STATUS_1.3
#bit Z_1 = STATUS_1.2
#bit DC_1 = STATUS_1.1
#bit C_1 = STATUS_1.0
#byte FSR = 0x84
#byte TRISA = 0x85
#byte TRISB = 0x86
#byte PCLATH_1 = 0x8A // mirror
#byte INTCON_1 = 0x8B // mirror
#bit GIE_1 = INTCON_1.7
#bit PEIE_1 = INTCON_1.6
#bit TMR0IE_1 = INTCON_1.5
#bit INT0IE_1 = INTCON_1.4
#bit RBIE_1 = INTCON_1.3
#bit TMR0IF_1 = INTCON_1.2
#bit INT0IF_1 = INTCON_1.1
#bit RBIF_1 = INTCON_1.0
#byte PIE1 = 0x8C
#bit ADIE = PIE1.6
#bit RCIE = PIE1.5
#bit TXIE = PIE1.4
#bit SSPIE = PIE1.3
#bit CCP1IE = PIE1.2
#bit TMR2IE = PIE1.1
#bit TMR1IE = PIE1.0
#byte PIE2 = 0x8D
#bit OSFIE = PIE2.7
#bit CMIE = PIE2.6
#bit EEIE = PIE2.4
#byte PCON = 0x8E
#bit POR = PCON.1
#bit BOR = PCON.0
#byte OSCCON = 0x8F
#bit IRCF2 = OSCCON.6
#bit IRCF1 = OSCCON.5
#bit IRCF0 = OSCCON.4
#bit OSTS = OSCCON.3
#bit IOFS = OSCCON.2
#bit SCS1 = OSCCON.1
#bit SCS0 = OSCCON.0
#byte OSCTUNE = 0x90
#bit TUN5 = OSCTUNE.5
#bit TUN4 = OSCTUNE.4
#bit TUN3 = OSCTUNE.3
#bit TUN2 = OSCTUNE.2
#bit TUN1 = OSCTUNE.1
#bit TUN0 = OSCTUNE.0
#byte PR2 = 0x92
#byte SSPADD = 0x93
#byte SSPSTAT = 0x94
#bit SMP = SSPSTAT.7
#bit CKE = SSPSTAT.6
#bit DA = SSPSTAT.5
#bit P = SSPSTAT.4
#bit S = SSPSTAT.3
#bit RW = SSPSTAT.2
#bit UA = SSPSTAT.1
#bit BF = SSPSTAT.0
#byte TXSTA = 0x98
#bit CSRC = TXSTA.7
#bit TX9 = TXSTA.6
#bit TXEN = TXSTA.5
#bit SYNC = TXSTA.4
#bit BRGH = TXSTA.2
#bit TRMT = TXSTA.1
#bit TX9D = TXSTA.0
#byte SPBRG = 0x99
#byte ANSEL = 0x9B // F88 only
#bit ANS6 = ANSEL.6
#bit ANS5 = ANSEL.5
#bit ANS4 = ANSEL.4
#bit ANS3 = ANSEL.3
#bit ANS2 = ANSEL.2
#bit ANS1 = ANSEL.1
#bit ANS0 = ANSEL.0
#byte CMCON = 0x9C
// #bit C2OUT = CMCON.7
// #bit C1OUT = CMCON.6
#bit C2INV = CMCON.5
#bit C1INV = CMCON.4
#bit CIS = CMCON.3
#bit CM2 = CMCON.2
#bit CM1 = CMCON.1
#bit CM0 = CMCON.0
#byte CVRCON = 0x9D
#bit CVREN = CVRCON.7
#bit CVROE = CVRCON.6
#bit CVRR = CVRCON.5
#bit CVR3 = CVRCON.3
#bit CVR2 = CVRCON.2
#bit CVR1 = CVRCON.1
#bit CVR0 = CVRCON.0
#byte ADRESL = 0x9E // F88 only
#byte ADCON1 = 0x9F // F88 only
#bit ADFM = ADCON1.7
#bit ADCS2 = ADCON1.6
#bit VCFG1 = ADCON1.5
#bit VCFG0 = ADCON1.4
 
// SFR Registers in Memory Bank 2
#byte INDF_2 = 0x100 // mirror
#byte TMR0_2 = 0x101 // mirror
#byte PCL_2 = 0x102 // mirror
#byte STATUS_2 = 0x103 // mirror
#bit IRP_2 = STATUS_2.7
#bit RP1_2 = STATUS_2.6
#bit RP0_2 = STATUS_2.5
#bit TO_2 = STATUS_2.4
#bit PD_2 = STATUS_2.3
#bit Z_2 = STATUS_2.2
#bit DC_2 = STATUS_2.1
#bit C_2 = STATUS_2.0
#byte FSR_2 = 0x104 // mirror
#byte WDTCON = 0x105
#bit WDTPS3 = WDTCON.4
#bit WDTPS2 = WDTCON.3
#bit WDTPS1 = WDTCON.2
#bit WDTPS0 = WDTCON.1
#bit SWDTEN = WDTCON.0
#byte PORTB_2 = 0x106 // mirror
#byte PCLATH_2 = 0x10A // mirror
#byte INTCON_2 = 0x10B // mirror
#bit GIE_2 = INTCON_2.7
#bit PEIE_2 = INTCON_2.6
#bit TMR0IE_2 = INTCON_2.5
#bit INT0IE_2 = INTCON_2.4
#bit RBIE_2 = INTCON_2.3
#bit TMR0IF_2 = INTCON_2.2
#bit INT0IF_2 = INTCON_2.1
#bit RBIF_2 = INTCON_2.0
#byte EEDATA = 0x10C
#byte EEADR = 0x10D
#byte EEDATH = 0x10E
#byte EEADRH = 0x10F
 
// SFR Registers in Memory Bank 3
#byte INDF_3 = 0x180 // mirror
#byte OPTION_3 = 0x181 // mirror
#bit RBPU_3 = OPTION_3.7
#bit INTEDG_3 = OPTION_3.6
#bit T0CS_3 = OPTION_3.5
#bit T0SE_3 = OPTION_3.4
#bit PSA_3 = OPTION_3.3
#bit PS2_3 = OPTION_3.2
#bit PS1_3 = OPTION_3.1
#bit PS0_3 = OPTION_3.0
#byte PCL_3 = 0x182 // mirror
#byte STATUS_3 = 0x183 // mirror
#bit IRP_3 = STATUS_3.7
#bit RP1_3 = STATUS_3.6
#bit RP0_3 = STATUS_3.5
#bit TO_3 = STATUS_3.4
#bit PD_3 = STATUS_3.3
#bit Z_3 = STATUS_3.2
#bit DC_3 = STATUS_3.1
#bit C_3 = STATUS_3.0
#byte FSR_3 = 0x184 // mirror
#byte TRISB_3 = 0x186 // mirror
#byte PLATH_3 = 0x18A // mirror
#byte INTCON_3 = 0x18B // mirror
#bit GIE_3 = INTCON_3.7
#bit PEIE_3 = INTCON_3.6
#bit TMR0IE_3 = INTCON_3.5
#bit INT0IE_3 = INTCON_3.4
#bit RBIE_3 = INTCON_3.3
#bit TMR0IF_3 = INTCON_3.2
#bit INT0IF_3 = INTCON_3.1
#bit RBIF_3 = INTCON_3.0
#byte EECON1 = 0x18C
#bit EEPGD = EECON1.7
#bit FREE = EECON1.4
#bit WRERR = EECON1.3
#bit WREN = EECON1.2
#bit WR = EECON1.1
#bit RD = EECON1.0
#byte EECON2 = 0x18D
 
#list
/roboti/istrobot/laserus/873/ble/laserus.PJT
0,0 → 1,35
[PROJECT]
Target=laserus.HEX
Development_Mode=
Processor=0x003F
ToolSuite=CCS
 
[Directories]
Include=C:\Program Files\PICC\devices\;C:\Program Files\PICC\Dr
Library=
LinkerScript=
 
[Target Data]
FileList=laserus.c;
BuildTool=C-COMPILER
OptionString=+FM
AdditionalOptionString=
BuildRequired=1
 
[laserus.c]
Type=4
Path=
FileList=
BuildTool=
OptionString=
AdditionalOptionString=
 
[mru-list]
1=laserus.c
 
[Windows]
0=0000 laserus.c 0 0 796 451 3 0
 
[Opened Files]
1=C:\PIC\laserus\873\ble\laserus.c
2=
/roboti/istrobot/laserus/873/ble/laserus.c
0,0 → 1,22
#include "C:\PIC\laserus\873\ble\laserus.h"
#int_EXT
EXT_isr()
{
 
}
 
 
 
void main()
{
 
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_spi(FALSE);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DIV_BY_4,255,1);
enable_interrupts(INT_EXT);
enable_interrupts(GLOBAL);
 
}
/roboti/istrobot/laserus/873/ble/laserus.h
0,0 → 1,15
#include <16F873.h>
#device adc=8
 
#FUSES NOWDT //No Watch Dog Timer
#FUSES XT //Crystal osc <= 4mhz
#FUSES NOPUT //No Power Up Timer
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD //No EE protection
#FUSES NOWRT //Program memory not write protected
#FUSES NODEBUG //No Debug mode for ICD
 
#use delay(clock=4000000)
 
/roboti/istrobot/laserus/873/laserus.BAK
0,0 → 1,130
#include "laserus.h"
 
#define SERVO PIN_B5 // Vystup pro rizeni serva
#define LASER PIN_B4 // Vstup pro cteni laseru
 
#define MOT_DIR_L PIN_C0 // Rizeni smeru otaceni motoru
#define MOT_DIR_R PIN_C3
 
// kroutitka
#define CERVENA 0 // AN0
#define CERNA 1 // AN1
//#define ZELENA 3 // AN3
//#define MODRA 4 // AN4
 
#byte INTCON = 0x0B // Interrupt configuration register
#bit GIE = INTCON.7
#bit PEIE = INTCON.6
#bit TMR0IE = INTCON.5
#bit INT0IE = INTCON.4
#bit RBIE = INTCON.3
#bit TMR0IF = INTCON.2
#bit INT0IF = INTCON.1
#bit RBIF = INTCON.0
 
boolean edge;
int8 uhel, olduhel;
int16 uhel16;
 
#int_EXT
EXT_isr()
{
int n, t1, t2, t;
 
set_timer0(0); // Vynulovani casovace pro 2ms
output_high(SERVO);
while(get_timer0()<(1000/256)); // Ceka 1ms
for(n=uhel; n>0; n--) delay_us(3); // Sirka impulzu podle uhlu
output_low(SERVO);
while(get_timer0()<(3000/256)); // Ceka do 3ms, nez zacne scanovat
 
set_timer0(0); // Vynulovani casovace pro zjisteni polohy cary
if(edge) // Zrcatko prejizdelo tam nebo zpet?
{
edge=false;
ext_int_edge(H_TO_L); // Pristi inerrupt bude od opacne hrany
INT0IF=0; // Povoleni dalsiho preruseni
enable_interrupts(INT_EXT);
enable_interrupts(GLOBAL);
// do
{
while(0==input(LASER)); // Ceka na detekci cary
// output_high(SERVO);
t1=get_timer0(); // Poznamena cas nabezne hrany
while(1==input(LASER)); // Ceka az zkonci cara
// output_low(SERVO);
t2=get_timer0(); // Poznamena cas sestupne hrany
t=t2-t1;
} while((t<3) || (t>20)); // Cara je detekovana, kdyz trva mezi xx ms
// if ((t>3) && (t<20)) uhel=(160-(read_adc()>>2))-t1;
if (abs(olduhel-uhel)<40)
{
uhel=(160-(read_adc()>>2))-t1;
olduhel=uhel;
};
// uhel16=uhel;
// set_pwm1_duty(250-(uhel16<<2)); // Elektronicky diferencial
// set_pwm2_duty((uhel16));
set_adc_channel(CERNA);
}
else
{
edge=true;
ext_int_edge(L_TO_H); // Pristi inerrupt bude od opacne hrany
INT0IF=0; // Povoleni dalsiho preruseni
enable_interrupts(INT_EXT);
enable_interrupts(GLOBAL);
// do
{
while(0==input(LASER)); // Ceka na detekci cary
t1=get_timer0(); // Poznamena cas nabezne hrany
while(1==input(LASER)); // Ceka az zkonci cara
t2=get_timer0(); // Poznamena cas sestupne hrany
t=t2-t1;
} while((t<3) || (t>20)); // Cara je detekovana, kdyz trva mezi xx ms
if (abs(olduhel-uhel)<40)
{
// uhel=((read_adc()>>2)+32)+t1;
// olduhel=uhel;
};
set_adc_channel(CERVENA);
}
while(true);
}
 
 
 
void main()
{
 
setup_adc_ports(ALL_ANALOG); // Analogove vstupy pro cteni trimru
setup_adc(ADC_CLOCK_INTERNAL);
setup_spi(FALSE);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_256); // Casovac pro cteni laseru
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DIV_BY_4,255,1); // Casovac pro PWM cca 900Hz
setup_ccp1(CCP_PWM); // Nastaveni PWM pro diferencial RC1, RC2
setup_ccp2(CCP_PWM);
 
set_pwm1_duty(90); // Zastaveni PWM
set_pwm2_duty(90);
 
delay_ms(100);
set_adc_channel(CERVENA);
Delay_ms(1);
 
ext_int_edge(L_TO_H);
edge=true;
uhel=((read_adc()>>2)+32)+30;
olduhel=uhel;
 
enable_interrupts(INT_EXT);
enable_interrupts(GLOBAL);
 
delay_ms(1000);
 
output_high(MOT_DIR_L); // Oba motory vpred
output_high(MOT_DIR_R);
 
while(true);
}
/roboti/istrobot/laserus/873/laserus.PJT
0,0 → 1,40
[PROJECT]
Target=laserus.HEX
Development_Mode=
Processor=0x873F
ToolSuite=CCS
 
[Directories]
Include=C:\Program Files\PICC\devices\;C:\Program Files\PICC\Dr
Library=
LinkerScript=
 
[Target Data]
FileList=C:\PIC\laserus\873\laserus.c
BuildTool=C-COMPILER
OptionString=+FM
AdditionalOptionString=
BuildRequired=1
 
[laserus.c]
Type=4
Path=
FileList=
BuildTool=
OptionString=
AdditionalOptionString=
 
[mru-list]
1=laserus.c
 
[Windows]
0=0000 laserus.c 0 0 796 451 3 0
 
[Opened Files]
1=C:\PIC\laserus\873\laserus.c
2=C:\PIC\laserus\873\laserus.h
3=C:\Program Files\PICC\devices\16F873.h
4=
[Units]
Count=1
1=C:\PIC\laserus\873\laserus.c (main)
/roboti/istrobot/laserus/873/laserus.c
0,0 → 1,130
#include "laserus.h"
 
#define SERVO PIN_B5 // Vystup pro rizeni serva
#define LASER PIN_B4 // Vstup pro cteni laseru
 
#define MOT_DIR_L PIN_C0 // Rizeni smeru otaceni motoru
#define MOT_DIR_R PIN_C3
 
// kroutitka
#define CERVENA 0 // AN0
#define CERNA 1 // AN1
//#define ZELENA 3 // AN3
//#define MODRA 4 // AN4
 
#byte INTCON = 0x0B // Interrupt configuration register
#bit GIE = INTCON.7
#bit PEIE = INTCON.6
#bit TMR0IE = INTCON.5
#bit INT0IE = INTCON.4
#bit RBIE = INTCON.3
#bit TMR0IF = INTCON.2
#bit INT0IF = INTCON.1
#bit RBIF = INTCON.0
 
boolean edge;
int8 uhel, olduhel;
int16 uhel16;
 
#int_EXT
EXT_isr()
{
int n, t1, t2, t;
 
set_timer0(0); // Vynulovani casovace pro 2ms
output_high(SERVO);
while(get_timer0()<(1000/256)); // Ceka 1ms
for(n=uhel; n>0; n--) delay_us(3); // Sirka impulzu podle uhlu
output_low(SERVO);
while(get_timer0()<(3000/256)); // Ceka do 3ms, nez zacne scanovat
 
set_timer0(0); // Vynulovani casovace pro zjisteni polohy cary
if(edge) // Zrcatko prejizdelo tam nebo zpet?
{
edge=false;
ext_int_edge(H_TO_L); // Pristi inerrupt bude od opacne hrany
INT0IF=0; // Povoleni dalsiho preruseni
enable_interrupts(INT_EXT);
enable_interrupts(GLOBAL);
// do
{
while(0==input(LASER)); // Ceka na detekci cary
// output_high(SERVO);
t1=get_timer0(); // Poznamena cas nabezne hrany
while(1==input(LASER)); // Ceka az zkonci cara
// output_low(SERVO);
t2=get_timer0(); // Poznamena cas sestupne hrany
t=t2-t1;
} while((t<3) || (t>20)); // Cara je detekovana, kdyz trva mezi xx ms
// if ((t>3) && (t<20)) uhel=(160-(read_adc()>>2))-t1;
// if (abs(olduhel-uhel)<40)
{
uhel=(160-(read_adc()>>2))-t1;
olduhel=uhel;
};
// uhel16=uhel;
// set_pwm1_duty(250-(uhel16<<2)); // Elektronicky diferencial
// set_pwm2_duty((uhel16));
set_adc_channel(CERNA);
}
else
{
edge=true;
ext_int_edge(L_TO_H); // Pristi inerrupt bude od opacne hrany
INT0IF=0; // Povoleni dalsiho preruseni
enable_interrupts(INT_EXT);
enable_interrupts(GLOBAL);
// do
{
while(0==input(LASER)); // Ceka na detekci cary
t1=get_timer0(); // Poznamena cas nabezne hrany
while(1==input(LASER)); // Ceka az zkonci cara
t2=get_timer0(); // Poznamena cas sestupne hrany
t=t2-t1;
} while((t<3) || (t>20)); // Cara je detekovana, kdyz trva mezi xx ms
if (abs(olduhel-uhel)<40)
{
// uhel=((read_adc()>>2)+32)+t1;
// olduhel=uhel;
};
set_adc_channel(CERVENA);
}
while(true);
}
 
 
 
void main()
{
 
setup_adc_ports(ALL_ANALOG); // Analogove vstupy pro cteni trimru
setup_adc(ADC_CLOCK_INTERNAL);
setup_spi(FALSE);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_256); // Casovac pro cteni laseru
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DIV_BY_4,255,1); // Casovac pro PWM cca 900Hz
setup_ccp1(CCP_PWM); // Nastaveni PWM pro diferencial RC1, RC2
setup_ccp2(CCP_PWM);
 
set_pwm1_duty(90); // Zastaveni PWM
set_pwm2_duty(90);
 
delay_ms(100);
set_adc_channel(CERVENA);
Delay_ms(1);
 
ext_int_edge(L_TO_H);
edge=true;
uhel=((read_adc()>>2)+32)+30;
olduhel=uhel;
 
enable_interrupts(INT_EXT);
enable_interrupts(GLOBAL);
 
delay_ms(1000);
 
output_high(MOT_DIR_L); // Oba motory vpred
output_high(MOT_DIR_R);
 
while(true);
}
/roboti/istrobot/laserus/873/laserus.cof
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/roboti/istrobot/laserus/873/laserus.err
0,0 → 1,2
No Errors
0 Errors, 0 Warnings.
/roboti/istrobot/laserus/873/laserus.h
0,0 → 1,15
#include <16F873.h>
#device adc=8
 
#FUSES NOWDT //No Watch Dog Timer
#FUSES XT //Crystal osc <= 4mhz
#FUSES NOPUT //No Power Up Timer
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD //No EE protection
#FUSES NOWRT //Program memory not write protected
#FUSES NODEBUG //No Debug mode for ICD
 
#use delay(clock=4000000)
 
/roboti/istrobot/laserus/873/laserus.hex
0,0 → 1,48
:1000000000308A00E3280000FF00030E8301A600F1
:100010007F08A5000A08AD008A01A50E0408A70004
:100020002008A8002108A9002208AA002308AB0084
:100030002408AC00831383120B1E20288B1833284E
:10004000270884002808A0002908A1002A08A20087
:100050002B08A3002C08A4002D088A00260E83007C
:10006000FF0E7F0E09008A11352881018316861242
:10007000831286160108023C03183A282F08B7009D
:10008000B70803194828000000000000B703402803
:10009000831686128312861201080A3C03184C2824
:1000A00081012E1C94282E108316011383128B10AD
:1000B0000B16C0308B048316061600308312061A06
:1000C0000130003A03195B280108B80083160616B0
:1000D00000308312061A0130013C0319662801081A
:1000E000B90038083902BA003A08023C03187428EB
:1000F0003A08143C031C74281F151F197D281E087C
:10010000A000A00CA00C3F30A0052008A03CA1003E
:1001100038082102AF002F08B0000830A1001F08E6
:10012000C73921049F00CA282E1483160117831291
:100130008B100B16C0308B0483160616003083120A
:10014000061A0130003A03199C280108B8008316EA
:10015000061600308312061A0130013C0319A72845
:100160000108B90038083902BA003A08023C0318FD
:10017000B5283A08143C031CB5282F083002BB00F0
:100180003B08273C031CC4280030A1001F08C739C6
:1001900021049F00CA288B108A1120283530840042
:1001A00000080319E2280130A100A001A00BD62805
:1001B000A10BD5284A30A000A00BDC2800000000CD
:1001C000800BD328003484011F30830583161F144D
:1001D0009F141F159F11FF308312B30083161F1049
:1001E0009F101F119F1183121F179F1783169F13B4
:1001F00083121F149412B3123308831687008312DC
:1002000033163308831687008312B311330883161D
:100210008700003083129400831694000108C039CF
:1002200007388100831290010030A1000538920048
:10023000FF30831692008312331133088316870030
:10024000831207110C309700B31033088316870010
:10025000831287100C309D005A3095009B0064304B
:10026000B500CE200030A1001F08C73921049F002F
:100270000130B500CE208316011783122E141F15EE
:100280001F1940291E08A000A00CA00C3F30A0059B
:100290002008203E1E3EAF002F08B0000B16C030D5
:1002A0008B040430B400FA30B500CE20B40B5329CF
:1002B000331033088316870083120714B3113308F1
:0C02C000831687008312871564296300F1
:02400E00393F38
:00000001FF
;PIC16F873
/roboti/istrobot/laserus/873/laserus.lst
0,0 → 1,528
CCS PCM C Compiler, Version 3.245, 27853 27-I-07 23:47
 
Filename: C:\PIC\laserus\873\laserus.lst
 
ROM used: 358 words (9%)
Largest free fragment is 2048
RAM used: 23 (12%) at main() level
29 (15%) worst case
Stack: 2 worst case (1 in main + 1 for interrupts)
 
*
0000: MOVLW 00
0001: MOVWF 0A
0002: GOTO 0E3
0003: NOP
0004: MOVWF 7F
0005: SWAPF 03,W
0006: CLRF 03
0007: MOVWF 26
0008: MOVF 7F,W
0009: MOVWF 25
000A: MOVF 0A,W
000B: MOVWF 2D
000C: CLRF 0A
000D: SWAPF 25,F
000E: MOVF 04,W
000F: MOVWF 27
0010: MOVF 20,W
0011: MOVWF 28
0012: MOVF 21,W
0013: MOVWF 29
0014: MOVF 22,W
0015: MOVWF 2A
0016: MOVF 23,W
0017: MOVWF 2B
0018: MOVF 24,W
0019: MOVWF 2C
001A: BCF 03.7
001B: BCF 03.5
001C: BTFSS 0B.4
001D: GOTO 020
001E: BTFSC 0B.1
001F: GOTO 033
0020: MOVF 27,W
0021: MOVWF 04
0022: MOVF 28,W
0023: MOVWF 20
0024: MOVF 29,W
0025: MOVWF 21
0026: MOVF 2A,W
0027: MOVWF 22
0028: MOVF 2B,W
0029: MOVWF 23
002A: MOVF 2C,W
002B: MOVWF 24
002C: MOVF 2D,W
002D: MOVWF 0A
002E: SWAPF 26,W
002F: MOVWF 03
0030: SWAPF 7F,F
0031: SWAPF 7F,W
0032: RETFIE
0033: BCF 0A.3
0034: GOTO 035
.................... #include "laserus.h"
.................... #include <16F873.h>
.................... //////// Standard Header file for the PIC16F873 device ////////////////
.................... #device PIC16F873
.................... #list
....................
.................... #device adc=8
....................
.................... #FUSES NOWDT //No Watch Dog Timer
.................... #FUSES XT //Crystal osc <= 4mhz
.................... #FUSES NOPUT //No Power Up Timer
.................... #FUSES NOPROTECT //Code not protected from reading
.................... #FUSES NOBROWNOUT //No brownout reset
.................... #FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
.................... #FUSES NOCPD //No EE protection
.................... #FUSES NOWRT //Program memory not write protected
.................... #FUSES NODEBUG //No Debug mode for ICD
....................
.................... #use delay(clock=4000000)
*
00CE: MOVLW 35
00CF: MOVWF 04
00D0: MOVF 00,W
00D1: BTFSC 03.2
00D2: GOTO 0E2
00D3: MOVLW 01
00D4: MOVWF 21
00D5: CLRF 20
00D6: DECFSZ 20,F
00D7: GOTO 0D6
00D8: DECFSZ 21,F
00D9: GOTO 0D5
00DA: MOVLW 4A
00DB: MOVWF 20
00DC: DECFSZ 20,F
00DD: GOTO 0DC
00DE: NOP
00DF: NOP
00E0: DECFSZ 00,F
00E1: GOTO 0D3
00E2: RETLW 00
....................
....................
....................
.................... #define SERVO PIN_B5 // Vystup pro rizeni serva
.................... #define LASER PIN_B4 // Vstup pro cteni laseru
....................
.................... #define MOT_DIR_L PIN_C0 // Rizeni smeru otaceni motoru
.................... #define MOT_DIR_R PIN_C3
....................
.................... // kroutitka
.................... #define CERVENA 0 // AN0
.................... #define CERNA 1 // AN1
.................... //#define ZELENA 3 // AN3
.................... //#define MODRA 4 // AN4
....................
.................... #byte INTCON = 0x0B // Interrupt configuration register
.................... #bit GIE = INTCON.7
.................... #bit PEIE = INTCON.6
.................... #bit TMR0IE = INTCON.5
.................... #bit INT0IE = INTCON.4
.................... #bit RBIE = INTCON.3
.................... #bit TMR0IF = INTCON.2
.................... #bit INT0IF = INTCON.1
.................... #bit RBIF = INTCON.0
....................
.................... boolean edge;
.................... int8 uhel, olduhel;
.................... int16 uhel16;
....................
.................... #int_EXT
.................... EXT_isr()
.................... {
.................... int n, t1, t2, t;
....................
.................... set_timer0(0); // Vynulovani casovace pro 2ms
*
0035: CLRF 01
.................... output_high(SERVO);
0036: BSF 03.5
0037: BCF 06.5
0038: BCF 03.5
0039: BSF 06.5
.................... while(get_timer0()<(1000/256)); // Ceka 1ms
003A: MOVF 01,W
003B: SUBLW 02
003C: BTFSC 03.0
003D: GOTO 03A
.................... for(n=uhel; n>0; n--) delay_us(3); // Sirka impulzu podle uhlu
003E: MOVF 2F,W
003F: MOVWF 37
0040: MOVF 37,F
0041: BTFSC 03.2
0042: GOTO 048
0043: NOP
0044: NOP
0045: NOP
0046: DECF 37,F
0047: GOTO 040
.................... output_low(SERVO);
0048: BSF 03.5
0049: BCF 06.5
004A: BCF 03.5
004B: BCF 06.5
.................... while(get_timer0()<(3000/256)); // Ceka do 3ms, nez zacne scanovat
004C: MOVF 01,W
004D: SUBLW 0A
004E: BTFSC 03.0
004F: GOTO 04C
....................
.................... set_timer0(0); // Vynulovani casovace pro zjisteni polohy cary
0050: CLRF 01
.................... if(edge) // Zrcatko prejizdelo tam nebo zpet?
0051: BTFSS 2E.0
0052: GOTO 094
.................... {
.................... edge=false;
0053: BCF 2E.0
.................... ext_int_edge(H_TO_L); // Pristi inerrupt bude od opacne hrany
0054: BSF 03.5
0055: BCF 01.6
.................... INT0IF=0; // Povoleni dalsiho preruseni
0056: BCF 03.5
0057: BCF 0B.1
.................... enable_interrupts(INT_EXT);
0058: BSF 0B.4
.................... enable_interrupts(GLOBAL);
0059: MOVLW C0
005A: IORWF 0B,F
.................... // do
.................... {
.................... while(0==input(LASER)); // Ceka na detekci cary
005B: BSF 03.5
005C: BSF 06.4
005D: MOVLW 00
005E: BCF 03.5
005F: BTFSC 06.4
0060: MOVLW 01
0061: XORLW 00
0062: BTFSC 03.2
0063: GOTO 05B
.................... // output_high(SERVO);
.................... t1=get_timer0(); // Poznamena cas nabezne hrany
0064: MOVF 01,W
0065: MOVWF 38
.................... while(1==input(LASER)); // Ceka az zkonci cara
0066: BSF 03.5
0067: BSF 06.4
0068: MOVLW 00
0069: BCF 03.5
006A: BTFSC 06.4
006B: MOVLW 01
006C: SUBLW 01
006D: BTFSC 03.2
006E: GOTO 066
.................... // output_low(SERVO);
.................... t2=get_timer0(); // Poznamena cas sestupne hrany
006F: MOVF 01,W
0070: MOVWF 39
.................... t=t2-t1;
0071: MOVF 38,W
0072: SUBWF 39,W
0073: MOVWF 3A
.................... } while((t<3) || (t>20)); // Cara je detekovana, kdyz trva mezi xx ms
0074: MOVF 3A,W
0075: SUBLW 02
0076: BTFSC 03.0
0077: GOTO 074
0078: MOVF 3A,W
0079: SUBLW 14
007A: BTFSS 03.0
007B: GOTO 074
.................... // if ((t>3) && (t<20)) uhel=(160-(read_adc()>>2))-t1;
.................... // if (abs(olduhel-uhel)<40)
.................... {
.................... uhel=(160-(read_adc()>>2))-t1;
007C: BSF 1F.2
007D: BTFSC 1F.2
007E: GOTO 07D
007F: MOVF 1E,W
0080: MOVWF 20
0081: RRF 20,F
0082: RRF 20,F
0083: MOVLW 3F
0084: ANDWF 20,F
0085: MOVF 20,W
0086: SUBLW A0
0087: MOVWF 21
0088: MOVF 38,W
0089: SUBWF 21,W
008A: MOVWF 2F
.................... olduhel=uhel;
008B: MOVF 2F,W
008C: MOVWF 30
.................... };
.................... // uhel16=uhel;
.................... // set_pwm1_duty(250-(uhel16<<2)); // Elektronicky diferencial
.................... // set_pwm2_duty((uhel16));
.................... set_adc_channel(CERNA);
008D: MOVLW 08
008E: MOVWF 21
008F: MOVF 1F,W
0090: ANDLW C7
0091: IORWF 21,W
0092: MOVWF 1F
.................... }
.................... else
0093: GOTO 0CA
.................... {
.................... edge=true;
0094: BSF 2E.0
.................... ext_int_edge(L_TO_H); // Pristi inerrupt bude od opacne hrany
0095: BSF 03.5
0096: BSF 01.6
.................... INT0IF=0; // Povoleni dalsiho preruseni
0097: BCF 03.5
0098: BCF 0B.1
.................... enable_interrupts(INT_EXT);
0099: BSF 0B.4
.................... enable_interrupts(GLOBAL);
009A: MOVLW C0
009B: IORWF 0B,F
.................... // do
.................... {
.................... while(0==input(LASER)); // Ceka na detekci cary
009C: BSF 03.5
009D: BSF 06.4
009E: MOVLW 00
009F: BCF 03.5
00A0: BTFSC 06.4
00A1: MOVLW 01
00A2: XORLW 00
00A3: BTFSC 03.2
00A4: GOTO 09C
.................... t1=get_timer0(); // Poznamena cas nabezne hrany
00A5: MOVF 01,W
00A6: MOVWF 38
.................... while(1==input(LASER)); // Ceka az zkonci cara
00A7: BSF 03.5
00A8: BSF 06.4
00A9: MOVLW 00
00AA: BCF 03.5
00AB: BTFSC 06.4
00AC: MOVLW 01
00AD: SUBLW 01
00AE: BTFSC 03.2
00AF: GOTO 0A7
.................... t2=get_timer0(); // Poznamena cas sestupne hrany
00B0: MOVF 01,W
00B1: MOVWF 39
.................... t=t2-t1;
00B2: MOVF 38,W
00B3: SUBWF 39,W
00B4: MOVWF 3A
.................... } while((t<3) || (t>20)); // Cara je detekovana, kdyz trva mezi xx ms
00B5: MOVF 3A,W
00B6: SUBLW 02
00B7: BTFSC 03.0
00B8: GOTO 0B5
00B9: MOVF 3A,W
00BA: SUBLW 14
00BB: BTFSS 03.0
00BC: GOTO 0B5
.................... if (abs(olduhel-uhel)<40)
00BD: MOVF 2F,W
00BE: SUBWF 30,W
00BF: MOVWF 3B
00C0: MOVF 3B,W
00C1: SUBLW 27
00C2: BTFSS 03.0
00C3: GOTO 0C4
.................... {
.................... // uhel=((read_adc()>>2)+32)+t1;
.................... // olduhel=uhel;
.................... };
.................... set_adc_channel(CERVENA);
00C4: MOVLW 00
00C5: MOVWF 21
00C6: MOVF 1F,W
00C7: ANDLW C7
00C8: IORWF 21,W
00C9: MOVWF 1F
.................... }
.................... while(true);
00CA: GOTO 0CA
.................... }
....................
....................
....................
00CB: BCF 0B.1
00CC: BCF 0A.3
00CD: GOTO 020
.................... void main()
.................... {
*
00E3: CLRF 04
00E4: MOVLW 1F
00E5: ANDWF 03,F
00E6: BSF 03.5
00E7: BSF 1F.0
00E8: BSF 1F.1
00E9: BSF 1F.2
00EA: BCF 1F.3
....................
.................... setup_adc_ports(ALL_ANALOG); // Analogove vstupy pro cteni trimru
*
00EE: BSF 03.5
00EF: BCF 1F.0
00F0: BCF 1F.1
00F1: BCF 1F.2
00F2: BCF 1F.3
.................... setup_adc(ADC_CLOCK_INTERNAL);
00F3: BCF 03.5
00F4: BSF 1F.6
00F5: BSF 1F.7
00F6: BSF 03.5
00F7: BCF 1F.7
00F8: BCF 03.5
00F9: BSF 1F.0
.................... setup_spi(FALSE);
*
00EB: MOVLW FF
00EC: BCF 03.5
00ED: MOVWF 33
*
00FA: BCF 14.5
00FB: BCF 33.5
00FC: MOVF 33,W
00FD: BSF 03.5
00FE: MOVWF 07
00FF: BCF 03.5
0100: BSF 33.4
0101: MOVF 33,W
0102: BSF 03.5
0103: MOVWF 07
0104: BCF 03.5
0105: BCF 33.3
0106: MOVF 33,W
0107: BSF 03.5
0108: MOVWF 07
0109: MOVLW 00
010A: BCF 03.5
010B: MOVWF 14
010C: BSF 03.5
010D: MOVWF 14
.................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_256); // Casovac pro cteni laseru
010E: MOVF 01,W
010F: ANDLW C0
0110: IORLW 07
0111: MOVWF 01
.................... setup_timer_1(T1_DISABLED);
0112: BCF 03.5
0113: CLRF 10
.................... setup_timer_2(T2_DIV_BY_4,255,1); // Casovac pro PWM cca 900Hz
0114: MOVLW 00
0115: MOVWF 21
0116: IORLW 05
0117: MOVWF 12
0118: MOVLW FF
0119: BSF 03.5
011A: MOVWF 12
.................... setup_ccp1(CCP_PWM); // Nastaveni PWM pro diferencial RC1, RC2
011B: BCF 03.5
011C: BCF 33.2
011D: MOVF 33,W
011E: BSF 03.5
011F: MOVWF 07
0120: BCF 03.5
0121: BCF 07.2
0122: MOVLW 0C
0123: MOVWF 17
.................... setup_ccp2(CCP_PWM);
0124: BCF 33.1
0125: MOVF 33,W
0126: BSF 03.5
0127: MOVWF 07
0128: BCF 03.5
0129: BCF 07.1
012A: MOVLW 0C
012B: MOVWF 1D
....................
.................... set_pwm1_duty(90); // Zastaveni PWM
012C: MOVLW 5A
012D: MOVWF 15
.................... set_pwm2_duty(90);
012E: MOVWF 1B
....................
.................... delay_ms(100);
012F: MOVLW 64
0130: MOVWF 35
0131: CALL 0CE
.................... set_adc_channel(CERVENA);
0132: MOVLW 00
0133: MOVWF 21
0134: MOVF 1F,W
0135: ANDLW C7
0136: IORWF 21,W
0137: MOVWF 1F
.................... Delay_ms(1);
0138: MOVLW 01
0139: MOVWF 35
013A: CALL 0CE
....................
.................... ext_int_edge(L_TO_H);
013B: BSF 03.5
013C: BSF 01.6
.................... edge=true;
013D: BCF 03.5
013E: BSF 2E.0
.................... uhel=((read_adc()>>2)+32)+30;
013F: BSF 1F.2
0140: BTFSC 1F.2
0141: GOTO 140
0142: MOVF 1E,W
0143: MOVWF 20
0144: RRF 20,F
0145: RRF 20,F
0146: MOVLW 3F
0147: ANDWF 20,F
0148: MOVF 20,W
0149: ADDLW 20
014A: ADDLW 1E
014B: MOVWF 2F
.................... olduhel=uhel;
014C: MOVF 2F,W
014D: MOVWF 30
....................
.................... enable_interrupts(INT_EXT);
014E: BSF 0B.4
.................... enable_interrupts(GLOBAL);
014F: MOVLW C0
0150: IORWF 0B,F
....................
.................... delay_ms(1000);
0151: MOVLW 04
0152: MOVWF 34
0153: MOVLW FA
0154: MOVWF 35
0155: CALL 0CE
0156: DECFSZ 34,F
0157: GOTO 153
....................
.................... output_high(MOT_DIR_L); // Oba motory vpred
0158: BCF 33.0
0159: MOVF 33,W
015A: BSF 03.5
015B: MOVWF 07
015C: BCF 03.5
015D: BSF 07.0
.................... output_high(MOT_DIR_R);
015E: BCF 33.3
015F: MOVF 33,W
0160: BSF 03.5
0161: MOVWF 07
0162: BCF 03.5
0163: BSF 07.3
....................
.................... while(true);
0164: GOTO 164
.................... }
0165: SLEEP
 
Configuration Fuses:
Word 1: 3F39 XT NOWDT NOPUT NOPROTECT NOBROWNOUT NOLVP NOCPD NOWRT NODEBUG
/roboti/istrobot/laserus/873/laserus.sta
0,0 → 1,31
 
ROM used: 358 (9%)
358 (9%) including unused fragments
 
1 Average locations per line
5 Average locations per statement
 
RAM used: 23 (12%) at main() level
29 (15%) worst case
 
Lines Stmts % Files
----- ----- --- -----
131 78 100 C:\PIC\laserus\873\laserus.c
16 0 0 C:\PIC\laserus\873\laserus.h
244 0 0 C:\Program Files\PICC\devices\16F873.h
----- -----
782 156 Total
 
Page ROM % RAM Functions:
---- --- --- --- ----------
0 21 6 1 @delay_ms1
0 153 43 6 EXT_isr
0 131 37 3 main
 
Segment Used Free
--------- ---- ----
00000-00003 4 0
00004-00034 49 0
00035-007FF 305 1690
00800-00FFF 0 2048
 
/roboti/istrobot/laserus/873/laserus.sym
0,0 → 1,74
00B.0 RBIF
00B INTCON
00B.1 INT0IF
00B.2 TMR0IF
00B.3 RBIE
00B.4 INT0IE
00B.5 TMR0IE
00B.6 PEIE
00B.7 GIE
015-016 CCP_1
015 CCP_1_LOW
016 CCP_1_HIGH
01B CCP_2_LOW
01B-01C CCP_2
01C CCP_2_HIGH
020 @SCRATCH
021 @SCRATCH
021 _RETURN_
022 @SCRATCH
023 @SCRATCH
024 @SCRATCH
025 @INTERRUPT_AREA
026 @INTERRUPT_AREA
027 @INTERRUPT_AREA
028 @INTERRUPT_AREA
029 @INTERRUPT_AREA
02A @INTERRUPT_AREA
02B @INTERRUPT_AREA
02C @INTERRUPT_AREA
02D @INTERRUPT_AREA
02E.0 edge
02F uhel
030 olduhel
031-032 uhel16
033 @TRIS_C
034 main.@SCRATCH
035 @delay_ms1.P1
035 main.@SCRATCH
036 main.@SCRATCH
037 EXT_isr.n
038 EXT_isr.t1
039 EXT_isr.t2
03A EXT_isr.t
03B EXT_isr.@SCRATCH
03C EXT_isr.@SCRATCH
 
00CE @delay_ms1
0035 EXT_isr
00E3 main
00E3 @cinit
 
Project Files:
C:\PIC\laserus\873\laserus.c
C:\PIC\laserus\873\laserus.h
C:\Program Files\PICC\devices\16F873.h
 
Units:
C:\PIC\laserus\873\laserus.c (main)
 
Compiler Settings:
Processor: PIC16F873
Pointer Size: 8
ADC Range: 0-255
Opt Level: 9
Short,Int,Long: 1,8,16
 
Output Files:
Errors: C:\PIC\laserus\873\laserus.err
INHX8: C:\PIC\laserus\873\laserus.hex
Symbols: C:\PIC\laserus\873\laserus.sym
List: C:\PIC\laserus\873\laserus.lst
Debug/COFF: C:\PIC\laserus\873\laserus.cof
Call Tree: C:\PIC\laserus\873\laserus.tre
Statistics: C:\PIC\laserus\873\laserus.sta
/roboti/istrobot/laserus/873/laserus.tre
0,0 → 1,7
ÀÄlaserus
ÃÄmain 0/131 Ram=3
³ ÃÄ??0??
³ ÃÄ@delay_ms1 0/21 Ram=1
³ ÃÄ@delay_ms1 0/21 Ram=1
³ ÀÄ@delay_ms1 0/21 Ram=1
ÀÄEXT_isr 0/153 Ram=6
/roboti/istrobot/laserus/88/16F88_Reg.BAK
0,0 → 1,298
// Komplete definition of all Special Feature Registers
// of PIC16F87 and PIC16F88
// (c)miho 2005
 
#nolist
 
// SFR Registers in Memory Bank 0
#byte INDF = 0x00
#byte TMR0 = 0x01
#byte PCL = 0x02
#byte STATUS = 0x03
#bit IRP = STATUS.7
#bit RP1 = STATUS.6
#bit RP0 = STATUS.5
#bit TO = STATUS.4
#bit PD = STATUS.3
#bit Z = STATUS.2
#bit DC = STATUS.1
#bit C = STATUS.0
#byte FSR = 0x04
#byte PORTA = 0x05
#byte PORTB = 0x06
#byte PCLATH = 0x0A
#byte INTCON = 0x0B
#bit GIE = INTCON.7
#bit PEIE = INTCON.6
#bit TMR0IE = INTCON.5
#bit INT0IE = INTCON.4
#bit RBIE = INTCON.3
#bit TMR0IF = INTCON.2
#bit INT0IF = INTCON.1
#bit RBIF = INTCON.0
#byte PIR1 = 0x0C
#bit ADIF = PIR1.6
#bit RCIF = PIR1.5
#bit TXIF = PIR1.4
#bit SSPIF = PIR1.3
#bit CCP1IF = PIR1.2
#bit TMR2IF = PIR1.1
#bit TMR1IF = PIR1.0
#byte PIR2 = 0x0D
#bit OSFIF = PIR2.7
#bit CMIF = PIR2.6
#bit EEIF = PIR2.4
#byte TMR1L = 0x0E
#byte TMR1H = 0x0F
#byte T1CON = 0x10
#bit T1RUN = T1CON.6
#bit T1CKPS1 = T1CON.5
#bit T1CKPS0 = T1CON.4
#bit T1OSCEN = T1CON.3
#bit T1SYNC = T1CON.2
#bit TMR1CS = T1CON.1
#bit TMR1ON = T1CON.0
#byte TMR2 = 0x11
#byte T2CON = 0x12
#bit TOUTPS3 = T2CON.6
#bit TOUTPS2 = T2CON.5
#bit TOUTPS1 = T2CON.4
#bit TOUTPS0 = T2CON.3
#bit TMR2ON = T2CON.2
#bit T2CKPS1 = T2CON.1
#bit T2CKPS0 = T2CON.0
#byte SSPBUF = 0x13
#byte SSPCON1 = 0x14
#bit WCOL = SSPCON1.7
#bit SSPOV = SSPCON1.6
#bit SSPEN = SSPCON1.5
#bit CKP = SSPCON1.4
#bit SSPM3 = SSPCON1.3
#bit SSPM2 = SSPCON1.2
#bit SSPM1 = SSPCON1.1
#bit SSPM0 = SSPCON1.0
#byte CCPR1L = 0x15
#byte CCPR1H = 0x16
#byte CCP1CON = 0x17
#bit CCP1X = CCP1CON.5
#bit CCP1Y = CCP1CON.4
#bit CCP1M3 = CCP1CON.3
#bit CCP1M2 = CCP1CON.2
#bit CCP1M1 = CCP1CON.1
#bit CCP1M0 = CCP1CON.0
#byte RCSTA = 0x18
#bit SPEN = RCSTA.7
#bit RX9 = RCSTA.6
#bit SREN = RCSTA.5
#bit CREN = RCSTA.4
#bit ADDEN = RCSTA.3
#bit FERR = RCSTA.2
#bit OERR = RCSTA.1
#bit RX9D = RCSTA.0
#byte TXREG = 0x19
#byte RCREG = 0x1A
#byte ADRESH = 0x1E // F88 only
#byte ADCON0 = 0x1F // F88 only
#bit ADCS1 = ADCON0.7
#bit ADCS0 = ADCON0.6
#bit CHS2 = ADCON0.5
#bit CHS1 = ADCON0.4
#bit CHS0 = ADCON0.3
#bit GO = ADCON0.2
#bit ADON = ADCON0.0
 
// SFR Registers in Memory Bank 1
#byte INDF_1 = 0x80 // miror
#byte OPTION = 0x81
#bit RBPU = OPTION.7
#bit INTEDG = OPTION.6
#bit T0CS = OPTION.5
#bit T0SE = OPTION.4
#bit PSA = OPTION.3
#bit PS2 = OPTION.2
#bit PS1 = OPTION.1
#bit PS0 = OPTION.0
#byte PCL = 0x82
#byte STATUS_1 = 0x83 // mirror
#bit IRP_1 = STATUS_1.7
#bit RP1_1 = STATUS_1.6
#bit RP0_1 = STATUS_1.5
#bit TO_1 = STATUS_1.4
#bit PD_1 = STATUS_1.3
#bit Z_1 = STATUS_1.2
#bit DC_1 = STATUS_1.1
#bit C_1 = STATUS_1.0
#byte FSR = 0x84
#byte TRISA = 0x85
#byte TRISB = 0x86
#byte PCLATH_1 = 0x8A // mirror
#byte INTCON_1 = 0x8B // mirror
#bit GIE_1 = INTCON_1.7
#bit PEIE_1 = INTCON_1.6
#bit TMR0IE_1 = INTCON_1.5
#bit INT0IE_1 = INTCON_1.4
#bit RBIE_1 = INTCON_1.3
#bit TMR0IF_1 = INTCON_1.2
#bit INT0IF_1 = INTCON_1.1
#bit RBIF_1 = INTCON_1.0
#byte PIE1 = 0x8C
#bit ADIE = PIE1.6
#bit RCIE = PIE1.5
#bit TXIE = PIE1.4
#bit SSPIE = PIE1.3
#bit CCP1IE = PIE1.2
#bit TMR2IE = PIE1.1
#bit TMR1IE = PIE1.0
#byte PIE2 = 0x8D
#bit OSFIE = PIE2.7
#bit CMIE = PIE2.6
#bit EEIE = PIE2.4
#byte PCON = 0x8E
#bit POR = PCON.1
#bit BOR = PCON.0
#byte OSCCON = 0x8F
#bit IRCF2 = OSCCON.6
#bit IRCF1 = OSCCON.5
#bit IRCF0 = OSCCON.4
#bit OSTS = OSCCON.3
#bit IOFS = OSCCON.2
#bit SCS1 = OSCCON.1
#bit SCS0 = OSCCON.0
#byte OSCTUNE = 0x90
#bit TUN5 = OSCTUNE.5
#bit TUN4 = OSCTUNE.4
#bit TUN3 = OSCTUNE.3
#bit TUN2 = OSCTUNE.2
#bit TUN1 = OSCTUNE.1
#bit TUN0 = OSCTUNE.0
#byte PR2 = 0x92
#byte SSPADD = 0x93
#byte SSPSTAT = 0x94
#bit SMP = SSPSTAT.7
#bit CKE = SSPSTAT.6
#bit DA = SSPSTAT.5
#bit P = SSPSTAT.4
#bit S = SSPSTAT.3
#bit RW = SSPSTAT.2
#bit UA = SSPSTAT.1
#bit BF = SSPSTAT.0
#byte TXSTA = 0x98
#bit CSRC = TXSTA.7
#bit TX9 = TXSTA.6
#bit TXEN = TXSTA.5
#bit SYNC = TXSTA.4
#bit BRGH = TXSTA.2
#bit TRMT = TXSTA.1
#bit TX9D = TXSTA.0
#byte SPBRG = 0x99
#byte ANSEL = 0x9B // F88 only
#bit ANS6 = ANSEL.6
#bit ANS5 = ANSEL.5
#bit ANS4 = ANSEL.4
#bit ANS3 = ANSEL.3
#bit ANS2 = ANSEL.2
#bit ANS1 = ANSEL.1
#bit ANS0 = ANSEL.0
#byte CMCON = 0x9C
#bit C2OUT = CMCON.7
#bit C1OUT = CMCON.6
#bit C2INV = CMCON.5
#bit C1INV = CMCON.4
#bit CIS = CMCON.3
#bit CM2 = CMCON.2
#bit CM1 = CMCON.1
#bit CM0 = CMCON.0
#byte CVRCON = 0x9D
#bit CVREN = CVRCON.7
#bit CVROE = CVRCON.6
#bit CVRR = CVRCON.5
#bit CVR3 = CVRCON.3
#bit CVR2 = CVRCON.2
#bit CVR1 = CVRCON.1
#bit CVR0 = CVRCON.0
#byte ADRESL = 0x9E // F88 only
#byte ADCON1 = 0x9F // F88 only
#bit ADFM = ADCON1.7
#bit ADCS2 = ADCON1.6
#bit VCFG1 = ADCON1.5
#bit VCFG0 = ADCON1.4
 
// SFR Registers in Memory Bank 2
#byte INDF_2 = 0x100 // mirror
#byte TMR0_2 = 0x101 // mirror
#byte PCL_2 = 0x102 // mirror
#byte STATUS_2 = 0x103 // mirror
#bit IRP_2 = STATUS_2.7
#bit RP1_2 = STATUS_2.6
#bit RP0_2 = STATUS_2.5
#bit TO_2 = STATUS_2.4
#bit PD_2 = STATUS_2.3
#bit Z_2 = STATUS_2.2
#bit DC_2 = STATUS_2.1
#bit C_2 = STATUS_2.0
#byte FSR_2 = 0x104 // mirror
#byte WDTCON = 0x105
#bit WDTPS3 = WDTCON.4
#bit WDTPS2 = WDTCON.3
#bit WDTPS1 = WDTCON.2
#bit WDTPS0 = WDTCON.1
#bit SWDTEN = WDTCON.0
#byte PORTB_2 = 0x106 // mirror
#byte PCLATH_2 = 0x10A // mirror
#byte INTCON_2 = 0x10B // mirror
#bit GIE_2 = INTCON_2.7
#bit PEIE_2 = INTCON_2.6
#bit TMR0IE_2 = INTCON_2.5
#bit INT0IE_2 = INTCON_2.4
#bit RBIE_2 = INTCON_2.3
#bit TMR0IF_2 = INTCON_2.2
#bit INT0IF_2 = INTCON_2.1
#bit RBIF_2 = INTCON_2.0
#byte EEDATA = 0x10C
#byte EEADR = 0x10D
#byte EEDATH = 0x10E
#byte EEADRH = 0x10F
 
// SFR Registers in Memory Bank 3
#byte INDF_3 = 0x180 // mirror
#byte OPTION_3 = 0x181 // mirror
#bit RBPU_3 = OPTION_3.7
#bit INTEDG_3 = OPTION_3.6
#bit T0CS_3 = OPTION_3.5
#bit T0SE_3 = OPTION_3.4
#bit PSA_3 = OPTION_3.3
#bit PS2_3 = OPTION_3.2
#bit PS1_3 = OPTION_3.1
#bit PS0_3 = OPTION_3.0
#byte PCL_3 = 0x182 // mirror
#byte STATUS_3 = 0x183 // mirror
#bit IRP_3 = STATUS_3.7
#bit RP1_3 = STATUS_3.6
#bit RP0_3 = STATUS_3.5
#bit TO_3 = STATUS_3.4
#bit PD_3 = STATUS_3.3
#bit Z_3 = STATUS_3.2
#bit DC_3 = STATUS_3.1
#bit C_3 = STATUS_3.0
#byte FSR_3 = 0x184 // mirror
#byte TRISB_3 = 0x186 // mirror
#byte PLATH_3 = 0x18A // mirror
#byte INTCON_3 = 0x18B // mirror
#bit GIE_3 = INTCON_3.7
#bit PEIE_3 = INTCON_3.6
#bit TMR0IE_3 = INTCON_3.5
#bit INT0IE_3 = INTCON_3.4
#bit RBIE_3 = INTCON_3.3
#bit TMR0IF_3 = INTCON_3.2
#bit INT0IF_3 = INTCON_3.1
#bit RBIF_3 = INTCON_3.0
#byte EECON1 = 0x18C
#bit EEPGD = EECON1.7
#bit FREE = EECON1.4
#bit WRERR = EECON1.3
#bit WREN = EECON1.2
#bit WR = EECON1.1
#bit RD = EECON1.0
#byte EECON2 = 0x18D
 
#list
/roboti/istrobot/laserus/88/16F88_Reg.H
0,0 → 1,298
// Komplete definition of all Special Feature Registers
// of PIC16F87 and PIC16F88
// (c)miho 2005
 
#nolist
 
// SFR Registers in Memory Bank 0
#byte INDF = 0x00
#byte TMR0 = 0x01
#byte PCL = 0x02
#byte STATUS = 0x03
#bit IRP = STATUS.7
#bit RP1 = STATUS.6
#bit RP0 = STATUS.5
#bit TO = STATUS.4
#bit PD = STATUS.3
#bit Z = STATUS.2
#bit DC = STATUS.1
#bit C = STATUS.0
#byte FSR = 0x04
#byte PORTA = 0x05
#byte PORTB = 0x06
#byte PCLATH = 0x0A
#byte INTCON = 0x0B
#bit GIE = INTCON.7
#bit PEIE = INTCON.6
#bit TMR0IE = INTCON.5
#bit INT0IE = INTCON.4
#bit RBIE = INTCON.3
#bit TMR0IF = INTCON.2
#bit INT0IF = INTCON.1
#bit RBIF = INTCON.0
#byte PIR1 = 0x0C
#bit ADIF = PIR1.6
#bit RCIF = PIR1.5
#bit TXIF = PIR1.4
#bit SSPIF = PIR1.3
#bit CCP1IF = PIR1.2
#bit TMR2IF = PIR1.1
#bit TMR1IF = PIR1.0
#byte PIR2 = 0x0D
#bit OSFIF = PIR2.7
#bit CMIF = PIR2.6
#bit EEIF = PIR2.4
#byte TMR1L = 0x0E
#byte TMR1H = 0x0F
#byte T1CON = 0x10
#bit T1RUN = T1CON.6
#bit T1CKPS1 = T1CON.5
#bit T1CKPS0 = T1CON.4
#bit T1OSCEN = T1CON.3
#bit T1SYNC = T1CON.2
#bit TMR1CS = T1CON.1
#bit TMR1ON = T1CON.0
#byte TMR2 = 0x11
#byte T2CON = 0x12
#bit TOUTPS3 = T2CON.6
#bit TOUTPS2 = T2CON.5
#bit TOUTPS1 = T2CON.4
#bit TOUTPS0 = T2CON.3
#bit TMR2ON = T2CON.2
#bit T2CKPS1 = T2CON.1
#bit T2CKPS0 = T2CON.0
#byte SSPBUF = 0x13
#byte SSPCON1 = 0x14
#bit WCOL = SSPCON1.7
#bit SSPOV = SSPCON1.6
#bit SSPEN = SSPCON1.5
#bit CKP = SSPCON1.4
#bit SSPM3 = SSPCON1.3
#bit SSPM2 = SSPCON1.2
#bit SSPM1 = SSPCON1.1
#bit SSPM0 = SSPCON1.0
#byte CCPR1L = 0x15
#byte CCPR1H = 0x16
#byte CCP1CON = 0x17
#bit CCP1X = CCP1CON.5
#bit CCP1Y = CCP1CON.4
#bit CCP1M3 = CCP1CON.3
#bit CCP1M2 = CCP1CON.2
#bit CCP1M1 = CCP1CON.1
#bit CCP1M0 = CCP1CON.0
#byte RCSTA = 0x18
#bit SPEN = RCSTA.7
#bit RX9 = RCSTA.6
#bit SREN = RCSTA.5
#bit CREN = RCSTA.4
#bit ADDEN = RCSTA.3
#bit FERR = RCSTA.2
#bit OERR = RCSTA.1
#bit RX9D = RCSTA.0
#byte TXREG = 0x19
#byte RCREG = 0x1A
#byte ADRESH = 0x1E // F88 only
#byte ADCON0 = 0x1F // F88 only
#bit ADCS1 = ADCON0.7
#bit ADCS0 = ADCON0.6
#bit CHS2 = ADCON0.5
#bit CHS1 = ADCON0.4
#bit CHS0 = ADCON0.3
#bit GO = ADCON0.2
#bit ADON = ADCON0.0
 
// SFR Registers in Memory Bank 1
#byte INDF_1 = 0x80 // miror
#byte OPTION = 0x81
#bit RBPU = OPTION.7
#bit INTEDG = OPTION.6
#bit T0CS = OPTION.5
#bit T0SE = OPTION.4
#bit PSA = OPTION.3
#bit PS2 = OPTION.2
#bit PS1 = OPTION.1
#bit PS0 = OPTION.0
#byte PCL = 0x82
#byte STATUS_1 = 0x83 // mirror
#bit IRP_1 = STATUS_1.7
#bit RP1_1 = STATUS_1.6
#bit RP0_1 = STATUS_1.5
#bit TO_1 = STATUS_1.4
#bit PD_1 = STATUS_1.3
#bit Z_1 = STATUS_1.2
#bit DC_1 = STATUS_1.1
#bit C_1 = STATUS_1.0
#byte FSR = 0x84
#byte TRISA = 0x85
#byte TRISB = 0x86
#byte PCLATH_1 = 0x8A // mirror
#byte INTCON_1 = 0x8B // mirror
#bit GIE_1 = INTCON_1.7
#bit PEIE_1 = INTCON_1.6
#bit TMR0IE_1 = INTCON_1.5
#bit INT0IE_1 = INTCON_1.4
#bit RBIE_1 = INTCON_1.3
#bit TMR0IF_1 = INTCON_1.2
#bit INT0IF_1 = INTCON_1.1
#bit RBIF_1 = INTCON_1.0
#byte PIE1 = 0x8C
#bit ADIE = PIE1.6
#bit RCIE = PIE1.5
#bit TXIE = PIE1.4
#bit SSPIE = PIE1.3
#bit CCP1IE = PIE1.2
#bit TMR2IE = PIE1.1
#bit TMR1IE = PIE1.0
#byte PIE2 = 0x8D
#bit OSFIE = PIE2.7
#bit CMIE = PIE2.6
#bit EEIE = PIE2.4
#byte PCON = 0x8E
#bit POR = PCON.1
#bit BOR = PCON.0
#byte OSCCON = 0x8F
#bit IRCF2 = OSCCON.6
#bit IRCF1 = OSCCON.5
#bit IRCF0 = OSCCON.4
#bit OSTS = OSCCON.3
#bit IOFS = OSCCON.2
#bit SCS1 = OSCCON.1
#bit SCS0 = OSCCON.0
#byte OSCTUNE = 0x90
#bit TUN5 = OSCTUNE.5
#bit TUN4 = OSCTUNE.4
#bit TUN3 = OSCTUNE.3
#bit TUN2 = OSCTUNE.2
#bit TUN1 = OSCTUNE.1
#bit TUN0 = OSCTUNE.0
#byte PR2 = 0x92
#byte SSPADD = 0x93
#byte SSPSTAT = 0x94
#bit SMP = SSPSTAT.7
#bit CKE = SSPSTAT.6
#bit DA = SSPSTAT.5
#bit P = SSPSTAT.4
#bit S = SSPSTAT.3
#bit RW = SSPSTAT.2
#bit UA = SSPSTAT.1
#bit BF = SSPSTAT.0
#byte TXSTA = 0x98
#bit CSRC = TXSTA.7
#bit TX9 = TXSTA.6
#bit TXEN = TXSTA.5
#bit SYNC = TXSTA.4
#bit BRGH = TXSTA.2
#bit TRMT = TXSTA.1
#bit TX9D = TXSTA.0
#byte SPBRG = 0x99
#byte ANSEL = 0x9B // F88 only
#bit ANS6 = ANSEL.6
#bit ANS5 = ANSEL.5
#bit ANS4 = ANSEL.4
#bit ANS3 = ANSEL.3
#bit ANS2 = ANSEL.2
#bit ANS1 = ANSEL.1
#bit ANS0 = ANSEL.0
#byte CMCON = 0x9C
// #bit C2OUT = CMCON.7
// #bit C1OUT = CMCON.6
#bit C2INV = CMCON.5
#bit C1INV = CMCON.4
#bit CIS = CMCON.3
#bit CM2 = CMCON.2
#bit CM1 = CMCON.1
#bit CM0 = CMCON.0
#byte CVRCON = 0x9D
#bit CVREN = CVRCON.7
#bit CVROE = CVRCON.6
#bit CVRR = CVRCON.5
#bit CVR3 = CVRCON.3
#bit CVR2 = CVRCON.2
#bit CVR1 = CVRCON.1
#bit CVR0 = CVRCON.0
#byte ADRESL = 0x9E // F88 only
#byte ADCON1 = 0x9F // F88 only
#bit ADFM = ADCON1.7
#bit ADCS2 = ADCON1.6
#bit VCFG1 = ADCON1.5
#bit VCFG0 = ADCON1.4
 
// SFR Registers in Memory Bank 2
#byte INDF_2 = 0x100 // mirror
#byte TMR0_2 = 0x101 // mirror
#byte PCL_2 = 0x102 // mirror
#byte STATUS_2 = 0x103 // mirror
#bit IRP_2 = STATUS_2.7
#bit RP1_2 = STATUS_2.6
#bit RP0_2 = STATUS_2.5
#bit TO_2 = STATUS_2.4
#bit PD_2 = STATUS_2.3
#bit Z_2 = STATUS_2.2
#bit DC_2 = STATUS_2.1
#bit C_2 = STATUS_2.0
#byte FSR_2 = 0x104 // mirror
#byte WDTCON = 0x105
#bit WDTPS3 = WDTCON.4
#bit WDTPS2 = WDTCON.3
#bit WDTPS1 = WDTCON.2
#bit WDTPS0 = WDTCON.1
#bit SWDTEN = WDTCON.0
#byte PORTB_2 = 0x106 // mirror
#byte PCLATH_2 = 0x10A // mirror
#byte INTCON_2 = 0x10B // mirror
#bit GIE_2 = INTCON_2.7
#bit PEIE_2 = INTCON_2.6
#bit TMR0IE_2 = INTCON_2.5
#bit INT0IE_2 = INTCON_2.4
#bit RBIE_2 = INTCON_2.3
#bit TMR0IF_2 = INTCON_2.2
#bit INT0IF_2 = INTCON_2.1
#bit RBIF_2 = INTCON_2.0
#byte EEDATA = 0x10C
#byte EEADR = 0x10D
#byte EEDATH = 0x10E
#byte EEADRH = 0x10F
 
// SFR Registers in Memory Bank 3
#byte INDF_3 = 0x180 // mirror
#byte OPTION_3 = 0x181 // mirror
#bit RBPU_3 = OPTION_3.7
#bit INTEDG_3 = OPTION_3.6
#bit T0CS_3 = OPTION_3.5
#bit T0SE_3 = OPTION_3.4
#bit PSA_3 = OPTION_3.3
#bit PS2_3 = OPTION_3.2
#bit PS1_3 = OPTION_3.1
#bit PS0_3 = OPTION_3.0
#byte PCL_3 = 0x182 // mirror
#byte STATUS_3 = 0x183 // mirror
#bit IRP_3 = STATUS_3.7
#bit RP1_3 = STATUS_3.6
#bit RP0_3 = STATUS_3.5
#bit TO_3 = STATUS_3.4
#bit PD_3 = STATUS_3.3
#bit Z_3 = STATUS_3.2
#bit DC_3 = STATUS_3.1
#bit C_3 = STATUS_3.0
#byte FSR_3 = 0x184 // mirror
#byte TRISB_3 = 0x186 // mirror
#byte PLATH_3 = 0x18A // mirror
#byte INTCON_3 = 0x18B // mirror
#bit GIE_3 = INTCON_3.7
#bit PEIE_3 = INTCON_3.6
#bit TMR0IE_3 = INTCON_3.5
#bit INT0IE_3 = INTCON_3.4
#bit RBIE_3 = INTCON_3.3
#bit TMR0IF_3 = INTCON_3.2
#bit INT0IF_3 = INTCON_3.1
#bit RBIF_3 = INTCON_3.0
#byte EECON1 = 0x18C
#bit EEPGD = EECON1.7
#bit FREE = EECON1.4
#bit WRERR = EECON1.3
#bit WREN = EECON1.2
#bit WR = EECON1.1
#bit RD = EECON1.0
#byte EECON2 = 0x18D
 
#list
/roboti/istrobot/laserus/88/laser.BAK
0,0 → 1,96
#include "laser.h"
#include "16F88_Reg.H"
 
#define SERVO PIN_B5 // Vystup pro rizeni serva
#define LASER PIN_B4 // Vstup pro cteni laseru
 
// kroutitka
#define CERVENA 0 // AN0
#define CERNA 1 // AN1
//#define ZELENA 3 // AN3
//#define MODRA 4 // AN4
 
//#define OFFSET 100 // Predni kolecko vprostred pri care vprostred
//#define HYSTERESE 3 // Rozdil mezi behem tam a zpet
 
boolean edge;
int8 uhel;
 
#int_EXT
EXT_isr()
{
int n, t1, t2, t;
 
set_timer0(0); // Vynulovani casovace pro 2ms
output_high(SERVO);
while(get_timer0()<(1000/256)); // Ceka 1ms
for(n=uhel; n>0; n--) delay_us(3); // Sirka impulzu podle uhlu
output_low(SERVO);
while(get_timer0()<(3000/256)); // Ceka do 3ms, nez zacne scanovat
 
set_timer0(0); // Vynulovani casovace pro zjisteni polohy cary
if(edge) // Zrcatko prejizdelo tam nebo zpet?
{
edge=false;
ext_int_edge(H_TO_L); // Pristi inerrupt bude od opacne hrany
INT0IF_1=0; // Povoleni dalsiho preruseni
enable_interrupts(INT_EXT);
enable_interrupts(GLOBAL);
// do
{
while(0==input(LASER)); // Ceka na detekci cary
// output_high(SERVO);
t1=get_timer0(); // Poznamena cas nabezne hrany
while(1==input(LASER)); // Ceka az zkonci cara
// output_low(SERVO);
t2=get_timer0(); // Poznamena cas sestupne hrany
t=t2-t1;
} //while((t<5) || (t>7)); // Cara je detekovana, kdyz trva mezi xx ms
if ((t>3) && (t<7)) uhel=(160-(read_adc()>>2))-t1;
set_adc_channel(1);
}
else
{
edge=true;
ext_int_edge(L_TO_H);
INT0IF_1=0; // Povoleni dalsiho preruseni
enable_interrupts(INT_EXT);
enable_interrupts(GLOBAL);
// do
{
while(0==input(LASER)); // Ceka na detekci cary
t1=get_timer0(); // Poznamena cas nabezne hrany
while(1==input(LASER)); // Ceka az zkonci cara
t2=get_timer0(); // Poznamena cas sestupne hrany
t=t2-t1;
} //while((t<5) || (t>7)); // Cara je detekovana, kdyz trva mezi xx ms
if ((t>3) && (t<7)) uhel=((read_adc()>>2)+32)+t1;
set_adc_channel(0);
}
while(true);
}
 
 
 
void main()
{
setup_adc_ports(sAN0|sAN1|VSS_VDD); // AD pro kroutitka
setup_adc(ADC_CLOCK_INTERNAL);
setup_spi(FALSE);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_256);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
setup_oscillator(False);
 
delay_ms(100);
set_adc_channel(0);
Delay_ms(1);
 
ext_int_edge(L_TO_H);
edge=true;
uhel=((read_adc()>>2)+32)+30;;
enable_interrupts(INT_EXT);
enable_interrupts(GLOBAL);
}
/roboti/istrobot/laserus/88/laser.PJT
0,0 → 1,41
[PROJECT]
Target=laser.HEX
Development_Mode=
Processor=0x688F
ToolSuite=CCS
 
[Directories]
Include=C:\Program Files\PICC\devices\;C:\Program Files\PICC\Dr
Library=
LinkerScript=
 
[Target Data]
FileList=C:\PIC\laserus\laser.c
BuildTool=C-COMPILER
OptionString=+FM
AdditionalOptionString=
BuildRequired=1
 
[laser.c]
Type=4
Path=
FileList=
BuildTool=
OptionString=
AdditionalOptionString=
 
[mru-list]
1=laser.c
 
[Windows]
0=0000 laser.c 0 0 796 451 3 0
 
[Opened Files]
1=C:\PIC\laserus\laser.c
2=C:\PIC\laserus\laser.h
3=C:\Program Files\PICC\devices\16F88.h
4=C:\PIC\laserus\16F88_Reg.H
5=
[Units]
Count=1
1=C:\PIC\laserus\laser.c (main)
/roboti/istrobot/laserus/88/laser.c
0,0 → 1,96
#include "laser.h"
#include "16F88_Reg.H"
 
#define SERVO PIN_B5 // Vystup pro rizeni serva
#define LASER PIN_B4 // Vstup pro cteni laseru
 
// kroutitka
#define CERVENA 0 // AN0
#define CERNA 1 // AN1
//#define ZELENA 3 // AN3
//#define MODRA 4 // AN4
 
//#define OFFSET 100 // Predni kolecko vprostred pri care vprostred
//#define HYSTERESE 3 // Rozdil mezi behem tam a zpet
 
boolean edge;
int8 uhel;
 
#int_EXT
EXT_isr()
{
int n, t1, t2, t;
 
set_timer0(0); // Vynulovani casovace pro 2ms
output_high(SERVO);
while(get_timer0()<(1000/256)); // Ceka 1ms
for(n=uhel; n>0; n--) delay_us(3); // Sirka impulzu podle uhlu
output_low(SERVO);
while(get_timer0()<(3000/256)); // Ceka do 3ms, nez zacne scanovat
 
set_timer0(0); // Vynulovani casovace pro zjisteni polohy cary
if(edge) // Zrcatko prejizdelo tam nebo zpet?
{
edge=false;
ext_int_edge(H_TO_L); // Pristi inerrupt bude od opacne hrany
INT0IF_1=0; // Povoleni dalsiho preruseni
enable_interrupts(INT_EXT);
enable_interrupts(GLOBAL);
// do
{
while(0==input(LASER)); // Ceka na detekci cary
// output_high(SERVO);
t1=get_timer0(); // Poznamena cas nabezne hrany
while(1==input(LASER)); // Ceka az zkonci cara
// output_low(SERVO);
t2=get_timer0(); // Poznamena cas sestupne hrany
t=t2-t1;
} //while((t<5) || (t>7)); // Cara je detekovana, kdyz trva mezi xx ms
if ((t>3) && (t<8)) uhel=(160-(read_adc()>>2))-t1;
set_adc_channel(1);
}
else
{
edge=true;
ext_int_edge(L_TO_H);
INT0IF_1=0; // Povoleni dalsiho preruseni
enable_interrupts(INT_EXT);
enable_interrupts(GLOBAL);
// do
{
while(0==input(LASER)); // Ceka na detekci cary
t1=get_timer0(); // Poznamena cas nabezne hrany
while(1==input(LASER)); // Ceka az zkonci cara
t2=get_timer0(); // Poznamena cas sestupne hrany
t=t2-t1;
} //while((t<5) || (t>7)); // Cara je detekovana, kdyz trva mezi xx ms
if ((t>3) && (t<8)) uhel=((read_adc()>>2)+32)+t1;
set_adc_channel(0);
}
while(true);
}
 
 
 
void main()
{
setup_adc_ports(sAN0|sAN1|VSS_VDD); // AD pro kroutitka
setup_adc(ADC_CLOCK_INTERNAL);
setup_spi(FALSE);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_256);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
setup_oscillator(False);
 
delay_ms(100);
set_adc_channel(0);
Delay_ms(1);
 
ext_int_edge(L_TO_H);
edge=true;
uhel=((read_adc()>>2)+32)+30;;
enable_interrupts(INT_EXT);
enable_interrupts(GLOBAL);
}
/roboti/istrobot/laserus/88/laser.cof
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/roboti/istrobot/laserus/88/laser.err
0,0 → 1,2
No Errors
0 Errors, 0 Warnings.
/roboti/istrobot/laserus/88/laser.h
0,0 → 1,18
#include <16F88.h>
#device adc=8
 
#FUSES NOWDT //No Watch Dog Timer
#FUSES XT //Crystal osc <= 4mhz
#FUSES NOPUT //No Power Up Timer
#FUSES MCLR //Master Clear pin enabled
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD //No EE protection
#FUSES NOWRT //Program memory not write protected
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOFCMEN //Fail-safe clock monitor disabled
#FUSES NOIESO //Internal External Switch Over mode disabled
 
#use delay(clock=4000000)
 
/roboti/istrobot/laserus/88/laser.hex
0,0 → 1,44
:1000000000308A00E7280000FF00030E8301A100F2
:100010007F08A0000A08A8008A01A00E0408A20018
:100020007708A3007808A4007908A5007A08A6003C
:100030007B08A700831383120B1E20288B183328FC
:10004000220884002308F7002408F8002508F90096
:100050002608FA002708FB0028088A00210E8300E2
:10006000FF0E7F0E09008A11352881018316861242
:10007000831286160108023C03183A282A08AE00AB
:10008000AE0803194828000000000000AE03402815
:10009000831686128312861201080A3C03184C2824
:1000A0008101291C92282910831601138B108312B9
:1000B0000B16C0308B048316061600308312061A06
:1000C0000130003A03195B280108AF0083160616B9
:1000D00000308312061A0130013C0319662801081A
:1000E000B0002F083002B1003108033C03188B2800
:1000F0003108073C031C8B281F151F197D281E087B
:10010000F700F70CF70C3F30F7057708A03CF80034
:100110002F087802AA000830F8001F08C7397804B1
:100120009F00CE282914831601178B1083120B16FB
:10013000C0308B048316061600308312061A013075
:10014000003A03199A280108AF00831606160030FA
:100150008312061A0130013C0319A5280108B000DA
:100160002F083002B1003108033C0318C8283108B9
:10017000073C031CC8281F151F19BC281E08F700C0
:10018000F70CF70C3F30F7057708203E2F07AA0041
:100190000030F8001F08C73978049F00CE288B1064
:1001A0008A1120282B30840000080319E62801302A
:1001B000F800F701F70BDA28F80BD9284A30F700D6
:1001C000F70BE02800000000800BD72800348401E2
:1001D0001F30830583161F129F121B0880399B0056
:1001E00007309C001F129F121B08803903389B00A8
:1001F0001F1383121F179F1783169F1383121F1439
:10020000941283160611861406120030831294008D
:10021000831694000108C0390738810083129001C9
:100220000030F800920000308316920007309C00E6
:1002300005080330F700F70B1B291C0883120D1368
:1002400083169D018F010F0864308312AB00D2200A
:100250000030F8001F08C73978049F000130AB0058
:10026000D22083160117831229141F151F1936294E
:100270001E08F700F70CF70C3F30F7057708203E13
:0C0280001E3EAA000B16C0308B04630069
:04400E00293FFC3F0B
:00000001FF
;PIC16F88
/roboti/istrobot/laserus/88/laser.lst
0,0 → 1,469
CCS PCM C Compiler, Version 3.245, 27853 22-I-07 23:13
 
Filename: C:\PIC\laserus\laser.lst
 
ROM used: 326 words (8%)
Largest free fragment is 2048
RAM used: 19 (11%) at main() level
26 (15%) worst case
Stack: 2 worst case (1 in main + 1 for interrupts)
 
*
0000: MOVLW 00
0001: MOVWF 0A
0002: GOTO 0E7
0003: NOP
0004: MOVWF 7F
0005: SWAPF 03,W
0006: CLRF 03
0007: MOVWF 21
0008: MOVF 7F,W
0009: MOVWF 20
000A: MOVF 0A,W
000B: MOVWF 28
000C: CLRF 0A
000D: SWAPF 20,F
000E: MOVF 04,W
000F: MOVWF 22
0010: MOVF 77,W
0011: MOVWF 23
0012: MOVF 78,W
0013: MOVWF 24
0014: MOVF 79,W
0015: MOVWF 25
0016: MOVF 7A,W
0017: MOVWF 26
0018: MOVF 7B,W
0019: MOVWF 27
001A: BCF 03.7
001B: BCF 03.5
001C: BTFSS 0B.4
001D: GOTO 020
001E: BTFSC 0B.1
001F: GOTO 033
0020: MOVF 22,W
0021: MOVWF 04
0022: MOVF 23,W
0023: MOVWF 77
0024: MOVF 24,W
0025: MOVWF 78
0026: MOVF 25,W
0027: MOVWF 79
0028: MOVF 26,W
0029: MOVWF 7A
002A: MOVF 27,W
002B: MOVWF 7B
002C: MOVF 28,W
002D: MOVWF 0A
002E: SWAPF 21,W
002F: MOVWF 03
0030: SWAPF 7F,F
0031: SWAPF 7F,W
0032: RETFIE
0033: BCF 0A.3
0034: GOTO 035
.................... #include "laser.h"
.................... #include <16F88.h>
.................... //////// Standard Header file for the PIC16F88 device ////////////////
.................... #device PIC16F88
.................... #list
....................
.................... #device adc=8
....................
.................... #FUSES NOWDT //No Watch Dog Timer
.................... #FUSES XT //Crystal osc <= 4mhz
.................... #FUSES NOPUT //No Power Up Timer
.................... #FUSES MCLR //Master Clear pin enabled
.................... #FUSES NOBROWNOUT //No brownout reset
.................... #FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
.................... #FUSES NOCPD //No EE protection
.................... #FUSES NOWRT //Program memory not write protected
.................... #FUSES NODEBUG //No Debug mode for ICD
.................... #FUSES NOPROTECT //Code not protected from reading
.................... #FUSES NOFCMEN //Fail-safe clock monitor disabled
.................... #FUSES NOIESO //Internal External Switch Over mode disabled
....................
.................... #use delay(clock=4000000)
*
00D2: MOVLW 2B
00D3: MOVWF 04
00D4: MOVF 00,W
00D5: BTFSC 03.2
00D6: GOTO 0E6
00D7: MOVLW 01
00D8: MOVWF 78
00D9: CLRF 77
00DA: DECFSZ 77,F
00DB: GOTO 0DA
00DC: DECFSZ 78,F
00DD: GOTO 0D9
00DE: MOVLW 4A
00DF: MOVWF 77
00E0: DECFSZ 77,F
00E1: GOTO 0E0
00E2: NOP
00E3: NOP
00E4: DECFSZ 00,F
00E5: GOTO 0D7
00E6: RETLW 00
....................
....................
.................... #include "16F88_Reg.H"
.................... // Komplete definition of all Special Feature Registers
.................... // of PIC16F87 and PIC16F88
.................... // (c)miho 2005
....................
.................... #list
....................
....................
.................... #define SERVO PIN_B5 // Vystup pro rizeni serva
.................... #define LASER PIN_B4 // Vstup pro cteni laseru
....................
.................... // kroutitka
.................... #define CERVENA 0 // AN0
.................... #define CERNA 1 // AN1
.................... //#define ZELENA 3 // AN3
.................... //#define MODRA 4 // AN4
....................
.................... //#define OFFSET 100 // Predni kolecko vprostred pri care vprostred
.................... //#define HYSTERESE 3 // Rozdil mezi behem tam a zpet
....................
.................... boolean edge;
.................... int8 uhel;
....................
.................... #int_EXT
.................... EXT_isr()
.................... {
.................... int n, t1, t2, t;
....................
.................... set_timer0(0); // Vynulovani casovace pro 2ms
*
0035: CLRF 01
.................... output_high(SERVO);
0036: BSF 03.5
0037: BCF 06.5
0038: BCF 03.5
0039: BSF 06.5
.................... while(get_timer0()<(1000/256)); // Ceka 1ms
003A: MOVF 01,W
003B: SUBLW 02
003C: BTFSC 03.0
003D: GOTO 03A
.................... for(n=uhel; n>0; n--) delay_us(3); // Sirka impulzu podle uhlu
003E: MOVF 2A,W
003F: MOVWF 2E
0040: MOVF 2E,F
0041: BTFSC 03.2
0042: GOTO 048
0043: NOP
0044: NOP
0045: NOP
0046: DECF 2E,F
0047: GOTO 040
.................... output_low(SERVO);
0048: BSF 03.5
0049: BCF 06.5
004A: BCF 03.5
004B: BCF 06.5
.................... while(get_timer0()<(3000/256)); // Ceka do 3ms, nez zacne scanovat
004C: MOVF 01,W
004D: SUBLW 0A
004E: BTFSC 03.0
004F: GOTO 04C
....................
.................... set_timer0(0); // Vynulovani casovace pro zjisteni polohy cary
0050: CLRF 01
.................... if(edge) // Zrcatko prejizdelo tam nebo zpet?
0051: BTFSS 29.0
0052: GOTO 092
.................... {
.................... edge=false;
0053: BCF 29.0
.................... ext_int_edge(H_TO_L); // Pristi inerrupt bude od opacne hrany
0054: BSF 03.5
0055: BCF 01.6
.................... INT0IF_1=0; // Povoleni dalsiho preruseni
0056: BCF 0B.1
.................... enable_interrupts(INT_EXT);
0057: BCF 03.5
0058: BSF 0B.4
.................... enable_interrupts(GLOBAL);
0059: MOVLW C0
005A: IORWF 0B,F
.................... // do
.................... {
.................... while(0==input(LASER)); // Ceka na detekci cary
005B: BSF 03.5
005C: BSF 06.4
005D: MOVLW 00
005E: BCF 03.5
005F: BTFSC 06.4
0060: MOVLW 01
0061: XORLW 00
0062: BTFSC 03.2
0063: GOTO 05B
.................... // output_high(SERVO);
.................... t1=get_timer0(); // Poznamena cas nabezne hrany
0064: MOVF 01,W
0065: MOVWF 2F
.................... while(1==input(LASER)); // Ceka az zkonci cara
0066: BSF 03.5
0067: BSF 06.4
0068: MOVLW 00
0069: BCF 03.5
006A: BTFSC 06.4
006B: MOVLW 01
006C: SUBLW 01
006D: BTFSC 03.2
006E: GOTO 066
.................... // output_low(SERVO);
.................... t2=get_timer0(); // Poznamena cas sestupne hrany
006F: MOVF 01,W
0070: MOVWF 30
.................... t=t2-t1;
0071: MOVF 2F,W
0072: SUBWF 30,W
0073: MOVWF 31
.................... } //while((t<5) || (t>7)); // Cara je detekovana, kdyz trva mezi xx ms
.................... if ((t>3) && (t<8)) uhel=(160-(read_adc()>>2))-t1;
0074: MOVF 31,W
0075: SUBLW 03
0076: BTFSC 03.0
0077: GOTO 08B
0078: MOVF 31,W
0079: SUBLW 07
007A: BTFSS 03.0
007B: GOTO 08B
007C: BSF 1F.2
007D: BTFSC 1F.2
007E: GOTO 07D
007F: MOVF 1E,W
0080: MOVWF 77
0081: RRF 77,F
0082: RRF 77,F
0083: MOVLW 3F
0084: ANDWF 77,F
0085: MOVF 77,W
0086: SUBLW A0
0087: MOVWF 78
0088: MOVF 2F,W
0089: SUBWF 78,W
008A: MOVWF 2A
.................... set_adc_channel(1);
008B: MOVLW 08
008C: MOVWF 78
008D: MOVF 1F,W
008E: ANDLW C7
008F: IORWF 78,W
0090: MOVWF 1F
.................... }
.................... else
0091: GOTO 0CE
.................... {
.................... edge=true;
0092: BSF 29.0
.................... ext_int_edge(L_TO_H);
0093: BSF 03.5
0094: BSF 01.6
.................... INT0IF_1=0; // Povoleni dalsiho preruseni
0095: BCF 0B.1
.................... enable_interrupts(INT_EXT);
0096: BCF 03.5
0097: BSF 0B.4
.................... enable_interrupts(GLOBAL);
0098: MOVLW C0
0099: IORWF 0B,F
.................... // do
.................... {
.................... while(0==input(LASER)); // Ceka na detekci cary
009A: BSF 03.5
009B: BSF 06.4
009C: MOVLW 00
009D: BCF 03.5
009E: BTFSC 06.4
009F: MOVLW 01
00A0: XORLW 00
00A1: BTFSC 03.2
00A2: GOTO 09A
.................... t1=get_timer0(); // Poznamena cas nabezne hrany
00A3: MOVF 01,W
00A4: MOVWF 2F
.................... while(1==input(LASER)); // Ceka az zkonci cara
00A5: BSF 03.5
00A6: BSF 06.4
00A7: MOVLW 00
00A8: BCF 03.5
00A9: BTFSC 06.4
00AA: MOVLW 01
00AB: SUBLW 01
00AC: BTFSC 03.2
00AD: GOTO 0A5
.................... t2=get_timer0(); // Poznamena cas sestupne hrany
00AE: MOVF 01,W
00AF: MOVWF 30
.................... t=t2-t1;
00B0: MOVF 2F,W
00B1: SUBWF 30,W
00B2: MOVWF 31
.................... } //while((t<5) || (t>7)); // Cara je detekovana, kdyz trva mezi xx ms
.................... if ((t>3) && (t<8)) uhel=((read_adc()>>2)+32)+t1;
00B3: MOVF 31,W
00B4: SUBLW 03
00B5: BTFSC 03.0
00B6: GOTO 0C8
00B7: MOVF 31,W
00B8: SUBLW 07
00B9: BTFSS 03.0
00BA: GOTO 0C8
00BB: BSF 1F.2
00BC: BTFSC 1F.2
00BD: GOTO 0BC
00BE: MOVF 1E,W
00BF: MOVWF 77
00C0: RRF 77,F
00C1: RRF 77,F
00C2: MOVLW 3F
00C3: ANDWF 77,F
00C4: MOVF 77,W
00C5: ADDLW 20
00C6: ADDWF 2F,W
00C7: MOVWF 2A
.................... set_adc_channel(0);
00C8: MOVLW 00
00C9: MOVWF 78
00CA: MOVF 1F,W
00CB: ANDLW C7
00CC: IORWF 78,W
00CD: MOVWF 1F
.................... }
.................... while(true);
00CE: GOTO 0CE
.................... }
....................
....................
....................
00CF: BCF 0B.1
00D0: BCF 0A.3
00D1: GOTO 020
.................... void main()
.................... {
*
00E7: CLRF 04
00E8: MOVLW 1F
00E9: ANDWF 03,F
00EA: BSF 03.5
00EB: BCF 1F.4
00EC: BCF 1F.5
00ED: MOVF 1B,W
00EE: ANDLW 80
00EF: MOVWF 1B
00F0: MOVLW 07
00F1: MOVWF 1C
.................... setup_adc_ports(sAN0|sAN1|VSS_VDD); // AD pro kroutitka
00F2: BCF 1F.4
00F3: BCF 1F.5
00F4: MOVF 1B,W
00F5: ANDLW 80
00F6: IORLW 03
00F7: MOVWF 1B
.................... setup_adc(ADC_CLOCK_INTERNAL);
00F8: BCF 1F.6
00F9: BCF 03.5
00FA: BSF 1F.6
00FB: BSF 1F.7
00FC: BSF 03.5
00FD: BCF 1F.7
00FE: BCF 03.5
00FF: BSF 1F.0
.................... setup_spi(FALSE);
0100: BCF 14.5
0101: BSF 03.5
0102: BCF 06.2
0103: BSF 06.1
0104: BCF 06.4
0105: MOVLW 00
0106: BCF 03.5
0107: MOVWF 14
0108: BSF 03.5
0109: MOVWF 14
.................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_256);
010A: MOVF 01,W
010B: ANDLW C0
010C: IORLW 07
010D: MOVWF 01
.................... setup_timer_1(T1_DISABLED);
010E: BCF 03.5
010F: CLRF 10
.................... setup_timer_2(T2_DISABLED,0,1);
0110: MOVLW 00
0111: MOVWF 78
0112: MOVWF 12
0113: MOVLW 00
0114: BSF 03.5
0115: MOVWF 12
.................... setup_comparator(NC_NC_NC_NC);
0116: MOVLW 07
0117: MOVWF 1C
0118: MOVF 05,W
0119: MOVLW 03
011A: MOVWF 77
011B: DECFSZ 77,F
011C: GOTO 11B
011D: MOVF 1C,W
011E: BCF 03.5
011F: BCF 0D.6
.................... setup_vref(FALSE);
0120: BSF 03.5
0121: CLRF 1D
.................... setup_oscillator(False);
0122: CLRF 0F
0123: MOVF 0F,W
....................
.................... delay_ms(100);
0124: MOVLW 64
0125: BCF 03.5
0126: MOVWF 2B
0127: CALL 0D2
.................... set_adc_channel(0);
0128: MOVLW 00
0129: MOVWF 78
012A: MOVF 1F,W
012B: ANDLW C7
012C: IORWF 78,W
012D: MOVWF 1F
.................... Delay_ms(1);
012E: MOVLW 01
012F: MOVWF 2B
0130: CALL 0D2
....................
.................... ext_int_edge(L_TO_H);
0131: BSF 03.5
0132: BSF 01.6
.................... edge=true;
0133: BCF 03.5
0134: BSF 29.0
.................... uhel=((read_adc()>>2)+32)+30;;
0135: BSF 1F.2
0136: BTFSC 1F.2
0137: GOTO 136
0138: MOVF 1E,W
0139: MOVWF 77
013A: RRF 77,F
013B: RRF 77,F
013C: MOVLW 3F
013D: ANDWF 77,F
013E: MOVF 77,W
013F: ADDLW 20
0140: ADDLW 1E
0141: MOVWF 2A
.................... enable_interrupts(INT_EXT);
0142: BSF 0B.4
.................... enable_interrupts(GLOBAL);
0143: MOVLW C0
0144: IORWF 0B,F
.................... }
0145: SLEEP
 
Configuration Fuses:
Word 1: 3F29 XT NOWDT NOPUT MCLR NOBROWNOUT NOLVP NOCPD NOWRT NODEBUG CCPB0 NOPROTECT
Word 2: 3FFC NOFCMEN NOIESO
/roboti/istrobot/laserus/88/laser.sta
0,0 → 1,32
 
ROM used: 326 (8%)
326 (8%) including unused fragments
 
0 Average locations per line
5 Average locations per statement
 
RAM used: 19 (11%) at main() level
26 (15%) worst case
 
Lines Stmts % Files
----- ----- --- -----
97 65 100 C:\PIC\laserus\laser.c
19 0 0 C:\PIC\laserus\laser.h
279 0 0 C:\Program Files\PICC\devices\16F88.h
299 0 0 C:\PIC\laserus\16F88_Reg.H
----- -----
1388 130 Total
 
Page ROM % RAM Functions:
---- --- --- --- ----------
0 21 6 1 @delay_ms1
0 157 48 7 EXT_isr
0 95 29 3 main
 
Segment Used Free
--------- ---- ----
00000-00003 4 0
00004-00034 49 0
00035-007FF 273 1722
00800-00FFF 0 2048
 
/roboti/istrobot/laserus/88/laser.sym
0,0 → 1,342
000 INDF
001 TMR0
003 STATUS
003.0 C
003.1 DC
003.2 Z
003.3 PD
003.4 TO
003.5 RP0
003.6 RP1
003.7 IRP
005 PORTA
006 PORTB
00A PCLATH
00B INTCON
00B.0 RBIF
00B.1 INT0IF
00B.2 TMR0IF
00B.3 RBIE
00B.4 INT0IE
00B.5 TMR0IE
00B.6 PEIE
00B.7 GIE
00C PIR1
00C.0 TMR1IF
00C.1 TMR2IF
00C.2 CCP1IF
00C.3 SSPIF
00C.4 TXIF
00C.5 RCIF
00C.6 ADIF
00D PIR2
00D.4 EEIF
00D.6 CMIF
00D.7 OSFIF
00E TMR1L
00F TMR1H
010 T1CON
010.0 TMR1ON
010.1 TMR1CS
010.2 T1SYNC
010.3 T1OSCEN
010.4 T1CKPS0
010.5 T1CKPS1
010.6 T1RUN
011 TMR2
012.0 T2CKPS0
012 T2CON
012.1 T2CKPS1
012.2 TMR2ON
012.3 TOUTPS0
012.4 TOUTPS1
012.5 TOUTPS2
012.6 TOUTPS3
013 SSPBUF
014 SSPCON1
014.0 SSPM0
014.1 SSPM1
014.2 SSPM2
014.3 SSPM3
014.4 CKP
014.5 SSPEN
014.6 SSPOV
014.7 WCOL
015 CCPR1L
015 CCP_1_LOW
015-016 CCP_1
016 CCPR1H
016 CCP_1_HIGH
017 CCP1CON
017.0 CCP1M0
017.1 CCP1M1
017.2 CCP1M2
017.3 CCP1M3
017.4 CCP1Y
017.5 CCP1X
018 RCSTA
018.0 RX9D
018.1 OERR
018.2 FERR
018.3 ADDEN
018.4 CREN
018.5 SREN
018.6 RX9
018.7 SPEN
019 TXREG
01A RCREG
01E ADRESH
01F.0 ADON
01F ADCON0
01F.2 GO
01F.3 CHS0
01F.4 CHS1
01F.5 CHS2
01F.6 ADCS0
01F.7 ADCS1
020 @INTERRUPT_AREA
021 @INTERRUPT_AREA
022 @INTERRUPT_AREA
023 @INTERRUPT_AREA
024 @INTERRUPT_AREA
025 @INTERRUPT_AREA
026 @INTERRUPT_AREA
027 @INTERRUPT_AREA
028 @INTERRUPT_AREA
029.0 edge
02A uhel
02B @delay_ms1.P1
02B main.@SCRATCH
02C main.@SCRATCH
02D main.@SCRATCH
02E EXT_isr.n
02F EXT_isr.t1
030 EXT_isr.t2
031 EXT_isr.t
032 EXT_isr.@SCRATCH
033 EXT_isr.@SCRATCH
034 EXT_isr.@SCRATCH
077 @SCRATCH
078 @SCRATCH
078 _RETURN_
079 @SCRATCH
07A @SCRATCH
07B @SCRATCH
080 INDF_1
081 OPTION
081.0 PS0
081.1 PS1
081.2 PS2
081.3 PSA
081.4 T0SE
081.5 T0CS
081.6 INTEDG
081.7 RBPU
082 PCL
083 STATUS_1
083.0 C_1
083.1 DC_1
083.2 Z_1
083.3 PD_1
083.4 TO_1
083.5 RP0_1
083.6 RP1_1
083.7 IRP_1
084 FSR
085 TRISA
086 TRISB
08A PCLATH_1
08B INTCON_1
08B.0 RBIF_1
08B.1 INT0IF_1
08B.2 TMR0IF_1
08B.3 RBIE_1
08B.4 INT0IE_1
08B.5 TMR0IE_1
08B.6 PEIE_1
08B.7 GIE_1
08C.0 TMR1IE
08C PIE1
08C.1 TMR2IE
08C.2 CCP1IE
08C.3 SSPIE
08C.4 TXIE
08C.5 RCIE
08C.6 ADIE
08D PIE2
08D.4 EEIE
08D.6 CMIE
08D.7 OSFIE
08E.0 BOR
08E PCON
08E.1 POR
08F OSCCON
08F.0 SCS0
08F.1 SCS1
08F.2 IOFS
08F.3 OSTS
08F.4 IRCF0
08F.5 IRCF1
08F.6 IRCF2
090.0 TUN0
090 OSCTUNE
090.1 TUN1
090.2 TUN2
090.3 TUN3
090.4 TUN4
090.5 TUN5
092 PR2
093 SSPADD
094 SSPSTAT
094.0 BF
094.1 UA
094.2 RW
094.3 S
094.4 P
094.5 DA
094.6 CKE
094.7 SMP
098 TXSTA
098.0 TX9D
098.1 TRMT
098.2 BRGH
098.4 SYNC
098.5 TXEN
098.6 TX9
098.7 CSRC
099 SPBRG
09B.0 ANS0
09B ANSEL
09B.1 ANS1
09B.2 ANS2
09B.3 ANS3
09B.4 ANS4
09B.5 ANS5
09B.6 ANS6
09C CMCON
09C.0 CM0
09C.1 CM1
09C.2 CM2
09C.3 CIS
09C.4 C1INV
09C.5 C2INV
09C.6 C1OUT
09C.7 C2OUT
09D.0 CVR0
09D CVRCON
09D.1 CVR1
09D.2 CVR2
09D.3 CVR3
09D.5 CVRR
09D.6 CVROE
09D.7 CVREN
09E ADRESL
09F ADCON1
09F.4 VCFG0
09F.5 VCFG1
09F.6 ADCS2
09F.7 ADFM
100 INDF_2
101 TMR0_2
102 PCL_2
103 STATUS_2
103.0 C_2
103.1 DC_2
103.2 Z_2
103.3 PD_2
103.4 TO_2
103.5 RP0_2
103.6 RP1_2
103.7 IRP_2
104 FSR_2
105.0 SWDTEN
105 WDTCON
105.1 WDTPS0
105.2 WDTPS1
105.3 WDTPS2
105.4 WDTPS3
106 PORTB_2
10A PCLATH_2
10B INTCON_2
10B.0 RBIF_2
10B.1 INT0IF_2
10B.2 TMR0IF_2
10B.3 RBIE_2
10B.4 INT0IE_2
10B.5 TMR0IE_2
10B.6 PEIE_2
10B.7 GIE_2
10C EEDATA
10D EEADR
10E EEDATH
10F EEADRH
180 INDF_3
181.0 PS0_3
181 OPTION_3
181.1 PS1_3
181.2 PS2_3
181.3 PSA_3
181.4 T0SE_3
181.5 T0CS_3
181.6 INTEDG_3
181.7 RBPU_3
182 PCL_3
183.0 C_3
183 STATUS_3
183.1 DC_3
183.2 Z_3
183.3 PD_3
183.4 TO_3
183.5 RP0_3
183.6 RP1_3
183.7 IRP_3
184 FSR_3
186 TRISB_3
18A PLATH_3
18B INTCON_3
18B.0 RBIF_3
18B.1 INT0IF_3
18B.2 TMR0IF_3
18B.3 RBIE_3
18B.4 INT0IE_3
18B.5 TMR0IE_3
18B.6 PEIE_3
18B.7 GIE_3
18C EECON1
18C.0 RD
18C.1 WR
18C.2 WREN
18C.3 WRERR
18C.4 FREE
18C.7 EEPGD
18D EECON2
 
00D2 @delay_ms1
0035 EXT_isr
00E7 main
00E7 @cinit
 
Project Files:
C:\PIC\laserus\laser.c
C:\PIC\laserus\laser.h
C:\Program Files\PICC\devices\16F88.h
C:\PIC\laserus\16F88_Reg.H
 
Units:
C:\PIC\laserus\laser.c (main)
 
Compiler Settings:
Processor: PIC16F88
Pointer Size: 8
ADC Range: 0-255
Opt Level: 9
Short,Int,Long: 1,8,16
 
Output Files:
Errors: C:\PIC\laserus\laser.err
INHX8: C:\PIC\laserus\laser.hex
Symbols: C:\PIC\laserus\laser.sym
List: C:\PIC\laserus\laser.lst
Debug/COFF: C:\PIC\laserus\laser.cof
Call Tree: C:\PIC\laserus\laser.tre
Statistics: C:\PIC\laserus\laser.sta
/roboti/istrobot/laserus/88/laser.tre
0,0 → 1,6
ÀÄlaser
ÃÄmain 0/95 Ram=3
³ ÃÄ??0??
³ ÃÄ@delay_ms1 0/21 Ram=1
³ ÀÄ@delay_ms1 0/21 Ram=1
ÀÄEXT_isr 0/157 Ram=7