No changes between revisions
/Designs/ROBOTS/Merkur/SW/MerkurU/AX25.c |
---|
0,0 → 1,135 |
#nolist |
//#define PTT PIN_A2 // PTT control |
//#define TXo PIN_C0 // To the transmitter modulator |
#define PERIODAH delay_us(222) // Halfperiod H 222;78/1200 500;430/500 |
#define TAILH delay_us(78) |
#define PERIODAL delay_us(412) // Halfperiod L 412;345/1200 1000;880/500 |
#define TAILL delay_us(345) |
#byte STATUS = 3 // CPUs status register |
byte SendData[16] = {'A'<<1, 'L'<<1, 'L'<<1, ' '<<1, ' '<<1, ' '<<1, 0x60, |
'C'<<1, 'Z'<<1, '0'<<1, 'R'<<1, 'R'<<1, 'R'<<1, 0x61, |
0x03, 0xF0}; |
boolean bit; |
int fcslo, fcshi; // variabloes for calculating FCS (CRC) |
int stuff; // stuff counter for extra 0 |
int flag_flag; // if it is sending flag (7E) |
int fcs_flag; // if it is sending Frame Check Sequence |
int i; // for for |
void flipout() //flips the state of output pin a_1 |
{ |
stuff = 0; //since this is a 0, reset the stuff counter |
if (bit) |
{ |
bit=FALSE; //if the state of the pin was low, make it high. |
} |
else |
{ |
bit=TRUE; //if the state of the pin was high make it low |
} |
} |
void fcsbit(byte tbyte) |
{ |
#asm |
BCF STATUS,0 |
RRF fcshi,F // rotates the entire 16 bits |
RRF fcslo,F // to the right |
#endasm |
if (((STATUS & 0x01)^(tbyte)) ==0x01) |
{ |
fcshi = fcshi^0x84; |
fcslo = fcslo^0x08; |
} |
} |
void SendBit () |
{ |
if (bit) |
{ |
output_high(TXo); |
PERIODAH; |
output_low(TXo); |
PERIODAH; |
output_high(TXo); |
PERIODAH; |
output_low(TXo); |
TAILH; |
} |
else |
{ |
output_high(TXo); |
PERIODAL; |
output_low(TXo); |
TAILL; |
}; |
} |
void SendByte (byte inbyte) |
{ |
int k, bt; |
for (k=0;k<8;k++) //do the following for each of the 8 bits in the byte |
{ |
bt = inbyte & 0x01; //strip off the rightmost bit of the byte to be sent (inbyte) |
if ((fcs_flag == FALSE) & (flag_flag == FALSE)) fcsbit(bt); //do FCS calc, but only if this |
//is not a flag or fcs byte |
if (bt == 0) |
{ |
flipout(); |
} // if this bit is a zero, flip the output state |
else |
{ //otherwise if it is a 1, do the following: |
if (flag_flag == FALSE) stuff++; //increment the count of consequtive 1's |
if ((flag_flag == FALSE) & (stuff == 5)) |
{ //stuff an extra 0, if 5 1's in a row |
SendBit(); |
flipout(); //flip the output state to stuff a 0 |
}//end of if |
}//end of else |
// delay_us(850); //introduces a delay that creates 1200 baud |
SendBit(); |
inbyte = inbyte>>1; //go to the next bit in the byte |
}//end of for |
}//end of SendByte |
void SendPacket(char *data) |
{ |
bit=FALSE; |
fcslo=fcshi=0xFF; //The 2 FCS Bytes are initialized to FF |
stuff = 0; //The variable stuff counts the number of 1's in a row. When it gets to 5 |
// it is time to stuff a 0. |
// output_low(PTT); // Blinking LED |
// delay_ms(1000); |
// output_high(PTT); |
flag_flag = TRUE; //The variable flag is true if you are transmitted flags (7E's) false otherwise. |
fcs_flag = FALSE; //The variable fcsflag is true if you are transmitting FCS bytes, false otherwise. |
for(i=0; i<10; i++) SendByte(0x7E); //Sends flag bytes. Adjust length for txdelay |
//each flag takes approx 6.7 ms |
flag_flag = FALSE; //done sending flags |
for(i=0; i<16; i++) SendByte(SendData[i]); //send the packet bytes |
for(i=0; 0 != *data; i++) |
{ |
SendByte(*data); //send the packet bytes |
data++; |
}; |
fcs_flag = TRUE; //about to send the FCS bytes |
fcslo =fcslo^0xff; //must XOR them with FF before sending |
fcshi = fcshi^0xff; |
SendByte(fcslo); //send the low byte of fcs |
SendByte(fcshi); //send the high byte of fcs |
fcs_flag = FALSE; //done sending FCS |
flag_flag = TRUE; //about to send flags |
SendByte(0x7e); // Send a flag to end packet |
} |
#list |
/Designs/ROBOTS/Merkur/SW/MerkurU/tank.BAK |
---|
0,0 → 1,268 |
// Program pro predvadeni schopnosti robota Merkur |
//------------------------------------------------ |
#include "tank.h" |
unsigned int8 sensors; // pomocna promenna pro cteni cidel na caru |
unsigned int8 line; // na ktere strane byla detekovana cara |
unsigned int8 speed; // rychlost zataceni |
unsigned int8 last; // kde byla cara, kdyz byly minule cidla mimo |
unsigned int8 rovinka; // pocitadlo pro zjisteni rovneho useku |
int cirkus; // pocitadlo, po kolika akcich se ma delat cirkus |
int1 BW; // urcuje, jestli je cara cerno/bila nebo |
// bilo/cerna (true = bila cara, cerny podklad) |
// Konstanty pro dynamiku pohybu |
#define T_DIRA 120 // po jakem case zataceni se detekuje dira |
#define FW_POMALU 170 // trochu mimo caru vnitrni pas |
#define FW_ZATACKA 200 // rychlost vnejsiho kola pri zataceni |
#define FW_STREDNE 190 // trochu mimo caru vnejsi pas |
#define COUVANI 750 // couvnuti zpet na caru, po detekci diry |
#define MAX_ROVINKA (255-FW_STREDNE) |
#define TRESHOLD 15 // rozhodovaci uroven komparatoru, 0xF = 0.75*Vdd |
#define BUMPER_TRESHOLD 128 // rozhodovaci uroven cidla na prekazku |
//motory //Napred vypnout potom zapnout! |
#define FR output_low(PIN_B5); output_high(PIN_B4) // Vpred |
#define FL output_low(PIN_B7); output_high(PIN_B6) |
#define BR output_low(PIN_B4); output_high(PIN_B5) // Vzad |
#define BL output_low(PIN_B6); output_high(PIN_B7) |
#define STOPR output_low(PIN_B4);output_low(PIN_B5) // Zastav |
#define STOPL output_low(PIN_B6);output_low(PIN_B7) |
#define L 0b10 // left |
#define R 0b01 // right |
#define S 0b11 // straight |
//cidla |
#define RSENSOR (BW != C2OUT) // Senzory na caru |
#define LSENSOR (BW != C1OUT) |
#define BUMPER sAN2 // Senzor na cihlu |
#define DIAG_SERVO PIN_B3 // Propojka pro diagnosticky mod |
#define DIAG_SENSORS PIN_B2 // Propojka pro diagnosticky mod |
#define BARVY PIN_B1 // Propojka pro nastaveni barvy cary |
#define SPEAKER PIN_B0 // vystup pro pipak |
#define LED1 PIN_A4 // LEDky |
#define LED2 PIN_A3 |
#define LED3 PIN_A7 |
#define LED4 PIN_A6 |
// makro pro PWM |
#define GO(motor, direction, power) if(get_timer0()<=power) \ |
{direction##motor;} else {stop##motor;} |
#int_TIMER2 |
void TIMER2_isr() // obsluha zrychlovani |
{ |
if (speed<255) speed++; |
if (rovinka<MAX_ROVINKA) rovinka++; |
} |
// Primitivni Pipani |
void beep(unsigned int16 period, unsigned int16 length) |
{ |
unsigned int16 nn; |
for(nn=length; nn>0; nn--) |
{ |
output_high(SPEAKER); |
delay_us(period); |
output_low(SPEAKER); |
delay_us(period); |
} |
} |
/******************************************************************************/ |
void diagnostika() |
{ |
unsigned int16 n; |
while (input(DIAG_SERVO)) // Propojka, ktera spousti diagnostiku |
{ |
for (n=500; n<800; n+=100) |
{ |
beep(n,n); //beep UP |
}; |
Delay_ms(1000); |
//zastav vse |
STOPL; STOPR; |
//pravy pas |
FR; Delay_ms(1000); STOPR; Delay_ms(1000); |
BR; Delay_ms(1000); STOPR; Delay_ms(1000); |
Beep(880,100); Delay_ms(1000); |
//levy pas |
FL; Delay_ms(1000); STOPL; Delay_ms(1000); |
BL; Delay_ms(1000); STOPL; Delay_ms(1000); |
Beep(880,100); Delay_ms(1000); |
//oba pasy |
FL; FR; Delay_ms(1000); STOPL; STOPR; Delay_ms(1000); |
BL; BR; Delay_ms(1000); STOPL; STOPR; Delay_ms(1000); |
}; |
while (input(DIAG_SENSORS)) // spusteni diagnostiky cidel |
{ |
if (RSENSOR) beep(1000,200); |
Delay_ms(300); |
if (LSENSOR) beep(2000,300); |
Delay_ms(300); |
if ((read_adc(ADC_READ_ONLY)<BUMPER_TRESHOLD)) beep(3000,400); |
Delay_ms(300); |
}; |
} |
/////////////////////////////////////////////////////////////////////////////// |
void OtocSe() // otoci se zpet, kdyz je prekazka |
{ |
unsigned int16 n; |
BL; BR; // cukni zpatky |
Delay_ms(200); |
STOPR;STOPL; |
beep(800,400); |
beep(2000,1000); |
output_low(LED4); |
beep(900,400); |
output_low(LED1); |
BR; FL; Delay_ms(100); // otoc se 30° do prava |
STOPL; STOPR; |
beep(1000,1000); |
output_low(LED3); |
BR; FL; |
for(n=40000;n>0;n--) // toc se, dokud nenarazis na caru |
{ |
line = RSENSOR; // cteni senzoru na caru |
line |= LSENSOR << 1; |
if (line!=0) break; |
} |
STOPR; STOPL; |
output_high(LED1); output_high(LED3); output_high(LED4); |
line=L; // caru jsme prejeli, tak je vlevo |
cirkus=0; |
} |
void main() |
{ |
unsigned int16 n; // pro FOR |
unsigned int16 i; |
STOPL; STOPR; // prepne vystupy na ovladani motoru na output a zastavi |
setup_oscillator(OSC_4MHZ|OSC_INTRC); // 4 MHz interni RC oscilator |
port_b_pullups(TRUE); // pullups pro piano na diagnostiku |
setup_spi(FALSE); |
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); // Casovac pro PWM |
setup_timer_2(T2_DIV_BY_4,255,10); // Casovac pro regulaci |
// preruseni kazdych 10ms |
setup_adc_ports(BUMPER|VSS_VDD); // nastaveni A/D prevodniku pro naraznik |
setup_adc(ADC_CLOCK_INTERNAL); |
set_adc_channel(2); |
setup_timer_1(T1_INTERNAL|T1_DIV_BY_1); // Casovac pro naraznik |
setup_ccp1(CCP_COMPARE_RESET_TIMER); |
CCP_1=(2^10)-1; // prevod kazdou 1ms |
output_low(LED1); output_low(LED2); output_low(LED3); output_low(LED4); |
setup_comparator(A0_VR_A1_VR); // inicializace komparatoru pro cidla cary |
setup_vref(VREF_HIGH|TRESHOLD); // 32 kroku od 0.25 do 0.75 Vdd |
Beep(1000,200); //double beep |
Delay_ms(50); |
Beep(1000,200); |
Delay_ms(1000); // 1s |
// povoleni rizeni rychlosti zataceni pres preruseni |
enable_interrupts(INT_TIMER2); |
enable_interrupts(GLOBAL); |
/*---------------------------------------------------------------------------*/ |
sensors=S; |
line=S; |
last=S; |
cirkus=0; |
// movement=S; |
speed=FW_POMALU; |
BW=input(BARVY); // Jaka ma byt barva cary? |
diagnostika(); // Zkus, jestli nekdo nechce, diagnostiku |
Delay_ms(500); |
output_high(LED1); Beep(1000,200); Delay_ms(500); |
output_high(LED2); Beep(1000,200); Delay_ms(500); |
output_high(LED3); Beep(1000,200); Delay_ms(500); |
output_high(LED4); Beep(1000,200); Delay_ms(500); |
while(true) // hlavni smycka (jizda podle cary) |
{ |
sensors = RSENSOR; // cteni senzoru na caru |
sensors |= LSENSOR << 1; |
if (read_adc(ADC_READ_ONLY)<BUMPER_TRESHOLD) OtocSe(); |
switch (sensors) // zatacej podle toho, kde vidis caru |
{ |
case S: // rovne |
GO(L, F, FW_STREDNE+rovinka); GO(R, F, FW_STREDNE+rovinka); |
continue; |
case L: // trochu vlevo |
GO(L, F, FW_POMALU+rovinka); GO(R, F, FW_STREDNE+rovinka); |
line=L; |
continue; |
case R: // trochu vpravo |
GO(R, F, FW_POMALU+rovinka); GO(L, F, FW_STREDNE+rovinka); |
line=R; |
continue; |
default: // kdyz jsou obe cidla mimo caru, tak pokracuj dal |
}; |
rovinka=0; |
if (last!=line) // pokud si prejel caru z jedne strany na druhou stranu, |
// tak zabrzdi |
{ |
output_bit(LED1, !input(LED1)); |
last=line; |
speed=FW_ZATACKA; |
cirkus++; |
if (cirkus>8) |
{ |
STOPL; STOPR; |
cirkus=0; |
disable_interrupts(GLOBAL); |
beep(1000,400); |
for(n=3000; n>3950; n--) beep(n,10); |
output_low(LED1); |
beep(2000,200); |
beep(900,400); |
for(n=2950; n<3000; n++) beep(n,10); |
output_low(LED2); |
output_high(LED1); |
beep(4000,400); |
beep(1000,100); |
output_low(LED3); |
beep(3000,400); |
Delay_ms(1000); |
output_high(LED1); output_high(LED2); |
output_high(LED3); output_high(LED4); |
enable_interrupts(GLOBAL); |
} |
}; |
if (L==line) // kdyz jsou obe cidla mimo caru, zatoc na caru |
{ |
STOPL; |
GO(R, F, speed); |
} |
else |
{ |
STOPR; |
GO(L, F, speed); |
} |
} // while(true) |
} |
/Designs/ROBOTS/Merkur/SW/MerkurU/tank.HEX |
---|
0,0 → 1,184 |
:1000000000308A00D12A0000FF00030E8301A10006 |
:100010007F08A0000A08A8008A01A00E0408A20018 |
:100020007708A3007808A4007908A5007A08A6003C |
:100030007B08A700831383128C308400801C222845 |
:100040008C183528220884002308F7002408F800BB |
:100050002508F9002608FA002708FB0028088A006E |
:10006000210E8300FF0E7F0E09008A1137282B0F07 |
:100070003A283B28AB0A2D08403C0318AD0A8C10E7 |
:100080008A1122281230BC02031C54283C30840000 |
:10009000FC3080050310800C800C000803195428E4 |
:1000A00052280000800B512800343908BB00380862 |
:1000B000BA00BA08031D5F28BB080319722883160B |
:1000C0000610831206143608BC0042208316061060 |
:1000D000831206103608BC0042203A080319BB03FD |
:1000E000BA035928003437308400000803198728E0 |
:1000F0000130F800F701F70B7B28F80B7A284A301B |
:10010000F700F70B812800000000800B78280034EE |
:10011000831686158312861DB3290130B500F4308D |
:10012000B4003508033C031CA928031D9B28340890 |
:100130001F3C031CA9283508B7003408B600350851 |
:10014000B9003408B80055206430B4070318B50A64 |
:1001500091280430B600FA30B7007320B60BAB28F4 |
:1001600083160613831206138316861383128613CF |
:1001700083160612831206128316861283128612C3 |
:1001800083168612831286128316061283120616AF |
:100190000430B600FA30B7007320B60BCA288316B5 |
:1001A00006128312061283168612831286120430F8 |
:1001B000B600FA30B7007320B60BD92883160612A2 |
:1001C0008312061283168612831286160430B60036 |
:1001D000FA30B7007320B60BE82883160612831294 |
:1001E000061283168612831286120430B600FA3085 |
:1001F000B7007320B60BF7280330B7007030B60095 |
:10020000B9016430B80055200430B600FA30B700A8 |
:100210007320B60B06298316861383128613831662 |
:100220000613831206170430B600FA30B7007320A5 |
:10023000B60B15298316061383120613831686132D |
:10024000831286130430B600FA30B7007320B60B61 |
:10025000242983160613831206138316861383122A |
:1002600086170430B600FA30B7007320B60B332976 |
:1002700083160613831206138316861383128613BE |
:100280000430B600FA30B7007320B60B42290330B1 |
:10029000B7007030B600B9016430B80055200430A2 |
:1002A000B600FA30B7007320B60B512983168613B7 |
:1002B000831286138316061383120617831686127B |
:1002C0008312861283160612831206160430B600B5 |
:1002D000FA30B7007320B60B682983160613831211 |
:1002E000061383168613831286138316061283124F |
:1002F000061283168612831286120430B600FA3074 |
:10030000B7007320B60B7F298316061383120613DA |
:10031000831686138312861783160612831206121B |
:1003200083168612831286160430B600FA30B700A0 |
:100330007320B60B962983160613831206138316B1 |
:1003400086138312861383160612831206128316EF |
:100350008612831286120430B600FA30B70073207A |
:10036000B60BAD298828831606158312061DF629BB |
:10037000F70183169C1B771483122F087706013927 |
:100380000319CA290330B700E830B600B901C830F4 |
:10039000B8005520C830B7007320F70183161C1B26 |
:1003A000771483122F08770601390319E0290730E3 |
:1003B000B700D030B6000130B9002C30B80055205D |
:1003C000C830B70073201F19E3291E087F3C031CA7 |
:1003D000F2290B30B700B830B6000130B9009030C8 |
:1003E000B8005520C830B7007320B3298A11782B84 |
:1003F0008316061383120613831686138312861739 |
:10040000831606128312061283168612831286162C |
:10041000C830B700732083160612831206128316A3 |
:10042000861283128612831606138312061383160E |
:100430008613831286130330B7002030B6000130D4 |
:10044000B9009030B80055200730B700D030B60062 |
:100450000330B900E830B800552083160513831225 |
:1004600005130330B7008430B6000130B900903076 |
:10047000B800552083160512831205128316061242 |
:10048000831206128316861283128616831686132B |
:100490008312861383160613831206176430B7007F |
:1004A0007320831606138312061383168613831292 |
:1004B000861383160612831206128316861283127F |
:1004C00086120330B700E830B6000330B900E830D8 |
:1004D000B8005520831685138312851383160612E0 |
:1004E00083120612831686128312861683168613CB |
:1004F0008312861383160613831206179C30B500E9 |
:100500004030B400B408031D882AB5080319B02A86 |
:10051000F70183169C1B771483122F087706013985 |
:10052000031D942A0030952A0130AA00F701831692 |
:100530001C1B771483122F0877060139031DA22A8A |
:100540000030A32A0130F7000310F70D7708AA0442 |
:10055000AA08031DB02A34080319B503B403822A7C |
:1005600083160612831206128316861283128612CF |
:1005700083160613831206138316861383128613BB |
:1005800083160512831205168316851383128517A9 |
:1005900083160513831205170230AA00AE018A11D3 |
:1005A000F12B84011F30830583161F129F121B0835 |
:1005B00080399B0007309C001C0883120D136030AB |
:1005C00083168F0006138312061383168613831275 |
:1005D000861383160612831206128316861283125E |
:1005E0008612623083168F00811383129412831651 |
:1005F00006118614061200308312940083169400AC |
:100600000108C739083881004830F80005388312DE |
:100610009200FF30831692001F129F121B08803930 |
:1006200004389B001F1383121F179F1783169F13F5 |
:1006300083121F141030F8001F08C73978049F0078 |
:1006400085309000831686150B3083129700960133 |
:100650000730950083160512831205128316851143 |
:100660008312851183168513831285138316051350 |
:1006700083120513023083169C0005080338850099 |
:100680000330F700F70B422B1C0883120D138F3039 |
:1006900083169D0003308312B700E830B600B9011D |
:1006A000C830B80055203230B70073200330B7008F |
:1006B000E830B600B901C830B80055200430B400A5 |
:1006C000FA30B7007320B40B602B83168C14C03043 |
:1006D00083128B040330A900AA00AC00AE01AA303B |
:1006E000AB008316861483122F1086182F148828C7 |
:1006F0000230B400FA30B7007320B40B7A2B8316A3 |
:100700000512831205160330B700E830B600B901B0 |
:10071000C830B80055200230B400FA30B70073205A |
:10072000B40B8D2B83168511831285150330B7000A |
:10073000E830B600B901C830B80055200230B40026 |
:10074000FA30B7007320B40BA02B831685138312E5 |
:1007500085170330B700E830B600B901C830B800DB |
:1007600055200230B400FA30B7007320B40BB32B1D |
:1007700083160513831205170330B700E830B6005F |
:10078000B901C830B80055200230B400FA30B700C3 |
:100790007320B40BC62BF70183169C1B77148312AE |
:1007A0002F0877060139031DD72B0030D82B0130D5 |
:1007B000A900F70183161C1B771483122F087706F4 |
:1007C0000139031DE52B0030E62B0130F700031043 |
:1007D000F70D7708A9041F19EB2B1E087F3C03189F |
:1007E000F8292908033A0319FC2B013A0319312C83 |
:1007F000033A0319682C9F2C0108B400BE302D0762 |
:1008000034020319052C03180E2C83168613831249 |
:1008100086138316061383120617162C83160613E7 |
:100820008312061383168613831286130108B400FD |
:10083000BE302D07340203191F2C0318282C8316F1 |
:100840008612831286128316061283120616302C25 |
:1008500083160612831206128316861283128612DC |
:10086000CB2B0108B400AA302D07340203193A2C0F |
:100870000318432C831686138312861383160613DC |
:10088000831206174B2C8316061383120613831646 |
:100890008613831286130108B400BE302D0734027C |
:1008A0000319542C03185D2C8316861283128612AA |
:1008B0008316061283120616652C831606128312FF |
:1008C000061283168612831286120230AA00CB2BE0 |
:1008D0000108B400AA302D0734020319712C031843 |
:1008E0007A2C8316861283128612831606128312BE |
:1008F0000616822C8316061283120612831686129F |
:10090000831286120108B400BE302D073402031989 |
:100910008B2C0318942C831686138312861383164C |
:100920000613831206179C2C8316061383120613D4 |
:1009300083168613831286130130AA00CB2BAD01D8 |
:100940002A082C020319602D831605168312051E32 |
:10095000AB2C0512AC2C05168316051283122A083F |
:10096000AC00C830AB00AE0A2E08083C0318602D5E |
:1009700083160613831206138316861383128613B7 |
:1009800083160612831206128316861283128612AB |
:10099000AE010B138B138B1BCA2C0330B700E8304E |
:1009A000B6000130B9009030B80055200B30B100CE |
:1009B000B830B00031080E3C0318F22CFF3A031D8A |
:1009C000E52C30086E3C0318F22C3108B7003008D3 |
:1009D000B600B9010A30B800552030080319B10338 |
:1009E000B003DA2C83160512831205120730B70004 |
:1009F000D030B600B901C830B80055200330B70078 |
:100A00008430B6000130B9009030B80055200B306A |
:100A1000B1008630B00031080B3C031C212D031DB2 |
:100A2000152D3008B73C031C212D3108B7003008C4 |
:100A3000B600B9010A30B8005520B00A0319B10A4E |
:100A40000B2D8316851183128511831605128312CF |
:100A500005160F30B700A030B6000130B900903055 |
:100A6000B80055200330B700E830B600B901643053 |
:100A7000B800552083168513831285130B30B700F9 |
:100A8000B830B6000130B9009030B80055200430BD |
:100A9000B400FA30B7007320B40B492D8316051249 |
:100AA0008312051683168511831285158316851307 |
:100AB000831285178316051383120517C0308B0424 |
:100AC0002A08023C031D822D831606138312061387 |
:100AD000831686138312861301082B02031C792DBB |
:100AE0008316861283128612831606128312061646 |
:100AF000812D831606128312061283168612831224 |
:100B000086129F2D831606128312061283168612F2 |
:100B10008312861201082B02031C972D831686135D |
:100B20008312861383160613831206179F2D8316CE |
:100B30000613831206138316861383128613CB2B98 |
:020B4000630050 |
:04400E00383FFC3FFC |
:00000001FF |
;PIC16F88 |
/Designs/ROBOTS/Merkur/SW/MerkurU/tank.LST |
---|
0,0 → 1,1740 |
CCS PCM C Compiler, Version 3.221, 27853 18-VI-05 13:30 |
Filename: D:\KAKLIK\programy\PIC_C\roboti\merkur\PIC16F88\MerkurU\tank.LST |
ROM used: 1441 words (35%) |
Largest free fragment is 2048 |
RAM used: 27 (15%) at main() level |
34 (19%) worst case |
Stack: 4 worst case (3 in main + 1 for interrupts) |
* |
0000: MOVLW 00 |
0001: MOVWF 0A |
0002: GOTO 2D1 |
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 037 |
.................... // Program pro predvadeni schopnosti robota Merkur |
.................... //------------------------------------------------ |
.................... |
.................... #include "tank.h" |
.................... #include <16F88.h> |
.................... //////// Standard Header file for the PIC16F88 device //////////////// |
.................... #device PIC16F88 |
.................... #list |
.................... |
.................... #device adc=8 |
.................... #fuses NOWDT,INTRC_IO, NOPUT, MCLR, NOBROWNOUT, NOLVP, NOCPD, NOWRT, NODEBUG, NOPROTECT, NOFCMEN, NOIESO |
.................... #use delay(clock=4000000) |
* |
0042: MOVLW 12 |
0043: SUBWF 3C,F |
0044: BTFSS 03.0 |
0045: GOTO 054 |
0046: MOVLW 3C |
0047: MOVWF 04 |
0048: MOVLW FC |
0049: ANDWF 00,F |
004A: BCF 03.0 |
004B: RRF 00,F |
004C: RRF 00,F |
004D: MOVF 00,W |
004E: BTFSC 03.2 |
004F: GOTO 054 |
0050: GOTO 052 |
0051: NOP |
0052: DECFSZ 00,F |
0053: GOTO 051 |
0054: RETLW 00 |
* |
0073: MOVLW 37 |
0074: MOVWF 04 |
0075: MOVF 00,W |
0076: BTFSC 03.2 |
0077: GOTO 087 |
0078: MOVLW 01 |
0079: MOVWF 78 |
007A: CLRF 77 |
007B: DECFSZ 77,F |
007C: GOTO 07B |
007D: DECFSZ 78,F |
007E: GOTO 07A |
007F: MOVLW 4A |
0080: MOVWF 77 |
0081: DECFSZ 77,F |
0082: GOTO 081 |
0083: NOP |
0084: NOP |
0085: DECFSZ 00,F |
0086: GOTO 078 |
0087: RETLW 00 |
.................... |
.................... |
.................... |
.................... unsigned int8 sensors; // pomocna promenna pro cteni cidel na caru |
.................... unsigned int8 line; // na ktere strane byla detekovana cara |
.................... unsigned int8 speed; // rychlost zataceni |
.................... unsigned int8 last; // kde byla cara, kdyz byly minule cidla mimo |
.................... unsigned int8 rovinka; // pocitadlo pro zjisteni rovneho useku |
.................... int cirkus; // pocitadlo, po kolika akcich se ma delat cirkus |
.................... int1 BW; // urcuje, jestli je cara cerno/bila nebo |
.................... // bilo/cerna (true = bila cara, cerny podklad) |
.................... |
.................... // Konstanty pro dynamiku pohybu |
.................... #define T_DIRA 120 // po jakem case zataceni se detekuje dira |
.................... #define FW_POMALU 170 // trochu mimo caru vnitrni pas |
.................... #define FW_ZATACKA 200 // rychlost vnejsiho kola pri zataceni |
.................... #define FW_STREDNE 190 // trochu mimo caru vnejsi pas |
.................... #define COUVANI 750 // couvnuti zpet na caru, po detekci diry |
.................... #define MAX_ROVINKA (255-FW_STREDNE) |
.................... #define TRESHOLD 15 // rozhodovaci uroven komparatoru, 0xF = 0.75*Vdd |
.................... #define BUMPER_TRESHOLD 128 // rozhodovaci uroven cidla na prekazku |
.................... |
.................... //motory //Napred vypnout potom zapnout! |
.................... #define FR output_low(PIN_B5); output_high(PIN_B4) // Vpred |
.................... #define FL output_low(PIN_B7); output_high(PIN_B6) |
.................... #define BR output_low(PIN_B4); output_high(PIN_B5) // Vzad |
.................... #define BL output_low(PIN_B6); output_high(PIN_B7) |
.................... #define STOPR output_low(PIN_B4);output_low(PIN_B5) // Zastav |
.................... #define STOPL output_low(PIN_B6);output_low(PIN_B7) |
.................... |
.................... #define L 0b10 // left |
.................... #define R 0b01 // right |
.................... #define S 0b11 // straight |
.................... |
.................... //cidla |
.................... #define RSENSOR (BW != C2OUT) // Senzory na caru |
.................... #define LSENSOR (BW != C1OUT) |
.................... #define BUMPER sAN2 // Senzor na cihlu |
.................... |
.................... #define DIAG_SERVO PIN_B3 // Propojka pro diagnosticky mod |
.................... #define DIAG_SENSORS PIN_B2 // Propojka pro diagnosticky mod |
.................... #define BARVY PIN_B1 // Propojka pro nastaveni barvy cary |
.................... |
.................... #define SPEAKER PIN_B0 // vystup pro pipak |
.................... |
.................... #define LED1 PIN_A4 // LEDky |
.................... #define LED2 PIN_A3 |
.................... #define LED3 PIN_A7 |
.................... #define LED4 PIN_A6 |
.................... |
.................... // makro pro PWM |
.................... #define GO(motor, direction, power) if(get_timer0()<=power) \ |
.................... {direction##motor;} else {stop##motor;} |
.................... |
.................... #int_TIMER2 |
.................... void TIMER2_isr() // obsluha zrychlovani |
.................... { |
.................... if (speed<255) speed++; |
* |
0037: INCFSZ 2B,W |
0038: GOTO 03A |
0039: GOTO 03B |
003A: INCF 2B,F |
.................... if (rovinka<MAX_ROVINKA) rovinka++; |
003B: MOVF 2D,W |
003C: SUBLW 40 |
003D: BTFSC 03.0 |
003E: INCF 2D,F |
.................... } |
.................... |
.................... // Primitivni Pipani |
003F: BCF 0C.1 |
0040: BCF 0A.3 |
0041: GOTO 022 |
.................... void beep(unsigned int16 period, unsigned int16 length) |
.................... { |
.................... unsigned int16 nn; |
.................... |
.................... for(nn=length; nn>0; nn--) |
* |
0055: MOVF 39,W |
0056: MOVWF 3B |
0057: MOVF 38,W |
0058: MOVWF 3A |
0059: MOVF 3A,F |
005A: BTFSS 03.2 |
005B: GOTO 05F |
005C: MOVF 3B,F |
005D: BTFSC 03.2 |
005E: GOTO 072 |
.................... { |
.................... output_high(SPEAKER); |
005F: BSF 03.5 |
0060: BCF 06.0 |
0061: BCF 03.5 |
0062: BSF 06.0 |
.................... delay_us(period); |
0063: MOVF 36,W |
0064: MOVWF 3C |
0065: CALL 042 |
.................... output_low(SPEAKER); |
0066: BSF 03.5 |
0067: BCF 06.0 |
0068: BCF 03.5 |
0069: BCF 06.0 |
.................... delay_us(period); |
006A: MOVF 36,W |
006B: MOVWF 3C |
006C: CALL 042 |
.................... } |
006D: MOVF 3A,W |
006E: BTFSC 03.2 |
006F: DECF 3B,F |
0070: DECF 3A,F |
0071: GOTO 059 |
.................... } |
0072: RETLW 00 |
.................... /******************************************************************************/ |
.................... void diagnostika() |
.................... { |
.................... unsigned int16 n; |
.................... |
.................... while (input(DIAG_SERVO)) // Propojka, ktera spousti diagnostiku |
.................... { |
* |
0088: BSF 03.5 |
0089: BSF 06.3 |
008A: BCF 03.5 |
008B: BTFSS 06.3 |
008C: GOTO 1B3 |
.................... for (n=500; n<800; n+=100) |
008D: MOVLW 01 |
008E: MOVWF 35 |
008F: MOVLW F4 |
0090: MOVWF 34 |
0091: MOVF 35,W |
0092: SUBLW 03 |
0093: BTFSS 03.0 |
0094: GOTO 0A9 |
0095: BTFSS 03.2 |
0096: GOTO 09B |
0097: MOVF 34,W |
0098: SUBLW 1F |
0099: BTFSS 03.0 |
009A: GOTO 0A9 |
.................... { |
.................... beep(n,n); //beep UP |
009B: MOVF 35,W |
009C: MOVWF 37 |
009D: MOVF 34,W |
009E: MOVWF 36 |
009F: MOVF 35,W |
00A0: MOVWF 39 |
00A1: MOVF 34,W |
00A2: MOVWF 38 |
00A3: CALL 055 |
.................... }; |
00A4: MOVLW 64 |
00A5: ADDWF 34,F |
00A6: BTFSC 03.0 |
00A7: INCF 35,F |
00A8: GOTO 091 |
.................... Delay_ms(1000); |
00A9: MOVLW 04 |
00AA: MOVWF 36 |
00AB: MOVLW FA |
00AC: MOVWF 37 |
00AD: CALL 073 |
00AE: DECFSZ 36,F |
00AF: GOTO 0AB |
.................... //zastav vse |
.................... STOPL; STOPR; |
00B0: BSF 03.5 |
00B1: BCF 06.6 |
00B2: BCF 03.5 |
00B3: BCF 06.6 |
00B4: BSF 03.5 |
00B5: BCF 06.7 |
00B6: BCF 03.5 |
00B7: BCF 06.7 |
00B8: BSF 03.5 |
00B9: BCF 06.4 |
00BA: BCF 03.5 |
00BB: BCF 06.4 |
00BC: BSF 03.5 |
00BD: BCF 06.5 |
00BE: BCF 03.5 |
00BF: BCF 06.5 |
.................... //pravy pas |
.................... FR; Delay_ms(1000); STOPR; Delay_ms(1000); |
00C0: BSF 03.5 |
00C1: BCF 06.5 |
00C2: BCF 03.5 |
00C3: BCF 06.5 |
00C4: BSF 03.5 |
00C5: BCF 06.4 |
00C6: BCF 03.5 |
00C7: BSF 06.4 |
00C8: MOVLW 04 |
00C9: MOVWF 36 |
00CA: MOVLW FA |
00CB: MOVWF 37 |
00CC: CALL 073 |
00CD: DECFSZ 36,F |
00CE: GOTO 0CA |
00CF: BSF 03.5 |
00D0: BCF 06.4 |
00D1: BCF 03.5 |
00D2: BCF 06.4 |
00D3: BSF 03.5 |
00D4: BCF 06.5 |
00D5: BCF 03.5 |
00D6: BCF 06.5 |
00D7: MOVLW 04 |
00D8: MOVWF 36 |
00D9: MOVLW FA |
00DA: MOVWF 37 |
00DB: CALL 073 |
00DC: DECFSZ 36,F |
00DD: GOTO 0D9 |
.................... BR; Delay_ms(1000); STOPR; Delay_ms(1000); |
00DE: BSF 03.5 |
00DF: BCF 06.4 |
00E0: BCF 03.5 |
00E1: BCF 06.4 |
00E2: BSF 03.5 |
00E3: BCF 06.5 |
00E4: BCF 03.5 |
00E5: BSF 06.5 |
00E6: MOVLW 04 |
00E7: MOVWF 36 |
00E8: MOVLW FA |
00E9: MOVWF 37 |
00EA: CALL 073 |
00EB: DECFSZ 36,F |
00EC: GOTO 0E8 |
00ED: BSF 03.5 |
00EE: BCF 06.4 |
00EF: BCF 03.5 |
00F0: BCF 06.4 |
00F1: BSF 03.5 |
00F2: BCF 06.5 |
00F3: BCF 03.5 |
00F4: BCF 06.5 |
00F5: MOVLW 04 |
00F6: MOVWF 36 |
00F7: MOVLW FA |
00F8: MOVWF 37 |
00F9: CALL 073 |
00FA: DECFSZ 36,F |
00FB: GOTO 0F7 |
.................... Beep(880,100); Delay_ms(1000); |
00FC: MOVLW 03 |
00FD: MOVWF 37 |
00FE: MOVLW 70 |
00FF: MOVWF 36 |
0100: CLRF 39 |
0101: MOVLW 64 |
0102: MOVWF 38 |
0103: CALL 055 |
0104: MOVLW 04 |
0105: MOVWF 36 |
0106: MOVLW FA |
0107: MOVWF 37 |
0108: CALL 073 |
0109: DECFSZ 36,F |
010A: GOTO 106 |
.................... //levy pas |
.................... FL; Delay_ms(1000); STOPL; Delay_ms(1000); |
010B: BSF 03.5 |
010C: BCF 06.7 |
010D: BCF 03.5 |
010E: BCF 06.7 |
010F: BSF 03.5 |
0110: BCF 06.6 |
0111: BCF 03.5 |
0112: BSF 06.6 |
0113: MOVLW 04 |
0114: MOVWF 36 |
0115: MOVLW FA |
0116: MOVWF 37 |
0117: CALL 073 |
0118: DECFSZ 36,F |
0119: GOTO 115 |
011A: BSF 03.5 |
011B: BCF 06.6 |
011C: BCF 03.5 |
011D: BCF 06.6 |
011E: BSF 03.5 |
011F: BCF 06.7 |
0120: BCF 03.5 |
0121: BCF 06.7 |
0122: MOVLW 04 |
0123: MOVWF 36 |
0124: MOVLW FA |
0125: MOVWF 37 |
0126: CALL 073 |
0127: DECFSZ 36,F |
0128: GOTO 124 |
.................... BL; Delay_ms(1000); STOPL; Delay_ms(1000); |
0129: BSF 03.5 |
012A: BCF 06.6 |
012B: BCF 03.5 |
012C: BCF 06.6 |
012D: BSF 03.5 |
012E: BCF 06.7 |
012F: BCF 03.5 |
0130: BSF 06.7 |
0131: MOVLW 04 |
0132: MOVWF 36 |
0133: MOVLW FA |
0134: MOVWF 37 |
0135: CALL 073 |
0136: DECFSZ 36,F |
0137: GOTO 133 |
0138: BSF 03.5 |
0139: BCF 06.6 |
013A: BCF 03.5 |
013B: BCF 06.6 |
013C: BSF 03.5 |
013D: BCF 06.7 |
013E: BCF 03.5 |
013F: BCF 06.7 |
0140: MOVLW 04 |
0141: MOVWF 36 |
0142: MOVLW FA |
0143: MOVWF 37 |
0144: CALL 073 |
0145: DECFSZ 36,F |
0146: GOTO 142 |
.................... Beep(880,100); Delay_ms(1000); |
0147: MOVLW 03 |
0148: MOVWF 37 |
0149: MOVLW 70 |
014A: MOVWF 36 |
014B: CLRF 39 |
014C: MOVLW 64 |
014D: MOVWF 38 |
014E: CALL 055 |
014F: MOVLW 04 |
0150: MOVWF 36 |
0151: MOVLW FA |
0152: MOVWF 37 |
0153: CALL 073 |
0154: DECFSZ 36,F |
0155: GOTO 151 |
.................... //oba pasy |
.................... FL; FR; Delay_ms(1000); STOPL; STOPR; Delay_ms(1000); |
0156: BSF 03.5 |
0157: BCF 06.7 |
0158: BCF 03.5 |
0159: BCF 06.7 |
015A: BSF 03.5 |
015B: BCF 06.6 |
015C: BCF 03.5 |
015D: BSF 06.6 |
015E: BSF 03.5 |
015F: BCF 06.5 |
0160: BCF 03.5 |
0161: BCF 06.5 |
0162: BSF 03.5 |
0163: BCF 06.4 |
0164: BCF 03.5 |
0165: BSF 06.4 |
0166: MOVLW 04 |
0167: MOVWF 36 |
0168: MOVLW FA |
0169: MOVWF 37 |
016A: CALL 073 |
016B: DECFSZ 36,F |
016C: GOTO 168 |
016D: BSF 03.5 |
016E: BCF 06.6 |
016F: BCF 03.5 |
0170: BCF 06.6 |
0171: BSF 03.5 |
0172: BCF 06.7 |
0173: BCF 03.5 |
0174: BCF 06.7 |
0175: BSF 03.5 |
0176: BCF 06.4 |
0177: BCF 03.5 |
0178: BCF 06.4 |
0179: BSF 03.5 |
017A: BCF 06.5 |
017B: BCF 03.5 |
017C: BCF 06.5 |
017D: MOVLW 04 |
017E: MOVWF 36 |
017F: MOVLW FA |
0180: MOVWF 37 |
0181: CALL 073 |
0182: DECFSZ 36,F |
0183: GOTO 17F |
.................... BL; BR; Delay_ms(1000); STOPL; STOPR; Delay_ms(1000); |
0184: BSF 03.5 |
0185: BCF 06.6 |
0186: BCF 03.5 |
0187: BCF 06.6 |
0188: BSF 03.5 |
0189: BCF 06.7 |
018A: BCF 03.5 |
018B: BSF 06.7 |
018C: BSF 03.5 |
018D: BCF 06.4 |
018E: BCF 03.5 |
018F: BCF 06.4 |
0190: BSF 03.5 |
0191: BCF 06.5 |
0192: BCF 03.5 |
0193: BSF 06.5 |
0194: MOVLW 04 |
0195: MOVWF 36 |
0196: MOVLW FA |
0197: MOVWF 37 |
0198: CALL 073 |
0199: DECFSZ 36,F |
019A: GOTO 196 |
019B: BSF 03.5 |
019C: BCF 06.6 |
019D: BCF 03.5 |
019E: BCF 06.6 |
019F: BSF 03.5 |
01A0: BCF 06.7 |
01A1: BCF 03.5 |
01A2: BCF 06.7 |
01A3: BSF 03.5 |
01A4: BCF 06.4 |
01A5: BCF 03.5 |
01A6: BCF 06.4 |
01A7: BSF 03.5 |
01A8: BCF 06.5 |
01A9: BCF 03.5 |
01AA: BCF 06.5 |
01AB: MOVLW 04 |
01AC: MOVWF 36 |
01AD: MOVLW FA |
01AE: MOVWF 37 |
01AF: CALL 073 |
01B0: DECFSZ 36,F |
01B1: GOTO 1AD |
.................... }; |
01B2: GOTO 088 |
.................... while (input(DIAG_SENSORS)) // spusteni diagnostiky cidel |
.................... { |
01B3: BSF 03.5 |
01B4: BSF 06.2 |
01B5: BCF 03.5 |
01B6: BTFSS 06.2 |
01B7: GOTO 1F6 |
.................... if (RSENSOR) beep(1000,200); |
01B8: CLRF 77 |
01B9: BSF 03.5 |
01BA: BTFSC 1C.7 |
01BB: BSF 77.0 |
01BC: BCF 03.5 |
01BD: MOVF 2F,W |
01BE: XORWF 77,W |
01BF: ANDLW 01 |
01C0: BTFSC 03.2 |
01C1: GOTO 1CA |
01C2: MOVLW 03 |
01C3: MOVWF 37 |
01C4: MOVLW E8 |
01C5: MOVWF 36 |
01C6: CLRF 39 |
01C7: MOVLW C8 |
01C8: MOVWF 38 |
01C9: CALL 055 |
.................... Delay_ms(200); |
01CA: MOVLW C8 |
01CB: MOVWF 37 |
01CC: CALL 073 |
.................... if (LSENSOR) beep(2000,300); |
01CD: CLRF 77 |
01CE: BSF 03.5 |
01CF: BTFSC 1C.6 |
01D0: BSF 77.0 |
01D1: BCF 03.5 |
01D2: MOVF 2F,W |
01D3: XORWF 77,W |
01D4: ANDLW 01 |
01D5: BTFSC 03.2 |
01D6: GOTO 1E0 |
01D7: MOVLW 07 |
01D8: MOVWF 37 |
01D9: MOVLW D0 |
01DA: MOVWF 36 |
01DB: MOVLW 01 |
01DC: MOVWF 39 |
01DD: MOVLW 2C |
01DE: MOVWF 38 |
01DF: CALL 055 |
.................... Delay_ms(200); |
01E0: MOVLW C8 |
01E1: MOVWF 37 |
01E2: CALL 073 |
.................... if ((read_adc(ADC_READ_ONLY)<BUMPER_TRESHOLD)) beep(3000,400); |
01E3: BTFSC 1F.2 |
01E4: GOTO 1E3 |
01E5: MOVF 1E,W |
01E6: SUBLW 7F |
01E7: BTFSS 03.0 |
01E8: GOTO 1F2 |
01E9: MOVLW 0B |
01EA: MOVWF 37 |
01EB: MOVLW B8 |
01EC: MOVWF 36 |
01ED: MOVLW 01 |
01EE: MOVWF 39 |
01EF: MOVLW 90 |
01F0: MOVWF 38 |
01F1: CALL 055 |
.................... Delay_ms(200); |
01F2: MOVLW C8 |
01F3: MOVWF 37 |
01F4: CALL 073 |
.................... }; |
01F5: GOTO 1B3 |
.................... } |
01F6: BCF 0A.3 |
01F7: GOTO 378 (RETURN) |
.................... /////////////////////////////////////////////////////////////////////////////// |
.................... void OtocSe() // otoci se zpet, kdyz je prekazka |
.................... { |
.................... unsigned int16 n; |
.................... |
.................... BL; BR; // cukni zpatky |
01F8: BSF 03.5 |
01F9: BCF 06.6 |
01FA: BCF 03.5 |
01FB: BCF 06.6 |
01FC: BSF 03.5 |
01FD: BCF 06.7 |
01FE: BCF 03.5 |
01FF: BSF 06.7 |
0200: BSF 03.5 |
0201: BCF 06.4 |
0202: BCF 03.5 |
0203: BCF 06.4 |
0204: BSF 03.5 |
0205: BCF 06.5 |
0206: BCF 03.5 |
0207: BSF 06.5 |
.................... Delay_ms(200); |
0208: MOVLW C8 |
0209: MOVWF 37 |
020A: CALL 073 |
.................... STOPR;STOPL; |
020B: BSF 03.5 |
020C: BCF 06.4 |
020D: BCF 03.5 |
020E: BCF 06.4 |
020F: BSF 03.5 |
0210: BCF 06.5 |
0211: BCF 03.5 |
0212: BCF 06.5 |
0213: BSF 03.5 |
0214: BCF 06.6 |
0215: BCF 03.5 |
0216: BCF 06.6 |
0217: BSF 03.5 |
0218: BCF 06.7 |
0219: BCF 03.5 |
021A: BCF 06.7 |
.................... beep(800,400); |
021B: MOVLW 03 |
021C: MOVWF 37 |
021D: MOVLW 20 |
021E: MOVWF 36 |
021F: MOVLW 01 |
0220: MOVWF 39 |
0221: MOVLW 90 |
0222: MOVWF 38 |
0223: CALL 055 |
.................... beep(2000,1000); |
0224: MOVLW 07 |
0225: MOVWF 37 |
0226: MOVLW D0 |
0227: MOVWF 36 |
0228: MOVLW 03 |
0229: MOVWF 39 |
022A: MOVLW E8 |
022B: MOVWF 38 |
022C: CALL 055 |
.................... output_low(LED4); |
022D: BSF 03.5 |
022E: BCF 05.6 |
022F: BCF 03.5 |
0230: BCF 05.6 |
.................... beep(900,400); |
0231: MOVLW 03 |
0232: MOVWF 37 |
0233: MOVLW 84 |
0234: MOVWF 36 |
0235: MOVLW 01 |
0236: MOVWF 39 |
0237: MOVLW 90 |
0238: MOVWF 38 |
0239: CALL 055 |
.................... output_low(LED1); |
023A: BSF 03.5 |
023B: BCF 05.4 |
023C: BCF 03.5 |
023D: BCF 05.4 |
.................... |
.................... BR; FL; Delay_ms(100); // otoc se 30° do prava |
023E: BSF 03.5 |
023F: BCF 06.4 |
0240: BCF 03.5 |
0241: BCF 06.4 |
0242: BSF 03.5 |
0243: BCF 06.5 |
0244: BCF 03.5 |
0245: BSF 06.5 |
0246: BSF 03.5 |
0247: BCF 06.7 |
0248: BCF 03.5 |
0249: BCF 06.7 |
024A: BSF 03.5 |
024B: BCF 06.6 |
024C: BCF 03.5 |
024D: BSF 06.6 |
024E: MOVLW 64 |
024F: MOVWF 37 |
0250: CALL 073 |
.................... STOPL; STOPR; |
0251: BSF 03.5 |
0252: BCF 06.6 |
0253: BCF 03.5 |
0254: BCF 06.6 |
0255: BSF 03.5 |
0256: BCF 06.7 |
0257: BCF 03.5 |
0258: BCF 06.7 |
0259: BSF 03.5 |
025A: BCF 06.4 |
025B: BCF 03.5 |
025C: BCF 06.4 |
025D: BSF 03.5 |
025E: BCF 06.5 |
025F: BCF 03.5 |
0260: BCF 06.5 |
.................... beep(1000,1000); |
0261: MOVLW 03 |
0262: MOVWF 37 |
0263: MOVLW E8 |
0264: MOVWF 36 |
0265: MOVLW 03 |
0266: MOVWF 39 |
0267: MOVLW E8 |
0268: MOVWF 38 |
0269: CALL 055 |
.................... output_low(LED3); |
026A: BSF 03.5 |
026B: BCF 05.7 |
026C: BCF 03.5 |
026D: BCF 05.7 |
.................... |
.................... BR; FL; |
026E: BSF 03.5 |
026F: BCF 06.4 |
0270: BCF 03.5 |
0271: BCF 06.4 |
0272: BSF 03.5 |
0273: BCF 06.5 |
0274: BCF 03.5 |
0275: BSF 06.5 |
0276: BSF 03.5 |
0277: BCF 06.7 |
0278: BCF 03.5 |
0279: BCF 06.7 |
027A: BSF 03.5 |
027B: BCF 06.6 |
027C: BCF 03.5 |
027D: BSF 06.6 |
.................... for(n=40000;n>0;n--) // toc se, dokud nenarazis na caru |
027E: MOVLW 9C |
027F: MOVWF 35 |
0280: MOVLW 40 |
0281: MOVWF 34 |
0282: MOVF 34,F |
0283: BTFSS 03.2 |
0284: GOTO 288 |
0285: MOVF 35,F |
0286: BTFSC 03.2 |
0287: GOTO 2B0 |
.................... { |
.................... line = RSENSOR; // cteni senzoru na caru |
0288: CLRF 77 |
0289: BSF 03.5 |
028A: BTFSC 1C.7 |
028B: BSF 77.0 |
028C: BCF 03.5 |
028D: MOVF 2F,W |
028E: XORWF 77,W |
028F: ANDLW 01 |
0290: BTFSS 03.2 |
0291: GOTO 294 |
0292: MOVLW 00 |
0293: GOTO 295 |
0294: MOVLW 01 |
0295: MOVWF 2A |
.................... line |= LSENSOR << 1; |
0296: CLRF 77 |
0297: BSF 03.5 |
0298: BTFSC 1C.6 |
0299: BSF 77.0 |
029A: BCF 03.5 |
029B: MOVF 2F,W |
029C: XORWF 77,W |
029D: ANDLW 01 |
029E: BTFSS 03.2 |
029F: GOTO 2A2 |
02A0: MOVLW 00 |
02A1: GOTO 2A3 |
02A2: MOVLW 01 |
02A3: MOVWF 77 |
02A4: BCF 03.0 |
02A5: RLF 77,F |
02A6: MOVF 77,W |
02A7: IORWF 2A,F |
.................... if (line!=0) break; |
02A8: MOVF 2A,F |
02A9: BTFSS 03.2 |
02AA: GOTO 2B0 |
.................... } |
02AB: MOVF 34,W |
02AC: BTFSC 03.2 |
02AD: DECF 35,F |
02AE: DECF 34,F |
02AF: GOTO 282 |
.................... STOPR; STOPL; |
02B0: BSF 03.5 |
02B1: BCF 06.4 |
02B2: BCF 03.5 |
02B3: BCF 06.4 |
02B4: BSF 03.5 |
02B5: BCF 06.5 |
02B6: BCF 03.5 |
02B7: BCF 06.5 |
02B8: BSF 03.5 |
02B9: BCF 06.6 |
02BA: BCF 03.5 |
02BB: BCF 06.6 |
02BC: BSF 03.5 |
02BD: BCF 06.7 |
02BE: BCF 03.5 |
02BF: BCF 06.7 |
.................... output_high(LED1); output_high(LED3); output_high(LED4); |
02C0: BSF 03.5 |
02C1: BCF 05.4 |
02C2: BCF 03.5 |
02C3: BSF 05.4 |
02C4: BSF 03.5 |
02C5: BCF 05.7 |
02C6: BCF 03.5 |
02C7: BSF 05.7 |
02C8: BSF 03.5 |
02C9: BCF 05.6 |
02CA: BCF 03.5 |
02CB: BSF 05.6 |
.................... |
.................... line=L; // caru jsme prejeli, tak je vlevo |
02CC: MOVLW 02 |
02CD: MOVWF 2A |
.................... cirkus=0; |
02CE: CLRF 2E |
.................... } |
02CF: BCF 0A.3 |
02D0: GOTO 3F1 (RETURN) |
.................... |
.................... |
.................... void main() |
.................... { |
02D1: CLRF 04 |
02D2: MOVLW 1F |
02D3: ANDWF 03,F |
02D4: BSF 03.5 |
02D5: BCF 1F.4 |
02D6: BCF 1F.5 |
02D7: MOVF 1B,W |
02D8: ANDLW 80 |
02D9: MOVWF 1B |
02DA: MOVLW 07 |
02DB: MOVWF 1C |
02DC: MOVF 1C,W |
02DD: BCF 03.5 |
02DE: BCF 0D.6 |
02DF: MOVLW 60 |
02E0: BSF 03.5 |
02E1: MOVWF 0F |
.................... unsigned int16 n; // pro FOR |
.................... unsigned int16 i; |
.................... |
.................... STOPL; STOPR; // prepne vystupy na ovladani motoru na output a zastavi |
02E2: BCF 06.6 |
02E3: BCF 03.5 |
02E4: BCF 06.6 |
02E5: BSF 03.5 |
02E6: BCF 06.7 |
02E7: BCF 03.5 |
02E8: BCF 06.7 |
02E9: BSF 03.5 |
02EA: BCF 06.4 |
02EB: BCF 03.5 |
02EC: BCF 06.4 |
02ED: BSF 03.5 |
02EE: BCF 06.5 |
02EF: BCF 03.5 |
02F0: BCF 06.5 |
.................... |
.................... setup_oscillator(OSC_4MHZ|OSC_INTRC); // 4 MHz interni RC oscilator |
02F1: MOVLW 62 |
02F2: BSF 03.5 |
02F3: MOVWF 0F |
.................... |
.................... port_b_pullups(TRUE); // pullups pro piano na diagnostiku |
02F4: BCF 01.7 |
.................... setup_spi(FALSE); |
02F5: BCF 03.5 |
02F6: BCF 14.5 |
02F7: BSF 03.5 |
02F8: BCF 06.2 |
02F9: BSF 06.1 |
02FA: BCF 06.4 |
02FB: MOVLW 00 |
02FC: BCF 03.5 |
02FD: MOVWF 14 |
02FE: BSF 03.5 |
02FF: MOVWF 14 |
.................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); // Casovac pro PWM |
0300: MOVF 01,W |
0301: ANDLW C7 |
0302: IORLW 08 |
0303: MOVWF 01 |
.................... |
.................... setup_timer_2(T2_DIV_BY_4,255,10); // Casovac pro regulaci |
0304: MOVLW 48 |
0305: MOVWF 78 |
0306: IORLW 05 |
0307: BCF 03.5 |
0308: MOVWF 12 |
0309: MOVLW FF |
030A: BSF 03.5 |
030B: MOVWF 12 |
.................... // preruseni kazdych 10ms |
.................... setup_adc_ports(BUMPER|VSS_VDD); // nastaveni A/D prevodniku pro naraznik |
030C: BCF 1F.4 |
030D: BCF 1F.5 |
030E: MOVF 1B,W |
030F: ANDLW 80 |
0310: IORLW 04 |
0311: MOVWF 1B |
.................... setup_adc(ADC_CLOCK_INTERNAL); |
0312: BCF 1F.6 |
0313: BCF 03.5 |
0314: BSF 1F.6 |
0315: BSF 1F.7 |
0316: BSF 03.5 |
0317: BCF 1F.7 |
0318: BCF 03.5 |
0319: BSF 1F.0 |
.................... set_adc_channel(2); |
031A: MOVLW 10 |
031B: MOVWF 78 |
031C: MOVF 1F,W |
031D: ANDLW C7 |
031E: IORWF 78,W |
031F: MOVWF 1F |
.................... setup_timer_1(T1_INTERNAL|T1_DIV_BY_1); // Casovac pro naraznik |
0320: MOVLW 85 |
0321: MOVWF 10 |
.................... setup_ccp1(CCP_COMPARE_RESET_TIMER); |
0322: BSF 03.5 |
0323: BSF 06.3 |
0324: MOVLW 0B |
0325: BCF 03.5 |
0326: MOVWF 17 |
.................... CCP_1=(2^10)-1; // prevod kazdou 1ms |
0327: CLRF 16 |
0328: MOVLW 07 |
0329: MOVWF 15 |
.................... |
.................... output_low(LED1); output_low(LED2); output_low(LED3); output_low(LED4); |
032A: BSF 03.5 |
032B: BCF 05.4 |
032C: BCF 03.5 |
032D: BCF 05.4 |
032E: BSF 03.5 |
032F: BCF 05.3 |
0330: BCF 03.5 |
0331: BCF 05.3 |
0332: BSF 03.5 |
0333: BCF 05.7 |
0334: BCF 03.5 |
0335: BCF 05.7 |
0336: BSF 03.5 |
0337: BCF 05.6 |
0338: BCF 03.5 |
0339: BCF 05.6 |
.................... |
.................... setup_comparator(A0_VR_A1_VR); // inicializace komparatoru pro cidla cary |
033A: MOVLW 02 |
033B: BSF 03.5 |
033C: MOVWF 1C |
033D: MOVF 05,W |
033E: IORLW 03 |
033F: MOVWF 05 |
0340: MOVLW 03 |
0341: MOVWF 77 |
0342: DECFSZ 77,F |
0343: GOTO 342 |
0344: MOVF 1C,W |
0345: BCF 03.5 |
0346: BCF 0D.6 |
.................... setup_vref(VREF_HIGH|TRESHOLD); // 32 kroku od 0.25 do 0.75 Vdd |
0347: MOVLW 8F |
0348: BSF 03.5 |
0349: MOVWF 1D |
.................... |
.................... Beep(1000,200); //double beep |
034A: MOVLW 03 |
034B: BCF 03.5 |
034C: MOVWF 37 |
034D: MOVLW E8 |
034E: MOVWF 36 |
034F: CLRF 39 |
0350: MOVLW C8 |
0351: MOVWF 38 |
0352: CALL 055 |
.................... Delay_ms(50); |
0353: MOVLW 32 |
0354: MOVWF 37 |
0355: CALL 073 |
.................... Beep(1000,200); |
0356: MOVLW 03 |
0357: MOVWF 37 |
0358: MOVLW E8 |
0359: MOVWF 36 |
035A: CLRF 39 |
035B: MOVLW C8 |
035C: MOVWF 38 |
035D: CALL 055 |
.................... Delay_ms(1000); // 1s |
035E: MOVLW 04 |
035F: MOVWF 34 |
0360: MOVLW FA |
0361: MOVWF 37 |
0362: CALL 073 |
0363: DECFSZ 34,F |
0364: GOTO 360 |
.................... |
.................... // povoleni rizeni rychlosti zataceni pres preruseni |
.................... enable_interrupts(INT_TIMER2); |
0365: BSF 03.5 |
0366: BSF 0C.1 |
.................... enable_interrupts(GLOBAL); |
0367: MOVLW C0 |
0368: BCF 03.5 |
0369: IORWF 0B,F |
.................... |
.................... /*---------------------------------------------------------------------------*/ |
.................... sensors=S; |
036A: MOVLW 03 |
036B: MOVWF 29 |
.................... line=S; |
036C: MOVWF 2A |
.................... last=S; |
036D: MOVWF 2C |
.................... cirkus=0; |
036E: CLRF 2E |
.................... // movement=S; |
.................... speed=FW_POMALU; |
036F: MOVLW AA |
0370: MOVWF 2B |
.................... |
.................... BW=input(BARVY); // Jaka ma byt barva cary? |
0371: BSF 03.5 |
0372: BSF 06.1 |
0373: BCF 03.5 |
0374: BCF 2F.0 |
0375: BTFSC 06.1 |
0376: BSF 2F.0 |
.................... diagnostika(); // Zkus, jestli nekdo nechce, diagnostiku |
0377: GOTO 088 |
.................... Delay_ms(500); |
0378: MOVLW 02 |
0379: MOVWF 34 |
037A: MOVLW FA |
037B: MOVWF 37 |
037C: CALL 073 |
037D: DECFSZ 34,F |
037E: GOTO 37A |
.................... |
.................... output_high(LED1); Beep(1000,200); Delay_ms(500); |
037F: BSF 03.5 |
0380: BCF 05.4 |
0381: BCF 03.5 |
0382: BSF 05.4 |
0383: MOVLW 03 |
0384: MOVWF 37 |
0385: MOVLW E8 |
0386: MOVWF 36 |
0387: CLRF 39 |
0388: MOVLW C8 |
0389: MOVWF 38 |
038A: CALL 055 |
038B: MOVLW 02 |
038C: MOVWF 34 |
038D: MOVLW FA |
038E: MOVWF 37 |
038F: CALL 073 |
0390: DECFSZ 34,F |
0391: GOTO 38D |
.................... output_high(LED2); Beep(1000,200); Delay_ms(500); |
0392: BSF 03.5 |
0393: BCF 05.3 |
0394: BCF 03.5 |
0395: BSF 05.3 |
0396: MOVLW 03 |
0397: MOVWF 37 |
0398: MOVLW E8 |
0399: MOVWF 36 |
039A: CLRF 39 |
039B: MOVLW C8 |
039C: MOVWF 38 |
039D: CALL 055 |
039E: MOVLW 02 |
039F: MOVWF 34 |
03A0: MOVLW FA |
03A1: MOVWF 37 |
03A2: CALL 073 |
03A3: DECFSZ 34,F |
03A4: GOTO 3A0 |
.................... output_high(LED3); Beep(1000,200); Delay_ms(500); |
03A5: BSF 03.5 |
03A6: BCF 05.7 |
03A7: BCF 03.5 |
03A8: BSF 05.7 |
03A9: MOVLW 03 |
03AA: MOVWF 37 |
03AB: MOVLW E8 |
03AC: MOVWF 36 |
03AD: CLRF 39 |
03AE: MOVLW C8 |
03AF: MOVWF 38 |
03B0: CALL 055 |
03B1: MOVLW 02 |
03B2: MOVWF 34 |
03B3: MOVLW FA |
03B4: MOVWF 37 |
03B5: CALL 073 |
03B6: DECFSZ 34,F |
03B7: GOTO 3B3 |
.................... output_high(LED4); Beep(1000,200); Delay_ms(500); |
03B8: BSF 03.5 |
03B9: BCF 05.6 |
03BA: BCF 03.5 |
03BB: BSF 05.6 |
03BC: MOVLW 03 |
03BD: MOVWF 37 |
03BE: MOVLW E8 |
03BF: MOVWF 36 |
03C0: CLRF 39 |
03C1: MOVLW C8 |
03C2: MOVWF 38 |
03C3: CALL 055 |
03C4: MOVLW 02 |
03C5: MOVWF 34 |
03C6: MOVLW FA |
03C7: MOVWF 37 |
03C8: CALL 073 |
03C9: DECFSZ 34,F |
03CA: GOTO 3C6 |
.................... |
.................... while(true) // hlavni smycka (jizda podle cary) |
.................... { |
.................... sensors = RSENSOR; // cteni senzoru na caru |
03CB: CLRF 77 |
03CC: BSF 03.5 |
03CD: BTFSC 1C.7 |
03CE: BSF 77.0 |
03CF: BCF 03.5 |
03D0: MOVF 2F,W |
03D1: XORWF 77,W |
03D2: ANDLW 01 |
03D3: BTFSS 03.2 |
03D4: GOTO 3D7 |
03D5: MOVLW 00 |
03D6: GOTO 3D8 |
03D7: MOVLW 01 |
03D8: MOVWF 29 |
.................... sensors |= LSENSOR << 1; |
03D9: CLRF 77 |
03DA: BSF 03.5 |
03DB: BTFSC 1C.6 |
03DC: BSF 77.0 |
03DD: BCF 03.5 |
03DE: MOVF 2F,W |
03DF: XORWF 77,W |
03E0: ANDLW 01 |
03E1: BTFSS 03.2 |
03E2: GOTO 3E5 |
03E3: MOVLW 00 |
03E4: GOTO 3E6 |
03E5: MOVLW 01 |
03E6: MOVWF 77 |
03E7: BCF 03.0 |
03E8: RLF 77,F |
03E9: MOVF 77,W |
03EA: IORWF 29,F |
.................... |
.................... if (read_adc(ADC_READ_ONLY)<BUMPER_TRESHOLD) OtocSe(); |
03EB: BTFSC 1F.2 |
03EC: GOTO 3EB |
03ED: MOVF 1E,W |
03EE: SUBLW 7F |
03EF: BTFSC 03.0 |
03F0: GOTO 1F8 |
.................... |
.................... switch (sensors) // zatacej podle toho, kde vidis caru |
.................... { |
03F1: MOVF 29,W |
03F2: XORLW 03 |
03F3: BTFSC 03.2 |
03F4: GOTO 3FC |
03F5: XORLW 01 |
03F6: BTFSC 03.2 |
03F7: GOTO 431 |
03F8: XORLW 03 |
03F9: BTFSC 03.2 |
03FA: GOTO 468 |
03FB: GOTO 49F |
.................... case S: // rovne |
.................... GO(L, F, FW_STREDNE+rovinka); GO(R, F, FW_STREDNE+rovinka); |
03FC: MOVF 01,W |
03FD: MOVWF 34 |
03FE: MOVLW BE |
03FF: ADDWF 2D,W |
0400: SUBWF 34,W |
0401: BTFSC 03.2 |
0402: GOTO 405 |
0403: BTFSC 03.0 |
0404: GOTO 40E |
0405: BSF 03.5 |
0406: BCF 06.7 |
0407: BCF 03.5 |
0408: BCF 06.7 |
0409: BSF 03.5 |
040A: BCF 06.6 |
040B: BCF 03.5 |
040C: BSF 06.6 |
040D: GOTO 416 |
040E: BSF 03.5 |
040F: BCF 06.6 |
0410: BCF 03.5 |
0411: BCF 06.6 |
0412: BSF 03.5 |
0413: BCF 06.7 |
0414: BCF 03.5 |
0415: BCF 06.7 |
0416: MOVF 01,W |
0417: MOVWF 34 |
0418: MOVLW BE |
0419: ADDWF 2D,W |
041A: SUBWF 34,W |
041B: BTFSC 03.2 |
041C: GOTO 41F |
041D: BTFSC 03.0 |
041E: GOTO 428 |
041F: BSF 03.5 |
0420: BCF 06.5 |
0421: BCF 03.5 |
0422: BCF 06.5 |
0423: BSF 03.5 |
0424: BCF 06.4 |
0425: BCF 03.5 |
0426: BSF 06.4 |
0427: GOTO 430 |
0428: BSF 03.5 |
0429: BCF 06.4 |
042A: BCF 03.5 |
042B: BCF 06.4 |
042C: BSF 03.5 |
042D: BCF 06.5 |
042E: BCF 03.5 |
042F: BCF 06.5 |
.................... continue; |
0430: GOTO 3CB |
.................... case L: // trochu vlevo |
.................... GO(L, F, FW_POMALU+rovinka); GO(R, F, FW_STREDNE+rovinka); |
0431: MOVF 01,W |
0432: MOVWF 34 |
0433: MOVLW AA |
0434: ADDWF 2D,W |
0435: SUBWF 34,W |
0436: BTFSC 03.2 |
0437: GOTO 43A |
0438: BTFSC 03.0 |
0439: GOTO 443 |
043A: BSF 03.5 |
043B: BCF 06.7 |
043C: BCF 03.5 |
043D: BCF 06.7 |
043E: BSF 03.5 |
043F: BCF 06.6 |
0440: BCF 03.5 |
0441: BSF 06.6 |
0442: GOTO 44B |
0443: BSF 03.5 |
0444: BCF 06.6 |
0445: BCF 03.5 |
0446: BCF 06.6 |
0447: BSF 03.5 |
0448: BCF 06.7 |
0449: BCF 03.5 |
044A: BCF 06.7 |
044B: MOVF 01,W |
044C: MOVWF 34 |
044D: MOVLW BE |
044E: ADDWF 2D,W |
044F: SUBWF 34,W |
0450: BTFSC 03.2 |
0451: GOTO 454 |
0452: BTFSC 03.0 |
0453: GOTO 45D |
0454: BSF 03.5 |
0455: BCF 06.5 |
0456: BCF 03.5 |
0457: BCF 06.5 |
0458: BSF 03.5 |
0459: BCF 06.4 |
045A: BCF 03.5 |
045B: BSF 06.4 |
045C: GOTO 465 |
045D: BSF 03.5 |
045E: BCF 06.4 |
045F: BCF 03.5 |
0460: BCF 06.4 |
0461: BSF 03.5 |
0462: BCF 06.5 |
0463: BCF 03.5 |
0464: BCF 06.5 |
.................... line=L; |
0465: MOVLW 02 |
0466: MOVWF 2A |
.................... continue; |
0467: GOTO 3CB |
.................... case R: // trochu vpravo |
.................... GO(R, F, FW_POMALU+rovinka); GO(L, F, FW_STREDNE+rovinka); |
0468: MOVF 01,W |
0469: MOVWF 34 |
046A: MOVLW AA |
046B: ADDWF 2D,W |
046C: SUBWF 34,W |
046D: BTFSC 03.2 |
046E: GOTO 471 |
046F: BTFSC 03.0 |
0470: GOTO 47A |
0471: BSF 03.5 |
0472: BCF 06.5 |
0473: BCF 03.5 |
0474: BCF 06.5 |
0475: BSF 03.5 |
0476: BCF 06.4 |
0477: BCF 03.5 |
0478: BSF 06.4 |
0479: GOTO 482 |
047A: BSF 03.5 |
047B: BCF 06.4 |
047C: BCF 03.5 |
047D: BCF 06.4 |
047E: BSF 03.5 |
047F: BCF 06.5 |
0480: BCF 03.5 |
0481: BCF 06.5 |
0482: MOVF 01,W |
0483: MOVWF 34 |
0484: MOVLW BE |
0485: ADDWF 2D,W |
0486: SUBWF 34,W |
0487: BTFSC 03.2 |
0488: GOTO 48B |
0489: BTFSC 03.0 |
048A: GOTO 494 |
048B: BSF 03.5 |
048C: BCF 06.7 |
048D: BCF 03.5 |
048E: BCF 06.7 |
048F: BSF 03.5 |
0490: BCF 06.6 |
0491: BCF 03.5 |
0492: BSF 06.6 |
0493: GOTO 49C |
0494: BSF 03.5 |
0495: BCF 06.6 |
0496: BCF 03.5 |
0497: BCF 06.6 |
0498: BSF 03.5 |
0499: BCF 06.7 |
049A: BCF 03.5 |
049B: BCF 06.7 |
.................... line=R; |
049C: MOVLW 01 |
049D: MOVWF 2A |
.................... continue; |
049E: GOTO 3CB |
.................... default: // kdyz jsou obe cidla mimo caru, tak pokracuj dal |
.................... }; |
.................... rovinka=0; |
049F: CLRF 2D |
.................... |
.................... if (last!=line) // pokud si prejel caru z jedne strany na druhou stranu, |
04A0: MOVF 2A,W |
04A1: SUBWF 2C,W |
04A2: BTFSC 03.2 |
04A3: GOTO 560 |
.................... // tak zabrzdi |
.................... { |
.................... output_bit(LED1, !input(LED1)); |
04A4: BSF 03.5 |
04A5: BSF 05.4 |
04A6: BCF 03.5 |
04A7: BTFSS 05.4 |
04A8: GOTO 4AB |
04A9: BCF 05.4 |
04AA: GOTO 4AC |
04AB: BSF 05.4 |
04AC: BSF 03.5 |
04AD: BCF 05.4 |
.................... last=line; |
04AE: BCF 03.5 |
04AF: MOVF 2A,W |
04B0: MOVWF 2C |
.................... speed=FW_ZATACKA; |
04B1: MOVLW C8 |
04B2: MOVWF 2B |
.................... cirkus++; |
04B3: INCF 2E,F |
.................... if (cirkus>8) |
04B4: MOVF 2E,W |
04B5: SUBLW 08 |
04B6: BTFSC 03.0 |
04B7: GOTO 560 |
.................... { |
.................... STOPL; STOPR; |
04B8: BSF 03.5 |
04B9: BCF 06.6 |
04BA: BCF 03.5 |
04BB: BCF 06.6 |
04BC: BSF 03.5 |
04BD: BCF 06.7 |
04BE: BCF 03.5 |
04BF: BCF 06.7 |
04C0: BSF 03.5 |
04C1: BCF 06.4 |
04C2: BCF 03.5 |
04C3: BCF 06.4 |
04C4: BSF 03.5 |
04C5: BCF 06.5 |
04C6: BCF 03.5 |
04C7: BCF 06.5 |
.................... cirkus=0; |
04C8: CLRF 2E |
.................... disable_interrupts(GLOBAL); |
04C9: BCF 0B.6 |
04CA: BCF 0B.7 |
04CB: BTFSC 0B.7 |
04CC: GOTO 4CA |
.................... beep(1000,400); |
04CD: MOVLW 03 |
04CE: MOVWF 37 |
04CF: MOVLW E8 |
04D0: MOVWF 36 |
04D1: MOVLW 01 |
04D2: MOVWF 39 |
04D3: MOVLW 90 |
04D4: MOVWF 38 |
04D5: CALL 055 |
.................... for(n=3000; n>3950; n--) beep(n,10); |
04D6: MOVLW 0B |
04D7: MOVWF 31 |
04D8: MOVLW B8 |
04D9: MOVWF 30 |
04DA: MOVF 31,W |
04DB: SUBLW 0E |
04DC: BTFSC 03.0 |
04DD: GOTO 4F2 |
04DE: XORLW FF |
04DF: BTFSS 03.2 |
04E0: GOTO 4E5 |
04E1: MOVF 30,W |
04E2: SUBLW 6E |
04E3: BTFSC 03.0 |
04E4: GOTO 4F2 |
04E5: MOVF 31,W |
04E6: MOVWF 37 |
04E7: MOVF 30,W |
04E8: MOVWF 36 |
04E9: CLRF 39 |
04EA: MOVLW 0A |
04EB: MOVWF 38 |
04EC: CALL 055 |
04ED: MOVF 30,W |
04EE: BTFSC 03.2 |
04EF: DECF 31,F |
04F0: DECF 30,F |
04F1: GOTO 4DA |
.................... output_low(LED1); |
04F2: BSF 03.5 |
04F3: BCF 05.4 |
04F4: BCF 03.5 |
04F5: BCF 05.4 |
.................... beep(2000,200); |
04F6: MOVLW 07 |
04F7: MOVWF 37 |
04F8: MOVLW D0 |
04F9: MOVWF 36 |
04FA: CLRF 39 |
04FB: MOVLW C8 |
04FC: MOVWF 38 |
04FD: CALL 055 |
.................... beep(900,400); |
04FE: MOVLW 03 |
04FF: MOVWF 37 |
0500: MOVLW 84 |
0501: MOVWF 36 |
0502: MOVLW 01 |
0503: MOVWF 39 |
0504: MOVLW 90 |
0505: MOVWF 38 |
0506: CALL 055 |
.................... for(n=2950; n<3000; n++) beep(n,10); |
0507: MOVLW 0B |
0508: MOVWF 31 |
0509: MOVLW 86 |
050A: MOVWF 30 |
050B: MOVF 31,W |
050C: SUBLW 0B |
050D: BTFSS 03.0 |
050E: GOTO 521 |
050F: BTFSS 03.2 |
0510: GOTO 515 |
0511: MOVF 30,W |
0512: SUBLW B7 |
0513: BTFSS 03.0 |
0514: GOTO 521 |
0515: MOVF 31,W |
0516: MOVWF 37 |
0517: MOVF 30,W |
0518: MOVWF 36 |
0519: CLRF 39 |
051A: MOVLW 0A |
051B: MOVWF 38 |
051C: CALL 055 |
051D: INCF 30,F |
051E: BTFSC 03.2 |
051F: INCF 31,F |
0520: GOTO 50B |
.................... output_low(LED2); |
0521: BSF 03.5 |
0522: BCF 05.3 |
0523: BCF 03.5 |
0524: BCF 05.3 |
.................... output_high(LED1); |
0525: BSF 03.5 |
0526: BCF 05.4 |
0527: BCF 03.5 |
0528: BSF 05.4 |
.................... beep(4000,400); |
0529: MOVLW 0F |
052A: MOVWF 37 |
052B: MOVLW A0 |
052C: MOVWF 36 |
052D: MOVLW 01 |
052E: MOVWF 39 |
052F: MOVLW 90 |
0530: MOVWF 38 |
0531: CALL 055 |
.................... beep(1000,100); |
0532: MOVLW 03 |
0533: MOVWF 37 |
0534: MOVLW E8 |
0535: MOVWF 36 |
0536: CLRF 39 |
0537: MOVLW 64 |
0538: MOVWF 38 |
0539: CALL 055 |
.................... output_low(LED3); |
053A: BSF 03.5 |
053B: BCF 05.7 |
053C: BCF 03.5 |
053D: BCF 05.7 |
.................... beep(3000,400); |
053E: MOVLW 0B |
053F: MOVWF 37 |
0540: MOVLW B8 |
0541: MOVWF 36 |
0542: MOVLW 01 |
0543: MOVWF 39 |
0544: MOVLW 90 |
0545: MOVWF 38 |
0546: CALL 055 |
.................... Delay_ms(1000); |
0547: MOVLW 04 |
0548: MOVWF 34 |
0549: MOVLW FA |
054A: MOVWF 37 |
054B: CALL 073 |
054C: DECFSZ 34,F |
054D: GOTO 549 |
.................... output_high(LED1); output_high(LED2); |
054E: BSF 03.5 |
054F: BCF 05.4 |
0550: BCF 03.5 |
0551: BSF 05.4 |
0552: BSF 03.5 |
0553: BCF 05.3 |
0554: BCF 03.5 |
0555: BSF 05.3 |
.................... output_high(LED3); output_high(LED4); |
0556: BSF 03.5 |
0557: BCF 05.7 |
0558: BCF 03.5 |
0559: BSF 05.7 |
055A: BSF 03.5 |
055B: BCF 05.6 |
055C: BCF 03.5 |
055D: BSF 05.6 |
.................... enable_interrupts(GLOBAL); |
055E: MOVLW C0 |
055F: IORWF 0B,F |
.................... } |
.................... }; |
.................... |
.................... if (L==line) // kdyz jsou obe cidla mimo caru, zatoc na caru |
0560: MOVF 2A,W |
0561: SUBLW 02 |
0562: BTFSS 03.2 |
0563: GOTO 582 |
.................... { |
.................... STOPL; |
0564: BSF 03.5 |
0565: BCF 06.6 |
0566: BCF 03.5 |
0567: BCF 06.6 |
0568: BSF 03.5 |
0569: BCF 06.7 |
056A: BCF 03.5 |
056B: BCF 06.7 |
.................... GO(R, F, speed); |
056C: MOVF 01,W |
056D: SUBWF 2B,W |
056E: BTFSS 03.0 |
056F: GOTO 579 |
0570: BSF 03.5 |
0571: BCF 06.5 |
0572: BCF 03.5 |
0573: BCF 06.5 |
0574: BSF 03.5 |
0575: BCF 06.4 |
0576: BCF 03.5 |
0577: BSF 06.4 |
0578: GOTO 581 |
0579: BSF 03.5 |
057A: BCF 06.4 |
057B: BCF 03.5 |
057C: BCF 06.4 |
057D: BSF 03.5 |
057E: BCF 06.5 |
057F: BCF 03.5 |
0580: BCF 06.5 |
.................... } |
.................... else |
0581: GOTO 59F |
.................... { |
.................... STOPR; |
0582: BSF 03.5 |
0583: BCF 06.4 |
0584: BCF 03.5 |
0585: BCF 06.4 |
0586: BSF 03.5 |
0587: BCF 06.5 |
0588: BCF 03.5 |
0589: BCF 06.5 |
.................... GO(L, F, speed); |
058A: MOVF 01,W |
058B: SUBWF 2B,W |
058C: BTFSS 03.0 |
058D: GOTO 597 |
058E: BSF 03.5 |
058F: BCF 06.7 |
0590: BCF 03.5 |
0591: BCF 06.7 |
0592: BSF 03.5 |
0593: BCF 06.6 |
0594: BCF 03.5 |
0595: BSF 06.6 |
0596: GOTO 59F |
0597: BSF 03.5 |
0598: BCF 06.6 |
0599: BCF 03.5 |
059A: BCF 06.6 |
059B: BSF 03.5 |
059C: BCF 06.7 |
059D: BCF 03.5 |
059E: BCF 06.7 |
.................... } |
.................... |
.................... } // while(true) |
059F: GOTO 3CB |
.................... } |
.................... |
.................... |
05A0: SLEEP |
Configuration Fuses: |
Word 1: 3F38 NOWDT NOPUT MCLR NOBROWNOUT NOLVP NOCPD NOWRT NODEBUG CCPB0 NOPROTECT INTRC_IO |
Word 2: 3FFC NOFCMEN NOIESO |
/Designs/ROBOTS/Merkur/SW/MerkurU/tank.PJT |
---|
0,0 → 1,40 |
[PROJECT] |
Target=tank.HEX |
Development_Mode= |
Processor=0x688F |
ToolSuite=CCS |
[Directories] |
Include=C:\Program Files\PICC\devices\;C:\Program Files\PICC\drivers\;C:\library\CCS; |
Library= |
LinkerScript= |
[Target Data] |
FileList=tank.c; |
BuildTool=C-COMPILER |
OptionString=+FM |
AdditionalOptionString= |
BuildRequired=1 |
[tank.c] |
Type=4 |
Path= |
FileList= |
BuildTool= |
OptionString= |
AdditionalOptionString= |
[mru-list] |
1=tank.c |
[Windows] |
0=0000 tank.c 0 0 796 451 3 0 |
[Opened Files] |
1=D:\KAKLIK\programy\PIC_C\roboti\merkur\PIC16F88\MerkurU\tank.c |
2=C:\Program Files\PICC\devices\16F88.h |
3=D:\KAKLIK\programy\PIC_C\roboti\merkur\PIC16F88\MerkurU\tank.h |
4= |
5= |
6= |
7= |
/Designs/ROBOTS/Merkur/SW/MerkurU/tank.SYM |
---|
0,0 → 1,71 |
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 sensors |
02A line |
02B speed |
02C last |
02D rovinka |
02E cirkus |
02F.0 BW |
030-031 main.n |
032-033 main.i |
034-035 diagnostika.n |
034-035 OtocSe.n |
034 main.@SCRATCH |
035 main.@SCRATCH |
036-037 beep.period |
036 diagnostika.@SCRATCH |
036 OtocSe.@SCRATCH |
037 @delay_ms1.P1 |
037 OtocSe.@SCRATCH |
038-039 beep.length |
03A-03B beep.nn |
03C @delay_us1.P1 |
077 @SCRATCH |
078 @SCRATCH |
078 _RETURN_ |
079 @SCRATCH |
07A @SCRATCH |
07B @SCRATCH |
09C.6 C1OUT |
09C.7 C2OUT |
0073 @delay_ms1 |
0042 @delay_us1 |
0037 TIMER2_isr |
0055 beep |
0088 diagnostika |
01F8 OtocSe |
02D1 main |
02D1 @cinit |
Project Files: |
D:\KAKLIK\programy\PIC_C\roboti\merkur\PIC16F88\MerkurU\tank.c |
D:\KAKLIK\programy\PIC_C\roboti\merkur\PIC16F88\MerkurU\tank.h |
C:\Program Files\PICC\devices\16F88.h |
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\merkur\PIC16F88\MerkurU\tank.err |
INHX8: D:\KAKLIK\programy\PIC_C\roboti\merkur\PIC16F88\MerkurU\tank.HEX |
Symbols: D:\KAKLIK\programy\PIC_C\roboti\merkur\PIC16F88\MerkurU\tank.SYM |
List: D:\KAKLIK\programy\PIC_C\roboti\merkur\PIC16F88\MerkurU\tank.LST |
Debug/COFF: D:\KAKLIK\programy\PIC_C\roboti\merkur\PIC16F88\MerkurU\tank.cof |
Call Tree: D:\KAKLIK\programy\PIC_C\roboti\merkur\PIC16F88\MerkurU\tank.tre |
Statistics: D:\KAKLIK\programy\PIC_C\roboti\merkur\PIC16F88\MerkurU\tank.sta |
/Designs/ROBOTS/Merkur/SW/MerkurU/tank.c |
---|
0,0 → 1,268 |
// Program pro predvadeni schopnosti robota Merkur |
//------------------------------------------------ |
#include "tank.h" |
unsigned int8 sensors; // pomocna promenna pro cteni cidel na caru |
unsigned int8 line; // na ktere strane byla detekovana cara |
unsigned int8 speed; // rychlost zataceni |
unsigned int8 last; // kde byla cara, kdyz byly minule cidla mimo |
unsigned int8 rovinka; // pocitadlo pro zjisteni rovneho useku |
int cirkus; // pocitadlo, po kolika akcich se ma delat cirkus |
int1 BW; // urcuje, jestli je cara cerno/bila nebo |
// bilo/cerna (true = bila cara, cerny podklad) |
// Konstanty pro dynamiku pohybu |
#define T_DIRA 120 // po jakem case zataceni se detekuje dira |
#define FW_POMALU 170 // trochu mimo caru vnitrni pas |
#define FW_ZATACKA 200 // rychlost vnejsiho kola pri zataceni |
#define FW_STREDNE 190 // trochu mimo caru vnejsi pas |
#define COUVANI 750 // couvnuti zpet na caru, po detekci diry |
#define MAX_ROVINKA (255-FW_STREDNE) |
#define TRESHOLD 15 // rozhodovaci uroven komparatoru, 0xF = 0.75*Vdd |
#define BUMPER_TRESHOLD 128 // rozhodovaci uroven cidla na prekazku |
//motory //Napred vypnout potom zapnout! |
#define FR output_low(PIN_B5); output_high(PIN_B4) // Vpred |
#define FL output_low(PIN_B7); output_high(PIN_B6) |
#define BR output_low(PIN_B4); output_high(PIN_B5) // Vzad |
#define BL output_low(PIN_B6); output_high(PIN_B7) |
#define STOPR output_low(PIN_B4);output_low(PIN_B5) // Zastav |
#define STOPL output_low(PIN_B6);output_low(PIN_B7) |
#define L 0b10 // left |
#define R 0b01 // right |
#define S 0b11 // straight |
//cidla |
#define RSENSOR (BW != C2OUT) // Senzory na caru |
#define LSENSOR (BW != C1OUT) |
#define BUMPER sAN2 // Senzor na cihlu |
#define DIAG_SERVO PIN_B3 // Propojka pro diagnosticky mod |
#define DIAG_SENSORS PIN_B2 // Propojka pro diagnosticky mod |
#define BARVY PIN_B1 // Propojka pro nastaveni barvy cary |
#define SPEAKER PIN_B0 // vystup pro pipak |
#define LED1 PIN_A4 // LEDky |
#define LED2 PIN_A3 |
#define LED3 PIN_A7 |
#define LED4 PIN_A6 |
// makro pro PWM |
#define GO(motor, direction, power) if(get_timer0()<=power) \ |
{direction##motor;} else {stop##motor;} |
#int_TIMER2 |
void TIMER2_isr() // obsluha zrychlovani |
{ |
if (speed<255) speed++; |
if (rovinka<MAX_ROVINKA) rovinka++; |
} |
// Primitivni Pipani |
void beep(unsigned int16 period, unsigned int16 length) |
{ |
unsigned int16 nn; |
for(nn=length; nn>0; nn--) |
{ |
output_high(SPEAKER); |
delay_us(period); |
output_low(SPEAKER); |
delay_us(period); |
} |
} |
/******************************************************************************/ |
void diagnostika() |
{ |
unsigned int16 n; |
while (input(DIAG_SERVO)) // Propojka, ktera spousti diagnostiku |
{ |
for (n=500; n<800; n+=100) |
{ |
beep(n,n); //beep UP |
}; |
Delay_ms(1000); |
//zastav vse |
STOPL; STOPR; |
//pravy pas |
FR; Delay_ms(1000); STOPR; Delay_ms(1000); |
BR; Delay_ms(1000); STOPR; Delay_ms(1000); |
Beep(880,100); Delay_ms(1000); |
//levy pas |
FL; Delay_ms(1000); STOPL; Delay_ms(1000); |
BL; Delay_ms(1000); STOPL; Delay_ms(1000); |
Beep(880,100); Delay_ms(1000); |
//oba pasy |
FL; FR; Delay_ms(1000); STOPL; STOPR; Delay_ms(1000); |
BL; BR; Delay_ms(1000); STOPL; STOPR; Delay_ms(1000); |
}; |
while (input(DIAG_SENSORS)) // spusteni diagnostiky cidel |
{ |
if (RSENSOR) beep(1000,200); |
Delay_ms(200); |
if (LSENSOR) beep(2000,300); |
Delay_ms(200); |
if ((read_adc(ADC_READ_ONLY)<BUMPER_TRESHOLD)) beep(3000,400); |
Delay_ms(200); |
}; |
} |
/////////////////////////////////////////////////////////////////////////////// |
void OtocSe() // otoci se zpet, kdyz je prekazka |
{ |
unsigned int16 n; |
BL; BR; // cukni zpatky |
Delay_ms(200); |
STOPR;STOPL; |
beep(800,400); |
beep(2000,1000); |
output_low(LED4); |
beep(900,400); |
output_low(LED1); |
BR; FL; Delay_ms(100); // otoc se 30° do prava |
STOPL; STOPR; |
beep(1000,1000); |
output_low(LED3); |
BR; FL; |
for(n=40000;n>0;n--) // toc se, dokud nenarazis na caru |
{ |
line = RSENSOR; // cteni senzoru na caru |
line |= LSENSOR << 1; |
if (line!=0) break; |
} |
STOPR; STOPL; |
output_high(LED1); output_high(LED3); output_high(LED4); |
line=L; // caru jsme prejeli, tak je vlevo |
cirkus=0; |
} |
void main() |
{ |
unsigned int16 n; // pro FOR |
unsigned int16 i; |
STOPL; STOPR; // prepne vystupy na ovladani motoru na output a zastavi |
setup_oscillator(OSC_4MHZ|OSC_INTRC); // 4 MHz interni RC oscilator |
port_b_pullups(TRUE); // pullups pro piano na diagnostiku |
setup_spi(FALSE); |
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); // Casovac pro PWM |
setup_timer_2(T2_DIV_BY_4,255,10); // Casovac pro regulaci |
// preruseni kazdych 10ms |
setup_adc_ports(BUMPER|VSS_VDD); // nastaveni A/D prevodniku pro naraznik |
setup_adc(ADC_CLOCK_INTERNAL); |
set_adc_channel(2); |
setup_timer_1(T1_INTERNAL|T1_DIV_BY_1); // Casovac pro naraznik |
setup_ccp1(CCP_COMPARE_RESET_TIMER); |
CCP_1=(2^10)-1; // prevod kazdou 1ms |
output_low(LED1); output_low(LED2); output_low(LED3); output_low(LED4); |
setup_comparator(A0_VR_A1_VR); // inicializace komparatoru pro cidla cary |
setup_vref(VREF_HIGH|TRESHOLD); // 32 kroku od 0.25 do 0.75 Vdd |
Beep(1000,200); //double beep |
Delay_ms(50); |
Beep(1000,200); |
Delay_ms(1000); // 1s |
// povoleni rizeni rychlosti zataceni pres preruseni |
enable_interrupts(INT_TIMER2); |
enable_interrupts(GLOBAL); |
/*---------------------------------------------------------------------------*/ |
sensors=S; |
line=S; |
last=S; |
cirkus=0; |
// movement=S; |
speed=FW_POMALU; |
BW=input(BARVY); // Jaka ma byt barva cary? |
diagnostika(); // Zkus, jestli nekdo nechce, diagnostiku |
Delay_ms(500); |
output_high(LED1); Beep(1000,200); Delay_ms(500); |
output_high(LED2); Beep(1000,200); Delay_ms(500); |
output_high(LED3); Beep(1000,200); Delay_ms(500); |
output_high(LED4); Beep(1000,200); Delay_ms(500); |
while(true) // hlavni smycka (jizda podle cary) |
{ |
sensors = RSENSOR; // cteni senzoru na caru |
sensors |= LSENSOR << 1; |
if (read_adc(ADC_READ_ONLY)<BUMPER_TRESHOLD) OtocSe(); |
switch (sensors) // zatacej podle toho, kde vidis caru |
{ |
case S: // rovne |
GO(L, F, FW_STREDNE+rovinka); GO(R, F, FW_STREDNE+rovinka); |
continue; |
case L: // trochu vlevo |
GO(L, F, FW_POMALU+rovinka); GO(R, F, FW_STREDNE+rovinka); |
line=L; |
continue; |
case R: // trochu vpravo |
GO(R, F, FW_POMALU+rovinka); GO(L, F, FW_STREDNE+rovinka); |
line=R; |
continue; |
default: // kdyz jsou obe cidla mimo caru, tak pokracuj dal |
}; |
rovinka=0; |
if (last!=line) // pokud si prejel caru z jedne strany na druhou stranu, |
// tak zabrzdi |
{ |
output_bit(LED1, !input(LED1)); |
last=line; |
speed=FW_ZATACKA; |
cirkus++; |
if (cirkus>8) |
{ |
STOPL; STOPR; |
cirkus=0; |
disable_interrupts(GLOBAL); |
beep(1000,400); |
for(n=3000; n>3950; n--) beep(n,10); |
output_low(LED1); |
beep(2000,200); |
beep(900,400); |
for(n=2950; n<3000; n++) beep(n,10); |
output_low(LED2); |
output_high(LED1); |
beep(4000,400); |
beep(1000,100); |
output_low(LED3); |
beep(3000,400); |
Delay_ms(1000); |
output_high(LED1); output_high(LED2); |
output_high(LED3); output_high(LED4); |
enable_interrupts(GLOBAL); |
} |
}; |
if (L==line) // kdyz jsou obe cidla mimo caru, zatoc na caru |
{ |
STOPL; |
GO(R, F, speed); |
} |
else |
{ |
STOPR; |
GO(L, F, speed); |
} |
} // while(true) |
} |
/Designs/ROBOTS/Merkur/SW/MerkurU/tank.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 |
/Designs/ROBOTS/Merkur/SW/MerkurU/tank.err |
---|
0,0 → 1,0 |
No Errors |
/Designs/ROBOTS/Merkur/SW/MerkurU/tank.h |
---|
0,0 → 1,5 |
#include <16F88.h> |
#device adc=8 |
#fuses NOWDT,INTRC_IO, NOPUT, MCLR, NOBROWNOUT, NOLVP, NOCPD, NOWRT, NODEBUG, NOPROTECT, NOFCMEN, NOIESO |
#use delay(clock=4000000) |
/Designs/ROBOTS/Merkur/SW/MerkurU/tank.sta |
---|
0,0 → 1,35 |
ROM used: 1441 (35%) |
1441 (35%) including unused fragments |
3 Average locations per line |
5 Average locations per statement |
RAM used: 27 (15%) at main() level |
34 (19%) worst case |
Lines Stmts % Files |
----- ----- --- ----- |
269 293 100 D:\KAKLIK\programy\PIC_C\roboti\merkur\PIC16F88\MerkurU\tank.c |
6 0 0 D:\KAKLIK\programy\PIC_C\roboti\merkur\PIC16F88\MerkurU\tank.h |
275 0 0 C:\Program Files\PICC\devices\16F88.h |
----- ----- |
1100 586 Total |
Page ROM % RAM Functions: |
---- --- --- --- ---------- |
0 21 1 1 @delay_ms1 |
0 19 1 1 @delay_us1 |
0 11 1 0 TIMER2_isr |
0 30 2 6 beep |
0 368 26 3 diagnostika |
0 217 15 4 OtocSe |
0 720 50 6 main |
Segment Used Free |
--------- ---- ---- |
00000-00003 4 0 |
00004-00036 51 0 |
00037-007FF 1386 607 |
00800-00FFF 0 2048 |
/Designs/ROBOTS/Merkur/SW/MerkurU/tank.tre |
---|
0,0 → 1,106 |
ÀÄtank |
ÃÄmain 0/720 Ram=6 |
³ ÃÄ??0?? |
³ ÃÄbeep 0/30 Ram=6 |
³ ³ ÃÄ@delay_us1 0/19 Ram=1 |
³ ³ ÀÄ@delay_us1 0/19 Ram=1 |
³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ÃÄbeep 0/30 Ram=6 |
³ ³ ÃÄ@delay_us1 0/19 Ram=1 |
³ ³ ÀÄ@delay_us1 0/19 Ram=1 |
³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ÃÄdiagnostika 0/368 Ram=3 |
³ ³ ÃÄbeep 0/30 Ram=6 |
³ ³ ³ ÃÄ@delay_us1 0/19 Ram=1 |
³ ³ ³ ÀÄ@delay_us1 0/19 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄbeep 0/30 Ram=6 |
³ ³ ³ ÃÄ@delay_us1 0/19 Ram=1 |
³ ³ ³ ÀÄ@delay_us1 0/19 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄbeep 0/30 Ram=6 |
³ ³ ³ ÃÄ@delay_us1 0/19 Ram=1 |
³ ³ ³ ÀÄ@delay_us1 0/19 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄbeep 0/30 Ram=6 |
³ ³ ³ ÃÄ@delay_us1 0/19 Ram=1 |
³ ³ ³ ÀÄ@delay_us1 0/19 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄbeep 0/30 Ram=6 |
³ ³ ³ ÃÄ@delay_us1 0/19 Ram=1 |
³ ³ ³ ÀÄ@delay_us1 0/19 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄbeep 0/30 Ram=6 |
³ ³ ³ ÃÄ@delay_us1 0/19 Ram=1 |
³ ³ ³ ÀÄ@delay_us1 0/19 Ram=1 |
³ ³ ÀÄ@delay_ms1 0/21 Ram=1 |
³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ÃÄbeep 0/30 Ram=6 |
³ ³ ÃÄ@delay_us1 0/19 Ram=1 |
³ ³ ÀÄ@delay_us1 0/19 Ram=1 |
³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ÃÄbeep 0/30 Ram=6 |
³ ³ ÃÄ@delay_us1 0/19 Ram=1 |
³ ³ ÀÄ@delay_us1 0/19 Ram=1 |
³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ÃÄbeep 0/30 Ram=6 |
³ ³ ÃÄ@delay_us1 0/19 Ram=1 |
³ ³ ÀÄ@delay_us1 0/19 Ram=1 |
³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ÃÄbeep 0/30 Ram=6 |
³ ³ ÃÄ@delay_us1 0/19 Ram=1 |
³ ³ ÀÄ@delay_us1 0/19 Ram=1 |
³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ÃÄOtocSe 0/217 Ram=4 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄbeep 0/30 Ram=6 |
³ ³ ³ ÃÄ@delay_us1 0/19 Ram=1 |
³ ³ ³ ÀÄ@delay_us1 0/19 Ram=1 |
³ ³ ÃÄbeep 0/30 Ram=6 |
³ ³ ³ ÃÄ@delay_us1 0/19 Ram=1 |
³ ³ ³ ÀÄ@delay_us1 0/19 Ram=1 |
³ ³ ÃÄbeep 0/30 Ram=6 |
³ ³ ³ ÃÄ@delay_us1 0/19 Ram=1 |
³ ³ ³ ÀÄ@delay_us1 0/19 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÀÄbeep 0/30 Ram=6 |
³ ³ ÃÄ@delay_us1 0/19 Ram=1 |
³ ³ ÀÄ@delay_us1 0/19 Ram=1 |
³ ÃÄbeep 0/30 Ram=6 |
³ ³ ÃÄ@delay_us1 0/19 Ram=1 |
³ ³ ÀÄ@delay_us1 0/19 Ram=1 |
³ ÃÄbeep 0/30 Ram=6 |
³ ³ ÃÄ@delay_us1 0/19 Ram=1 |
³ ³ ÀÄ@delay_us1 0/19 Ram=1 |
³ ÃÄbeep 0/30 Ram=6 |
³ ³ ÃÄ@delay_us1 0/19 Ram=1 |
³ ³ ÀÄ@delay_us1 0/19 Ram=1 |
³ ÃÄbeep 0/30 Ram=6 |
³ ³ ÃÄ@delay_us1 0/19 Ram=1 |
³ ³ ÀÄ@delay_us1 0/19 Ram=1 |
³ ÃÄbeep 0/30 Ram=6 |
³ ³ ÃÄ@delay_us1 0/19 Ram=1 |
³ ³ ÀÄ@delay_us1 0/19 Ram=1 |
³ ÃÄbeep 0/30 Ram=6 |
³ ³ ÃÄ@delay_us1 0/19 Ram=1 |
³ ³ ÀÄ@delay_us1 0/19 Ram=1 |
³ ÃÄbeep 0/30 Ram=6 |
³ ³ ÃÄ@delay_us1 0/19 Ram=1 |
³ ³ ÀÄ@delay_us1 0/19 Ram=1 |
³ ÃÄbeep 0/30 Ram=6 |
³ ³ ÃÄ@delay_us1 0/19 Ram=1 |
³ ³ ÀÄ@delay_us1 0/19 Ram=1 |
³ ÀÄ@delay_ms1 0/21 Ram=1 |
ÀÄTIMER2_isr 0/11 Ram=0 |
/Designs/ROBOTS/Merkur/SW/README.txt |
---|
0,0 → 1,6 |
Složka MerkurU obsahuje zdrojáky pro jízdu po neuzavřené křivce |
Složka turn_L obsahuje zdroják pro objíždění cihly vlevo |
Složka turn_R obsahuje zdroják pro objíždění cihly vpravo |
A složka vystava je verze firmware pro výstavně ježdění, zařazena rutina pro usporný režim a šetření motorů. |
/Designs/ROBOTS/Merkur/SW/turn_L/AX25.c |
---|
0,0 → 1,135 |
#nolist |
//#define PTT PIN_A2 // PTT control |
//#define TXo PIN_C0 // To the transmitter modulator |
#define PERIODAH delay_us(222) // Halfperiod H 222;78/1200 500;430/500 |
#define TAILH delay_us(78) |
#define PERIODAL delay_us(412) // Halfperiod L 412;345/1200 1000;880/500 |
#define TAILL delay_us(345) |
#byte STATUS = 3 // CPUs status register |
byte SendData[16] = {'A'<<1, 'L'<<1, 'L'<<1, ' '<<1, ' '<<1, ' '<<1, 0x60, |
'C'<<1, 'Z'<<1, '0'<<1, 'R'<<1, 'R'<<1, 'R'<<1, 0x61, |
0x03, 0xF0}; |
boolean bit; |
int fcslo, fcshi; // variabloes for calculating FCS (CRC) |
int stuff; // stuff counter for extra 0 |
int flag_flag; // if it is sending flag (7E) |
int fcs_flag; // if it is sending Frame Check Sequence |
int i; // for for |
void flipout() //flips the state of output pin a_1 |
{ |
stuff = 0; //since this is a 0, reset the stuff counter |
if (bit) |
{ |
bit=FALSE; //if the state of the pin was low, make it high. |
} |
else |
{ |
bit=TRUE; //if the state of the pin was high make it low |
} |
} |
void fcsbit(byte tbyte) |
{ |
#asm |
BCF STATUS,0 |
RRF fcshi,F // rotates the entire 16 bits |
RRF fcslo,F // to the right |
#endasm |
if (((STATUS & 0x01)^(tbyte)) ==0x01) |
{ |
fcshi = fcshi^0x84; |
fcslo = fcslo^0x08; |
} |
} |
void SendBit () |
{ |
if (bit) |
{ |
output_high(TXo); |
PERIODAH; |
output_low(TXo); |
PERIODAH; |
output_high(TXo); |
PERIODAH; |
output_low(TXo); |
TAILH; |
} |
else |
{ |
output_high(TXo); |
PERIODAL; |
output_low(TXo); |
TAILL; |
}; |
} |
void SendByte (byte inbyte) |
{ |
int k, bt; |
for (k=0;k<8;k++) //do the following for each of the 8 bits in the byte |
{ |
bt = inbyte & 0x01; //strip off the rightmost bit of the byte to be sent (inbyte) |
if ((fcs_flag == FALSE) & (flag_flag == FALSE)) fcsbit(bt); //do FCS calc, but only if this |
//is not a flag or fcs byte |
if (bt == 0) |
{ |
flipout(); |
} // if this bit is a zero, flip the output state |
else |
{ //otherwise if it is a 1, do the following: |
if (flag_flag == FALSE) stuff++; //increment the count of consequtive 1's |
if ((flag_flag == FALSE) & (stuff == 5)) |
{ //stuff an extra 0, if 5 1's in a row |
SendBit(); |
flipout(); //flip the output state to stuff a 0 |
}//end of if |
}//end of else |
// delay_us(850); //introduces a delay that creates 1200 baud |
SendBit(); |
inbyte = inbyte>>1; //go to the next bit in the byte |
}//end of for |
}//end of SendByte |
void SendPacket(char *data) |
{ |
bit=FALSE; |
fcslo=fcshi=0xFF; //The 2 FCS Bytes are initialized to FF |
stuff = 0; //The variable stuff counts the number of 1's in a row. When it gets to 5 |
// it is time to stuff a 0. |
// output_low(PTT); // Blinking LED |
// delay_ms(1000); |
// output_high(PTT); |
flag_flag = TRUE; //The variable flag is true if you are transmitted flags (7E's) false otherwise. |
fcs_flag = FALSE; //The variable fcsflag is true if you are transmitting FCS bytes, false otherwise. |
for(i=0; i<10; i++) SendByte(0x7E); //Sends flag bytes. Adjust length for txdelay |
//each flag takes approx 6.7 ms |
flag_flag = FALSE; //done sending flags |
for(i=0; i<16; i++) SendByte(SendData[i]); //send the packet bytes |
for(i=0; 0 != *data; i++) |
{ |
SendByte(*data); //send the packet bytes |
data++; |
}; |
fcs_flag = TRUE; //about to send the FCS bytes |
fcslo =fcslo^0xff; //must XOR them with FF before sending |
fcshi = fcshi^0xff; |
SendByte(fcslo); //send the low byte of fcs |
SendByte(fcshi); //send the high byte of fcs |
fcs_flag = FALSE; //done sending FCS |
flag_flag = TRUE; //about to send flags |
SendByte(0x7e); // Send a flag to end packet |
} |
#list |
/Designs/ROBOTS/Merkur/SW/turn_L/tank.BAK |
---|
0,0 → 1,340 |
#include "tank.h" |
#define DEBUG |
#define TXo PIN_A3 // To the transmitter modulator |
#include "AX25.c" // podprogram pro prenos telemetrie |
unsigned int8 sensors; // pomocna promenna pro cteni cidel na caru |
unsigned int8 line; // na ktere strane byla detekovana cara |
unsigned int8 speed; // rychlost zataceni |
unsigned int8 rovinka; // pocitadlo pro zjisteni rovneho useku |
unsigned int8 last; // kde byla cara, kdyz byly minule cidla mimo |
unsigned int8 movement; // obsahuje aktualni smer zataceni |
unsigned int8 dira; // pocita dobu po kterou je ztracena cara |
// Konstanty pro dynamiku pohybu |
#define T_DIRA 87 // po jakem case zataceni se detekuje dira |
#define INC_SPEED 1 // prirustek rychlosti v jednom kroku |
#define FW_POMALU 230 // trochu mimo caru vnitrni pas |
#define FW_ZATACKA 200 // rychlost vnejsiho kola pri zataceni |
#define FW_STREDNE 240 // trochu mimo caru vnejsi pas |
#define COUVANI 600 // couvnuti zpet na caru, po detekci diry |
#define PRES_DIRU 250 |
#define MAX_ROVINKA (255-FW_STREDNE) |
#define TRESHOLD 10 // rozhodovaci uroven komparatoru, 0xF = 0.75*Vdd |
#define BUMPER_TRESHOLD 128 |
#define CIK_CAK 30000 |
#define T_CIHLA 50 // perioda detekce cihly |
//motory //Napred vypnout potom zapnout! |
#define FR output_low(PIN_B5); output_high(PIN_B4) // Vpred |
#define FL output_low(PIN_B7); output_high(PIN_B6) |
#define BR output_low(PIN_B4); output_high(PIN_B5) // Vzad |
#define BL output_low(PIN_B6); output_high(PIN_B7) |
#define STOPR output_low(PIN_B4);output_low(PIN_B5) // Zastav |
#define STOPL output_low(PIN_B6);output_low(PIN_B7) |
#define L 0b10 // left |
#define R 0b01 // right |
#define S 0b11 // straight |
//cidla |
#define RSENSOR C2OUT // Senzory na caru |
#define LSENSOR C1OUT |
#define BUMPER PIN_A4 // Senzor na cihlu |
#define DIAG_SERVO PIN_B3 // Propojka pro diagnosticky mod |
#define DIAG_SENSORS PIN_B2 // Propojka pro diagnosticky mod |
#DEFINE SOUND_HI PIN_A6 // komplementarni vystupy pro piezo pipak |
#DEFINE SOUND_LO PIN_A7 |
char AXstring[40]; // Buffer pro prenos telemetrie |
// makro pro PWM |
#define GO(motor, direction, power) if(get_timer0()<=power) \ |
{direction##motor;} else {stop##motor;} |
#int_TIMER2 |
void TIMER2_isr() |
{ |
if (speed<255) speed+=INC_SPEED; |
if (rovinka<MAX_ROVINKA) rovinka++; |
if (dira<=T_DIRA) dira++; |
} |
// Primitivni Pipani |
void beep(unsigned int16 period, unsigned int16 length) |
{ |
unsigned int16 nn; |
for(nn=length; nn>0; nn--) |
{ |
output_high(SOUND_HI);output_low(SOUND_LO); |
delay_us(period); |
output_high(SOUND_LO);output_low(SOUND_HI); |
delay_us(period); |
} |
} |
/******************************************************************************/ |
void diagnostika() |
{ |
unsigned int16 n; |
while (input(DIAG_SERVO)) // Propojka, ktera spousti diagnostiku |
{ |
for (n=500; n<800; n+=100) |
{ |
beep(n,n); //beep UP |
}; |
Delay_ms(1000); |
//zastav vse |
STOPL; STOPR; |
//pravy pas |
FR; Delay_ms(1000); STOPR; Delay_ms(1000); |
BR; Delay_ms(1000); STOPR; Delay_ms(1000); |
Beep(880,100); Delay_ms(1000); |
//levy pas |
FL; Delay_ms(1000); STOPL; Delay_ms(1000); |
BL; Delay_ms(1000); STOPL; Delay_ms(1000); |
Beep(880,100); Delay_ms(1000); |
//oba pasy |
FL; FR; Delay_ms(1000); STOPL; STOPR; Delay_ms(1000); |
BL; BR; Delay_ms(1000); STOPL; STOPR; Delay_ms(1000); |
}; |
while (input(DIAG_SENSORS)) |
{ |
if (RSENSOR) beep(900,500); |
if (LSENSOR) beep(800,500); |
if ((read_adc(ADC_READ_ONLY)<BUMPER_TRESHOLD)) beep(1000,500); |
}; |
} |
/////////////////////////////////////////////////////////////////////////////// |
void cikcak() |
{ |
unsigned int16 n; |
sem1: |
n=CIK_CAK; |
while (0==RSENSOR||LSENSOR) // zkontroluj caru |
{ |
if (n==CIK_CAK) // zmen smer zataceni |
{ |
n=0; |
switch(movement) |
{ |
case L: |
FL;BR; |
movement=R; |
break; |
case R: |
FR;BL; |
movement=L; |
break; |
case S: |
FL;BR; |
movement=R; |
n=CIK_CAK/2; |
break; |
} |
} |
n++; |
} |
STOPL;STOPR; |
line = RSENSOR; // cteni senzoru na caru |
line |= LSENSOR << 1; |
if (line==0) goto sem1; |
// nasli jsme caru |
line=S; |
} |
/////////////////////////////////////////////////////////////////////////////// |
void objizdka() // objede cihlu |
{ |
unsigned int16 n; |
BL;BR;Delay_ms(200); |
STOPR;STOPL; |
beep(900,1000); |
// movement=S; |
//cikcak(); |
BL; FR; Delay_ms(215); // otoc se 70° do leva |
FR; FL; Delay_ms(600); // popojed rovne |
BR; Delay_ms(50); // otoc se 90° do prava |
STOPR; FL; Delay_ms(700); |
FR; FL; Delay_ms(100); // popojed rovne na slepo |
for(n=600;n>0;n--) // popojed rovne ale kontroluj caru |
{ |
line = RSENSOR; // cteni senzoru na caru |
line |= LSENSOR << 1; |
if (line!=0) {Delay_ms(50); break;} // kdyz narazis na caru, za chvili zastav |
Delay_ms(1); |
} |
BL; // otoc se 60° do leva |
for(n=600;n>0;n--) |
{ |
line = RSENSOR; // cteni senzoru na caru |
line |= LSENSOR << 1; |
if (line!=0) break; |
Delay_ms(1); |
} |
STOPR; STOPL; |
movement=R; |
cikcak(); |
dira=0; |
} |
/////////////////////////////////////////////////////////////////////////////// |
void prejeddiru() // vyresi diru |
{ |
unsigned int16 n; |
unsigned int8 speed_dira; |
STOPL;STOPR; |
speed_dira=speed; |
beep(1000,500); |
switch (movement) //vrat se zpet na caru |
{ |
case L: |
for (n=COUVANI;n>0;n--) {GO(R,B,speed_dira); Delay_ms(1);} |
STOPL;STOPR; |
break; |
case R: |
for (n=COUVANI;n>0;n--) {GO(L,B,speed_dira); Delay_ms(1);} |
STOPL;STOPR; |
break; |
case S: |
goto sem; |
break; |
} |
beep(800,500); |
line=0; |
FR; BL; Delay_ms(300); // otoc se na caru |
while(line==0) |
{ |
line = RSENSOR; // cteni senzoru na caru |
line |= LSENSOR << 1; |
} |
FL;BR; Delay_ms(60); |
STOPL; STOPR; |
FL; BR; Delay_ms(500); |
STOPL; STOPR; |
Delay_ms(1000); |
FR;FL; //popojed rovne |
for(n=PRES_DIRU;n>0;n--) |
{ |
line = RSENSOR; // cteni senzoru na caru |
line |= LSENSOR << 1; |
if (line!=0) break; |
Delay_ms(1); |
} |
sem: |
STOPL; STOPR; |
movement=S; |
cikcak(); // najdi caru |
dira=0; |
} |
/////////////////////////////////////////////////////////////////////////////// |
void main() |
{ |
unsigned int16 n; // pro FOR |
STOPL; STOPR; // prepne vystupy na ovladani motoru na output a zastavi |
setup_oscillator(OSC_4MHZ|OSC_INTRC); // 4 MHz interni RC oscilator |
port_b_pullups(TRUE); // pullups pro piano na diagnostiku |
setup_spi(FALSE); |
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); // Casovac pro PWM |
setup_timer_2(T2_DIV_BY_4,255,10); // Casovac pro regulaci |
// preruseni kazdych 10ms |
setup_adc_ports(sAN2|VSS_VDD); // nastaveni A/D prevodniku pro naraznik |
setup_adc(ADC_CLOCK_INTERNAL); |
set_adc_channel(2); |
setup_timer_1(T1_INTERNAL|T1_DIV_BY_1); // Casovac pro naraznik |
setup_ccp1(CCP_COMPARE_RESET_TIMER); |
CCP_1=(2^10)-1; // prevod kazdou 1ms |
setup_comparator(A0_VR_A1_VR); // inicializace komparatoru pro cidla cary |
setup_vref(VREF_HIGH|TRESHOLD); // 32 kroku od 0.25 do 0.75 Vdd |
Beep(1000,200); //double beep |
Delay_ms(50); |
Beep(1000,200); |
Delay_ms(1000); // 1s |
// povoleni rizeni rychlosti zataceni pres preruseni |
enable_interrupts(INT_TIMER2); |
enable_interrupts(GLOBAL); |
/*---------------------------------------------------------------------------*/ |
sensors=S; |
line=S; |
last=S; |
movement=S; |
speed=FW_POMALU; |
diagnostika(); |
// cikcak(); // toc se, abys nasel caru |
Delay_ms(500); |
Beep(1000,200); |
Delay_ms(500); |
while(true) // hlavni smycka (jizda podle cary) |
{ |
sensors = RSENSOR; // cteni senzoru na caru |
sensors |= LSENSOR << 1; |
if ((read_adc(ADC_READ_ONLY)<BUMPER_TRESHOLD) && (dira<=T_CIHLA)) objizdka(); |
switch (sensors) // zatacej podle toho, kde vidis caru |
{ |
case S: // rovne |
FL; FR; // pokud se jede dlouho rovne, tak pridej |
dira=0; |
movement=S; |
continue; |
case L: // trochu vlevo |
GO(L, F, FW_POMALU+rovinka); GO(R, F, FW_STREDNE+rovinka); |
line=L; |
dira=0; |
movement=L; |
continue; |
case R: // trochu vpravo |
GO(R, F, FW_POMALU+rovinka); GO(L, F, FW_STREDNE+rovinka); |
line=R; |
dira=0; |
movement=R; |
continue; |
default: // kdyz jsou obe cidla mimo caru, tak pokracuj dal |
} |
rovinka=0; |
if (dira>=T_DIRA) prejeddiru(); |
if (last!=line) // pokud si prejel caru z jedne strany na druhou stranu, tak zabrzdi |
{ |
last=line; |
speed=FW_ZATACKA; |
} |
if (L==line) // kdyz jsou obe cidla mimo caru, zatoc na caru |
{ |
STOPL; |
GO(R, F, speed); |
movement=L; |
} |
else |
{ |
STOPR; |
GO(L, F, speed); |
movement=R; |
} |
} // while(true) |
} |
/Designs/ROBOTS/Merkur/SW/turn_L/tank.HEX |
---|
0,0 → 1,217 |
:1000000000308A00E82C0000FF00030E8301A100ED |
:100010007F08A0000A08A8008A01A00E0408A20018 |
:100020007708A3007808A4007908A5007A08A6003C |
:100030007B08A700831383128C308400801C222845 |
:100040008C183528220884002308F7002408F800BB |
:100050002508F9002608FA002708FB0028088A006E |
:10006000210E8300FF0E7F0E09008A113728420FF0 |
:100070003A283C280130C20743080E3C0318C30A43 |
:100080004608573C0318C60A8C108A1122281230E1 |
:100090008316A202031C5A28A2308400FC3080057B |
:1000A0000310800C800C000803195A2858280000FF |
:1000B000800B5728831200347D088316A1007C082A |
:1000C000A000A008031D6728A108031986280513AE |
:1000D00083120517831685138312851374088316FC |
:1000E000A200831247208316851383128517831677 |
:1000F00005138312051374088316A2008312472088 |
:10010000831620080319A103A00361288312003479 |
:1001100075308400000803199C280130F800F701AD |
:10012000F70B9028F80B8F284A30F700F70B96282A |
:1001300000000000800B8D28003483168615831282 |
:10014000861DC8290130F200F430F1007208033C2A |
:10015000031CBE28031DB02871081F3C031CBE28C9 |
:100160007208F5007108F4007208FD007108FC00C7 |
:100170005C206430F1070318F20AA6280430F3006B |
:10018000FA30F5008820F30BC0288316061383127B |
:1001900006138316861383128613831606128312A0 |
:1001A0000612831686128312861283168612831213 |
:1001B000861283160612831206160430F300FA30F4 |
:1001C000F5008820F30BDF2883160612831206122F |
:1001D00083168612831286120430F300FA30F5007B |
:1001E0008820F30BEE28831606128312061283165C |
:1001F0008612831286160430F300FA30F500882048 |
:10020000F30BFD288316061283120612831686123C |
:10021000831286120430F300FA30F5008820F30BC5 |
:100220000C290330F5007030F400FD016430FC004F |
:100230005C200430F300FA30F5008820F30B1B2912 |
:1002400083168613831286138316061383120617EA |
:100250000430F300FA30F5008820F30B2A298316C6 |
:100260000613831206138316861383128613043033 |
:10027000F300FA30F5008820F30B392983160613B2 |
:100280008312061383168613831286170430F30035 |
:10029000FA30F5008820F30B4829831606138312E1 |
:1002A000061383168613831286130430F300FA3084 |
:1002B000F5008820F30B57290330F5007030F40067 |
:1002C000FD016430FC005C200430F300FA30F500DE |
:1002D0008820F30B662983168613831286138316F0 |
:1002E000061383120617831686128312861283164C |
:1002F0000612831206160430F300FA30F500882047 |
:10030000F30B7D29831606138312061383168613B7 |
:100310008312861383160612831206128316861220 |
:10032000831286120430F300FA30F5008820F30BB4 |
:1003300094298316061383120613831686138312D9 |
:1003400086178316061283120612831686128312EC |
:1003500086160430F300FA30F5008820F30BAB2941 |
:1003600083160613831206138316861383128613CD |
:1003700083160612831206128316861283128612C1 |
:100380000430F300FA30F5008820F30BC2299D28D1 |
:10039000831606158312061DFB2983169C1FDB2975 |
:1003A0000330F5008430F4000130FD00F430FC002F |
:1003B00083125C2083161C1FE8290330F5002030CF |
:1003C000F4000130FD00F430FC0083125C20831641 |
:1003D00083121F1DED298316E8291E087F3C031C8C |
:1003E000FA290330F500E830F4000130FD00F43064 |
:1003F000FC005C20C8298A11962D7530F50030303C |
:10040000F400003083169C1B0130003A03190A2ABD |
:100410001C1F642A7408303C031D5E2A7508753C55 |
:10042000031D5E2AF501F40183124508023A0319FF |
:10043000202A033A0319332A023A0319462A5D2A6D |
:1004400083168613831286138316061383120617E8 |
:1004500083160612831206128316861283128616DC |
:100460000130C5005D2A8316861283128612831618 |
:1004700006128312061683160613831206138316BA |
:100480008613831286170230C5005D2A83168613F1 |
:100490008312861383160613831206178316061219 |
:1004A0008312061283168612831286160130C50047 |
:1004B0003A30F5009830F4005D2A8316F40A0319E7 |
:1004C000F50A8312012A8316061383120613831674 |
:1004D000861383128613831606128312061283165E |
:1004E000861283128612C10183169C1F7A2A8312F8 |
:1004F000C10A831600301C1B0130F7000310F70DF2 |
:1005000077088312C104C1080319FD290330C10013 |
:100510000034831606138312061383168613831280 |
:10052000861783160612831206128316861283120A |
:100530008616C830F500882083160612831206122C |
:1005400083168612831286128316061383120613ED |
:1005500083168613831286130330F5008430F4006B |
:100560000330FD00E830FC005C2083160613831284 |
:100570000613831686138312861783168612831238 |
:1005800086128316061283120616D730F5008820CD |
:10059000831686128312861283160612831206169B |
:1005A0008316861383128613831606138312061787 |
:1005B0000330F300C830F5008820F30BDA2A8316E5 |
:1005C00006128312061283168612831286163230A2 |
:1005D000F5008820831606128312061283168612EF |
:1005E00083128612831686138312861383160613CC |
:1005F000831206170330F300C830F5008820F30B90 |
:10060000FC2A831686128312861283160612831220 |
:100610000616831686138312861383160613831217 |
:1006200006176430F50088200230F2005830F100DF |
:10063000F108031D1E2BF20803193D2BC10183167F |
:100640009C1F252B8312C10A831600301C1B01300E |
:10065000F7000310F70D77088312C104C1080319CE |
:10066000352B3230F50088203D2B0130F5008820F5 |
:1006700071080319F203F103182B83160613831272 |
:10068000061383168613831286170230F200583041 |
:10069000F100F108031D4F2BF20803196A2BC10169 |
:1006A00083169C1F562B8312C10A831600301C1B15 |
:1006B0000130F7000310F70D77088312C104C10859 |
:1006C000031D6A2B0130F500882071080319F2031D |
:1006D000F103492B83160612831206128316861223 |
:1006E000831286128316061383120613831686134B |
:1006F000831286130130C500FD21C6018A11C62D63 |
:100700008316061383120613831686138312861329 |
:10071000831606128312061283168612831286121D |
:100720004208F3000330F500E830F4000130FD002A |
:10073000F430FC005C204508023A0319A62B033A6A |
:100740000319DE2B023A0319162C182C0230F20082 |
:100750005830F100F108031DB02BF2080319CD2B1E |
:1007600001087302031CBD2B8316061283120612A6 |
:100770008316861283128616C52B831606128312E1 |
:10078000061283168612831286120130F500882025 |
:1007900071080319F203F103AA2B831606138312BF |
:1007A000061383168613831286138316061283128A |
:1007B00006128316861283128612182C0230F2005B |
:1007C0005830F100F108031DE82BF2080319052C3D |
:1007D00001087302031CF52B8316061383120613FC |
:1007E0008316861383128617FD2B83160613831236 |
:1007F000061383168613831286130130F5008820B2 |
:1008000071080319F203F103E22B83160613831216 |
:100810000613831686138312861383160612831219 |
:1008200006128316861283128612182CD22C182CCC |
:100830000330F5002030F4000130FD00F430FC00FE |
:100840005C20C1018316861283128612831606125B |
:100850008312061683160613831206138316861355 |
:10086000831286170230F4009630F5008820F40BCE |
:10087000342CC108031D4D2CC10183169C1F432C31 |
:100880008312C10A831600301C1B0130F7000310CD |
:10089000F70D77088312C104392C8316861383124F |
:1008A0008613831606138312061783160612831205 |
:1008B000061283168612831286163C30F5008820B5 |
:1008C0008316061383120613831686138312861368 |
:1008D000831606128312061283168612831286125C |
:1008E0008316861383128613831606138312061744 |
:1008F0008316061283120612831686128312861638 |
:100900000230F400FA30F5008820F40B822C8316B4 |
:100910000613831206138316861383128613831617 |
:100920000612831206128316861283128612043070 |
:10093000F400FA30F5008820F40B992C8316861207 |
:1009400083128612831606128312061683168613E6 |
:10095000831286138316061383120617F201FA30E8 |
:10096000F100F108031DB72CF2080319D22CC101C4 |
:1009700083169C1FBE2C8312C10A831600301C1BD9 |
:100980000130F7000310F70D77088312C104C10886 |
:10099000031DD22C0130F500882071080319F203E1 |
:1009A000F103B12C831606138312061383168613E4 |
:1009B000831286138316061283120612831686127A |
:1009C000831286120330C500FD21C6018A115C2EF8 |
:1009D00084011F30830583161F129F121B08803964 |
:1009E0009B0007309C001C0883120D136030831697 |
:1009F0008F0082308312A9009830AA00AB004030EB |
:100A0000AC00AD00AE006030AF008630B000B43056 |
:100A1000B1006030B200A430B300B400B500613062 |
:100A2000B6000330B700F030B80083160613831207 |
:100A300006138316861383128613831606128312F7 |
:100A400006128316861283128612623083168F0076 |
:100A50008113831294128316061186140612003035 |
:100A600083129400831694000108C7390838810066 |
:100A70004830F800053883129200FF308316920048 |
:100A80001F129F121B08803904389B001F1383120A |
:100A90001F179F1783169F1383121F141030F8001F |
:100AA0001F08C73978049F0085309000831686158B |
:100AB0000B308312970096010730950002308316A1 |
:100AC0009C000508033885000330F700F70B662DFE |
:100AD0001C0883120D138A3083169D000330F50025 |
:100AE000E830F400FD01C830FC0083125C20323095 |
:100AF000F50088200330F500E830F400FD01C8302F |
:100B0000FC005C200430F100FA30F5008820F10B85 |
:100B1000842D83168C14C03083128B040330C000E4 |
:100B2000C100C400C500E630C2009D280230F100BB |
:100B3000FA30F5008820F10B982D0330F500E830ED |
:100B4000F400FD01C830FC005C200230F100FA30F6 |
:100B5000F5008820F10BA72DC00183169C1FB32D33 |
:100B60008312C00A831600301C1B0130F7000310EB |
:100B7000F70D77088312C0041F19BC2D1E087F3C97 |
:100B8000031CC62D4608323C0318892A4008033A44 |
:100B90000319D12D013A0319E52D033A03191E2E2D |
:100BA000572E831686138312861383160613831219 |
:100BB0000617831686128312861283160612831274 |
:100BC0000616C6010330C500AC2D0108F100E63061 |
:100BD000430771020319EE2D0318F72D83168613B0 |
:100BE000831286138316061383120617FF2D8316AE |
:100BF00006138312061383168613831286130108C5 |
:100C0000F100F030430771020319082E0318112E6A |
:100C10008316861283128612831606128312061614 |
:100C2000192E831606128312061283168612831259 |
:100C300086120230C100C601C500AC2D0108F100CA |
:100C4000E630430771020319272E0318302E83164E |
:100C50008612831286128316061283120616382E07 |
:100C600083160612831206128316861283128612C8 |
:100C70000108F100F030430771020319412E0318F7 |
:100C80004A2E831686138312861383160613831245 |
:100C90000617522E83160613831206138316861325 |
:100CA000831286130130C100C601C500AC2DC301FB |
:100CB0004608563C031C802B410844020319642E4D |
:100CC0004108C400C830C2004108023C031D882E00 |
:100CD0008316061383120613831686138312861354 |
:100CE00001084202031C7D2E83168612831286128F |
:100CF0008316061283120616852E83160612831299 |
:100D0000061283168612831286120230C500A72EA1 |
:100D10008316061283120612831686128312861217 |
:100D200001084202031C9D2E83168613831286132C |
:100D30008316061383120617A52E83160613831235 |
:100D4000061383168613831286130130C500AC2D5B |
:020D500063003E |
:04400E00383FFC3FFC |
:00000001FF |
;PIC16F88 |
/Designs/ROBOTS/Merkur/SW/turn_L/tank.LST |
---|
0,0 → 1,2051 |
CCS PCM C Compiler, Version 3.221, 27853 26-IV-05 21:32 |
Filename: D:\KAKLIK\programy\PIC_C\roboti\merkur\PIC16F88\turn_L\tank.LST |
ROM used: 1705 words (42%) |
Largest free fragment is 2048 |
RAM used: 87 (50%) at main() level |
98 (56%) worst case |
Stack: 4 worst case (3 in main + 1 for interrupts) |
* |
0000: MOVLW 00 |
0001: MOVWF 0A |
0002: GOTO 4E8 |
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 037 |
.................... #include "tank.h" |
.................... #include <16F88.h> |
.................... //////// Standard Header file for the PIC16F88 device //////////////// |
.................... #device PIC16F88 |
.................... #list |
.................... |
.................... #device adc=8 |
.................... #fuses NOWDT,INTRC_IO, NOPUT, MCLR, NOBROWNOUT, NOLVP, NOCPD, NOWRT, NODEBUG, NOPROTECT, NOFCMEN, NOIESO |
.................... #use delay(clock=4000000) |
* |
0047: MOVLW 12 |
0048: BSF 03.5 |
0049: SUBWF 22,F |
004A: BTFSS 03.0 |
004B: GOTO 05A |
004C: MOVLW A2 |
004D: MOVWF 04 |
004E: MOVLW FC |
004F: ANDWF 00,F |
0050: BCF 03.0 |
0051: RRF 00,F |
0052: RRF 00,F |
0053: MOVF 00,W |
0054: BTFSC 03.2 |
0055: GOTO 05A |
0056: GOTO 058 |
0057: NOP |
0058: DECFSZ 00,F |
0059: GOTO 057 |
005A: BCF 03.5 |
005B: RETLW 00 |
* |
0088: MOVLW 75 |
0089: MOVWF 04 |
008A: MOVF 00,W |
008B: BTFSC 03.2 |
008C: GOTO 09C |
008D: MOVLW 01 |
008E: MOVWF 78 |
008F: CLRF 77 |
0090: DECFSZ 77,F |
0091: GOTO 090 |
0092: DECFSZ 78,F |
0093: GOTO 08F |
0094: MOVLW 4A |
0095: MOVWF 77 |
0096: DECFSZ 77,F |
0097: GOTO 096 |
0098: NOP |
0099: NOP |
009A: DECFSZ 00,F |
009B: GOTO 08D |
009C: RETLW 00 |
.................... |
.................... |
.................... |
.................... #define DEBUG |
.................... |
.................... #define TXo PIN_A3 // To the transmitter modulator |
.................... #include "AX25.c" // podprogram pro prenos telemetrie |
.................... #list |
.................... |
.................... |
.................... unsigned int8 sensors; // pomocna promenna pro cteni cidel na caru |
.................... unsigned int8 line; // na ktere strane byla detekovana cara |
.................... unsigned int8 speed; // rychlost zataceni |
.................... unsigned int8 rovinka; // pocitadlo pro zjisteni rovneho useku |
.................... unsigned int8 last; // kde byla cara, kdyz byly minule cidla mimo |
.................... unsigned int8 movement; // obsahuje aktualni smer zataceni |
.................... unsigned int8 dira; // pocita dobu po kterou je ztracena cara |
.................... |
.................... // Konstanty pro dynamiku pohybu |
.................... #define T_DIRA 87 // po jakem case zataceni se detekuje dira |
.................... #define INC_SPEED 1 // prirustek rychlosti v jednom kroku |
.................... #define FW_POMALU 230 // trochu mimo caru vnitrni pas |
.................... #define FW_ZATACKA 200 // rychlost vnejsiho kola pri zataceni |
.................... #define FW_STREDNE 240 // trochu mimo caru vnejsi pas |
.................... #define COUVANI 600 // couvnuti zpet na caru, po detekci diry |
.................... #define PRES_DIRU 250 |
.................... #define MAX_ROVINKA (255-FW_STREDNE) |
.................... #define TRESHOLD 10 // rozhodovaci uroven komparatoru, 0xF = 0.75*Vdd |
.................... #define BUMPER_TRESHOLD 128 |
.................... #define CIK_CAK 30000 |
.................... #define T_CIHLA 50 // perioda detekce cihly |
.................... |
.................... //motory //Napred vypnout potom zapnout! |
.................... #define FR output_low(PIN_B5); output_high(PIN_B4) // Vpred |
.................... #define FL output_low(PIN_B7); output_high(PIN_B6) |
.................... #define BR output_low(PIN_B4); output_high(PIN_B5) // Vzad |
.................... #define BL output_low(PIN_B6); output_high(PIN_B7) |
.................... #define STOPR output_low(PIN_B4);output_low(PIN_B5) // Zastav |
.................... #define STOPL output_low(PIN_B6);output_low(PIN_B7) |
.................... |
.................... #define L 0b10 // left |
.................... #define R 0b01 // right |
.................... #define S 0b11 // straight |
.................... |
.................... //cidla |
.................... #define RSENSOR C2OUT // Senzory na caru |
.................... #define LSENSOR C1OUT |
.................... #define BUMPER PIN_A4 // Senzor na cihlu |
.................... |
.................... #define DIAG_SERVO PIN_B3 // Propojka pro diagnosticky mod |
.................... #define DIAG_SENSORS PIN_B2 // Propojka pro diagnosticky mod |
.................... |
.................... #DEFINE SOUND_HI PIN_A6 // komplementarni vystupy pro piezo pipak |
.................... #DEFINE SOUND_LO PIN_A7 |
.................... |
.................... char AXstring[40]; // Buffer pro prenos telemetrie |
.................... |
.................... // makro pro PWM |
.................... #define GO(motor, direction, power) if(get_timer0()<=power) \ |
.................... {direction##motor;} else {stop##motor;} |
.................... |
.................... #int_TIMER2 |
.................... void TIMER2_isr() |
.................... { |
.................... if (speed<255) speed+=INC_SPEED; |
* |
0037: INCFSZ 42,W |
0038: GOTO 03A |
0039: GOTO 03C |
003A: MOVLW 01 |
003B: ADDWF 42,F |
.................... if (rovinka<MAX_ROVINKA) rovinka++; |
003C: MOVF 43,W |
003D: SUBLW 0E |
003E: BTFSC 03.0 |
003F: INCF 43,F |
.................... if (dira<=T_DIRA) dira++; |
0040: MOVF 46,W |
0041: SUBLW 57 |
0042: BTFSC 03.0 |
0043: INCF 46,F |
.................... } |
.................... // Primitivni Pipani |
0044: BCF 0C.1 |
0045: BCF 0A.3 |
0046: GOTO 022 |
.................... void beep(unsigned int16 period, unsigned int16 length) |
.................... { |
.................... unsigned int16 nn; |
.................... |
.................... for(nn=length; nn>0; nn--) |
* |
005C: MOVF 7D,W |
005D: BSF 03.5 |
005E: MOVWF 21 |
005F: MOVF 7C,W |
0060: MOVWF 20 |
0061: MOVF 20,F |
0062: BTFSS 03.2 |
0063: GOTO 067 |
0064: MOVF 21,F |
0065: BTFSC 03.2 |
0066: GOTO 086 |
.................... { |
.................... output_high(SOUND_HI);output_low(SOUND_LO); |
0067: BCF 05.6 |
0068: BCF 03.5 |
0069: BSF 05.6 |
006A: BSF 03.5 |
006B: BCF 05.7 |
006C: BCF 03.5 |
006D: BCF 05.7 |
.................... delay_us(period); |
006E: MOVF 74,W |
006F: BSF 03.5 |
0070: MOVWF 22 |
0071: BCF 03.5 |
0072: CALL 047 |
.................... output_high(SOUND_LO);output_low(SOUND_HI); |
0073: BSF 03.5 |
0074: BCF 05.7 |
0075: BCF 03.5 |
0076: BSF 05.7 |
0077: BSF 03.5 |
0078: BCF 05.6 |
0079: BCF 03.5 |
007A: BCF 05.6 |
.................... delay_us(period); |
007B: MOVF 74,W |
007C: BSF 03.5 |
007D: MOVWF 22 |
007E: BCF 03.5 |
007F: CALL 047 |
.................... } |
0080: BSF 03.5 |
0081: MOVF 20,W |
0082: BTFSC 03.2 |
0083: DECF 21,F |
0084: DECF 20,F |
0085: GOTO 061 |
.................... } |
0086: BCF 03.5 |
0087: RETLW 00 |
.................... /******************************************************************************/ |
.................... void diagnostika() |
.................... { |
.................... unsigned int16 n; |
.................... |
.................... while (input(DIAG_SERVO)) // Propojka, ktera spousti diagnostiku |
.................... { |
* |
009D: BSF 03.5 |
009E: BSF 06.3 |
009F: BCF 03.5 |
00A0: BTFSS 06.3 |
00A1: GOTO 1C8 |
.................... for (n=500; n<800; n+=100) |
00A2: MOVLW 01 |
00A3: MOVWF 72 |
00A4: MOVLW F4 |
00A5: MOVWF 71 |
00A6: MOVF 72,W |
00A7: SUBLW 03 |
00A8: BTFSS 03.0 |
00A9: GOTO 0BE |
00AA: BTFSS 03.2 |
00AB: GOTO 0B0 |
00AC: MOVF 71,W |
00AD: SUBLW 1F |
00AE: BTFSS 03.0 |
00AF: GOTO 0BE |
.................... { |
.................... beep(n,n); //beep UP |
00B0: MOVF 72,W |
00B1: MOVWF 75 |
00B2: MOVF 71,W |
00B3: MOVWF 74 |
00B4: MOVF 72,W |
00B5: MOVWF 7D |
00B6: MOVF 71,W |
00B7: MOVWF 7C |
00B8: CALL 05C |
.................... }; |
00B9: MOVLW 64 |
00BA: ADDWF 71,F |
00BB: BTFSC 03.0 |
00BC: INCF 72,F |
00BD: GOTO 0A6 |
.................... Delay_ms(1000); |
00BE: MOVLW 04 |
00BF: MOVWF 73 |
00C0: MOVLW FA |
00C1: MOVWF 75 |
00C2: CALL 088 |
00C3: DECFSZ 73,F |
00C4: GOTO 0C0 |
.................... //zastav vse |
.................... STOPL; STOPR; |
00C5: BSF 03.5 |
00C6: BCF 06.6 |
00C7: BCF 03.5 |
00C8: BCF 06.6 |
00C9: BSF 03.5 |
00CA: BCF 06.7 |
00CB: BCF 03.5 |
00CC: BCF 06.7 |
00CD: BSF 03.5 |
00CE: BCF 06.4 |
00CF: BCF 03.5 |
00D0: BCF 06.4 |
00D1: BSF 03.5 |
00D2: BCF 06.5 |
00D3: BCF 03.5 |
00D4: BCF 06.5 |
.................... //pravy pas |
.................... FR; Delay_ms(1000); STOPR; Delay_ms(1000); |
00D5: BSF 03.5 |
00D6: BCF 06.5 |
00D7: BCF 03.5 |
00D8: BCF 06.5 |
00D9: BSF 03.5 |
00DA: BCF 06.4 |
00DB: BCF 03.5 |
00DC: BSF 06.4 |
00DD: MOVLW 04 |
00DE: MOVWF 73 |
00DF: MOVLW FA |
00E0: MOVWF 75 |
00E1: CALL 088 |
00E2: DECFSZ 73,F |
00E3: GOTO 0DF |
00E4: BSF 03.5 |
00E5: BCF 06.4 |
00E6: BCF 03.5 |
00E7: BCF 06.4 |
00E8: BSF 03.5 |
00E9: BCF 06.5 |
00EA: BCF 03.5 |
00EB: BCF 06.5 |
00EC: MOVLW 04 |
00ED: MOVWF 73 |
00EE: MOVLW FA |
00EF: MOVWF 75 |
00F0: CALL 088 |
00F1: DECFSZ 73,F |
00F2: GOTO 0EE |
.................... BR; Delay_ms(1000); STOPR; Delay_ms(1000); |
00F3: BSF 03.5 |
00F4: BCF 06.4 |
00F5: BCF 03.5 |
00F6: BCF 06.4 |
00F7: BSF 03.5 |
00F8: BCF 06.5 |
00F9: BCF 03.5 |
00FA: BSF 06.5 |
00FB: MOVLW 04 |
00FC: MOVWF 73 |
00FD: MOVLW FA |
00FE: MOVWF 75 |
00FF: CALL 088 |
0100: DECFSZ 73,F |
0101: GOTO 0FD |
0102: BSF 03.5 |
0103: BCF 06.4 |
0104: BCF 03.5 |
0105: BCF 06.4 |
0106: BSF 03.5 |
0107: BCF 06.5 |
0108: BCF 03.5 |
0109: BCF 06.5 |
010A: MOVLW 04 |
010B: MOVWF 73 |
010C: MOVLW FA |
010D: MOVWF 75 |
010E: CALL 088 |
010F: DECFSZ 73,F |
0110: GOTO 10C |
.................... Beep(880,100); Delay_ms(1000); |
0111: MOVLW 03 |
0112: MOVWF 75 |
0113: MOVLW 70 |
0114: MOVWF 74 |
0115: CLRF 7D |
0116: MOVLW 64 |
0117: MOVWF 7C |
0118: CALL 05C |
0119: MOVLW 04 |
011A: MOVWF 73 |
011B: MOVLW FA |
011C: MOVWF 75 |
011D: CALL 088 |
011E: DECFSZ 73,F |
011F: GOTO 11B |
.................... //levy pas |
.................... FL; Delay_ms(1000); STOPL; Delay_ms(1000); |
0120: BSF 03.5 |
0121: BCF 06.7 |
0122: BCF 03.5 |
0123: BCF 06.7 |
0124: BSF 03.5 |
0125: BCF 06.6 |
0126: BCF 03.5 |
0127: BSF 06.6 |
0128: MOVLW 04 |
0129: MOVWF 73 |
012A: MOVLW FA |
012B: MOVWF 75 |
012C: CALL 088 |
012D: DECFSZ 73,F |
012E: GOTO 12A |
012F: BSF 03.5 |
0130: BCF 06.6 |
0131: BCF 03.5 |
0132: BCF 06.6 |
0133: BSF 03.5 |
0134: BCF 06.7 |
0135: BCF 03.5 |
0136: BCF 06.7 |
0137: MOVLW 04 |
0138: MOVWF 73 |
0139: MOVLW FA |
013A: MOVWF 75 |
013B: CALL 088 |
013C: DECFSZ 73,F |
013D: GOTO 139 |
.................... BL; Delay_ms(1000); STOPL; Delay_ms(1000); |
013E: BSF 03.5 |
013F: BCF 06.6 |
0140: BCF 03.5 |
0141: BCF 06.6 |
0142: BSF 03.5 |
0143: BCF 06.7 |
0144: BCF 03.5 |
0145: BSF 06.7 |
0146: MOVLW 04 |
0147: MOVWF 73 |
0148: MOVLW FA |
0149: MOVWF 75 |
014A: CALL 088 |
014B: DECFSZ 73,F |
014C: GOTO 148 |
014D: BSF 03.5 |
014E: BCF 06.6 |
014F: BCF 03.5 |
0150: BCF 06.6 |
0151: BSF 03.5 |
0152: BCF 06.7 |
0153: BCF 03.5 |
0154: BCF 06.7 |
0155: MOVLW 04 |
0156: MOVWF 73 |
0157: MOVLW FA |
0158: MOVWF 75 |
0159: CALL 088 |
015A: DECFSZ 73,F |
015B: GOTO 157 |
.................... Beep(880,100); Delay_ms(1000); |
015C: MOVLW 03 |
015D: MOVWF 75 |
015E: MOVLW 70 |
015F: MOVWF 74 |
0160: CLRF 7D |
0161: MOVLW 64 |
0162: MOVWF 7C |
0163: CALL 05C |
0164: MOVLW 04 |
0165: MOVWF 73 |
0166: MOVLW FA |
0167: MOVWF 75 |
0168: CALL 088 |
0169: DECFSZ 73,F |
016A: GOTO 166 |
.................... //oba pasy |
.................... FL; FR; Delay_ms(1000); STOPL; STOPR; Delay_ms(1000); |
016B: BSF 03.5 |
016C: BCF 06.7 |
016D: BCF 03.5 |
016E: BCF 06.7 |
016F: BSF 03.5 |
0170: BCF 06.6 |
0171: BCF 03.5 |
0172: BSF 06.6 |
0173: BSF 03.5 |
0174: BCF 06.5 |
0175: BCF 03.5 |
0176: BCF 06.5 |
0177: BSF 03.5 |
0178: BCF 06.4 |
0179: BCF 03.5 |
017A: BSF 06.4 |
017B: MOVLW 04 |
017C: MOVWF 73 |
017D: MOVLW FA |
017E: MOVWF 75 |
017F: CALL 088 |
0180: DECFSZ 73,F |
0181: GOTO 17D |
0182: BSF 03.5 |
0183: BCF 06.6 |
0184: BCF 03.5 |
0185: BCF 06.6 |
0186: BSF 03.5 |
0187: BCF 06.7 |
0188: BCF 03.5 |
0189: BCF 06.7 |
018A: BSF 03.5 |
018B: BCF 06.4 |
018C: BCF 03.5 |
018D: BCF 06.4 |
018E: BSF 03.5 |
018F: BCF 06.5 |
0190: BCF 03.5 |
0191: BCF 06.5 |
0192: MOVLW 04 |
0193: MOVWF 73 |
0194: MOVLW FA |
0195: MOVWF 75 |
0196: CALL 088 |
0197: DECFSZ 73,F |
0198: GOTO 194 |
.................... BL; BR; Delay_ms(1000); STOPL; STOPR; Delay_ms(1000); |
0199: BSF 03.5 |
019A: BCF 06.6 |
019B: BCF 03.5 |
019C: BCF 06.6 |
019D: BSF 03.5 |
019E: BCF 06.7 |
019F: BCF 03.5 |
01A0: BSF 06.7 |
01A1: BSF 03.5 |
01A2: BCF 06.4 |
01A3: BCF 03.5 |
01A4: BCF 06.4 |
01A5: BSF 03.5 |
01A6: BCF 06.5 |
01A7: BCF 03.5 |
01A8: BSF 06.5 |
01A9: MOVLW 04 |
01AA: MOVWF 73 |
01AB: MOVLW FA |
01AC: MOVWF 75 |
01AD: CALL 088 |
01AE: DECFSZ 73,F |
01AF: GOTO 1AB |
01B0: BSF 03.5 |
01B1: BCF 06.6 |
01B2: BCF 03.5 |
01B3: BCF 06.6 |
01B4: BSF 03.5 |
01B5: BCF 06.7 |
01B6: BCF 03.5 |
01B7: BCF 06.7 |
01B8: BSF 03.5 |
01B9: BCF 06.4 |
01BA: BCF 03.5 |
01BB: BCF 06.4 |
01BC: BSF 03.5 |
01BD: BCF 06.5 |
01BE: BCF 03.5 |
01BF: BCF 06.5 |
01C0: MOVLW 04 |
01C1: MOVWF 73 |
01C2: MOVLW FA |
01C3: MOVWF 75 |
01C4: CALL 088 |
01C5: DECFSZ 73,F |
01C6: GOTO 1C2 |
.................... }; |
01C7: GOTO 09D |
.................... while (input(DIAG_SENSORS)) |
.................... { |
01C8: BSF 03.5 |
01C9: BSF 06.2 |
01CA: BCF 03.5 |
01CB: BTFSS 06.2 |
01CC: GOTO 1FB |
.................... if (RSENSOR) beep(900,500); |
01CD: BSF 03.5 |
01CE: BTFSS 1C.7 |
01CF: GOTO 1DB |
01D0: MOVLW 03 |
01D1: MOVWF 75 |
01D2: MOVLW 84 |
01D3: MOVWF 74 |
01D4: MOVLW 01 |
01D5: MOVWF 7D |
01D6: MOVLW F4 |
01D7: MOVWF 7C |
01D8: BCF 03.5 |
01D9: CALL 05C |
01DA: BSF 03.5 |
.................... if (LSENSOR) beep(800,500); |
01DB: BTFSS 1C.6 |
01DC: GOTO 1E8 |
01DD: MOVLW 03 |
01DE: MOVWF 75 |
01DF: MOVLW 20 |
01E0: MOVWF 74 |
01E1: MOVLW 01 |
01E2: MOVWF 7D |
01E3: MOVLW F4 |
01E4: MOVWF 7C |
01E5: BCF 03.5 |
01E6: CALL 05C |
01E7: BSF 03.5 |
.................... if ((read_adc(ADC_READ_ONLY)<BUMPER_TRESHOLD)) beep(1000,500); |
01E8: BCF 03.5 |
01E9: BTFSS 1F.2 |
01EA: GOTO 1ED |
01EB: BSF 03.5 |
01EC: GOTO 1E8 |
01ED: MOVF 1E,W |
01EE: SUBLW 7F |
01EF: BTFSS 03.0 |
01F0: GOTO 1FA |
01F1: MOVLW 03 |
01F2: MOVWF 75 |
01F3: MOVLW E8 |
01F4: MOVWF 74 |
01F5: MOVLW 01 |
01F6: MOVWF 7D |
01F7: MOVLW F4 |
01F8: MOVWF 7C |
01F9: CALL 05C |
.................... }; |
01FA: GOTO 1C8 |
.................... } |
01FB: BCF 0A.3 |
01FC: GOTO 596 (RETURN) |
.................... /////////////////////////////////////////////////////////////////////////////// |
.................... void cikcak() |
.................... { |
.................... unsigned int16 n; |
.................... sem1: |
.................... n=CIK_CAK; |
01FD: MOVLW 75 |
01FE: MOVWF 75 |
01FF: MOVLW 30 |
0200: MOVWF 74 |
.................... while (0==RSENSOR||LSENSOR) // zkontroluj caru |
.................... { |
0201: MOVLW 00 |
0202: BSF 03.5 |
0203: BTFSC 1C.7 |
0204: MOVLW 01 |
0205: XORLW 00 |
0206: BTFSC 03.2 |
0207: GOTO 20A |
0208: BTFSS 1C.6 |
0209: GOTO 264 |
.................... if (n==CIK_CAK) // zmen smer zataceni |
020A: MOVF 74,W |
020B: SUBLW 30 |
020C: BTFSS 03.2 |
020D: GOTO 25E |
020E: MOVF 75,W |
020F: SUBLW 75 |
0210: BTFSS 03.2 |
0211: GOTO 25E |
.................... { |
.................... n=0; |
0212: CLRF 75 |
0213: CLRF 74 |
.................... switch(movement) |
.................... { |
0214: BCF 03.5 |
0215: MOVF 45,W |
0216: XORLW 02 |
0217: BTFSC 03.2 |
0218: GOTO 220 |
0219: XORLW 03 |
021A: BTFSC 03.2 |
021B: GOTO 233 |
021C: XORLW 02 |
021D: BTFSC 03.2 |
021E: GOTO 246 |
021F: GOTO 25D |
.................... case L: |
.................... FL;BR; |
0220: BSF 03.5 |
0221: BCF 06.7 |
0222: BCF 03.5 |
0223: BCF 06.7 |
0224: BSF 03.5 |
0225: BCF 06.6 |
0226: BCF 03.5 |
0227: BSF 06.6 |
0228: BSF 03.5 |
0229: BCF 06.4 |
022A: BCF 03.5 |
022B: BCF 06.4 |
022C: BSF 03.5 |
022D: BCF 06.5 |
022E: BCF 03.5 |
022F: BSF 06.5 |
.................... movement=R; |
0230: MOVLW 01 |
0231: MOVWF 45 |
.................... break; |
0232: GOTO 25D |
.................... case R: |
.................... FR;BL; |
0233: BSF 03.5 |
0234: BCF 06.5 |
0235: BCF 03.5 |
0236: BCF 06.5 |
0237: BSF 03.5 |
0238: BCF 06.4 |
0239: BCF 03.5 |
023A: BSF 06.4 |
023B: BSF 03.5 |
023C: BCF 06.6 |
023D: BCF 03.5 |
023E: BCF 06.6 |
023F: BSF 03.5 |
0240: BCF 06.7 |
0241: BCF 03.5 |
0242: BSF 06.7 |
.................... movement=L; |
0243: MOVLW 02 |
0244: MOVWF 45 |
.................... break; |
0245: GOTO 25D |
.................... case S: |
.................... FL;BR; |
0246: BSF 03.5 |
0247: BCF 06.7 |
0248: BCF 03.5 |
0249: BCF 06.7 |
024A: BSF 03.5 |
024B: BCF 06.6 |
024C: BCF 03.5 |
024D: BSF 06.6 |
024E: BSF 03.5 |
024F: BCF 06.4 |
0250: BCF 03.5 |
0251: BCF 06.4 |
0252: BSF 03.5 |
0253: BCF 06.5 |
0254: BCF 03.5 |
0255: BSF 06.5 |
.................... movement=R; |
0256: MOVLW 01 |
0257: MOVWF 45 |
.................... n=CIK_CAK/2; |
0258: MOVLW 3A |
0259: MOVWF 75 |
025A: MOVLW 98 |
025B: MOVWF 74 |
.................... break; |
025C: GOTO 25D |
025D: BSF 03.5 |
.................... } |
.................... } |
.................... n++; |
025E: INCF 74,F |
025F: BTFSC 03.2 |
0260: INCF 75,F |
.................... } |
0261: BCF 03.5 |
0262: GOTO 201 |
0263: BSF 03.5 |
.................... STOPL;STOPR; |
0264: BCF 06.6 |
0265: BCF 03.5 |
0266: BCF 06.6 |
0267: BSF 03.5 |
0268: BCF 06.7 |
0269: BCF 03.5 |
026A: BCF 06.7 |
026B: BSF 03.5 |
026C: BCF 06.4 |
026D: BCF 03.5 |
026E: BCF 06.4 |
026F: BSF 03.5 |
0270: BCF 06.5 |
0271: BCF 03.5 |
0272: BCF 06.5 |
.................... line = RSENSOR; // cteni senzoru na caru |
0273: CLRF 41 |
0274: BSF 03.5 |
0275: BTFSS 1C.7 |
0276: GOTO 27A |
0277: BCF 03.5 |
0278: INCF 41,F |
0279: BSF 03.5 |
.................... line |= LSENSOR << 1; |
027A: MOVLW 00 |
027B: BTFSC 1C.6 |
027C: MOVLW 01 |
027D: MOVWF 77 |
027E: BCF 03.0 |
027F: RLF 77,F |
0280: MOVF 77,W |
0281: BCF 03.5 |
0282: IORWF 41,F |
.................... if (line==0) goto sem1; |
0283: MOVF 41,F |
0284: BTFSC 03.2 |
0285: GOTO 1FD |
.................... // nasli jsme caru |
.................... line=S; |
0286: MOVLW 03 |
0287: MOVWF 41 |
.................... } |
0288: RETLW 00 |
.................... /////////////////////////////////////////////////////////////////////////////// |
.................... void objizdka() // objede cihlu |
.................... { |
.................... unsigned int16 n; |
.................... |
.................... BL;BR;Delay_ms(200); |
0289: BSF 03.5 |
028A: BCF 06.6 |
028B: BCF 03.5 |
028C: BCF 06.6 |
028D: BSF 03.5 |
028E: BCF 06.7 |
028F: BCF 03.5 |
0290: BSF 06.7 |
0291: BSF 03.5 |
0292: BCF 06.4 |
0293: BCF 03.5 |
0294: BCF 06.4 |
0295: BSF 03.5 |
0296: BCF 06.5 |
0297: BCF 03.5 |
0298: BSF 06.5 |
0299: MOVLW C8 |
029A: MOVWF 75 |
029B: CALL 088 |
.................... STOPR;STOPL; |
029C: BSF 03.5 |
029D: BCF 06.4 |
029E: BCF 03.5 |
029F: BCF 06.4 |
02A0: BSF 03.5 |
02A1: BCF 06.5 |
02A2: BCF 03.5 |
02A3: BCF 06.5 |
02A4: BSF 03.5 |
02A5: BCF 06.6 |
02A6: BCF 03.5 |
02A7: BCF 06.6 |
02A8: BSF 03.5 |
02A9: BCF 06.7 |
02AA: BCF 03.5 |
02AB: BCF 06.7 |
.................... beep(900,1000); |
02AC: MOVLW 03 |
02AD: MOVWF 75 |
02AE: MOVLW 84 |
02AF: MOVWF 74 |
02B0: MOVLW 03 |
02B1: MOVWF 7D |
02B2: MOVLW E8 |
02B3: MOVWF 7C |
02B4: CALL 05C |
.................... // movement=S; |
.................... //cikcak(); |
.................... |
.................... BL; FR; Delay_ms(215); // otoc se 70° do leva |
02B5: BSF 03.5 |
02B6: BCF 06.6 |
02B7: BCF 03.5 |
02B8: BCF 06.6 |
02B9: BSF 03.5 |
02BA: BCF 06.7 |
02BB: BCF 03.5 |
02BC: BSF 06.7 |
02BD: BSF 03.5 |
02BE: BCF 06.5 |
02BF: BCF 03.5 |
02C0: BCF 06.5 |
02C1: BSF 03.5 |
02C2: BCF 06.4 |
02C3: BCF 03.5 |
02C4: BSF 06.4 |
02C5: MOVLW D7 |
02C6: MOVWF 75 |
02C7: CALL 088 |
.................... |
.................... FR; FL; Delay_ms(600); // popojed rovne |
02C8: BSF 03.5 |
02C9: BCF 06.5 |
02CA: BCF 03.5 |
02CB: BCF 06.5 |
02CC: BSF 03.5 |
02CD: BCF 06.4 |
02CE: BCF 03.5 |
02CF: BSF 06.4 |
02D0: BSF 03.5 |
02D1: BCF 06.7 |
02D2: BCF 03.5 |
02D3: BCF 06.7 |
02D4: BSF 03.5 |
02D5: BCF 06.6 |
02D6: BCF 03.5 |
02D7: BSF 06.6 |
02D8: MOVLW 03 |
02D9: MOVWF 73 |
02DA: MOVLW C8 |
02DB: MOVWF 75 |
02DC: CALL 088 |
02DD: DECFSZ 73,F |
02DE: GOTO 2DA |
.................... |
.................... BR; Delay_ms(50); // otoc se 90° do prava |
02DF: BSF 03.5 |
02E0: BCF 06.4 |
02E1: BCF 03.5 |
02E2: BCF 06.4 |
02E3: BSF 03.5 |
02E4: BCF 06.5 |
02E5: BCF 03.5 |
02E6: BSF 06.5 |
02E7: MOVLW 32 |
02E8: MOVWF 75 |
02E9: CALL 088 |
.................... STOPR; FL; Delay_ms(600); |
02EA: BSF 03.5 |
02EB: BCF 06.4 |
02EC: BCF 03.5 |
02ED: BCF 06.4 |
02EE: BSF 03.5 |
02EF: BCF 06.5 |
02F0: BCF 03.5 |
02F1: BCF 06.5 |
02F2: BSF 03.5 |
02F3: BCF 06.7 |
02F4: BCF 03.5 |
02F5: BCF 06.7 |
02F6: BSF 03.5 |
02F7: BCF 06.6 |
02F8: BCF 03.5 |
02F9: BSF 06.6 |
02FA: MOVLW 03 |
02FB: MOVWF 73 |
02FC: MOVLW C8 |
02FD: MOVWF 75 |
02FE: CALL 088 |
02FF: DECFSZ 73,F |
0300: GOTO 2FC |
.................... |
.................... FR; FL; Delay_ms(100); // popojed rovne na slepo |
0301: BSF 03.5 |
0302: BCF 06.5 |
0303: BCF 03.5 |
0304: BCF 06.5 |
0305: BSF 03.5 |
0306: BCF 06.4 |
0307: BCF 03.5 |
0308: BSF 06.4 |
0309: BSF 03.5 |
030A: BCF 06.7 |
030B: BCF 03.5 |
030C: BCF 06.7 |
030D: BSF 03.5 |
030E: BCF 06.6 |
030F: BCF 03.5 |
0310: BSF 06.6 |
0311: MOVLW 64 |
0312: MOVWF 75 |
0313: CALL 088 |
.................... for(n=600;n>0;n--) // popojed rovne ale kontroluj caru |
0314: MOVLW 02 |
0315: MOVWF 72 |
0316: MOVLW 58 |
0317: MOVWF 71 |
0318: MOVF 71,F |
0319: BTFSS 03.2 |
031A: GOTO 31E |
031B: MOVF 72,F |
031C: BTFSC 03.2 |
031D: GOTO 33D |
.................... { |
.................... line = RSENSOR; // cteni senzoru na caru |
031E: CLRF 41 |
031F: BSF 03.5 |
0320: BTFSS 1C.7 |
0321: GOTO 325 |
0322: BCF 03.5 |
0323: INCF 41,F |
0324: BSF 03.5 |
.................... line |= LSENSOR << 1; |
0325: MOVLW 00 |
0326: BTFSC 1C.6 |
0327: MOVLW 01 |
0328: MOVWF 77 |
0329: BCF 03.0 |
032A: RLF 77,F |
032B: MOVF 77,W |
032C: BCF 03.5 |
032D: IORWF 41,F |
.................... if (line!=0) {Delay_ms(50); break;} // kdyz narazis na caru, za chvili zastav |
032E: MOVF 41,F |
032F: BTFSC 03.2 |
0330: GOTO 335 |
0331: MOVLW 32 |
0332: MOVWF 75 |
0333: CALL 088 |
0334: GOTO 33D |
.................... Delay_ms(1); |
0335: MOVLW 01 |
0336: MOVWF 75 |
0337: CALL 088 |
.................... } |
0338: MOVF 71,W |
0339: BTFSC 03.2 |
033A: DECF 72,F |
033B: DECF 71,F |
033C: GOTO 318 |
.................... |
.................... BL; // otoc se 60° do leva |
033D: BSF 03.5 |
033E: BCF 06.6 |
033F: BCF 03.5 |
0340: BCF 06.6 |
0341: BSF 03.5 |
0342: BCF 06.7 |
0343: BCF 03.5 |
0344: BSF 06.7 |
.................... for(n=600;n>0;n--) |
0345: MOVLW 02 |
0346: MOVWF 72 |
0347: MOVLW 58 |
0348: MOVWF 71 |
0349: MOVF 71,F |
034A: BTFSS 03.2 |
034B: GOTO 34F |
034C: MOVF 72,F |
034D: BTFSC 03.2 |
034E: GOTO 36A |
.................... { |
.................... line = RSENSOR; // cteni senzoru na caru |
034F: CLRF 41 |
0350: BSF 03.5 |
0351: BTFSS 1C.7 |
0352: GOTO 356 |
0353: BCF 03.5 |
0354: INCF 41,F |
0355: BSF 03.5 |
.................... line |= LSENSOR << 1; |
0356: MOVLW 00 |
0357: BTFSC 1C.6 |
0358: MOVLW 01 |
0359: MOVWF 77 |
035A: BCF 03.0 |
035B: RLF 77,F |
035C: MOVF 77,W |
035D: BCF 03.5 |
035E: IORWF 41,F |
.................... if (line!=0) break; |
035F: MOVF 41,F |
0360: BTFSS 03.2 |
0361: GOTO 36A |
.................... Delay_ms(1); |
0362: MOVLW 01 |
0363: MOVWF 75 |
0364: CALL 088 |
.................... } |
0365: MOVF 71,W |
0366: BTFSC 03.2 |
0367: DECF 72,F |
0368: DECF 71,F |
0369: GOTO 349 |
.................... STOPR; STOPL; |
036A: BSF 03.5 |
036B: BCF 06.4 |
036C: BCF 03.5 |
036D: BCF 06.4 |
036E: BSF 03.5 |
036F: BCF 06.5 |
0370: BCF 03.5 |
0371: BCF 06.5 |
0372: BSF 03.5 |
0373: BCF 06.6 |
0374: BCF 03.5 |
0375: BCF 06.6 |
0376: BSF 03.5 |
0377: BCF 06.7 |
0378: BCF 03.5 |
0379: BCF 06.7 |
.................... |
.................... movement=R; |
037A: MOVLW 01 |
037B: MOVWF 45 |
.................... cikcak(); |
037C: CALL 1FD |
.................... dira=0; |
037D: CLRF 46 |
.................... } |
037E: BCF 0A.3 |
037F: GOTO 5C6 (RETURN) |
.................... /////////////////////////////////////////////////////////////////////////////// |
.................... void prejeddiru() // vyresi diru |
.................... { |
.................... unsigned int16 n; |
.................... unsigned int8 speed_dira; |
.................... |
.................... STOPL;STOPR; |
0380: BSF 03.5 |
0381: BCF 06.6 |
0382: BCF 03.5 |
0383: BCF 06.6 |
0384: BSF 03.5 |
0385: BCF 06.7 |
0386: BCF 03.5 |
0387: BCF 06.7 |
0388: BSF 03.5 |
0389: BCF 06.4 |
038A: BCF 03.5 |
038B: BCF 06.4 |
038C: BSF 03.5 |
038D: BCF 06.5 |
038E: BCF 03.5 |
038F: BCF 06.5 |
.................... speed_dira=speed; |
0390: MOVF 42,W |
0391: MOVWF 73 |
.................... beep(1000,500); |
0392: MOVLW 03 |
0393: MOVWF 75 |
0394: MOVLW E8 |
0395: MOVWF 74 |
0396: MOVLW 01 |
0397: MOVWF 7D |
0398: MOVLW F4 |
0399: MOVWF 7C |
039A: CALL 05C |
.................... switch (movement) //vrat se zpet na caru |
.................... { |
039B: MOVF 45,W |
039C: XORLW 02 |
039D: BTFSC 03.2 |
039E: GOTO 3A6 |
039F: XORLW 03 |
03A0: BTFSC 03.2 |
03A1: GOTO 3DE |
03A2: XORLW 02 |
03A3: BTFSC 03.2 |
03A4: GOTO 416 |
03A5: GOTO 418 |
.................... case L: |
.................... for (n=COUVANI;n>0;n--) {GO(R,B,speed_dira); Delay_ms(1);} |
03A6: MOVLW 02 |
03A7: MOVWF 72 |
03A8: MOVLW 58 |
03A9: MOVWF 71 |
03AA: MOVF 71,F |
03AB: BTFSS 03.2 |
03AC: GOTO 3B0 |
03AD: MOVF 72,F |
03AE: BTFSC 03.2 |
03AF: GOTO 3CD |
03B0: MOVF 01,W |
03B1: SUBWF 73,W |
03B2: BTFSS 03.0 |
03B3: GOTO 3BD |
03B4: BSF 03.5 |
03B5: BCF 06.4 |
03B6: BCF 03.5 |
03B7: BCF 06.4 |
03B8: BSF 03.5 |
03B9: BCF 06.5 |
03BA: BCF 03.5 |
03BB: BSF 06.5 |
03BC: GOTO 3C5 |
03BD: BSF 03.5 |
03BE: BCF 06.4 |
03BF: BCF 03.5 |
03C0: BCF 06.4 |
03C1: BSF 03.5 |
03C2: BCF 06.5 |
03C3: BCF 03.5 |
03C4: BCF 06.5 |
03C5: MOVLW 01 |
03C6: MOVWF 75 |
03C7: CALL 088 |
03C8: MOVF 71,W |
03C9: BTFSC 03.2 |
03CA: DECF 72,F |
03CB: DECF 71,F |
03CC: GOTO 3AA |
.................... STOPL;STOPR; |
03CD: BSF 03.5 |
03CE: BCF 06.6 |
03CF: BCF 03.5 |
03D0: BCF 06.6 |
03D1: BSF 03.5 |
03D2: BCF 06.7 |
03D3: BCF 03.5 |
03D4: BCF 06.7 |
03D5: BSF 03.5 |
03D6: BCF 06.4 |
03D7: BCF 03.5 |
03D8: BCF 06.4 |
03D9: BSF 03.5 |
03DA: BCF 06.5 |
03DB: BCF 03.5 |
03DC: BCF 06.5 |
.................... break; |
03DD: GOTO 418 |
.................... case R: |
.................... for (n=COUVANI;n>0;n--) {GO(L,B,speed_dira); Delay_ms(1);} |
03DE: MOVLW 02 |
03DF: MOVWF 72 |
03E0: MOVLW 58 |
03E1: MOVWF 71 |
03E2: MOVF 71,F |
03E3: BTFSS 03.2 |
03E4: GOTO 3E8 |
03E5: MOVF 72,F |
03E6: BTFSC 03.2 |
03E7: GOTO 405 |
03E8: MOVF 01,W |
03E9: SUBWF 73,W |
03EA: BTFSS 03.0 |
03EB: GOTO 3F5 |
03EC: BSF 03.5 |
03ED: BCF 06.6 |
03EE: BCF 03.5 |
03EF: BCF 06.6 |
03F0: BSF 03.5 |
03F1: BCF 06.7 |
03F2: BCF 03.5 |
03F3: BSF 06.7 |
03F4: GOTO 3FD |
03F5: BSF 03.5 |
03F6: BCF 06.6 |
03F7: BCF 03.5 |
03F8: BCF 06.6 |
03F9: BSF 03.5 |
03FA: BCF 06.7 |
03FB: BCF 03.5 |
03FC: BCF 06.7 |
03FD: MOVLW 01 |
03FE: MOVWF 75 |
03FF: CALL 088 |
0400: MOVF 71,W |
0401: BTFSC 03.2 |
0402: DECF 72,F |
0403: DECF 71,F |
0404: GOTO 3E2 |
.................... STOPL;STOPR; |
0405: BSF 03.5 |
0406: BCF 06.6 |
0407: BCF 03.5 |
0408: BCF 06.6 |
0409: BSF 03.5 |
040A: BCF 06.7 |
040B: BCF 03.5 |
040C: BCF 06.7 |
040D: BSF 03.5 |
040E: BCF 06.4 |
040F: BCF 03.5 |
0410: BCF 06.4 |
0411: BSF 03.5 |
0412: BCF 06.5 |
0413: BCF 03.5 |
0414: BCF 06.5 |
.................... break; |
0415: GOTO 418 |
.................... case S: |
.................... goto sem; |
0416: GOTO 4D2 |
.................... break; |
0417: GOTO 418 |
.................... } |
.................... beep(800,500); |
0418: MOVLW 03 |
0419: MOVWF 75 |
041A: MOVLW 20 |
041B: MOVWF 74 |
041C: MOVLW 01 |
041D: MOVWF 7D |
041E: MOVLW F4 |
041F: MOVWF 7C |
0420: CALL 05C |
.................... |
.................... line=0; |
0421: CLRF 41 |
.................... FR; BL; Delay_ms(300); // otoc se na caru |
0422: BSF 03.5 |
0423: BCF 06.5 |
0424: BCF 03.5 |
0425: BCF 06.5 |
0426: BSF 03.5 |
0427: BCF 06.4 |
0428: BCF 03.5 |
0429: BSF 06.4 |
042A: BSF 03.5 |
042B: BCF 06.6 |
042C: BCF 03.5 |
042D: BCF 06.6 |
042E: BSF 03.5 |
042F: BCF 06.7 |
0430: BCF 03.5 |
0431: BSF 06.7 |
0432: MOVLW 02 |
0433: MOVWF 74 |
0434: MOVLW 96 |
0435: MOVWF 75 |
0436: CALL 088 |
0437: DECFSZ 74,F |
0438: GOTO 434 |
.................... while(line==0) |
.................... { |
0439: MOVF 41,F |
043A: BTFSS 03.2 |
043B: GOTO 44D |
.................... line = RSENSOR; // cteni senzoru na caru |
043C: CLRF 41 |
043D: BSF 03.5 |
043E: BTFSS 1C.7 |
043F: GOTO 443 |
0440: BCF 03.5 |
0441: INCF 41,F |
0442: BSF 03.5 |
.................... line |= LSENSOR << 1; |
0443: MOVLW 00 |
0444: BTFSC 1C.6 |
0445: MOVLW 01 |
0446: MOVWF 77 |
0447: BCF 03.0 |
0448: RLF 77,F |
0449: MOVF 77,W |
044A: BCF 03.5 |
044B: IORWF 41,F |
.................... } |
044C: GOTO 439 |
.................... FL;BR; Delay_ms(60); |
044D: BSF 03.5 |
044E: BCF 06.7 |
044F: BCF 03.5 |
0450: BCF 06.7 |
0451: BSF 03.5 |
0452: BCF 06.6 |
0453: BCF 03.5 |
0454: BSF 06.6 |
0455: BSF 03.5 |
0456: BCF 06.4 |
0457: BCF 03.5 |
0458: BCF 06.4 |
0459: BSF 03.5 |
045A: BCF 06.5 |
045B: BCF 03.5 |
045C: BSF 06.5 |
045D: MOVLW 3C |
045E: MOVWF 75 |
045F: CALL 088 |
.................... STOPL; STOPR; |
0460: BSF 03.5 |
0461: BCF 06.6 |
0462: BCF 03.5 |
0463: BCF 06.6 |
0464: BSF 03.5 |
0465: BCF 06.7 |
0466: BCF 03.5 |
0467: BCF 06.7 |
0468: BSF 03.5 |
0469: BCF 06.4 |
046A: BCF 03.5 |
046B: BCF 06.4 |
046C: BSF 03.5 |
046D: BCF 06.5 |
046E: BCF 03.5 |
046F: BCF 06.5 |
.................... |
.................... FL; BR; Delay_ms(500); |
0470: BSF 03.5 |
0471: BCF 06.7 |
0472: BCF 03.5 |
0473: BCF 06.7 |
0474: BSF 03.5 |
0475: BCF 06.6 |
0476: BCF 03.5 |
0477: BSF 06.6 |
0478: BSF 03.5 |
0479: BCF 06.4 |
047A: BCF 03.5 |
047B: BCF 06.4 |
047C: BSF 03.5 |
047D: BCF 06.5 |
047E: BCF 03.5 |
047F: BSF 06.5 |
0480: MOVLW 02 |
0481: MOVWF 74 |
0482: MOVLW FA |
0483: MOVWF 75 |
0484: CALL 088 |
0485: DECFSZ 74,F |
0486: GOTO 482 |
.................... STOPL; STOPR; |
0487: BSF 03.5 |
0488: BCF 06.6 |
0489: BCF 03.5 |
048A: BCF 06.6 |
048B: BSF 03.5 |
048C: BCF 06.7 |
048D: BCF 03.5 |
048E: BCF 06.7 |
048F: BSF 03.5 |
0490: BCF 06.4 |
0491: BCF 03.5 |
0492: BCF 06.4 |
0493: BSF 03.5 |
0494: BCF 06.5 |
0495: BCF 03.5 |
0496: BCF 06.5 |
.................... |
.................... Delay_ms(1000); |
0497: MOVLW 04 |
0498: MOVWF 74 |
0499: MOVLW FA |
049A: MOVWF 75 |
049B: CALL 088 |
049C: DECFSZ 74,F |
049D: GOTO 499 |
.................... |
.................... FR;FL; //popojed rovne |
049E: BSF 03.5 |
049F: BCF 06.5 |
04A0: BCF 03.5 |
04A1: BCF 06.5 |
04A2: BSF 03.5 |
04A3: BCF 06.4 |
04A4: BCF 03.5 |
04A5: BSF 06.4 |
04A6: BSF 03.5 |
04A7: BCF 06.7 |
04A8: BCF 03.5 |
04A9: BCF 06.7 |
04AA: BSF 03.5 |
04AB: BCF 06.6 |
04AC: BCF 03.5 |
04AD: BSF 06.6 |
.................... for(n=PRES_DIRU;n>0;n--) |
04AE: CLRF 72 |
04AF: MOVLW FA |
04B0: MOVWF 71 |
04B1: MOVF 71,F |
04B2: BTFSS 03.2 |
04B3: GOTO 4B7 |
04B4: MOVF 72,F |
04B5: BTFSC 03.2 |
04B6: GOTO 4D2 |
.................... { |
.................... line = RSENSOR; // cteni senzoru na caru |
04B7: CLRF 41 |
04B8: BSF 03.5 |
04B9: BTFSS 1C.7 |
04BA: GOTO 4BE |
04BB: BCF 03.5 |
04BC: INCF 41,F |
04BD: BSF 03.5 |
.................... line |= LSENSOR << 1; |
04BE: MOVLW 00 |
04BF: BTFSC 1C.6 |
04C0: MOVLW 01 |
04C1: MOVWF 77 |
04C2: BCF 03.0 |
04C3: RLF 77,F |
04C4: MOVF 77,W |
04C5: BCF 03.5 |
04C6: IORWF 41,F |
.................... if (line!=0) break; |
04C7: MOVF 41,F |
04C8: BTFSS 03.2 |
04C9: GOTO 4D2 |
.................... Delay_ms(1); |
04CA: MOVLW 01 |
04CB: MOVWF 75 |
04CC: CALL 088 |
.................... } |
04CD: MOVF 71,W |
04CE: BTFSC 03.2 |
04CF: DECF 72,F |
04D0: DECF 71,F |
04D1: GOTO 4B1 |
.................... sem: |
.................... STOPL; STOPR; |
04D2: BSF 03.5 |
04D3: BCF 06.6 |
04D4: BCF 03.5 |
04D5: BCF 06.6 |
04D6: BSF 03.5 |
04D7: BCF 06.7 |
04D8: BCF 03.5 |
04D9: BCF 06.7 |
04DA: BSF 03.5 |
04DB: BCF 06.4 |
04DC: BCF 03.5 |
04DD: BCF 06.4 |
04DE: BSF 03.5 |
04DF: BCF 06.5 |
04E0: BCF 03.5 |
04E1: BCF 06.5 |
.................... movement=S; |
04E2: MOVLW 03 |
04E3: MOVWF 45 |
.................... cikcak(); // najdi caru |
04E4: CALL 1FD |
.................... dira=0; |
04E5: CLRF 46 |
.................... } |
04E6: BCF 0A.3 |
04E7: GOTO 65C (RETURN) |
.................... /////////////////////////////////////////////////////////////////////////////// |
.................... void main() |
.................... { |
04E8: CLRF 04 |
04E9: MOVLW 1F |
04EA: ANDWF 03,F |
04EB: BSF 03.5 |
04EC: BCF 1F.4 |
04ED: BCF 1F.5 |
04EE: MOVF 1B,W |
04EF: ANDLW 80 |
04F0: MOVWF 1B |
04F1: MOVLW 07 |
04F2: MOVWF 1C |
04F3: MOVF 1C,W |
04F4: BCF 03.5 |
04F5: BCF 0D.6 |
04F6: MOVLW 60 |
04F7: BSF 03.5 |
04F8: MOVWF 0F |
.................... unsigned int16 n; // pro FOR |
.................... |
.................... STOPL; STOPR; // prepne vystupy na ovladani motoru na output a zastavi |
* |
0515: BSF 03.5 |
0516: BCF 06.6 |
0517: BCF 03.5 |
0518: BCF 06.6 |
0519: BSF 03.5 |
051A: BCF 06.7 |
051B: BCF 03.5 |
051C: BCF 06.7 |
051D: BSF 03.5 |
051E: BCF 06.4 |
051F: BCF 03.5 |
0520: BCF 06.4 |
0521: BSF 03.5 |
0522: BCF 06.5 |
0523: BCF 03.5 |
0524: BCF 06.5 |
.................... |
.................... setup_oscillator(OSC_4MHZ|OSC_INTRC); // 4 MHz interni RC oscilator |
0525: MOVLW 62 |
0526: BSF 03.5 |
0527: MOVWF 0F |
.................... |
.................... port_b_pullups(TRUE); // pullups pro piano na diagnostiku |
0528: BCF 01.7 |
.................... setup_spi(FALSE); |
0529: BCF 03.5 |
052A: BCF 14.5 |
052B: BSF 03.5 |
052C: BCF 06.2 |
052D: BSF 06.1 |
052E: BCF 06.4 |
052F: MOVLW 00 |
0530: BCF 03.5 |
0531: MOVWF 14 |
0532: BSF 03.5 |
0533: MOVWF 14 |
.................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); // Casovac pro PWM |
0534: MOVF 01,W |
0535: ANDLW C7 |
0536: IORLW 08 |
0537: MOVWF 01 |
.................... |
.................... setup_timer_2(T2_DIV_BY_4,255,10); // Casovac pro regulaci |
0538: MOVLW 48 |
0539: MOVWF 78 |
053A: IORLW 05 |
053B: BCF 03.5 |
053C: MOVWF 12 |
053D: MOVLW FF |
053E: BSF 03.5 |
053F: MOVWF 12 |
.................... // preruseni kazdych 10ms |
.................... setup_adc_ports(sAN2|VSS_VDD); // nastaveni A/D prevodniku pro naraznik |
0540: BCF 1F.4 |
0541: BCF 1F.5 |
0542: MOVF 1B,W |
0543: ANDLW 80 |
0544: IORLW 04 |
0545: MOVWF 1B |
.................... setup_adc(ADC_CLOCK_INTERNAL); |
0546: BCF 1F.6 |
0547: BCF 03.5 |
0548: BSF 1F.6 |
0549: BSF 1F.7 |
054A: BSF 03.5 |
054B: BCF 1F.7 |
054C: BCF 03.5 |
054D: BSF 1F.0 |
.................... set_adc_channel(2); |
054E: MOVLW 10 |
054F: MOVWF 78 |
0550: MOVF 1F,W |
0551: ANDLW C7 |
0552: IORWF 78,W |
0553: MOVWF 1F |
.................... setup_timer_1(T1_INTERNAL|T1_DIV_BY_1); // Casovac pro naraznik |
0554: MOVLW 85 |
0555: MOVWF 10 |
.................... setup_ccp1(CCP_COMPARE_RESET_TIMER); |
0556: BSF 03.5 |
0557: BSF 06.3 |
0558: MOVLW 0B |
0559: BCF 03.5 |
055A: MOVWF 17 |
.................... CCP_1=(2^10)-1; // prevod kazdou 1ms |
055B: CLRF 16 |
055C: MOVLW 07 |
055D: MOVWF 15 |
.................... |
.................... setup_comparator(A0_VR_A1_VR); // inicializace komparatoru pro cidla cary |
055E: MOVLW 02 |
055F: BSF 03.5 |
0560: MOVWF 1C |
0561: MOVF 05,W |
0562: IORLW 03 |
0563: MOVWF 05 |
0564: MOVLW 03 |
0565: MOVWF 77 |
0566: DECFSZ 77,F |
0567: GOTO 566 |
0568: MOVF 1C,W |
0569: BCF 03.5 |
056A: BCF 0D.6 |
.................... setup_vref(VREF_HIGH|TRESHOLD); // 32 kroku od 0.25 do 0.75 Vdd |
056B: MOVLW 8A |
056C: BSF 03.5 |
056D: MOVWF 1D |
.................... |
.................... Beep(1000,200); //double beep |
056E: MOVLW 03 |
056F: MOVWF 75 |
0570: MOVLW E8 |
0571: MOVWF 74 |
0572: CLRF 7D |
0573: MOVLW C8 |
0574: MOVWF 7C |
0575: BCF 03.5 |
0576: CALL 05C |
.................... Delay_ms(50); |
0577: MOVLW 32 |
0578: MOVWF 75 |
0579: CALL 088 |
.................... Beep(1000,200); |
057A: MOVLW 03 |
057B: MOVWF 75 |
057C: MOVLW E8 |
057D: MOVWF 74 |
057E: CLRF 7D |
057F: MOVLW C8 |
0580: MOVWF 7C |
0581: CALL 05C |
.................... Delay_ms(1000); // 1s |
0582: MOVLW 04 |
0583: MOVWF 71 |
0584: MOVLW FA |
0585: MOVWF 75 |
0586: CALL 088 |
0587: DECFSZ 71,F |
0588: GOTO 584 |
.................... |
.................... // povoleni rizeni rychlosti zataceni pres preruseni |
.................... enable_interrupts(INT_TIMER2); |
0589: BSF 03.5 |
058A: BSF 0C.1 |
.................... enable_interrupts(GLOBAL); |
058B: MOVLW C0 |
058C: BCF 03.5 |
058D: IORWF 0B,F |
.................... |
.................... /*---------------------------------------------------------------------------*/ |
.................... sensors=S; |
058E: MOVLW 03 |
058F: MOVWF 40 |
.................... line=S; |
0590: MOVWF 41 |
.................... last=S; |
0591: MOVWF 44 |
.................... movement=S; |
0592: MOVWF 45 |
.................... speed=FW_POMALU; |
0593: MOVLW E6 |
0594: MOVWF 42 |
.................... |
.................... diagnostika(); |
0595: GOTO 09D |
.................... // cikcak(); // toc se, abys nasel caru |
.................... Delay_ms(500); |
0596: MOVLW 02 |
0597: MOVWF 71 |
0598: MOVLW FA |
0599: MOVWF 75 |
059A: CALL 088 |
059B: DECFSZ 71,F |
059C: GOTO 598 |
.................... Beep(1000,200); |
059D: MOVLW 03 |
059E: MOVWF 75 |
059F: MOVLW E8 |
05A0: MOVWF 74 |
05A1: CLRF 7D |
05A2: MOVLW C8 |
05A3: MOVWF 7C |
05A4: CALL 05C |
.................... Delay_ms(500); |
05A5: MOVLW 02 |
05A6: MOVWF 71 |
05A7: MOVLW FA |
05A8: MOVWF 75 |
05A9: CALL 088 |
05AA: DECFSZ 71,F |
05AB: GOTO 5A7 |
.................... |
.................... while(true) // hlavni smycka (jizda podle cary) |
.................... { |
.................... sensors = RSENSOR; // cteni senzoru na caru |
05AC: CLRF 40 |
05AD: BSF 03.5 |
05AE: BTFSS 1C.7 |
05AF: GOTO 5B3 |
05B0: BCF 03.5 |
05B1: INCF 40,F |
05B2: BSF 03.5 |
.................... sensors |= LSENSOR << 1; |
05B3: MOVLW 00 |
05B4: BTFSC 1C.6 |
05B5: MOVLW 01 |
05B6: MOVWF 77 |
05B7: BCF 03.0 |
05B8: RLF 77,F |
05B9: MOVF 77,W |
05BA: BCF 03.5 |
05BB: IORWF 40,F |
.................... |
.................... if ((read_adc(ADC_READ_ONLY)<BUMPER_TRESHOLD) && (dira<=T_CIHLA)) objizdka(); |
05BC: BTFSC 1F.2 |
05BD: GOTO 5BC |
05BE: MOVF 1E,W |
05BF: SUBLW 7F |
05C0: BTFSS 03.0 |
05C1: GOTO 5C6 |
05C2: MOVF 46,W |
05C3: SUBLW 32 |
05C4: BTFSC 03.0 |
05C5: GOTO 289 |
.................... |
.................... switch (sensors) // zatacej podle toho, kde vidis caru |
.................... { |
05C6: MOVF 40,W |
05C7: XORLW 03 |
05C8: BTFSC 03.2 |
05C9: GOTO 5D1 |
05CA: XORLW 01 |
05CB: BTFSC 03.2 |
05CC: GOTO 5E5 |
05CD: XORLW 03 |
05CE: BTFSC 03.2 |
05CF: GOTO 61E |
05D0: GOTO 657 |
.................... case S: // rovne |
.................... FL; FR; // pokud se jede dlouho rovne, tak pridej |
05D1: BSF 03.5 |
05D2: BCF 06.7 |
05D3: BCF 03.5 |
05D4: BCF 06.7 |
05D5: BSF 03.5 |
05D6: BCF 06.6 |
05D7: BCF 03.5 |
05D8: BSF 06.6 |
05D9: BSF 03.5 |
05DA: BCF 06.5 |
05DB: BCF 03.5 |
05DC: BCF 06.5 |
05DD: BSF 03.5 |
05DE: BCF 06.4 |
05DF: BCF 03.5 |
05E0: BSF 06.4 |
.................... dira=0; |
05E1: CLRF 46 |
.................... movement=S; |
05E2: MOVLW 03 |
05E3: MOVWF 45 |
.................... continue; |
05E4: GOTO 5AC |
.................... case L: // trochu vlevo |
.................... GO(L, F, FW_POMALU+rovinka); GO(R, F, FW_STREDNE+rovinka); |
05E5: MOVF 01,W |
05E6: MOVWF 71 |
05E7: MOVLW E6 |
05E8: ADDWF 43,W |
05E9: SUBWF 71,W |
05EA: BTFSC 03.2 |
05EB: GOTO 5EE |
05EC: BTFSC 03.0 |
05ED: GOTO 5F7 |
05EE: BSF 03.5 |
05EF: BCF 06.7 |
05F0: BCF 03.5 |
05F1: BCF 06.7 |
05F2: BSF 03.5 |
05F3: BCF 06.6 |
05F4: BCF 03.5 |
05F5: BSF 06.6 |
05F6: GOTO 5FF |
05F7: BSF 03.5 |
05F8: BCF 06.6 |
05F9: BCF 03.5 |
05FA: BCF 06.6 |
05FB: BSF 03.5 |
05FC: BCF 06.7 |
05FD: BCF 03.5 |
05FE: BCF 06.7 |
05FF: MOVF 01,W |
0600: MOVWF 71 |
0601: MOVLW F0 |
0602: ADDWF 43,W |
0603: SUBWF 71,W |
0604: BTFSC 03.2 |
0605: GOTO 608 |
0606: BTFSC 03.0 |
0607: GOTO 611 |
0608: BSF 03.5 |
0609: BCF 06.5 |
060A: BCF 03.5 |
060B: BCF 06.5 |
060C: BSF 03.5 |
060D: BCF 06.4 |
060E: BCF 03.5 |
060F: BSF 06.4 |
0610: GOTO 619 |
0611: BSF 03.5 |
0612: BCF 06.4 |
0613: BCF 03.5 |
0614: BCF 06.4 |
0615: BSF 03.5 |
0616: BCF 06.5 |
0617: BCF 03.5 |
0618: BCF 06.5 |
.................... line=L; |
0619: MOVLW 02 |
061A: MOVWF 41 |
.................... dira=0; |
061B: CLRF 46 |
.................... movement=L; |
061C: MOVWF 45 |
.................... continue; |
061D: GOTO 5AC |
.................... case R: // trochu vpravo |
.................... GO(R, F, FW_POMALU+rovinka); GO(L, F, FW_STREDNE+rovinka); |
061E: MOVF 01,W |
061F: MOVWF 71 |
0620: MOVLW E6 |
0621: ADDWF 43,W |
0622: SUBWF 71,W |
0623: BTFSC 03.2 |
0624: GOTO 627 |
0625: BTFSC 03.0 |
0626: GOTO 630 |
0627: BSF 03.5 |
0628: BCF 06.5 |
0629: BCF 03.5 |
062A: BCF 06.5 |
062B: BSF 03.5 |
062C: BCF 06.4 |
062D: BCF 03.5 |
062E: BSF 06.4 |
062F: GOTO 638 |
0630: BSF 03.5 |
0631: BCF 06.4 |
0632: BCF 03.5 |
0633: BCF 06.4 |
0634: BSF 03.5 |
0635: BCF 06.5 |
0636: BCF 03.5 |
0637: BCF 06.5 |
0638: MOVF 01,W |
0639: MOVWF 71 |
063A: MOVLW F0 |
063B: ADDWF 43,W |
063C: SUBWF 71,W |
063D: BTFSC 03.2 |
063E: GOTO 641 |
063F: BTFSC 03.0 |
0640: GOTO 64A |
0641: BSF 03.5 |
0642: BCF 06.7 |
0643: BCF 03.5 |
0644: BCF 06.7 |
0645: BSF 03.5 |
0646: BCF 06.6 |
0647: BCF 03.5 |
0648: BSF 06.6 |
0649: GOTO 652 |
064A: BSF 03.5 |
064B: BCF 06.6 |
064C: BCF 03.5 |
064D: BCF 06.6 |
064E: BSF 03.5 |
064F: BCF 06.7 |
0650: BCF 03.5 |
0651: BCF 06.7 |
.................... line=R; |
0652: MOVLW 01 |
0653: MOVWF 41 |
.................... dira=0; |
0654: CLRF 46 |
.................... movement=R; |
0655: MOVWF 45 |
.................... continue; |
0656: GOTO 5AC |
.................... default: // kdyz jsou obe cidla mimo caru, tak pokracuj dal |
.................... } |
.................... rovinka=0; |
0657: CLRF 43 |
.................... if (dira>=T_DIRA) prejeddiru(); |
0658: MOVF 46,W |
0659: SUBLW 56 |
065A: BTFSS 03.0 |
065B: GOTO 380 |
.................... if (last!=line) // pokud si prejel caru z jedne strany na druhou stranu, tak zabrzdi |
065C: MOVF 41,W |
065D: SUBWF 44,W |
065E: BTFSC 03.2 |
065F: GOTO 664 |
.................... { |
.................... last=line; |
0660: MOVF 41,W |
0661: MOVWF 44 |
.................... speed=FW_ZATACKA; |
0662: MOVLW C8 |
0663: MOVWF 42 |
.................... } |
.................... if (L==line) // kdyz jsou obe cidla mimo caru, zatoc na caru |
0664: MOVF 41,W |
0665: SUBLW 02 |
0666: BTFSS 03.2 |
0667: GOTO 688 |
.................... { |
.................... STOPL; |
0668: BSF 03.5 |
0669: BCF 06.6 |
066A: BCF 03.5 |
066B: BCF 06.6 |
066C: BSF 03.5 |
066D: BCF 06.7 |
066E: BCF 03.5 |
066F: BCF 06.7 |
.................... GO(R, F, speed); |
0670: MOVF 01,W |
0671: SUBWF 42,W |
0672: BTFSS 03.0 |
0673: GOTO 67D |
0674: BSF 03.5 |
0675: BCF 06.5 |
0676: BCF 03.5 |
0677: BCF 06.5 |
0678: BSF 03.5 |
0679: BCF 06.4 |
067A: BCF 03.5 |
067B: BSF 06.4 |
067C: GOTO 685 |
067D: BSF 03.5 |
067E: BCF 06.4 |
067F: BCF 03.5 |
0680: BCF 06.4 |
0681: BSF 03.5 |
0682: BCF 06.5 |
0683: BCF 03.5 |
0684: BCF 06.5 |
.................... movement=L; |
0685: MOVLW 02 |
0686: MOVWF 45 |
.................... } |
.................... else |
0687: GOTO 6A7 |
.................... { |
.................... STOPR; |
0688: BSF 03.5 |
0689: BCF 06.4 |
068A: BCF 03.5 |
068B: BCF 06.4 |
068C: BSF 03.5 |
068D: BCF 06.5 |
068E: BCF 03.5 |
068F: BCF 06.5 |
.................... GO(L, F, speed); |
0690: MOVF 01,W |
0691: SUBWF 42,W |
0692: BTFSS 03.0 |
0693: GOTO 69D |
0694: BSF 03.5 |
0695: BCF 06.7 |
0696: BCF 03.5 |
0697: BCF 06.7 |
0698: BSF 03.5 |
0699: BCF 06.6 |
069A: BCF 03.5 |
069B: BSF 06.6 |
069C: GOTO 6A5 |
069D: BSF 03.5 |
069E: BCF 06.6 |
069F: BCF 03.5 |
06A0: BCF 06.6 |
06A1: BSF 03.5 |
06A2: BCF 06.7 |
06A3: BCF 03.5 |
06A4: BCF 06.7 |
.................... movement=R; |
06A5: MOVLW 01 |
06A6: MOVWF 45 |
.................... } |
.................... } // while(true) |
06A7: GOTO 5AC |
.................... } |
.................... |
.................... |
06A8: SLEEP |
Configuration Fuses: |
Word 1: 3F38 NOWDT NOPUT MCLR NOBROWNOUT NOLVP NOCPD NOWRT NODEBUG CCPB0 NOPROTECT INTRC_IO |
Word 2: 3FFC NOFCMEN NOIESO |
/Designs/ROBOTS/Merkur/SW/turn_L/tank.PJT |
---|
0,0 → 1,40 |
[PROJECT] |
Target=tank.HEX |
Development_Mode= |
Processor=0x688F |
ToolSuite=CCS |
[Directories] |
Include=C:\Program Files\PICC\devices\;C:\Program Files\PICC\drivers\;C:\library\CCS; |
Library= |
LinkerScript= |
[Target Data] |
FileList=tank.c; |
BuildTool=C-COMPILER |
OptionString=+FM |
AdditionalOptionString= |
BuildRequired=1 |
[tank.c] |
Type=4 |
Path= |
FileList= |
BuildTool= |
OptionString= |
AdditionalOptionString= |
[mru-list] |
1=tank.c |
[Windows] |
0=0000 tank.c 0 0 796 451 3 0 |
[Opened Files] |
1=D:\KAKLIK\programy\PIC_C\roboti\merkur\PIC16F88\turn_L\tank.c |
2=C:\Program Files\PICC\devices\16F88.h |
3= |
4=C:\Program Files\PICC\devices\16F88.h |
5= |
6= |
7= |
/Designs/ROBOTS/Merkur/SW/turn_L/tank.SYM |
---|
0,0 → 1,88 |
003 STATUS |
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-038 SendData |
039.0 bit |
03A fcslo |
03B fcshi |
03C stuff |
03D flag_flag |
03E fcs_flag |
03F i |
040 sensors |
041 line |
042 speed |
043 rovinka |
044 last |
045 movement |
046 dira |
047-06E AXstring |
06F-070 main.n |
071-072 objizdka.n |
071-072 diagnostika.n |
071-072 prejeddiru.n |
071 main.@SCRATCH |
073 prejeddiru.speed_dira |
073 diagnostika.@SCRATCH |
073 objizdka.@SCRATCH |
074-075 beep.period |
074-075 cikcak.n |
074 prejeddiru.@SCRATCH |
075 @delay_ms1.P1 |
076 cikcak.@SCRATCH |
077 @SCRATCH |
078 @SCRATCH |
078 _RETURN_ |
079 @SCRATCH |
07A @SCRATCH |
07B @SCRATCH |
07C-07D beep.length |
09C.6 C1OUT |
09C.7 C2OUT |
0A0-0A1 beep.nn |
0A2 @delay_us1.P1 |
0088 @delay_ms1 |
0047 @delay_us1 |
0037 TIMER2_isr |
005C beep |
009D diagnostika |
01FD cikcak |
0289 objizdka |
0380 prejeddiru |
04E8 main |
04E8 @cinit |
01FD sem1 |
04D2 sem |
Project Files: |
D:\KAKLIK\programy\PIC_C\roboti\merkur\PIC16F88\turn_L\tank.c |
D:\KAKLIK\programy\PIC_C\roboti\merkur\PIC16F88\turn_L\tank.h |
C:\Program Files\PICC\devices\16F88.h |
D:\KAKLIK\programy\PIC_C\roboti\merkur\PIC16F88\turn_L\AX25.c |
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\merkur\PIC16F88\turn_L\tank.err |
INHX8: D:\KAKLIK\programy\PIC_C\roboti\merkur\PIC16F88\turn_L\tank.HEX |
Symbols: D:\KAKLIK\programy\PIC_C\roboti\merkur\PIC16F88\turn_L\tank.SYM |
List: D:\KAKLIK\programy\PIC_C\roboti\merkur\PIC16F88\turn_L\tank.LST |
Debug/COFF: D:\KAKLIK\programy\PIC_C\roboti\merkur\PIC16F88\turn_L\tank.cof |
Call Tree: D:\KAKLIK\programy\PIC_C\roboti\merkur\PIC16F88\turn_L\tank.tre |
Statistics: D:\KAKLIK\programy\PIC_C\roboti\merkur\PIC16F88\turn_L\tank.sta |
/Designs/ROBOTS/Merkur/SW/turn_L/tank.c |
---|
0,0 → 1,340 |
#include "tank.h" |
#define DEBUG |
#define TXo PIN_A3 // To the transmitter modulator |
#include "AX25.c" // podprogram pro prenos telemetrie |
unsigned int8 sensors; // pomocna promenna pro cteni cidel na caru |
unsigned int8 line; // na ktere strane byla detekovana cara |
unsigned int8 speed; // rychlost zataceni |
unsigned int8 rovinka; // pocitadlo pro zjisteni rovneho useku |
unsigned int8 last; // kde byla cara, kdyz byly minule cidla mimo |
unsigned int8 movement; // obsahuje aktualni smer zataceni |
unsigned int8 dira; // pocita dobu po kterou je ztracena cara |
// Konstanty pro dynamiku pohybu |
#define T_DIRA 87 // po jakem case zataceni se detekuje dira |
#define INC_SPEED 1 // prirustek rychlosti v jednom kroku |
#define FW_POMALU 230 // trochu mimo caru vnitrni pas |
#define FW_ZATACKA 200 // rychlost vnejsiho kola pri zataceni |
#define FW_STREDNE 240 // trochu mimo caru vnejsi pas |
#define COUVANI 600 // couvnuti zpet na caru, po detekci diry |
#define PRES_DIRU 250 |
#define MAX_ROVINKA (255-FW_STREDNE) |
#define TRESHOLD 10 // rozhodovaci uroven komparatoru, 0xF = 0.75*Vdd |
#define BUMPER_TRESHOLD 128 |
#define CIK_CAK 30000 |
#define T_CIHLA 50 // perioda detekce cihly |
//motory //Napred vypnout potom zapnout! |
#define FR output_low(PIN_B5); output_high(PIN_B4) // Vpred |
#define FL output_low(PIN_B7); output_high(PIN_B6) |
#define BR output_low(PIN_B4); output_high(PIN_B5) // Vzad |
#define BL output_low(PIN_B6); output_high(PIN_B7) |
#define STOPR output_low(PIN_B4);output_low(PIN_B5) // Zastav |
#define STOPL output_low(PIN_B6);output_low(PIN_B7) |
#define L 0b10 // left |
#define R 0b01 // right |
#define S 0b11 // straight |
//cidla |
#define RSENSOR C2OUT // Senzory na caru |
#define LSENSOR C1OUT |
#define BUMPER PIN_A4 // Senzor na cihlu |
#define DIAG_SERVO PIN_B3 // Propojka pro diagnosticky mod |
#define DIAG_SENSORS PIN_B2 // Propojka pro diagnosticky mod |
#DEFINE SOUND_HI PIN_A6 // komplementarni vystupy pro piezo pipak |
#DEFINE SOUND_LO PIN_A7 |
char AXstring[40]; // Buffer pro prenos telemetrie |
// makro pro PWM |
#define GO(motor, direction, power) if(get_timer0()<=power) \ |
{direction##motor;} else {stop##motor;} |
#int_TIMER2 |
void TIMER2_isr() |
{ |
if (speed<255) speed+=INC_SPEED; |
if (rovinka<MAX_ROVINKA) rovinka++; |
if (dira<=T_DIRA) dira++; |
} |
// Primitivni Pipani |
void beep(unsigned int16 period, unsigned int16 length) |
{ |
unsigned int16 nn; |
for(nn=length; nn>0; nn--) |
{ |
output_high(SOUND_HI);output_low(SOUND_LO); |
delay_us(period); |
output_high(SOUND_LO);output_low(SOUND_HI); |
delay_us(period); |
} |
} |
/******************************************************************************/ |
void diagnostika() |
{ |
unsigned int16 n; |
while (input(DIAG_SERVO)) // Propojka, ktera spousti diagnostiku |
{ |
for (n=500; n<800; n+=100) |
{ |
beep(n,n); //beep UP |
}; |
Delay_ms(1000); |
//zastav vse |
STOPL; STOPR; |
//pravy pas |
FR; Delay_ms(1000); STOPR; Delay_ms(1000); |
BR; Delay_ms(1000); STOPR; Delay_ms(1000); |
Beep(880,100); Delay_ms(1000); |
//levy pas |
FL; Delay_ms(1000); STOPL; Delay_ms(1000); |
BL; Delay_ms(1000); STOPL; Delay_ms(1000); |
Beep(880,100); Delay_ms(1000); |
//oba pasy |
FL; FR; Delay_ms(1000); STOPL; STOPR; Delay_ms(1000); |
BL; BR; Delay_ms(1000); STOPL; STOPR; Delay_ms(1000); |
}; |
while (input(DIAG_SENSORS)) |
{ |
if (RSENSOR) beep(900,500); |
if (LSENSOR) beep(800,500); |
if ((read_adc(ADC_READ_ONLY)<BUMPER_TRESHOLD)) beep(1000,500); |
}; |
} |
/////////////////////////////////////////////////////////////////////////////// |
void cikcak() |
{ |
unsigned int16 n; |
sem1: |
n=CIK_CAK; |
while (0==RSENSOR||LSENSOR) // zkontroluj caru |
{ |
if (n==CIK_CAK) // zmen smer zataceni |
{ |
n=0; |
switch(movement) |
{ |
case L: |
FL;BR; |
movement=R; |
break; |
case R: |
FR;BL; |
movement=L; |
break; |
case S: |
FL;BR; |
movement=R; |
n=CIK_CAK/2; |
break; |
} |
} |
n++; |
} |
STOPL;STOPR; |
line = RSENSOR; // cteni senzoru na caru |
line |= LSENSOR << 1; |
if (line==0) goto sem1; |
// nasli jsme caru |
line=S; |
} |
/////////////////////////////////////////////////////////////////////////////// |
void objizdka() // objede cihlu |
{ |
unsigned int16 n; |
BL;BR;Delay_ms(200); |
STOPR;STOPL; |
beep(900,1000); |
// movement=S; |
//cikcak(); |
BL; FR; Delay_ms(215); // otoc se 70° do leva |
FR; FL; Delay_ms(600); // popojed rovne |
BR; Delay_ms(50); // otoc se 90° do prava |
STOPR; FL; Delay_ms(600); |
FR; FL; Delay_ms(100); // popojed rovne na slepo |
for(n=600;n>0;n--) // popojed rovne ale kontroluj caru |
{ |
line = RSENSOR; // cteni senzoru na caru |
line |= LSENSOR << 1; |
if (line!=0) {Delay_ms(50); break;} // kdyz narazis na caru, za chvili zastav |
Delay_ms(1); |
} |
BL; // otoc se 60° do leva |
for(n=600;n>0;n--) |
{ |
line = RSENSOR; // cteni senzoru na caru |
line |= LSENSOR << 1; |
if (line!=0) break; |
Delay_ms(1); |
} |
STOPR; STOPL; |
movement=R; |
cikcak(); |
dira=0; |
} |
/////////////////////////////////////////////////////////////////////////////// |
void prejeddiru() // vyresi diru |
{ |
unsigned int16 n; |
unsigned int8 speed_dira; |
STOPL;STOPR; |
speed_dira=speed; |
beep(1000,500); |
switch (movement) //vrat se zpet na caru |
{ |
case L: |
for (n=COUVANI;n>0;n--) {GO(R,B,speed_dira); Delay_ms(1);} |
STOPL;STOPR; |
break; |
case R: |
for (n=COUVANI;n>0;n--) {GO(L,B,speed_dira); Delay_ms(1);} |
STOPL;STOPR; |
break; |
case S: |
goto sem; |
break; |
} |
beep(800,500); |
line=0; |
FR; BL; Delay_ms(300); // otoc se na caru |
while(line==0) |
{ |
line = RSENSOR; // cteni senzoru na caru |
line |= LSENSOR << 1; |
} |
FL;BR; Delay_ms(60); |
STOPL; STOPR; |
FL; BR; Delay_ms(500); |
STOPL; STOPR; |
Delay_ms(1000); |
FR;FL; //popojed rovne |
for(n=PRES_DIRU;n>0;n--) |
{ |
line = RSENSOR; // cteni senzoru na caru |
line |= LSENSOR << 1; |
if (line!=0) break; |
Delay_ms(1); |
} |
sem: |
STOPL; STOPR; |
movement=S; |
cikcak(); // najdi caru |
dira=0; |
} |
/////////////////////////////////////////////////////////////////////////////// |
void main() |
{ |
unsigned int16 n; // pro FOR |
STOPL; STOPR; // prepne vystupy na ovladani motoru na output a zastavi |
setup_oscillator(OSC_4MHZ|OSC_INTRC); // 4 MHz interni RC oscilator |
port_b_pullups(TRUE); // pullups pro piano na diagnostiku |
setup_spi(FALSE); |
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); // Casovac pro PWM |
setup_timer_2(T2_DIV_BY_4,255,10); // Casovac pro regulaci |
// preruseni kazdych 10ms |
setup_adc_ports(sAN2|VSS_VDD); // nastaveni A/D prevodniku pro naraznik |
setup_adc(ADC_CLOCK_INTERNAL); |
set_adc_channel(2); |
setup_timer_1(T1_INTERNAL|T1_DIV_BY_1); // Casovac pro naraznik |
setup_ccp1(CCP_COMPARE_RESET_TIMER); |
CCP_1=(2^10)-1; // prevod kazdou 1ms |
setup_comparator(A0_VR_A1_VR); // inicializace komparatoru pro cidla cary |
setup_vref(VREF_HIGH|TRESHOLD); // 32 kroku od 0.25 do 0.75 Vdd |
Beep(1000,200); //double beep |
Delay_ms(50); |
Beep(1000,200); |
Delay_ms(1000); // 1s |
// povoleni rizeni rychlosti zataceni pres preruseni |
enable_interrupts(INT_TIMER2); |
enable_interrupts(GLOBAL); |
/*---------------------------------------------------------------------------*/ |
sensors=S; |
line=S; |
last=S; |
movement=S; |
speed=FW_POMALU; |
diagnostika(); |
// cikcak(); // toc se, abys nasel caru |
Delay_ms(500); |
Beep(1000,200); |
Delay_ms(500); |
while(true) // hlavni smycka (jizda podle cary) |
{ |
sensors = RSENSOR; // cteni senzoru na caru |
sensors |= LSENSOR << 1; |
if ((read_adc(ADC_READ_ONLY)<BUMPER_TRESHOLD) && (dira<=T_CIHLA)) objizdka(); |
switch (sensors) // zatacej podle toho, kde vidis caru |
{ |
case S: // rovne |
FL; FR; // pokud se jede dlouho rovne, tak pridej |
dira=0; |
movement=S; |
continue; |
case L: // trochu vlevo |
GO(L, F, FW_POMALU+rovinka); GO(R, F, FW_STREDNE+rovinka); |
line=L; |
dira=0; |
movement=L; |
continue; |
case R: // trochu vpravo |
GO(R, F, FW_POMALU+rovinka); GO(L, F, FW_STREDNE+rovinka); |
line=R; |
dira=0; |
movement=R; |
continue; |
default: // kdyz jsou obe cidla mimo caru, tak pokracuj dal |
} |
rovinka=0; |
if (dira>=T_DIRA) prejeddiru(); |
if (last!=line) // pokud si prejel caru z jedne strany na druhou stranu, tak zabrzdi |
{ |
last=line; |
speed=FW_ZATACKA; |
} |
if (L==line) // kdyz jsou obe cidla mimo caru, zatoc na caru |
{ |
STOPL; |
GO(R, F, speed); |
movement=L; |
} |
else |
{ |
STOPR; |
GO(L, F, speed); |
movement=R; |
} |
} // while(true) |
} |
/Designs/ROBOTS/Merkur/SW/turn_L/tank.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 |
/Designs/ROBOTS/Merkur/SW/turn_L/tank.err |
---|
0,0 → 1,0 |
No Errors |
/Designs/ROBOTS/Merkur/SW/turn_L/tank.h |
---|
0,0 → 1,5 |
#include <16F88.h> |
#device adc=8 |
#fuses NOWDT,INTRC_IO, NOPUT, MCLR, NOBROWNOUT, NOLVP, NOCPD, NOWRT, NODEBUG, NOPROTECT, NOFCMEN, NOIESO |
#use delay(clock=4000000) |
/Designs/ROBOTS/Merkur/SW/turn_L/tank.sta |
---|
0,0 → 1,38 |
ROM used: 1705 (42%) |
1705 (42%) including unused fragments |
2 Average locations per line |
4 Average locations per statement |
RAM used: 87 (50%) at main() level |
98 (56%) worst case |
Lines Stmts % Files |
----- ----- --- ----- |
341 386 85 D:\KAKLIK\programy\PIC_C\roboti\merkur\PIC16F88\turn_L\tank.c |
6 0 0 D:\KAKLIK\programy\PIC_C\roboti\merkur\PIC16F88\turn_L\tank.h |
275 0 0 C:\Program Files\PICC\devices\16F88.h |
136 67 8 D:\KAKLIK\programy\PIC_C\roboti\merkur\PIC16F88\turn_L\AX25.c |
----- ----- |
1516 906 Total |
Page ROM % RAM Functions: |
---- --- --- --- ---------- |
0 21 1 1 @delay_ms1 |
0 21 1 1 @delay_us1 |
0 16 1 0 TIMER2_isr |
0 44 3 6 beep |
0 352 21 3 diagnostika |
0 140 8 3 cikcak |
0 247 14 3 objizdka |
0 360 21 4 prejeddiru |
0 449 26 3 main |
Segment Used Free |
--------- ---- ---- |
00000-00003 4 0 |
00004-00036 51 0 |
00037-007FF 1650 343 |
00800-00FFF 0 2048 |
/Designs/ROBOTS/Merkur/SW/turn_L/tank.tre |
---|
0,0 → 1,80 |
ÀÄtank |
ÃÄmain 0/449 Ram=3 |
³ ÃÄ??0?? |
³ ÃÄbeep 0/44 Ram=6 |
³ ³ ÃÄ@delay_us1 0/21 Ram=1 |
³ ³ ÀÄ@delay_us1 0/21 Ram=1 |
³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ÃÄbeep 0/44 Ram=6 |
³ ³ ÃÄ@delay_us1 0/21 Ram=1 |
³ ³ ÀÄ@delay_us1 0/21 Ram=1 |
³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ÃÄdiagnostika 0/352 Ram=3 |
³ ³ ÃÄbeep 0/44 Ram=6 |
³ ³ ³ ÃÄ@delay_us1 0/21 Ram=1 |
³ ³ ³ ÀÄ@delay_us1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄbeep 0/44 Ram=6 |
³ ³ ³ ÃÄ@delay_us1 0/21 Ram=1 |
³ ³ ³ ÀÄ@delay_us1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄbeep 0/44 Ram=6 |
³ ³ ³ ÃÄ@delay_us1 0/21 Ram=1 |
³ ³ ³ ÀÄ@delay_us1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄbeep 0/44 Ram=6 |
³ ³ ³ ÃÄ@delay_us1 0/21 Ram=1 |
³ ³ ³ ÀÄ@delay_us1 0/21 Ram=1 |
³ ³ ÃÄbeep 0/44 Ram=6 |
³ ³ ³ ÃÄ@delay_us1 0/21 Ram=1 |
³ ³ ³ ÀÄ@delay_us1 0/21 Ram=1 |
³ ³ ÀÄbeep 0/44 Ram=6 |
³ ³ ÃÄ@delay_us1 0/21 Ram=1 |
³ ³ ÀÄ@delay_us1 0/21 Ram=1 |
³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ÃÄbeep 0/44 Ram=6 |
³ ³ ÃÄ@delay_us1 0/21 Ram=1 |
³ ³ ÀÄ@delay_us1 0/21 Ram=1 |
³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ÃÄobjizdka 0/247 Ram=3 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄbeep 0/44 Ram=6 |
³ ³ ³ ÃÄ@delay_us1 0/21 Ram=1 |
³ ³ ³ ÀÄ@delay_us1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÀÄcikcak 0/140 Ram=3 |
³ ÀÄprejeddiru 0/360 Ram=4 |
³ ÃÄbeep 0/44 Ram=6 |
³ ³ ÃÄ@delay_us1 0/21 Ram=1 |
³ ³ ÀÄ@delay_us1 0/21 Ram=1 |
³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ÃÄbeep 0/44 Ram=6 |
³ ³ ÃÄ@delay_us1 0/21 Ram=1 |
³ ³ ÀÄ@delay_us1 0/21 Ram=1 |
³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ÀÄcikcak 0/140 Ram=3 |
ÀÄTIMER2_isr 0/16 Ram=0 |
/Designs/ROBOTS/Merkur/SW/turn_R/AX25.c |
---|
0,0 → 1,135 |
#nolist |
//#define PTT PIN_A2 // PTT control |
//#define TXo PIN_C0 // To the transmitter modulator |
#define PERIODAH delay_us(222) // Halfperiod H 222;78/1200 500;430/500 |
#define TAILH delay_us(78) |
#define PERIODAL delay_us(412) // Halfperiod L 412;345/1200 1000;880/500 |
#define TAILL delay_us(345) |
#byte STATUS = 3 // CPUs status register |
byte SendData[16] = {'A'<<1, 'L'<<1, 'L'<<1, ' '<<1, ' '<<1, ' '<<1, 0x60, |
'C'<<1, 'Z'<<1, '0'<<1, 'R'<<1, 'R'<<1, 'R'<<1, 0x61, |
0x03, 0xF0}; |
boolean bit; |
int fcslo, fcshi; // variabloes for calculating FCS (CRC) |
int stuff; // stuff counter for extra 0 |
int flag_flag; // if it is sending flag (7E) |
int fcs_flag; // if it is sending Frame Check Sequence |
int i; // for for |
void flipout() //flips the state of output pin a_1 |
{ |
stuff = 0; //since this is a 0, reset the stuff counter |
if (bit) |
{ |
bit=FALSE; //if the state of the pin was low, make it high. |
} |
else |
{ |
bit=TRUE; //if the state of the pin was high make it low |
} |
} |
void fcsbit(byte tbyte) |
{ |
#asm |
BCF STATUS,0 |
RRF fcshi,F // rotates the entire 16 bits |
RRF fcslo,F // to the right |
#endasm |
if (((STATUS & 0x01)^(tbyte)) ==0x01) |
{ |
fcshi = fcshi^0x84; |
fcslo = fcslo^0x08; |
} |
} |
void SendBit () |
{ |
if (bit) |
{ |
output_high(TXo); |
PERIODAH; |
output_low(TXo); |
PERIODAH; |
output_high(TXo); |
PERIODAH; |
output_low(TXo); |
TAILH; |
} |
else |
{ |
output_high(TXo); |
PERIODAL; |
output_low(TXo); |
TAILL; |
}; |
} |
void SendByte (byte inbyte) |
{ |
int k, bt; |
for (k=0;k<8;k++) //do the following for each of the 8 bits in the byte |
{ |
bt = inbyte & 0x01; //strip off the rightmost bit of the byte to be sent (inbyte) |
if ((fcs_flag == FALSE) & (flag_flag == FALSE)) fcsbit(bt); //do FCS calc, but only if this |
//is not a flag or fcs byte |
if (bt == 0) |
{ |
flipout(); |
} // if this bit is a zero, flip the output state |
else |
{ //otherwise if it is a 1, do the following: |
if (flag_flag == FALSE) stuff++; //increment the count of consequtive 1's |
if ((flag_flag == FALSE) & (stuff == 5)) |
{ //stuff an extra 0, if 5 1's in a row |
SendBit(); |
flipout(); //flip the output state to stuff a 0 |
}//end of if |
}//end of else |
// delay_us(850); //introduces a delay that creates 1200 baud |
SendBit(); |
inbyte = inbyte>>1; //go to the next bit in the byte |
}//end of for |
}//end of SendByte |
void SendPacket(char *data) |
{ |
bit=FALSE; |
fcslo=fcshi=0xFF; //The 2 FCS Bytes are initialized to FF |
stuff = 0; //The variable stuff counts the number of 1's in a row. When it gets to 5 |
// it is time to stuff a 0. |
// output_low(PTT); // Blinking LED |
// delay_ms(1000); |
// output_high(PTT); |
flag_flag = TRUE; //The variable flag is true if you are transmitted flags (7E's) false otherwise. |
fcs_flag = FALSE; //The variable fcsflag is true if you are transmitting FCS bytes, false otherwise. |
for(i=0; i<10; i++) SendByte(0x7E); //Sends flag bytes. Adjust length for txdelay |
//each flag takes approx 6.7 ms |
flag_flag = FALSE; //done sending flags |
for(i=0; i<16; i++) SendByte(SendData[i]); //send the packet bytes |
for(i=0; 0 != *data; i++) |
{ |
SendByte(*data); //send the packet bytes |
data++; |
}; |
fcs_flag = TRUE; //about to send the FCS bytes |
fcslo =fcslo^0xff; //must XOR them with FF before sending |
fcshi = fcshi^0xff; |
SendByte(fcslo); //send the low byte of fcs |
SendByte(fcshi); //send the high byte of fcs |
fcs_flag = FALSE; //done sending FCS |
flag_flag = TRUE; //about to send flags |
SendByte(0x7e); // Send a flag to end packet |
} |
#list |
/Designs/ROBOTS/Merkur/SW/turn_R/tank.BAK |
---|
0,0 → 1,339 |
#include "tank.h" |
#define DEBUG |
#define TXo PIN_A3 // To the transmitter modulator |
#include "AX25.c" // podprogram pro prenos telemetrie |
unsigned int8 sensors; // pomocna promenna pro cteni cidel na caru |
unsigned int8 line; // na ktere strane byla detekovana cara |
unsigned int8 speed; // rychlost zataceni |
unsigned int8 rovinka; // pocitadlo pro zjisteni rovneho useku |
unsigned int8 last; // kde byla cara, kdyz byly minule cidla mimo |
unsigned int8 movement; // obsahuje aktualni smer zataceni |
unsigned int8 dira; // pocita dobu po kterou je ztracena cara |
// Konstanty pro dynamiku pohybu |
#define T_DIRA 120 // po jakem case zataceni se detekuje dira |
#define INC_SPEED 1 // prirustek rychlosti v jednom kroku |
#define FW_POMALU 230 // trochu mimo caru vnitrni pas |
#define FW_ZATACKA 240 // rychlost vnejsiho kola pri zataceni |
#define FW_STREDNE 240 // trochu mimo caru vnejsi pas |
#define COUVANI 750 // couvnuti zpet na caru, po detekci diry |
#define PRES_DIRU 300 |
#define MAX_ROVINKA (255-FW_STREDNE) |
#define TRESHOLD 6 // rozhodovaci uroven komparatoru, 0xF = 0.75*Vdd |
#define BUMPER_TRESHOLD 128 |
#define CIK_CAK 30000 |
#define T_CIHLA 50 // perioda detekce cihly |
//motory //Napred vypnout potom zapnout! |
#define FR output_low(PIN_B5); output_high(PIN_B4) // Vpred |
#define FL output_low(PIN_B7); output_high(PIN_B6) |
#define BR output_low(PIN_B4); output_high(PIN_B5) // Vzad |
#define BL output_low(PIN_B6); output_high(PIN_B7) |
#define STOPR output_low(PIN_B4);output_low(PIN_B5) // Zastav |
#define STOPL output_low(PIN_B6);output_low(PIN_B7) |
#define L 0b10 // left |
#define R 0b01 // right |
#define S 0b11 // straight |
//cidla |
#define RSENSOR C2OUT // Senzory na caru |
#define LSENSOR C1OUT |
#define BUMPER PIN_A4 // Senzor na cihlu |
#define DIAG_SERVO PIN_B3 // Propojka pro diagnosticky mod |
#define DIAG_SENSORS PIN_B2 // Propojka pro diagnosticky mod |
#DEFINE SOUND_HI PIN_A6 // komplementarni vystupy pro piezo pipak |
#DEFINE SOUND_LO PIN_A7 |
char AXstring[40]; // Buffer pro prenos telemetrie |
// makro pro PWM |
#define GO(motor, direction, power) if(get_timer0()<=power) \ |
{direction##motor;} else {stop##motor;} |
#int_TIMER2 |
void TIMER2_isr() |
{ |
if (speed<255) speed+=INC_SPEED; |
if (rovinka<MAX_ROVINKA) rovinka++; |
if (dira<=T_DIRA) dira++; |
} |
// Primitivni Pipani |
void beep(unsigned int16 period, unsigned int16 length) |
{ |
unsigned int16 nn; |
for(nn=length; nn>0; nn--) |
{ |
output_high(SOUND_HI);output_low(SOUND_LO); |
delay_us(period); |
output_high(SOUND_LO);output_low(SOUND_HI); |
delay_us(period); |
} |
} |
/******************************************************************************/ |
void diagnostika() |
{ |
unsigned int16 n; |
while (input(DIAG_SERVO)) // Propojka, ktera spousti diagnostiku |
{ |
for (n=500; n<800; n+=100) |
{ |
beep(n,n); //beep UP |
}; |
Delay_ms(1000); |
//zastav vse |
STOPL; STOPR; |
//pravy pas |
FR; Delay_ms(1000); STOPR; Delay_ms(1000); |
BR; Delay_ms(1000); STOPR; Delay_ms(1000); |
Beep(880,100); Delay_ms(1000); |
//levy pas |
FL; Delay_ms(1000); STOPL; Delay_ms(1000); |
BL; Delay_ms(1000); STOPL; Delay_ms(1000); |
Beep(880,100); Delay_ms(1000); |
//oba pasy |
FL; FR; Delay_ms(1000); STOPL; STOPR; Delay_ms(1000); |
BL; BR; Delay_ms(1000); STOPL; STOPR; Delay_ms(1000); |
}; |
while (input(DIAG_SENSORS)) // spusteni diagnostiky cidel |
{ |
if (RSENSOR) beep(900,500); |
if (LSENSOR) beep(800,500); |
if ((read_adc(ADC_READ_ONLY)<BUMPER_TRESHOLD)) beep(1000,500); |
}; |
} |
/////////////////////////////////////////////////////////////////////////////// |
void cikcak() |
{ |
unsigned int16 n; |
sem1: |
n=CIK_CAK; |
while (0==RSENSOR||LSENSOR) // zkontroluj caru |
{ |
if (n==CIK_CAK) // zmen smer zataceni |
{ |
n=0; |
switch(movement) |
{ |
case L: |
FL;BR; |
movement=R; |
break; |
case R: |
FR;BL; |
movement=L; |
break; |
case S: |
FL;BR; |
movement=R; |
n=CIK_CAK/2; |
break; |
} |
} |
n++; |
} |
STOPL;STOPR; |
line = RSENSOR; // cteni senzoru na caru |
line |= LSENSOR << 1; |
if (line==0) goto sem1; |
// nasli jsme caru |
line=S; |
} |
/////////////////////////////////////////////////////////////////////////////// |
void objizdka() // objede cihlu |
{ |
unsigned int16 n; |
BL;BR;Delay_ms(150); |
STOPR;STOPL; |
beep(900,1000); |
// movement=S; |
// cikcak(); |
BR; FL; Delay_ms(270); // otoc se 70° do prava |
FR; FL; Delay_ms(700); // popojed rovne |
BL; Delay_ms(30); // otoc se 90° do leva |
STOPL; FR; Delay_ms(500); |
FR; FL; Delay_ms(100); // popojed rovne na slepo |
for(n=40000;n>0;n--) // popojed rovne ale kontroluj caru |
{ |
line = RSENSOR; // cteni senzoru na caru |
line |= LSENSOR << 1; |
if (line!=0) {Delay_ms(150); break;} |
// Delay_ms(1); |
} |
BR; FL; // otoc se 60° do prava |
for(n=40000;n>0;n--) |
{ |
line = RSENSOR; // cteni senzoru na caru |
line |= LSENSOR << 1; |
if (line!=0) break; |
// Delay_ms(1); |
} |
STOPR; STOPL; |
movement=L; //R; |
cikcak(); |
dira=0; |
} |
/////////////////////////////////////////////////////////////////////////////// |
void prejeddiru() // vyresi diru |
{ |
unsigned int16 n; |
unsigned int8 speed_dira; |
STOPL;STOPR; |
speed_dira=speed; |
beep(1000,500); |
switch (movement) //vrat se zpet na caru |
{ |
case L: |
for (n=COUVANI;n>0;n--) {GO(R,B,speed_dira); Delay_ms(1);} |
STOPL;STOPR; |
break; |
case R: |
for (n=COUVANI;n>0;n--) {GO(L,B,speed_dira); Delay_ms(1);} |
STOPL;STOPR; |
break; |
case S: |
goto sem; |
break; |
} |
beep(1000,500); |
/*line=0; |
FR; BL; Delay_ms(400); // otoc se na caru |
beep(1000,500); |
while(line==0) |
{ |
line = RSENSOR; // cteni senzoru na caru |
line |= LSENSOR << 1; |
} |
FL;BR; Delay_ms(60); // zabrzdi |
STOPL; STOPR; |
FL; BR; Delay_ms(700); // otacka 180 deg |
STOPL; STOPR;*/ |
FR;FL; //popojed rovne |
for(n=PRES_DIRU;n>0;n--) |
{ |
line = RSENSOR; // cteni senzoru na caru |
line |= LSENSOR << 1; |
if (line!=0) break; |
Delay_ms(1); |
} |
sem: |
STOPL; STOPR; |
movement=S; |
cikcak(); // najdi caru |
dira=0; |
} |
/////////////////////////////////////////////////////////////////////////////// |
void main() |
{ |
unsigned int16 n; // pro FOR |
STOPL; STOPR; // prepne vystupy na ovladani motoru na output a zastavi |
setup_oscillator(OSC_4MHZ|OSC_INTRC); // 4 MHz interni RC oscilator |
port_b_pullups(TRUE); // pullups pro piano na diagnostiku |
setup_spi(FALSE); |
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); // Casovac pro PWM |
setup_timer_2(T2_DIV_BY_4,255,10); // Casovac pro regulaci |
// preruseni kazdych 10ms |
setup_adc_ports(sAN2|VSS_VDD); // nastaveni A/D prevodniku pro naraznik |
setup_adc(ADC_CLOCK_INTERNAL); |
set_adc_channel(2); |
setup_timer_1(T1_INTERNAL|T1_DIV_BY_1); // Casovac pro naraznik |
setup_ccp1(CCP_COMPARE_RESET_TIMER); |
CCP_1=(2^10)-1; // prevod kazdou 1ms |
setup_comparator(A0_VR_A1_VR); // inicializace komparatoru pro cidla cary |
setup_vref(VREF_HIGH|TRESHOLD); // 32 kroku od 0.25 do 0.75 Vdd |
Beep(1000,200); //double beep |
Delay_ms(50); |
Beep(1000,200); |
Delay_ms(1000); // 1s |
// povoleni rizeni rychlosti zataceni pres preruseni |
enable_interrupts(INT_TIMER2); |
enable_interrupts(GLOBAL); |
/*---------------------------------------------------------------------------*/ |
sensors=S; |
line=S; |
last=S; |
movement=S; |
speed=FW_POMALU; |
diagnostika(); |
//cikcak(); // toc se, abys nasel caru |
Delay_ms(500); |
Beep(1000,200); |
Delay_ms(500); |
while(true) // hlavni smycka (jizda podle cary) |
{ |
sensors = RSENSOR; // cteni senzoru na caru |
sensors |= LSENSOR << 1; |
if ((read_adc(ADC_READ_ONLY)<BUMPER_TRESHOLD) && (dira<=T_CIHLA)) objizdka(); |
switch (sensors) // zatacej podle toho, kde vidis caru |
{ |
case S: // rovne |
FL; FR; // pokud se jede dlouho rovne, tak pridej |
dira=0; |
movement=S; |
continue; |
case L: // trochu vlevo |
GO(L, F, FW_POMALU+rovinka); GO(R, F, FW_STREDNE+rovinka); |
line=L; |
dira=0; |
movement=L; |
continue; |
case R: // trochu vpravo |
GO(R, F, FW_POMALU+rovinka); GO(L, F, FW_STREDNE+rovinka); |
line=R; |
dira=0; |
movement=R; |
continue; |
default: // kdyz jsou obe cidla mimo caru, tak pokracuj dal |
} |
rovinka=0; |
if (dira>=T_DIRA) prejeddiru(); |
if (last!=line) // pokud si prejel caru z jedne strany na druhou stranu, tak zabrzdi |
{ |
last=line; |
speed=FW_ZATACKA; |
} |
if (L==line) // kdyz jsou obe cidla mimo caru, zatoc na caru |
{ |
STOPL; |
GO(R, F, speed); |
movement=L; |
} |
else |
{ |
STOPR; |
GO(L, F, speed); |
movement=R; |
} |
} // while(true) |
} |
/Designs/ROBOTS/Merkur/SW/turn_R/tank.HEX |
---|
0,0 → 1,202 |
:1000000000308A00722C0000FF00030E8301A10063 |
:100010007F08A0000A08A8008A01A00E0408A20018 |
:100020007708A3007808A4007908A5007A08A6003C |
:100030007B08A700831383128C308400801C222845 |
:100040008C183528220884002308F7002408F800BB |
:100050002508F9002608FA002708FB0028088A006E |
:10006000210E8300FF0E7F0E09008A113728420FF0 |
:100070003A283C280130C20743080E3C0318C30A43 |
:100080004608783C0318C60A8C108A1122281230C0 |
:100090008316A202031C5A28A2308400FC3080057B |
:1000A0000310800C800C000803195A2858280000FF |
:1000B000800B5728831200347D088316A1007C082A |
:1000C000A000A008031D6728A108031986280513AE |
:1000D00083120517831685138312851374088316FC |
:1000E000A200831247208316851383128517831677 |
:1000F00005138312051374088316A2008312472088 |
:10010000831620080319A103A00361288312003479 |
:1001100074308400000803199C280130F800F701AE |
:10012000F70B9028F80B8F284A30F700F70B96282A |
:1001300000000000800B8D28003483168615831282 |
:10014000861DC8290130F200F430F1007208033C2A |
:10015000031CBE28031DB02871081F3C031CBE28C9 |
:100160007208F5007108F4007208FD007108FC00C7 |
:100170005C206430F1070318F20AA6280430F3006B |
:10018000FA30F4008820F30BC0288316061383127C |
:1001900006138316861383128613831606128312A0 |
:1001A0000612831686128312861283168612831213 |
:1001B000861283160612831206160430F300FA30F4 |
:1001C000F4008820F30BDF28831606128312061230 |
:1001D00083168612831286120430F300FA30F4007C |
:1001E0008820F30BEE28831606128312061283165C |
:1001F0008612831286160430F300FA30F400882049 |
:10020000F30BFD288316061283120612831686123C |
:10021000831286120430F300FA30F4008820F30BC6 |
:100220000C290330F5007030F400FD016430FC004F |
:100230005C200430F300FA30F4008820F30B1B2913 |
:1002400083168613831286138316061383120617EA |
:100250000430F300FA30F4008820F30B2A298316C7 |
:100260000613831206138316861383128613043033 |
:10027000F300FA30F4008820F30B392983160613B3 |
:100280008312061383168613831286170430F30035 |
:10029000FA30F4008820F30B4829831606138312E2 |
:1002A000061383168613831286130430F300FA3084 |
:1002B000F4008820F30B57290330F5007030F40068 |
:1002C000FD016430FC005C200430F300FA30F400DF |
:1002D0008820F30B662983168613831286138316F0 |
:1002E000061383120617831686128312861283164C |
:1002F0000612831206160430F300FA30F400882048 |
:10030000F30B7D29831606138312061383168613B7 |
:100310008312861383160612831206128316861220 |
:10032000831286120430F300FA30F4008820F30BB5 |
:1003300094298316061383120613831686138312D9 |
:1003400086178316061283120612831686128312EC |
:1003500086160430F300FA30F4008820F30BAB2942 |
:1003600083160613831206138316861383128613CD |
:1003700083160612831206128316861283128612C1 |
:100380000430F300FA30F4008820F30BC2299D28D2 |
:10039000831606158312061DFB2983169C1FDB2975 |
:1003A0000330F5008430F4000130FD00F430FC002F |
:1003B00083125C2083161C1FE8290330F5002030CF |
:1003C000F4000130FD00F430FC0083125C20831641 |
:1003D00083121F1DED298316E8291E087F3C031C8C |
:1003E000FA290330F500E830F4000130FD00F43064 |
:1003F000FC005C20C8298A11202D7530F5003030B2 |
:10040000F400003083169C1B0130003A03190A2ABD |
:100410001C1F642A7408303C031D5E2A7508753C55 |
:10042000031D5E2AF501F40183124508023A0319FF |
:10043000202A033A0319332A023A0319462A5D2A6D |
:1004400083168613831286138316061383120617E8 |
:1004500083160612831206128316861283128616DC |
:100460000130C5005D2A8316861283128612831618 |
:1004700006128312061683160613831206138316BA |
:100480008613831286170230C5005D2A83168613F1 |
:100490008312861383160613831206178316061219 |
:1004A0008312061283168612831286160130C50047 |
:1004B0003A30F5009830F4005D2A8316F40A0319E7 |
:1004C000F50A8312012A8316061383120613831674 |
:1004D000861383128613831606128312061283165E |
:1004E000861283128612C10183169C1F7A2A8312F8 |
:1004F000C10A831600301C1B0130F7000310F70DF2 |
:1005000077088312C104C1080319FD290330C10013 |
:100510000034831606138312061383168613831280 |
:10052000861783160612831206128316861283120A |
:1005300086169630F400882083160612831206125F |
:1005400083168612831286128316061383120613ED |
:1005500083168613831286130330F5008430F4006B |
:100560000330FD00E830FC005C2083160612831285 |
:10057000061283168612831286168316861383123A |
:10058000861383160613831206170230F300873092 |
:10059000F4008820F30BC72A831686128312861272 |
:1005A0008316061283120616831686138312861389 |
:1005B00083160613831206170230F300FA30F40094 |
:1005C0008820F30BDE2A8316061383120613831684 |
:1005D0008613831286171E30F400882083160613B4 |
:1005E00083120613831686138312861383168612CC |
:1005F0008312861283160612831206160230F30047 |
:10060000FA30F4008820F30B002B83168612831235 |
:100610008612831606128312061683168613831219 |
:10062000861383160613831206176430F40088209D |
:100630009C30F2004030F100F108031D222BF2083B |
:1006400003193E2BC10183169C1F292B8312C10A5B |
:10065000831600301C1B0130F7000310F70D7708DC |
:100660008312C104C1080319392B9630F400882085 |
:100670003E2B71080319F203F1031C2B831606129B |
:100680008312061283168612831286168316861329 |
:100690008312861383160613831206179C30F2000A |
:1006A0004030F100F108031D582BF2080319702B9C |
:1006B000C10183169C1F5F2B8312C10A8316003071 |
:1006C0001C1B0130F7000310F70D77088312C104DB |
:1006D000C108031D702B71080319F203F103522B9B |
:1006E000831606128312061283168612831286124E |
:1006F000831606138312061383168613831286133A |
:100700000230C500FD21C6018A11502D8316061343 |
:10071000831206138316861383128613831606121A |
:100720008312061283168612831286124208F30081 |
:100730000330F500E830F4000130FD00F430FC0037 |
:100740005C204508023A0319AC2B033A0319E42B49 |
:10075000023A03191C2C1E2C0230F200EE30F1007C |
:10076000F108031DB62BF2080319D32B01087302FD |
:10077000031CC32B831606128312061283168612DD |
:1007800083128616CB2B831606128312061283164B |
:100790008612831286120130F40088207108031932 |
:1007A000F203F103B02B831606138312061383168C |
:1007B000861383128613831606128312061283167B |
:1007C0008612831286121E2C0230F200EE30F100E7 |
:1007D000F108031DEE2BF20803190B2C010873021C |
:1007E000031CFB2B83160613831206138316861332 |
:1007F00083128617032C831606138312061383169F |
:100800008613831286130130F400882071080319BF |
:10081000F203F103E82B83160613831206138316E3 |
:10082000861383128613831606128312061283160A |
:100830008612831286121E2C5C2C1E2C0330F500AF |
:10084000E830F4000130FD00F430FC005C20831639 |
:1008500086128312861283160612831206168316D8 |
:10086000861383128613831606138312061701302C |
:10087000F2002C30F100F108031D412CF20803199D |
:100880005C2CC10183169C1F482C8312C10A83165D |
:1008900000301C1B0130F7000310F70D770883129E |
:1008A000C104C108031D5C2C0130F40088207108CC |
:1008B0000319F203F1033B2C83160613831206136C |
:1008C000831686138312861383160612831206126A |
:1008D00083168612831286120330C500FD21C601DD |
:1008E0008A11E62D84011F30830583161F129F1283 |
:1008F0001B0880399B0007309C001C0883120D13D5 |
:10090000603083168F0082308312A9009830AA00CD |
:10091000AB004030AC00AD00AE006030AF008630C0 |
:10092000B000B430B1006030B200A430B300B40005 |
:10093000B5006130B6000330B700F030B800831660 |
:1009400006138312061383168613831286138316E7 |
:1009500006128312061283168612831286126230E2 |
:1009600083168F0081138312941283160611861446 |
:100970000612003083129400831694000108C739D0 |
:10098000083881004830F800053883129200FF30A3 |
:10099000831692001F129F121B08803904389B0097 |
:1009A0001F1383121F179F1783169F1383121F1481 |
:1009B0001030F8001F08C73978049F008530900078 |
:1009C000831686150B308312970096010730950029 |
:1009D000023083169C000508033885000330F700B9 |
:1009E000F70BF02C1C0883120D13863083169D0024 |
:1009F0000330F500E830F400FD01C830FC0083123C |
:100A00005C203230F40088200330F500E830F40038 |
:100A1000FD01C830FC005C200430F100FA30F40025 |
:100A20008820F10B0E2D83168C14C03083128B049A |
:100A30000330C000C100C400C500E630C2009D28DC |
:100A40000230F100FA30F4008820F10B222D03303F |
:100A5000F500E830F400FD01C830FC005C200230F5 |
:100A6000F100FA30F4008820F10B312DC00183161B |
:100A70009C1F3D2D8312C00A831600301C1B0130C1 |
:100A8000F7000310F70D77088312C0041F19462DD5 |
:100A90001E087F3C031C502D4608323C0318892A4F |
:100AA0004008033A03195B2D013A03196F2D033AED |
:100AB0000319A82DE12D831686138312861383163E |
:100AC0000613831206178316861283128612831664 |
:100AD000061283120616C6010330C500362D010822 |
:100AE000F100E630430771020319782D0318812DB8 |
:100AF0008316861383128613831606138312061732 |
:100B0000892D831606138312061383168613831208 |
:100B100086130108F100F030430771020319922D8A |
:100B200003189B2D831686128312861283160612D3 |
:100B300083120616A32D831606128312061283163D |
:100B40008612831286120230C100C601C500362DFE |
:100B50000108F100E630430771020319B12D0318B3 |
:100B6000BA2D8316861283128612831606128312FA |
:100B70000616C22D831606128312061283168612DB |
:100B8000831286120108F100F03043077102031945 |
:100B9000CB2D0318D42D8316861383128613831648 |
:100BA000061383120617DC2D831606138312061311 |
:100BB00083168613831286130130C100C601C50057 |
:100BC000362DC3014608773C031C862B410844029E |
:100BD0000319EE2D4108C400F030C2004108023C68 |
:100BE000031D122E83160613831206138316861313 |
:100BF0008312861301084202031C072E83168612F5 |
:100C00008312861283160612831206160F2E83167F |
:100C1000061283120612831686128312861202307F |
:100C2000C500312E83160612831206128316861211 |
:100C30008312861201084202031C272E8316861394 |
:100C40008312861383160613831206172F2E83161C |
:100C5000061383120613831686138312861301303C |
:060C6000C500362D630003 |
:04400E00383FFC3FFC |
:00000001FF |
;PIC16F88 |
/Designs/ROBOTS/Merkur/SW/turn_R/tank.LST |
---|
0,0 → 1,1932 |
CCS PCM C Compiler, Version 3.221, 27853 27-IV-05 14:16 |
Filename: D:\KAKLIK\programy\PIC_C\roboti\merkur\PIC16F88\turn_R\tank.LST |
ROM used: 1587 words (39%) |
Largest free fragment is 2048 |
RAM used: 87 (50%) at main() level |
98 (56%) worst case |
Stack: 4 worst case (3 in main + 1 for interrupts) |
* |
0000: MOVLW 00 |
0001: MOVWF 0A |
0002: GOTO 472 |
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 037 |
.................... #include "tank.h" |
.................... #include <16F88.h> |
.................... //////// Standard Header file for the PIC16F88 device //////////////// |
.................... #device PIC16F88 |
.................... #list |
.................... |
.................... #device adc=8 |
.................... #fuses NOWDT,INTRC_IO, NOPUT, MCLR, NOBROWNOUT, NOLVP, NOCPD, NOWRT, NODEBUG, NOPROTECT, NOFCMEN, NOIESO |
.................... #use delay(clock=4000000) |
* |
0047: MOVLW 12 |
0048: BSF 03.5 |
0049: SUBWF 22,F |
004A: BTFSS 03.0 |
004B: GOTO 05A |
004C: MOVLW A2 |
004D: MOVWF 04 |
004E: MOVLW FC |
004F: ANDWF 00,F |
0050: BCF 03.0 |
0051: RRF 00,F |
0052: RRF 00,F |
0053: MOVF 00,W |
0054: BTFSC 03.2 |
0055: GOTO 05A |
0056: GOTO 058 |
0057: NOP |
0058: DECFSZ 00,F |
0059: GOTO 057 |
005A: BCF 03.5 |
005B: RETLW 00 |
* |
0088: MOVLW 74 |
0089: MOVWF 04 |
008A: MOVF 00,W |
008B: BTFSC 03.2 |
008C: GOTO 09C |
008D: MOVLW 01 |
008E: MOVWF 78 |
008F: CLRF 77 |
0090: DECFSZ 77,F |
0091: GOTO 090 |
0092: DECFSZ 78,F |
0093: GOTO 08F |
0094: MOVLW 4A |
0095: MOVWF 77 |
0096: DECFSZ 77,F |
0097: GOTO 096 |
0098: NOP |
0099: NOP |
009A: DECFSZ 00,F |
009B: GOTO 08D |
009C: RETLW 00 |
.................... |
.................... |
.................... |
.................... #define DEBUG |
.................... |
.................... #define TXo PIN_A3 // To the transmitter modulator |
.................... #include "AX25.c" // podprogram pro prenos telemetrie |
.................... #list |
.................... |
.................... |
.................... unsigned int8 sensors; // pomocna promenna pro cteni cidel na caru |
.................... unsigned int8 line; // na ktere strane byla detekovana cara |
.................... unsigned int8 speed; // rychlost zataceni |
.................... unsigned int8 rovinka; // pocitadlo pro zjisteni rovneho useku |
.................... unsigned int8 last; // kde byla cara, kdyz byly minule cidla mimo |
.................... unsigned int8 movement; // obsahuje aktualni smer zataceni |
.................... unsigned int8 dira; // pocita dobu po kterou je ztracena cara |
.................... |
.................... // Konstanty pro dynamiku pohybu |
.................... #define T_DIRA 120 // po jakem case zataceni se detekuje dira |
.................... #define INC_SPEED 1 // prirustek rychlosti v jednom kroku |
.................... #define FW_POMALU 230 // trochu mimo caru vnitrni pas |
.................... #define FW_ZATACKA 240 // rychlost vnejsiho kola pri zataceni |
.................... #define FW_STREDNE 240 // trochu mimo caru vnejsi pas |
.................... #define COUVANI 750 // couvnuti zpet na caru, po detekci diry |
.................... #define PRES_DIRU 300 |
.................... #define MAX_ROVINKA (255-FW_STREDNE) |
.................... #define TRESHOLD 6 // rozhodovaci uroven komparatoru, 0xF = 0.75*Vdd |
.................... #define BUMPER_TRESHOLD 128 |
.................... #define CIK_CAK 30000 |
.................... #define T_CIHLA 50 // perioda detekce cihly |
.................... |
.................... //motory //Napred vypnout potom zapnout! |
.................... #define FR output_low(PIN_B5); output_high(PIN_B4) // Vpred |
.................... #define FL output_low(PIN_B7); output_high(PIN_B6) |
.................... #define BR output_low(PIN_B4); output_high(PIN_B5) // Vzad |
.................... #define BL output_low(PIN_B6); output_high(PIN_B7) |
.................... #define STOPR output_low(PIN_B4);output_low(PIN_B5) // Zastav |
.................... #define STOPL output_low(PIN_B6);output_low(PIN_B7) |
.................... |
.................... #define L 0b10 // left |
.................... #define R 0b01 // right |
.................... #define S 0b11 // straight |
.................... |
.................... //cidla |
.................... #define RSENSOR C2OUT // Senzory na caru |
.................... #define LSENSOR C1OUT |
.................... #define BUMPER PIN_A4 // Senzor na cihlu |
.................... |
.................... #define DIAG_SERVO PIN_B3 // Propojka pro diagnosticky mod |
.................... #define DIAG_SENSORS PIN_B2 // Propojka pro diagnosticky mod |
.................... |
.................... #DEFINE SOUND_HI PIN_A6 // komplementarni vystupy pro piezo pipak |
.................... #DEFINE SOUND_LO PIN_A7 |
.................... |
.................... char AXstring[40]; // Buffer pro prenos telemetrie |
.................... |
.................... // makro pro PWM |
.................... #define GO(motor, direction, power) if(get_timer0()<=power) \ |
.................... {direction##motor;} else {stop##motor;} |
.................... |
.................... #int_TIMER2 |
.................... void TIMER2_isr() |
.................... { |
.................... if (speed<255) speed+=INC_SPEED; |
* |
0037: INCFSZ 42,W |
0038: GOTO 03A |
0039: GOTO 03C |
003A: MOVLW 01 |
003B: ADDWF 42,F |
.................... if (rovinka<MAX_ROVINKA) rovinka++; |
003C: MOVF 43,W |
003D: SUBLW 0E |
003E: BTFSC 03.0 |
003F: INCF 43,F |
.................... if (dira<=T_DIRA) dira++; |
0040: MOVF 46,W |
0041: SUBLW 78 |
0042: BTFSC 03.0 |
0043: INCF 46,F |
.................... } |
.................... // Primitivni Pipani |
0044: BCF 0C.1 |
0045: BCF 0A.3 |
0046: GOTO 022 |
.................... void beep(unsigned int16 period, unsigned int16 length) |
.................... { |
.................... unsigned int16 nn; |
.................... |
.................... for(nn=length; nn>0; nn--) |
* |
005C: MOVF 7D,W |
005D: BSF 03.5 |
005E: MOVWF 21 |
005F: MOVF 7C,W |
0060: MOVWF 20 |
0061: MOVF 20,F |
0062: BTFSS 03.2 |
0063: GOTO 067 |
0064: MOVF 21,F |
0065: BTFSC 03.2 |
0066: GOTO 086 |
.................... { |
.................... output_high(SOUND_HI);output_low(SOUND_LO); |
0067: BCF 05.6 |
0068: BCF 03.5 |
0069: BSF 05.6 |
006A: BSF 03.5 |
006B: BCF 05.7 |
006C: BCF 03.5 |
006D: BCF 05.7 |
.................... delay_us(period); |
006E: MOVF 74,W |
006F: BSF 03.5 |
0070: MOVWF 22 |
0071: BCF 03.5 |
0072: CALL 047 |
.................... output_high(SOUND_LO);output_low(SOUND_HI); |
0073: BSF 03.5 |
0074: BCF 05.7 |
0075: BCF 03.5 |
0076: BSF 05.7 |
0077: BSF 03.5 |
0078: BCF 05.6 |
0079: BCF 03.5 |
007A: BCF 05.6 |
.................... delay_us(period); |
007B: MOVF 74,W |
007C: BSF 03.5 |
007D: MOVWF 22 |
007E: BCF 03.5 |
007F: CALL 047 |
.................... } |
0080: BSF 03.5 |
0081: MOVF 20,W |
0082: BTFSC 03.2 |
0083: DECF 21,F |
0084: DECF 20,F |
0085: GOTO 061 |
.................... } |
0086: BCF 03.5 |
0087: RETLW 00 |
.................... /******************************************************************************/ |
.................... void diagnostika() |
.................... { |
.................... unsigned int16 n; |
.................... |
.................... while (input(DIAG_SERVO)) // Propojka, ktera spousti diagnostiku |
.................... { |
* |
009D: BSF 03.5 |
009E: BSF 06.3 |
009F: BCF 03.5 |
00A0: BTFSS 06.3 |
00A1: GOTO 1C8 |
.................... for (n=500; n<800; n+=100) |
00A2: MOVLW 01 |
00A3: MOVWF 72 |
00A4: MOVLW F4 |
00A5: MOVWF 71 |
00A6: MOVF 72,W |
00A7: SUBLW 03 |
00A8: BTFSS 03.0 |
00A9: GOTO 0BE |
00AA: BTFSS 03.2 |
00AB: GOTO 0B0 |
00AC: MOVF 71,W |
00AD: SUBLW 1F |
00AE: BTFSS 03.0 |
00AF: GOTO 0BE |
.................... { |
.................... beep(n,n); //beep UP |
00B0: MOVF 72,W |
00B1: MOVWF 75 |
00B2: MOVF 71,W |
00B3: MOVWF 74 |
00B4: MOVF 72,W |
00B5: MOVWF 7D |
00B6: MOVF 71,W |
00B7: MOVWF 7C |
00B8: CALL 05C |
.................... }; |
00B9: MOVLW 64 |
00BA: ADDWF 71,F |
00BB: BTFSC 03.0 |
00BC: INCF 72,F |
00BD: GOTO 0A6 |
.................... Delay_ms(1000); |
00BE: MOVLW 04 |
00BF: MOVWF 73 |
00C0: MOVLW FA |
00C1: MOVWF 74 |
00C2: CALL 088 |
00C3: DECFSZ 73,F |
00C4: GOTO 0C0 |
.................... //zastav vse |
.................... STOPL; STOPR; |
00C5: BSF 03.5 |
00C6: BCF 06.6 |
00C7: BCF 03.5 |
00C8: BCF 06.6 |
00C9: BSF 03.5 |
00CA: BCF 06.7 |
00CB: BCF 03.5 |
00CC: BCF 06.7 |
00CD: BSF 03.5 |
00CE: BCF 06.4 |
00CF: BCF 03.5 |
00D0: BCF 06.4 |
00D1: BSF 03.5 |
00D2: BCF 06.5 |
00D3: BCF 03.5 |
00D4: BCF 06.5 |
.................... //pravy pas |
.................... FR; Delay_ms(1000); STOPR; Delay_ms(1000); |
00D5: BSF 03.5 |
00D6: BCF 06.5 |
00D7: BCF 03.5 |
00D8: BCF 06.5 |
00D9: BSF 03.5 |
00DA: BCF 06.4 |
00DB: BCF 03.5 |
00DC: BSF 06.4 |
00DD: MOVLW 04 |
00DE: MOVWF 73 |
00DF: MOVLW FA |
00E0: MOVWF 74 |
00E1: CALL 088 |
00E2: DECFSZ 73,F |
00E3: GOTO 0DF |
00E4: BSF 03.5 |
00E5: BCF 06.4 |
00E6: BCF 03.5 |
00E7: BCF 06.4 |
00E8: BSF 03.5 |
00E9: BCF 06.5 |
00EA: BCF 03.5 |
00EB: BCF 06.5 |
00EC: MOVLW 04 |
00ED: MOVWF 73 |
00EE: MOVLW FA |
00EF: MOVWF 74 |
00F0: CALL 088 |
00F1: DECFSZ 73,F |
00F2: GOTO 0EE |
.................... BR; Delay_ms(1000); STOPR; Delay_ms(1000); |
00F3: BSF 03.5 |
00F4: BCF 06.4 |
00F5: BCF 03.5 |
00F6: BCF 06.4 |
00F7: BSF 03.5 |
00F8: BCF 06.5 |
00F9: BCF 03.5 |
00FA: BSF 06.5 |
00FB: MOVLW 04 |
00FC: MOVWF 73 |
00FD: MOVLW FA |
00FE: MOVWF 74 |
00FF: CALL 088 |
0100: DECFSZ 73,F |
0101: GOTO 0FD |
0102: BSF 03.5 |
0103: BCF 06.4 |
0104: BCF 03.5 |
0105: BCF 06.4 |
0106: BSF 03.5 |
0107: BCF 06.5 |
0108: BCF 03.5 |
0109: BCF 06.5 |
010A: MOVLW 04 |
010B: MOVWF 73 |
010C: MOVLW FA |
010D: MOVWF 74 |
010E: CALL 088 |
010F: DECFSZ 73,F |
0110: GOTO 10C |
.................... Beep(880,100); Delay_ms(1000); |
0111: MOVLW 03 |
0112: MOVWF 75 |
0113: MOVLW 70 |
0114: MOVWF 74 |
0115: CLRF 7D |
0116: MOVLW 64 |
0117: MOVWF 7C |
0118: CALL 05C |
0119: MOVLW 04 |
011A: MOVWF 73 |
011B: MOVLW FA |
011C: MOVWF 74 |
011D: CALL 088 |
011E: DECFSZ 73,F |
011F: GOTO 11B |
.................... //levy pas |
.................... FL; Delay_ms(1000); STOPL; Delay_ms(1000); |
0120: BSF 03.5 |
0121: BCF 06.7 |
0122: BCF 03.5 |
0123: BCF 06.7 |
0124: BSF 03.5 |
0125: BCF 06.6 |
0126: BCF 03.5 |
0127: BSF 06.6 |
0128: MOVLW 04 |
0129: MOVWF 73 |
012A: MOVLW FA |
012B: MOVWF 74 |
012C: CALL 088 |
012D: DECFSZ 73,F |
012E: GOTO 12A |
012F: BSF 03.5 |
0130: BCF 06.6 |
0131: BCF 03.5 |
0132: BCF 06.6 |
0133: BSF 03.5 |
0134: BCF 06.7 |
0135: BCF 03.5 |
0136: BCF 06.7 |
0137: MOVLW 04 |
0138: MOVWF 73 |
0139: MOVLW FA |
013A: MOVWF 74 |
013B: CALL 088 |
013C: DECFSZ 73,F |
013D: GOTO 139 |
.................... BL; Delay_ms(1000); STOPL; Delay_ms(1000); |
013E: BSF 03.5 |
013F: BCF 06.6 |
0140: BCF 03.5 |
0141: BCF 06.6 |
0142: BSF 03.5 |
0143: BCF 06.7 |
0144: BCF 03.5 |
0145: BSF 06.7 |
0146: MOVLW 04 |
0147: MOVWF 73 |
0148: MOVLW FA |
0149: MOVWF 74 |
014A: CALL 088 |
014B: DECFSZ 73,F |
014C: GOTO 148 |
014D: BSF 03.5 |
014E: BCF 06.6 |
014F: BCF 03.5 |
0150: BCF 06.6 |
0151: BSF 03.5 |
0152: BCF 06.7 |
0153: BCF 03.5 |
0154: BCF 06.7 |
0155: MOVLW 04 |
0156: MOVWF 73 |
0157: MOVLW FA |
0158: MOVWF 74 |
0159: CALL 088 |
015A: DECFSZ 73,F |
015B: GOTO 157 |
.................... Beep(880,100); Delay_ms(1000); |
015C: MOVLW 03 |
015D: MOVWF 75 |
015E: MOVLW 70 |
015F: MOVWF 74 |
0160: CLRF 7D |
0161: MOVLW 64 |
0162: MOVWF 7C |
0163: CALL 05C |
0164: MOVLW 04 |
0165: MOVWF 73 |
0166: MOVLW FA |
0167: MOVWF 74 |
0168: CALL 088 |
0169: DECFSZ 73,F |
016A: GOTO 166 |
.................... //oba pasy |
.................... FL; FR; Delay_ms(1000); STOPL; STOPR; Delay_ms(1000); |
016B: BSF 03.5 |
016C: BCF 06.7 |
016D: BCF 03.5 |
016E: BCF 06.7 |
016F: BSF 03.5 |
0170: BCF 06.6 |
0171: BCF 03.5 |
0172: BSF 06.6 |
0173: BSF 03.5 |
0174: BCF 06.5 |
0175: BCF 03.5 |
0176: BCF 06.5 |
0177: BSF 03.5 |
0178: BCF 06.4 |
0179: BCF 03.5 |
017A: BSF 06.4 |
017B: MOVLW 04 |
017C: MOVWF 73 |
017D: MOVLW FA |
017E: MOVWF 74 |
017F: CALL 088 |
0180: DECFSZ 73,F |
0181: GOTO 17D |
0182: BSF 03.5 |
0183: BCF 06.6 |
0184: BCF 03.5 |
0185: BCF 06.6 |
0186: BSF 03.5 |
0187: BCF 06.7 |
0188: BCF 03.5 |
0189: BCF 06.7 |
018A: BSF 03.5 |
018B: BCF 06.4 |
018C: BCF 03.5 |
018D: BCF 06.4 |
018E: BSF 03.5 |
018F: BCF 06.5 |
0190: BCF 03.5 |
0191: BCF 06.5 |
0192: MOVLW 04 |
0193: MOVWF 73 |
0194: MOVLW FA |
0195: MOVWF 74 |
0196: CALL 088 |
0197: DECFSZ 73,F |
0198: GOTO 194 |
.................... BL; BR; Delay_ms(1000); STOPL; STOPR; Delay_ms(1000); |
0199: BSF 03.5 |
019A: BCF 06.6 |
019B: BCF 03.5 |
019C: BCF 06.6 |
019D: BSF 03.5 |
019E: BCF 06.7 |
019F: BCF 03.5 |
01A0: BSF 06.7 |
01A1: BSF 03.5 |
01A2: BCF 06.4 |
01A3: BCF 03.5 |
01A4: BCF 06.4 |
01A5: BSF 03.5 |
01A6: BCF 06.5 |
01A7: BCF 03.5 |
01A8: BSF 06.5 |
01A9: MOVLW 04 |
01AA: MOVWF 73 |
01AB: MOVLW FA |
01AC: MOVWF 74 |
01AD: CALL 088 |
01AE: DECFSZ 73,F |
01AF: GOTO 1AB |
01B0: BSF 03.5 |
01B1: BCF 06.6 |
01B2: BCF 03.5 |
01B3: BCF 06.6 |
01B4: BSF 03.5 |
01B5: BCF 06.7 |
01B6: BCF 03.5 |
01B7: BCF 06.7 |
01B8: BSF 03.5 |
01B9: BCF 06.4 |
01BA: BCF 03.5 |
01BB: BCF 06.4 |
01BC: BSF 03.5 |
01BD: BCF 06.5 |
01BE: BCF 03.5 |
01BF: BCF 06.5 |
01C0: MOVLW 04 |
01C1: MOVWF 73 |
01C2: MOVLW FA |
01C3: MOVWF 74 |
01C4: CALL 088 |
01C5: DECFSZ 73,F |
01C6: GOTO 1C2 |
.................... }; |
01C7: GOTO 09D |
.................... while (input(DIAG_SENSORS)) // spusteni diagnostiky cidel |
.................... { |
01C8: BSF 03.5 |
01C9: BSF 06.2 |
01CA: BCF 03.5 |
01CB: BTFSS 06.2 |
01CC: GOTO 1FB |
.................... if (RSENSOR) beep(900,500); |
01CD: BSF 03.5 |
01CE: BTFSS 1C.7 |
01CF: GOTO 1DB |
01D0: MOVLW 03 |
01D1: MOVWF 75 |
01D2: MOVLW 84 |
01D3: MOVWF 74 |
01D4: MOVLW 01 |
01D5: MOVWF 7D |
01D6: MOVLW F4 |
01D7: MOVWF 7C |
01D8: BCF 03.5 |
01D9: CALL 05C |
01DA: BSF 03.5 |
.................... if (LSENSOR) beep(800,500); |
01DB: BTFSS 1C.6 |
01DC: GOTO 1E8 |
01DD: MOVLW 03 |
01DE: MOVWF 75 |
01DF: MOVLW 20 |
01E0: MOVWF 74 |
01E1: MOVLW 01 |
01E2: MOVWF 7D |
01E3: MOVLW F4 |
01E4: MOVWF 7C |
01E5: BCF 03.5 |
01E6: CALL 05C |
01E7: BSF 03.5 |
.................... if ((read_adc(ADC_READ_ONLY)<BUMPER_TRESHOLD)) beep(1000,500); |
01E8: BCF 03.5 |
01E9: BTFSS 1F.2 |
01EA: GOTO 1ED |
01EB: BSF 03.5 |
01EC: GOTO 1E8 |
01ED: MOVF 1E,W |
01EE: SUBLW 7F |
01EF: BTFSS 03.0 |
01F0: GOTO 1FA |
01F1: MOVLW 03 |
01F2: MOVWF 75 |
01F3: MOVLW E8 |
01F4: MOVWF 74 |
01F5: MOVLW 01 |
01F6: MOVWF 7D |
01F7: MOVLW F4 |
01F8: MOVWF 7C |
01F9: CALL 05C |
.................... }; |
01FA: GOTO 1C8 |
.................... } |
01FB: BCF 0A.3 |
01FC: GOTO 520 (RETURN) |
.................... /////////////////////////////////////////////////////////////////////////////// |
.................... void cikcak() |
.................... { |
.................... unsigned int16 n; |
.................... sem1: |
.................... n=CIK_CAK; |
01FD: MOVLW 75 |
01FE: MOVWF 75 |
01FF: MOVLW 30 |
0200: MOVWF 74 |
.................... while (0==RSENSOR||LSENSOR) // zkontroluj caru |
.................... { |
0201: MOVLW 00 |
0202: BSF 03.5 |
0203: BTFSC 1C.7 |
0204: MOVLW 01 |
0205: XORLW 00 |
0206: BTFSC 03.2 |
0207: GOTO 20A |
0208: BTFSS 1C.6 |
0209: GOTO 264 |
.................... if (n==CIK_CAK) // zmen smer zataceni |
020A: MOVF 74,W |
020B: SUBLW 30 |
020C: BTFSS 03.2 |
020D: GOTO 25E |
020E: MOVF 75,W |
020F: SUBLW 75 |
0210: BTFSS 03.2 |
0211: GOTO 25E |
.................... { |
.................... n=0; |
0212: CLRF 75 |
0213: CLRF 74 |
.................... switch(movement) |
.................... { |
0214: BCF 03.5 |
0215: MOVF 45,W |
0216: XORLW 02 |
0217: BTFSC 03.2 |
0218: GOTO 220 |
0219: XORLW 03 |
021A: BTFSC 03.2 |
021B: GOTO 233 |
021C: XORLW 02 |
021D: BTFSC 03.2 |
021E: GOTO 246 |
021F: GOTO 25D |
.................... case L: |
.................... FL;BR; |
0220: BSF 03.5 |
0221: BCF 06.7 |
0222: BCF 03.5 |
0223: BCF 06.7 |
0224: BSF 03.5 |
0225: BCF 06.6 |
0226: BCF 03.5 |
0227: BSF 06.6 |
0228: BSF 03.5 |
0229: BCF 06.4 |
022A: BCF 03.5 |
022B: BCF 06.4 |
022C: BSF 03.5 |
022D: BCF 06.5 |
022E: BCF 03.5 |
022F: BSF 06.5 |
.................... movement=R; |
0230: MOVLW 01 |
0231: MOVWF 45 |
.................... break; |
0232: GOTO 25D |
.................... case R: |
.................... FR;BL; |
0233: BSF 03.5 |
0234: BCF 06.5 |
0235: BCF 03.5 |
0236: BCF 06.5 |
0237: BSF 03.5 |
0238: BCF 06.4 |
0239: BCF 03.5 |
023A: BSF 06.4 |
023B: BSF 03.5 |
023C: BCF 06.6 |
023D: BCF 03.5 |
023E: BCF 06.6 |
023F: BSF 03.5 |
0240: BCF 06.7 |
0241: BCF 03.5 |
0242: BSF 06.7 |
.................... movement=L; |
0243: MOVLW 02 |
0244: MOVWF 45 |
.................... break; |
0245: GOTO 25D |
.................... case S: |
.................... FL;BR; |
0246: BSF 03.5 |
0247: BCF 06.7 |
0248: BCF 03.5 |
0249: BCF 06.7 |
024A: BSF 03.5 |
024B: BCF 06.6 |
024C: BCF 03.5 |
024D: BSF 06.6 |
024E: BSF 03.5 |
024F: BCF 06.4 |
0250: BCF 03.5 |
0251: BCF 06.4 |
0252: BSF 03.5 |
0253: BCF 06.5 |
0254: BCF 03.5 |
0255: BSF 06.5 |
.................... movement=R; |
0256: MOVLW 01 |
0257: MOVWF 45 |
.................... n=CIK_CAK/2; |
0258: MOVLW 3A |
0259: MOVWF 75 |
025A: MOVLW 98 |
025B: MOVWF 74 |
.................... break; |
025C: GOTO 25D |
025D: BSF 03.5 |
.................... } |
.................... } |
.................... n++; |
025E: INCF 74,F |
025F: BTFSC 03.2 |
0260: INCF 75,F |
.................... } |
0261: BCF 03.5 |
0262: GOTO 201 |
0263: BSF 03.5 |
.................... STOPL;STOPR; |
0264: BCF 06.6 |
0265: BCF 03.5 |
0266: BCF 06.6 |
0267: BSF 03.5 |
0268: BCF 06.7 |
0269: BCF 03.5 |
026A: BCF 06.7 |
026B: BSF 03.5 |
026C: BCF 06.4 |
026D: BCF 03.5 |
026E: BCF 06.4 |
026F: BSF 03.5 |
0270: BCF 06.5 |
0271: BCF 03.5 |
0272: BCF 06.5 |
.................... line = RSENSOR; // cteni senzoru na caru |
0273: CLRF 41 |
0274: BSF 03.5 |
0275: BTFSS 1C.7 |
0276: GOTO 27A |
0277: BCF 03.5 |
0278: INCF 41,F |
0279: BSF 03.5 |
.................... line |= LSENSOR << 1; |
027A: MOVLW 00 |
027B: BTFSC 1C.6 |
027C: MOVLW 01 |
027D: MOVWF 77 |
027E: BCF 03.0 |
027F: RLF 77,F |
0280: MOVF 77,W |
0281: BCF 03.5 |
0282: IORWF 41,F |
.................... if (line==0) goto sem1; |
0283: MOVF 41,F |
0284: BTFSC 03.2 |
0285: GOTO 1FD |
.................... // nasli jsme caru |
.................... line=S; |
0286: MOVLW 03 |
0287: MOVWF 41 |
.................... } |
0288: RETLW 00 |
.................... /////////////////////////////////////////////////////////////////////////////// |
.................... void objizdka() // objede cihlu |
.................... { |
.................... unsigned int16 n; |
.................... |
.................... BL;BR;Delay_ms(150); |
0289: BSF 03.5 |
028A: BCF 06.6 |
028B: BCF 03.5 |
028C: BCF 06.6 |
028D: BSF 03.5 |
028E: BCF 06.7 |
028F: BCF 03.5 |
0290: BSF 06.7 |
0291: BSF 03.5 |
0292: BCF 06.4 |
0293: BCF 03.5 |
0294: BCF 06.4 |
0295: BSF 03.5 |
0296: BCF 06.5 |
0297: BCF 03.5 |
0298: BSF 06.5 |
0299: MOVLW 96 |
029A: MOVWF 74 |
029B: CALL 088 |
.................... STOPR;STOPL; |
029C: BSF 03.5 |
029D: BCF 06.4 |
029E: BCF 03.5 |
029F: BCF 06.4 |
02A0: BSF 03.5 |
02A1: BCF 06.5 |
02A2: BCF 03.5 |
02A3: BCF 06.5 |
02A4: BSF 03.5 |
02A5: BCF 06.6 |
02A6: BCF 03.5 |
02A7: BCF 06.6 |
02A8: BSF 03.5 |
02A9: BCF 06.7 |
02AA: BCF 03.5 |
02AB: BCF 06.7 |
.................... beep(900,1000); |
02AC: MOVLW 03 |
02AD: MOVWF 75 |
02AE: MOVLW 84 |
02AF: MOVWF 74 |
02B0: MOVLW 03 |
02B1: MOVWF 7D |
02B2: MOVLW E8 |
02B3: MOVWF 7C |
02B4: CALL 05C |
.................... // movement=S; |
.................... // cikcak(); |
.................... |
.................... BR; FL; Delay_ms(270); // otoc se 70° do prava |
02B5: BSF 03.5 |
02B6: BCF 06.4 |
02B7: BCF 03.5 |
02B8: BCF 06.4 |
02B9: BSF 03.5 |
02BA: BCF 06.5 |
02BB: BCF 03.5 |
02BC: BSF 06.5 |
02BD: BSF 03.5 |
02BE: BCF 06.7 |
02BF: BCF 03.5 |
02C0: BCF 06.7 |
02C1: BSF 03.5 |
02C2: BCF 06.6 |
02C3: BCF 03.5 |
02C4: BSF 06.6 |
02C5: MOVLW 02 |
02C6: MOVWF 73 |
02C7: MOVLW 87 |
02C8: MOVWF 74 |
02C9: CALL 088 |
02CA: DECFSZ 73,F |
02CB: GOTO 2C7 |
.................... |
.................... FR; FL; Delay_ms(500); // popojed rovne |
02CC: BSF 03.5 |
02CD: BCF 06.5 |
02CE: BCF 03.5 |
02CF: BCF 06.5 |
02D0: BSF 03.5 |
02D1: BCF 06.4 |
02D2: BCF 03.5 |
02D3: BSF 06.4 |
02D4: BSF 03.5 |
02D5: BCF 06.7 |
02D6: BCF 03.5 |
02D7: BCF 06.7 |
02D8: BSF 03.5 |
02D9: BCF 06.6 |
02DA: BCF 03.5 |
02DB: BSF 06.6 |
02DC: MOVLW 02 |
02DD: MOVWF 73 |
02DE: MOVLW FA |
02DF: MOVWF 74 |
02E0: CALL 088 |
02E1: DECFSZ 73,F |
02E2: GOTO 2DE |
.................... |
.................... BL; Delay_ms(30); // otoc se 90° do leva |
02E3: BSF 03.5 |
02E4: BCF 06.6 |
02E5: BCF 03.5 |
02E6: BCF 06.6 |
02E7: BSF 03.5 |
02E8: BCF 06.7 |
02E9: BCF 03.5 |
02EA: BSF 06.7 |
02EB: MOVLW 1E |
02EC: MOVWF 74 |
02ED: CALL 088 |
.................... STOPL; FR; Delay_ms(500); |
02EE: BSF 03.5 |
02EF: BCF 06.6 |
02F0: BCF 03.5 |
02F1: BCF 06.6 |
02F2: BSF 03.5 |
02F3: BCF 06.7 |
02F4: BCF 03.5 |
02F5: BCF 06.7 |
02F6: BSF 03.5 |
02F7: BCF 06.5 |
02F8: BCF 03.5 |
02F9: BCF 06.5 |
02FA: BSF 03.5 |
02FB: BCF 06.4 |
02FC: BCF 03.5 |
02FD: BSF 06.4 |
02FE: MOVLW 02 |
02FF: MOVWF 73 |
0300: MOVLW FA |
0301: MOVWF 74 |
0302: CALL 088 |
0303: DECFSZ 73,F |
0304: GOTO 300 |
.................... |
.................... FR; FL; Delay_ms(100); // popojed rovne na slepo |
0305: BSF 03.5 |
0306: BCF 06.5 |
0307: BCF 03.5 |
0308: BCF 06.5 |
0309: BSF 03.5 |
030A: BCF 06.4 |
030B: BCF 03.5 |
030C: BSF 06.4 |
030D: BSF 03.5 |
030E: BCF 06.7 |
030F: BCF 03.5 |
0310: BCF 06.7 |
0311: BSF 03.5 |
0312: BCF 06.6 |
0313: BCF 03.5 |
0314: BSF 06.6 |
0315: MOVLW 64 |
0316: MOVWF 74 |
0317: CALL 088 |
.................... for(n=40000;n>0;n--) // popojed rovne ale kontroluj caru |
0318: MOVLW 9C |
0319: MOVWF 72 |
031A: MOVLW 40 |
031B: MOVWF 71 |
031C: MOVF 71,F |
031D: BTFSS 03.2 |
031E: GOTO 322 |
031F: MOVF 72,F |
0320: BTFSC 03.2 |
0321: GOTO 33E |
.................... { |
.................... line = RSENSOR; // cteni senzoru na caru |
0322: CLRF 41 |
0323: BSF 03.5 |
0324: BTFSS 1C.7 |
0325: GOTO 329 |
0326: BCF 03.5 |
0327: INCF 41,F |
0328: BSF 03.5 |
.................... line |= LSENSOR << 1; |
0329: MOVLW 00 |
032A: BTFSC 1C.6 |
032B: MOVLW 01 |
032C: MOVWF 77 |
032D: BCF 03.0 |
032E: RLF 77,F |
032F: MOVF 77,W |
0330: BCF 03.5 |
0331: IORWF 41,F |
.................... if (line!=0) {Delay_ms(150); break;} |
0332: MOVF 41,F |
0333: BTFSC 03.2 |
0334: GOTO 339 |
0335: MOVLW 96 |
0336: MOVWF 74 |
0337: CALL 088 |
0338: GOTO 33E |
.................... // Delay_ms(1); |
.................... } |
0339: MOVF 71,W |
033A: BTFSC 03.2 |
033B: DECF 72,F |
033C: DECF 71,F |
033D: GOTO 31C |
.................... |
.................... BR; FL; // otoc se 60° do prava |
033E: BSF 03.5 |
033F: BCF 06.4 |
0340: BCF 03.5 |
0341: BCF 06.4 |
0342: BSF 03.5 |
0343: BCF 06.5 |
0344: BCF 03.5 |
0345: BSF 06.5 |
0346: BSF 03.5 |
0347: BCF 06.7 |
0348: BCF 03.5 |
0349: BCF 06.7 |
034A: BSF 03.5 |
034B: BCF 06.6 |
034C: BCF 03.5 |
034D: BSF 06.6 |
.................... for(n=40000;n>0;n--) |
034E: MOVLW 9C |
034F: MOVWF 72 |
0350: MOVLW 40 |
0351: MOVWF 71 |
0352: MOVF 71,F |
0353: BTFSS 03.2 |
0354: GOTO 358 |
0355: MOVF 72,F |
0356: BTFSC 03.2 |
0357: GOTO 370 |
.................... { |
.................... line = RSENSOR; // cteni senzoru na caru |
0358: CLRF 41 |
0359: BSF 03.5 |
035A: BTFSS 1C.7 |
035B: GOTO 35F |
035C: BCF 03.5 |
035D: INCF 41,F |
035E: BSF 03.5 |
.................... line |= LSENSOR << 1; |
035F: MOVLW 00 |
0360: BTFSC 1C.6 |
0361: MOVLW 01 |
0362: MOVWF 77 |
0363: BCF 03.0 |
0364: RLF 77,F |
0365: MOVF 77,W |
0366: BCF 03.5 |
0367: IORWF 41,F |
.................... if (line!=0) break; |
0368: MOVF 41,F |
0369: BTFSS 03.2 |
036A: GOTO 370 |
.................... // Delay_ms(1); |
.................... } |
036B: MOVF 71,W |
036C: BTFSC 03.2 |
036D: DECF 72,F |
036E: DECF 71,F |
036F: GOTO 352 |
.................... STOPR; STOPL; |
0370: BSF 03.5 |
0371: BCF 06.4 |
0372: BCF 03.5 |
0373: BCF 06.4 |
0374: BSF 03.5 |
0375: BCF 06.5 |
0376: BCF 03.5 |
0377: BCF 06.5 |
0378: BSF 03.5 |
0379: BCF 06.6 |
037A: BCF 03.5 |
037B: BCF 06.6 |
037C: BSF 03.5 |
037D: BCF 06.7 |
037E: BCF 03.5 |
037F: BCF 06.7 |
.................... |
.................... movement=L; //R; |
0380: MOVLW 02 |
0381: MOVWF 45 |
.................... cikcak(); |
0382: CALL 1FD |
.................... dira=0; |
0383: CLRF 46 |
.................... } |
0384: BCF 0A.3 |
0385: GOTO 550 (RETURN) |
.................... /////////////////////////////////////////////////////////////////////////////// |
.................... void prejeddiru() // vyresi diru |
.................... { |
.................... unsigned int16 n; |
.................... unsigned int8 speed_dira; |
.................... |
.................... STOPL;STOPR; |
0386: BSF 03.5 |
0387: BCF 06.6 |
0388: BCF 03.5 |
0389: BCF 06.6 |
038A: BSF 03.5 |
038B: BCF 06.7 |
038C: BCF 03.5 |
038D: BCF 06.7 |
038E: BSF 03.5 |
038F: BCF 06.4 |
0390: BCF 03.5 |
0391: BCF 06.4 |
0392: BSF 03.5 |
0393: BCF 06.5 |
0394: BCF 03.5 |
0395: BCF 06.5 |
.................... speed_dira=speed; |
0396: MOVF 42,W |
0397: MOVWF 73 |
.................... beep(1000,500); |
0398: MOVLW 03 |
0399: MOVWF 75 |
039A: MOVLW E8 |
039B: MOVWF 74 |
039C: MOVLW 01 |
039D: MOVWF 7D |
039E: MOVLW F4 |
039F: MOVWF 7C |
03A0: CALL 05C |
.................... switch (movement) //vrat se zpet na caru |
.................... { |
03A1: MOVF 45,W |
03A2: XORLW 02 |
03A3: BTFSC 03.2 |
03A4: GOTO 3AC |
03A5: XORLW 03 |
03A6: BTFSC 03.2 |
03A7: GOTO 3E4 |
03A8: XORLW 02 |
03A9: BTFSC 03.2 |
03AA: GOTO 41C |
03AB: GOTO 41E |
.................... case L: |
.................... for (n=COUVANI;n>0;n--) {GO(R,B,speed_dira); Delay_ms(1);} |
03AC: MOVLW 02 |
03AD: MOVWF 72 |
03AE: MOVLW EE |
03AF: MOVWF 71 |
03B0: MOVF 71,F |
03B1: BTFSS 03.2 |
03B2: GOTO 3B6 |
03B3: MOVF 72,F |
03B4: BTFSC 03.2 |
03B5: GOTO 3D3 |
03B6: MOVF 01,W |
03B7: SUBWF 73,W |
03B8: BTFSS 03.0 |
03B9: GOTO 3C3 |
03BA: BSF 03.5 |
03BB: BCF 06.4 |
03BC: BCF 03.5 |
03BD: BCF 06.4 |
03BE: BSF 03.5 |
03BF: BCF 06.5 |
03C0: BCF 03.5 |
03C1: BSF 06.5 |
03C2: GOTO 3CB |
03C3: BSF 03.5 |
03C4: BCF 06.4 |
03C5: BCF 03.5 |
03C6: BCF 06.4 |
03C7: BSF 03.5 |
03C8: BCF 06.5 |
03C9: BCF 03.5 |
03CA: BCF 06.5 |
03CB: MOVLW 01 |
03CC: MOVWF 74 |
03CD: CALL 088 |
03CE: MOVF 71,W |
03CF: BTFSC 03.2 |
03D0: DECF 72,F |
03D1: DECF 71,F |
03D2: GOTO 3B0 |
.................... STOPL;STOPR; |
03D3: BSF 03.5 |
03D4: BCF 06.6 |
03D5: BCF 03.5 |
03D6: BCF 06.6 |
03D7: BSF 03.5 |
03D8: BCF 06.7 |
03D9: BCF 03.5 |
03DA: BCF 06.7 |
03DB: BSF 03.5 |
03DC: BCF 06.4 |
03DD: BCF 03.5 |
03DE: BCF 06.4 |
03DF: BSF 03.5 |
03E0: BCF 06.5 |
03E1: BCF 03.5 |
03E2: BCF 06.5 |
.................... break; |
03E3: GOTO 41E |
.................... case R: |
.................... for (n=COUVANI;n>0;n--) {GO(L,B,speed_dira); Delay_ms(1);} |
03E4: MOVLW 02 |
03E5: MOVWF 72 |
03E6: MOVLW EE |
03E7: MOVWF 71 |
03E8: MOVF 71,F |
03E9: BTFSS 03.2 |
03EA: GOTO 3EE |
03EB: MOVF 72,F |
03EC: BTFSC 03.2 |
03ED: GOTO 40B |
03EE: MOVF 01,W |
03EF: SUBWF 73,W |
03F0: BTFSS 03.0 |
03F1: GOTO 3FB |
03F2: BSF 03.5 |
03F3: BCF 06.6 |
03F4: BCF 03.5 |
03F5: BCF 06.6 |
03F6: BSF 03.5 |
03F7: BCF 06.7 |
03F8: BCF 03.5 |
03F9: BSF 06.7 |
03FA: GOTO 403 |
03FB: BSF 03.5 |
03FC: BCF 06.6 |
03FD: BCF 03.5 |
03FE: BCF 06.6 |
03FF: BSF 03.5 |
0400: BCF 06.7 |
0401: BCF 03.5 |
0402: BCF 06.7 |
0403: MOVLW 01 |
0404: MOVWF 74 |
0405: CALL 088 |
0406: MOVF 71,W |
0407: BTFSC 03.2 |
0408: DECF 72,F |
0409: DECF 71,F |
040A: GOTO 3E8 |
.................... STOPL;STOPR; |
040B: BSF 03.5 |
040C: BCF 06.6 |
040D: BCF 03.5 |
040E: BCF 06.6 |
040F: BSF 03.5 |
0410: BCF 06.7 |
0411: BCF 03.5 |
0412: BCF 06.7 |
0413: BSF 03.5 |
0414: BCF 06.4 |
0415: BCF 03.5 |
0416: BCF 06.4 |
0417: BSF 03.5 |
0418: BCF 06.5 |
0419: BCF 03.5 |
041A: BCF 06.5 |
.................... break; |
041B: GOTO 41E |
.................... case S: |
.................... goto sem; |
041C: GOTO 45C |
.................... break; |
041D: GOTO 41E |
.................... } |
.................... beep(1000,500); |
041E: MOVLW 03 |
041F: MOVWF 75 |
0420: MOVLW E8 |
0421: MOVWF 74 |
0422: MOVLW 01 |
0423: MOVWF 7D |
0424: MOVLW F4 |
0425: MOVWF 7C |
0426: CALL 05C |
.................... |
.................... /*line=0; |
.................... FR; BL; Delay_ms(400); // otoc se na caru |
.................... beep(1000,500); |
.................... while(line==0) |
.................... { |
.................... line = RSENSOR; // cteni senzoru na caru |
.................... line |= LSENSOR << 1; |
.................... } |
.................... FL;BR; Delay_ms(60); // zabrzdi |
.................... STOPL; STOPR; |
.................... |
.................... FL; BR; Delay_ms(700); // otacka 180 deg |
.................... STOPL; STOPR;*/ |
.................... |
.................... FR;FL; //popojed rovne |
0427: BSF 03.5 |
0428: BCF 06.5 |
0429: BCF 03.5 |
042A: BCF 06.5 |
042B: BSF 03.5 |
042C: BCF 06.4 |
042D: BCF 03.5 |
042E: BSF 06.4 |
042F: BSF 03.5 |
0430: BCF 06.7 |
0431: BCF 03.5 |
0432: BCF 06.7 |
0433: BSF 03.5 |
0434: BCF 06.6 |
0435: BCF 03.5 |
0436: BSF 06.6 |
.................... for(n=PRES_DIRU;n>0;n--) |
0437: MOVLW 01 |
0438: MOVWF 72 |
0439: MOVLW 2C |
043A: MOVWF 71 |
043B: MOVF 71,F |
043C: BTFSS 03.2 |
043D: GOTO 441 |
043E: MOVF 72,F |
043F: BTFSC 03.2 |
0440: GOTO 45C |
.................... { |
.................... line = RSENSOR; // cteni senzoru na caru |
0441: CLRF 41 |
0442: BSF 03.5 |
0443: BTFSS 1C.7 |
0444: GOTO 448 |
0445: BCF 03.5 |
0446: INCF 41,F |
0447: BSF 03.5 |
.................... line |= LSENSOR << 1; |
0448: MOVLW 00 |
0449: BTFSC 1C.6 |
044A: MOVLW 01 |
044B: MOVWF 77 |
044C: BCF 03.0 |
044D: RLF 77,F |
044E: MOVF 77,W |
044F: BCF 03.5 |
0450: IORWF 41,F |
.................... if (line!=0) break; |
0451: MOVF 41,F |
0452: BTFSS 03.2 |
0453: GOTO 45C |
.................... Delay_ms(1); |
0454: MOVLW 01 |
0455: MOVWF 74 |
0456: CALL 088 |
.................... } |
0457: MOVF 71,W |
0458: BTFSC 03.2 |
0459: DECF 72,F |
045A: DECF 71,F |
045B: GOTO 43B |
.................... sem: |
.................... STOPL; STOPR; |
045C: BSF 03.5 |
045D: BCF 06.6 |
045E: BCF 03.5 |
045F: BCF 06.6 |
0460: BSF 03.5 |
0461: BCF 06.7 |
0462: BCF 03.5 |
0463: BCF 06.7 |
0464: BSF 03.5 |
0465: BCF 06.4 |
0466: BCF 03.5 |
0467: BCF 06.4 |
0468: BSF 03.5 |
0469: BCF 06.5 |
046A: BCF 03.5 |
046B: BCF 06.5 |
.................... movement=S; |
046C: MOVLW 03 |
046D: MOVWF 45 |
.................... cikcak(); // najdi caru |
046E: CALL 1FD |
.................... dira=0; |
046F: CLRF 46 |
.................... } |
0470: BCF 0A.3 |
0471: GOTO 5E6 (RETURN) |
.................... /////////////////////////////////////////////////////////////////////////////// |
.................... void main() |
.................... { |
0472: CLRF 04 |
0473: MOVLW 1F |
0474: ANDWF 03,F |
0475: BSF 03.5 |
0476: BCF 1F.4 |
0477: BCF 1F.5 |
0478: MOVF 1B,W |
0479: ANDLW 80 |
047A: MOVWF 1B |
047B: MOVLW 07 |
047C: MOVWF 1C |
047D: MOVF 1C,W |
047E: BCF 03.5 |
047F: BCF 0D.6 |
0480: MOVLW 60 |
0481: BSF 03.5 |
0482: MOVWF 0F |
.................... unsigned int16 n; // pro FOR |
.................... |
.................... STOPL; STOPR; // prepne vystupy na ovladani motoru na output a zastavi |
* |
049F: BSF 03.5 |
04A0: BCF 06.6 |
04A1: BCF 03.5 |
04A2: BCF 06.6 |
04A3: BSF 03.5 |
04A4: BCF 06.7 |
04A5: BCF 03.5 |
04A6: BCF 06.7 |
04A7: BSF 03.5 |
04A8: BCF 06.4 |
04A9: BCF 03.5 |
04AA: BCF 06.4 |
04AB: BSF 03.5 |
04AC: BCF 06.5 |
04AD: BCF 03.5 |
04AE: BCF 06.5 |
.................... |
.................... setup_oscillator(OSC_4MHZ|OSC_INTRC); // 4 MHz interni RC oscilator |
04AF: MOVLW 62 |
04B0: BSF 03.5 |
04B1: MOVWF 0F |
.................... |
.................... port_b_pullups(TRUE); // pullups pro piano na diagnostiku |
04B2: BCF 01.7 |
.................... setup_spi(FALSE); |
04B3: BCF 03.5 |
04B4: BCF 14.5 |
04B5: BSF 03.5 |
04B6: BCF 06.2 |
04B7: BSF 06.1 |
04B8: BCF 06.4 |
04B9: MOVLW 00 |
04BA: BCF 03.5 |
04BB: MOVWF 14 |
04BC: BSF 03.5 |
04BD: MOVWF 14 |
.................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); // Casovac pro PWM |
04BE: MOVF 01,W |
04BF: ANDLW C7 |
04C0: IORLW 08 |
04C1: MOVWF 01 |
.................... |
.................... setup_timer_2(T2_DIV_BY_4,255,10); // Casovac pro regulaci |
04C2: MOVLW 48 |
04C3: MOVWF 78 |
04C4: IORLW 05 |
04C5: BCF 03.5 |
04C6: MOVWF 12 |
04C7: MOVLW FF |
04C8: BSF 03.5 |
04C9: MOVWF 12 |
.................... // preruseni kazdych 10ms |
.................... setup_adc_ports(sAN2|VSS_VDD); // nastaveni A/D prevodniku pro naraznik |
04CA: BCF 1F.4 |
04CB: BCF 1F.5 |
04CC: MOVF 1B,W |
04CD: ANDLW 80 |
04CE: IORLW 04 |
04CF: MOVWF 1B |
.................... setup_adc(ADC_CLOCK_INTERNAL); |
04D0: BCF 1F.6 |
04D1: BCF 03.5 |
04D2: BSF 1F.6 |
04D3: BSF 1F.7 |
04D4: BSF 03.5 |
04D5: BCF 1F.7 |
04D6: BCF 03.5 |
04D7: BSF 1F.0 |
.................... set_adc_channel(2); |
04D8: MOVLW 10 |
04D9: MOVWF 78 |
04DA: MOVF 1F,W |
04DB: ANDLW C7 |
04DC: IORWF 78,W |
04DD: MOVWF 1F |
.................... setup_timer_1(T1_INTERNAL|T1_DIV_BY_1); // Casovac pro naraznik |
04DE: MOVLW 85 |
04DF: MOVWF 10 |
.................... setup_ccp1(CCP_COMPARE_RESET_TIMER); |
04E0: BSF 03.5 |
04E1: BSF 06.3 |
04E2: MOVLW 0B |
04E3: BCF 03.5 |
04E4: MOVWF 17 |
.................... CCP_1=(2^10)-1; // prevod kazdou 1ms |
04E5: CLRF 16 |
04E6: MOVLW 07 |
04E7: MOVWF 15 |
.................... |
.................... setup_comparator(A0_VR_A1_VR); // inicializace komparatoru pro cidla cary |
04E8: MOVLW 02 |
04E9: BSF 03.5 |
04EA: MOVWF 1C |
04EB: MOVF 05,W |
04EC: IORLW 03 |
04ED: MOVWF 05 |
04EE: MOVLW 03 |
04EF: MOVWF 77 |
04F0: DECFSZ 77,F |
04F1: GOTO 4F0 |
04F2: MOVF 1C,W |
04F3: BCF 03.5 |
04F4: BCF 0D.6 |
.................... setup_vref(VREF_HIGH|TRESHOLD); // 32 kroku od 0.25 do 0.75 Vdd |
04F5: MOVLW 86 |
04F6: BSF 03.5 |
04F7: MOVWF 1D |
.................... |
.................... Beep(1000,200); //double beep |
04F8: MOVLW 03 |
04F9: MOVWF 75 |
04FA: MOVLW E8 |
04FB: MOVWF 74 |
04FC: CLRF 7D |
04FD: MOVLW C8 |
04FE: MOVWF 7C |
04FF: BCF 03.5 |
0500: CALL 05C |
.................... Delay_ms(50); |
0501: MOVLW 32 |
0502: MOVWF 74 |
0503: CALL 088 |
.................... Beep(1000,200); |
0504: MOVLW 03 |
0505: MOVWF 75 |
0506: MOVLW E8 |
0507: MOVWF 74 |
0508: CLRF 7D |
0509: MOVLW C8 |
050A: MOVWF 7C |
050B: CALL 05C |
.................... Delay_ms(1000); // 1s |
050C: MOVLW 04 |
050D: MOVWF 71 |
050E: MOVLW FA |
050F: MOVWF 74 |
0510: CALL 088 |
0511: DECFSZ 71,F |
0512: GOTO 50E |
.................... |
.................... // povoleni rizeni rychlosti zataceni pres preruseni |
.................... enable_interrupts(INT_TIMER2); |
0513: BSF 03.5 |
0514: BSF 0C.1 |
.................... enable_interrupts(GLOBAL); |
0515: MOVLW C0 |
0516: BCF 03.5 |
0517: IORWF 0B,F |
.................... |
.................... /*---------------------------------------------------------------------------*/ |
.................... sensors=S; |
0518: MOVLW 03 |
0519: MOVWF 40 |
.................... line=S; |
051A: MOVWF 41 |
.................... last=S; |
051B: MOVWF 44 |
.................... movement=S; |
051C: MOVWF 45 |
.................... speed=FW_POMALU; |
051D: MOVLW E6 |
051E: MOVWF 42 |
.................... |
.................... diagnostika(); |
051F: GOTO 09D |
.................... //cikcak(); // toc se, abys nasel caru |
.................... Delay_ms(500); |
0520: MOVLW 02 |
0521: MOVWF 71 |
0522: MOVLW FA |
0523: MOVWF 74 |
0524: CALL 088 |
0525: DECFSZ 71,F |
0526: GOTO 522 |
.................... Beep(1000,200); |
0527: MOVLW 03 |
0528: MOVWF 75 |
0529: MOVLW E8 |
052A: MOVWF 74 |
052B: CLRF 7D |
052C: MOVLW C8 |
052D: MOVWF 7C |
052E: CALL 05C |
.................... Delay_ms(500); |
052F: MOVLW 02 |
0530: MOVWF 71 |
0531: MOVLW FA |
0532: MOVWF 74 |
0533: CALL 088 |
0534: DECFSZ 71,F |
0535: GOTO 531 |
.................... |
.................... while(true) // hlavni smycka (jizda podle cary) |
.................... { |
.................... sensors = RSENSOR; // cteni senzoru na caru |
0536: CLRF 40 |
0537: BSF 03.5 |
0538: BTFSS 1C.7 |
0539: GOTO 53D |
053A: BCF 03.5 |
053B: INCF 40,F |
053C: BSF 03.5 |
.................... sensors |= LSENSOR << 1; |
053D: MOVLW 00 |
053E: BTFSC 1C.6 |
053F: MOVLW 01 |
0540: MOVWF 77 |
0541: BCF 03.0 |
0542: RLF 77,F |
0543: MOVF 77,W |
0544: BCF 03.5 |
0545: IORWF 40,F |
.................... |
.................... if ((read_adc(ADC_READ_ONLY)<BUMPER_TRESHOLD) && (dira<=T_CIHLA)) objizdka(); |
0546: BTFSC 1F.2 |
0547: GOTO 546 |
0548: MOVF 1E,W |
0549: SUBLW 7F |
054A: BTFSS 03.0 |
054B: GOTO 550 |
054C: MOVF 46,W |
054D: SUBLW 32 |
054E: BTFSC 03.0 |
054F: GOTO 289 |
.................... |
.................... switch (sensors) // zatacej podle toho, kde vidis caru |
.................... { |
0550: MOVF 40,W |
0551: XORLW 03 |
0552: BTFSC 03.2 |
0553: GOTO 55B |
0554: XORLW 01 |
0555: BTFSC 03.2 |
0556: GOTO 56F |
0557: XORLW 03 |
0558: BTFSC 03.2 |
0559: GOTO 5A8 |
055A: GOTO 5E1 |
.................... case S: // rovne |
.................... FL; FR; // pokud se jede dlouho rovne, tak pridej |
055B: BSF 03.5 |
055C: BCF 06.7 |
055D: BCF 03.5 |
055E: BCF 06.7 |
055F: BSF 03.5 |
0560: BCF 06.6 |
0561: BCF 03.5 |
0562: BSF 06.6 |
0563: BSF 03.5 |
0564: BCF 06.5 |
0565: BCF 03.5 |
0566: BCF 06.5 |
0567: BSF 03.5 |
0568: BCF 06.4 |
0569: BCF 03.5 |
056A: BSF 06.4 |
.................... dira=0; |
056B: CLRF 46 |
.................... movement=S; |
056C: MOVLW 03 |
056D: MOVWF 45 |
.................... continue; |
056E: GOTO 536 |
.................... case L: // trochu vlevo |
.................... GO(L, F, FW_POMALU+rovinka); GO(R, F, FW_STREDNE+rovinka); |
056F: MOVF 01,W |
0570: MOVWF 71 |
0571: MOVLW E6 |
0572: ADDWF 43,W |
0573: SUBWF 71,W |
0574: BTFSC 03.2 |
0575: GOTO 578 |
0576: BTFSC 03.0 |
0577: GOTO 581 |
0578: BSF 03.5 |
0579: BCF 06.7 |
057A: BCF 03.5 |
057B: BCF 06.7 |
057C: BSF 03.5 |
057D: BCF 06.6 |
057E: BCF 03.5 |
057F: BSF 06.6 |
0580: GOTO 589 |
0581: BSF 03.5 |
0582: BCF 06.6 |
0583: BCF 03.5 |
0584: BCF 06.6 |
0585: BSF 03.5 |
0586: BCF 06.7 |
0587: BCF 03.5 |
0588: BCF 06.7 |
0589: MOVF 01,W |
058A: MOVWF 71 |
058B: MOVLW F0 |
058C: ADDWF 43,W |
058D: SUBWF 71,W |
058E: BTFSC 03.2 |
058F: GOTO 592 |
0590: BTFSC 03.0 |
0591: GOTO 59B |
0592: BSF 03.5 |
0593: BCF 06.5 |
0594: BCF 03.5 |
0595: BCF 06.5 |
0596: BSF 03.5 |
0597: BCF 06.4 |
0598: BCF 03.5 |
0599: BSF 06.4 |
059A: GOTO 5A3 |
059B: BSF 03.5 |
059C: BCF 06.4 |
059D: BCF 03.5 |
059E: BCF 06.4 |
059F: BSF 03.5 |
05A0: BCF 06.5 |
05A1: BCF 03.5 |
05A2: BCF 06.5 |
.................... line=L; |
05A3: MOVLW 02 |
05A4: MOVWF 41 |
.................... dira=0; |
05A5: CLRF 46 |
.................... movement=L; |
05A6: MOVWF 45 |
.................... continue; |
05A7: GOTO 536 |
.................... case R: // trochu vpravo |
.................... GO(R, F, FW_POMALU+rovinka); GO(L, F, FW_STREDNE+rovinka); |
05A8: MOVF 01,W |
05A9: MOVWF 71 |
05AA: MOVLW E6 |
05AB: ADDWF 43,W |
05AC: SUBWF 71,W |
05AD: BTFSC 03.2 |
05AE: GOTO 5B1 |
05AF: BTFSC 03.0 |
05B0: GOTO 5BA |
05B1: BSF 03.5 |
05B2: BCF 06.5 |
05B3: BCF 03.5 |
05B4: BCF 06.5 |
05B5: BSF 03.5 |
05B6: BCF 06.4 |
05B7: BCF 03.5 |
05B8: BSF 06.4 |
05B9: GOTO 5C2 |
05BA: BSF 03.5 |
05BB: BCF 06.4 |
05BC: BCF 03.5 |
05BD: BCF 06.4 |
05BE: BSF 03.5 |
05BF: BCF 06.5 |
05C0: BCF 03.5 |
05C1: BCF 06.5 |
05C2: MOVF 01,W |
05C3: MOVWF 71 |
05C4: MOVLW F0 |
05C5: ADDWF 43,W |
05C6: SUBWF 71,W |
05C7: BTFSC 03.2 |
05C8: GOTO 5CB |
05C9: BTFSC 03.0 |
05CA: GOTO 5D4 |
05CB: BSF 03.5 |
05CC: BCF 06.7 |
05CD: BCF 03.5 |
05CE: BCF 06.7 |
05CF: BSF 03.5 |
05D0: BCF 06.6 |
05D1: BCF 03.5 |
05D2: BSF 06.6 |
05D3: GOTO 5DC |
05D4: BSF 03.5 |
05D5: BCF 06.6 |
05D6: BCF 03.5 |
05D7: BCF 06.6 |
05D8: BSF 03.5 |
05D9: BCF 06.7 |
05DA: BCF 03.5 |
05DB: BCF 06.7 |
.................... line=R; |
05DC: MOVLW 01 |
05DD: MOVWF 41 |
.................... dira=0; |
05DE: CLRF 46 |
.................... movement=R; |
05DF: MOVWF 45 |
.................... continue; |
05E0: GOTO 536 |
.................... default: // kdyz jsou obe cidla mimo caru, tak pokracuj dal |
.................... } |
.................... rovinka=0; |
05E1: CLRF 43 |
.................... if (dira>=T_DIRA) prejeddiru(); |
05E2: MOVF 46,W |
05E3: SUBLW 77 |
05E4: BTFSS 03.0 |
05E5: GOTO 386 |
.................... if (last!=line) // pokud si prejel caru z jedne strany na druhou stranu, tak zabrzdi |
05E6: MOVF 41,W |
05E7: SUBWF 44,W |
05E8: BTFSC 03.2 |
05E9: GOTO 5EE |
.................... { |
.................... last=line; |
05EA: MOVF 41,W |
05EB: MOVWF 44 |
.................... speed=FW_ZATACKA; |
05EC: MOVLW F0 |
05ED: MOVWF 42 |
.................... } |
.................... if (L==line) // kdyz jsou obe cidla mimo caru, zatoc na caru |
05EE: MOVF 41,W |
05EF: SUBLW 02 |
05F0: BTFSS 03.2 |
05F1: GOTO 612 |
.................... { |
.................... STOPL; |
05F2: BSF 03.5 |
05F3: BCF 06.6 |
05F4: BCF 03.5 |
05F5: BCF 06.6 |
05F6: BSF 03.5 |
05F7: BCF 06.7 |
05F8: BCF 03.5 |
05F9: BCF 06.7 |
.................... GO(R, F, speed); |
05FA: MOVF 01,W |
05FB: SUBWF 42,W |
05FC: BTFSS 03.0 |
05FD: GOTO 607 |
05FE: BSF 03.5 |
05FF: BCF 06.5 |
0600: BCF 03.5 |
0601: BCF 06.5 |
0602: BSF 03.5 |
0603: BCF 06.4 |
0604: BCF 03.5 |
0605: BSF 06.4 |
0606: GOTO 60F |
0607: BSF 03.5 |
0608: BCF 06.4 |
0609: BCF 03.5 |
060A: BCF 06.4 |
060B: BSF 03.5 |
060C: BCF 06.5 |
060D: BCF 03.5 |
060E: BCF 06.5 |
.................... movement=L; |
060F: MOVLW 02 |
0610: MOVWF 45 |
.................... } |
.................... else |
0611: GOTO 631 |
.................... { |
.................... STOPR; |
0612: BSF 03.5 |
0613: BCF 06.4 |
0614: BCF 03.5 |
0615: BCF 06.4 |
0616: BSF 03.5 |
0617: BCF 06.5 |
0618: BCF 03.5 |
0619: BCF 06.5 |
.................... GO(L, F, speed); |
061A: MOVF 01,W |
061B: SUBWF 42,W |
061C: BTFSS 03.0 |
061D: GOTO 627 |
061E: BSF 03.5 |
061F: BCF 06.7 |
0620: BCF 03.5 |
0621: BCF 06.7 |
0622: BSF 03.5 |
0623: BCF 06.6 |
0624: BCF 03.5 |
0625: BSF 06.6 |
0626: GOTO 62F |
0627: BSF 03.5 |
0628: BCF 06.6 |
0629: BCF 03.5 |
062A: BCF 06.6 |
062B: BSF 03.5 |
062C: BCF 06.7 |
062D: BCF 03.5 |
062E: BCF 06.7 |
.................... movement=R; |
062F: MOVLW 01 |
0630: MOVWF 45 |
.................... } |
.................... } // while(true) |
0631: GOTO 536 |
.................... } |
.................... |
.................... |
0632: SLEEP |
Configuration Fuses: |
Word 1: 3F38 NOWDT NOPUT MCLR NOBROWNOUT NOLVP NOCPD NOWRT NODEBUG CCPB0 NOPROTECT INTRC_IO |
Word 2: 3FFC NOFCMEN NOIESO |
/Designs/ROBOTS/Merkur/SW/turn_R/tank.PJT |
---|
0,0 → 1,40 |
[PROJECT] |
Target=tank.HEX |
Development_Mode= |
Processor=0x688F |
ToolSuite=CCS |
[Directories] |
Include=C:\Program Files\PICC\devices\;C:\Program Files\PICC\drivers\;C:\library\CCS; |
Library= |
LinkerScript= |
[Target Data] |
FileList=tank.c; |
BuildTool=C-COMPILER |
OptionString=+FM |
AdditionalOptionString= |
BuildRequired=1 |
[tank.c] |
Type=4 |
Path= |
FileList= |
BuildTool= |
OptionString= |
AdditionalOptionString= |
[mru-list] |
1=tank.c |
[Windows] |
0=0000 tank.c 0 0 796 451 3 0 |
[Opened Files] |
1=D:\KAKLIK\programy\PIC_C\roboti\merkur\PIC16F88\turn_R\tank.c |
2=C:\Program Files\PICC\devices\16F88.h |
3= |
4=C:\Program Files\PICC\devices\16F88.h |
5= |
6= |
7= |
/Designs/ROBOTS/Merkur/SW/turn_R/tank.SYM |
---|
0,0 → 1,88 |
003 STATUS |
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-038 SendData |
039.0 bit |
03A fcslo |
03B fcshi |
03C stuff |
03D flag_flag |
03E fcs_flag |
03F i |
040 sensors |
041 line |
042 speed |
043 rovinka |
044 last |
045 movement |
046 dira |
047-06E AXstring |
06F-070 main.n |
071-072 objizdka.n |
071-072 diagnostika.n |
071-072 prejeddiru.n |
071 main.@SCRATCH |
073 prejeddiru.speed_dira |
073 diagnostika.@SCRATCH |
073 objizdka.@SCRATCH |
074-075 beep.period |
074 @delay_ms1.P1 |
074-075 cikcak.n |
074 prejeddiru.@SCRATCH |
076 cikcak.@SCRATCH |
077 @SCRATCH |
078 @SCRATCH |
078 _RETURN_ |
079 @SCRATCH |
07A @SCRATCH |
07B @SCRATCH |
07C-07D beep.length |
09C.6 C1OUT |
09C.7 C2OUT |
0A0-0A1 beep.nn |
0A2 @delay_us1.P1 |
0088 @delay_ms1 |
0047 @delay_us1 |
0037 TIMER2_isr |
005C beep |
009D diagnostika |
01FD cikcak |
0289 objizdka |
0386 prejeddiru |
0472 main |
0472 @cinit |
01FD sem1 |
045C sem |
Project Files: |
D:\KAKLIK\programy\PIC_C\roboti\merkur\PIC16F88\turn_R\tank.c |
D:\KAKLIK\programy\PIC_C\roboti\merkur\PIC16F88\turn_R\tank.h |
C:\Program Files\PICC\devices\16F88.h |
D:\KAKLIK\programy\PIC_C\roboti\merkur\PIC16F88\turn_R\AX25.c |
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\merkur\PIC16F88\turn_R\tank.err |
INHX8: D:\KAKLIK\programy\PIC_C\roboti\merkur\PIC16F88\turn_R\tank.HEX |
Symbols: D:\KAKLIK\programy\PIC_C\roboti\merkur\PIC16F88\turn_R\tank.SYM |
List: D:\KAKLIK\programy\PIC_C\roboti\merkur\PIC16F88\turn_R\tank.LST |
Debug/COFF: D:\KAKLIK\programy\PIC_C\roboti\merkur\PIC16F88\turn_R\tank.cof |
Call Tree: D:\KAKLIK\programy\PIC_C\roboti\merkur\PIC16F88\turn_R\tank.tre |
Statistics: D:\KAKLIK\programy\PIC_C\roboti\merkur\PIC16F88\turn_R\tank.sta |
/Designs/ROBOTS/Merkur/SW/turn_R/tank.c |
---|
0,0 → 1,339 |
#include "tank.h" |
#define DEBUG |
#define TXo PIN_A3 // To the transmitter modulator |
#include "AX25.c" // podprogram pro prenos telemetrie |
unsigned int8 sensors; // pomocna promenna pro cteni cidel na caru |
unsigned int8 line; // na ktere strane byla detekovana cara |
unsigned int8 speed; // rychlost zataceni |
unsigned int8 rovinka; // pocitadlo pro zjisteni rovneho useku |
unsigned int8 last; // kde byla cara, kdyz byly minule cidla mimo |
unsigned int8 movement; // obsahuje aktualni smer zataceni |
unsigned int8 dira; // pocita dobu po kterou je ztracena cara |
// Konstanty pro dynamiku pohybu |
#define T_DIRA 120 // po jakem case zataceni se detekuje dira |
#define INC_SPEED 1 // prirustek rychlosti v jednom kroku |
#define FW_POMALU 230 // trochu mimo caru vnitrni pas |
#define FW_ZATACKA 240 // rychlost vnejsiho kola pri zataceni |
#define FW_STREDNE 240 // trochu mimo caru vnejsi pas |
#define COUVANI 750 // couvnuti zpet na caru, po detekci diry |
#define PRES_DIRU 300 |
#define MAX_ROVINKA (255-FW_STREDNE) |
#define TRESHOLD 6 // rozhodovaci uroven komparatoru, 0xF = 0.75*Vdd |
#define BUMPER_TRESHOLD 128 |
#define CIK_CAK 30000 |
#define T_CIHLA 50 // perioda detekce cihly |
//motory //Napred vypnout potom zapnout! |
#define FR output_low(PIN_B5); output_high(PIN_B4) // Vpred |
#define FL output_low(PIN_B7); output_high(PIN_B6) |
#define BR output_low(PIN_B4); output_high(PIN_B5) // Vzad |
#define BL output_low(PIN_B6); output_high(PIN_B7) |
#define STOPR output_low(PIN_B4);output_low(PIN_B5) // Zastav |
#define STOPL output_low(PIN_B6);output_low(PIN_B7) |
#define L 0b10 // left |
#define R 0b01 // right |
#define S 0b11 // straight |
//cidla |
#define RSENSOR C2OUT // Senzory na caru |
#define LSENSOR C1OUT |
#define BUMPER PIN_A4 // Senzor na cihlu |
#define DIAG_SERVO PIN_B3 // Propojka pro diagnosticky mod |
#define DIAG_SENSORS PIN_B2 // Propojka pro diagnosticky mod |
#DEFINE SOUND_HI PIN_A6 // komplementarni vystupy pro piezo pipak |
#DEFINE SOUND_LO PIN_A7 |
char AXstring[40]; // Buffer pro prenos telemetrie |
// makro pro PWM |
#define GO(motor, direction, power) if(get_timer0()<=power) \ |
{direction##motor;} else {stop##motor;} |
#int_TIMER2 |
void TIMER2_isr() |
{ |
if (speed<255) speed+=INC_SPEED; |
if (rovinka<MAX_ROVINKA) rovinka++; |
if (dira<=T_DIRA) dira++; |
} |
// Primitivni Pipani |
void beep(unsigned int16 period, unsigned int16 length) |
{ |
unsigned int16 nn; |
for(nn=length; nn>0; nn--) |
{ |
output_high(SOUND_HI);output_low(SOUND_LO); |
delay_us(period); |
output_high(SOUND_LO);output_low(SOUND_HI); |
delay_us(period); |
} |
} |
/******************************************************************************/ |
void diagnostika() |
{ |
unsigned int16 n; |
while (input(DIAG_SERVO)) // Propojka, ktera spousti diagnostiku |
{ |
for (n=500; n<800; n+=100) |
{ |
beep(n,n); //beep UP |
}; |
Delay_ms(1000); |
//zastav vse |
STOPL; STOPR; |
//pravy pas |
FR; Delay_ms(1000); STOPR; Delay_ms(1000); |
BR; Delay_ms(1000); STOPR; Delay_ms(1000); |
Beep(880,100); Delay_ms(1000); |
//levy pas |
FL; Delay_ms(1000); STOPL; Delay_ms(1000); |
BL; Delay_ms(1000); STOPL; Delay_ms(1000); |
Beep(880,100); Delay_ms(1000); |
//oba pasy |
FL; FR; Delay_ms(1000); STOPL; STOPR; Delay_ms(1000); |
BL; BR; Delay_ms(1000); STOPL; STOPR; Delay_ms(1000); |
}; |
while (input(DIAG_SENSORS)) // spusteni diagnostiky cidel |
{ |
if (RSENSOR) beep(900,500); |
if (LSENSOR) beep(800,500); |
if ((read_adc(ADC_READ_ONLY)<BUMPER_TRESHOLD)) beep(1000,500); |
}; |
} |
/////////////////////////////////////////////////////////////////////////////// |
void cikcak() |
{ |
unsigned int16 n; |
sem1: |
n=CIK_CAK; |
while (0==RSENSOR||LSENSOR) // zkontroluj caru |
{ |
if (n==CIK_CAK) // zmen smer zataceni |
{ |
n=0; |
switch(movement) |
{ |
case L: |
FL;BR; |
movement=R; |
break; |
case R: |
FR;BL; |
movement=L; |
break; |
case S: |
FL;BR; |
movement=R; |
n=CIK_CAK/2; |
break; |
} |
} |
n++; |
} |
STOPL;STOPR; |
line = RSENSOR; // cteni senzoru na caru |
line |= LSENSOR << 1; |
if (line==0) goto sem1; |
// nasli jsme caru |
line=S; |
} |
/////////////////////////////////////////////////////////////////////////////// |
void objizdka() // objede cihlu |
{ |
unsigned int16 n; |
BL;BR;Delay_ms(150); |
STOPR;STOPL; |
beep(900,1000); |
// movement=S; |
// cikcak(); |
BR; FL; Delay_ms(270); // otoc se 70° do prava |
FR; FL; Delay_ms(500); // popojed rovne |
BL; Delay_ms(30); // otoc se 90° do leva |
STOPL; FR; Delay_ms(500); |
FR; FL; Delay_ms(100); // popojed rovne na slepo |
for(n=40000;n>0;n--) // popojed rovne ale kontroluj caru |
{ |
line = RSENSOR; // cteni senzoru na caru |
line |= LSENSOR << 1; |
if (line!=0) {Delay_ms(150); break;} |
// Delay_ms(1); |
} |
BR; FL; // otoc se 60° do prava |
for(n=40000;n>0;n--) |
{ |
line = RSENSOR; // cteni senzoru na caru |
line |= LSENSOR << 1; |
if (line!=0) break; |
// Delay_ms(1); |
} |
STOPR; STOPL; |
movement=L; //R; |
cikcak(); |
dira=0; |
} |
/////////////////////////////////////////////////////////////////////////////// |
void prejeddiru() // vyresi diru |
{ |
unsigned int16 n; |
unsigned int8 speed_dira; |
STOPL;STOPR; |
speed_dira=speed; |
beep(1000,500); |
switch (movement) //vrat se zpet na caru |
{ |
case L: |
for (n=COUVANI;n>0;n--) {GO(R,B,speed_dira); Delay_ms(1);} |
STOPL;STOPR; |
break; |
case R: |
for (n=COUVANI;n>0;n--) {GO(L,B,speed_dira); Delay_ms(1);} |
STOPL;STOPR; |
break; |
case S: |
goto sem; |
break; |
} |
beep(1000,500); |
/*line=0; |
FR; BL; Delay_ms(400); // otoc se na caru |
beep(1000,500); |
while(line==0) |
{ |
line = RSENSOR; // cteni senzoru na caru |
line |= LSENSOR << 1; |
} |
FL;BR; Delay_ms(60); // zabrzdi |
STOPL; STOPR; |
FL; BR; Delay_ms(700); // otacka 180 deg |
STOPL; STOPR;*/ |
FR;FL; //popojed rovne |
for(n=PRES_DIRU;n>0;n--) |
{ |
line = RSENSOR; // cteni senzoru na caru |
line |= LSENSOR << 1; |
if (line!=0) break; |
Delay_ms(1); |
} |
sem: |
STOPL; STOPR; |
movement=S; |
cikcak(); // najdi caru |
dira=0; |
} |
/////////////////////////////////////////////////////////////////////////////// |
void main() |
{ |
unsigned int16 n; // pro FOR |
STOPL; STOPR; // prepne vystupy na ovladani motoru na output a zastavi |
setup_oscillator(OSC_4MHZ|OSC_INTRC); // 4 MHz interni RC oscilator |
port_b_pullups(TRUE); // pullups pro piano na diagnostiku |
setup_spi(FALSE); |
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); // Casovac pro PWM |
setup_timer_2(T2_DIV_BY_4,255,10); // Casovac pro regulaci |
// preruseni kazdych 10ms |
setup_adc_ports(sAN2|VSS_VDD); // nastaveni A/D prevodniku pro naraznik |
setup_adc(ADC_CLOCK_INTERNAL); |
set_adc_channel(2); |
setup_timer_1(T1_INTERNAL|T1_DIV_BY_1); // Casovac pro naraznik |
setup_ccp1(CCP_COMPARE_RESET_TIMER); |
CCP_1=(2^10)-1; // prevod kazdou 1ms |
setup_comparator(A0_VR_A1_VR); // inicializace komparatoru pro cidla cary |
setup_vref(VREF_HIGH|TRESHOLD); // 32 kroku od 0.25 do 0.75 Vdd |
Beep(1000,200); //double beep |
Delay_ms(50); |
Beep(1000,200); |
Delay_ms(1000); // 1s |
// povoleni rizeni rychlosti zataceni pres preruseni |
enable_interrupts(INT_TIMER2); |
enable_interrupts(GLOBAL); |
/*---------------------------------------------------------------------------*/ |
sensors=S; |
line=S; |
last=S; |
movement=S; |
speed=FW_POMALU; |
diagnostika(); |
//cikcak(); // toc se, abys nasel caru |
Delay_ms(500); |
Beep(1000,200); |
Delay_ms(500); |
while(true) // hlavni smycka (jizda podle cary) |
{ |
sensors = RSENSOR; // cteni senzoru na caru |
sensors |= LSENSOR << 1; |
if ((read_adc(ADC_READ_ONLY)<BUMPER_TRESHOLD) && (dira<=T_CIHLA)) objizdka(); |
switch (sensors) // zatacej podle toho, kde vidis caru |
{ |
case S: // rovne |
FL; FR; // pokud se jede dlouho rovne, tak pridej |
dira=0; |
movement=S; |
continue; |
case L: // trochu vlevo |
GO(L, F, FW_POMALU+rovinka); GO(R, F, FW_STREDNE+rovinka); |
line=L; |
dira=0; |
movement=L; |
continue; |
case R: // trochu vpravo |
GO(R, F, FW_POMALU+rovinka); GO(L, F, FW_STREDNE+rovinka); |
line=R; |
dira=0; |
movement=R; |
continue; |
default: // kdyz jsou obe cidla mimo caru, tak pokracuj dal |
} |
rovinka=0; |
if (dira>=T_DIRA) prejeddiru(); |
if (last!=line) // pokud si prejel caru z jedne strany na druhou stranu, tak zabrzdi |
{ |
last=line; |
speed=FW_ZATACKA; |
} |
if (L==line) // kdyz jsou obe cidla mimo caru, zatoc na caru |
{ |
STOPL; |
GO(R, F, speed); |
movement=L; |
} |
else |
{ |
STOPR; |
GO(L, F, speed); |
movement=R; |
} |
} // while(true) |
} |
/Designs/ROBOTS/Merkur/SW/turn_R/tank.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 |
/Designs/ROBOTS/Merkur/SW/turn_R/tank.err |
---|
0,0 → 1,0 |
No Errors |
/Designs/ROBOTS/Merkur/SW/turn_R/tank.h |
---|
0,0 → 1,5 |
#include <16F88.h> |
#device adc=8 |
#fuses NOWDT,INTRC_IO, NOPUT, MCLR, NOBROWNOUT, NOLVP, NOCPD, NOWRT, NODEBUG, NOPROTECT, NOFCMEN, NOIESO |
#use delay(clock=4000000) |
/Designs/ROBOTS/Merkur/SW/turn_R/tank.sta |
---|
0,0 → 1,38 |
ROM used: 1587 (39%) |
1587 (39%) including unused fragments |
2 Average locations per line |
4 Average locations per statement |
RAM used: 87 (50%) at main() level |
98 (56%) worst case |
Lines Stmts % Files |
----- ----- --- ----- |
340 357 84 D:\KAKLIK\programy\PIC_C\roboti\merkur\PIC16F88\turn_R\tank.c |
6 0 0 D:\KAKLIK\programy\PIC_C\roboti\merkur\PIC16F88\turn_R\tank.h |
275 0 0 C:\Program Files\PICC\devices\16F88.h |
136 67 9 D:\KAKLIK\programy\PIC_C\roboti\merkur\PIC16F88\turn_R\AX25.c |
----- ----- |
1514 848 Total |
Page ROM % RAM Functions: |
---- --- --- --- ---------- |
0 21 1 1 @delay_ms1 |
0 21 1 1 @delay_us1 |
0 16 1 0 TIMER2_isr |
0 44 3 6 beep |
0 352 22 3 diagnostika |
0 140 9 3 cikcak |
0 253 16 3 objizdka |
0 236 15 4 prejeddiru |
0 449 28 3 main |
Segment Used Free |
--------- ---- ---- |
00000-00003 4 0 |
00004-00036 51 0 |
00037-007FF 1532 461 |
00800-00FFF 0 2048 |
/Designs/ROBOTS/Merkur/SW/turn_R/tank.tre |
---|
0,0 → 1,74 |
ÀÄtank |
ÃÄmain 0/449 Ram=3 |
³ ÃÄ??0?? |
³ ÃÄbeep 0/44 Ram=6 |
³ ³ ÃÄ@delay_us1 0/21 Ram=1 |
³ ³ ÀÄ@delay_us1 0/21 Ram=1 |
³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ÃÄbeep 0/44 Ram=6 |
³ ³ ÃÄ@delay_us1 0/21 Ram=1 |
³ ³ ÀÄ@delay_us1 0/21 Ram=1 |
³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ÃÄdiagnostika 0/352 Ram=3 |
³ ³ ÃÄbeep 0/44 Ram=6 |
³ ³ ³ ÃÄ@delay_us1 0/21 Ram=1 |
³ ³ ³ ÀÄ@delay_us1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄbeep 0/44 Ram=6 |
³ ³ ³ ÃÄ@delay_us1 0/21 Ram=1 |
³ ³ ³ ÀÄ@delay_us1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄbeep 0/44 Ram=6 |
³ ³ ³ ÃÄ@delay_us1 0/21 Ram=1 |
³ ³ ³ ÀÄ@delay_us1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄbeep 0/44 Ram=6 |
³ ³ ³ ÃÄ@delay_us1 0/21 Ram=1 |
³ ³ ³ ÀÄ@delay_us1 0/21 Ram=1 |
³ ³ ÃÄbeep 0/44 Ram=6 |
³ ³ ³ ÃÄ@delay_us1 0/21 Ram=1 |
³ ³ ³ ÀÄ@delay_us1 0/21 Ram=1 |
³ ³ ÀÄbeep 0/44 Ram=6 |
³ ³ ÃÄ@delay_us1 0/21 Ram=1 |
³ ³ ÀÄ@delay_us1 0/21 Ram=1 |
³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ÃÄbeep 0/44 Ram=6 |
³ ³ ÃÄ@delay_us1 0/21 Ram=1 |
³ ³ ÀÄ@delay_us1 0/21 Ram=1 |
³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ÃÄobjizdka 0/253 Ram=3 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄbeep 0/44 Ram=6 |
³ ³ ³ ÃÄ@delay_us1 0/21 Ram=1 |
³ ³ ³ ÀÄ@delay_us1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÀÄcikcak 0/140 Ram=3 |
³ ÀÄprejeddiru 0/236 Ram=4 |
³ ÃÄbeep 0/44 Ram=6 |
³ ³ ÃÄ@delay_us1 0/21 Ram=1 |
³ ³ ÀÄ@delay_us1 0/21 Ram=1 |
³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ÃÄbeep 0/44 Ram=6 |
³ ³ ÃÄ@delay_us1 0/21 Ram=1 |
³ ³ ÀÄ@delay_us1 0/21 Ram=1 |
³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ÀÄcikcak 0/140 Ram=3 |
ÀÄTIMER2_isr 0/16 Ram=0 |
/Designs/ROBOTS/Merkur/SW/vystava/AX25.c |
---|
0,0 → 1,135 |
#nolist |
//#define PTT PIN_A2 // PTT control |
//#define TXo PIN_C0 // To the transmitter modulator |
#define PERIODAH delay_us(222) // Halfperiod H 222;78/1200 500;430/500 |
#define TAILH delay_us(78) |
#define PERIODAL delay_us(412) // Halfperiod L 412;345/1200 1000;880/500 |
#define TAILL delay_us(345) |
#byte STATUS = 3 // CPUs status register |
byte SendData[16] = {'A'<<1, 'L'<<1, 'L'<<1, ' '<<1, ' '<<1, ' '<<1, 0x60, |
'C'<<1, 'Z'<<1, '0'<<1, 'R'<<1, 'R'<<1, 'R'<<1, 0x61, |
0x03, 0xF0}; |
boolean bit; |
int fcslo, fcshi; // variabloes for calculating FCS (CRC) |
int stuff; // stuff counter for extra 0 |
int flag_flag; // if it is sending flag (7E) |
int fcs_flag; // if it is sending Frame Check Sequence |
int i; // for for |
void flipout() //flips the state of output pin a_1 |
{ |
stuff = 0; //since this is a 0, reset the stuff counter |
if (bit) |
{ |
bit=FALSE; //if the state of the pin was low, make it high. |
} |
else |
{ |
bit=TRUE; //if the state of the pin was high make it low |
} |
} |
void fcsbit(byte tbyte) |
{ |
#asm |
BCF STATUS,0 |
RRF fcshi,F // rotates the entire 16 bits |
RRF fcslo,F // to the right |
#endasm |
if (((STATUS & 0x01)^(tbyte)) ==0x01) |
{ |
fcshi = fcshi^0x84; |
fcslo = fcslo^0x08; |
} |
} |
void SendBit () |
{ |
if (bit) |
{ |
output_high(TXo); |
PERIODAH; |
output_low(TXo); |
PERIODAH; |
output_high(TXo); |
PERIODAH; |
output_low(TXo); |
TAILH; |
} |
else |
{ |
output_high(TXo); |
PERIODAL; |
output_low(TXo); |
TAILL; |
}; |
} |
void SendByte (byte inbyte) |
{ |
int k, bt; |
for (k=0;k<8;k++) //do the following for each of the 8 bits in the byte |
{ |
bt = inbyte & 0x01; //strip off the rightmost bit of the byte to be sent (inbyte) |
if ((fcs_flag == FALSE) & (flag_flag == FALSE)) fcsbit(bt); //do FCS calc, but only if this |
//is not a flag or fcs byte |
if (bt == 0) |
{ |
flipout(); |
} // if this bit is a zero, flip the output state |
else |
{ //otherwise if it is a 1, do the following: |
if (flag_flag == FALSE) stuff++; //increment the count of consequtive 1's |
if ((flag_flag == FALSE) & (stuff == 5)) |
{ //stuff an extra 0, if 5 1's in a row |
SendBit(); |
flipout(); //flip the output state to stuff a 0 |
}//end of if |
}//end of else |
// delay_us(850); //introduces a delay that creates 1200 baud |
SendBit(); |
inbyte = inbyte>>1; //go to the next bit in the byte |
}//end of for |
}//end of SendByte |
void SendPacket(char *data) |
{ |
bit=FALSE; |
fcslo=fcshi=0xFF; //The 2 FCS Bytes are initialized to FF |
stuff = 0; //The variable stuff counts the number of 1's in a row. When it gets to 5 |
// it is time to stuff a 0. |
// output_low(PTT); // Blinking LED |
// delay_ms(1000); |
// output_high(PTT); |
flag_flag = TRUE; //The variable flag is true if you are transmitted flags (7E's) false otherwise. |
fcs_flag = FALSE; //The variable fcsflag is true if you are transmitting FCS bytes, false otherwise. |
for(i=0; i<10; i++) SendByte(0x7E); //Sends flag bytes. Adjust length for txdelay |
//each flag takes approx 6.7 ms |
flag_flag = FALSE; //done sending flags |
for(i=0; i<16; i++) SendByte(SendData[i]); //send the packet bytes |
for(i=0; 0 != *data; i++) |
{ |
SendByte(*data); //send the packet bytes |
data++; |
}; |
fcs_flag = TRUE; //about to send the FCS bytes |
fcslo =fcslo^0xff; //must XOR them with FF before sending |
fcshi = fcshi^0xff; |
SendByte(fcslo); //send the low byte of fcs |
SendByte(fcshi); //send the high byte of fcs |
fcs_flag = FALSE; //done sending FCS |
flag_flag = TRUE; //about to send flags |
SendByte(0x7e); // Send a flag to end packet |
} |
#list |
/Designs/ROBOTS/Merkur/SW/vystava/tank.BAK |
---|
0,0 → 1,236 |
#include "tank.h" |
unsigned int8 sensors; // pomocna promenna pro cteni cidel na caru |
unsigned int8 line; // na ktere strane byla detekovana cara |
unsigned int8 speed; // rychlost zataceni |
unsigned int8 last; // kde byla cara, kdyz byly minule cidla mimo |
unsigned int8 rovinka; // pocitadlo pro zjisteni rovneho useku |
int cirkus; |
// Konstanty pro dynamiku pohybu |
#define T_DIRA 120 // po jakem case zataceni se detekuje dira |
#define FW_POMALU 170 // trochu mimo caru vnitrni pas |
#define FW_ZATACKA 200 // rychlost vnejsiho kola pri zataceni |
#define FW_STREDNE 190 // trochu mimo caru vnejsi pas |
#define COUVANI 750 // couvnuti zpet na caru, po detekci diry |
#define MAX_ROVINKA (255-FW_STREDNE) |
#define TRESHOLD 15 // rozhodovaci uroven komparatoru, 0xF = 0.75*Vdd |
#define BUMPER_TRESHOLD 128 |
//motory //Napred vypnout potom zapnout! |
#define FR output_low(PIN_B5); output_high(PIN_B4) // Vpred |
#define FL output_low(PIN_B7); output_high(PIN_B6) |
#define BR output_low(PIN_B4); output_high(PIN_B5) // Vzad |
#define BL output_low(PIN_B6); output_high(PIN_B7) |
#define STOPR output_low(PIN_B4);output_low(PIN_B5) // Zastav |
#define STOPL output_low(PIN_B6);output_low(PIN_B7) |
#define L 0b10 // left |
#define R 0b01 // right |
#define S 0b11 // straight |
//cidla |
#define RSENSOR !C2OUT // Senzory na caru |
#define LSENSOR !C1OUT |
#define BUMPER PIN_A4 // Senzor na cihlu |
#define DIAG_SERVO PIN_B3 // Propojka pro diagnosticky mod |
#define DIAG_SENSORS PIN_B2 // Propojka pro diagnosticky mod |
#DEFINE SOUND_HI PIN_A6 // komplementarni vystupy pro piezo pipak |
#DEFINE SOUND_LO PIN_A7 |
char AXstring[40]; // Buffer pro prenos telemetrie |
// makro pro PWM |
#define GO(motor, direction, power) if(get_timer0()<=power) \ |
{direction##motor;} else {stop##motor;} |
#int_TIMER2 |
void TIMER2_isr() |
{ |
if (speed<255) speed++; |
if (rovinka<MAX_ROVINKA) rovinka++; |
} |
// Primitivni Pipani |
void beep(unsigned int16 period, unsigned int16 length) |
{ |
unsigned int16 nn; |
for(nn=length; nn>0; nn--) |
{ |
output_high(SOUND_HI);output_low(SOUND_LO); |
delay_us(period); |
output_high(SOUND_LO);output_low(SOUND_HI); |
delay_us(period); |
} |
} |
/******************************************************************************/ |
void diagnostika() |
{ |
unsigned int16 n; |
while (input(DIAG_SERVO)) // Propojka, ktera spousti diagnostiku |
{ |
for (n=500; n<800; n+=100) |
{ |
beep(n,n); //beep UP |
}; |
Delay_ms(1000); |
//zastav vse |
STOPL; STOPR; |
//pravy pas |
FR; Delay_ms(1000); STOPR; Delay_ms(1000); |
BR; Delay_ms(1000); STOPR; Delay_ms(1000); |
Beep(880,100); Delay_ms(1000); |
//levy pas |
FL; Delay_ms(1000); STOPL; Delay_ms(1000); |
BL; Delay_ms(1000); STOPL; Delay_ms(1000); |
Beep(880,100); Delay_ms(1000); |
//oba pasy |
FL; FR; Delay_ms(1000); STOPL; STOPR; Delay_ms(1000); |
BL; BR; Delay_ms(1000); STOPL; STOPR; Delay_ms(1000); |
}; |
while (input(DIAG_SENSORS)) // spusteni diagnostiky cidel |
{ |
if (RSENSOR) beep(1000,1000); |
if (LSENSOR) beep(2000,2000); |
if ((read_adc(ADC_READ_ONLY)<BUMPER_TRESHOLD)) beep(3000,3000); |
}; |
} |
/////////////////////////////////////////////////////////////////////////////// |
void OtocSe() // otoci se zpet, kdyz je prekazka |
{ |
unsigned int16 n; |
STOPR;STOPL; |
beep(800,400); |
beep(2000,1000); |
beep(900,400); |
BR; FL; Delay_ms(100); // otoc se 30° do prava |
STOPL; STOPR; |
beep(1000,1000); |
BR; FL; |
for(n=40000;n>0;n--) // toc se, dokud nenarazis na caru |
{ |
line = RSENSOR; // cteni senzoru na caru |
line |= LSENSOR << 1; |
if (line!=0) break; |
} |
STOPR; STOPL; |
line=L; // caru jsme prejeli, tak je vlevo |
cirkus=0; |
} |
void main() |
{ |
unsigned int16 n; // pro FOR |
unsigned int16 i; |
STOPL; STOPR; // prepne vystupy na ovladani motoru na output a zastavi |
setup_oscillator(OSC_4MHZ|OSC_INTRC); // 4 MHz interni RC oscilator |
port_b_pullups(TRUE); // pullups pro piano na diagnostiku |
setup_spi(FALSE); |
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); // Casovac pro PWM |
setup_timer_2(T2_DIV_BY_4,255,10); // Casovac pro regulaci |
// preruseni kazdych 10ms |
setup_adc_ports(sAN2|VSS_VDD); // nastaveni A/D prevodniku pro naraznik |
setup_adc(ADC_CLOCK_INTERNAL); |
set_adc_channel(2); |
setup_timer_1(T1_INTERNAL|T1_DIV_BY_1); // Casovac pro naraznik |
setup_ccp1(CCP_COMPARE_RESET_TIMER); |
CCP_1=(2^10)-1; // prevod kazdou 1ms |
setup_comparator(A0_VR_A1_VR); // inicializace komparatoru pro cidla cary |
setup_vref(VREF_HIGH|TRESHOLD); // 32 kroku od 0.25 do 0.75 Vdd |
Beep(1000,200); //double beep |
Delay_ms(50); |
Beep(1000,200); |
Delay_ms(1000); // 1s |
// povoleni rizeni rychlosti zataceni pres preruseni |
enable_interrupts(INT_TIMER2); |
enable_interrupts(GLOBAL); |
/*---------------------------------------------------------------------------*/ |
sensors=S; |
line=S; |
last=S; |
cirkus=0; |
// movement=S; |
speed=FW_POMALU; |
diagnostika(); |
Delay_ms(500); |
Beep(1000,200); |
Delay_ms(500); |
while(true) // hlavni smycka (jizda podle cary) |
{ |
sensors = RSENSOR; // cteni senzoru na caru |
sensors |= LSENSOR << 1; |
if (read_adc(ADC_READ_ONLY)<BUMPER_TRESHOLD) OtocSe(); |
switch (sensors) // zatacej podle toho, kde vidis caru |
{ |
case S: // rovne |
GO(L, F, FW_STREDNE+rovinka); GO(R, F, FW_STREDNE+rovinka); |
continue; |
case L: // trochu vlevo |
GO(L, F, FW_POMALU+rovinka); GO(R, F, FW_STREDNE+rovinka); |
line=L; |
continue; |
case R: // trochu vpravo |
GO(R, F, FW_POMALU+rovinka); GO(L, F, FW_STREDNE+rovinka); |
line=R; |
continue; |
default: // kdyz jsou obe cidla mimo caru, tak pokracuj dal |
}; |
rovinka=0; |
if (last!=line) // pokud si prejel caru z jedne strany na druhou stranu, tak zabrzdi |
{ |
last=line; |
speed=FW_ZATACKA; |
cirkus++; |
if (cirkus>10) |
{ |
STOPL; STOPR; |
cirkus=0; |
disable_interrupts(GLOBAL); |
beep(1000,400); |
for(n=3000; n>3950; n--) beep(n,10); |
beep(2000,200); |
beep(900,400); |
for(n=2950; n<3000; n++) beep(n,10); |
beep(4000,400); |
beep(1000,100); |
beep(3000,400); |
Delay_ms(1000); |
enable_interrupts(GLOBAL); |
} |
}; |
if (L==line) // kdyz jsou obe cidla mimo caru, zatoc na caru |
{ |
STOPL; |
GO(R, F, speed); |
} |
else |
{ |
STOPR; |
GO(L, F, speed); |
} |
} // while(true) |
} |
/Designs/ROBOTS/Merkur/SW/vystava/tank.HEX |
---|
0,0 → 1,157 |
:1000000000308A008E2A0000FF00030E8301A10049 |
:100010007F08A0000A08A8008A01A00E0408A20018 |
:100020007708A3007808A4007908A5007A08A6003C |
:100030007B08A700831383128C308400801C222845 |
:100040008C183528220884002308F7002408F800BB |
:100050002508F9002608FA002708FB0028088A006E |
:10006000210E8300FF0E7F0E09008A1137282B0F07 |
:100070003A283B28AB0A2D08403C0318AD0A8C10E7 |
:100080008A1122281230E302031C542863308400B2 |
:10009000FC3080050310800C800C000803195428E4 |
:1000A00052280000800B512800346008E2005F08ED |
:1000B000E100E108031D5F28E20803197A2883168E |
:1000C00005138312051783168513831285135D08A4 |
:1000D000E3004220831685138312851783160513C8 |
:1000E000831205135D08E300422061080319E2034F |
:1000F000E103592800345E308400000803198F287A |
:100100000130F800F701F70B8328F80B82284A30FA |
:10011000F700F70B892800000000800B80280034CE |
:10012000831686158312861DBB290130DC00F4304E |
:10013000DB005C08033C031CB128031DA3285B08FB |
:100140001F3C031CB1285C08DE005B08DD005C0876 |
:10015000E0005B08DF0055206430DB070318DC0A91 |
:1001600099280430DD00FA30DE007B20DD0BB32857 |
:1001700083160613831206138316861383128613BF |
:1001800083160612831206128316861283128612B3 |
:10019000831686128312861283160612831206169F |
:1001A0000430DD00FA30DE007B20DD0BD228831620 |
:1001B00006128312061283168612831286120430E8 |
:1001C000DD00FA30DE007B20DD0BE128831606120D |
:1001D0008312061283168612831286160430DD00FF |
:1001E000FA30DE007B20DD0BF02883160612831226 |
:1001F000061283168612831286120430DD00FA304E |
:10020000DE007B20DD0BFF280330DE007030DD00D8 |
:10021000E0016430DF0055200430DD00FA30DE00FC |
:100220007B20DD0B0E29831686138312861383161B |
:100230000613831206170430DD00FA30DE007B203F |
:10024000DD0B1D29831606138312061383168613EE |
:10025000831286130430DD00FA30DE007B20DD0BD4 |
:100260002C29831606138312061383168613831212 |
:1002700086170430DD00FA30DE007B20DD0B3B29E1 |
:1002800083160613831206138316861383128613AE |
:100290000430DD00FA30DE007B20DD0B4A2903301C |
:1002A000DE007030DD00E0016430DF0055200430F6 |
:1002B000DD00FA30DE007B20DD0B59298316861322 |
:1002C000831286138316061383120617831686126B |
:1002D0008312861283160612831206160430DD007E |
:1002E000FA30DE007B20DD0B7029831606138312A3 |
:1002F000061383168613831286138316061283123F |
:10030000061283168612831286120430DD00FA303C |
:10031000DE007B20DD0B872983160613831206136C |
:10032000831686138312861783160612831206120B |
:1003300083168612831286160430DD00FA30DE0042 |
:100340007B20DD0B9E29831606138312061383166A |
:1003500086138312861383160612831206128316DF |
:100360008612831286120430DD00FA30DE007B2014 |
:10037000DD0BB5299028831606158312061DEE297C |
:1003800083169C1BCE2903308312DE00E830DD008B |
:100390000330E000E830DF00552083161C1BDB290A |
:1003A00007308312DE00D030DD000730E000D030AF |
:1003B000DF005520831683121F1DE0298316DB29D9 |
:1003C0001E087F3C031CED290B30DE00B830DD0039 |
:1003D0000B30E000B830DF005520BB298A111F2BFD |
:1003E000831606128312061283168612831286164D |
:1003F0008316061383120613831686138312861739 |
:100400000330DE002030DD000130E0009030DF00FE |
:1004100055200730DE00D030DD000330E000E8304A |
:10042000DF0055200330DE008430DD000130E000C5 |
:100430009030DF00552083160612831206128316B1 |
:1004400086128312861683168613831286138316EA |
:100450000613831206173230DE007B208316061344 |
:1004600083120613831686138312861383160612CD |
:100470008312061283168612831286120330DE0060 |
:10048000E830DD000330E000E830DF00552083165F |
:10049000061283120612831686128312861683169C |
:1004A00086138312861383160613831206179C3055 |
:1004B000DC004030DB00DB08031D612ADC08031987 |
:1004C000792AAA0183169C1B682A8312AA0A83161A |
:1004D00000301C1F0130F7000310F70D770883125E |
:1004E000AA04AA08031D792A5B080319DC03DB03AD |
:1004F0005B2A831606128312061283168612831253 |
:10050000861283160613831206138316861383122C |
:1005100086130230AA00AE018A114B2B84011F30D2 |
:10052000830583161F129F121B0880399B0007301A |
:100530009C001C0883120D13603083168F00061375 |
:1005400083120613831686138312861383160612EC |
:100550008312061283168612831286126230831665 |
:100560008F008113831294128316061186140612CB |
:10057000003083129400831694000108C7390838AC |
:1005800081004830F800053883129200FF3083164E |
:1005900092001F129F121B08803904389B001F1302 |
:1005A00083121F179F1783169F1383121F14103077 |
:1005B000F8001F08C73978049F0085309000831623 |
:1005C00086150B3083129700960107309500023094 |
:1005D00083169C000508033885000330F700F70BED |
:1005E000EF2A1C0883120D138F3083169D000330F1 |
:1005F0008312DE00E830DD00E001C830DF00552066 |
:100600003230DE007B200330DE00E830DD00E00128 |
:10061000C830DF0055200430DB00FA30DE007B20DC |
:10062000DB0B0D2B83168C14C03083128B0403302C |
:10063000A900AA00AC00AE01AA30AB00902802309D |
:10064000DB00FA30DE007B20DB0B212B0330DE00E9 |
:10065000E830DD00E001C830DF0055200230DB006B |
:10066000FA30DE007B20DB0B302BA90183169C1BAC |
:100670003C2B8312A90A831600301C1F0130F7009F |
:100680000310F70D77088312A9041F19452B1E08C4 |
:100690007F3C0318F0292908033A0319562B013A25 |
:1006A00003198B2B033A0319C22BF92B0108DB002A |
:1006B000BE302D075B0203195F2B0318682B8316CE |
:1006C0008613831286138316061383120617702B64 |
:1006D000831606138312061383168613831286135A |
:1006E0000108DB00BE302D075B020319792B0318CC |
:1006F000822B8316861283128612831606128312A9 |
:1007000006168A2B83160612831206128316861289 |
:1007100083128612352B0108DB00AA302D075B02FD |
:100720000319942B03189D2B8316861383128613AB |
:100730008316061383120617A52B8316061383123E |
:10074000061383168613831286130108DB00BE305E |
:100750002D075B020319AE2B0318B72B83168612E5 |
:10076000831286128316061283120616BF2B831677 |
:100770000612831206128316861283128612023024 |
:10078000AA00352B0108DB00AA302D075B020319F4 |
:10079000CB2B0318D42B8316861283128612831652 |
:1007A000061283120616DC2B83160612831206121B |
:1007B00083168612831286120108DB00BE302D07D5 |
:1007C0005B020319E52B0318EE2B831686138312A5 |
:1007D00086138316061383120617F62B8316061349 |
:1007E0008312061383168613831286130130AA0020 |
:1007F000352BAD012A082C0203198F2C2A08AC00D6 |
:10080000C830AB00AE0A2E080A3C03188F2C8316A2 |
:100810000613831206138316861383128613831618 |
:100820000612831206128316861283128612AE01F6 |
:100830000B138B138B1B192C0330DE00E830DD000B |
:100840000130E0009030DF0055200B30D800B83088 |
:10085000D70058080E3C0318412CFF3A031D342CD6 |
:1008600057086E3C0318412C5808DE005708DD007D |
:10087000E0010A30DF00552057080319D803D703D9 |
:10088000292C0730DE00D030DD00E001C830DF0069 |
:1008900055200330DE008430DD000130E000903070 |
:1008A000DF0055200B30D8008630D70058080B3CAD |
:1008B000031C6C2C031D602C5708B73C031C6C2CCC |
:1008C0005808DE005708DD00E0010A30DF0055203F |
:1008D000D70A0319D80A562C0F30DE00A030DD00ED |
:1008E0000130E0009030DF0055200330DE00E830BA |
:1008F000DD00E0016430DF0055200B30DE00B83051 |
:10090000DD000130E0009030DF0055200430DB00D6 |
:10091000FA30DE007B20DB0B882CC0308B042A08E9 |
:10092000023C031DB12C8316061383120613831693 |
:1009300086138312861301082B02031CA82C83162E |
:100940008612831286128316061283120616B02CA4 |
:1009500083160612831206128316861283128612DB |
:10096000CE2C831606128312061283168612831269 |
:10097000861201082B02031CC62C831686138312D1 |
:1009800086138316061383120617CE2C83160613BE |
:10099000831206138316861383128613352B630086 |
:04400E00383FFC3FFC |
:00000001FF |
;PIC16F88 |
/Designs/ROBOTS/Merkur/SW/vystava/tank.LST |
---|
0,0 → 1,1497 |
CCS PCM C Compiler, Version 3.221, 27853 20-V-05 13:52 |
Filename: D:\KAKLIK\programy\PIC_C\roboti\merkur\PIC16F88\vystava\tank.LST |
ROM used: 1232 words (30%) |
Largest free fragment is 2048 |
RAM used: 65 (37%) at main() level |
73 (42%) worst case |
Stack: 4 worst case (3 in main + 1 for interrupts) |
* |
0000: MOVLW 00 |
0001: MOVWF 0A |
0002: GOTO 28E |
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 037 |
.................... #include "tank.h" |
.................... #include <16F88.h> |
.................... //////// Standard Header file for the PIC16F88 device //////////////// |
.................... #device PIC16F88 |
.................... #list |
.................... |
.................... #device adc=8 |
.................... #fuses NOWDT,INTRC_IO, NOPUT, MCLR, NOBROWNOUT, NOLVP, NOCPD, NOWRT, NODEBUG, NOPROTECT, NOFCMEN, NOIESO |
.................... #use delay(clock=4000000) |
* |
0042: MOVLW 12 |
0043: SUBWF 63,F |
0044: BTFSS 03.0 |
0045: GOTO 054 |
0046: MOVLW 63 |
0047: MOVWF 04 |
0048: MOVLW FC |
0049: ANDWF 00,F |
004A: BCF 03.0 |
004B: RRF 00,F |
004C: RRF 00,F |
004D: MOVF 00,W |
004E: BTFSC 03.2 |
004F: GOTO 054 |
0050: GOTO 052 |
0051: NOP |
0052: DECFSZ 00,F |
0053: GOTO 051 |
0054: RETLW 00 |
* |
007B: MOVLW 5E |
007C: MOVWF 04 |
007D: MOVF 00,W |
007E: BTFSC 03.2 |
007F: GOTO 08F |
0080: MOVLW 01 |
0081: MOVWF 78 |
0082: CLRF 77 |
0083: DECFSZ 77,F |
0084: GOTO 083 |
0085: DECFSZ 78,F |
0086: GOTO 082 |
0087: MOVLW 4A |
0088: MOVWF 77 |
0089: DECFSZ 77,F |
008A: GOTO 089 |
008B: NOP |
008C: NOP |
008D: DECFSZ 00,F |
008E: GOTO 080 |
008F: RETLW 00 |
.................... |
.................... |
.................... |
.................... unsigned int8 sensors; // pomocna promenna pro cteni cidel na caru |
.................... unsigned int8 line; // na ktere strane byla detekovana cara |
.................... unsigned int8 speed; // rychlost zataceni |
.................... unsigned int8 last; // kde byla cara, kdyz byly minule cidla mimo |
.................... unsigned int8 rovinka; // pocitadlo pro zjisteni rovneho useku |
.................... int cirkus; |
.................... |
.................... // Konstanty pro dynamiku pohybu |
.................... #define T_DIRA 120 // po jakem case zataceni se detekuje dira |
.................... #define FW_POMALU 170 // trochu mimo caru vnitrni pas |
.................... #define FW_ZATACKA 200 // rychlost vnejsiho kola pri zataceni |
.................... #define FW_STREDNE 190 // trochu mimo caru vnejsi pas |
.................... #define COUVANI 750 // couvnuti zpet na caru, po detekci diry |
.................... #define MAX_ROVINKA (255-FW_STREDNE) |
.................... #define TRESHOLD 15 // rozhodovaci uroven komparatoru, 0xF = 0.75*Vdd |
.................... #define BUMPER_TRESHOLD 128 |
.................... |
.................... //motory //Napred vypnout potom zapnout! |
.................... #define FR output_low(PIN_B5); output_high(PIN_B4) // Vpred |
.................... #define FL output_low(PIN_B7); output_high(PIN_B6) |
.................... #define BR output_low(PIN_B4); output_high(PIN_B5) // Vzad |
.................... #define BL output_low(PIN_B6); output_high(PIN_B7) |
.................... #define STOPR output_low(PIN_B4);output_low(PIN_B5) // Zastav |
.................... #define STOPL output_low(PIN_B6);output_low(PIN_B7) |
.................... |
.................... #define L 0b10 // left |
.................... #define R 0b01 // right |
.................... #define S 0b11 // straight |
.................... |
.................... //cidla |
.................... #define RSENSOR !C2OUT // Senzory na caru |
.................... #define LSENSOR !C1OUT |
.................... #define BUMPER PIN_A4 // Senzor na cihlu |
.................... |
.................... #define DIAG_SERVO PIN_B3 // Propojka pro diagnosticky mod |
.................... #define DIAG_SENSORS PIN_B2 // Propojka pro diagnosticky mod |
.................... |
.................... #DEFINE SOUND_HI PIN_A6 // komplementarni vystupy pro piezo pipak |
.................... #DEFINE SOUND_LO PIN_A7 |
.................... |
.................... char AXstring[40]; // Buffer pro prenos telemetrie |
.................... |
.................... // makro pro PWM |
.................... #define GO(motor, direction, power) if(get_timer0()<=power) \ |
.................... {direction##motor;} else {stop##motor;} |
.................... |
.................... #int_TIMER2 |
.................... void TIMER2_isr() |
.................... { |
.................... if (speed<255) speed++; |
* |
0037: INCFSZ 2B,W |
0038: GOTO 03A |
0039: GOTO 03B |
003A: INCF 2B,F |
.................... if (rovinka<MAX_ROVINKA) rovinka++; |
003B: MOVF 2D,W |
003C: SUBLW 40 |
003D: BTFSC 03.0 |
003E: INCF 2D,F |
.................... } |
.................... // Primitivni Pipani |
003F: BCF 0C.1 |
0040: BCF 0A.3 |
0041: GOTO 022 |
.................... void beep(unsigned int16 period, unsigned int16 length) |
.................... { |
.................... unsigned int16 nn; |
.................... |
.................... for(nn=length; nn>0; nn--) |
* |
0055: MOVF 60,W |
0056: MOVWF 62 |
0057: MOVF 5F,W |
0058: MOVWF 61 |
0059: MOVF 61,F |
005A: BTFSS 03.2 |
005B: GOTO 05F |
005C: MOVF 62,F |
005D: BTFSC 03.2 |
005E: GOTO 07A |
.................... { |
.................... output_high(SOUND_HI);output_low(SOUND_LO); |
005F: BSF 03.5 |
0060: BCF 05.6 |
0061: BCF 03.5 |
0062: BSF 05.6 |
0063: BSF 03.5 |
0064: BCF 05.7 |
0065: BCF 03.5 |
0066: BCF 05.7 |
.................... delay_us(period); |
0067: MOVF 5D,W |
0068: MOVWF 63 |
0069: CALL 042 |
.................... output_high(SOUND_LO);output_low(SOUND_HI); |
006A: BSF 03.5 |
006B: BCF 05.7 |
006C: BCF 03.5 |
006D: BSF 05.7 |
006E: BSF 03.5 |
006F: BCF 05.6 |
0070: BCF 03.5 |
0071: BCF 05.6 |
.................... delay_us(period); |
0072: MOVF 5D,W |
0073: MOVWF 63 |
0074: CALL 042 |
.................... } |
0075: MOVF 61,W |
0076: BTFSC 03.2 |
0077: DECF 62,F |
0078: DECF 61,F |
0079: GOTO 059 |
.................... } |
007A: RETLW 00 |
.................... /******************************************************************************/ |
.................... void diagnostika() |
.................... { |
.................... unsigned int16 n; |
.................... |
.................... while (input(DIAG_SERVO)) // Propojka, ktera spousti diagnostiku |
.................... { |
* |
0090: BSF 03.5 |
0091: BSF 06.3 |
0092: BCF 03.5 |
0093: BTFSS 06.3 |
0094: GOTO 1BB |
.................... for (n=500; n<800; n+=100) |
0095: MOVLW 01 |
0096: MOVWF 5C |
0097: MOVLW F4 |
0098: MOVWF 5B |
0099: MOVF 5C,W |
009A: SUBLW 03 |
009B: BTFSS 03.0 |
009C: GOTO 0B1 |
009D: BTFSS 03.2 |
009E: GOTO 0A3 |
009F: MOVF 5B,W |
00A0: SUBLW 1F |
00A1: BTFSS 03.0 |
00A2: GOTO 0B1 |
.................... { |
.................... beep(n,n); //beep UP |
00A3: MOVF 5C,W |
00A4: MOVWF 5E |
00A5: MOVF 5B,W |
00A6: MOVWF 5D |
00A7: MOVF 5C,W |
00A8: MOVWF 60 |
00A9: MOVF 5B,W |
00AA: MOVWF 5F |
00AB: CALL 055 |
.................... }; |
00AC: MOVLW 64 |
00AD: ADDWF 5B,F |
00AE: BTFSC 03.0 |
00AF: INCF 5C,F |
00B0: GOTO 099 |
.................... Delay_ms(1000); |
00B1: MOVLW 04 |
00B2: MOVWF 5D |
00B3: MOVLW FA |
00B4: MOVWF 5E |
00B5: CALL 07B |
00B6: DECFSZ 5D,F |
00B7: GOTO 0B3 |
.................... //zastav vse |
.................... STOPL; STOPR; |
00B8: BSF 03.5 |
00B9: BCF 06.6 |
00BA: BCF 03.5 |
00BB: BCF 06.6 |
00BC: BSF 03.5 |
00BD: BCF 06.7 |
00BE: BCF 03.5 |
00BF: BCF 06.7 |
00C0: BSF 03.5 |
00C1: BCF 06.4 |
00C2: BCF 03.5 |
00C3: BCF 06.4 |
00C4: BSF 03.5 |
00C5: BCF 06.5 |
00C6: BCF 03.5 |
00C7: BCF 06.5 |
.................... //pravy pas |
.................... FR; Delay_ms(1000); STOPR; Delay_ms(1000); |
00C8: BSF 03.5 |
00C9: BCF 06.5 |
00CA: BCF 03.5 |
00CB: BCF 06.5 |
00CC: BSF 03.5 |
00CD: BCF 06.4 |
00CE: BCF 03.5 |
00CF: BSF 06.4 |
00D0: MOVLW 04 |
00D1: MOVWF 5D |
00D2: MOVLW FA |
00D3: MOVWF 5E |
00D4: CALL 07B |
00D5: DECFSZ 5D,F |
00D6: GOTO 0D2 |
00D7: BSF 03.5 |
00D8: BCF 06.4 |
00D9: BCF 03.5 |
00DA: BCF 06.4 |
00DB: BSF 03.5 |
00DC: BCF 06.5 |
00DD: BCF 03.5 |
00DE: BCF 06.5 |
00DF: MOVLW 04 |
00E0: MOVWF 5D |
00E1: MOVLW FA |
00E2: MOVWF 5E |
00E3: CALL 07B |
00E4: DECFSZ 5D,F |
00E5: GOTO 0E1 |
.................... BR; Delay_ms(1000); STOPR; Delay_ms(1000); |
00E6: BSF 03.5 |
00E7: BCF 06.4 |
00E8: BCF 03.5 |
00E9: BCF 06.4 |
00EA: BSF 03.5 |
00EB: BCF 06.5 |
00EC: BCF 03.5 |
00ED: BSF 06.5 |
00EE: MOVLW 04 |
00EF: MOVWF 5D |
00F0: MOVLW FA |
00F1: MOVWF 5E |
00F2: CALL 07B |
00F3: DECFSZ 5D,F |
00F4: GOTO 0F0 |
00F5: BSF 03.5 |
00F6: BCF 06.4 |
00F7: BCF 03.5 |
00F8: BCF 06.4 |
00F9: BSF 03.5 |
00FA: BCF 06.5 |
00FB: BCF 03.5 |
00FC: BCF 06.5 |
00FD: MOVLW 04 |
00FE: MOVWF 5D |
00FF: MOVLW FA |
0100: MOVWF 5E |
0101: CALL 07B |
0102: DECFSZ 5D,F |
0103: GOTO 0FF |
.................... Beep(880,100); Delay_ms(1000); |
0104: MOVLW 03 |
0105: MOVWF 5E |
0106: MOVLW 70 |
0107: MOVWF 5D |
0108: CLRF 60 |
0109: MOVLW 64 |
010A: MOVWF 5F |
010B: CALL 055 |
010C: MOVLW 04 |
010D: MOVWF 5D |
010E: MOVLW FA |
010F: MOVWF 5E |
0110: CALL 07B |
0111: DECFSZ 5D,F |
0112: GOTO 10E |
.................... //levy pas |
.................... FL; Delay_ms(1000); STOPL; Delay_ms(1000); |
0113: BSF 03.5 |
0114: BCF 06.7 |
0115: BCF 03.5 |
0116: BCF 06.7 |
0117: BSF 03.5 |
0118: BCF 06.6 |
0119: BCF 03.5 |
011A: BSF 06.6 |
011B: MOVLW 04 |
011C: MOVWF 5D |
011D: MOVLW FA |
011E: MOVWF 5E |
011F: CALL 07B |
0120: DECFSZ 5D,F |
0121: GOTO 11D |
0122: BSF 03.5 |
0123: BCF 06.6 |
0124: BCF 03.5 |
0125: BCF 06.6 |
0126: BSF 03.5 |
0127: BCF 06.7 |
0128: BCF 03.5 |
0129: BCF 06.7 |
012A: MOVLW 04 |
012B: MOVWF 5D |
012C: MOVLW FA |
012D: MOVWF 5E |
012E: CALL 07B |
012F: DECFSZ 5D,F |
0130: GOTO 12C |
.................... BL; Delay_ms(1000); STOPL; Delay_ms(1000); |
0131: BSF 03.5 |
0132: BCF 06.6 |
0133: BCF 03.5 |
0134: BCF 06.6 |
0135: BSF 03.5 |
0136: BCF 06.7 |
0137: BCF 03.5 |
0138: BSF 06.7 |
0139: MOVLW 04 |
013A: MOVWF 5D |
013B: MOVLW FA |
013C: MOVWF 5E |
013D: CALL 07B |
013E: DECFSZ 5D,F |
013F: GOTO 13B |
0140: BSF 03.5 |
0141: BCF 06.6 |
0142: BCF 03.5 |
0143: BCF 06.6 |
0144: BSF 03.5 |
0145: BCF 06.7 |
0146: BCF 03.5 |
0147: BCF 06.7 |
0148: MOVLW 04 |
0149: MOVWF 5D |
014A: MOVLW FA |
014B: MOVWF 5E |
014C: CALL 07B |
014D: DECFSZ 5D,F |
014E: GOTO 14A |
.................... Beep(880,100); Delay_ms(1000); |
014F: MOVLW 03 |
0150: MOVWF 5E |
0151: MOVLW 70 |
0152: MOVWF 5D |
0153: CLRF 60 |
0154: MOVLW 64 |
0155: MOVWF 5F |
0156: CALL 055 |
0157: MOVLW 04 |
0158: MOVWF 5D |
0159: MOVLW FA |
015A: MOVWF 5E |
015B: CALL 07B |
015C: DECFSZ 5D,F |
015D: GOTO 159 |
.................... //oba pasy |
.................... FL; FR; Delay_ms(1000); STOPL; STOPR; Delay_ms(1000); |
015E: BSF 03.5 |
015F: BCF 06.7 |
0160: BCF 03.5 |
0161: BCF 06.7 |
0162: BSF 03.5 |
0163: BCF 06.6 |
0164: BCF 03.5 |
0165: BSF 06.6 |
0166: BSF 03.5 |
0167: BCF 06.5 |
0168: BCF 03.5 |
0169: BCF 06.5 |
016A: BSF 03.5 |
016B: BCF 06.4 |
016C: BCF 03.5 |
016D: BSF 06.4 |
016E: MOVLW 04 |
016F: MOVWF 5D |
0170: MOVLW FA |
0171: MOVWF 5E |
0172: CALL 07B |
0173: DECFSZ 5D,F |
0174: GOTO 170 |
0175: BSF 03.5 |
0176: BCF 06.6 |
0177: BCF 03.5 |
0178: BCF 06.6 |
0179: BSF 03.5 |
017A: BCF 06.7 |
017B: BCF 03.5 |
017C: BCF 06.7 |
017D: BSF 03.5 |
017E: BCF 06.4 |
017F: BCF 03.5 |
0180: BCF 06.4 |
0181: BSF 03.5 |
0182: BCF 06.5 |
0183: BCF 03.5 |
0184: BCF 06.5 |
0185: MOVLW 04 |
0186: MOVWF 5D |
0187: MOVLW FA |
0188: MOVWF 5E |
0189: CALL 07B |
018A: DECFSZ 5D,F |
018B: GOTO 187 |
.................... BL; BR; Delay_ms(1000); STOPL; STOPR; Delay_ms(1000); |
018C: BSF 03.5 |
018D: BCF 06.6 |
018E: BCF 03.5 |
018F: BCF 06.6 |
0190: BSF 03.5 |
0191: BCF 06.7 |
0192: BCF 03.5 |
0193: BSF 06.7 |
0194: BSF 03.5 |
0195: BCF 06.4 |
0196: BCF 03.5 |
0197: BCF 06.4 |
0198: BSF 03.5 |
0199: BCF 06.5 |
019A: BCF 03.5 |
019B: BSF 06.5 |
019C: MOVLW 04 |
019D: MOVWF 5D |
019E: MOVLW FA |
019F: MOVWF 5E |
01A0: CALL 07B |
01A1: DECFSZ 5D,F |
01A2: GOTO 19E |
01A3: BSF 03.5 |
01A4: BCF 06.6 |
01A5: BCF 03.5 |
01A6: BCF 06.6 |
01A7: BSF 03.5 |
01A8: BCF 06.7 |
01A9: BCF 03.5 |
01AA: BCF 06.7 |
01AB: BSF 03.5 |
01AC: BCF 06.4 |
01AD: BCF 03.5 |
01AE: BCF 06.4 |
01AF: BSF 03.5 |
01B0: BCF 06.5 |
01B1: BCF 03.5 |
01B2: BCF 06.5 |
01B3: MOVLW 04 |
01B4: MOVWF 5D |
01B5: MOVLW FA |
01B6: MOVWF 5E |
01B7: CALL 07B |
01B8: DECFSZ 5D,F |
01B9: GOTO 1B5 |
.................... }; |
01BA: GOTO 090 |
.................... while (input(DIAG_SENSORS)) // spusteni diagnostiky cidel |
.................... { |
01BB: BSF 03.5 |
01BC: BSF 06.2 |
01BD: BCF 03.5 |
01BE: BTFSS 06.2 |
01BF: GOTO 1EE |
.................... if (RSENSOR) beep(1000,1000); |
01C0: BSF 03.5 |
01C1: BTFSC 1C.7 |
01C2: GOTO 1CE |
01C3: MOVLW 03 |
01C4: BCF 03.5 |
01C5: MOVWF 5E |
01C6: MOVLW E8 |
01C7: MOVWF 5D |
01C8: MOVLW 03 |
01C9: MOVWF 60 |
01CA: MOVLW E8 |
01CB: MOVWF 5F |
01CC: CALL 055 |
01CD: BSF 03.5 |
.................... if (LSENSOR) beep(2000,2000); |
01CE: BTFSC 1C.6 |
01CF: GOTO 1DB |
01D0: MOVLW 07 |
01D1: BCF 03.5 |
01D2: MOVWF 5E |
01D3: MOVLW D0 |
01D4: MOVWF 5D |
01D5: MOVLW 07 |
01D6: MOVWF 60 |
01D7: MOVLW D0 |
01D8: MOVWF 5F |
01D9: CALL 055 |
01DA: BSF 03.5 |
.................... if ((read_adc(ADC_READ_ONLY)<BUMPER_TRESHOLD)) beep(3000,3000); |
01DB: BCF 03.5 |
01DC: BTFSS 1F.2 |
01DD: GOTO 1E0 |
01DE: BSF 03.5 |
01DF: GOTO 1DB |
01E0: MOVF 1E,W |
01E1: SUBLW 7F |
01E2: BTFSS 03.0 |
01E3: GOTO 1ED |
01E4: MOVLW 0B |
01E5: MOVWF 5E |
01E6: MOVLW B8 |
01E7: MOVWF 5D |
01E8: MOVLW 0B |
01E9: MOVWF 60 |
01EA: MOVLW B8 |
01EB: MOVWF 5F |
01EC: CALL 055 |
.................... }; |
01ED: GOTO 1BB |
.................... } |
01EE: BCF 0A.3 |
01EF: GOTO 31F (RETURN) |
.................... /////////////////////////////////////////////////////////////////////////////// |
.................... void OtocSe() // otoci se zpet, kdyz je prekazka |
.................... { |
.................... unsigned int16 n; |
.................... |
.................... BR;BL; |
01F0: BSF 03.5 |
01F1: BCF 06.4 |
01F2: BCF 03.5 |
01F3: BCF 06.4 |
01F4: BSF 03.5 |
01F5: BCF 06.5 |
01F6: BCF 03.5 |
01F7: BSF 06.5 |
01F8: BSF 03.5 |
01F9: BCF 06.6 |
01FA: BCF 03.5 |
01FB: BCF 06.6 |
01FC: BSF 03.5 |
01FD: BCF 06.7 |
01FE: BCF 03.5 |
01FF: BSF 06.7 |
.................... beep(800,400); |
0200: MOVLW 03 |
0201: MOVWF 5E |
0202: MOVLW 20 |
0203: MOVWF 5D |
0204: MOVLW 01 |
0205: MOVWF 60 |
0206: MOVLW 90 |
0207: MOVWF 5F |
0208: CALL 055 |
.................... beep(2000,1000); |
0209: MOVLW 07 |
020A: MOVWF 5E |
020B: MOVLW D0 |
020C: MOVWF 5D |
020D: MOVLW 03 |
020E: MOVWF 60 |
020F: MOVLW E8 |
0210: MOVWF 5F |
0211: CALL 055 |
.................... beep(900,400); |
0212: MOVLW 03 |
0213: MOVWF 5E |
0214: MOVLW 84 |
0215: MOVWF 5D |
0216: MOVLW 01 |
0217: MOVWF 60 |
0218: MOVLW 90 |
0219: MOVWF 5F |
021A: CALL 055 |
.................... |
.................... BR; FL; Delay_ms(50); // otoc se 30° do prava |
021B: BSF 03.5 |
021C: BCF 06.4 |
021D: BCF 03.5 |
021E: BCF 06.4 |
021F: BSF 03.5 |
0220: BCF 06.5 |
0221: BCF 03.5 |
0222: BSF 06.5 |
0223: BSF 03.5 |
0224: BCF 06.7 |
0225: BCF 03.5 |
0226: BCF 06.7 |
0227: BSF 03.5 |
0228: BCF 06.6 |
0229: BCF 03.5 |
022A: BSF 06.6 |
022B: MOVLW 32 |
022C: MOVWF 5E |
022D: CALL 07B |
.................... STOPL; STOPR; |
022E: BSF 03.5 |
022F: BCF 06.6 |
0230: BCF 03.5 |
0231: BCF 06.6 |
0232: BSF 03.5 |
0233: BCF 06.7 |
0234: BCF 03.5 |
0235: BCF 06.7 |
0236: BSF 03.5 |
0237: BCF 06.4 |
0238: BCF 03.5 |
0239: BCF 06.4 |
023A: BSF 03.5 |
023B: BCF 06.5 |
023C: BCF 03.5 |
023D: BCF 06.5 |
.................... beep(1000,1000); |
023E: MOVLW 03 |
023F: MOVWF 5E |
0240: MOVLW E8 |
0241: MOVWF 5D |
0242: MOVLW 03 |
0243: MOVWF 60 |
0244: MOVLW E8 |
0245: MOVWF 5F |
0246: CALL 055 |
.................... |
.................... BR; FL; |
0247: BSF 03.5 |
0248: BCF 06.4 |
0249: BCF 03.5 |
024A: BCF 06.4 |
024B: BSF 03.5 |
024C: BCF 06.5 |
024D: BCF 03.5 |
024E: BSF 06.5 |
024F: BSF 03.5 |
0250: BCF 06.7 |
0251: BCF 03.5 |
0252: BCF 06.7 |
0253: BSF 03.5 |
0254: BCF 06.6 |
0255: BCF 03.5 |
0256: BSF 06.6 |
.................... for(n=40000;n>0;n--) // toc se, dokud nenarazis na caru |
0257: MOVLW 9C |
0258: MOVWF 5C |
0259: MOVLW 40 |
025A: MOVWF 5B |
025B: MOVF 5B,F |
025C: BTFSS 03.2 |
025D: GOTO 261 |
025E: MOVF 5C,F |
025F: BTFSC 03.2 |
0260: GOTO 279 |
.................... { |
.................... line = RSENSOR; // cteni senzoru na caru |
0261: CLRF 2A |
0262: BSF 03.5 |
0263: BTFSC 1C.7 |
0264: GOTO 268 |
0265: BCF 03.5 |
0266: INCF 2A,F |
0267: BSF 03.5 |
.................... line |= LSENSOR << 1; |
0268: MOVLW 00 |
0269: BTFSS 1C.6 |
026A: MOVLW 01 |
026B: MOVWF 77 |
026C: BCF 03.0 |
026D: RLF 77,F |
026E: MOVF 77,W |
026F: BCF 03.5 |
0270: IORWF 2A,F |
.................... if (line!=0) break; |
0271: MOVF 2A,F |
0272: BTFSS 03.2 |
0273: GOTO 279 |
.................... } |
0274: MOVF 5B,W |
0275: BTFSC 03.2 |
0276: DECF 5C,F |
0277: DECF 5B,F |
0278: GOTO 25B |
.................... STOPR; STOPL; |
0279: BSF 03.5 |
027A: BCF 06.4 |
027B: BCF 03.5 |
027C: BCF 06.4 |
027D: BSF 03.5 |
027E: BCF 06.5 |
027F: BCF 03.5 |
0280: BCF 06.5 |
0281: BSF 03.5 |
0282: BCF 06.6 |
0283: BCF 03.5 |
0284: BCF 06.6 |
0285: BSF 03.5 |
0286: BCF 06.7 |
0287: BCF 03.5 |
0288: BCF 06.7 |
.................... |
.................... line=L; // caru jsme prejeli, tak je vlevo |
0289: MOVLW 02 |
028A: MOVWF 2A |
.................... cirkus=0; |
028B: CLRF 2E |
.................... } |
028C: BCF 0A.3 |
028D: GOTO 34B (RETURN) |
.................... |
.................... |
.................... void main() |
.................... { |
028E: CLRF 04 |
028F: MOVLW 1F |
0290: ANDWF 03,F |
0291: BSF 03.5 |
0292: BCF 1F.4 |
0293: BCF 1F.5 |
0294: MOVF 1B,W |
0295: ANDLW 80 |
0296: MOVWF 1B |
0297: MOVLW 07 |
0298: MOVWF 1C |
0299: MOVF 1C,W |
029A: BCF 03.5 |
029B: BCF 0D.6 |
029C: MOVLW 60 |
029D: BSF 03.5 |
029E: MOVWF 0F |
.................... unsigned int16 n; // pro FOR |
.................... unsigned int16 i; |
.................... |
.................... STOPL; STOPR; // prepne vystupy na ovladani motoru na output a zastavi |
029F: BCF 06.6 |
02A0: BCF 03.5 |
02A1: BCF 06.6 |
02A2: BSF 03.5 |
02A3: BCF 06.7 |
02A4: BCF 03.5 |
02A5: BCF 06.7 |
02A6: BSF 03.5 |
02A7: BCF 06.4 |
02A8: BCF 03.5 |
02A9: BCF 06.4 |
02AA: BSF 03.5 |
02AB: BCF 06.5 |
02AC: BCF 03.5 |
02AD: BCF 06.5 |
.................... |
.................... setup_oscillator(OSC_4MHZ|OSC_INTRC); // 4 MHz interni RC oscilator |
02AE: MOVLW 62 |
02AF: BSF 03.5 |
02B0: MOVWF 0F |
.................... |
.................... port_b_pullups(TRUE); // pullups pro piano na diagnostiku |
02B1: BCF 01.7 |
.................... setup_spi(FALSE); |
02B2: BCF 03.5 |
02B3: BCF 14.5 |
02B4: BSF 03.5 |
02B5: BCF 06.2 |
02B6: BSF 06.1 |
02B7: BCF 06.4 |
02B8: MOVLW 00 |
02B9: BCF 03.5 |
02BA: MOVWF 14 |
02BB: BSF 03.5 |
02BC: MOVWF 14 |
.................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); // Casovac pro PWM |
02BD: MOVF 01,W |
02BE: ANDLW C7 |
02BF: IORLW 08 |
02C0: MOVWF 01 |
.................... |
.................... setup_timer_2(T2_DIV_BY_4,255,10); // Casovac pro regulaci |
02C1: MOVLW 48 |
02C2: MOVWF 78 |
02C3: IORLW 05 |
02C4: BCF 03.5 |
02C5: MOVWF 12 |
02C6: MOVLW FF |
02C7: BSF 03.5 |
02C8: MOVWF 12 |
.................... // preruseni kazdych 10ms |
.................... setup_adc_ports(sAN2|VSS_VDD); // nastaveni A/D prevodniku pro naraznik |
02C9: BCF 1F.4 |
02CA: BCF 1F.5 |
02CB: MOVF 1B,W |
02CC: ANDLW 80 |
02CD: IORLW 04 |
02CE: MOVWF 1B |
.................... setup_adc(ADC_CLOCK_INTERNAL); |
02CF: BCF 1F.6 |
02D0: BCF 03.5 |
02D1: BSF 1F.6 |
02D2: BSF 1F.7 |
02D3: BSF 03.5 |
02D4: BCF 1F.7 |
02D5: BCF 03.5 |
02D6: BSF 1F.0 |
.................... set_adc_channel(2); |
02D7: MOVLW 10 |
02D8: MOVWF 78 |
02D9: MOVF 1F,W |
02DA: ANDLW C7 |
02DB: IORWF 78,W |
02DC: MOVWF 1F |
.................... setup_timer_1(T1_INTERNAL|T1_DIV_BY_1); // Casovac pro naraznik |
02DD: MOVLW 85 |
02DE: MOVWF 10 |
.................... setup_ccp1(CCP_COMPARE_RESET_TIMER); |
02DF: BSF 03.5 |
02E0: BSF 06.3 |
02E1: MOVLW 0B |
02E2: BCF 03.5 |
02E3: MOVWF 17 |
.................... CCP_1=(2^10)-1; // prevod kazdou 1ms |
02E4: CLRF 16 |
02E5: MOVLW 07 |
02E6: MOVWF 15 |
.................... |
.................... setup_comparator(A0_VR_A1_VR); // inicializace komparatoru pro cidla cary |
02E7: MOVLW 02 |
02E8: BSF 03.5 |
02E9: MOVWF 1C |
02EA: MOVF 05,W |
02EB: IORLW 03 |
02EC: MOVWF 05 |
02ED: MOVLW 03 |
02EE: MOVWF 77 |
02EF: DECFSZ 77,F |
02F0: GOTO 2EF |
02F1: MOVF 1C,W |
02F2: BCF 03.5 |
02F3: BCF 0D.6 |
.................... setup_vref(VREF_HIGH|TRESHOLD); // 32 kroku od 0.25 do 0.75 Vdd |
02F4: MOVLW 8F |
02F5: BSF 03.5 |
02F6: MOVWF 1D |
.................... |
.................... Beep(1000,200); //double beep |
02F7: MOVLW 03 |
02F8: BCF 03.5 |
02F9: MOVWF 5E |
02FA: MOVLW E8 |
02FB: MOVWF 5D |
02FC: CLRF 60 |
02FD: MOVLW C8 |
02FE: MOVWF 5F |
02FF: CALL 055 |
.................... Delay_ms(50); |
0300: MOVLW 32 |
0301: MOVWF 5E |
0302: CALL 07B |
.................... Beep(1000,200); |
0303: MOVLW 03 |
0304: MOVWF 5E |
0305: MOVLW E8 |
0306: MOVWF 5D |
0307: CLRF 60 |
0308: MOVLW C8 |
0309: MOVWF 5F |
030A: CALL 055 |
.................... Delay_ms(1000); // 1s |
030B: MOVLW 04 |
030C: MOVWF 5B |
030D: MOVLW FA |
030E: MOVWF 5E |
030F: CALL 07B |
0310: DECFSZ 5B,F |
0311: GOTO 30D |
.................... |
.................... // povoleni rizeni rychlosti zataceni pres preruseni |
.................... enable_interrupts(INT_TIMER2); |
0312: BSF 03.5 |
0313: BSF 0C.1 |
.................... enable_interrupts(GLOBAL); |
0314: MOVLW C0 |
0315: BCF 03.5 |
0316: IORWF 0B,F |
.................... |
.................... /*---------------------------------------------------------------------------*/ |
.................... sensors=S; |
0317: MOVLW 03 |
0318: MOVWF 29 |
.................... line=S; |
0319: MOVWF 2A |
.................... last=S; |
031A: MOVWF 2C |
.................... cirkus=0; |
031B: CLRF 2E |
.................... // movement=S; |
.................... speed=FW_POMALU; |
031C: MOVLW AA |
031D: MOVWF 2B |
.................... |
.................... diagnostika(); |
031E: GOTO 090 |
.................... Delay_ms(500); |
031F: MOVLW 02 |
0320: MOVWF 5B |
0321: MOVLW FA |
0322: MOVWF 5E |
0323: CALL 07B |
0324: DECFSZ 5B,F |
0325: GOTO 321 |
.................... Beep(1000,200); |
0326: MOVLW 03 |
0327: MOVWF 5E |
0328: MOVLW E8 |
0329: MOVWF 5D |
032A: CLRF 60 |
032B: MOVLW C8 |
032C: MOVWF 5F |
032D: CALL 055 |
.................... Delay_ms(500); |
032E: MOVLW 02 |
032F: MOVWF 5B |
0330: MOVLW FA |
0331: MOVWF 5E |
0332: CALL 07B |
0333: DECFSZ 5B,F |
0334: GOTO 330 |
.................... |
.................... while(true) // hlavni smycka (jizda podle cary) |
.................... { |
.................... sensors = RSENSOR; // cteni senzoru na caru |
0335: CLRF 29 |
0336: BSF 03.5 |
0337: BTFSC 1C.7 |
0338: GOTO 33C |
0339: BCF 03.5 |
033A: INCF 29,F |
033B: BSF 03.5 |
.................... sensors |= LSENSOR << 1; |
033C: MOVLW 00 |
033D: BTFSS 1C.6 |
033E: MOVLW 01 |
033F: MOVWF 77 |
0340: BCF 03.0 |
0341: RLF 77,F |
0342: MOVF 77,W |
0343: BCF 03.5 |
0344: IORWF 29,F |
.................... |
.................... if (read_adc(ADC_READ_ONLY)<BUMPER_TRESHOLD) OtocSe(); |
0345: BTFSC 1F.2 |
0346: GOTO 345 |
0347: MOVF 1E,W |
0348: SUBLW 7F |
0349: BTFSC 03.0 |
034A: GOTO 1F0 |
.................... |
.................... switch (sensors) // zatacej podle toho, kde vidis caru |
.................... { |
034B: MOVF 29,W |
034C: XORLW 03 |
034D: BTFSC 03.2 |
034E: GOTO 356 |
034F: XORLW 01 |
0350: BTFSC 03.2 |
0351: GOTO 38B |
0352: XORLW 03 |
0353: BTFSC 03.2 |
0354: GOTO 3C2 |
0355: GOTO 3F9 |
.................... case S: // rovne |
.................... GO(L, F, FW_STREDNE+rovinka); GO(R, F, FW_STREDNE+rovinka); |
0356: MOVF 01,W |
0357: MOVWF 5B |
0358: MOVLW BE |
0359: ADDWF 2D,W |
035A: SUBWF 5B,W |
035B: BTFSC 03.2 |
035C: GOTO 35F |
035D: BTFSC 03.0 |
035E: GOTO 368 |
035F: BSF 03.5 |
0360: BCF 06.7 |
0361: BCF 03.5 |
0362: BCF 06.7 |
0363: BSF 03.5 |
0364: BCF 06.6 |
0365: BCF 03.5 |
0366: BSF 06.6 |
0367: GOTO 370 |
0368: BSF 03.5 |
0369: BCF 06.6 |
036A: BCF 03.5 |
036B: BCF 06.6 |
036C: BSF 03.5 |
036D: BCF 06.7 |
036E: BCF 03.5 |
036F: BCF 06.7 |
0370: MOVF 01,W |
0371: MOVWF 5B |
0372: MOVLW BE |
0373: ADDWF 2D,W |
0374: SUBWF 5B,W |
0375: BTFSC 03.2 |
0376: GOTO 379 |
0377: BTFSC 03.0 |
0378: GOTO 382 |
0379: BSF 03.5 |
037A: BCF 06.5 |
037B: BCF 03.5 |
037C: BCF 06.5 |
037D: BSF 03.5 |
037E: BCF 06.4 |
037F: BCF 03.5 |
0380: BSF 06.4 |
0381: GOTO 38A |
0382: BSF 03.5 |
0383: BCF 06.4 |
0384: BCF 03.5 |
0385: BCF 06.4 |
0386: BSF 03.5 |
0387: BCF 06.5 |
0388: BCF 03.5 |
0389: BCF 06.5 |
.................... continue; |
038A: GOTO 335 |
.................... case L: // trochu vlevo |
.................... GO(L, F, FW_POMALU+rovinka); GO(R, F, FW_STREDNE+rovinka); |
038B: MOVF 01,W |
038C: MOVWF 5B |
038D: MOVLW AA |
038E: ADDWF 2D,W |
038F: SUBWF 5B,W |
0390: BTFSC 03.2 |
0391: GOTO 394 |
0392: BTFSC 03.0 |
0393: GOTO 39D |
0394: BSF 03.5 |
0395: BCF 06.7 |
0396: BCF 03.5 |
0397: BCF 06.7 |
0398: BSF 03.5 |
0399: BCF 06.6 |
039A: BCF 03.5 |
039B: BSF 06.6 |
039C: GOTO 3A5 |
039D: BSF 03.5 |
039E: BCF 06.6 |
039F: BCF 03.5 |
03A0: BCF 06.6 |
03A1: BSF 03.5 |
03A2: BCF 06.7 |
03A3: BCF 03.5 |
03A4: BCF 06.7 |
03A5: MOVF 01,W |
03A6: MOVWF 5B |
03A7: MOVLW BE |
03A8: ADDWF 2D,W |
03A9: SUBWF 5B,W |
03AA: BTFSC 03.2 |
03AB: GOTO 3AE |
03AC: BTFSC 03.0 |
03AD: GOTO 3B7 |
03AE: BSF 03.5 |
03AF: BCF 06.5 |
03B0: BCF 03.5 |
03B1: BCF 06.5 |
03B2: BSF 03.5 |
03B3: BCF 06.4 |
03B4: BCF 03.5 |
03B5: BSF 06.4 |
03B6: GOTO 3BF |
03B7: BSF 03.5 |
03B8: BCF 06.4 |
03B9: BCF 03.5 |
03BA: BCF 06.4 |
03BB: BSF 03.5 |
03BC: BCF 06.5 |
03BD: BCF 03.5 |
03BE: BCF 06.5 |
.................... line=L; |
03BF: MOVLW 02 |
03C0: MOVWF 2A |
.................... continue; |
03C1: GOTO 335 |
.................... case R: // trochu vpravo |
.................... GO(R, F, FW_POMALU+rovinka); GO(L, F, FW_STREDNE+rovinka); |
03C2: MOVF 01,W |
03C3: MOVWF 5B |
03C4: MOVLW AA |
03C5: ADDWF 2D,W |
03C6: SUBWF 5B,W |
03C7: BTFSC 03.2 |
03C8: GOTO 3CB |
03C9: BTFSC 03.0 |
03CA: GOTO 3D4 |
03CB: BSF 03.5 |
03CC: BCF 06.5 |
03CD: BCF 03.5 |
03CE: BCF 06.5 |
03CF: BSF 03.5 |
03D0: BCF 06.4 |
03D1: BCF 03.5 |
03D2: BSF 06.4 |
03D3: GOTO 3DC |
03D4: BSF 03.5 |
03D5: BCF 06.4 |
03D6: BCF 03.5 |
03D7: BCF 06.4 |
03D8: BSF 03.5 |
03D9: BCF 06.5 |
03DA: BCF 03.5 |
03DB: BCF 06.5 |
03DC: MOVF 01,W |
03DD: MOVWF 5B |
03DE: MOVLW BE |
03DF: ADDWF 2D,W |
03E0: SUBWF 5B,W |
03E1: BTFSC 03.2 |
03E2: GOTO 3E5 |
03E3: BTFSC 03.0 |
03E4: GOTO 3EE |
03E5: BSF 03.5 |
03E6: BCF 06.7 |
03E7: BCF 03.5 |
03E8: BCF 06.7 |
03E9: BSF 03.5 |
03EA: BCF 06.6 |
03EB: BCF 03.5 |
03EC: BSF 06.6 |
03ED: GOTO 3F6 |
03EE: BSF 03.5 |
03EF: BCF 06.6 |
03F0: BCF 03.5 |
03F1: BCF 06.6 |
03F2: BSF 03.5 |
03F3: BCF 06.7 |
03F4: BCF 03.5 |
03F5: BCF 06.7 |
.................... line=R; |
03F6: MOVLW 01 |
03F7: MOVWF 2A |
.................... continue; |
03F8: GOTO 335 |
.................... default: // kdyz jsou obe cidla mimo caru, tak pokracuj dal |
.................... }; |
.................... rovinka=0; |
03F9: CLRF 2D |
.................... |
.................... if (last!=line) // pokud si prejel caru z jedne strany na druhou stranu, tak zabrzdi |
03FA: MOVF 2A,W |
03FB: SUBWF 2C,W |
03FC: BTFSC 03.2 |
03FD: GOTO 48F |
.................... { |
.................... last=line; |
03FE: MOVF 2A,W |
03FF: MOVWF 2C |
.................... speed=FW_ZATACKA; |
0400: MOVLW C8 |
0401: MOVWF 2B |
.................... cirkus++; |
0402: INCF 2E,F |
.................... if (cirkus>10) |
0403: MOVF 2E,W |
0404: SUBLW 0A |
0405: BTFSC 03.0 |
0406: GOTO 48F |
.................... { |
.................... STOPL; STOPR; |
0407: BSF 03.5 |
0408: BCF 06.6 |
0409: BCF 03.5 |
040A: BCF 06.6 |
040B: BSF 03.5 |
040C: BCF 06.7 |
040D: BCF 03.5 |
040E: BCF 06.7 |
040F: BSF 03.5 |
0410: BCF 06.4 |
0411: BCF 03.5 |
0412: BCF 06.4 |
0413: BSF 03.5 |
0414: BCF 06.5 |
0415: BCF 03.5 |
0416: BCF 06.5 |
.................... cirkus=0; |
0417: CLRF 2E |
.................... disable_interrupts(GLOBAL); |
0418: BCF 0B.6 |
0419: BCF 0B.7 |
041A: BTFSC 0B.7 |
041B: GOTO 419 |
.................... beep(1000,400); |
041C: MOVLW 03 |
041D: MOVWF 5E |
041E: MOVLW E8 |
041F: MOVWF 5D |
0420: MOVLW 01 |
0421: MOVWF 60 |
0422: MOVLW 90 |
0423: MOVWF 5F |
0424: CALL 055 |
.................... for(n=3000; n>3950; n--) beep(n,10); |
0425: MOVLW 0B |
0426: MOVWF 58 |
0427: MOVLW B8 |
0428: MOVWF 57 |
0429: MOVF 58,W |
042A: SUBLW 0E |
042B: BTFSC 03.0 |
042C: GOTO 441 |
042D: XORLW FF |
042E: BTFSS 03.2 |
042F: GOTO 434 |
0430: MOVF 57,W |
0431: SUBLW 6E |
0432: BTFSC 03.0 |
0433: GOTO 441 |
0434: MOVF 58,W |
0435: MOVWF 5E |
0436: MOVF 57,W |
0437: MOVWF 5D |
0438: CLRF 60 |
0439: MOVLW 0A |
043A: MOVWF 5F |
043B: CALL 055 |
043C: MOVF 57,W |
043D: BTFSC 03.2 |
043E: DECF 58,F |
043F: DECF 57,F |
0440: GOTO 429 |
.................... beep(2000,200); |
0441: MOVLW 07 |
0442: MOVWF 5E |
0443: MOVLW D0 |
0444: MOVWF 5D |
0445: CLRF 60 |
0446: MOVLW C8 |
0447: MOVWF 5F |
0448: CALL 055 |
.................... beep(900,400); |
0449: MOVLW 03 |
044A: MOVWF 5E |
044B: MOVLW 84 |
044C: MOVWF 5D |
044D: MOVLW 01 |
044E: MOVWF 60 |
044F: MOVLW 90 |
0450: MOVWF 5F |
0451: CALL 055 |
.................... for(n=2950; n<3000; n++) beep(n,10); |
0452: MOVLW 0B |
0453: MOVWF 58 |
0454: MOVLW 86 |
0455: MOVWF 57 |
0456: MOVF 58,W |
0457: SUBLW 0B |
0458: BTFSS 03.0 |
0459: GOTO 46C |
045A: BTFSS 03.2 |
045B: GOTO 460 |
045C: MOVF 57,W |
045D: SUBLW B7 |
045E: BTFSS 03.0 |
045F: GOTO 46C |
0460: MOVF 58,W |
0461: MOVWF 5E |
0462: MOVF 57,W |
0463: MOVWF 5D |
0464: CLRF 60 |
0465: MOVLW 0A |
0466: MOVWF 5F |
0467: CALL 055 |
0468: INCF 57,F |
0469: BTFSC 03.2 |
046A: INCF 58,F |
046B: GOTO 456 |
.................... beep(4000,400); |
046C: MOVLW 0F |
046D: MOVWF 5E |
046E: MOVLW A0 |
046F: MOVWF 5D |
0470: MOVLW 01 |
0471: MOVWF 60 |
0472: MOVLW 90 |
0473: MOVWF 5F |
0474: CALL 055 |
.................... beep(1000,100); |
0475: MOVLW 03 |
0476: MOVWF 5E |
0477: MOVLW E8 |
0478: MOVWF 5D |
0479: CLRF 60 |
047A: MOVLW 64 |
047B: MOVWF 5F |
047C: CALL 055 |
.................... beep(3000,400); |
047D: MOVLW 0B |
047E: MOVWF 5E |
047F: MOVLW B8 |
0480: MOVWF 5D |
0481: MOVLW 01 |
0482: MOVWF 60 |
0483: MOVLW 90 |
0484: MOVWF 5F |
0485: CALL 055 |
.................... Delay_ms(1000); |
0486: MOVLW 04 |
0487: MOVWF 5B |
0488: MOVLW FA |
0489: MOVWF 5E |
048A: CALL 07B |
048B: DECFSZ 5B,F |
048C: GOTO 488 |
.................... enable_interrupts(GLOBAL); |
048D: MOVLW C0 |
048E: IORWF 0B,F |
.................... } |
.................... }; |
.................... |
.................... if (L==line) // kdyz jsou obe cidla mimo caru, zatoc na caru |
048F: MOVF 2A,W |
0490: SUBLW 02 |
0491: BTFSS 03.2 |
0492: GOTO 4B1 |
.................... { |
.................... STOPL; |
0493: BSF 03.5 |
0494: BCF 06.6 |
0495: BCF 03.5 |
0496: BCF 06.6 |
0497: BSF 03.5 |
0498: BCF 06.7 |
0499: BCF 03.5 |
049A: BCF 06.7 |
.................... GO(R, F, speed); |
049B: MOVF 01,W |
049C: SUBWF 2B,W |
049D: BTFSS 03.0 |
049E: GOTO 4A8 |
049F: BSF 03.5 |
04A0: BCF 06.5 |
04A1: BCF 03.5 |
04A2: BCF 06.5 |
04A3: BSF 03.5 |
04A4: BCF 06.4 |
04A5: BCF 03.5 |
04A6: BSF 06.4 |
04A7: GOTO 4B0 |
04A8: BSF 03.5 |
04A9: BCF 06.4 |
04AA: BCF 03.5 |
04AB: BCF 06.4 |
04AC: BSF 03.5 |
04AD: BCF 06.5 |
04AE: BCF 03.5 |
04AF: BCF 06.5 |
.................... } |
.................... else |
04B0: GOTO 4CE |
.................... { |
.................... STOPR; |
04B1: BSF 03.5 |
04B2: BCF 06.4 |
04B3: BCF 03.5 |
04B4: BCF 06.4 |
04B5: BSF 03.5 |
04B6: BCF 06.5 |
04B7: BCF 03.5 |
04B8: BCF 06.5 |
.................... GO(L, F, speed); |
04B9: MOVF 01,W |
04BA: SUBWF 2B,W |
04BB: BTFSS 03.0 |
04BC: GOTO 4C6 |
04BD: BSF 03.5 |
04BE: BCF 06.7 |
04BF: BCF 03.5 |
04C0: BCF 06.7 |
04C1: BSF 03.5 |
04C2: BCF 06.6 |
04C3: BCF 03.5 |
04C4: BSF 06.6 |
04C5: GOTO 4CE |
04C6: BSF 03.5 |
04C7: BCF 06.6 |
04C8: BCF 03.5 |
04C9: BCF 06.6 |
04CA: BSF 03.5 |
04CB: BCF 06.7 |
04CC: BCF 03.5 |
04CD: BCF 06.7 |
.................... } |
.................... } // while(true) |
04CE: GOTO 335 |
.................... } |
.................... |
04CF: SLEEP |
Configuration Fuses: |
Word 1: 3F38 NOWDT NOPUT MCLR NOBROWNOUT NOLVP NOCPD NOWRT NODEBUG CCPB0 NOPROTECT INTRC_IO |
Word 2: 3FFC NOFCMEN NOIESO |
/Designs/ROBOTS/Merkur/SW/vystava/tank.PJT |
---|
0,0 → 1,40 |
[PROJECT] |
Target=tank.HEX |
Development_Mode= |
Processor=0x688F |
ToolSuite=CCS |
[Directories] |
Include=C:\Program Files\PICC\devices\;C:\Program Files\PICC\drivers\;C:\library\CCS; |
Library= |
LinkerScript= |
[Target Data] |
FileList=tank.c; |
BuildTool=C-COMPILER |
OptionString=+FM |
AdditionalOptionString= |
BuildRequired=1 |
[tank.c] |
Type=4 |
Path= |
FileList= |
BuildTool= |
OptionString= |
AdditionalOptionString= |
[mru-list] |
1=tank.c |
[Windows] |
0=0000 tank.c 0 0 796 451 3 0 |
[Opened Files] |
1=D:\KAKLIK\programy\PIC_C\roboti\merkur\PIC16F88\vystava\tank.c |
2=D:\KAKL\PIC\MerkurI\tank.c |
3=D:\KAKL\PIC\MerkurV\tank.c |
4=D:\KAKLIK\programy\PIC_C\roboti\merkur\PIC16F88\turn_R\tank.c |
5= |
6= |
7= |
/Designs/ROBOTS/Merkur/SW/vystava/tank.SYM |
---|
0,0 → 1,69 |
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 sensors |
02A line |
02B speed |
02C last |
02D rovinka |
02E cirkus |
02F-056 AXstring |
057-058 main.n |
059-05A main.i |
05B-05C diagnostika.n |
05B-05C OtocSe.n |
05B main.@SCRATCH |
05D-05E beep.period |
05D diagnostika.@SCRATCH |
05D OtocSe.@SCRATCH |
05E @delay_ms1.P1 |
05F-060 beep.length |
061-062 beep.nn |
063 @delay_us1.P1 |
077 @SCRATCH |
078 @SCRATCH |
078 _RETURN_ |
079 @SCRATCH |
07A @SCRATCH |
07B @SCRATCH |
09C.6 C1OUT |
09C.7 C2OUT |
007B @delay_ms1 |
0042 @delay_us1 |
0037 TIMER2_isr |
0055 beep |
0090 diagnostika |
01F0 OtocSe |
028E main |
028E @cinit |
Project Files: |
D:\KAKLIK\programy\PIC_C\roboti\merkur\PIC16F88\vystava\tank.c |
D:\KAKLIK\programy\PIC_C\roboti\merkur\PIC16F88\vystava\tank.h |
C:\Program Files\PICC\devices\16F88.h |
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\merkur\PIC16F88\vystava\tank.err |
INHX8: D:\KAKLIK\programy\PIC_C\roboti\merkur\PIC16F88\vystava\tank.HEX |
Symbols: D:\KAKLIK\programy\PIC_C\roboti\merkur\PIC16F88\vystava\tank.SYM |
List: D:\KAKLIK\programy\PIC_C\roboti\merkur\PIC16F88\vystava\tank.LST |
Debug/COFF: D:\KAKLIK\programy\PIC_C\roboti\merkur\PIC16F88\vystava\tank.cof |
Call Tree: D:\KAKLIK\programy\PIC_C\roboti\merkur\PIC16F88\vystava\tank.tre |
Statistics: D:\KAKLIK\programy\PIC_C\roboti\merkur\PIC16F88\vystava\tank.sta |
/Designs/ROBOTS/Merkur/SW/vystava/tank.c |
---|
0,0 → 1,234 |
#include "tank.h" |
unsigned int8 sensors; // pomocna promenna pro cteni cidel na caru |
unsigned int8 line; // na ktere strane byla detekovana cara |
unsigned int8 speed; // rychlost zataceni |
unsigned int8 last; // kde byla cara, kdyz byly minule cidla mimo |
unsigned int8 rovinka; // pocitadlo pro zjisteni rovneho useku |
int cirkus; |
// Konstanty pro dynamiku pohybu |
#define T_DIRA 120 // po jakem case zataceni se detekuje dira |
#define FW_POMALU 170 // trochu mimo caru vnitrni pas |
#define FW_ZATACKA 200 // rychlost vnejsiho kola pri zataceni |
#define FW_STREDNE 190 // trochu mimo caru vnejsi pas |
#define COUVANI 750 // couvnuti zpet na caru, po detekci diry |
#define MAX_ROVINKA (255-FW_STREDNE) |
#define TRESHOLD 15 // rozhodovaci uroven komparatoru, 0xF = 0.75*Vdd |
#define BUMPER_TRESHOLD 128 |
//motory //Napred vypnout potom zapnout! |
#define FR output_low(PIN_B5); output_high(PIN_B4) // Vpred |
#define FL output_low(PIN_B7); output_high(PIN_B6) |
#define BR output_low(PIN_B4); output_high(PIN_B5) // Vzad |
#define BL output_low(PIN_B6); output_high(PIN_B7) |
#define STOPR output_low(PIN_B4);output_low(PIN_B5) // Zastav |
#define STOPL output_low(PIN_B6);output_low(PIN_B7) |
#define L 0b10 // left |
#define R 0b01 // right |
#define S 0b11 // straight |
//cidla |
#define RSENSOR !C2OUT // Senzory na caru |
#define LSENSOR !C1OUT |
#define BUMPER PIN_A4 // Senzor na cihlu |
#define DIAG_SERVO PIN_B3 // Propojka pro diagnosticky mod |
#define DIAG_SENSORS PIN_B2 // Propojka pro diagnosticky mod |
#DEFINE SOUND_HI PIN_A6 // komplementarni vystupy pro piezo pipak |
#DEFINE SOUND_LO PIN_A7 |
char AXstring[40]; // Buffer pro prenos telemetrie |
// makro pro PWM |
#define GO(motor, direction, power) if(get_timer0()<=power) \ |
{direction##motor;} else {stop##motor;} |
#int_TIMER2 |
void TIMER2_isr() |
{ |
if (speed<255) speed++; |
if (rovinka<MAX_ROVINKA) rovinka++; |
} |
// Primitivni Pipani |
void beep(unsigned int16 period, unsigned int16 length) |
{ |
unsigned int16 nn; |
for(nn=length; nn>0; nn--) |
{ |
output_high(SOUND_HI);output_low(SOUND_LO); |
delay_us(period); |
output_high(SOUND_LO);output_low(SOUND_HI); |
delay_us(period); |
} |
} |
/******************************************************************************/ |
void diagnostika() |
{ |
unsigned int16 n; |
while (input(DIAG_SERVO)) // Propojka, ktera spousti diagnostiku |
{ |
for (n=500; n<800; n+=100) |
{ |
beep(n,n); //beep UP |
}; |
Delay_ms(1000); |
//zastav vse |
STOPL; STOPR; |
//pravy pas |
FR; Delay_ms(1000); STOPR; Delay_ms(1000); |
BR; Delay_ms(1000); STOPR; Delay_ms(1000); |
Beep(880,100); Delay_ms(1000); |
//levy pas |
FL; Delay_ms(1000); STOPL; Delay_ms(1000); |
BL; Delay_ms(1000); STOPL; Delay_ms(1000); |
Beep(880,100); Delay_ms(1000); |
//oba pasy |
FL; FR; Delay_ms(1000); STOPL; STOPR; Delay_ms(1000); |
BL; BR; Delay_ms(1000); STOPL; STOPR; Delay_ms(1000); |
}; |
while (input(DIAG_SENSORS)) // spusteni diagnostiky cidel |
{ |
if (RSENSOR) beep(1000,1000); |
if (LSENSOR) beep(2000,2000); |
if ((read_adc(ADC_READ_ONLY)<BUMPER_TRESHOLD)) beep(3000,3000); |
}; |
} |
/////////////////////////////////////////////////////////////////////////////// |
void OtocSe() // otoci se zpet, kdyz je prekazka |
{ |
unsigned int16 n; |
BR;BL; |
beep(800,400); |
beep(2000,1000); |
beep(900,400); |
BR; FL; Delay_ms(50); // otoc se 30° do prava |
STOPL; STOPR; |
beep(1000,1000); |
BR; FL; |
for(n=40000;n>0;n--) // toc se, dokud nenarazis na caru |
{ |
line = RSENSOR; // cteni senzoru na caru |
line |= LSENSOR << 1; |
if (line!=0) break; |
} |
STOPR; STOPL; |
line=L; // caru jsme prejeli, tak je vlevo |
cirkus=0; |
} |
void main() |
{ |
unsigned int16 n; // pro FOR |
unsigned int16 i; |
STOPL; STOPR; // prepne vystupy na ovladani motoru na output a zastavi |
setup_oscillator(OSC_4MHZ|OSC_INTRC); // 4 MHz interni RC oscilator |
port_b_pullups(TRUE); // pullups pro piano na diagnostiku |
setup_spi(FALSE); |
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); // Casovac pro PWM |
setup_timer_2(T2_DIV_BY_4,255,10); // Casovac pro regulaci |
// preruseni kazdych 10ms |
setup_adc_ports(sAN2|VSS_VDD); // nastaveni A/D prevodniku pro naraznik |
setup_adc(ADC_CLOCK_INTERNAL); |
set_adc_channel(2); |
setup_timer_1(T1_INTERNAL|T1_DIV_BY_1); // Casovac pro naraznik |
setup_ccp1(CCP_COMPARE_RESET_TIMER); |
CCP_1=(2^10)-1; // prevod kazdou 1ms |
setup_comparator(A0_VR_A1_VR); // inicializace komparatoru pro cidla cary |
setup_vref(VREF_HIGH|TRESHOLD); // 32 kroku od 0.25 do 0.75 Vdd |
Beep(1000,200); //double beep |
Delay_ms(50); |
Beep(1000,200); |
Delay_ms(1000); // 1s |
// povoleni rizeni rychlosti zataceni pres preruseni |
enable_interrupts(INT_TIMER2); |
enable_interrupts(GLOBAL); |
/*---------------------------------------------------------------------------*/ |
sensors=S; |
line=S; |
last=S; |
cirkus=0; |
// movement=S; |
speed=FW_POMALU; |
diagnostika(); |
Delay_ms(500); |
Beep(1000,200); |
Delay_ms(500); |
while(true) // hlavni smycka (jizda podle cary) |
{ |
sensors = RSENSOR; // cteni senzoru na caru |
sensors |= LSENSOR << 1; |
if (read_adc(ADC_READ_ONLY)<BUMPER_TRESHOLD) OtocSe(); |
switch (sensors) // zatacej podle toho, kde vidis caru |
{ |
case S: // rovne |
GO(L, F, FW_STREDNE+rovinka); GO(R, F, FW_STREDNE+rovinka); |
continue; |
case L: // trochu vlevo |
GO(L, F, FW_POMALU+rovinka); GO(R, F, FW_STREDNE+rovinka); |
line=L; |
continue; |
case R: // trochu vpravo |
GO(R, F, FW_POMALU+rovinka); GO(L, F, FW_STREDNE+rovinka); |
line=R; |
continue; |
default: // kdyz jsou obe cidla mimo caru, tak pokracuj dal |
}; |
rovinka=0; |
if (last!=line) // pokud si prejel caru z jedne strany na druhou stranu, tak zabrzdi |
{ |
last=line; |
speed=FW_ZATACKA; |
cirkus++; |
if (cirkus>10) |
{ |
STOPL; STOPR; |
cirkus=0; |
disable_interrupts(GLOBAL); |
beep(1000,400); |
for(n=3000; n>3950; n--) beep(n,10); |
beep(2000,200); |
beep(900,400); |
for(n=2950; n<3000; n++) beep(n,10); |
beep(4000,400); |
beep(1000,100); |
beep(3000,400); |
Delay_ms(1000); |
enable_interrupts(GLOBAL); |
} |
}; |
if (L==line) // kdyz jsou obe cidla mimo caru, zatoc na caru |
{ |
STOPL; |
GO(R, F, speed); |
} |
else |
{ |
STOPR; |
GO(L, F, speed); |
} |
} // while(true) |
} |
/Designs/ROBOTS/Merkur/SW/vystava/tank.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 |
/Designs/ROBOTS/Merkur/SW/vystava/tank.err |
---|
0,0 → 1,0 |
No Errors |
/Designs/ROBOTS/Merkur/SW/vystava/tank.h |
---|
0,0 → 1,5 |
#include <16F88.h> |
#device adc=8 |
#fuses NOWDT,INTRC_IO, NOPUT, MCLR, NOBROWNOUT, NOLVP, NOCPD, NOWRT, NODEBUG, NOPROTECT, NOFCMEN, NOIESO |
#use delay(clock=4000000) |
/Designs/ROBOTS/Merkur/SW/vystava/tank.sta |
---|
0,0 → 1,35 |
ROM used: 1232 (30%) |
1232 (30%) including unused fragments |
2 Average locations per line |
5 Average locations per statement |
RAM used: 65 (37%) at main() level |
73 (42%) worst case |
Lines Stmts % Files |
----- ----- --- ----- |
235 257 100 D:\KAKLIK\programy\PIC_C\roboti\merkur\PIC16F88\vystava\tank.c |
6 0 0 D:\KAKLIK\programy\PIC_C\roboti\merkur\PIC16F88\vystava\tank.h |
275 0 0 C:\Program Files\PICC\devices\16F88.h |
----- ----- |
1032 514 Total |
Page ROM % RAM Functions: |
---- --- --- --- ---------- |
0 21 2 1 @delay_ms1 |
0 19 2 1 @delay_us1 |
0 11 1 0 TIMER2_isr |
0 38 3 6 beep |
0 352 29 3 diagnostika |
0 158 13 3 OtocSe |
0 578 47 5 main |
Segment Used Free |
--------- ---- ---- |
00000-00003 4 0 |
00004-00036 51 0 |
00037-007FF 1177 816 |
00800-00FFF 0 2048 |
/Designs/ROBOTS/Merkur/SW/vystava/tank.tre |
---|
0,0 → 1,90 |
ÀÄtank |
ÃÄmain 0/578 Ram=5 |
³ ÃÄ??0?? |
³ ÃÄbeep 0/38 Ram=6 |
³ ³ ÃÄ@delay_us1 0/19 Ram=1 |
³ ³ ÀÄ@delay_us1 0/19 Ram=1 |
³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ÃÄbeep 0/38 Ram=6 |
³ ³ ÃÄ@delay_us1 0/19 Ram=1 |
³ ³ ÀÄ@delay_us1 0/19 Ram=1 |
³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ÃÄdiagnostika 0/352 Ram=3 |
³ ³ ÃÄbeep 0/38 Ram=6 |
³ ³ ³ ÃÄ@delay_us1 0/19 Ram=1 |
³ ³ ³ ÀÄ@delay_us1 0/19 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄbeep 0/38 Ram=6 |
³ ³ ³ ÃÄ@delay_us1 0/19 Ram=1 |
³ ³ ³ ÀÄ@delay_us1 0/19 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄbeep 0/38 Ram=6 |
³ ³ ³ ÃÄ@delay_us1 0/19 Ram=1 |
³ ³ ³ ÀÄ@delay_us1 0/19 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÃÄbeep 0/38 Ram=6 |
³ ³ ³ ÃÄ@delay_us1 0/19 Ram=1 |
³ ³ ³ ÀÄ@delay_us1 0/19 Ram=1 |
³ ³ ÃÄbeep 0/38 Ram=6 |
³ ³ ³ ÃÄ@delay_us1 0/19 Ram=1 |
³ ³ ³ ÀÄ@delay_us1 0/19 Ram=1 |
³ ³ ÀÄbeep 0/38 Ram=6 |
³ ³ ÃÄ@delay_us1 0/19 Ram=1 |
³ ³ ÀÄ@delay_us1 0/19 Ram=1 |
³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ÃÄbeep 0/38 Ram=6 |
³ ³ ÃÄ@delay_us1 0/19 Ram=1 |
³ ³ ÀÄ@delay_us1 0/19 Ram=1 |
³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ÃÄOtocSe 0/158 Ram=3 |
³ ³ ÃÄbeep 0/38 Ram=6 |
³ ³ ³ ÃÄ@delay_us1 0/19 Ram=1 |
³ ³ ³ ÀÄ@delay_us1 0/19 Ram=1 |
³ ³ ÃÄbeep 0/38 Ram=6 |
³ ³ ³ ÃÄ@delay_us1 0/19 Ram=1 |
³ ³ ³ ÀÄ@delay_us1 0/19 Ram=1 |
³ ³ ÃÄbeep 0/38 Ram=6 |
³ ³ ³ ÃÄ@delay_us1 0/19 Ram=1 |
³ ³ ³ ÀÄ@delay_us1 0/19 Ram=1 |
³ ³ ÃÄ@delay_ms1 0/21 Ram=1 |
³ ³ ÀÄbeep 0/38 Ram=6 |
³ ³ ÃÄ@delay_us1 0/19 Ram=1 |
³ ³ ÀÄ@delay_us1 0/19 Ram=1 |
³ ÃÄbeep 0/38 Ram=6 |
³ ³ ÃÄ@delay_us1 0/19 Ram=1 |
³ ³ ÀÄ@delay_us1 0/19 Ram=1 |
³ ÃÄbeep 0/38 Ram=6 |
³ ³ ÃÄ@delay_us1 0/19 Ram=1 |
³ ³ ÀÄ@delay_us1 0/19 Ram=1 |
³ ÃÄbeep 0/38 Ram=6 |
³ ³ ÃÄ@delay_us1 0/19 Ram=1 |
³ ³ ÀÄ@delay_us1 0/19 Ram=1 |
³ ÃÄbeep 0/38 Ram=6 |
³ ³ ÃÄ@delay_us1 0/19 Ram=1 |
³ ³ ÀÄ@delay_us1 0/19 Ram=1 |
³ ÃÄbeep 0/38 Ram=6 |
³ ³ ÃÄ@delay_us1 0/19 Ram=1 |
³ ³ ÀÄ@delay_us1 0/19 Ram=1 |
³ ÃÄbeep 0/38 Ram=6 |
³ ³ ÃÄ@delay_us1 0/19 Ram=1 |
³ ³ ÀÄ@delay_us1 0/19 Ram=1 |
³ ÃÄbeep 0/38 Ram=6 |
³ ³ ÃÄ@delay_us1 0/19 Ram=1 |
³ ³ ÀÄ@delay_us1 0/19 Ram=1 |
³ ÃÄbeep 0/38 Ram=6 |
³ ³ ÃÄ@delay_us1 0/19 Ram=1 |
³ ³ ÀÄ@delay_us1 0/19 Ram=1 |
³ ÀÄ@delay_ms1 0/21 Ram=1 |
ÀÄTIMER2_isr 0/11 Ram=0 |