Subversion Repositories svnkaklik

Compare Revisions

No changes between revisions

Ignore whitespace Rev 1 → Rev 2

/roboti/istrobot/3Orbis/bak/02/master/main.BAK
0,0 → 1,170
#include ".\main.h"
 
#use rtos (timer=2, minor_cycle=2ms)
 
unsigned int8 sensors; // pomocna promenna pro cteni cidel na caru
unsigned int8 line; // na ktere strane byla detekovana cara
unsigned int8 dira; // pocita dobu po kterou je ztracena cara
unsigned int8 uhel; // urcuje aktualni uhel zataceni
 
signed int16 Lmotor; // promene, ktere urcuji velikost vykonu na levem
signed int16 Rmotor; // a pravem motoru
 
#define LMAX 190 // maximalni zatoceni doleva
#define RMAX 60 // maximalni zatoceni doprava
#define STRED 128 // sredni poloha zadniho kolecka
 
// servo
#define SERVO PIN_A2
 
//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
 
// makro pro PWM
#define GO(motor, direction, power) if(get_timer0()<=power) \
{direction##motor;} else {stop##motor;}
 
 
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/*
void diagnostika()
{
if(input(SW1))STOPR;STOPL;While(TRUE);
// if(LSENSOR==true) output_high(LED2); else output_low(LED2);
// if(RSENSOR==true) output_high(LED1); else output_low(LED1);
}
*/
////////////////////////////////////////////////////////////////////////////////
#task (rate=16ms,max=2ms)
void zatoc() // ridi servo ktere otaci kolem
{
unsigned int8 n;
output_high(SERVO);
delay_us(1200);
for(n=uhel; n>0; n--);
output_low(SERVO);
}
 
////////////////////////////////////////////////////////////////////////////////
#task (rate=2ms, max=500us)
void motory() // umoznuje nezavisle rizeni vykonu na obou motorech
{
 
if(Rmotor>0) //pravy motor
{
GO(R, F, Rmotor);
}
 
if(Rmotor==0) STOPR;
 
if(Rmotor<0)
{
GO(R, B, abs(Rmotor));
}
 
if(Lmotor>0) // levy motor
{
GO(L, F, Lmotor);
}
 
if(Lmotor==0) STOPL;
 
if(Lmotor<0)
{
GO(L, B, abs(Lmotor));
}
}
////////////////////////////////////////////////////////////////////////////////
#task (rate=4ms, max=500us, queue=0)
void rizeni()
{
rizeni:
 
sensors = spi_read(0); // cteni senzoru na caru
output_high(STROBE);
output_low(STROBE);
 
if(bit_test(sensors,0)) //*......// // z duvodu zkraceni doby reakce se cidla nevyhodnocuji poporade ale od krajnich k prostrednimu
{
uhel=LMAX;
Lmotor=60;Rmotor=127;
goto rizeni;
}
if(bit_test(sensors,6)) //......*//
{
uhel=RMAX;
Rmotor=60;Lmotor=127;
goto rizeni;
}
if(bit_test(sensors,1)) //.*.....//
{
uhel=STRED+30;
Lmotor=70;Rmotor=127;
goto rizeni;
}
if(bit_test(sensors,5)) //.....*.//
{
uhel=STRED-30;
Rmotor=70;Lmotor=127;
goto rizeni;
}
if(bit_test(sensors,2)) //..*....//
{
uhel=STRED+20;
Lmotor=90;Rmotor=127;
goto rizeni;
}
if(bit_test(sensors,4)) //....*..//
{
uhel=STRED-20;
Rmotor=90;Lmotor=127;
goto rizeni;
}
if(bit_test(sensors,3)) //...*...//
{
uhel=STRED;
Lmotor=100;Rmotor=100;
goto rizeni;
}
 
/*STOPL;STOPR;
if(bit_test(sensors,7))
{
 
}*/
}
////////////////////////////////////////////////////////////////////////////////
void main()
{
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_CLOCK_INTERNAL);
setup_spi(SPI_MASTER|SPI_H_TO_L|SPI_XMIT_L_TO_H|SPI_CLK_DIV_4);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_oscillator(OSC_8MHZ|OSC_INTRC);
// set_pwm1_duty(0); // Spust PWM, ale zatim s trvalou 0 na vystupu
// setup_ccp1(CCP_PWM);
// setup_timer_2(T2_DIV_BY_16,200,1); // perioda
// setup_timer_2(T2_DIV_BY_4,255,10); // Casovac pro regulaci
 
STOPR; STOPL;
uhel=STRED;
// diagnostika();
Lmotor=0;
Rmotor=0;
rtos_run();
 
}
/roboti/istrobot/3Orbis/bak/02/master/main.HEX
0,0 → 1,76
:1000000000308A008F2900000A108A100A11820726
:100010002934003430340034373400343F30840025
:100020000008031925280230F800BF30F7006400EB
:10003000F70B1728F80B15289630F700F70B1E283A
:10004000000000006400800B13288A11402808304B
:10005000BF02031C36283F3084000310800C0008C8
:100060000319362834286400800B33288A1143286A
:10007000831605118312051564000130BF000E2898
:10008000C730BF0027282408BE00BE0803194A282D
:10009000BE03452883160511831205113830AE00C2
:1000A0000030AF008A11362A0034A81B7D28A8082A
:1000B000031D5E282708003C03187D280108801FC7
:1000C0006428A81F6C286628A81B7528A808031D8B
:1000D0006C282702031C7528831685138312851349
:1000E00083160513831205177D28831605138312C3
:1000F00005138316851383128513A708031D87280C
:10010000A808031D87288316051383120513831679
:10011000851383128513A81FBD280108C000280875
:10012000FA002708A81F9D282708003CF700FA01BD
:100130002808031C280FFA027708F800C01FA3281C
:10014000FA1FAC28A528FA1BB528FA08031DAC280D
:1001500040087802031CB528831605138312051383
:100160008316851383128517BD2883160513831202
:1001700005138316851383128513A61BE528A6088D
:10018000031DC6282508003C0318E5280108801F28
:10019000CC28A61FD428CE28A61BDD28A608031D20
:1001A000D4282502031CDD288316851083128510B0
:1001B0008316051083120514E52883160510831293
:1001C00005108316851083128510A508031DEF28DE
:1001D000A608031DEF288316051083120510831649
:1001E000851083128510A61F25290108C000260846
:1001F000FA002508A61F05292508003CF700FA018A
:100200002608031C260FFA027708F800C01F0B29E6
:10021000FA1F14290D29FA1B1D29FA08031D142998
:1002200040087802031C1D2983160510831205104F
:1002300083168510831285142529831605108312D1
:10024000051083168510831285105530B5000030D7
:10025000B6008A11362A0034130893018316141845
:10026000332983122E2983121308A1008316061046
:10027000831206148316061083120610211C4829C7
:10028000BE30A400A601A501A8017F30A7002C293B
:10029000211F52293C30A400A801A701A6017F30EC
:1002A000A5002C29A11C5D299E30A400A601463082
:1002B000A500A8017F30A7002C29A11E6829623063
:1002C000A400A8014630A700A6017F30A5002C2974
:1002D000211D73299430A400A6015A30A500A8015D
:1002E0007F30A7002C29211E7E296C30A400A80194
:1002F0005A30A700A6017F30A5002C29A11D88290E
:100300008030A400A6016430A500A801A7002C2914
:100310002C30BC000130BD008A11362A0034840123
:100320001F308305703083168F001F129F121B0829
:1003300080399B0007309C001F129F121B088039D8
:100340009B001F1383121F179F1783169F1383127F
:100350001F1494128316061186140612303083126D
:1003600094000030831694000108C73908388100D2
:1003700083129001723083168F00051383120513C8
:1003800083168513831285138316051083120510B7
:1003900083168510831285108030A400A601A50164
:1003A000A801A701A901AB010830AA00AD010130E5
:1003B000AC003830AE000030AF00B001B201013007
:1003C000B100B401B3015530B5000030B600B7013B
:1003D000B9010230B800BB01BA012C30BC000130B9
:1003E000BD00A0010030F80006389200FA308316F4
:1003F000920083128C100030F80006389200FA3018
:100400008316920083128C100310200DF700042035
:10041000F900013077070420FA0079088400000809
:10042000F900840A0008F700840A0008F800840A2A
:10043000800A0008FA00031D202A840A800A840327
:10044000840A00087802031D382A77087A02031DFF
:10045000382A84038001840A8001840AF91B382A1F
:10046000840A00088A0084030008820083120313B0
:10047000A00A03302002031D042AA0018C1C422A7A
:0C0480008316022A3E2AFF30A000630011
:04400E00F83FFF3F39
:00000001FF
;PIC16F88
/roboti/istrobot/3Orbis/bak/02/master/main.LST
0,0 → 1,780
CCS PCM C Compiler, Version 3.245, 27853 01-IV-06 23:13
 
Filename: D:\KAKLIK\programy\PIC_C\roboti\istrobot\3Orbis\main.lst
 
ROM used: 582 words (14%)
Largest free fragment is 2048
RAM used: 35 (20%) at main() level
38 (22%) worst case
Stack: 3 worst case (1 in main + 2 for interrupts)
 
*
0000: MOVLW 00
0001: MOVWF 0A
0002: GOTO 18F
0003: NOP
.................... #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 BROWNOUT //Reset when brownout detected
.................... #FUSES LVP //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 FCMEN //Fail-safe clock monitor enabled
.................... #FUSES IESO //Internal External Switch Over mode enabled
....................
.................... #use delay(clock=8000000,RESTART_WDT)
000E: MOVLW 3F
000F: MOVWF 04
0010: MOVF 00,W
0011: BTFSC 03.2
0012: GOTO 025
0013: MOVLW 02
0014: MOVWF 78
0015: MOVLW BF
0016: MOVWF 77
0017: CLRWDT
0018: DECFSZ 77,F
0019: GOTO 017
001A: DECFSZ 78,F
001B: GOTO 015
001C: MOVLW 96
001D: MOVWF 77
001E: DECFSZ 77,F
001F: GOTO 01E
0020: NOP
0021: NOP
0022: CLRWDT
0023: DECFSZ 00,F
0024: GOTO 013
0025: BCF 0A.3
0026: GOTO 040 (RETURN)
0027: MOVLW 08
0028: SUBWF 3F,F
0029: BTFSS 03.0
002A: GOTO 036
002B: MOVLW 3F
002C: MOVWF 04
002D: BCF 03.0
002E: RRF 00,F
002F: MOVF 00,W
0030: BTFSC 03.2
0031: GOTO 036
0032: GOTO 034
0033: CLRWDT
0034: DECFSZ 00,F
0035: GOTO 033
0036: BCF 0A.3
0037: GOTO 043 (RETURN)
....................
....................
....................
.................... #use rtos (timer=2, minor_cycle=2ms)
....................
.................... unsigned int8 sensors; // pomocna promenna pro cteni cidel na caru
.................... unsigned int8 line; // na ktere strane byla detekovana cara
.................... unsigned int8 dira; // pocita dobu po kterou je ztracena cara
.................... unsigned int8 uhel; // urcuje aktualni uhel zataceni
....................
.................... signed int16 Lmotor; // promene, ktere urcuji velikost vykonu na levem
.................... signed int16 Rmotor; // a pravem motoru
....................
.................... #define LMAX 190 // maximalni zatoceni doleva
.................... #define RMAX 60 // maximalni zatoceni doprava
.................... #define STRED 128 // sredni poloha zadniho kolecka
....................
.................... // servo
.................... #define SERVO PIN_A2
....................
.................... //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
....................
.................... // makro pro PWM
.................... #define GO(motor, direction, power) if(get_timer0()<=power) \
.................... {direction##motor;} else {stop##motor;}
....................
....................
.................... ////////////////////////////////////////////////////////////////////////////////
.................... ////////////////////////////////////////////////////////////////////////////////
.................... /*
.................... void diagnostika()
.................... {
.................... if(input(SW1))STOPR;STOPL;While(TRUE);
.................... // if(LSENSOR==true) output_high(LED2); else output_low(LED2);
.................... // if(RSENSOR==true) output_high(LED1); else output_low(LED1);
.................... }
.................... */
.................... ////////////////////////////////////////////////////////////////////////////////
.................... #task (rate=16ms,max=2ms)
.................... void zatoc() // ridi servo ktere otaci kolem
.................... {
.................... unsigned int8 n;
.................... output_high(SERVO);
0038: BSF 03.5
0039: BCF 05.2
003A: BCF 03.5
003B: BSF 05.2
.................... delay_us(1200);
003C: CLRWDT
003D: MOVLW 01
003E: MOVWF 3F
003F: GOTO 00E
0040: MOVLW C7
0041: MOVWF 3F
0042: GOTO 027
.................... for(n=uhel; n>0; n--);
0043: MOVF 24,W
0044: MOVWF 3E
0045: MOVF 3E,F
0046: BTFSC 03.2
0047: GOTO 04A
0048: DECF 3E,F
0049: GOTO 045
.................... output_low(SERVO);
004A: BSF 03.5
004B: BCF 05.2
004C: BCF 03.5
004D: BCF 05.2
.................... }
004E: MOVLW 38
004F: MOVWF 2E
0050: MOVLW 00
0051: MOVWF 2F
0052: BCF 0A.3
0053: GOTO 236
0054: RETLW 00
....................
.................... ////////////////////////////////////////////////////////////////////////////////
.................... #task (rate=2ms, max=500us)
.................... void motory() // umoznuje nezavisle rizeni vykonu na obou motorech
.................... {
....................
.................... if(Rmotor>0) //pravy motor
0055: BTFSC 28.7
0056: GOTO 07D
0057: MOVF 28,F
0058: BTFSS 03.2
0059: GOTO 05E
005A: MOVF 27,W
005B: SUBLW 00
005C: BTFSC 03.0
005D: GOTO 07D
.................... {
.................... GO(R, F, Rmotor);
005E: MOVF 01,W
005F: BTFSS 00.7
0060: GOTO 064
0061: BTFSS 28.7
0062: GOTO 06C
0063: GOTO 066
0064: BTFSC 28.7
0065: GOTO 075
0066: MOVF 28,F
0067: BTFSS 03.2
0068: GOTO 06C
0069: SUBWF 27,W
006A: BTFSS 03.0
006B: GOTO 075
006C: BSF 03.5
006D: BCF 05.7
006E: BCF 03.5
006F: BCF 05.7
0070: BSF 03.5
0071: BCF 05.6
0072: BCF 03.5
0073: BSF 05.6
0074: GOTO 07D
0075: BSF 03.5
0076: BCF 05.6
0077: BCF 03.5
0078: BCF 05.6
0079: BSF 03.5
007A: BCF 05.7
007B: BCF 03.5
007C: BCF 05.7
.................... }
....................
.................... if(Rmotor==0) STOPR;
007D: MOVF 27,F
007E: BTFSS 03.2
007F: GOTO 087
0080: MOVF 28,F
0081: BTFSS 03.2
0082: GOTO 087
0083: BSF 03.5
0084: BCF 05.6
0085: BCF 03.5
0086: BCF 05.6
0087: BSF 03.5
0088: BCF 05.7
0089: BCF 03.5
008A: BCF 05.7
....................
.................... if(Rmotor<0)
008B: BTFSS 28.7
008C: GOTO 0BD
.................... {
.................... GO(R, B, abs(Rmotor));
008D: MOVF 01,W
008E: MOVWF 40
008F: MOVF 28,W
0090: MOVWF 7A
0091: MOVF 27,W
0092: BTFSS 28.7
0093: GOTO 09D
0094: MOVF 27,W
0095: SUBLW 00
0096: MOVWF 77
0097: CLRF 7A
0098: MOVF 28,W
0099: BTFSS 03.0
009A: INCFSZ 28,W
009B: SUBWF 7A,F
009C: MOVF 77,W
009D: MOVWF 78
009E: BTFSS 40.7
009F: GOTO 0A3
00A0: BTFSS 7A.7
00A1: GOTO 0AC
00A2: GOTO 0A5
00A3: BTFSC 7A.7
00A4: GOTO 0B5
00A5: MOVF 7A,F
00A6: BTFSS 03.2
00A7: GOTO 0AC
00A8: MOVF 40,W
00A9: SUBWF 78,W
00AA: BTFSS 03.0
00AB: GOTO 0B5
00AC: BSF 03.5
00AD: BCF 05.6
00AE: BCF 03.5
00AF: BCF 05.6
00B0: BSF 03.5
00B1: BCF 05.7
00B2: BCF 03.5
00B3: BSF 05.7
00B4: GOTO 0BD
00B5: BSF 03.5
00B6: BCF 05.6
00B7: BCF 03.5
00B8: BCF 05.6
00B9: BSF 03.5
00BA: BCF 05.7
00BB: BCF 03.5
00BC: BCF 05.7
.................... }
....................
.................... if(Lmotor>0) // levy motor
00BD: BTFSC 26.7
00BE: GOTO 0E5
00BF: MOVF 26,F
00C0: BTFSS 03.2
00C1: GOTO 0C6
00C2: MOVF 25,W
00C3: SUBLW 00
00C4: BTFSC 03.0
00C5: GOTO 0E5
.................... {
.................... GO(L, F, Lmotor);
00C6: MOVF 01,W
00C7: BTFSS 00.7
00C8: GOTO 0CC
00C9: BTFSS 26.7
00CA: GOTO 0D4
00CB: GOTO 0CE
00CC: BTFSC 26.7
00CD: GOTO 0DD
00CE: MOVF 26,F
00CF: BTFSS 03.2
00D0: GOTO 0D4
00D1: SUBWF 25,W
00D2: BTFSS 03.0
00D3: GOTO 0DD
00D4: BSF 03.5
00D5: BCF 05.1
00D6: BCF 03.5
00D7: BCF 05.1
00D8: BSF 03.5
00D9: BCF 05.0
00DA: BCF 03.5
00DB: BSF 05.0
00DC: GOTO 0E5
00DD: BSF 03.5
00DE: BCF 05.0
00DF: BCF 03.5
00E0: BCF 05.0
00E1: BSF 03.5
00E2: BCF 05.1
00E3: BCF 03.5
00E4: BCF 05.1
.................... }
....................
.................... if(Lmotor==0) STOPL;
00E5: MOVF 25,F
00E6: BTFSS 03.2
00E7: GOTO 0EF
00E8: MOVF 26,F
00E9: BTFSS 03.2
00EA: GOTO 0EF
00EB: BSF 03.5
00EC: BCF 05.0
00ED: BCF 03.5
00EE: BCF 05.0
00EF: BSF 03.5
00F0: BCF 05.1
00F1: BCF 03.5
00F2: BCF 05.1
....................
.................... if(Lmotor<0)
00F3: BTFSS 26.7
00F4: GOTO 125
.................... {
.................... GO(L, B, abs(Lmotor));
00F5: MOVF 01,W
00F6: MOVWF 40
00F7: MOVF 26,W
00F8: MOVWF 7A
00F9: MOVF 25,W
00FA: BTFSS 26.7
00FB: GOTO 105
00FC: MOVF 25,W
00FD: SUBLW 00
00FE: MOVWF 77
00FF: CLRF 7A
0100: MOVF 26,W
0101: BTFSS 03.0
0102: INCFSZ 26,W
0103: SUBWF 7A,F
0104: MOVF 77,W
0105: MOVWF 78
0106: BTFSS 40.7
0107: GOTO 10B
0108: BTFSS 7A.7
0109: GOTO 114
010A: GOTO 10D
010B: BTFSC 7A.7
010C: GOTO 11D
010D: MOVF 7A,F
010E: BTFSS 03.2
010F: GOTO 114
0110: MOVF 40,W
0111: SUBWF 78,W
0112: BTFSS 03.0
0113: GOTO 11D
0114: BSF 03.5
0115: BCF 05.0
0116: BCF 03.5
0117: BCF 05.0
0118: BSF 03.5
0119: BCF 05.1
011A: BCF 03.5
011B: BSF 05.1
011C: GOTO 125
011D: BSF 03.5
011E: BCF 05.0
011F: BCF 03.5
0120: BCF 05.0
0121: BSF 03.5
0122: BCF 05.1
0123: BCF 03.5
0124: BCF 05.1
.................... }
.................... }
0125: MOVLW 55
0126: MOVWF 35
0127: MOVLW 00
0128: MOVWF 36
0129: BCF 0A.3
012A: GOTO 236
012B: RETLW 00
.................... ////////////////////////////////////////////////////////////////////////////////
.................... #task (rate=4ms, max=500us, queue=0)
.................... void rizeni()
.................... {
.................... rizeni:
....................
.................... sensors = spi_read(0); // cteni senzoru na caru
012C: MOVF 13,W
012D: CLRF 13
012E: BSF 03.5
012F: BTFSC 14.0
0130: GOTO 133
0131: BCF 03.5
0132: GOTO 12E
0133: BCF 03.5
0134: MOVF 13,W
0135: MOVWF 21
.................... output_high(STROBE);
0136: BSF 03.5
0137: BCF 06.0
0138: BCF 03.5
0139: BSF 06.0
.................... output_low(STROBE);
013A: BSF 03.5
013B: BCF 06.0
013C: BCF 03.5
013D: BCF 06.0
....................
.................... if(bit_test(sensors,0)) //*......// // z duvodu zkraceni doby reakce se cidla nevyhodnocuji poporade ale od krajnich k prostrednimu
013E: BTFSS 21.0
013F: GOTO 148
.................... {
.................... uhel=LMAX;
0140: MOVLW BE
0141: MOVWF 24
.................... Lmotor=0;Rmotor=127;
0142: CLRF 26
0143: CLRF 25
0144: CLRF 28
0145: MOVLW 7F
0146: MOVWF 27
.................... goto rizeni;
0147: GOTO 12C
.................... }
.................... if(bit_test(sensors,6)) //......*//
0148: BTFSS 21.6
0149: GOTO 152
.................... {
.................... uhel=RMAX;
014A: MOVLW 3C
014B: MOVWF 24
.................... Rmotor=0;Lmotor=127;
014C: CLRF 28
014D: CLRF 27
014E: CLRF 26
014F: MOVLW 7F
0150: MOVWF 25
.................... goto rizeni;
0151: GOTO 12C
.................... }
.................... if(bit_test(sensors,1)) //.*.....//
0152: BTFSS 21.1
0153: GOTO 15D
.................... {
.................... uhel=STRED+30;
0154: MOVLW 9E
0155: MOVWF 24
.................... Lmotor=70;Rmotor=127;
0156: CLRF 26
0157: MOVLW 46
0158: MOVWF 25
0159: CLRF 28
015A: MOVLW 7F
015B: MOVWF 27
.................... goto rizeni;
015C: GOTO 12C
.................... }
.................... if(bit_test(sensors,5)) //.....*.//
015D: BTFSS 21.5
015E: GOTO 168
.................... {
.................... uhel=STRED-30;
015F: MOVLW 62
0160: MOVWF 24
.................... Rmotor=70;Lmotor=127;
0161: CLRF 28
0162: MOVLW 46
0163: MOVWF 27
0164: CLRF 26
0165: MOVLW 7F
0166: MOVWF 25
.................... goto rizeni;
0167: GOTO 12C
.................... }
.................... if(bit_test(sensors,2)) //..*....//
0168: BTFSS 21.2
0169: GOTO 173
.................... {
.................... uhel=STRED+20;
016A: MOVLW 94
016B: MOVWF 24
.................... Lmotor=90;Rmotor=127;
016C: CLRF 26
016D: MOVLW 5A
016E: MOVWF 25
016F: CLRF 28
0170: MOVLW 7F
0171: MOVWF 27
.................... goto rizeni;
0172: GOTO 12C
.................... }
.................... if(bit_test(sensors,4)) //....*..//
0173: BTFSS 21.4
0174: GOTO 17E
.................... {
.................... uhel=STRED-20;
0175: MOVLW 6C
0176: MOVWF 24
.................... Rmotor=90;Lmotor=127;
0177: CLRF 28
0178: MOVLW 5A
0179: MOVWF 27
017A: CLRF 26
017B: MOVLW 7F
017C: MOVWF 25
.................... goto rizeni;
017D: GOTO 12C
.................... }
.................... if(bit_test(sensors,3)) //...*...//
017E: BTFSS 21.3
017F: GOTO 188
.................... {
.................... uhel=STRED;
0180: MOVLW 80
0181: MOVWF 24
.................... Lmotor=100;Rmotor=100;
0182: CLRF 26
0183: MOVLW 64
0184: MOVWF 25
0185: CLRF 28
0186: MOVWF 27
.................... goto rizeni;
0187: GOTO 12C
.................... }
....................
.................... /*STOPL;STOPR;
.................... if(bit_test(sensors,7))
.................... {
....................
.................... }*/
.................... }
0188: MOVLW 2C
0189: MOVWF 3C
018A: MOVLW 01
018B: MOVWF 3D
018C: BCF 0A.3
018D: GOTO 236
018E: RETLW 00
.................... ////////////////////////////////////////////////////////////////////////////////
.................... void main()
.................... {
018F: CLRF 04
0190: MOVLW 1F
0191: ANDWF 03,F
0192: MOVLW 70
0193: BSF 03.5
0194: MOVWF 0F
0195: BCF 1F.4
0196: BCF 1F.5
0197: MOVF 1B,W
0198: ANDLW 80
0199: MOVWF 1B
019A: MOVLW 07
019B: MOVWF 1C
.................... setup_adc_ports(NO_ANALOGS);
019C: BCF 1F.4
019D: BCF 1F.5
019E: MOVF 1B,W
019F: ANDLW 80
01A0: MOVWF 1B
.................... setup_adc(ADC_CLOCK_INTERNAL);
01A1: BCF 1F.6
01A2: BCF 03.5
01A3: BSF 1F.6
01A4: BSF 1F.7
01A5: BSF 03.5
01A6: BCF 1F.7
01A7: BCF 03.5
01A8: BSF 1F.0
.................... setup_spi(SPI_MASTER|SPI_H_TO_L|SPI_XMIT_L_TO_H|SPI_CLK_DIV_4);
01A9: BCF 14.5
01AA: BSF 03.5
01AB: BCF 06.2
01AC: BSF 06.1
01AD: BCF 06.4
01AE: MOVLW 30
01AF: BCF 03.5
01B0: MOVWF 14
01B1: MOVLW 00
01B2: BSF 03.5
01B3: MOVWF 14
.................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
01B4: MOVF 01,W
01B5: ANDLW C7
01B6: IORLW 08
01B7: MOVWF 01
.................... setup_timer_1(T1_DISABLED);
01B8: BCF 03.5
01B9: CLRF 10
.................... setup_oscillator(OSC_8MHZ|OSC_INTRC);
01BA: MOVLW 72
01BB: BSF 03.5
01BC: MOVWF 0F
.................... // set_pwm1_duty(0); // Spust PWM, ale zatim s trvalou 0 na vystupu
.................... // setup_ccp1(CCP_PWM);
.................... // setup_timer_2(T2_DIV_BY_16,200,1); // perioda
.................... // setup_timer_2(T2_DIV_BY_4,255,10); // Casovac pro regulaci
....................
.................... STOPR; STOPL;
01BD: BCF 05.6
01BE: BCF 03.5
01BF: BCF 05.6
01C0: BSF 03.5
01C1: BCF 05.7
01C2: BCF 03.5
01C3: BCF 05.7
01C4: BSF 03.5
01C5: BCF 05.0
01C6: BCF 03.5
01C7: BCF 05.0
01C8: BSF 03.5
01C9: BCF 05.1
01CA: BCF 03.5
01CB: BCF 05.1
.................... uhel=STRED;
01CC: MOVLW 80
01CD: MOVWF 24
.................... // diagnostika();
.................... Lmotor=0;
01CE: CLRF 26
01CF: CLRF 25
.................... Rmotor=0;
01D0: CLRF 28
01D1: CLRF 27
.................... rtos_run();
01D2: CLRF 29
01D3: CLRF 2B
01D4: MOVLW 08
01D5: MOVWF 2A
01D6: CLRF 2D
01D7: MOVLW 01
01D8: MOVWF 2C
01D9: MOVLW 38
01DA: MOVWF 2E
01DB: MOVLW 00
01DC: MOVWF 2F
01DD: CLRF 30
01DE: CLRF 32
01DF: MOVLW 01
01E0: MOVWF 31
01E1: CLRF 34
01E2: CLRF 33
01E3: MOVLW 55
01E4: MOVWF 35
01E5: MOVLW 00
01E6: MOVWF 36
01E7: CLRF 37
01E8: CLRF 39
01E9: MOVLW 02
01EA: MOVWF 38
01EB: CLRF 3B
01EC: CLRF 3A
01ED: MOVLW 2C
01EE: MOVWF 3C
01EF: MOVLW 01
01F0: MOVWF 3D
01F1: CLRF 20
01F2: MOVLW 00
01F3: MOVWF 78
01F4: IORLW 06
01F5: MOVWF 12
01F6: MOVLW FA
01F7: BSF 03.5
01F8: MOVWF 12
01F9: BCF 03.5
01FA: BCF 0C.1
01FB: MOVLW 00
01FC: MOVWF 78
01FD: IORLW 06
01FE: MOVWF 12
01FF: MOVLW FA
0200: BSF 03.5
0201: MOVWF 12
0202: BCF 03.5
0203: BCF 0C.1
0204: BCF 03.0
0205: RLF 20,W
0206: MOVWF 77
0207: CALL 004
0208: MOVWF 79
0209: MOVLW 01
020A: ADDWF 77,W
020B: CALL 004
020C: MOVWF 7A
020D: MOVF 79,W
020E: MOVWF 04
020F: MOVF 00,W
0210: MOVWF 79
0211: INCF 04,F
0212: MOVF 00,W
0213: MOVWF 77
0214: INCF 04,F
0215: MOVF 00,W
0216: MOVWF 78
0217: INCF 04,F
0218: INCF 00,F
0219: MOVF 00,W
021A: MOVWF 7A
021B: BTFSS 03.2
021C: GOTO 220
021D: INCF 04,F
021E: INCF 00,F
021F: DECF 04,F
0220: INCF 04,F
0221: MOVF 00,W
0222: SUBWF 78,W
0223: BTFSS 03.2
0224: GOTO 238
0225: MOVF 77,W
0226: SUBWF 7A,W
0227: BTFSS 03.2
0228: GOTO 238
0229: DECF 04,F
022A: CLRF 00
022B: INCF 04,F
022C: CLRF 00
022D: INCF 04,F
022E: BTFSC 79.7
022F: GOTO 238
0230: INCF 04,F
0231: MOVF 00,W
0232: MOVWF 0A
0233: DECF 04,F
0234: MOVF 00,W
0235: MOVWF 02
0236: BCF 03.5
0237: BCF 03.6
0238: INCF 20,F
0239: MOVLW 03
023A: SUBWF 20,W
023B: BTFSS 03.2
023C: GOTO 204
023D: CLRF 20
023E: BTFSS 0C.1
023F: GOTO 242
0240: BSF 03.5
0241: GOTO 202
0242: GOTO 23E
0243: MOVLW FF
0244: MOVWF 20
....................
.................... }
0245: SLEEP
 
Configuration Fuses:
Word 1: 3FF8 NOWDT NOPUT MCLR BROWNOUT LVP NOCPD NOWRT NODEBUG CCPB0 NOPROTECT INTRC_IO
Word 2: 3FFF FCMEN IESO
/roboti/istrobot/3Orbis/bak/02/master/main.PJT
0,0 → 1,40
[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\istrobot\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\istrobot\3Orbis\main.c
2=C:\Program Files\PICC\devices\16F88.h
3=D:\KAKLIK\programy\PIC_C\roboti\istrobot\3Orbis\main.h
4=
[Units]
Count=1
1=D:\KAKLIK\programy\PIC_C\roboti\istrobot\3Orbis\main.c (main)
/roboti/istrobot/3Orbis/bak/02/master/main.SYM
0,0 → 1,82
015-016 CCP_1
015 CCP_1_LOW
016 CCP_1_HIGH
020 @CURRENT_TASK
021 sensors
022 line
023 dira
024 uhel
025-026 Lmotor
027-028 Rmotor
029-02F @TASKINFO1_2_2_0_0
030-036 @TASKINFO2_2_2_0_0
037-03D @TASKINFO3_2_2_0_0
03E zatoc.n
03F @delay_ms1.P1
03F @delay_us1.P2
040 motory.@SCRATCH
077 @SCRATCH
078 @SCRATCH
078 _RETURN_
079 @SCRATCH
07A @SCRATCH
07B @SCRATCH
09C.6 C1OUT
09C.7 C2OUT
 
000E @delay_ms1
0027 @delay_us1
0038 zatoc
0055 motory
012C rizeni
018F main
0004 @const10133
018F @cinit
012C rizeni
 
Project Files:
D:\KAKLIK\programy\PIC_C\roboti\istrobot\3Orbis\main.c
D:\KAKLIK\programy\PIC_C\roboti\istrobot\3Orbis\main.h
C:\Program Files\PICC\devices\16F88.h
 
Units:
D:\KAKLIK\programy\PIC_C\roboti\istrobot\3Orbis\main.c (main)
 
Compiler Settings:
Processor: PIC16F88
Pointer Size: 8
ADC Range: 0-255
Opt Level: 9
Short,Int,Long: 1,8,16
 
Task Schedule:
500 us motory
500 us rizeni
Sync to next 2, ms
2, ms zatoc
500 us motory
Sync to next 2, ms
500 us motory
500 us rizeni
Sync to next 2, ms
500 us motory
Sync to next 2, ms
500 us motory
500 us rizeni
Sync to next 2, ms
500 us motory
Sync to next 2, ms
500 us motory
500 us rizeni
Sync to next 2, ms
500 us motory
Sync to next 2, ms
 
Output Files:
Errors: D:\KAKLIK\programy\PIC_C\roboti\istrobot\3Orbis\main.err
INHX8: D:\KAKLIK\programy\PIC_C\roboti\istrobot\3Orbis\main.hex
Symbols: D:\KAKLIK\programy\PIC_C\roboti\istrobot\3Orbis\main.sym
List: D:\KAKLIK\programy\PIC_C\roboti\istrobot\3Orbis\main.lst
Debug/COFF: D:\KAKLIK\programy\PIC_C\roboti\istrobot\3Orbis\main.cof
Call Tree: D:\KAKLIK\programy\PIC_C\roboti\istrobot\3Orbis\main.tre
Statistics: D:\KAKLIK\programy\PIC_C\roboti\istrobot\3Orbis\main.sta
/roboti/istrobot/3Orbis/bak/02/master/main.c
0,0 → 1,170
#include ".\main.h"
 
#use rtos (timer=2, minor_cycle=2ms)
 
unsigned int8 sensors; // pomocna promenna pro cteni cidel na caru
unsigned int8 line; // na ktere strane byla detekovana cara
unsigned int8 dira; // pocita dobu po kterou je ztracena cara
unsigned int8 uhel; // urcuje aktualni uhel zataceni
 
signed int16 Lmotor; // promene, ktere urcuji velikost vykonu na levem
signed int16 Rmotor; // a pravem motoru
 
#define LMAX 190 // maximalni zatoceni doleva
#define RMAX 60 // maximalni zatoceni doprava
#define STRED 128 // sredni poloha zadniho kolecka
 
// servo
#define SERVO PIN_A2
 
//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
 
// makro pro PWM
#define GO(motor, direction, power) if(get_timer0()<=power) \
{direction##motor;} else {stop##motor;}
 
 
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/*
void diagnostika()
{
if(input(SW1))STOPR;STOPL;While(TRUE);
// if(LSENSOR==true) output_high(LED2); else output_low(LED2);
// if(RSENSOR==true) output_high(LED1); else output_low(LED1);
}
*/
////////////////////////////////////////////////////////////////////////////////
#task (rate=16ms,max=2ms)
void zatoc() // ridi servo ktere otaci kolem
{
unsigned int8 n;
output_high(SERVO);
delay_us(1200);
for(n=uhel; n>0; n--);
output_low(SERVO);
}
 
////////////////////////////////////////////////////////////////////////////////
#task (rate=2ms, max=500us)
void motory() // umoznuje nezavisle rizeni vykonu na obou motorech
{
 
if(Rmotor>0) //pravy motor
{
GO(R, F, Rmotor);
}
 
if(Rmotor==0) STOPR;
 
if(Rmotor<0)
{
GO(R, B, abs(Rmotor));
}
 
if(Lmotor>0) // levy motor
{
GO(L, F, Lmotor);
}
 
if(Lmotor==0) STOPL;
 
if(Lmotor<0)
{
GO(L, B, abs(Lmotor));
}
}
////////////////////////////////////////////////////////////////////////////////
#task (rate=4ms, max=500us, queue=0)
void rizeni()
{
rizeni:
 
sensors = spi_read(0); // cteni senzoru na caru
output_high(STROBE);
output_low(STROBE);
 
if(bit_test(sensors,0)) //*......// // z duvodu zkraceni doby reakce se cidla nevyhodnocuji poporade ale od krajnich k prostrednimu
{
uhel=LMAX;
Lmotor=0;Rmotor=127;
goto rizeni;
}
if(bit_test(sensors,6)) //......*//
{
uhel=RMAX;
Rmotor=0;Lmotor=127;
goto rizeni;
}
if(bit_test(sensors,1)) //.*.....//
{
uhel=STRED+30;
Lmotor=70;Rmotor=127;
goto rizeni;
}
if(bit_test(sensors,5)) //.....*.//
{
uhel=STRED-30;
Rmotor=70;Lmotor=127;
goto rizeni;
}
if(bit_test(sensors,2)) //..*....//
{
uhel=STRED+20;
Lmotor=90;Rmotor=127;
goto rizeni;
}
if(bit_test(sensors,4)) //....*..//
{
uhel=STRED-20;
Rmotor=90;Lmotor=127;
goto rizeni;
}
if(bit_test(sensors,3)) //...*...//
{
uhel=STRED;
Lmotor=100;Rmotor=100;
goto rizeni;
}
 
/*STOPL;STOPR;
if(bit_test(sensors,7))
{
 
}*/
}
////////////////////////////////////////////////////////////////////////////////
void main()
{
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_CLOCK_INTERNAL);
setup_spi(SPI_MASTER|SPI_H_TO_L|SPI_XMIT_L_TO_H|SPI_CLK_DIV_4);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_oscillator(OSC_8MHZ|OSC_INTRC);
// set_pwm1_duty(0); // Spust PWM, ale zatim s trvalou 0 na vystupu
// setup_ccp1(CCP_PWM);
// setup_timer_2(T2_DIV_BY_16,200,1); // perioda
// setup_timer_2(T2_DIV_BY_4,255,10); // Casovac pro regulaci
 
STOPR; STOPL;
uhel=STRED;
// diagnostika();
Lmotor=0;
Rmotor=0;
rtos_run();
 
}
/roboti/istrobot/3Orbis/bak/02/master/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/3Orbis/bak/02/master/main.err
0,0 → 1,2
No Errors
0 Errors, 0 Warnings.
/roboti/istrobot/3Orbis/bak/02/master/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 BROWNOUT //Reset when brownout detected
#FUSES LVP //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 FCMEN //Fail-safe clock monitor enabled
#FUSES IESO //Internal External Switch Over mode enabled
 
#use delay(clock=8000000,RESTART_WDT)
 
/roboti/istrobot/3Orbis/bak/02/master/main.sta
0,0 → 1,34
 
ROM used: 582 (14%)
582 (14%) including unused fragments
 
1 Average locations per line
5 Average locations per statement
 
RAM used: 35 (20%) at main() level
38 (22%) worst case
 
Lines Stmts % Files
----- ----- --- -----
171 111 100 D:\KAKLIK\programy\PIC_C\roboti\istrobot\3Orbis\main.c
19 0 0 D:\KAKLIK\programy\PIC_C\roboti\istrobot\3Orbis\main.h
279 0 0 C:\Program Files\PICC\devices\16F88.h
----- -----
938 222 Total
 
Page ROM % RAM Functions:
---- --- --- --- ----------
0 25 4 1 @delay_ms1
0 17 3 1 @delay_us1
0 29 5 1 zatoc
0 215 37 1 motory
0 99 17 0 rizeni
0 183 31 0 main
0 10 2 0 @const10133
 
Segment Used Free
--------- ---- ----
00000-00003 4 0
00004-007FF 578 1466
00800-00FFF 0 2048
 
/roboti/istrobot/3Orbis/bak/02/master/main.tre
0,0 → 1,10
ÀÄmain
ÃÄmain 0/183 Ram=0
³ ÃÄ??0??
³ ÃÄ@const10133 0/10 Ram=0
³ ÀÄ@const10133 0/10 Ram=0
ÃÄzatoc 0/29 Ram=1
³ ÃÄ@delay_ms1 0/25 Ram=1
³ ÀÄ@delay_us1 0/17 Ram=1
ÃÄmotory 0/215 Ram=1
ÀÄrizeni 0/99 Ram=0