/roboti/istrobot/camerus/SW/876/backup/camerus.c |
---|
0,0 → 1,657 |
//********* Robot Camerus pro IstRobot 2007 ************ |
//"$Id: camerus.c 253 2007-04-24 09:26:46Z kakl $" |
//***************************************************** |
#include ".\camerus.h" |
#USE FAST_IO (C) // Brana C je ve FAST_IO modu, aby slo rychle cist z kamery |
// Rychlostni konstanty |
#define RR_CIHLA 50 // Rozumna rychlost pro objizdeni cihly |
#define RR_PRERUSENI 50 // Rozumna rychlost pro priblizeni se k preruseni |
#define BRZDNA_DRAHA 0x15 // Jak daleko pred problemem se zacne brzdit |
#define TUHOS 100 // Jak dlouho se bude couvat po narazu na naraznik |
#define ODODO_CIHLA 0xD0 |
#define ODODO_TUNEL 0xFFF |
#define ODODO_PRERUSENI 0xFFF//0xB4 |
// Adresy IIC periferii |
#define COMPAS_ADR 0xC0 |
#define CAMERA_ADR 0xDC |
#define SONAR_ADR 0xE0 |
// A/D vstupy |
#define RMAX 4 // AN4/RA5 - leve cidlo na vyjeti z cary |
#define LMAX 3 // AN3/RA3 - prave cidlo na vyjeti z cary |
#define CERVENA 2 // AN2/RA2 - cervene kroutitko |
#define ZELENA 1 // AN1/RA0 - zelene kroutitko |
#define MODRA 0 // AN0/RA1 - modre kroutitko |
// I/O |
#define HREF PIN_C5 // Signal HREF z kamery (v H po celou dobu radku) |
#define PIX PIN_C6 // Vstup pro body z kamery (za trivstupim hradlem OR (dig. komparator)) |
#define SERVO PIN_B4 // Vystup na servo (1 az 2ms po cca 20ms (synchronizovano snimkovym kmitoctem)) |
#define MOT_L PIN_B5 // Smer otaceni leveho motoru; druhy pol je RC2 |
#define MOT_R PIN_B6 // Smer otaceni praveho motoru; druhy pol je RC1 |
#define MOT_1 PIN_C1 // PWM vystpy motoru |
#define MOT_2 PIN_C2 // |
#define DATA PIN_B2 // K modulu LEDbar data |
#define CP PIN_B1 // K modulu LEDbar hodiny |
//#define ODO PIN_C0 // Ze snimace z odometrie z praveho kola na TIMER1 |
// Jeden impuls je 31,25mm |
#define IRRX !input(PIN_B0) // Vstup INT, generuje preruseni pri prekazce |
#define IRTX PIN_B3 // Modulovani vysilaci IR LED na detekci prekazky |
#define PROXIMITY PIN_C7 // Cidlo kratkeho dosahu na cihlu |
#define BUMPER !input(PIN_A4) // Naraznik |
#define CASMIN 6 // Rozsah radku snimace |
#define CASMAX 192 |
#define CASAVR ((CASMAX+CASMIN) / 2) |
#define EEMAX 255 // Konec EEPROM |
#define MAXLOG 0x10 // Maximalni pocet zaznamu v logu |
#if MAXLOG>(EEMAX/3) |
#error Prekrocena velikost EEPROM |
#endif |
#define OFFSETO 0x9F //0x9F // Vystredeni serva pro objeti prekazky |
#define THR 90 // Threshold pro UV cidla na caru |
#byte INTCON = 0x0B // Interrupt configuration register |
#bit GIE = INTCON.7 |
#bit PEIE = INTCON.6 |
#bit TMR0IE = INTCON.5 |
#bit INT0IE = INTCON.4 |
#bit RBIE = INTCON.3 |
#bit TMR0IF = INTCON.2 |
#bit INT0IF = INTCON.1 |
#bit RBIF = INTCON.0 |
enum stavy {start,rozjezd,jizda,cihla,pocihle,cil}; |
stavy stav; // Kde jsme na trati |
int8 cas; // Cas hrany bila/cerna v radce |
int8 stred; // Vystredeni kolecka |
int16 odocounter; // Zaznamenani aktualniho stavu pocitadla odometrie |
int16 last_log_odo; // Posledni stav odometrie poznamenany do logu |
int16 last_log; // Cislo posledniho zaznamu v logu v EEPROM |
int8 bb_h[MAXLOG]; // Cerna skrinka MSB |
int8 bb_l[MAXLOG]; // Cerna skrinka LSB |
int8 bb_f[MAXLOG]; // Cerna skrinka priznak (typ zaznamu) |
int8 log; // Pocitadlo pro cernou skrinku |
int8 rr; // Promenna na ulozeni Rozumne rychlost |
int8 rrold; |
int16 odo_preruseni, odo_cihla, odo_tunel; // Problemy na trati |
// Zobrazeni jednoho byte na modulu LEDbar |
inline void disp(int8 x) |
{ |
int n; |
for(n=0;n<=7;n++) |
{ |
if (bit_test(x,0)) output_low(DATA); else output_high(DATA); |
output_high(CP); |
x>>=1; |
output_low(CP); |
} |
} |
// Blikani LEDbarem ve stilu Night Rider |
void NightRider(int8 x) |
{ |
int n,i,j; |
for(j=0;j<x;j++) |
{ |
i=0x01; |
for(n=0;n<7;n++) |
{ |
disp(i); |
rotate_left(&i, 1); |
delay_ms(40); |
} |
for(n=0;n<7;n++) |
{ |
disp(i); |
rotate_right(&i, 1); |
delay_ms(40); |
} |
} |
disp(i); |
delay_ms(40); |
i=0; |
disp(i); |
} |
// Zaznam LOGu do EEPROM |
void SaveLog() |
{ |
int8 n,i,xlog; |
i=0; |
for(n=0;n<=(log*3);n+=3) // Ulozeni Black Boxu do EEPROM |
{ |
write_eeprom(n,bb_f[i]); |
write_eeprom(n+1,bb_h[i]); |
write_eeprom(n+2,bb_l[i]); |
i++; |
}; |
if(log>0) {xlog=log-1;} else {xlog=0;}; |
write_eeprom(EEMAX,xlog); // Zapis poctu zaznamu na konec EEPROM |
} |
// Zaznam do Logu do RAM |
void LogLog(int8 reason, int16 log_delay) |
{ |
int16 timer_pom; |
timer_pom=get_timer1(); // Timer se musi vycist atomicky |
bb_l[log]=make8(timer_pom,0); // Zaznam |
bb_h[log]=make8(timer_pom,1); |
bb_f[log]=reason; // Typ zaznamu |
if(log<(MAXLOG-1)) log++; // Ukazatel na dalsi zaznam |
last_log_odo=timer_pom+log_delay; // Dalsi mereni nejdrive po ujeti def. vzdalenosti |
rr=rrold; // Problem skoncil, znovu jed Rozumnou Rychlosti |
} |
void ReadBlackBox() |
{ |
last_log=read_eeprom(EEMAX); // Kolik zaznamu mame od minule poznamenano? |
{ |
int8 n,i; |
i=0; |
for(n=0;n<=last_log;n++) |
{ |
if(read_eeprom(i)==0) odo_tunel=MAKE16(read_eeprom(i+2),read_eeprom(i+1)); |
if(read_eeprom(i)==0xFF) odo_cihla=MAKE16(read_eeprom(i+2),read_eeprom(i+1)); |
if((read_eeprom(i)>0) && (read_eeprom(i)<0xFF)) odo_preruseni=MAKE16(read_eeprom(i+2),read_eeprom(i+1)); |
} |
} |
} |
// Brzdeni motorama stridou 1:1 |
void brzda() |
{ |
int8 n,i; |
set_pwm1_duty(0); // vypni PWM |
set_pwm2_duty(0); |
setup_ccp1(CCP_OFF); |
setup_ccp2(CCP_OFF); |
for (n=0;n<200;n++) |
{ |
output_low(MOT_L); |
output_low(MOT_R); |
output_high(MOT_1); |
output_high(MOT_2); |
delay_us(200); |
output_high(MOT_L); |
output_high(MOT_R); |
output_low(MOT_1); |
output_low(MOT_2); |
delay_us(200); |
} |
output_low(MOT_L); // smer vpred |
output_low(MOT_R); |
setup_ccp1(CCP_PWM); // RC1 // Zapni PWM pro motory |
setup_ccp2(CCP_PWM); // RC2 |
} |
void SetServo(int8 angle) |
{ |
int8 n; |
for(n=0; n<10; n++) |
{ |
output_high(SERVO); // Odvysilani impuzu 1 az 2ms pro servo |
delay_us(1000); |
delay_us(stred); |
delay_us(stred); |
delay_us(stred); |
delay_us(angle); |
delay_us(angle); |
output_low(SERVO); |
delay_ms(18); |
} |
} |
inline void SetServoQ(int8 angle) |
{ |
output_high(SERVO); // Odvysilani impuzu 1 az 2ms pro servo |
delay_us(1000); |
delay_us(stred); |
delay_us(stred); |
delay_us(stred); |
delay_us(angle); |
delay_us(angle); |
output_low(SERVO); |
} |
// Couvni po narazu na naraznik |
inline void bum() |
{ |
set_pwm1_duty(0); // couvni, rovne dozadu |
set_pwm2_duty(0); |
output_high(MOT_L); |
output_high(MOT_R); |
disp(0xA5); |
SetServo(CASAVR-CASMIN); |
} |
#include ".\diag.c" |
//---------------------------- INT -------------------------------- |
#int_EXT |
EXT_isr() // Preruseni od prekazky |
{ |
unsigned int8 bearing, bearing_offset, delta_bearing; |
set_pwm1_duty(0); // zabrzdi levym kolem, prave vypni |
set_pwm2_duty(0); |
output_high(MOT_L); |
output_low(MOT_R); |
// Ujistime se, ze prijaty signal je z naseho IR vysilace |
output_high(IRTX); // Vypni LED na detekci prekazky |
delay_ms(2); |
if (IRRX) // stale nas signal? |
{ |
output_low(MOT_L); // je odraz -> vpred |
output_low(MOT_R); |
return; |
}; |
output_low(IRTX); // Zapni LED na detekci prekazky |
i2c_start(); // Cteni kompasu |
i2c_write(COMPAS_ADR); |
i2c_write(0x1); // 0-255 (odpovida 0-359) |
i2c_stop(); |
i2c_start(); |
i2c_write(COMPAS_ADR+1); |
bearing_offset=i2c_read(0); // Poznamenej hodnotu pred cihlou |
i2c_stop(); |
delay_ms(9); |
if (!IRRX) // stale nas signal? |
{ |
output_low(MOT_L); // neni odraz -> vpred |
output_low(MOT_R); |
return; |
}; |
rr=rrold; // Po cihle se pojede opet Rozumnou Rychlosti |
if(stav!=cihla) |
{ |
LogLog(0xFF,3); // Cihla |
}; |
//!!! if(stav==cihla) while(true); // Zastav na furt, konec drahy |
// if(stav==cihla) return; // Po druhe nic neobjizdej |
// Pozor na rozjezd |
if((stav==jizda)||(stav==cihla)) // Objed cihlu |
{ |
#include ".\objizdka_L.c" |
}; |
last_log_odo=get_timer1()+16; // Pul metru po cihle nezaznamenavej do LOGu |
} |
//---------------------------------- MAIN -------------------------------------- |
void main() |
{ |
int8 offset; // Promena pro ulozeni offsetu |
int8 r1; // Rychlost motoru 1 |
int8 r2; // Rychlost motoru 2 |
int16 ble; |
setup_adc_ports(ALL_ANALOG); // Zapnuti A/D prevodniku pro cteni kroutitek |
setup_adc(ADC_CLOCK_INTERNAL); |
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); // Casovac pro mereni casu hrany W/B v radce |
setup_timer_1(T1_EXTERNAL); // Cita pulzy z odometrie z praveho kola |
setup_timer_2(T2_DIV_BY_16,255,1); // Casovac PWM motoru |
//!!! setup_timer_2(T2_DIV_BY_4,255,1); // Casovac PWM motoru |
setup_ccp1(CCP_PWM); // RC1 // PWM pro motory |
setup_ccp2(CCP_PWM); // RC2 |
setup_comparator(NC_NC_NC_NC); |
setup_vref(FALSE); |
set_tris_c(0b11111001); // Nastaveni vstup/vystup pro branu C, protoze se to nedela automaticky |
set_pwm1_duty(0); // Zastav motory |
set_pwm2_duty(0); |
output_low(MOT_L); // Nastav smer vpred |
output_low(MOT_R); |
disp(0); // Zhasni LEDbar |
if(BUMPER) // Kdyz nekdo na zacatku drzi naraznik, vymaz log a spust diagnostiku |
{ |
diag(); |
} |
output_low(IRTX); // Zapni LED na detekci prekazky |
NightRider(1); // Zablikej, aby se poznalo, ze byl RESET |
// Zaroven se musi pockat, nez se rozjede kamera, nez se do ni zacnou posilat prikazy |
//... Nastaveni sonaru ... |
i2c_start(); |
i2c_write(SONAR_ADR); |
i2c_write(0x02); // dosah |
i2c_write(0x03); // n*43mm |
i2c_stop(); |
i2c_start(); |
i2c_write(SONAR_ADR); |
i2c_write(0x01); // zesileni |
i2c_write(0x01); // male, pro eliminaci echa z minuleho mereni |
i2c_stop(); |
//... Nastaveni kamery ... |
i2c_start(); // Soft RESET kamery |
i2c_write(CAMERA_ADR); // Adresa kamery |
i2c_write(0x12); // Adresa registru COMH |
i2c_write(0x80 | 0x24); // Zapis ridiciho slova |
i2c_stop(); |
i2c_start(); // BW |
i2c_write(CAMERA_ADR); |
i2c_write(0x28); |
i2c_write(0b01000001); |
i2c_stop(); |
/* |
i2c_start(); // Contrast (nema podstatny vliv na obraz) |
i2c_write(CAMERA_ADR); |
i2c_write(0x05); |
i2c_write(0xA0); // 48h |
i2c_stop(); |
i2c_start(); // Band Filter (pokud by byl problem se zarivkama 50Hz) |
i2c_write(CAMERA_ADR); |
i2c_write(0x2D); |
i2c_write(0x04 | 0x03); |
i2c_stop(); |
*/ |
i2c_start(); // Fame Rate |
i2c_write(CAMERA_ADR); |
i2c_write(0x2B); |
i2c_write(0x00); // cca 17ms (puvodni hodnota 5Eh = 20ms) |
i2c_stop(); |
i2c_start(); // VSTRT |
i2c_write(CAMERA_ADR); |
i2c_write(0x19); |
i2c_write(118); // prostredni radka |
i2c_stop(); |
i2c_start(); // VEND |
i2c_write(CAMERA_ADR); |
i2c_write(0x1A); |
i2c_write(118); |
i2c_stop(); |
NightRider(1); // Musi se dat cas kamere na AGC a AEC |
{ // Mereni expozice |
int8 t1,t2; |
i2c_start(); // Brightness, zacni od uplne tmy |
i2c_write(CAMERA_ADR); |
i2c_write(0x06); |
i2c_write(0); // 80h default |
i2c_stop(); |
delay_ms(50); |
for(offset=0x04;offset<(255-0x04);offset+=0x04) // Zacni od jasu 10h |
{ |
i2c_start(); // Brightness |
i2c_write(CAMERA_ADR); |
i2c_write(0x06); |
i2c_write(offset); // 80h default |
i2c_stop(); |
disp(offset); |
delay_ms(50); |
t1=0; |
t2=0; |
while(!input(HREF)); // Cekej nez se zacnou posilat pixely z radky |
delay_ms(5); |
while(!input(HREF)); // Cekej nez se zacnou posilat pixely z radky |
set_timer0(0); // Vynuluj pocitadlo casu |
if(!input(PIX)) continue; |
while(input(PIX)); |
t1=get_timer0(); // Precti cas z citace casu hrany |
set_timer0(0); // Vynuluj pocitadlo casu |
while(!input(PIX)); |
t2=get_timer0(); |
if((t1>60) && (t1<140) && (t2>5) && (t2<=10)) break; // Vidis, co mas? |
delay_ms(2); // Preskoc druhou radku z kamery |
}; |
delay_ms(1000); // Nech chvili na displayi zmerenou hodnotu |
} |
set_adc_channel(CERVENA); // --- Kroutitko pro jas --- |
delay_ms(1); |
offset=read_adc(); |
offset &= 0b11111100; // Dva nejnizsi bity ignoruj |
// offset += 0x70; // Jas nebude nikdy nizsi |
disp(offset); |
i2c_start(); // Brightness |
i2c_write(CAMERA_adr); |
i2c_write(0x06); |
i2c_write(offset); // 80h default |
i2c_stop(); |
delay_ms(1000); // Nech hodnotu chvili na displayi |
set_adc_channel(ZELENA); // --- Kroutitko pro vykon motoru --- |
delay_ms(1); |
rr=read_adc()>>2; // 0-63 // Pokud by se zvetsil rozsah, tak zkontrolovat jakonasobeni! |
rr+=27; // 27-90 |
//!!! rr=read_adc()>>1; // 0-128 // Pokud by se zvetsil rozsah, tak zkontrolovat jakonasobeni! |
rrold=rr; |
cas=CASAVR-CASMIN; // Inicializace promenych, aby neslo servo za roh |
// a aby se to rozjelo jeste dneska |
stav=start; // Jsme na startu |
set_timer1(0); // Vynuluj citac odometrie |
log=0; // Zacatek logu v cerne skrince |
last_log_odo=0; // Posledni zaznam odometrie do logu |
// ReadBlackBox(); // Vycteni zaznamu z Black Boxu |
odo_cihla=ODODO_CIHLA-BRZDNA_DRAHA; |
odo_tunel=ODODO_TUNEL-BRZDNA_DRAHA; |
odo_preruseni=ODODO_PRERUSENI-BRZDNA_DRAHA; |
// ........................... Hlavni smycka ................................ |
while(true) |
{ |
int8 pom; |
int8 n; |
int8 gap; |
int16 ododo; |
gap=0; // Vynuluj pocitadlo preruseni |
next_snap: |
pom=0; |
disable_interrupts(GLOBAL); //----------------------- Critical Section |
while(input(HREF)); // Preskoc 1. radku |
while(!input(HREF)); // Cekej nez se zacnou posilat pixely z 2. radky |
set_timer0(0); // Vynuluj pocitadlo casu |
while(input(HREF)) // Po dobu vysilani radky cekej na hranu W/B |
{ |
// !!!!Dodelat rozpoznani cerne cary napric pro zastaveni ? |
if(!input(PIX)) // Pokud se X-krat za sebou precetla CERNA |
if(!input(PIX)) |
// if(!input(PIX)) |
{ |
pom=get_timer0(); // Precti cas z citace casu hrany |
break; |
}; |
}; |
while(input(HREF)); // Pockej na shozeni signalu HREF |
if((pom<CASMAX) && (pom>CASMIN)) cas=pom; // Orizni konce radku |
// Na konci obrazovaho radku to blbne. Jednak chyba od apertury |
// a vubec to nejak na kraji nefunguje. |
output_high(SERVO); // Odvysilani impuzu 1 az 2ms pro servo |
delay_us(1000); |
delay_us(stred); |
delay_us(stred); |
delay_us(stred); |
delay_us(cas); |
delay_us(cas); |
output_low(SERVO); |
// Elektronicky diferencial 1. cast |
if(cas<CASAVR) {r1=cas-CASMIN; r2=CASAVR-CASMIN;}; // Normovani vystupni hodnoty radkoveho snimace |
if(cas==CASAVR) {r1=cas-CASMIN; r2=cas-CASMIN;}; // pro rizeni rychlosti motoru |
if(cas>CASAVR) {r1=CASAVR-CASMIN; r2=CASMAX-cas;}; // Rozsah 1 az 92 |
enable_interrupts(GLOBAL); //----------------------- End Critical Section |
if(pom==0) // Kamera nevidi caru |
{ |
if((cas>(CASMIN+15))&&(cas<(CASMAX-15))) // Nebyla minule cara moc u kraje? |
{ |
gap++; |
if(gap>=3) // Trva preruseni cary alespon 2 snimky? |
{ |
cas=CASAVR-CASMIN; |
// disp(0xAA); |
} |
} |
} |
else |
{ |
gap=0; |
}; |
/* |
if(pom==0) // Kamera nevidi caru, poznamenej to do logu |
{ |
if((cas>(CASMIN+30))&&(cas<(CASMAX-30))) // Nebyla minule cara moc u kraje? |
if(last_log_odo<get_timer1()) // Aby nebyly zaznamy v logu prilis huste, musi se napred neco ujet od minuleho zaznamu |
{ |
gap++; |
} |
} |
else |
{ |
if(gap>=4) // Trva preruseni cary alespon 2 snimky? |
{ |
LogLog(gap,8); // Dalsi mereni nejdrive po ujeti 24 cm |
rr=rrold; // Preruseni cary skoncilo, znovu jed Rozumnou Rychlosti |
cas=CASAVR-CASMIN; |
disp(0xAA); |
} |
gap=0; |
}; |
if(!input(PROXIMITY) && ((stav==jizda)||(stav==cihla))) // Tunel |
{ |
if(last_log_odo<get_timer1()) // Aby nebyly zaznamy v logu prilis huste, musi se napred neco ujet od minuleho zaznamu |
{ |
LogLog(0xDD,16); // Priznak tunelu; dalsi mereni nejdrive po ujeti 48 cm |
rr=rrold; // Vjeli jsme do tunelu, znovu jed rychle |
} |
}; |
*/ |
//ODODO |
ododo=get_timer1(); |
if((ododo>odo_preruseni)&&(ododo<(odo_preruseni+8))) rr=RR_PRERUSENI; |
if((ododo>odo_cihla)&&(ododo<(odo_cihla+8))) rr=RR_PRERUSENI; |
if((ododo>odo_tunel)&&(ododo<(odo_tunel+8))) rr=RR_PRERUSENI; |
// Elektronicky diferencial 2. cast |
if (r1>(CASAVR-CASMIN-rr)) r1=(r1<<1)+rr-(CASAVR-CASMIN); // Neco jako nasobeni |
if (r2>(CASAVR-CASMIN-rr)) r2=(r2<<1)+rr-(CASAVR-CASMIN); // rozsah 1 az 92 pro rr=0 // rozsah 1 az 154 pro rr=63 |
//!!! pro zatuhle prevodovky |
// r1<<=1; // Rychlost je dvojnasobna |
// r2<<=1; // Rozsah 2 az 184 pro rr=0 |
if ((stav==jizda)||(stav==cihla)||(stav==rozjezd)) //||(stav==pocihle)) // Jizda |
{ |
set_pwm1_duty(r1); |
set_pwm2_duty(r2); |
} |
else |
{ |
set_pwm1_duty(0); // Zastaveni |
set_pwm2_duty(0); |
}; |
if((stav==rozjezd)&&(get_timer1()>10)) // musi ujet alespon 31cm |
{ |
ext_int_edge(H_TO_L); // Nastav podminky preruseni od cihly |
INT0IF=0; // Zruseni predesle udalosti od startera |
enable_interrupts(INT_EXT); |
enable_interrupts(GLOBAL); |
stav=jizda; |
}; |
if(stav==start) // Snimkuje, toci servem a ceka na start |
{ |
set_adc_channel(MODRA); // Kroutitko na vystredeni predniho kolecka |
Delay_ms(1); |
stred=read_adc(); |
if(!input(PROXIMITY)) |
{ |
disp(0x80); |
while(input(PROXIMITY)); // Cekej, dokud starter neda ruku pryc |
set_timer1(0); // Vynuluj citac odometrie |
set_pwm1_duty(255); // Rychly rozjezd !!! Zkontrolovat na oscyloskopu |
set_pwm2_duty(255); |
disp(0x01); |
while(get_timer1()<=4) // Ujed alespon 12cm |
{ |
set_adc_channel(LMAX); // Levy UV sensor |
delay_us(40); |
if(read_adc()<THR) {cas=CASMIN; break;}; // Prejeli jsme caru vlevo |
set_adc_channel(RMAX); // Pravy UV sensor |
delay_us(40); |
if(read_adc()<THR) {cas=CASMAX; break;}; // Prejeli jsme caru vpravo |
cas=CASAVR-CASMIN; // Cara je rovne |
}; |
stav=rozjezd; |
}; |
} |
pom=0x80; // Zobrazeni pozice cary na displayi |
for(n=CASMAX/8; n<cas; n+=CASMAX/8) pom>>=1; |
disp(pom); |
while(true) // Ve zbytku casu snimku cti krajni UV senzory a naraznik |
{ |
if(BUMPER) // Sakra, do neceho jsme narazili a nevideli jsme to! |
{ |
bum(); |
SaveLog(); // Zapis Black Boxu do EEPROM |
delay_ms(TUHOS); //!!! Zatuhle prevodovky |
set_pwm1_duty(200); // pomalu vpred |
set_pwm2_duty(200); |
output_low(MOT_L); |
output_low(MOT_R); |
cas=CASAVR-CASMIN; |
}; |
set_adc_channel(LMAX); // Levy UV sensor |
for(n=0;n<20;n++) if(input(HREF)) goto next_snap; |
if(read_adc()<THR) cas=CASMIN; |
set_adc_channel(RMAX); // Pravy UV sensor |
for(n=0;n<20;n++) if(input(HREF)) goto next_snap; |
if(read_adc()<THR) cas=CASMAX; |
}; |
} |
} |
/roboti/istrobot/camerus/SW/876/backup/diag.c |
---|
0,0 → 1,68 |
//--- Diagnostika cidel a vymazani EEPROM --- |
void diag() |
{ |
int8 n; |
// Vymaz Black Box v EEPROM |
for(n=0;n<255;n++) write_eeprom(n,0); |
bb_l[0]=0; // Zapis na pozici 0 vzdalenost 0 |
bb_h[0]=0; |
bb_f[0]=0; |
write_eeprom(EEMAX,0); // Zapis do EEPROM pocet zaznamu 0, tedy jeden zaznam |
for(n=0;n<=4;n++) |
{ |
disp(0x55); // Blikni pro potvrzeni |
delay_ms(200); |
disp(0xAA); |
delay_ms(200); |
}; |
while(true) |
{ |
if(!IRRX) |
{ |
int8 ble; |
i2c_start(); // Cteni kompasu |
i2c_write(COMPAS_ADR); |
i2c_write(0x1); |
i2c_stop(); |
i2c_start(); |
i2c_write(COMPAS_ADR+1); |
ble=i2c_read(0); |
i2c_stop(); |
disp(ble); |
delay_ms(200); |
} |
else |
{ |
i2c_start(); // Diagnostika sonaru |
i2c_write(SONAR_ADR); |
i2c_write(0x02); // dosah |
i2c_write(0x03); // n*43mm |
i2c_stop(); |
i2c_start(); |
i2c_write(SONAR_ADR); |
i2c_write(0x01); // zesileni |
i2c_write(0x01); // male, pro eliminaci echa z minuleho mereni |
i2c_stop(); |
i2c_start(); // Sonar Ping |
i2c_write(0xE0); |
i2c_write(0x0); |
i2c_write(0x51); // 50 mereni v palcich, 51 mereni v cm, 52 v us |
i2c_stop(); |
delay_ms(100); |
i2c_start(); // Odraz ze sonaru |
i2c_write(0xE0); |
i2c_write(0x3); |
i2c_stop(); |
i2c_start(); |
i2c_write(0xE1); |
n=i2c_read(0); |
i2c_stop(); |
disp(n); // Zobrazeni hodnoty ze sonaru a zaroven diagnostika predniho IR cidla |
delay_ms(200); |
} |
} |
} |
/roboti/istrobot/camerus/SW/876/backup/objizdka_L.c |
---|
0,0 → 1,183 |
// **** Objeti cihly vlevo **** LLLL |
#define L_TOUCH 1 // Cara vlevo |
#define R_TOUCH 2 // Cata vpravo |
#define B_TOUCH 3 // Both |
int8 n; |
int8 r1,r2,rr; |
int8 touch; |
enum okolo_cihly {pred_carou,na_care,po_care}; |
okolo_cihly ridic; // V jakem jsme stavu objizdeni cihly |
int8 vzdalenost; |
int8 visualisation; |
stav=cihla; // Dalsi prekazku uz nezaznamenavej (je to s velkou pravdepodobnosti cil) |
odocounter=get_timer1(); |
cihla: |
rr=RR_CIHLA; //!!! Rozumna rychlost pro objizdeni cihly (bylo by lepsi rychlost zvysovat) a pri detekci pohybu zase snizit |
disp(0x99); |
set_pwm1_duty(0); // zabrzdi levym kolem, prave vpred |
set_pwm2_duty(255); |
output_high(MOT_L); |
output_low(MOT_R); |
while(true) // Na zacatku se vyhni cihle, zatoc co muzes |
{ |
cas=CASMIN-5; // jeste vic nez hodne do leva |
if(BUMPER) // Narazili jsme do cihly, musime couvnout! |
{ |
bum(); |
SaveLog(); // Zapis Black Boxu do EEPROM |
delay_ms(TUHOS); //!!! Zatuhle prevodovky |
brzda(); |
goto cihla; // Znovu zacni cihlu objizdet |
}; |
set_pwm1_duty(0); |
set_pwm2_duty(255); // !!! mozna prilis maly vykon pro rozjezd pro zatuhlou prevodovku |
output_high(MOT_L); // leve kolo reverz |
output_low(MOT_R); // prave kolo vpred |
if(get_timer1()>(odocounter+5)) // konec zatacky? |
{ |
disp(0x66); |
break; |
} |
SetServoQ(cas); |
delay_ms(18); |
}; |
//------ Objeti cihly v konstantni vzdalenosti ------ |
touch=0; // Indikator detekce cary pri objizdeni |
ridic=pred_carou; |
cas=CASAVR-CASMIN; // rovne |
output_low(MOT_L); // vpred |
output_low(MOT_R); |
visualisation=0; |
while(true) |
{ |
if(BUMPER) // Narazili jsme do cihly, musime couvnout! |
{ |
bum(); |
SaveLog(); // Zapis Black Boxu do EEPROM |
delay_ms(TUHOS); //!!! Zatuhle prevodovky |
set_pwm1_duty(160); // vpred |
set_pwm2_duty(160); |
output_low(MOT_L); |
output_low(MOT_R); |
cas=CASMIN; |
}; |
delta_bearing=bearing-bearing_offset; |
visualisation=(delta_bearing & 0xF0) | (visualisation & 0x0F); |
if(IRRX) // hrozi celni srazka s cihlou v prubehu objizdeni |
{ |
cas=CASMIN; |
} |
else |
{ |
if((vzdalenost!=0)||!input(PROXIMITY)||((delta_bearing>60)&&(delta_bearing<128))) // Udrzovani konstantni vzdalenosti od cihly |
{ |
if(cas>(CASMIN+30)) cas-=30; |
} |
else |
{ |
if(cas<(CASMAX-30)) cas+=30; |
}; |
}; |
// Elektronicky diferencial |
if(cas<CASAVR) {r1=cas-CASMIN; r2=CASAVR-CASMIN;}; // Normovani vystupni hodnoty radkoveho snimace |
if(cas==CASAVR) {r1=cas-CASMIN; r2=cas-CASMIN;}; // pro rizeni rychlosti motoru |
if(cas>CASAVR) {r1=CASAVR-CASMIN; r2=CASMAX-cas;}; // Rozsah 1 az 92 |
if (r1>(CASAVR-CASMIN-rr)) r1=(r1<<1)+rr-(CASAVR-CASMIN); // Neco jako nasobeni |
if (r2>(CASAVR-CASMIN-rr)) r2=(r2<<1)+rr-(CASAVR-CASMIN); |
//!!! pro zatuhle prevodovky |
// r1<<=1; // Rychlost je dvojnasobna |
// r2<<=1; // Rozsah 2 az 184 pro rr=0 |
set_pwm1_duty(r1); // Nastav rychlost motoru |
set_pwm2_duty(r2); |
SetServoQ(cas); |
i2c_start(); // Sonar Ping |
i2c_write(SONAR_ADR); |
i2c_write(0x0); |
i2c_write(0x52); // mereni v us |
i2c_stop(); |
for(n=1;n<=90;n++) // 18ms testovani cary do dalsi korekce serva |
{ |
set_adc_channel(LMAX); |
delay_us(100); |
if(read_adc()<THR) touch|=L_TOUCH; |
set_adc_channel(RMAX); |
delay_us(100); |
if(read_adc()<THR) touch|=R_TOUCH; |
}; |
i2c_start(); // Odraz ze sonaru |
i2c_write(SONAR_ADR); |
i2c_write(0x3); |
i2c_stop(); |
i2c_start(); |
i2c_write(SONAR_ADR+1); |
vzdalenost=i2c_read(0); |
i2c_stop(); |
i2c_start(); // Cteni kompasu |
i2c_write(COMPAS_ADR); |
i2c_write(0x1); // uhel 0-255 |
i2c_stop(); |
i2c_start(); |
i2c_write(COMPAS_ADR+1); |
bearing=i2c_read(0); |
i2c_stop(); |
if(touch==L_TOUCH) visualisation|=0x2; |
if(touch==R_TOUCH) visualisation|=0x1; |
if((touch==B_TOUCH)&&(ridic==pred_carou)) ridic=na_care; |
if((ridic==na_care)&&(touch==0)) break; |
if(ridic==na_care) touch=0; |
disp(visualisation); |
}; |
disp(0xC3); |
set_pwm1_duty(0); //!!! pred zatuhlejma prevodovkama tam bylo 20 a 200 |
set_pwm2_duty(255); |
output_high(MOT_L); |
output_low(MOT_R); |
delay_us(40); |
odocounter=get_timer1(); // Poznamenej aktualni stav odometrie |
while (true) // Znovu se musime dotknout cary |
{ |
for(n=1;n<=90;n++) // 18ms testovani cary do dalsi korekce serva |
{ |
set_adc_channel(LMAX); // Levy UV sensor |
delay_us(100); |
if(read_adc()<THR) // Dotkli jsme se levym senzorem |
{ |
disp(0xE0); |
cas=CASAVR-CASMIN; // nastavime, ze cara je rovne |
goto cara; |
}; |
set_adc_channel(RMAX); // Pravy UV sensor |
delay_us(100); |
if((get_timer1()>=(odocounter+2)) && (read_adc()<THR)) // Pravym senzorem nesmime caru prejet! |
{ |
disp(0x07); |
cas=CASMAX; // kdyz prejedem, tak nastavime, ze cara je vpravo |
goto cara; |
}; |
} |
SetServoQ(CASMIN-5); // max. max. doleva L |
} |
cara: |
output_low(MOT_L); // oba motory vpred |
output_low(MOT_R); |
/roboti/istrobot/camerus/SW/876/bak/camerus.c |
---|
0,0 → 1,633 |
//********* Robot Camerus pro IstRobot 2007 ************ |
//"$Id: camerus.c 253 2007-04-24 09:26:46Z kakl $" |
//***************************************************** |
#include ".\camerus.h" |
#USE FAST_IO (C) // Brana C je ve FAST_IO modu, aby slo rychle cist z kamery |
// Rychlostni konstanty |
#define RR_CIHLA 50 // Rozumna rychlost pro objizdeni cihly |
#define RR_PRERUSENI 30 // Rozumna rychlost pro priblizeni se k preruseni |
#define BRZDNA_DRAHA 0x20 // Jak daleko pred problemem se zacne brzdit |
#define TUHOS 100 // Jak dlouho se bude couvat po narazu na naraznik |
#define ODODO_CIHLA 0xFFF |
#define ODODO_TUNEL 0xFFF |
#define ODODO_PRERUSENI 0xFFF |
// Adresy IIC periferii |
#define COMPAS_ADR 0xC0 |
#define CAMERA_ADR 0xDC |
#define SONAR_ADR 0xE0 |
// A/D vstupy |
#define RMAX 4 // AN4/RA5 - leve cidlo na vyjeti z cary |
#define LMAX 3 // AN3/RA3 - prave cidlo na vyjeti z cary |
#define CERVENA 2 // AN2/RA2 - cervene kroutitko |
#define ZELENA 1 // AN1/RA0 - zelene kroutitko |
#define MODRA 0 // AN0/RA1 - modre kroutitko |
// I/O |
#define HREF PIN_C5 // Signal HREF z kamery (v H po celou dobu radku) |
#define PIX PIN_C6 // Vstup pro body z kamery (za trivstupim hradlem OR (dig. komparator)) |
#define SERVO PIN_B4 // Vystup na servo (1 az 2ms po cca 20ms (synchronizovano snimkovym kmitoctem)) |
#define MOT_L PIN_B5 // Smer otaceni leveho motoru; druhy pol je RC2 |
#define MOT_R PIN_B6 // Smer otaceni praveho motoru; druhy pol je RC1 |
#define MOT_1 PIN_C1 // PWM vystpy motoru |
#define MOT_2 PIN_C2 // |
#define DATA PIN_B2 // K modulu LEDbar data |
#define CP PIN_B1 // K modulu LEDbar hodiny |
//#define ODO PIN_C0 // Ze snimace z odometrie z praveho kola na TIMER1 |
// Jeden impuls je 31,25mm |
#define IRRX !input(PIN_B0) // Vstup INT, generuje preruseni pri prekazce |
#define IRTX PIN_B3 // Modulovani vysilaci IR LED na detekci prekazky |
#define PROXIMITY PIN_C7 // Cidlo kratkeho dosahu na cihlu |
#define BUMPER !input(PIN_A4) // Naraznik |
#define CASMIN 6 // Rozsah radku snimace |
#define CASMAX 192 |
#define CASAVR ((CASMAX+CASMIN) / 2) |
#define EEMAX 255 // Konec EEPROM |
#define MAXLOG 0x10 // Maximalni pocet zaznamu v logu |
#if MAXLOG>(EEMAX/3) |
#error Prekrocena velikost EEPROM |
#endif |
#define OFFSETO 0x9F //0x9F // Vystredeni serva pro objeti prekazky |
#define THR 90 // Threshold pro UV cidla na caru |
#byte INTCON = 0x0B // Interrupt configuration register |
#bit GIE = INTCON.7 |
#bit PEIE = INTCON.6 |
#bit TMR0IE = INTCON.5 |
#bit INT0IE = INTCON.4 |
#bit RBIE = INTCON.3 |
#bit TMR0IF = INTCON.2 |
#bit INT0IF = INTCON.1 |
#bit RBIF = INTCON.0 |
enum stavy {start,rozjezd,jizda,cihla,pocihle,cil}; |
stavy stav; // Kde jsme na trati |
int8 cas; // Cas hrany bila/cerna v radce |
int8 stred; // Vystredeni kolecka |
int16 odocounter; // Zaznamenani aktualniho stavu pocitadla odometrie |
int16 last_log_odo; // Posledni stav odometrie poznamenany do logu |
int16 last_log; // Cislo posledniho zaznamu v logu v EEPROM |
int8 bb_h[MAXLOG]; // Cerna skrinka MSB |
int8 bb_l[MAXLOG]; // Cerna skrinka LSB |
int8 bb_f[MAXLOG]; // Cerna skrinka priznak (typ zaznamu) |
int8 log; // Pocitadlo pro cernou skrinku |
int8 rr; // Promenna na ulozeni Rozumne rychlost |
int8 rrold; |
int16 odo_preruseni, odo_cihla, odo_tunel; // Problemy na trati |
// Zobrazeni jednoho byte na modulu LEDbar |
inline void disp(int8 x) |
{ |
int n; |
for(n=0;n<=7;n++) |
{ |
if (bit_test(x,0)) output_low(DATA); else output_high(DATA); |
output_high(CP); |
x>>=1; |
output_low(CP); |
} |
} |
// Blikani LEDbarem ve stilu Night Rider |
void NightRider(int8 x) |
{ |
int n,i,j; |
for(j=0;j<x;j++) |
{ |
i=0x01; |
for(n=0;n<7;n++) |
{ |
disp(i); |
rotate_left(&i, 1); |
delay_ms(40); |
} |
for(n=0;n<7;n++) |
{ |
disp(i); |
rotate_right(&i, 1); |
delay_ms(40); |
} |
} |
disp(i); |
delay_ms(40); |
i=0; |
disp(i); |
} |
// Zaznam LOGu do EEPROM |
void SaveLog(int8 log) |
{ |
int8 n,i; |
i=0; |
for(n=0;n<=(log*3);n+=3) // Ulozeni Black Boxu do EEPROM |
{ |
write_eeprom(n,bb_f[i]); |
write_eeprom(n+1,bb_h[i]); |
write_eeprom(n+2,bb_l[i]); |
i++; |
}; |
write_eeprom(EEMAX,log); // Zapis poctu zaznamu na konec EEPROM |
} |
// Zaznam do Logu do RAM |
void LogLog(int8 flag, int16 gap) |
{ |
int16 timer_pom; |
timer_pom=get_timer1(); // Timer se musi vycist atomicky |
bb_l[log]=make8(timer_pom,0); // Zaznam |
bb_h[log]=make8(timer_pom,1); |
bb_f[log]=flag; // Typ zaznamu |
if(log<MAXLOG) log++; // Ukazatel na dalsi zaznam |
last_log_odo=timer_pom+gap; // Dalsi mereni nejdrive po ujeti def. vzdalenosti |
rr=rrold; // Problem skoncil, znovu jed Rozumnou Rychlosti |
} |
void ReadBlackBox() |
{ |
last_log=read_eeprom(EEMAX); // Kolik zaznamu mame od minule poznamenano? |
{ |
int8 n,i; |
i=0; |
for(n=0;n<=last_log;n++) |
{ |
if(read_eeprom(i)==0) odo_tunel=MAKE16(read_eeprom(i+2),read_eeprom(i+1)); |
if(read_eeprom(i)==0xFF) odo_cihla=MAKE16(read_eeprom(i+2),read_eeprom(i+1)); |
if((read_eeprom(i)>0) && (read_eeprom(i)<0xFF)) odo_preruseni=MAKE16(read_eeprom(i+2),read_eeprom(i+1)); |
} |
} |
} |
// Brzdeni motorama stridou 1:1 |
void brzda() |
{ |
int8 n,i; |
set_pwm1_duty(0); // vypni PWM |
set_pwm2_duty(0); |
setup_ccp1(CCP_OFF); |
setup_ccp2(CCP_OFF); |
for (n=0;n<200;n++) |
{ |
output_low(MOT_L); |
output_low(MOT_R); |
output_high(MOT_1); |
output_high(MOT_2); |
delay_us(200); |
output_high(MOT_L); |
output_high(MOT_R); |
output_low(MOT_1); |
output_low(MOT_2); |
delay_us(200); |
} |
output_low(MOT_L); // smer vpred |
output_low(MOT_R); |
setup_ccp1(CCP_PWM); // RC1 // Zapni PWM pro motory |
setup_ccp2(CCP_PWM); // RC2 |
} |
void SetServo(int8 angle) |
{ |
int8 n; |
for(n=0; n<10; n++) |
{ |
output_high(SERVO); // Odvysilani impuzu 1 az 2ms pro servo |
delay_us(1000); |
delay_us(stred); |
delay_us(stred); |
delay_us(stred); |
delay_us(angle); |
delay_us(angle); |
output_low(SERVO); |
delay_ms(18); |
} |
} |
inline void SetServoQ(int8 angle) |
{ |
output_high(SERVO); // Odvysilani impuzu 1 az 2ms pro servo |
delay_us(1000); |
delay_us(stred); |
delay_us(stred); |
delay_us(stred); |
delay_us(angle); |
delay_us(angle); |
output_low(SERVO); |
} |
// Couvni po narazu na naraznik |
inline void bum() |
{ |
set_pwm1_duty(0); // couvni, rovne dozadu |
set_pwm2_duty(0); |
output_high(MOT_L); |
output_high(MOT_R); |
disp(0xA5); |
SetServo(CASAVR-CASMIN); |
} |
#include ".\diag.c" |
//---------------------------- INT -------------------------------- |
#int_EXT |
EXT_isr() // Preruseni od prekazky |
{ |
unsigned int8 bearing, bearing_offset, delta_bearing; |
set_pwm1_duty(0); // zabrzdi levym kolem, prave vypni |
set_pwm2_duty(0); |
output_high(MOT_L); |
output_low(MOT_R); |
// Ujistime se, ze prijaty signal je z naseho IR vysilace |
output_high(IRTX); // Vypni LED na detekci prekazky |
delay_ms(2); |
if (IRRX) // stale nas signal? |
{ |
output_low(MOT_L); // je odraz -> vpred |
output_low(MOT_R); |
return; |
}; |
output_low(IRTX); // Zapni LED na detekci prekazky |
i2c_start(); // Cteni kompasu |
i2c_write(COMPAS_ADR); |
i2c_write(0x1); // 0-255 (odpovida 0-359) |
i2c_stop(); |
i2c_start(); |
i2c_write(COMPAS_ADR+1); |
bearing_offset=i2c_read(0); // Poznamenej hodnotu pred cihlou |
i2c_stop(); |
delay_ms(9); |
if (!IRRX) // stale nas signal? |
{ |
output_low(MOT_L); // neni odraz -> vpred |
output_low(MOT_R); |
return; |
}; |
rr=rrold; // Po cihle se pojede opet Rozumnou Rychlosti |
if(stav!=cihla) |
{ |
LogLog(0xFF,3); // Cihla |
}; |
//!!! if(stav==cihla) while(true); // Zastav na furt, konec drahy |
// if(stav==cihla) return; // Po druhe nic neobjizdej |
// Pozor na rozjezd |
if((stav==jizda)||(stav==cihla)) // Objed cihlu |
{ |
#include ".\objizdka_L.c" |
}; |
last_log_odo=get_timer1()+16; // Pul metru po cihle nezaznamenavej do LOGu |
} |
//---------------------------------- MAIN -------------------------------------- |
void main() |
{ |
int8 offset; // Promena pro ulozeni offsetu |
int8 r1; // Rychlost motoru 1 |
int8 r2; // Rychlost motoru 2 |
setup_adc_ports(ALL_ANALOG); // Zapnuti A/D prevodniku pro cteni kroutitek |
setup_adc(ADC_CLOCK_INTERNAL); |
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); // Casovac pro mereni casu hrany W/B v radce |
setup_timer_1(T1_EXTERNAL); // Cita pulzy z odometrie z praveho kola |
setup_timer_2(T2_DIV_BY_16,255,1); // Casovac PWM motoru |
//!!! setup_timer_2(T2_DIV_BY_4,255,1); // Casovac PWM motoru |
setup_ccp1(CCP_PWM); // RC1 // PWM pro motory |
setup_ccp2(CCP_PWM); // RC2 |
setup_comparator(NC_NC_NC_NC); |
setup_vref(FALSE); |
set_tris_c(0b11111001); // Nastaveni vstup/vystup pro branu C, protoze se to nedela automaticky |
set_pwm1_duty(0); // Zastav motory |
set_pwm2_duty(0); |
output_low(MOT_L); // Nastav smer vpred |
output_low(MOT_R); |
disp(0); // Zhasni LEDbar |
if(BUMPER) // Kdyz nekdo na zacatku drzi naraznik, vymaz log a spust diagnostiku |
{ |
diag(); |
} |
output_low(IRTX); // Zapni LED na detekci prekazky |
NightRider(1); // Zablikej, aby se poznalo, ze byl RESET |
// Zaroven se musi pockat, nez se rozjede kamera, nez se do ni zacnou posilat prikazy |
//... Nastaveni sonaru ... |
i2c_start(); |
i2c_write(SONAR_ADR); |
i2c_write(0x02); // dosah |
i2c_write(0x03); // n*43mm |
i2c_stop(); |
i2c_start(); |
i2c_write(SONAR_ADR); |
i2c_write(0x01); // zesileni |
i2c_write(0x01); // male, pro eliminaci echa z minuleho mereni |
i2c_stop(); |
//... Nastaveni kamery ... |
i2c_start(); // Soft RESET kamery |
i2c_write(CAMERA_ADR); // Adresa kamery |
i2c_write(0x12); // Adresa registru COMH |
i2c_write(0x80 | 0x24); // Zapis ridiciho slova |
i2c_stop(); |
i2c_start(); // BW |
i2c_write(CAMERA_ADR); |
i2c_write(0x28); |
i2c_write(0b01000001); |
i2c_stop(); |
/* |
i2c_start(); // Contrast (nema podstatny vliv na obraz) |
i2c_write(CAMERA_ADR); |
i2c_write(0x05); |
i2c_write(0xA0); // 48h |
i2c_stop(); |
i2c_start(); // Band Filter (pokud by byl problem se zarivkama 50Hz) |
i2c_write(CAMERA_ADR); |
i2c_write(0x2D); |
i2c_write(0x04 | 0x03); |
i2c_stop(); |
*/ |
i2c_start(); // Fame Rate |
i2c_write(CAMERA_ADR); |
i2c_write(0x2B); |
i2c_write(0x00); // cca 17ms (puvodni hodnota 5Eh = 20ms) |
i2c_stop(); |
i2c_start(); // VSTRT |
i2c_write(CAMERA_ADR); |
i2c_write(0x19); |
i2c_write(118); // prostredni radka |
i2c_stop(); |
i2c_start(); // VEND |
i2c_write(CAMERA_ADR); |
i2c_write(0x1A); |
i2c_write(118); |
i2c_stop(); |
NightRider(1); // Musi se dat cas kamere na AGC a AEC |
{ // Mereni expozice |
int8 t1,t2; |
i2c_start(); // Brightness, zacni od uplne tmy |
i2c_write(CAMERA_ADR); |
i2c_write(0x06); |
i2c_write(0); // 80h default |
i2c_stop(); |
delay_ms(50); |
for(offset=0x04;offset<(255-0x04);offset+=0x04) // Zacni od jasu 10h |
{ |
i2c_start(); // Brightness |
i2c_write(CAMERA_ADR); |
i2c_write(0x06); |
i2c_write(offset); // 80h default |
i2c_stop(); |
disp(offset); |
delay_ms(50); |
t1=0; |
t2=0; |
while(!input(HREF)); // Cekej nez se zacnou posilat pixely z radky |
delay_ms(5); |
while(!input(HREF)); // Cekej nez se zacnou posilat pixely z radky |
set_timer0(0); // Vynuluj pocitadlo casu |
if(!input(PIX)) continue; |
while(input(PIX)); |
t1=get_timer0(); // Precti cas z citace casu hrany |
set_timer0(0); // Vynuluj pocitadlo casu |
while(!input(PIX)); |
t2=get_timer0(); |
if((t1>60) && (t1<140) && (t2>5) && (t2<=10)) break; // Vidis, co mas? |
delay_ms(2); // Preskoc druhou radku z kamery |
}; |
delay_ms(1000); // Nech chvili na displayi zmerenou hodnotu |
} |
set_adc_channel(CERVENA); // --- Kroutitko pro jas --- |
delay_ms(1); |
offset=read_adc(); |
offset &= 0b11111100; // Dva nejnizsi bity ignoruj |
// offset += 0x70; // Jas nebude nikdy nizsi |
disp(offset); |
i2c_start(); // Brightness |
i2c_write(CAMERA_adr); |
i2c_write(0x06); |
i2c_write(offset); // 80h default |
i2c_stop(); |
delay_ms(1000); // Nech hodnotu chvili na displayi |
set_adc_channel(ZELENA); // --- Kroutitko pro vykon motoru --- |
delay_ms(1); |
rr=read_adc()>>2; // 0-63 // Pokud by se zvetsil rozsah, tak zkontrolovat jakonasobeni! |
rr+=27; // 27-90 |
//!!! rr=read_adc()>>1; // 0-128 // Pokud by se zvetsil rozsah, tak zkontrolovat jakonasobeni! |
rrold=rr; |
cas=CASAVR-CASMIN; // Inicializace promenych, aby neslo servo za roh |
// a aby se to rozjelo jeste dneska |
stav=start; // Jsme na startu |
set_timer1(0); // Vynuluj citac odometrie |
log=0; // Zacatek logu v cerne skrince |
last_log_odo=0; // Posledni zaznam odometrie do logu |
// ReadBlackBox(); // Vycteni zaznamu z Black Boxu |
odo_cihla=ODODO_CIHLA-BRZDNA_DRAHA; |
odo_tunel=ODODO_TUNEL-BRZDNA_DRAHA; |
odo_preruseni=ODODO_PRERUSENI-BRZDNA_DRAHA; |
// ........................... Hlavni smycka ................................ |
while(true) |
{ |
int8 pom; |
int8 n; |
int8 gap; |
int16 ododo; |
gap=0; // Vynuluj pocitadlo preruseni |
next_snap: |
pom=0; |
disable_interrupts(GLOBAL); //----------------------- Critical Section |
while(input(HREF)); // Preskoc 1. radku |
while(!input(HREF)); // Cekej nez se zacnou posilat pixely z 2. radky |
set_timer0(0); // Vynuluj pocitadlo casu |
while(input(HREF)) // Po dobu vysilani radky cekej na hranu W/B |
{ |
// !!!!Dodelat rozpoznani cerne cary napric pro zastaveni ? |
if(!input(PIX)) // Pokud se X-krat za sebou precetla CERNA |
if(!input(PIX)) |
// if(!input(PIX)) |
{ |
pom=get_timer0(); // Precti cas z citace casu hrany |
break; |
}; |
}; |
while(input(HREF)); // Pockej na shozeni signalu HREF |
if((pom<CASMAX) && (pom>CASMIN)) cas=pom; // Orizni konce radku |
// Na konci obrazovaho radku to blbne. Jednak chyba od apertury |
// a vubec to nejak na kraji nefunguje. |
output_high(SERVO); // Odvysilani impuzu 1 az 2ms pro servo |
delay_us(1000); |
delay_us(stred); |
delay_us(stred); |
delay_us(stred); |
delay_us(cas); |
delay_us(cas); |
output_low(SERVO); |
// Elektronicky diferencial 1. cast |
if(cas<CASAVR) {r1=cas-CASMIN; r2=CASAVR-CASMIN;}; // Normovani vystupni hodnoty radkoveho snimace |
if(cas==CASAVR) {r1=cas-CASMIN; r2=cas-CASMIN;}; // pro rizeni rychlosti motoru |
if(cas>CASAVR) {r1=CASAVR-CASMIN; r2=CASMAX-cas;}; // Rozsah 1 az 92 |
enable_interrupts(GLOBAL); //----------------------- End Critical Section |
if(pom==0) // Kamera nevidi caru, poznamenej to do logu |
{ |
if((cas>(CASMIN+30))&&(cas<(CASMAX-30))) // Nebyla minule cara moc u kraje? |
if(last_log_odo<get_timer1()) // Aby nebyly zaznamy v logu prilis huste, musi se napred neco ujet od minuleho zaznamu |
{ |
gap++; |
} |
} |
else |
{ |
if(gap>=2) // Trva preruseni cary alespon 2 snimky? |
{ |
LogLog(gap,8); // Dalsi mereni nejdrive po ujeti 24 cm |
rr=rrold; // Preruseni cary skoncilo, znovu jed Rozumnou Rychlosti |
} |
gap=0; |
}; |
if(input(PROXIMITY) && ((stav==jizda)||(stav==cihla))) // Tunel |
{ |
if(last_log_odo<get_timer1()) // Aby nebyly zaznamy v logu prilis huste, musi se napred neco ujet od minuleho zaznamu |
{ |
LogLog(0,16); // Priznak tunelu; dalsi mereni nejdrive po ujeti 48 cm |
rr=rrold; // Vjeli jsme do tunelu, znovu jed rychle |
} |
}; |
//ODODO |
ododo=get_timer1(); |
if((ododo>odo_preruseni)&&(ododo<(odo_preruseni+8))) rr=RR_PRERUSENI; |
if((ododo>odo_cihla)&&(ododo<(odo_cihla+8))) rr=RR_PRERUSENI; |
if((ododo>odo_tunel)&&(ododo<(odo_tunel+8))) rr=RR_PRERUSENI; |
// Elektronicky diferencial 2. cast |
if (r1>(CASAVR-CASMIN-rr)) r1=(r1<<1)+rr-(CASAVR-CASMIN); // Neco jako nasobeni |
if (r2>(CASAVR-CASMIN-rr)) r2=(r2<<1)+rr-(CASAVR-CASMIN); // rozsah 1 az 92 pro rr=0 // rozsah 1 az 154 pro rr=63 |
//!!! pro zatuhle prevodovky |
// r1<<=1; // Rychlost je dvojnasobna |
// r2<<=1; // Rozsah 2 az 184 pro rr=0 |
if ((stav==jizda)||(stav==cihla)||(stav==rozjezd)) //||(stav==pocihle)) // Jizda |
{ |
set_pwm1_duty(r1); |
set_pwm2_duty(r2); |
} |
else |
{ |
set_pwm1_duty(0); // Zastaveni |
set_pwm2_duty(0); |
}; |
if((stav==rozjezd)&&(get_timer1()>10)) // musi ujet alespon 31cm |
{ |
ext_int_edge(H_TO_L); // Nastav podminky preruseni od cihly |
INT0IF=0; // Zruseni predesle udalosti od startera |
enable_interrupts(INT_EXT); |
enable_interrupts(GLOBAL); |
stav=jizda; |
}; |
if(stav==start) // Snimkuje, toci servem a ceka na start |
{ |
set_adc_channel(MODRA); // Kroutitko na vystredeni predniho kolecka |
Delay_ms(1); |
stred=read_adc(); |
if(!input(PROXIMITY)) |
{ |
disp(0x80); |
while(input(PROXIMITY)); // Cekej, dokud starter neda ruku pryc |
set_timer1(0); // Vynuluj citac odometrie |
set_pwm1_duty(255); // Rychly rozjezd !!! Zkontrolovat na oscyloskopu |
set_pwm2_duty(255); |
disp(0x01); |
while(get_timer1()<=4) // Ujed alespon 12cm |
{ |
set_adc_channel(LMAX); // Levy UV sensor |
delay_us(40); |
if(read_adc()<THR) {cas=CASMIN; break;}; // Prejeli jsme caru vlevo |
set_adc_channel(RMAX); // Pravy UV sensor |
delay_us(40); |
if(read_adc()<THR) {cas=CASMAX; break;}; // Prejeli jsme caru vpravo |
cas=CASAVR-CASMIN; // Cara je rovne |
}; |
stav=rozjezd; |
}; |
} |
pom=0x80; // Zobrazeni pozice cary na displayi |
for(n=CASMAX/8; n<cas; n+=CASMAX/8) pom>>=1; |
disp(pom); |
while(true) // Ve zbytku casu snimku cti krajni UV senzory a naraznik |
{ |
if(BUMPER) // Sakra, do neceho jsme narazili a nevideli jsme to! |
{ |
bum(); |
SaveLog(log-1); // Zapis Black Boxu do EEPROM |
delay_ms(TUHOS); //!!! Zatuhle prevodovky |
set_pwm1_duty(200); // pomalu vpred |
set_pwm2_duty(200); |
output_low(MOT_L); |
output_low(MOT_R); |
cas=CASAVR-CASMIN; |
}; |
set_adc_channel(LMAX); // Levy UV sensor |
for(n=0;n<20;n++) if(input(HREF)) goto next_snap; |
if(read_adc()<THR) cas=CASMIN; |
set_adc_channel(RMAX); // Pravy UV sensor |
for(n=0;n<20;n++) if(input(HREF)) goto next_snap; |
if(read_adc()<THR) cas=CASMAX; |
}; |
} |
} |
/roboti/istrobot/camerus/SW/876/bak/diag.c |
---|
0,0 → 1,67 |
//--- Diagnostika cidel a vymazani EEPROM --- |
void diag() |
{ |
int8 n; |
// Vymaz Black Box v EEPROM |
for(n=0;n<255;n++) write_eeprom(n,0); |
bb_l[0]=0; // Zapis na pozici 0 vzdalenost 0 |
bb_h[0]=0; |
SaveLog(0); // Zapis do EEPROM pocet zaznamu 0, tedy jeden zaznam |
for(n=0;n<=4;n++) |
{ |
disp(0x55); // Blikni pro potvrzeni |
delay_ms(200); |
disp(0xAA); |
delay_ms(200); |
}; |
while(true) |
{ |
if(!IRRX) |
{ |
int8 ble; |
i2c_start(); // Cteni kompasu |
i2c_write(COMPAS_ADR); |
i2c_write(0x1); |
i2c_stop(); |
i2c_start(); |
i2c_write(COMPAS_ADR+1); |
ble=i2c_read(0); |
i2c_stop(); |
disp(ble); |
delay_ms(200); |
} |
else |
{ |
i2c_start(); // Diagnostika sonaru |
i2c_write(SONAR_ADR); |
i2c_write(0x02); // dosah |
i2c_write(0x03); // n*43mm |
i2c_stop(); |
i2c_start(); |
i2c_write(SONAR_ADR); |
i2c_write(0x01); // zesileni |
i2c_write(0x01); // male, pro eliminaci echa z minuleho mereni |
i2c_stop(); |
i2c_start(); // Sonar Ping |
i2c_write(0xE0); |
i2c_write(0x0); |
i2c_write(0x51); // 50 mereni v palcich, 51 mereni v cm, 52 v us |
i2c_stop(); |
delay_ms(100); |
i2c_start(); // Odraz ze sonaru |
i2c_write(0xE0); |
i2c_write(0x3); |
i2c_stop(); |
i2c_start(); |
i2c_write(0xE1); |
n=i2c_read(0); |
i2c_stop(); |
disp(n); // Zobrazeni hodnoty ze sonaru a zaroven diagnostika predniho IR cidla |
delay_ms(200); |
} |
} |
} |
/roboti/istrobot/camerus/SW/876/bak/objizdka_L.c |
---|
0,0 → 1,183 |
// **** Objeti cihly vlevo **** LLLL |
#define L_TOUCH 1 // Cara vlevo |
#define R_TOUCH 2 // Cata vpravo |
#define B_TOUCH 3 // Both |
int8 n; |
int8 r1,r2,rr; |
int8 touch; |
enum okolo_cihly {pred_carou,na_care,po_care}; |
okolo_cihly ridic; // V jakem jsme stavu objizdeni cihly |
int8 vzdalenost; |
int8 visualisation; |
stav=cihla; // Dalsi prekazku uz nezaznamenavej (je to s velkou pravdepodobnosti cil) |
touch=0; // Indikator detekce cary pri objizdeni |
cihla: |
rr=RR_CIHLA; //!!! Rozumna rychlost pro objizdeni cihly (bylo by lepsi rychlost zvysovat) a pri detekci pohybu zase snizit |
disp(0x99); |
set_pwm1_duty(0); // zabrzdi levym kolem, prave vpred |
set_pwm2_duty(220); |
output_high(MOT_L); |
output_low(MOT_R); |
odocounter=get_timer1(); |
while(true) // Na zacatku se vyhni cihle, zatoc co muzes |
{ |
cas=CASMIN-5; // jeste vic nez hodne do leva |
if(BUMPER) // Narazili jsme do cihly, musime couvnout! |
{ |
bum(); |
SaveLog(log-1); // Zapis Black Boxu do EEPROM |
delay_ms(TUHOS); //!!! Zatuhle prevodovky |
brzda(); |
goto cihla; // Znovu zacni cihlu objizdet |
}; |
set_pwm1_duty(0); |
set_pwm2_duty(220); // !!! mozna prilis maly vykon pro rozjezd pro zatuhlou prevodovku |
output_high(MOT_L); // leve kolo reverz |
output_low(MOT_R); // prave kolo vpred |
if(get_timer1()>(odocounter+5)) // konec zatacky? |
{ |
disp(0x66); |
break; |
} |
SetServoQ(cas); |
delay_ms(18); |
}; |
//------ Objeti cihly v konstantni vzdalenosti ------ |
ridic=pred_carou; |
cas=CASAVR-CASMIN; // rovne |
output_low(MOT_L); // vpred |
output_low(MOT_R); |
visualisation=0; |
while(true) |
{ |
if(BUMPER) // Narazili jsme do cihly, musime couvnout! |
{ |
bum(); |
SaveLog(log-1); // Zapis Black Boxu do EEPROM |
delay_ms(TUHOS); //!!! Zatuhle prevodovky |
set_pwm1_duty(160); // vpred |
set_pwm2_duty(160); |
output_low(MOT_L); |
output_low(MOT_R); |
cas=CASMIN; |
}; |
delta_bearing=bearing-bearing_offset; |
visualisation=(delta_bearing & 0xF0) | (visualisation & 0x0F); |
if(IRRX) // hrozi celni srazka s cihlou v prubehu objizdeni |
{ |
cas=CASMIN; |
} |
else |
{ |
if((vzdalenost!=0)||!input(PROXIMITY)||((delta_bearing>60)&&(delta_bearing<128))) // Udrzovani konstantni vzdalenosti od cihly |
{ |
if(cas>(CASMIN+20)) cas-=20; |
} |
else |
{ |
if(cas<(CASMAX-20)) cas+=20; |
}; |
}; |
// Elektronicky diferencial |
if(cas<CASAVR) {r1=cas-CASMIN; r2=CASAVR-CASMIN;}; // Normovani vystupni hodnoty radkoveho snimace |
if(cas==CASAVR) {r1=cas-CASMIN; r2=cas-CASMIN;}; // pro rizeni rychlosti motoru |
if(cas>CASAVR) {r1=CASAVR-CASMIN; r2=CASMAX-cas;}; // Rozsah 1 az 92 |
if (r1>(CASAVR-CASMIN-rr)) r1=(r1<<1)+rr-(CASAVR-CASMIN); // Neco jako nasobeni |
if (r2>(CASAVR-CASMIN-rr)) r2=(r2<<1)+rr-(CASAVR-CASMIN); |
//!!! pro zatuhle prevodovky |
// r1<<=1; // Rychlost je dvojnasobna |
// r2<<=1; // Rozsah 2 az 184 pro rr=0 |
set_pwm1_duty(r1); // Nastav rychlost motoru |
set_pwm2_duty(r2); |
SetServoQ(cas); |
i2c_start(); // Sonar Ping |
i2c_write(SONAR_ADR); |
i2c_write(0x0); |
i2c_write(0x52); // mereni v us |
i2c_stop(); |
for(n=1;n<=90;n++) // 18ms testovani cary do dalsi korekce serva |
{ |
set_adc_channel(LMAX); |
delay_us(100); |
if(read_adc()<THR) touch|=L_TOUCH; |
set_adc_channel(RMAX); |
delay_us(100); |
if(read_adc()<THR) touch|=R_TOUCH; |
}; |
i2c_start(); // Odraz ze sonaru |
i2c_write(SONAR_ADR); |
i2c_write(0x3); |
i2c_stop(); |
i2c_start(); |
i2c_write(SONAR_ADR+1); |
vzdalenost=i2c_read(0); |
i2c_stop(); |
i2c_start(); // Cteni kompasu |
i2c_write(COMPAS_ADR); |
i2c_write(0x1); // uhel 0-255 |
i2c_stop(); |
i2c_start(); |
i2c_write(COMPAS_ADR+1); |
bearing=i2c_read(0); |
i2c_stop(); |
if(touch==L_TOUCH) visualisation|=0x2; |
if(touch==R_TOUCH) visualisation|=0x1; |
if((touch==B_TOUCH)&&(ridic==pred_carou)) ridic=na_care; |
if((ridic==na_care)&&(touch==0)) break; |
if(ridic==na_care) touch=0; |
disp(visualisation); |
}; |
disp(0xC3); |
set_pwm1_duty(20); //!!! pred zatuhlejma prevodovkama tam bylo 20 a 200 |
set_pwm2_duty(250); |
output_high(MOT_L); |
output_low(MOT_R); |
delay_us(40); |
odocounter=get_timer1(); // Poznamenej aktualni stav odometrie |
while (true) // Znovu se musime dotknout cary |
{ |
for(n=1;n<=90;n++) // 18ms testovani cary do dalsi korekce serva |
{ |
set_adc_channel(LMAX); // Levy UV sensor |
delay_us(100); |
if(read_adc()<THR) // Dotkli jsme se levym senzorem |
{ |
disp(0xE0); |
cas=CASAVR-CASMIN; // nastavime, ze cara je rovne |
goto cara; |
}; |
set_adc_channel(RMAX); // Pravy UV sensor |
delay_us(100); |
if((get_timer1()>=(odocounter+2)) && (read_adc()<THR)) // Pravym senzorem nesmime caru prejet! |
{ |
disp(0x07); |
cas=CASMAX; // kdyz prejedem, tak nastavime, ze cara je vpravo |
goto cara; |
}; |
} |
SetServoQ(CASMIN-5); // max. max. doleva L |
} |
cara: |
output_low(MOT_L); // oba motory vpred |
output_low(MOT_R); |
/roboti/istrobot/camerus/SW/876/bak2/camerus.c |
---|
0,0 → 1,633 |
//********* Robot Camerus pro IstRobot 2007 ************ |
//"$Id: camerus.c 253 2007-04-24 09:26:46Z kakl $" |
//***************************************************** |
#include ".\camerus.h" |
#USE FAST_IO (C) // Brana C je ve FAST_IO modu, aby slo rychle cist z kamery |
// Rychlostni konstanty |
#define RR_CIHLA 60 // Rozumna rychlost pro objizdeni cihly |
#define RR_PRERUSENI 50 // Rozumna rychlost pro priblizeni se k preruseni |
#define BRZDNA_DRAHA 0x20 // Jak daleko pred problemem se zacne brzdit |
#define TUHOS 100 // Jak dlouho se bude couvat po narazu na naraznik |
#define ODODO_CIHLA 0xFFF |
#define ODODO_TUNEL 0xFFF |
#define ODODO_PRERUSENI 0xFFF |
// Adresy IIC periferii |
#define COMPAS_ADR 0xC0 |
#define CAMERA_ADR 0xDC |
#define SONAR_ADR 0xE0 |
// A/D vstupy |
#define RMAX 4 // AN4/RA5 - leve cidlo na vyjeti z cary |
#define LMAX 3 // AN3/RA3 - prave cidlo na vyjeti z cary |
#define CERVENA 2 // AN2/RA2 - cervene kroutitko |
#define ZELENA 1 // AN1/RA0 - zelene kroutitko |
#define MODRA 0 // AN0/RA1 - modre kroutitko |
// I/O |
#define HREF PIN_C5 // Signal HREF z kamery (v H po celou dobu radku) |
#define PIX PIN_C6 // Vstup pro body z kamery (za trivstupim hradlem OR (dig. komparator)) |
#define SERVO PIN_B4 // Vystup na servo (1 az 2ms po cca 20ms (synchronizovano snimkovym kmitoctem)) |
#define MOT_L PIN_B5 // Smer otaceni leveho motoru; druhy pol je RC2 |
#define MOT_R PIN_B6 // Smer otaceni praveho motoru; druhy pol je RC1 |
#define MOT_1 PIN_C1 // PWM vystpy motoru |
#define MOT_2 PIN_C2 // |
#define DATA PIN_B2 // K modulu LEDbar data |
#define CP PIN_B1 // K modulu LEDbar hodiny |
//#define ODO PIN_C0 // Ze snimace z odometrie z praveho kola na TIMER1 |
// Jeden impuls je 31,25mm |
#define IRRX !input(PIN_B0) // Vstup INT, generuje preruseni pri prekazce |
#define IRTX PIN_B3 // Modulovani vysilaci IR LED na detekci prekazky |
#define PROXIMITY PIN_C7 // Cidlo kratkeho dosahu na cihlu |
#define BUMPER !input(PIN_A4) // Naraznik |
#define CASMIN 6 // Rozsah radku snimace |
#define CASMAX 192 |
#define CASAVR ((CASMAX+CASMIN) / 2) |
#define EEMAX 255 // Konec EEPROM |
#define MAXLOG 0x10 // Maximalni pocet zaznamu v logu |
#if MAXLOG>(EEMAX/3) |
#error Prekrocena velikost EEPROM |
#endif |
#define OFFSETO 0x9F //0x9F // Vystredeni serva pro objeti prekazky |
#define THR 90 // Threshold pro UV cidla na caru |
#byte INTCON = 0x0B // Interrupt configuration register |
#bit GIE = INTCON.7 |
#bit PEIE = INTCON.6 |
#bit TMR0IE = INTCON.5 |
#bit INT0IE = INTCON.4 |
#bit RBIE = INTCON.3 |
#bit TMR0IF = INTCON.2 |
#bit INT0IF = INTCON.1 |
#bit RBIF = INTCON.0 |
enum stavy {start,rozjezd,jizda,cihla,pocihle,cil}; |
stavy stav; // Kde jsme na trati |
int8 cas; // Cas hrany bila/cerna v radce |
int8 stred; // Vystredeni kolecka |
int16 odocounter; // Zaznamenani aktualniho stavu pocitadla odometrie |
int16 last_log_odo; // Posledni stav odometrie poznamenany do logu |
int16 last_log; // Cislo posledniho zaznamu v logu v EEPROM |
int8 bb_h[MAXLOG]; // Cerna skrinka MSB |
int8 bb_l[MAXLOG]; // Cerna skrinka LSB |
int8 bb_f[MAXLOG]; // Cerna skrinka priznak (typ zaznamu) |
int8 log; // Pocitadlo pro cernou skrinku |
int8 rr; // Promenna na ulozeni Rozumne rychlost |
int8 rrold; |
int16 odo_preruseni, odo_cihla, odo_tunel; // Problemy na trati |
// Zobrazeni jednoho byte na modulu LEDbar |
inline void disp(int8 x) |
{ |
int n; |
for(n=0;n<=7;n++) |
{ |
if (bit_test(x,0)) output_low(DATA); else output_high(DATA); |
output_high(CP); |
x>>=1; |
output_low(CP); |
} |
} |
// Blikani LEDbarem ve stilu Night Rider |
void NightRider(int8 x) |
{ |
int n,i,j; |
for(j=0;j<x;j++) |
{ |
i=0x01; |
for(n=0;n<7;n++) |
{ |
disp(i); |
rotate_left(&i, 1); |
delay_ms(40); |
} |
for(n=0;n<7;n++) |
{ |
disp(i); |
rotate_right(&i, 1); |
delay_ms(40); |
} |
} |
disp(i); |
delay_ms(40); |
i=0; |
disp(i); |
} |
// Zaznam LOGu do EEPROM |
void SaveLog(int8 log) |
{ |
int8 n,i; |
i=0; |
for(n=0;n<=(log*3);n+=3) // Ulozeni Black Boxu do EEPROM |
{ |
write_eeprom(n,bb_f[i]); |
write_eeprom(n+1,bb_h[i]); |
write_eeprom(n+2,bb_l[i]); |
i++; |
}; |
write_eeprom(EEMAX,log); // Zapis poctu zaznamu na konec EEPROM |
} |
// Zaznam do Logu do RAM |
void LogLog(int8 flag, int16 gap) |
{ |
int16 timer_pom; |
timer_pom=get_timer1(); // Timer se musi vycist atomicky |
bb_l[log]=make8(timer_pom,0); // Zaznam |
bb_h[log]=make8(timer_pom,1); |
bb_f[log]=flag; // Typ zaznamu |
if(log<MAXLOG) log++; // Ukazatel na dalsi zaznam |
last_log_odo=timer_pom+gap; // Dalsi mereni nejdrive po ujeti def. vzdalenosti |
rr=rrold; // Problem skoncil, znovu jed Rozumnou Rychlosti |
} |
void ReadBlackBox() |
{ |
last_log=read_eeprom(EEMAX); // Kolik zaznamu mame od minule poznamenano? |
{ |
int8 n,i; |
i=0; |
for(n=0;n<=last_log;n++) |
{ |
if(read_eeprom(i)==0) odo_tunel=MAKE16(read_eeprom(i+2),read_eeprom(i+1)); |
if(read_eeprom(i)==0xFF) odo_cihla=MAKE16(read_eeprom(i+2),read_eeprom(i+1)); |
if((read_eeprom(i)>0) && (read_eeprom(i)<0xFF)) odo_preruseni=MAKE16(read_eeprom(i+2),read_eeprom(i+1)); |
} |
} |
} |
// Brzdeni motorama stridou 1:1 |
void brzda() |
{ |
int8 n,i; |
set_pwm1_duty(0); // vypni PWM |
set_pwm2_duty(0); |
setup_ccp1(CCP_OFF); |
setup_ccp2(CCP_OFF); |
for (n=0;n<200;n++) |
{ |
output_low(MOT_L); |
output_low(MOT_R); |
output_high(MOT_1); |
output_high(MOT_2); |
delay_us(200); |
output_high(MOT_L); |
output_high(MOT_R); |
output_low(MOT_1); |
output_low(MOT_2); |
delay_us(200); |
} |
output_low(MOT_L); // smer vpred |
output_low(MOT_R); |
setup_ccp1(CCP_PWM); // RC1 // Zapni PWM pro motory |
setup_ccp2(CCP_PWM); // RC2 |
} |
void SetServo(int8 angle) |
{ |
int8 n; |
for(n=0; n<10; n++) |
{ |
output_high(SERVO); // Odvysilani impuzu 1 az 2ms pro servo |
delay_us(1000); |
delay_us(stred); |
delay_us(stred); |
delay_us(stred); |
delay_us(angle); |
delay_us(angle); |
output_low(SERVO); |
delay_ms(18); |
} |
} |
inline void SetServoQ(int8 angle) |
{ |
output_high(SERVO); // Odvysilani impuzu 1 az 2ms pro servo |
delay_us(1000); |
delay_us(stred); |
delay_us(stred); |
delay_us(stred); |
delay_us(angle); |
delay_us(angle); |
output_low(SERVO); |
} |
// Couvni po narazu na naraznik |
inline void bum() |
{ |
set_pwm1_duty(0); // couvni, rovne dozadu |
set_pwm2_duty(0); |
output_high(MOT_L); |
output_high(MOT_R); |
disp(0xA5); |
SetServo(CASAVR-CASMIN); |
} |
#include ".\diag.c" |
//---------------------------- INT -------------------------------- |
#int_EXT |
EXT_isr() // Preruseni od prekazky |
{ |
unsigned int8 bearing, bearing_offset, delta_bearing; |
set_pwm1_duty(0); // zabrzdi levym kolem, prave vypni |
set_pwm2_duty(0); |
output_high(MOT_L); |
output_low(MOT_R); |
// Ujistime se, ze prijaty signal je z naseho IR vysilace |
output_high(IRTX); // Vypni LED na detekci prekazky |
delay_ms(2); |
if (IRRX) // stale nas signal? |
{ |
output_low(MOT_L); // je odraz -> vpred |
output_low(MOT_R); |
return; |
}; |
output_low(IRTX); // Zapni LED na detekci prekazky |
i2c_start(); // Cteni kompasu |
i2c_write(COMPAS_ADR); |
i2c_write(0x1); // 0-255 (odpovida 0-359) |
i2c_stop(); |
i2c_start(); |
i2c_write(COMPAS_ADR+1); |
bearing_offset=i2c_read(0); // Poznamenej hodnotu pred cihlou |
i2c_stop(); |
delay_ms(9); |
if (!IRRX) // stale nas signal? |
{ |
output_low(MOT_L); // neni odraz -> vpred |
output_low(MOT_R); |
return; |
}; |
rr=rrold; // Po cihle se pojede opet Rozumnou Rychlosti |
if(stav!=cihla) |
{ |
LogLog(0xFF,3); // Cihla |
}; |
//!!! if(stav==cihla) while(true); // Zastav na furt, konec drahy |
// if(stav==cihla) return; // Po druhe nic neobjizdej |
// Pozor na rozjezd |
if((stav==jizda)||(stav==cihla)) // Objed cihlu |
{ |
#include ".\objizdka_L.c" |
}; |
last_log_odo=get_timer1()+16; // Pul metru po cihle nezaznamenavej do LOGu |
} |
//---------------------------------- MAIN -------------------------------------- |
void main() |
{ |
int8 offset; // Promena pro ulozeni offsetu |
int8 r1; // Rychlost motoru 1 |
int8 r2; // Rychlost motoru 2 |
setup_adc_ports(ALL_ANALOG); // Zapnuti A/D prevodniku pro cteni kroutitek |
setup_adc(ADC_CLOCK_INTERNAL); |
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); // Casovac pro mereni casu hrany W/B v radce |
setup_timer_1(T1_EXTERNAL); // Cita pulzy z odometrie z praveho kola |
setup_timer_2(T2_DIV_BY_16,255,1); // Casovac PWM motoru |
//!!! setup_timer_2(T2_DIV_BY_4,255,1); // Casovac PWM motoru |
setup_ccp1(CCP_PWM); // RC1 // PWM pro motory |
setup_ccp2(CCP_PWM); // RC2 |
setup_comparator(NC_NC_NC_NC); |
setup_vref(FALSE); |
set_tris_c(0b11111001); // Nastaveni vstup/vystup pro branu C, protoze se to nedela automaticky |
set_pwm1_duty(0); // Zastav motory |
set_pwm2_duty(0); |
output_low(MOT_L); // Nastav smer vpred |
output_low(MOT_R); |
disp(0); // Zhasni LEDbar |
if(BUMPER) // Kdyz nekdo na zacatku drzi naraznik, vymaz log a spust diagnostiku |
{ |
diag(); |
} |
output_low(IRTX); // Zapni LED na detekci prekazky |
NightRider(1); // Zablikej, aby se poznalo, ze byl RESET |
// Zaroven se musi pockat, nez se rozjede kamera, nez se do ni zacnou posilat prikazy |
//... Nastaveni sonaru ... |
i2c_start(); |
i2c_write(SONAR_ADR); |
i2c_write(0x02); // dosah |
i2c_write(0x03); // n*43mm |
i2c_stop(); |
i2c_start(); |
i2c_write(SONAR_ADR); |
i2c_write(0x01); // zesileni |
i2c_write(0x01); // male, pro eliminaci echa z minuleho mereni |
i2c_stop(); |
//... Nastaveni kamery ... |
i2c_start(); // Soft RESET kamery |
i2c_write(CAMERA_ADR); // Adresa kamery |
i2c_write(0x12); // Adresa registru COMH |
i2c_write(0x80 | 0x24); // Zapis ridiciho slova |
i2c_stop(); |
i2c_start(); // BW |
i2c_write(CAMERA_ADR); |
i2c_write(0x28); |
i2c_write(0b01000001); |
i2c_stop(); |
/* |
i2c_start(); // Contrast (nema podstatny vliv na obraz) |
i2c_write(CAMERA_ADR); |
i2c_write(0x05); |
i2c_write(0xA0); // 48h |
i2c_stop(); |
i2c_start(); // Band Filter (pokud by byl problem se zarivkama 50Hz) |
i2c_write(CAMERA_ADR); |
i2c_write(0x2D); |
i2c_write(0x04 | 0x03); |
i2c_stop(); |
*/ |
i2c_start(); // Fame Rate |
i2c_write(CAMERA_ADR); |
i2c_write(0x2B); |
i2c_write(0x00); // cca 17ms (puvodni hodnota 5Eh = 20ms) |
i2c_stop(); |
i2c_start(); // VSTRT |
i2c_write(CAMERA_ADR); |
i2c_write(0x19); |
i2c_write(118); // prostredni radka |
i2c_stop(); |
i2c_start(); // VEND |
i2c_write(CAMERA_ADR); |
i2c_write(0x1A); |
i2c_write(118); |
i2c_stop(); |
NightRider(1); // Musi se dat cas kamere na AGC a AEC |
{ // Mereni expozice |
int8 t1,t2; |
i2c_start(); // Brightness, zacni od uplne tmy |
i2c_write(CAMERA_ADR); |
i2c_write(0x06); |
i2c_write(0); // 80h default |
i2c_stop(); |
delay_ms(50); |
for(offset=0x04;offset<(255-0x04);offset+=0x04) // Zacni od jasu 10h |
{ |
i2c_start(); // Brightness |
i2c_write(CAMERA_ADR); |
i2c_write(0x06); |
i2c_write(offset); // 80h default |
i2c_stop(); |
disp(offset); |
delay_ms(50); |
t1=0; |
t2=0; |
while(!input(HREF)); // Cekej nez se zacnou posilat pixely z radky |
delay_ms(5); |
while(!input(HREF)); // Cekej nez se zacnou posilat pixely z radky |
set_timer0(0); // Vynuluj pocitadlo casu |
if(!input(PIX)) continue; |
while(input(PIX)); |
t1=get_timer0(); // Precti cas z citace casu hrany |
set_timer0(0); // Vynuluj pocitadlo casu |
while(!input(PIX)); |
t2=get_timer0(); |
if((t1>60) && (t1<140) && (t2>5) && (t2<=10)) break; // Vidis, co mas? |
delay_ms(2); // Preskoc druhou radku z kamery |
}; |
delay_ms(1000); // Nech chvili na displayi zmerenou hodnotu |
} |
set_adc_channel(CERVENA); // --- Kroutitko pro jas --- |
delay_ms(1); |
offset=read_adc(); |
offset &= 0b11111100; // Dva nejnizsi bity ignoruj |
// offset += 0x70; // Jas nebude nikdy nizsi |
disp(offset); |
i2c_start(); // Brightness |
i2c_write(CAMERA_adr); |
i2c_write(0x06); |
i2c_write(offset); // 80h default |
i2c_stop(); |
delay_ms(1000); // Nech hodnotu chvili na displayi |
set_adc_channel(ZELENA); // --- Kroutitko pro vykon motoru --- |
delay_ms(1); |
rr=read_adc()>>2; // 0-63 // Pokud by se zvetsil rozsah, tak zkontrolovat jakonasobeni! |
rr+=27; // 27-90 |
//!!! rr=read_adc()>>1; // 0-128 // Pokud by se zvetsil rozsah, tak zkontrolovat jakonasobeni! |
rrold=rr; |
cas=CASAVR-CASMIN; // Inicializace promenych, aby neslo servo za roh |
// a aby se to rozjelo jeste dneska |
stav=start; // Jsme na startu |
set_timer1(0); // Vynuluj citac odometrie |
log=0; // Zacatek logu v cerne skrince |
last_log_odo=0; // Posledni zaznam odometrie do logu |
// ReadBlackBox(); // Vycteni zaznamu z Black Boxu |
odo_cihla=ODODO_CIHLA-BRZDNA_DRAHA; |
odo_tunel=ODODO_TUNEL-BRZDNA_DRAHA; |
odo_preruseni=ODODO_PRERUSENI-BRZDNA_DRAHA; |
// ........................... Hlavni smycka ................................ |
while(true) |
{ |
int8 pom; |
int8 n; |
int8 gap; |
int16 ododo; |
gap=0; // Vynuluj pocitadlo preruseni |
next_snap: |
pom=0; |
disable_interrupts(GLOBAL); //----------------------- Critical Section |
while(input(HREF)); // Preskoc 1. radku |
while(!input(HREF)); // Cekej nez se zacnou posilat pixely z 2. radky |
set_timer0(0); // Vynuluj pocitadlo casu |
while(input(HREF)) // Po dobu vysilani radky cekej na hranu W/B |
{ |
// !!!!Dodelat rozpoznani cerne cary napric pro zastaveni ? |
if(!input(PIX)) // Pokud se X-krat za sebou precetla CERNA |
if(!input(PIX)) |
// if(!input(PIX)) |
{ |
pom=get_timer0(); // Precti cas z citace casu hrany |
break; |
}; |
}; |
while(input(HREF)); // Pockej na shozeni signalu HREF |
if((pom<CASMAX) && (pom>CASMIN)) cas=pom; // Orizni konce radku |
// Na konci obrazovaho radku to blbne. Jednak chyba od apertury |
// a vubec to nejak na kraji nefunguje. |
output_high(SERVO); // Odvysilani impuzu 1 az 2ms pro servo |
delay_us(1000); |
delay_us(stred); |
delay_us(stred); |
delay_us(stred); |
delay_us(cas); |
delay_us(cas); |
output_low(SERVO); |
// Elektronicky diferencial 1. cast |
if(cas<CASAVR) {r1=cas-CASMIN; r2=CASAVR-CASMIN;}; // Normovani vystupni hodnoty radkoveho snimace |
if(cas==CASAVR) {r1=cas-CASMIN; r2=cas-CASMIN;}; // pro rizeni rychlosti motoru |
if(cas>CASAVR) {r1=CASAVR-CASMIN; r2=CASMAX-cas;}; // Rozsah 1 az 92 |
enable_interrupts(GLOBAL); //----------------------- End Critical Section |
if(pom==0) // Kamera nevidi caru, poznamenej to do logu |
{ |
if((cas>(CASMIN+30))&&(cas<(CASMAX-30))) // Nebyla minule cara moc u kraje? |
if(last_log_odo<get_timer1()) // Aby nebyly zaznamy v logu prilis huste, musi se napred neco ujet od minuleho zaznamu |
{ |
gap++; |
} |
} |
else |
{ |
if(gap>=2) // Trva preruseni cary alespon 2 snimky? |
{ |
LogLog(gap,8); // Dalsi mereni nejdrive po ujeti 24 cm |
rr=rrold; // Preruseni cary skoncilo, znovu jed Rozumnou Rychlosti |
} |
gap=0; |
}; |
if(input(PROXIMITY) && ((stav==jizda)||(stav==cihla))) // Tunel |
{ |
if(last_log_odo<get_timer1()) // Aby nebyly zaznamy v logu prilis huste, musi se napred neco ujet od minuleho zaznamu |
{ |
LogLog(0,16); // Priznak tunelu; dalsi mereni nejdrive po ujeti 48 cm |
rr=rrold; // Vjeli jsme do tunelu, znovu jed rychle |
} |
}; |
//ODODO |
ododo=get_timer1(); |
if((ododo>odo_preruseni)&&(ododo<(odo_preruseni+8))) rr=RR_PRERUSENI; |
if((ododo>odo_cihla)&&(ododo<(odo_cihla+8))) rr=RR_PRERUSENI; |
if((ododo>odo_tunel)&&(ododo<(odo_tunel+8))) rr=RR_PRERUSENI; |
// Elektronicky diferencial 2. cast |
if (r1>(CASAVR-CASMIN-rr)) r1=(r1<<1)+rr-(CASAVR-CASMIN); // Neco jako nasobeni |
if (r2>(CASAVR-CASMIN-rr)) r2=(r2<<1)+rr-(CASAVR-CASMIN); // rozsah 1 az 92 pro rr=0 // rozsah 1 az 154 pro rr=63 |
//!!! pro zatuhle prevodovky |
// r1<<=1; // Rychlost je dvojnasobna |
// r2<<=1; // Rozsah 2 az 184 pro rr=0 |
if ((stav==jizda)||(stav==cihla)||(stav==rozjezd)) //||(stav==pocihle)) // Jizda |
{ |
set_pwm1_duty(r1); |
set_pwm2_duty(r2); |
} |
else |
{ |
set_pwm1_duty(0); // Zastaveni |
set_pwm2_duty(0); |
}; |
if((stav==rozjezd)&&(get_timer1()>10)) // musi ujet alespon 31cm |
{ |
ext_int_edge(H_TO_L); // Nastav podminky preruseni od cihly |
INT0IF=0; // Zruseni predesle udalosti od startera |
enable_interrupts(INT_EXT); |
enable_interrupts(GLOBAL); |
stav=jizda; |
}; |
if(stav==start) // Snimkuje, toci servem a ceka na start |
{ |
set_adc_channel(MODRA); // Kroutitko na vystredeni predniho kolecka |
Delay_ms(1); |
stred=read_adc(); |
if(!input(PROXIMITY)) |
{ |
disp(0x80); |
while(input(PROXIMITY)); // Cekej, dokud starter neda ruku pryc |
set_timer1(0); // Vynuluj citac odometrie |
set_pwm1_duty(255); // Rychly rozjezd !!! Zkontrolovat na oscyloskopu |
set_pwm2_duty(255); |
disp(0x01); |
while(get_timer1()<=4) // Ujed alespon 12cm |
{ |
set_adc_channel(LMAX); // Levy UV sensor |
delay_us(40); |
if(read_adc()<THR) {cas=CASMIN; break;}; // Prejeli jsme caru vlevo |
set_adc_channel(RMAX); // Pravy UV sensor |
delay_us(40); |
if(read_adc()<THR) {cas=CASMAX; break;}; // Prejeli jsme caru vpravo |
cas=CASAVR-CASMIN; // Cara je rovne |
}; |
stav=rozjezd; |
}; |
} |
pom=0x80; // Zobrazeni pozice cary na displayi |
for(n=CASMAX/8; n<cas; n+=CASMAX/8) pom>>=1; |
disp(pom); |
while(true) // Ve zbytku casu snimku cti krajni UV senzory a naraznik |
{ |
if(BUMPER) // Sakra, do neceho jsme narazili a nevideli jsme to! |
{ |
bum(); |
SaveLog(log-1); // Zapis Black Boxu do EEPROM |
delay_ms(TUHOS); //!!! Zatuhle prevodovky |
set_pwm1_duty(200); // pomalu vpred |
set_pwm2_duty(200); |
output_low(MOT_L); |
output_low(MOT_R); |
cas=CASAVR-CASMIN; |
}; |
set_adc_channel(LMAX); // Levy UV sensor |
for(n=0;n<20;n++) if(input(HREF)) goto next_snap; |
if(read_adc()<THR) cas=CASMIN; |
set_adc_channel(RMAX); // Pravy UV sensor |
for(n=0;n<20;n++) if(input(HREF)) goto next_snap; |
if(read_adc()<THR) cas=CASMAX; |
}; |
} |
} |
/roboti/istrobot/camerus/SW/876/bak2/diag.c |
---|
0,0 → 1,67 |
//--- Diagnostika cidel a vymazani EEPROM --- |
void diag() |
{ |
int8 n; |
// Vymaz Black Box v EEPROM |
for(n=0;n<255;n++) write_eeprom(n,0); |
bb_l[0]=0; // Zapis na pozici 0 vzdalenost 0 |
bb_h[0]=0; |
SaveLog(0); // Zapis do EEPROM pocet zaznamu 0, tedy jeden zaznam |
for(n=0;n<=4;n++) |
{ |
disp(0x55); // Blikni pro potvrzeni |
delay_ms(200); |
disp(0xAA); |
delay_ms(200); |
}; |
while(true) |
{ |
if(!IRRX) |
{ |
int8 ble; |
i2c_start(); // Cteni kompasu |
i2c_write(COMPAS_ADR); |
i2c_write(0x1); |
i2c_stop(); |
i2c_start(); |
i2c_write(COMPAS_ADR+1); |
ble=i2c_read(0); |
i2c_stop(); |
disp(ble); |
delay_ms(200); |
} |
else |
{ |
i2c_start(); // Diagnostika sonaru |
i2c_write(SONAR_ADR); |
i2c_write(0x02); // dosah |
i2c_write(0x03); // n*43mm |
i2c_stop(); |
i2c_start(); |
i2c_write(SONAR_ADR); |
i2c_write(0x01); // zesileni |
i2c_write(0x01); // male, pro eliminaci echa z minuleho mereni |
i2c_stop(); |
i2c_start(); // Sonar Ping |
i2c_write(0xE0); |
i2c_write(0x0); |
i2c_write(0x51); // 50 mereni v palcich, 51 mereni v cm, 52 v us |
i2c_stop(); |
delay_ms(100); |
i2c_start(); // Odraz ze sonaru |
i2c_write(0xE0); |
i2c_write(0x3); |
i2c_stop(); |
i2c_start(); |
i2c_write(0xE1); |
n=i2c_read(0); |
i2c_stop(); |
disp(n); // Zobrazeni hodnoty ze sonaru a zaroven diagnostika predniho IR cidla |
delay_ms(200); |
} |
} |
} |
/roboti/istrobot/camerus/SW/876/bak2/objizdka_L.c |
---|
0,0 → 1,183 |
// **** Objeti cihly vlevo **** LLLL |
#define L_TOUCH 1 // Cara vlevo |
#define R_TOUCH 2 // Cata vpravo |
#define B_TOUCH 3 // Both |
int8 n; |
int8 r1,r2,rr; |
int8 touch; |
enum okolo_cihly {pred_carou,na_care,po_care}; |
okolo_cihly ridic; // V jakem jsme stavu objizdeni cihly |
int8 vzdalenost; |
int8 visualisation; |
stav=cihla; // Dalsi prekazku uz nezaznamenavej (je to s velkou pravdepodobnosti cil) |
odocounter=get_timer1(); |
cihla: |
rr=RR_CIHLA; //!!! Rozumna rychlost pro objizdeni cihly (bylo by lepsi rychlost zvysovat) a pri detekci pohybu zase snizit |
disp(0x99); |
set_pwm1_duty(0); // zabrzdi levym kolem, prave vpred |
set_pwm2_duty(255); |
output_high(MOT_L); |
output_low(MOT_R); |
while(true) // Na zacatku se vyhni cihle, zatoc co muzes |
{ |
cas=CASMIN-5; // jeste vic nez hodne do leva |
if(BUMPER) // Narazili jsme do cihly, musime couvnout! |
{ |
bum(); |
SaveLog(log-1); // Zapis Black Boxu do EEPROM |
delay_ms(TUHOS); //!!! Zatuhle prevodovky |
brzda(); |
goto cihla; // Znovu zacni cihlu objizdet |
}; |
set_pwm1_duty(0); |
set_pwm2_duty(220); // !!! mozna prilis maly vykon pro rozjezd pro zatuhlou prevodovku |
output_high(MOT_L); // leve kolo reverz |
output_low(MOT_R); // prave kolo vpred |
if(get_timer1()>(odocounter+5)) // konec zatacky? |
{ |
disp(0x66); |
break; |
} |
SetServoQ(cas); |
delay_ms(18); |
}; |
//------ Objeti cihly v konstantni vzdalenosti ------ |
touch=0; // Indikator detekce cary pri objizdeni |
ridic=pred_carou; |
cas=CASAVR-CASMIN; // rovne |
output_low(MOT_L); // vpred |
output_low(MOT_R); |
visualisation=0; |
while(true) |
{ |
if(BUMPER) // Narazili jsme do cihly, musime couvnout! |
{ |
bum(); |
SaveLog(log-1); // Zapis Black Boxu do EEPROM |
delay_ms(TUHOS); //!!! Zatuhle prevodovky |
set_pwm1_duty(160); // vpred |
set_pwm2_duty(160); |
output_low(MOT_L); |
output_low(MOT_R); |
cas=CASMIN; |
}; |
delta_bearing=bearing-bearing_offset; |
visualisation=(delta_bearing & 0xF0) | (visualisation & 0x0F); |
if(IRRX) // hrozi celni srazka s cihlou v prubehu objizdeni |
{ |
cas=CASMIN; |
} |
else |
{ |
if((vzdalenost!=0)||!input(PROXIMITY)||((delta_bearing>60)&&(delta_bearing<128))) // Udrzovani konstantni vzdalenosti od cihly |
{ |
if(cas>(CASMIN+20)) cas-=20; |
} |
else |
{ |
if(cas<(CASMAX-20)) cas+=20; |
}; |
}; |
// Elektronicky diferencial |
if(cas<CASAVR) {r1=cas-CASMIN; r2=CASAVR-CASMIN;}; // Normovani vystupni hodnoty radkoveho snimace |
if(cas==CASAVR) {r1=cas-CASMIN; r2=cas-CASMIN;}; // pro rizeni rychlosti motoru |
if(cas>CASAVR) {r1=CASAVR-CASMIN; r2=CASMAX-cas;}; // Rozsah 1 az 92 |
if (r1>(CASAVR-CASMIN-rr)) r1=(r1<<1)+rr-(CASAVR-CASMIN); // Neco jako nasobeni |
if (r2>(CASAVR-CASMIN-rr)) r2=(r2<<1)+rr-(CASAVR-CASMIN); |
//!!! pro zatuhle prevodovky |
// r1<<=1; // Rychlost je dvojnasobna |
// r2<<=1; // Rozsah 2 az 184 pro rr=0 |
set_pwm1_duty(r1); // Nastav rychlost motoru |
set_pwm2_duty(r2); |
SetServoQ(cas); |
i2c_start(); // Sonar Ping |
i2c_write(SONAR_ADR); |
i2c_write(0x0); |
i2c_write(0x52); // mereni v us |
i2c_stop(); |
for(n=1;n<=90;n++) // 18ms testovani cary do dalsi korekce serva |
{ |
set_adc_channel(LMAX); |
delay_us(100); |
if(read_adc()<THR) touch|=L_TOUCH; |
set_adc_channel(RMAX); |
delay_us(100); |
if(read_adc()<THR) touch|=R_TOUCH; |
}; |
i2c_start(); // Odraz ze sonaru |
i2c_write(SONAR_ADR); |
i2c_write(0x3); |
i2c_stop(); |
i2c_start(); |
i2c_write(SONAR_ADR+1); |
vzdalenost=i2c_read(0); |
i2c_stop(); |
i2c_start(); // Cteni kompasu |
i2c_write(COMPAS_ADR); |
i2c_write(0x1); // uhel 0-255 |
i2c_stop(); |
i2c_start(); |
i2c_write(COMPAS_ADR+1); |
bearing=i2c_read(0); |
i2c_stop(); |
if(touch==L_TOUCH) visualisation|=0x2; |
if(touch==R_TOUCH) visualisation|=0x1; |
if((touch==B_TOUCH)&&(ridic==pred_carou)) ridic=na_care; |
if((ridic==na_care)&&(touch==0)) break; |
if(ridic==na_care) touch=0; |
disp(visualisation); |
}; |
disp(0xC3); |
set_pwm1_duty(20); //!!! pred zatuhlejma prevodovkama tam bylo 20 a 200 |
set_pwm2_duty(250); |
output_high(MOT_L); |
output_low(MOT_R); |
delay_us(40); |
odocounter=get_timer1(); // Poznamenej aktualni stav odometrie |
while (true) // Znovu se musime dotknout cary |
{ |
for(n=1;n<=90;n++) // 18ms testovani cary do dalsi korekce serva |
{ |
set_adc_channel(LMAX); // Levy UV sensor |
delay_us(100); |
if(read_adc()<THR) // Dotkli jsme se levym senzorem |
{ |
disp(0xE0); |
cas=CASAVR-CASMIN; // nastavime, ze cara je rovne |
goto cara; |
}; |
set_adc_channel(RMAX); // Pravy UV sensor |
delay_us(100); |
if((get_timer1()>=(odocounter+2)) && (read_adc()<THR)) // Pravym senzorem nesmime caru prejet! |
{ |
disp(0x07); |
cas=CASMAX; // kdyz prejedem, tak nastavime, ze cara je vpravo |
goto cara; |
}; |
} |
SetServoQ(CASMIN-5); // max. max. doleva L |
} |
cara: |
output_low(MOT_L); // oba motory vpred |
output_low(MOT_R); |
/roboti/istrobot/camerus/SW/876/camerus.c |
---|
0,0 → 1,661 |
//********* Robot Camerus pro IstRobot 2007 ************ |
//"$Id$" |
//***************************************************** |
#include ".\camerus.h" |
#USE FAST_IO (C) // Brana C je ve FAST_IO modu, aby slo rychle cist z kamery |
// Rychlostni konstanty |
#define RR_CIHLA 50 // Rozumna rychlost pro objizdeni cihly |
#define RR_PRERUSENI 50 // Rozumna rychlost pro priblizeni se k preruseni |
#define BRZDNA_DRAHA 0x15 // Jak daleko pred problemem se zacne brzdit |
#define TUHOS 100 // Jak dlouho se bude couvat po narazu na naraznik |
#define ODODO_PROBLEM1 0xFFF |
#define ODODO_PROBLEM2 0xFFF |
#define ODODO_PROBLEM3 0xFFF |
// Adresy IIC periferii |
#define COMPAS_ADR 0xC0 |
#define CAMERA_ADR 0xDC |
#define SONAR_ADR 0xE0 |
// A/D vstupy |
#define RMAX 4 // AN4/RA5 - leve cidlo na vyjeti z cary |
#define LMAX 3 // AN3/RA3 - prave cidlo na vyjeti z cary |
#define CERVENA 2 // AN2/RA2 - cervene kroutitko |
#define ZELENA 1 // AN1/RA0 - zelene kroutitko |
#define MODRA 0 // AN0/RA1 - modre kroutitko |
// I/O |
#define HREF PIN_C5 // Signal HREF z kamery (v H po celou dobu radku) |
#define PIX PIN_C6 // Vstup pro body z kamery (za trivstupim hradlem OR (dig. komparator)) |
#define SERVO PIN_B4 // Vystup na servo (1 az 2ms po cca 20ms (synchronizovano snimkovym kmitoctem)) |
#define MOT_L PIN_B5 // Smer otaceni leveho motoru; druhy pol je RC2 |
#define MOT_R PIN_B6 // Smer otaceni praveho motoru; druhy pol je RC1 |
#define MOT_1 PIN_C1 // PWM vystpy motoru |
#define MOT_2 PIN_C2 // |
#define DATA PIN_B2 // K modulu LEDbar data |
#define CP PIN_B1 // K modulu LEDbar hodiny |
//#define ODO PIN_C0 // Ze snimace z odometrie z praveho kola na TIMER1 |
// Jeden impuls je 31,25mm |
#define IRRX !input(PIN_B0) // Vstup INT, generuje preruseni pri prekazce |
#define IRTX PIN_B3 // Modulovani vysilaci IR LED na detekci prekazky |
#define PROXIMITY PIN_C7 // Cidlo kratkeho dosahu na cihlu |
#define BUMPER !input(PIN_A4) // Naraznik |
#define CASMIN 6 // Rozsah radku snimace |
#define CASMAX 192 |
#define CASAVR ((CASMAX+CASMIN) / 2) |
#define EEMAX 255 // Konec EEPROM |
#define MAXLOG 0x10 // Maximalni pocet zaznamu v logu |
#if MAXLOG>(EEMAX/3) |
#error Prekrocena velikost EEPROM |
#endif |
#define OFFSETO 0x9F //0x9F // Vystredeni serva pro objeti prekazky |
#define THR 90 // Threshold pro UV cidla na caru |
#byte INTCON = 0x0B // Interrupt configuration register |
#bit GIE = INTCON.7 |
#bit PEIE = INTCON.6 |
#bit TMR0IE = INTCON.5 |
#bit INT0IE = INTCON.4 |
#bit RBIE = INTCON.3 |
#bit TMR0IF = INTCON.2 |
#bit INT0IF = INTCON.1 |
#bit RBIF = INTCON.0 |
enum stavy {start,rozjezd,jizda,cihla,pocihle,cil}; |
stavy stav; // Kde jsme na trati |
int8 cas; // Cas hrany bila/cerna v radce |
int8 stred; // Vystredeni kolecka |
int16 odocounter; // Zaznamenani aktualniho stavu pocitadla odometrie |
int16 last_log_odo; // Posledni stav odometrie poznamenany do logu |
int16 last_log; // Cislo posledniho zaznamu v logu v EEPROM |
int8 bb_h[MAXLOG]; // Cerna skrinka MSB |
int8 bb_l[MAXLOG]; // Cerna skrinka LSB |
int8 bb_f[MAXLOG]; // Cerna skrinka priznak (typ zaznamu) |
int8 log; // Pocitadlo pro cernou skrinku |
int8 rr; // Promenna na ulozeni Rozumne rychlost |
int8 rrold; |
int16 odo_preruseni, odo_cihla, odo_tunel; // Problemy na trati |
int16 odo_problem1, odo_problem2, odo_problem3; // Problemy na trati |
// Zobrazeni jednoho byte na modulu LEDbar |
inline void disp(int8 x) |
{ |
int n; |
for(n=0;n<=7;n++) |
{ |
if (bit_test(x,0)) output_low(DATA); else output_high(DATA); |
output_high(CP); |
x>>=1; |
output_low(CP); |
} |
} |
// Blikani LEDbarem ve stilu Night Rider |
void NightRider(int8 x) |
{ |
int n,i,j; |
for(j=0;j<x;j++) |
{ |
i=0x01; |
for(n=0;n<7;n++) |
{ |
disp(i); |
rotate_left(&i, 1); |
delay_ms(40); |
} |
for(n=0;n<7;n++) |
{ |
disp(i); |
rotate_right(&i, 1); |
delay_ms(40); |
} |
} |
disp(i); |
delay_ms(40); |
i=0; |
disp(i); |
} |
// Zaznam LOGu do EEPROM |
void SaveLog() |
{ |
int8 n,i,xlog; |
i=0; |
for(n=0;n<=(log*3);n+=3) // Ulozeni Black Boxu do EEPROM |
{ |
write_eeprom(n,bb_f[i]); |
write_eeprom(n+1,bb_h[i]); |
write_eeprom(n+2,bb_l[i]); |
i++; |
}; |
if(log>0) {xlog=log-1;} else {xlog=0;}; |
write_eeprom(EEMAX,xlog); // Zapis poctu zaznamu na konec EEPROM |
} |
// Zaznam do Logu do RAM |
void LogLog(int8 reason, int16 log_delay) |
{ |
int16 timer_pom; |
timer_pom=get_timer1(); // Timer se musi vycist atomicky |
bb_l[log]=make8(timer_pom,0); // Zaznam |
bb_h[log]=make8(timer_pom,1); |
bb_f[log]=reason; // Typ zaznamu |
if(log<(MAXLOG-1)) log++; // Ukazatel na dalsi zaznam |
last_log_odo=timer_pom+log_delay; // Dalsi mereni nejdrive po ujeti def. vzdalenosti |
rr=rrold; // Problem skoncil, znovu jed Rozumnou Rychlosti |
} |
void ReadBlackBox() |
{ |
last_log=read_eeprom(EEMAX); // Kolik zaznamu mame od minule poznamenano? |
{ |
int8 n,i; |
i=0; |
for(n=0;n<=last_log;n++) |
{ |
if(read_eeprom(i)==0) odo_tunel=MAKE16(read_eeprom(i+2),read_eeprom(i+1)); |
if(read_eeprom(i)==0xFF) odo_cihla=MAKE16(read_eeprom(i+2),read_eeprom(i+1)); |
if((read_eeprom(i)>0) && (read_eeprom(i)<0xFF)) odo_preruseni=MAKE16(read_eeprom(i+2),read_eeprom(i+1)); |
} |
} |
} |
// Brzdeni motorama stridou 1:1 |
void brzda() |
{ |
int8 n,i; |
set_pwm1_duty(0); // vypni PWM |
set_pwm2_duty(0); |
setup_ccp1(CCP_OFF); |
setup_ccp2(CCP_OFF); |
for (n=0;n<200;n++) |
{ |
output_low(MOT_L); |
output_low(MOT_R); |
output_high(MOT_1); |
output_high(MOT_2); |
delay_us(200); |
output_high(MOT_L); |
output_high(MOT_R); |
output_low(MOT_1); |
output_low(MOT_2); |
delay_us(200); |
} |
output_low(MOT_L); // smer vpred |
output_low(MOT_R); |
setup_ccp1(CCP_PWM); // RC1 // Zapni PWM pro motory |
setup_ccp2(CCP_PWM); // RC2 |
} |
void SetServo(int8 angle) |
{ |
int8 n; |
for(n=0; n<10; n++) |
{ |
output_high(SERVO); // Odvysilani impuzu 1 az 2ms pro servo |
delay_us(1000); |
delay_us(stred); |
delay_us(stred); |
delay_us(stred); |
delay_us(angle); |
delay_us(angle); |
output_low(SERVO); |
delay_ms(18); |
} |
} |
inline void SetServoQ(int8 angle) |
{ |
output_high(SERVO); // Odvysilani impuzu 1 az 2ms pro servo |
delay_us(1000); |
delay_us(stred); |
delay_us(stred); |
delay_us(stred); |
delay_us(angle); |
delay_us(angle); |
output_low(SERVO); |
} |
// Couvni po narazu na naraznik |
inline void bum() |
{ |
set_pwm1_duty(0); // couvni, rovne dozadu |
set_pwm2_duty(0); |
output_high(MOT_L); |
output_high(MOT_R); |
disp(0xA5); |
SetServo(CASAVR-CASMIN); |
} |
#include ".\diag.c" |
//---------------------------- INT -------------------------------- |
#int_EXT |
EXT_isr() // Preruseni od prekazky |
{ |
unsigned int8 bearing, bearing_offset, delta_bearing; |
set_pwm1_duty(0); // zabrzdi levym kolem, prave vypni |
set_pwm2_duty(0); |
output_high(MOT_L); |
output_low(MOT_R); |
// Ujistime se, ze prijaty signal je z naseho IR vysilace |
output_high(IRTX); // Vypni LED na detekci prekazky |
delay_ms(2); |
if (IRRX) // stale nas signal? |
{ |
output_low(MOT_L); // je odraz -> vpred |
output_low(MOT_R); |
return; |
}; |
output_low(IRTX); // Zapni LED na detekci prekazky |
i2c_start(); // Cteni kompasu |
i2c_write(COMPAS_ADR); |
i2c_write(0x1); // 0-255 (odpovida 0-359) |
i2c_stop(); |
i2c_start(); |
i2c_write(COMPAS_ADR+1); |
bearing_offset=i2c_read(0); // Poznamenej hodnotu pred cihlou |
i2c_stop(); |
delay_ms(9); |
if (!IRRX) // stale nas signal? |
{ |
output_low(MOT_L); // neni odraz -> vpred |
output_low(MOT_R); |
return; |
}; |
rr=rrold; // Po cihle se pojede opet Rozumnou Rychlosti |
if(stav!=cihla) |
{ |
LogLog(0xFF,3); // Cihla |
}; |
//!!! if(stav==cihla) while(true); // Zastav na furt, konec drahy |
// if(stav==cihla) return; // Po druhe nic neobjizdej |
// Pozor na rozjezd |
if((stav==jizda)||(stav==cihla)) // Objed cihlu |
{ |
#include ".\objizdka_L.c" |
}; |
last_log_odo=get_timer1()+16; // Pul metru po cihle nezaznamenavej do LOGu |
} |
//---------------------------------- MAIN -------------------------------------- |
void main() |
{ |
int8 offset; // Promena pro ulozeni offsetu |
int8 r1; // Rychlost motoru 1 |
int8 r2; // Rychlost motoru 2 |
int16 ble; |
setup_adc_ports(ALL_ANALOG); // Zapnuti A/D prevodniku pro cteni kroutitek |
setup_adc(ADC_CLOCK_INTERNAL); |
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); // Casovac pro mereni casu hrany W/B v radce |
setup_timer_1(T1_EXTERNAL); // Cita pulzy z odometrie z praveho kola |
setup_timer_2(T2_DIV_BY_16,255,1); // Casovac PWM motoru |
//!!! setup_timer_2(T2_DIV_BY_4,255,1); // Casovac PWM motoru |
setup_ccp1(CCP_PWM); // RC1 // PWM pro motory |
setup_ccp2(CCP_PWM); // RC2 |
setup_comparator(NC_NC_NC_NC); |
setup_vref(FALSE); |
set_tris_c(0b11111001); // Nastaveni vstup/vystup pro branu C, protoze se to nedela automaticky |
set_pwm1_duty(0); // Zastav motory |
set_pwm2_duty(0); |
output_low(MOT_L); // Nastav smer vpred |
output_low(MOT_R); |
disp(0); // Zhasni LEDbar |
if(BUMPER) // Kdyz nekdo na zacatku drzi naraznik, vymaz log a spust diagnostiku |
{ |
diag(); |
} |
output_low(IRTX); // Zapni LED na detekci prekazky |
NightRider(1); // Zablikej, aby se poznalo, ze byl RESET |
// Zaroven se musi pockat, nez se rozjede kamera, nez se do ni zacnou posilat prikazy |
//... Nastaveni sonaru ... |
i2c_start(); |
i2c_write(SONAR_ADR); |
i2c_write(0x02); // dosah |
i2c_write(0x03); // n*43mm |
i2c_stop(); |
i2c_start(); |
i2c_write(SONAR_ADR); |
i2c_write(0x01); // zesileni |
i2c_write(0x01); // male, pro eliminaci echa z minuleho mereni |
i2c_stop(); |
//... Nastaveni kamery ... |
i2c_start(); // Soft RESET kamery |
i2c_write(CAMERA_ADR); // Adresa kamery |
i2c_write(0x12); // Adresa registru COMH |
i2c_write(0x80 | 0x24); // Zapis ridiciho slova |
i2c_stop(); |
i2c_start(); // BW |
i2c_write(CAMERA_ADR); |
i2c_write(0x28); |
i2c_write(0b01000001); |
i2c_stop(); |
/* |
i2c_start(); // Contrast (nema podstatny vliv na obraz) |
i2c_write(CAMERA_ADR); |
i2c_write(0x05); |
i2c_write(0xA0); // 48h |
i2c_stop(); |
i2c_start(); // Band Filter (pokud by byl problem se zarivkama 50Hz) |
i2c_write(CAMERA_ADR); |
i2c_write(0x2D); |
i2c_write(0x04 | 0x03); |
i2c_stop(); |
*/ |
i2c_start(); // Fame Rate |
i2c_write(CAMERA_ADR); |
i2c_write(0x2B); |
i2c_write(0x00); // cca 17ms (puvodni hodnota 5Eh = 20ms) |
i2c_stop(); |
i2c_start(); // VSTRT |
i2c_write(CAMERA_ADR); |
i2c_write(0x19); |
i2c_write(118); // prostredni radka |
i2c_stop(); |
i2c_start(); // VEND |
i2c_write(CAMERA_ADR); |
i2c_write(0x1A); |
i2c_write(118); |
i2c_stop(); |
NightRider(1); // Musi se dat cas kamere na AGC a AEC |
{ // Mereni expozice |
int8 t1,t2; |
i2c_start(); // Brightness, zacni od uplne tmy |
i2c_write(CAMERA_ADR); |
i2c_write(0x06); |
i2c_write(0); // 80h default |
i2c_stop(); |
delay_ms(50); |
for(offset=0x04;offset<(255-0x04);offset+=0x04) // Zacni od jasu 10h |
{ |
i2c_start(); // Brightness |
i2c_write(CAMERA_ADR); |
i2c_write(0x06); |
i2c_write(offset); // 80h default |
i2c_stop(); |
disp(offset); |
delay_ms(50); |
t1=0; |
t2=0; |
while(!input(HREF)); // Cekej nez se zacnou posilat pixely z radky |
delay_ms(5); |
while(!input(HREF)); // Cekej nez se zacnou posilat pixely z radky |
set_timer0(0); // Vynuluj pocitadlo casu |
if(!input(PIX)) continue; |
while(input(PIX)); |
t1=get_timer0(); // Precti cas z citace casu hrany |
set_timer0(0); // Vynuluj pocitadlo casu |
while(!input(PIX)); |
t2=get_timer0(); |
if((t1>60) && (t1<140) && (t2>5) && (t2<=10)) break; // Vidis, co mas? |
delay_ms(2); // Preskoc druhou radku z kamery |
}; |
delay_ms(1000); // Nech chvili na displayi zmerenou hodnotu |
} |
set_adc_channel(CERVENA); // --- Kroutitko pro jas --- |
delay_ms(1); |
offset=read_adc(); |
offset &= 0b11111100; // Dva nejnizsi bity ignoruj |
// offset += 0x70; // Jas nebude nikdy nizsi |
disp(offset); |
i2c_start(); // Brightness |
i2c_write(CAMERA_adr); |
i2c_write(0x06); |
i2c_write(offset); // 80h default |
i2c_stop(); |
delay_ms(1000); // Nech hodnotu chvili na displayi |
set_adc_channel(ZELENA); // --- Kroutitko pro vykon motoru --- |
delay_ms(1); |
rr=read_adc()>>2; // 0-63 // Pokud by se zvetsil rozsah, tak zkontrolovat jakonasobeni! |
rr+=27; // 27-90 |
//!!! rr=read_adc()>>1; // 0-128 // Pokud by se zvetsil rozsah, tak zkontrolovat jakonasobeni! |
rrold=rr; |
cas=CASAVR-CASMIN; // Inicializace promenych, aby neslo servo za roh |
// a aby se to rozjelo jeste dneska |
stav=start; // Jsme na startu |
set_timer1(0); // Vynuluj citac odometrie |
log=0; // Zacatek logu v cerne skrince |
last_log_odo=0; // Posledni zaznam odometrie do logu |
ReadBlackBox(); // Vycteni zaznamu z Black Boxu |
odo_problem1=ODODO_PROBLEM1-BRZDNA_DRAHA; |
odo_problem2=ODODO_PROBLEM2-BRZDNA_DRAHA; |
odo_problem3=ODODO_PROBLEM3-BRZDNA_DRAHA; |
// ........................... Hlavni smycka ................................ |
while(true) |
{ |
int8 pom; |
int8 n; |
int8 gap; |
int16 ododo; |
gap=0; // Vynuluj pocitadlo preruseni |
next_snap: |
pom=0; |
disable_interrupts(GLOBAL); //----------------------- Critical Section |
while(input(HREF)); // Preskoc 1. radku |
while(!input(HREF)); // Cekej nez se zacnou posilat pixely z 2. radky |
set_timer0(0); // Vynuluj pocitadlo casu |
while(input(HREF)) // Po dobu vysilani radky cekej na hranu W/B |
{ |
// !!!!Dodelat rozpoznani cerne cary napric pro zastaveni ? |
if(!input(PIX)) // Pokud se X-krat za sebou precetla CERNA |
if(!input(PIX)) |
// if(!input(PIX)) |
{ |
pom=get_timer0(); // Precti cas z citace casu hrany |
break; |
}; |
}; |
while(input(HREF)); // Pockej na shozeni signalu HREF |
if((pom<CASMAX) && (pom>CASMIN)) cas=pom; // Orizni konce radku |
// Na konci obrazovaho radku to blbne. Jednak chyba od apertury |
// a vubec to nejak na kraji nefunguje. |
output_high(SERVO); // Odvysilani impuzu 1 az 2ms pro servo |
delay_us(1000); |
delay_us(stred); |
delay_us(stred); |
delay_us(stred); |
delay_us(cas); |
delay_us(cas); |
output_low(SERVO); |
// Elektronicky diferencial 1. cast |
if(cas<CASAVR) {r1=cas-CASMIN; r2=CASAVR-CASMIN;}; // Normovani vystupni hodnoty radkoveho snimace |
if(cas==CASAVR) {r1=cas-CASMIN; r2=cas-CASMIN;}; // pro rizeni rychlosti motoru |
if(cas>CASAVR) {r1=CASAVR-CASMIN; r2=CASMAX-cas;}; // Rozsah 1 az 92 |
enable_interrupts(GLOBAL); //----------------------- End Critical Section |
if(pom==0) // Kamera nevidi caru |
{ |
if((cas>(CASMIN+15))&&(cas<(CASMAX-15))) // Nebyla minule cara moc u kraje? |
{ |
gap++; |
if(gap>=3) // Trva preruseni cary alespon 2 snimky? |
{ |
cas=CASAVR-CASMIN; |
// disp(0xAA); |
} |
} |
} |
else |
{ |
gap=0; |
}; |
/* |
if(pom==0) // Kamera nevidi caru, poznamenej to do logu |
{ |
if((cas>(CASMIN+30))&&(cas<(CASMAX-30))) // Nebyla minule cara moc u kraje? |
if(last_log_odo<get_timer1()) // Aby nebyly zaznamy v logu prilis huste, musi se napred neco ujet od minuleho zaznamu |
{ |
gap++; |
} |
} |
else |
{ |
if(gap>=4) // Trva preruseni cary alespon 2 snimky? |
{ |
LogLog(gap,8); // Dalsi mereni nejdrive po ujeti 24 cm |
rr=rrold; // Preruseni cary skoncilo, znovu jed Rozumnou Rychlosti |
cas=CASAVR-CASMIN; |
disp(0xAA); |
} |
gap=0; |
}; |
if(!input(PROXIMITY) && ((stav==jizda)||(stav==cihla))) // Tunel |
{ |
if(last_log_odo<get_timer1()) // Aby nebyly zaznamy v logu prilis huste, musi se napred neco ujet od minuleho zaznamu |
{ |
LogLog(0xDD,16); // Priznak tunelu; dalsi mereni nejdrive po ujeti 48 cm |
rr=rrold; // Vjeli jsme do tunelu, znovu jed rychle |
} |
}; |
*/ |
//ODODO |
ododo=get_timer1(); |
if((ododo>odo_preruseni)&&(ododo<(odo_preruseni+8))) rr=RR_PRERUSENI; |
if((ododo>odo_cihla)&&(ododo<(odo_cihla+8))) rr=RR_PRERUSENI; |
if((ododo>odo_tunel)&&(ododo<(odo_tunel+8))) rr=RR_PRERUSENI; |
if((ododo>odo_problem1)&&(ododo<(odo_problem1+8))) rr=RR_PRERUSENI; |
if((ododo>odo_problem2)&&(ododo<(odo_problem2+8))) rr=RR_PRERUSENI; |
if((ododo>odo_problem3)&&(ododo<(odo_problem3+8))) rr=RR_PRERUSENI; |
// Elektronicky diferencial 2. cast |
if (r1>(CASAVR-CASMIN-rr)) r1=(r1<<1)+rr-(CASAVR-CASMIN); // Neco jako nasobeni |
if (r2>(CASAVR-CASMIN-rr)) r2=(r2<<1)+rr-(CASAVR-CASMIN); // rozsah 1 az 92 pro rr=0 // rozsah 1 az 154 pro rr=63 |
//!!! pro zatuhle prevodovky |
// r1<<=1; // Rychlost je dvojnasobna |
// r2<<=1; // Rozsah 2 az 184 pro rr=0 |
if ((stav==jizda)||(stav==cihla)||(stav==rozjezd)) //||(stav==pocihle)) // Jizda |
{ |
set_pwm1_duty(r1); |
set_pwm2_duty(r2); |
} |
else |
{ |
set_pwm1_duty(0); // Zastaveni |
set_pwm2_duty(0); |
}; |
if((stav==rozjezd)&&(get_timer1()>10)) // musi ujet alespon 31cm |
{ |
ext_int_edge(H_TO_L); // Nastav podminky preruseni od cihly |
INT0IF=0; // Zruseni predesle udalosti od startera |
enable_interrupts(INT_EXT); |
enable_interrupts(GLOBAL); |
stav=jizda; |
}; |
if(stav==start) // Snimkuje, toci servem a ceka na start |
{ |
set_adc_channel(MODRA); // Kroutitko na vystredeni predniho kolecka |
Delay_ms(1); |
stred=read_adc(); |
if(!input(PROXIMITY)) |
{ |
disp(0x80); |
while(input(PROXIMITY)); // Cekej, dokud starter neda ruku pryc |
set_timer1(0); // Vynuluj citac odometrie |
set_pwm1_duty(255); // Rychly rozjezd !!! Zkontrolovat na oscyloskopu |
set_pwm2_duty(255); |
disp(0x01); |
while(get_timer1()<=4) // Ujed alespon 12cm |
{ |
set_adc_channel(LMAX); // Levy UV sensor |
delay_us(40); |
if(read_adc()<THR) {cas=CASMIN; break;}; // Prejeli jsme caru vlevo |
set_adc_channel(RMAX); // Pravy UV sensor |
delay_us(40); |
if(read_adc()<THR) {cas=CASMAX; break;}; // Prejeli jsme caru vpravo |
cas=CASAVR-CASMIN; // Cara je rovne |
}; |
stav=rozjezd; |
}; |
} |
pom=0x80; // Zobrazeni pozice cary na displayi |
for(n=CASMAX/8; n<cas; n+=CASMAX/8) pom>>=1; |
disp(pom); |
while(true) // Ve zbytku casu snimku cti krajni UV senzory a naraznik |
{ |
if(BUMPER) // Sakra, do neceho jsme narazili a nevideli jsme to! |
{ |
bum(); |
SaveLog(); // Zapis Black Boxu do EEPROM |
delay_ms(TUHOS); //!!! Zatuhle prevodovky |
set_pwm1_duty(200); // pomalu vpred |
set_pwm2_duty(200); |
output_low(MOT_L); |
output_low(MOT_R); |
cas=CASAVR-CASMIN; |
}; |
set_adc_channel(LMAX); // Levy UV sensor |
for(n=0;n<20;n++) if(input(HREF)) goto next_snap; |
if(read_adc()<THR) cas=CASMIN; |
set_adc_channel(RMAX); // Pravy UV sensor |
for(n=0;n<20;n++) if(input(HREF)) goto next_snap; |
if(read_adc()<THR) cas=CASMAX; |
}; |
} |
} |
Property changes: |
Added: svn:keywords |
+Id Rev |
\ No newline at end of property |
/roboti/istrobot/camerus/SW/876/jiny_zapis_do_eeprom/camerus.c |
---|
0,0 → 1,634 |
//********* Robot Camerus pro IstRobot 2007 ************ |
//"$Id: camerus.c 253 2007-04-24 09:26:46Z kakl $" |
//***************************************************** |
#include ".\camerus.h" |
#USE FAST_IO (C) // Brana C je ve FAST_IO modu, aby slo rychle cist z kamery |
// Rychlostni konstanty |
#define RR_CIHLA 50 // Rozumna rychlost pro objizdeni cihly |
#define RR_PRERUSENI 50 // Rozumna rychlost pro priblizeni se k preruseni |
#define BRZDNA_DRAHA 0x20 // Jak daleko pred problemem se zacne brzdit |
#define TUHOS 100 // Jak dlouho se bude couvat po narazu na naraznik |
#define ODODO_CIHLA 0xFFF |
#define ODODO_TUNEL 0xFFF |
#define ODODO_PRERUSENI 0xFFF |
// Adresy IIC periferii |
#define COMPAS_ADR 0xC0 |
#define CAMERA_ADR 0xDC |
#define SONAR_ADR 0xE0 |
// A/D vstupy |
#define RMAX 4 // AN4/RA5 - leve cidlo na vyjeti z cary |
#define LMAX 3 // AN3/RA3 - prave cidlo na vyjeti z cary |
#define CERVENA 2 // AN2/RA2 - cervene kroutitko |
#define ZELENA 1 // AN1/RA0 - zelene kroutitko |
#define MODRA 0 // AN0/RA1 - modre kroutitko |
// I/O |
#define HREF PIN_C5 // Signal HREF z kamery (v H po celou dobu radku) |
#define PIX PIN_C6 // Vstup pro body z kamery (za trivstupim hradlem OR (dig. komparator)) |
#define SERVO PIN_B4 // Vystup na servo (1 az 2ms po cca 20ms (synchronizovano snimkovym kmitoctem)) |
#define MOT_L PIN_B5 // Smer otaceni leveho motoru; druhy pol je RC2 |
#define MOT_R PIN_B6 // Smer otaceni praveho motoru; druhy pol je RC1 |
#define MOT_1 PIN_C1 // PWM vystpy motoru |
#define MOT_2 PIN_C2 // |
#define DATA PIN_B2 // K modulu LEDbar data |
#define CP PIN_B1 // K modulu LEDbar hodiny |
//#define ODO PIN_C0 // Ze snimace z odometrie z praveho kola na TIMER1 |
// Jeden impuls je 31,25mm |
#define IRRX !input(PIN_B0) // Vstup INT, generuje preruseni pri prekazce |
#define IRTX PIN_B3 // Modulovani vysilaci IR LED na detekci prekazky |
#define PROXIMITY PIN_C7 // Cidlo kratkeho dosahu na cihlu |
#define BUMPER !input(PIN_A4) // Naraznik |
#define CASMIN 6 // Rozsah radku snimace |
#define CASMAX 192 |
#define CASAVR ((CASMAX+CASMIN) / 2) |
#define EEMAX 255 // Konec EEPROM |
#define MAXLOG 0x10 // Maximalni pocet zaznamu v logu |
#if MAXLOG>(EEMAX/3) |
#error Prekrocena velikost EEPROM |
#endif |
#define OFFSETO 0x9F //0x9F // Vystredeni serva pro objeti prekazky |
#define THR 90 // Threshold pro UV cidla na caru |
#byte INTCON = 0x0B // Interrupt configuration register |
#bit GIE = INTCON.7 |
#bit PEIE = INTCON.6 |
#bit TMR0IE = INTCON.5 |
#bit INT0IE = INTCON.4 |
#bit RBIE = INTCON.3 |
#bit TMR0IF = INTCON.2 |
#bit INT0IF = INTCON.1 |
#bit RBIF = INTCON.0 |
enum stavy {start,rozjezd,jizda,cihla,pocihle,cil}; |
stavy stav; // Kde jsme na trati |
int8 cas; // Cas hrany bila/cerna v radce |
int8 stred; // Vystredeni kolecka |
int16 odocounter; // Zaznamenani aktualniho stavu pocitadla odometrie |
int16 last_log_odo; // Posledni stav odometrie poznamenany do logu |
int16 last_log; // Cislo posledniho zaznamu v logu v EEPROM |
int8 bb_h[MAXLOG]; // Cerna skrinka MSB |
int8 bb_l[MAXLOG]; // Cerna skrinka LSB |
int8 bb_f[MAXLOG]; // Cerna skrinka priznak (typ zaznamu) |
int8 log; // Pocitadlo pro cernou skrinku |
int8 rr; // Promenna na ulozeni Rozumne rychlost |
int8 rrold; |
int16 odo_preruseni, odo_cihla, odo_tunel; // Problemy na trati |
// Zobrazeni jednoho byte na modulu LEDbar |
inline void disp(int8 x) |
{ |
int n; |
for(n=0;n<=7;n++) |
{ |
if (bit_test(x,0)) output_low(DATA); else output_high(DATA); |
output_high(CP); |
x>>=1; |
output_low(CP); |
} |
} |
// Blikani LEDbarem ve stilu Night Rider |
void NightRider(int8 x) |
{ |
int n,i,j; |
for(j=0;j<x;j++) |
{ |
i=0x01; |
for(n=0;n<7;n++) |
{ |
disp(i); |
rotate_left(&i, 1); |
delay_ms(40); |
} |
for(n=0;n<7;n++) |
{ |
disp(i); |
rotate_right(&i, 1); |
delay_ms(40); |
} |
} |
disp(i); |
delay_ms(40); |
i=0; |
disp(i); |
} |
// Zaznam LOGu do EEPROM |
void SaveLog() |
{ |
int8 n,i,xlog; |
i=0; |
for(n=0;n<=(log*3);n+=3) // Ulozeni Black Boxu do EEPROM |
{ |
write_eeprom(n,bb_f[i]); |
write_eeprom(n+1,bb_h[i]); |
write_eeprom(n+2,bb_l[i]); |
i++; |
}; |
if(log>0) {xlog=log-1;} else {xlog=0;}; |
write_eeprom(EEMAX,xlog); // Zapis poctu zaznamu na konec EEPROM |
} |
// Zaznam do Logu do RAM |
void LogLog(int8 reason, int16 log_delay) |
{ |
int16 timer_pom; |
timer_pom=get_timer1(); // Timer se musi vycist atomicky |
bb_l[log]=make8(timer_pom,0); // Zaznam |
bb_h[log]=make8(timer_pom,1); |
bb_f[log]=reason; // Typ zaznamu |
if(log<(MAXLOG-1)) log++; // Ukazatel na dalsi zaznam |
last_log_odo=timer_pom+log_delay; // Dalsi mereni nejdrive po ujeti def. vzdalenosti |
rr=rrold; // Problem skoncil, znovu jed Rozumnou Rychlosti |
} |
void ReadBlackBox() |
{ |
last_log=read_eeprom(EEMAX); // Kolik zaznamu mame od minule poznamenano? |
{ |
int8 n,i; |
i=0; |
for(n=0;n<=last_log;n++) |
{ |
if(read_eeprom(i)==0) odo_tunel=MAKE16(read_eeprom(i+2),read_eeprom(i+1)); |
if(read_eeprom(i)==0xFF) odo_cihla=MAKE16(read_eeprom(i+2),read_eeprom(i+1)); |
if((read_eeprom(i)>0) && (read_eeprom(i)<0xFF)) odo_preruseni=MAKE16(read_eeprom(i+2),read_eeprom(i+1)); |
} |
} |
} |
// Brzdeni motorama stridou 1:1 |
void brzda() |
{ |
int8 n,i; |
set_pwm1_duty(0); // vypni PWM |
set_pwm2_duty(0); |
setup_ccp1(CCP_OFF); |
setup_ccp2(CCP_OFF); |
for (n=0;n<200;n++) |
{ |
output_low(MOT_L); |
output_low(MOT_R); |
output_high(MOT_1); |
output_high(MOT_2); |
delay_us(200); |
output_high(MOT_L); |
output_high(MOT_R); |
output_low(MOT_1); |
output_low(MOT_2); |
delay_us(200); |
} |
output_low(MOT_L); // smer vpred |
output_low(MOT_R); |
setup_ccp1(CCP_PWM); // RC1 // Zapni PWM pro motory |
setup_ccp2(CCP_PWM); // RC2 |
} |
void SetServo(int8 angle) |
{ |
int8 n; |
for(n=0; n<10; n++) |
{ |
output_high(SERVO); // Odvysilani impuzu 1 az 2ms pro servo |
delay_us(1000); |
delay_us(stred); |
delay_us(stred); |
delay_us(stred); |
delay_us(angle); |
delay_us(angle); |
output_low(SERVO); |
delay_ms(18); |
} |
} |
inline void SetServoQ(int8 angle) |
{ |
output_high(SERVO); // Odvysilani impuzu 1 az 2ms pro servo |
delay_us(1000); |
delay_us(stred); |
delay_us(stred); |
delay_us(stred); |
delay_us(angle); |
delay_us(angle); |
output_low(SERVO); |
} |
// Couvni po narazu na naraznik |
inline void bum() |
{ |
set_pwm1_duty(0); // couvni, rovne dozadu |
set_pwm2_duty(0); |
output_high(MOT_L); |
output_high(MOT_R); |
disp(0xA5); |
SetServo(CASAVR-CASMIN); |
} |
#include ".\diag.c" |
//---------------------------- INT -------------------------------- |
#int_EXT |
EXT_isr() // Preruseni od prekazky |
{ |
unsigned int8 bearing, bearing_offset, delta_bearing; |
set_pwm1_duty(0); // zabrzdi levym kolem, prave vypni |
set_pwm2_duty(0); |
output_high(MOT_L); |
output_low(MOT_R); |
// Ujistime se, ze prijaty signal je z naseho IR vysilace |
output_high(IRTX); // Vypni LED na detekci prekazky |
delay_ms(2); |
if (IRRX) // stale nas signal? |
{ |
output_low(MOT_L); // je odraz -> vpred |
output_low(MOT_R); |
return; |
}; |
output_low(IRTX); // Zapni LED na detekci prekazky |
i2c_start(); // Cteni kompasu |
i2c_write(COMPAS_ADR); |
i2c_write(0x1); // 0-255 (odpovida 0-359) |
i2c_stop(); |
i2c_start(); |
i2c_write(COMPAS_ADR+1); |
bearing_offset=i2c_read(0); // Poznamenej hodnotu pred cihlou |
i2c_stop(); |
delay_ms(9); |
if (!IRRX) // stale nas signal? |
{ |
output_low(MOT_L); // neni odraz -> vpred |
output_low(MOT_R); |
return; |
}; |
rr=rrold; // Po cihle se pojede opet Rozumnou Rychlosti |
if(stav!=cihla) |
{ |
LogLog(0xFF,3); // Cihla |
}; |
//!!! if(stav==cihla) while(true); // Zastav na furt, konec drahy |
// if(stav==cihla) return; // Po druhe nic neobjizdej |
// Pozor na rozjezd |
if((stav==jizda)||(stav==cihla)) // Objed cihlu |
{ |
#include ".\objizdka_L.c" |
}; |
last_log_odo=get_timer1()+16; // Pul metru po cihle nezaznamenavej do LOGu |
} |
//---------------------------------- MAIN -------------------------------------- |
void main() |
{ |
int8 offset; // Promena pro ulozeni offsetu |
int8 r1; // Rychlost motoru 1 |
int8 r2; // Rychlost motoru 2 |
setup_adc_ports(ALL_ANALOG); // Zapnuti A/D prevodniku pro cteni kroutitek |
setup_adc(ADC_CLOCK_INTERNAL); |
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); // Casovac pro mereni casu hrany W/B v radce |
setup_timer_1(T1_EXTERNAL); // Cita pulzy z odometrie z praveho kola |
setup_timer_2(T2_DIV_BY_16,255,1); // Casovac PWM motoru |
//!!! setup_timer_2(T2_DIV_BY_4,255,1); // Casovac PWM motoru |
setup_ccp1(CCP_PWM); // RC1 // PWM pro motory |
setup_ccp2(CCP_PWM); // RC2 |
setup_comparator(NC_NC_NC_NC); |
setup_vref(FALSE); |
set_tris_c(0b11111001); // Nastaveni vstup/vystup pro branu C, protoze se to nedela automaticky |
set_pwm1_duty(0); // Zastav motory |
set_pwm2_duty(0); |
output_low(MOT_L); // Nastav smer vpred |
output_low(MOT_R); |
disp(0); // Zhasni LEDbar |
if(BUMPER) // Kdyz nekdo na zacatku drzi naraznik, vymaz log a spust diagnostiku |
{ |
diag(); |
} |
output_low(IRTX); // Zapni LED na detekci prekazky |
NightRider(1); // Zablikej, aby se poznalo, ze byl RESET |
// Zaroven se musi pockat, nez se rozjede kamera, nez se do ni zacnou posilat prikazy |
//... Nastaveni sonaru ... |
i2c_start(); |
i2c_write(SONAR_ADR); |
i2c_write(0x02); // dosah |
i2c_write(0x03); // n*43mm |
i2c_stop(); |
i2c_start(); |
i2c_write(SONAR_ADR); |
i2c_write(0x01); // zesileni |
i2c_write(0x01); // male, pro eliminaci echa z minuleho mereni |
i2c_stop(); |
//... Nastaveni kamery ... |
i2c_start(); // Soft RESET kamery |
i2c_write(CAMERA_ADR); // Adresa kamery |
i2c_write(0x12); // Adresa registru COMH |
i2c_write(0x80 | 0x24); // Zapis ridiciho slova |
i2c_stop(); |
i2c_start(); // BW |
i2c_write(CAMERA_ADR); |
i2c_write(0x28); |
i2c_write(0b01000001); |
i2c_stop(); |
/* |
i2c_start(); // Contrast (nema podstatny vliv na obraz) |
i2c_write(CAMERA_ADR); |
i2c_write(0x05); |
i2c_write(0xA0); // 48h |
i2c_stop(); |
i2c_start(); // Band Filter (pokud by byl problem se zarivkama 50Hz) |
i2c_write(CAMERA_ADR); |
i2c_write(0x2D); |
i2c_write(0x04 | 0x03); |
i2c_stop(); |
*/ |
i2c_start(); // Fame Rate |
i2c_write(CAMERA_ADR); |
i2c_write(0x2B); |
i2c_write(0x00); // cca 17ms (puvodni hodnota 5Eh = 20ms) |
i2c_stop(); |
i2c_start(); // VSTRT |
i2c_write(CAMERA_ADR); |
i2c_write(0x19); |
i2c_write(118); // prostredni radka |
i2c_stop(); |
i2c_start(); // VEND |
i2c_write(CAMERA_ADR); |
i2c_write(0x1A); |
i2c_write(118); |
i2c_stop(); |
NightRider(1); // Musi se dat cas kamere na AGC a AEC |
{ // Mereni expozice |
int8 t1,t2; |
i2c_start(); // Brightness, zacni od uplne tmy |
i2c_write(CAMERA_ADR); |
i2c_write(0x06); |
i2c_write(0); // 80h default |
i2c_stop(); |
delay_ms(50); |
for(offset=0x04;offset<(255-0x04);offset+=0x04) // Zacni od jasu 10h |
{ |
i2c_start(); // Brightness |
i2c_write(CAMERA_ADR); |
i2c_write(0x06); |
i2c_write(offset); // 80h default |
i2c_stop(); |
disp(offset); |
delay_ms(50); |
t1=0; |
t2=0; |
while(!input(HREF)); // Cekej nez se zacnou posilat pixely z radky |
delay_ms(5); |
while(!input(HREF)); // Cekej nez se zacnou posilat pixely z radky |
set_timer0(0); // Vynuluj pocitadlo casu |
if(!input(PIX)) continue; |
while(input(PIX)); |
t1=get_timer0(); // Precti cas z citace casu hrany |
set_timer0(0); // Vynuluj pocitadlo casu |
while(!input(PIX)); |
t2=get_timer0(); |
if((t1>60) && (t1<140) && (t2>5) && (t2<=10)) break; // Vidis, co mas? |
delay_ms(2); // Preskoc druhou radku z kamery |
}; |
delay_ms(1000); // Nech chvili na displayi zmerenou hodnotu |
} |
set_adc_channel(CERVENA); // --- Kroutitko pro jas --- |
delay_ms(1); |
offset=read_adc(); |
offset &= 0b11111100; // Dva nejnizsi bity ignoruj |
// offset += 0x70; // Jas nebude nikdy nizsi |
disp(offset); |
i2c_start(); // Brightness |
i2c_write(CAMERA_adr); |
i2c_write(0x06); |
i2c_write(offset); // 80h default |
i2c_stop(); |
delay_ms(1000); // Nech hodnotu chvili na displayi |
set_adc_channel(ZELENA); // --- Kroutitko pro vykon motoru --- |
delay_ms(1); |
rr=read_adc()>>2; // 0-63 // Pokud by se zvetsil rozsah, tak zkontrolovat jakonasobeni! |
rr+=27; // 27-90 |
//!!! rr=read_adc()>>1; // 0-128 // Pokud by se zvetsil rozsah, tak zkontrolovat jakonasobeni! |
rrold=rr; |
cas=CASAVR-CASMIN; // Inicializace promenych, aby neslo servo za roh |
// a aby se to rozjelo jeste dneska |
stav=start; // Jsme na startu |
set_timer1(0); // Vynuluj citac odometrie |
log=0; // Zacatek logu v cerne skrince |
last_log_odo=0; // Posledni zaznam odometrie do logu |
// ReadBlackBox(); // Vycteni zaznamu z Black Boxu |
odo_cihla=ODODO_CIHLA-BRZDNA_DRAHA; |
odo_tunel=ODODO_TUNEL-BRZDNA_DRAHA; |
odo_preruseni=ODODO_PRERUSENI-BRZDNA_DRAHA; |
// ........................... Hlavni smycka ................................ |
while(true) |
{ |
int8 pom; |
int8 n; |
int8 gap; |
int16 ododo; |
gap=0; // Vynuluj pocitadlo preruseni |
next_snap: |
pom=0; |
disable_interrupts(GLOBAL); //----------------------- Critical Section |
while(input(HREF)); // Preskoc 1. radku |
while(!input(HREF)); // Cekej nez se zacnou posilat pixely z 2. radky |
set_timer0(0); // Vynuluj pocitadlo casu |
while(input(HREF)) // Po dobu vysilani radky cekej na hranu W/B |
{ |
// !!!!Dodelat rozpoznani cerne cary napric pro zastaveni ? |
if(!input(PIX)) // Pokud se X-krat za sebou precetla CERNA |
if(!input(PIX)) |
// if(!input(PIX)) |
{ |
pom=get_timer0(); // Precti cas z citace casu hrany |
break; |
}; |
}; |
while(input(HREF)); // Pockej na shozeni signalu HREF |
if((pom<CASMAX) && (pom>CASMIN)) cas=pom; // Orizni konce radku |
// Na konci obrazovaho radku to blbne. Jednak chyba od apertury |
// a vubec to nejak na kraji nefunguje. |
output_high(SERVO); // Odvysilani impuzu 1 az 2ms pro servo |
delay_us(1000); |
delay_us(stred); |
delay_us(stred); |
delay_us(stred); |
delay_us(cas); |
delay_us(cas); |
output_low(SERVO); |
// Elektronicky diferencial 1. cast |
if(cas<CASAVR) {r1=cas-CASMIN; r2=CASAVR-CASMIN;}; // Normovani vystupni hodnoty radkoveho snimace |
if(cas==CASAVR) {r1=cas-CASMIN; r2=cas-CASMIN;}; // pro rizeni rychlosti motoru |
if(cas>CASAVR) {r1=CASAVR-CASMIN; r2=CASMAX-cas;}; // Rozsah 1 az 92 |
enable_interrupts(GLOBAL); //----------------------- End Critical Section |
if(pom==0) // Kamera nevidi caru, poznamenej to do logu |
{ |
if((cas>(CASMIN+30))&&(cas<(CASMAX-30))) // Nebyla minule cara moc u kraje? |
if(last_log_odo<get_timer1()) // Aby nebyly zaznamy v logu prilis huste, musi se napred neco ujet od minuleho zaznamu |
{ |
gap++; |
} |
} |
else |
{ |
if(gap>=2) // Trva preruseni cary alespon 2 snimky? |
{ |
LogLog(gap,8); // Dalsi mereni nejdrive po ujeti 24 cm |
rr=rrold; // Preruseni cary skoncilo, znovu jed Rozumnou Rychlosti |
} |
gap=0; |
}; |
if(!input(PROXIMITY) && ((stav==jizda)||(stav==cihla))) // Tunel |
{ |
if(last_log_odo<get_timer1()) // Aby nebyly zaznamy v logu prilis huste, musi se napred neco ujet od minuleho zaznamu |
{ |
LogLog(0xDD,16); // Priznak tunelu; dalsi mereni nejdrive po ujeti 48 cm |
rr=rrold; // Vjeli jsme do tunelu, znovu jed rychle |
} |
}; |
//ODODO |
ododo=get_timer1(); |
if((ododo>odo_preruseni)&&(ododo<(odo_preruseni+8))) rr=RR_PRERUSENI; |
if((ododo>odo_cihla)&&(ododo<(odo_cihla+8))) rr=RR_PRERUSENI; |
if((ododo>odo_tunel)&&(ododo<(odo_tunel+8))) rr=RR_PRERUSENI; |
// Elektronicky diferencial 2. cast |
if (r1>(CASAVR-CASMIN-rr)) r1=(r1<<1)+rr-(CASAVR-CASMIN); // Neco jako nasobeni |
if (r2>(CASAVR-CASMIN-rr)) r2=(r2<<1)+rr-(CASAVR-CASMIN); // rozsah 1 az 92 pro rr=0 // rozsah 1 az 154 pro rr=63 |
//!!! pro zatuhle prevodovky |
// r1<<=1; // Rychlost je dvojnasobna |
// r2<<=1; // Rozsah 2 az 184 pro rr=0 |
if ((stav==jizda)||(stav==cihla)||(stav==rozjezd)) //||(stav==pocihle)) // Jizda |
{ |
set_pwm1_duty(r1); |
set_pwm2_duty(r2); |
} |
else |
{ |
set_pwm1_duty(0); // Zastaveni |
set_pwm2_duty(0); |
}; |
if((stav==rozjezd)&&(get_timer1()>10)) // musi ujet alespon 31cm |
{ |
ext_int_edge(H_TO_L); // Nastav podminky preruseni od cihly |
INT0IF=0; // Zruseni predesle udalosti od startera |
enable_interrupts(INT_EXT); |
enable_interrupts(GLOBAL); |
stav=jizda; |
}; |
if(stav==start) // Snimkuje, toci servem a ceka na start |
{ |
set_adc_channel(MODRA); // Kroutitko na vystredeni predniho kolecka |
Delay_ms(1); |
stred=read_adc(); |
if(!input(PROXIMITY)) |
{ |
disp(0x80); |
while(input(PROXIMITY)); // Cekej, dokud starter neda ruku pryc |
set_timer1(0); // Vynuluj citac odometrie |
set_pwm1_duty(255); // Rychly rozjezd !!! Zkontrolovat na oscyloskopu |
set_pwm2_duty(255); |
disp(0x01); |
while(get_timer1()<=4) // Ujed alespon 12cm |
{ |
set_adc_channel(LMAX); // Levy UV sensor |
delay_us(40); |
if(read_adc()<THR) {cas=CASMIN; break;}; // Prejeli jsme caru vlevo |
set_adc_channel(RMAX); // Pravy UV sensor |
delay_us(40); |
if(read_adc()<THR) {cas=CASMAX; break;}; // Prejeli jsme caru vpravo |
cas=CASAVR-CASMIN; // Cara je rovne |
}; |
stav=rozjezd; |
}; |
} |
pom=0x80; // Zobrazeni pozice cary na displayi |
for(n=CASMAX/8; n<cas; n+=CASMAX/8) pom>>=1; |
disp(pom); |
while(true) // Ve zbytku casu snimku cti krajni UV senzory a naraznik |
{ |
if(BUMPER) // Sakra, do neceho jsme narazili a nevideli jsme to! |
{ |
bum(); |
SaveLog(); // Zapis Black Boxu do EEPROM |
delay_ms(TUHOS); //!!! Zatuhle prevodovky |
set_pwm1_duty(200); // pomalu vpred |
set_pwm2_duty(200); |
output_low(MOT_L); |
output_low(MOT_R); |
cas=CASAVR-CASMIN; |
}; |
set_adc_channel(LMAX); // Levy UV sensor |
for(n=0;n<20;n++) if(input(HREF)) goto next_snap; |
if(read_adc()<THR) cas=CASMIN; |
set_adc_channel(RMAX); // Pravy UV sensor |
for(n=0;n<20;n++) if(input(HREF)) goto next_snap; |
if(read_adc()<THR) cas=CASMAX; |
}; |
} |
} |
/roboti/istrobot/camerus/SW/876/jiny_zapis_do_eeprom/diag.c |
---|
0,0 → 1,68 |
//--- Diagnostika cidel a vymazani EEPROM --- |
void diag() |
{ |
int8 n; |
// Vymaz Black Box v EEPROM |
for(n=0;n<255;n++) write_eeprom(n,0); |
bb_l[0]=0; // Zapis na pozici 0 vzdalenost 0 |
bb_h[0]=0; |
bb_f[0]=0; |
write_eeprom(EEMAX,0); // Zapis do EEPROM pocet zaznamu 0, tedy jeden zaznam |
for(n=0;n<=4;n++) |
{ |
disp(0x55); // Blikni pro potvrzeni |
delay_ms(200); |
disp(0xAA); |
delay_ms(200); |
}; |
while(true) |
{ |
if(!IRRX) |
{ |
int8 ble; |
i2c_start(); // Cteni kompasu |
i2c_write(COMPAS_ADR); |
i2c_write(0x1); |
i2c_stop(); |
i2c_start(); |
i2c_write(COMPAS_ADR+1); |
ble=i2c_read(0); |
i2c_stop(); |
disp(ble); |
delay_ms(200); |
} |
else |
{ |
i2c_start(); // Diagnostika sonaru |
i2c_write(SONAR_ADR); |
i2c_write(0x02); // dosah |
i2c_write(0x03); // n*43mm |
i2c_stop(); |
i2c_start(); |
i2c_write(SONAR_ADR); |
i2c_write(0x01); // zesileni |
i2c_write(0x01); // male, pro eliminaci echa z minuleho mereni |
i2c_stop(); |
i2c_start(); // Sonar Ping |
i2c_write(0xE0); |
i2c_write(0x0); |
i2c_write(0x51); // 50 mereni v palcich, 51 mereni v cm, 52 v us |
i2c_stop(); |
delay_ms(100); |
i2c_start(); // Odraz ze sonaru |
i2c_write(0xE0); |
i2c_write(0x3); |
i2c_stop(); |
i2c_start(); |
i2c_write(0xE1); |
n=i2c_read(0); |
i2c_stop(); |
disp(n); // Zobrazeni hodnoty ze sonaru a zaroven diagnostika predniho IR cidla |
delay_ms(200); |
} |
} |
} |
/roboti/istrobot/camerus/SW/876/jiny_zapis_do_eeprom/objizdka_L.c |
---|
0,0 → 1,183 |
// **** Objeti cihly vlevo **** LLLL |
#define L_TOUCH 1 // Cara vlevo |
#define R_TOUCH 2 // Cata vpravo |
#define B_TOUCH 3 // Both |
int8 n; |
int8 r1,r2,rr; |
int8 touch; |
enum okolo_cihly {pred_carou,na_care,po_care}; |
okolo_cihly ridic; // V jakem jsme stavu objizdeni cihly |
int8 vzdalenost; |
int8 visualisation; |
stav=cihla; // Dalsi prekazku uz nezaznamenavej (je to s velkou pravdepodobnosti cil) |
odocounter=get_timer1(); |
cihla: |
rr=RR_CIHLA; //!!! Rozumna rychlost pro objizdeni cihly (bylo by lepsi rychlost zvysovat) a pri detekci pohybu zase snizit |
disp(0x99); |
set_pwm1_duty(0); // zabrzdi levym kolem, prave vpred |
set_pwm2_duty(255); |
output_high(MOT_L); |
output_low(MOT_R); |
while(true) // Na zacatku se vyhni cihle, zatoc co muzes |
{ |
cas=CASMIN-5; // jeste vic nez hodne do leva |
if(BUMPER) // Narazili jsme do cihly, musime couvnout! |
{ |
bum(); |
SaveLog(); // Zapis Black Boxu do EEPROM |
delay_ms(TUHOS); //!!! Zatuhle prevodovky |
brzda(); |
goto cihla; // Znovu zacni cihlu objizdet |
}; |
set_pwm1_duty(0); |
set_pwm2_duty(200); // !!! mozna prilis maly vykon pro rozjezd pro zatuhlou prevodovku |
output_high(MOT_L); // leve kolo reverz |
output_low(MOT_R); // prave kolo vpred |
if(get_timer1()>(odocounter+5)) // konec zatacky? |
{ |
disp(0x66); |
break; |
} |
SetServoQ(cas); |
delay_ms(18); |
}; |
//------ Objeti cihly v konstantni vzdalenosti ------ |
touch=0; // Indikator detekce cary pri objizdeni |
ridic=pred_carou; |
cas=CASAVR-CASMIN; // rovne |
output_low(MOT_L); // vpred |
output_low(MOT_R); |
visualisation=0; |
while(true) |
{ |
if(BUMPER) // Narazili jsme do cihly, musime couvnout! |
{ |
bum(); |
SaveLog(); // Zapis Black Boxu do EEPROM |
delay_ms(TUHOS); //!!! Zatuhle prevodovky |
set_pwm1_duty(160); // vpred |
set_pwm2_duty(160); |
output_low(MOT_L); |
output_low(MOT_R); |
cas=CASMIN; |
}; |
delta_bearing=bearing-bearing_offset; |
visualisation=(delta_bearing & 0xF0) | (visualisation & 0x0F); |
if(IRRX) // hrozi celni srazka s cihlou v prubehu objizdeni |
{ |
cas=CASMIN; |
} |
else |
{ |
if((vzdalenost!=0)||!input(PROXIMITY)||((delta_bearing>60)&&(delta_bearing<128))) // Udrzovani konstantni vzdalenosti od cihly |
{ |
if(cas>(CASMIN+30)) cas-=30; |
} |
else |
{ |
if(cas<(CASMAX-30)) cas+=30; |
}; |
}; |
// Elektronicky diferencial |
if(cas<CASAVR) {r1=cas-CASMIN; r2=CASAVR-CASMIN;}; // Normovani vystupni hodnoty radkoveho snimace |
if(cas==CASAVR) {r1=cas-CASMIN; r2=cas-CASMIN;}; // pro rizeni rychlosti motoru |
if(cas>CASAVR) {r1=CASAVR-CASMIN; r2=CASMAX-cas;}; // Rozsah 1 az 92 |
if (r1>(CASAVR-CASMIN-rr)) r1=(r1<<1)+rr-(CASAVR-CASMIN); // Neco jako nasobeni |
if (r2>(CASAVR-CASMIN-rr)) r2=(r2<<1)+rr-(CASAVR-CASMIN); |
//!!! pro zatuhle prevodovky |
// r1<<=1; // Rychlost je dvojnasobna |
// r2<<=1; // Rozsah 2 az 184 pro rr=0 |
set_pwm1_duty(r1); // Nastav rychlost motoru |
set_pwm2_duty(r2); |
SetServoQ(cas); |
i2c_start(); // Sonar Ping |
i2c_write(SONAR_ADR); |
i2c_write(0x0); |
i2c_write(0x52); // mereni v us |
i2c_stop(); |
for(n=1;n<=90;n++) // 18ms testovani cary do dalsi korekce serva |
{ |
set_adc_channel(LMAX); |
delay_us(100); |
if(read_adc()<THR) touch|=L_TOUCH; |
set_adc_channel(RMAX); |
delay_us(100); |
if(read_adc()<THR) touch|=R_TOUCH; |
}; |
i2c_start(); // Odraz ze sonaru |
i2c_write(SONAR_ADR); |
i2c_write(0x3); |
i2c_stop(); |
i2c_start(); |
i2c_write(SONAR_ADR+1); |
vzdalenost=i2c_read(0); |
i2c_stop(); |
i2c_start(); // Cteni kompasu |
i2c_write(COMPAS_ADR); |
i2c_write(0x1); // uhel 0-255 |
i2c_stop(); |
i2c_start(); |
i2c_write(COMPAS_ADR+1); |
bearing=i2c_read(0); |
i2c_stop(); |
if(touch==L_TOUCH) visualisation|=0x2; |
if(touch==R_TOUCH) visualisation|=0x1; |
if((touch==B_TOUCH)&&(ridic==pred_carou)) ridic=na_care; |
if((ridic==na_care)&&(touch==0)) break; |
if(ridic==na_care) touch=0; |
disp(visualisation); |
}; |
disp(0xC3); |
set_pwm1_duty(0); //!!! pred zatuhlejma prevodovkama tam bylo 20 a 200 |
set_pwm2_duty(240); |
output_high(MOT_L); |
output_low(MOT_R); |
delay_us(40); |
odocounter=get_timer1(); // Poznamenej aktualni stav odometrie |
while (true) // Znovu se musime dotknout cary |
{ |
for(n=1;n<=90;n++) // 18ms testovani cary do dalsi korekce serva |
{ |
set_adc_channel(LMAX); // Levy UV sensor |
delay_us(100); |
if(read_adc()<THR) // Dotkli jsme se levym senzorem |
{ |
disp(0xE0); |
cas=CASAVR-CASMIN; // nastavime, ze cara je rovne |
goto cara; |
}; |
set_adc_channel(RMAX); // Pravy UV sensor |
delay_us(100); |
if((get_timer1()>=(odocounter+2)) && (read_adc()<THR)) // Pravym senzorem nesmime caru prejet! |
{ |
disp(0x07); |
cas=CASMAX; // kdyz prejedem, tak nastavime, ze cara je vpravo |
goto cara; |
}; |
} |
SetServoQ(CASMIN-5); // max. max. doleva L |
} |
cara: |
output_low(MOT_L); // oba motory vpred |
output_low(MOT_R); |
/roboti/istrobot/camerus/SW/876/pred_finale/camerus.c |
---|
0,0 → 1,657 |
//********* Robot Camerus pro IstRobot 2007 ************ |
//"$Id: camerus.c 253 2007-04-24 09:26:46Z kakl $" |
//***************************************************** |
#include ".\camerus.h" |
#USE FAST_IO (C) // Brana C je ve FAST_IO modu, aby slo rychle cist z kamery |
// Rychlostni konstanty |
#define RR_CIHLA 50 // Rozumna rychlost pro objizdeni cihly |
#define RR_PRERUSENI 50 // Rozumna rychlost pro priblizeni se k preruseni |
#define BRZDNA_DRAHA 0x15 // Jak daleko pred problemem se zacne brzdit |
#define TUHOS 100 // Jak dlouho se bude couvat po narazu na naraznik |
#define ODODO_CIHLA 0xD0 |
#define ODODO_TUNEL 0xFFF |
#define ODODO_PRERUSENI 0xFFF//0xB4 |
// Adresy IIC periferii |
#define COMPAS_ADR 0xC0 |
#define CAMERA_ADR 0xDC |
#define SONAR_ADR 0xE0 |
// A/D vstupy |
#define RMAX 4 // AN4/RA5 - leve cidlo na vyjeti z cary |
#define LMAX 3 // AN3/RA3 - prave cidlo na vyjeti z cary |
#define CERVENA 2 // AN2/RA2 - cervene kroutitko |
#define ZELENA 1 // AN1/RA0 - zelene kroutitko |
#define MODRA 0 // AN0/RA1 - modre kroutitko |
// I/O |
#define HREF PIN_C5 // Signal HREF z kamery (v H po celou dobu radku) |
#define PIX PIN_C6 // Vstup pro body z kamery (za trivstupim hradlem OR (dig. komparator)) |
#define SERVO PIN_B4 // Vystup na servo (1 az 2ms po cca 20ms (synchronizovano snimkovym kmitoctem)) |
#define MOT_L PIN_B5 // Smer otaceni leveho motoru; druhy pol je RC2 |
#define MOT_R PIN_B6 // Smer otaceni praveho motoru; druhy pol je RC1 |
#define MOT_1 PIN_C1 // PWM vystpy motoru |
#define MOT_2 PIN_C2 // |
#define DATA PIN_B2 // K modulu LEDbar data |
#define CP PIN_B1 // K modulu LEDbar hodiny |
//#define ODO PIN_C0 // Ze snimace z odometrie z praveho kola na TIMER1 |
// Jeden impuls je 31,25mm |
#define IRRX !input(PIN_B0) // Vstup INT, generuje preruseni pri prekazce |
#define IRTX PIN_B3 // Modulovani vysilaci IR LED na detekci prekazky |
#define PROXIMITY PIN_C7 // Cidlo kratkeho dosahu na cihlu |
#define BUMPER !input(PIN_A4) // Naraznik |
#define CASMIN 6 // Rozsah radku snimace |
#define CASMAX 192 |
#define CASAVR ((CASMAX+CASMIN) / 2) |
#define EEMAX 255 // Konec EEPROM |
#define MAXLOG 0x10 // Maximalni pocet zaznamu v logu |
#if MAXLOG>(EEMAX/3) |
#error Prekrocena velikost EEPROM |
#endif |
#define OFFSETO 0x9F //0x9F // Vystredeni serva pro objeti prekazky |
#define THR 90 // Threshold pro UV cidla na caru |
#byte INTCON = 0x0B // Interrupt configuration register |
#bit GIE = INTCON.7 |
#bit PEIE = INTCON.6 |
#bit TMR0IE = INTCON.5 |
#bit INT0IE = INTCON.4 |
#bit RBIE = INTCON.3 |
#bit TMR0IF = INTCON.2 |
#bit INT0IF = INTCON.1 |
#bit RBIF = INTCON.0 |
enum stavy {start,rozjezd,jizda,cihla,pocihle,cil}; |
stavy stav; // Kde jsme na trati |
int8 cas; // Cas hrany bila/cerna v radce |
int8 stred; // Vystredeni kolecka |
int16 odocounter; // Zaznamenani aktualniho stavu pocitadla odometrie |
int16 last_log_odo; // Posledni stav odometrie poznamenany do logu |
int16 last_log; // Cislo posledniho zaznamu v logu v EEPROM |
int8 bb_h[MAXLOG]; // Cerna skrinka MSB |
int8 bb_l[MAXLOG]; // Cerna skrinka LSB |
int8 bb_f[MAXLOG]; // Cerna skrinka priznak (typ zaznamu) |
int8 log; // Pocitadlo pro cernou skrinku |
int8 rr; // Promenna na ulozeni Rozumne rychlost |
int8 rrold; |
int16 odo_preruseni, odo_cihla, odo_tunel; // Problemy na trati |
// Zobrazeni jednoho byte na modulu LEDbar |
inline void disp(int8 x) |
{ |
int n; |
for(n=0;n<=7;n++) |
{ |
if (bit_test(x,0)) output_low(DATA); else output_high(DATA); |
output_high(CP); |
x>>=1; |
output_low(CP); |
} |
} |
// Blikani LEDbarem ve stilu Night Rider |
void NightRider(int8 x) |
{ |
int n,i,j; |
for(j=0;j<x;j++) |
{ |
i=0x01; |
for(n=0;n<7;n++) |
{ |
disp(i); |
rotate_left(&i, 1); |
delay_ms(40); |
} |
for(n=0;n<7;n++) |
{ |
disp(i); |
rotate_right(&i, 1); |
delay_ms(40); |
} |
} |
disp(i); |
delay_ms(40); |
i=0; |
disp(i); |
} |
// Zaznam LOGu do EEPROM |
void SaveLog() |
{ |
int8 n,i,xlog; |
i=0; |
for(n=0;n<=(log*3);n+=3) // Ulozeni Black Boxu do EEPROM |
{ |
write_eeprom(n,bb_f[i]); |
write_eeprom(n+1,bb_h[i]); |
write_eeprom(n+2,bb_l[i]); |
i++; |
}; |
if(log>0) {xlog=log-1;} else {xlog=0;}; |
write_eeprom(EEMAX,xlog); // Zapis poctu zaznamu na konec EEPROM |
} |
// Zaznam do Logu do RAM |
void LogLog(int8 reason, int16 log_delay) |
{ |
int16 timer_pom; |
timer_pom=get_timer1(); // Timer se musi vycist atomicky |
bb_l[log]=make8(timer_pom,0); // Zaznam |
bb_h[log]=make8(timer_pom,1); |
bb_f[log]=reason; // Typ zaznamu |
if(log<(MAXLOG-1)) log++; // Ukazatel na dalsi zaznam |
last_log_odo=timer_pom+log_delay; // Dalsi mereni nejdrive po ujeti def. vzdalenosti |
rr=rrold; // Problem skoncil, znovu jed Rozumnou Rychlosti |
} |
void ReadBlackBox() |
{ |
last_log=read_eeprom(EEMAX); // Kolik zaznamu mame od minule poznamenano? |
{ |
int8 n,i; |
i=0; |
for(n=0;n<=last_log;n++) |
{ |
if(read_eeprom(i)==0) odo_tunel=MAKE16(read_eeprom(i+2),read_eeprom(i+1)); |
if(read_eeprom(i)==0xFF) odo_cihla=MAKE16(read_eeprom(i+2),read_eeprom(i+1)); |
if((read_eeprom(i)>0) && (read_eeprom(i)<0xFF)) odo_preruseni=MAKE16(read_eeprom(i+2),read_eeprom(i+1)); |
} |
} |
} |
// Brzdeni motorama stridou 1:1 |
void brzda() |
{ |
int8 n,i; |
set_pwm1_duty(0); // vypni PWM |
set_pwm2_duty(0); |
setup_ccp1(CCP_OFF); |
setup_ccp2(CCP_OFF); |
for (n=0;n<200;n++) |
{ |
output_low(MOT_L); |
output_low(MOT_R); |
output_high(MOT_1); |
output_high(MOT_2); |
delay_us(200); |
output_high(MOT_L); |
output_high(MOT_R); |
output_low(MOT_1); |
output_low(MOT_2); |
delay_us(200); |
} |
output_low(MOT_L); // smer vpred |
output_low(MOT_R); |
setup_ccp1(CCP_PWM); // RC1 // Zapni PWM pro motory |
setup_ccp2(CCP_PWM); // RC2 |
} |
void SetServo(int8 angle) |
{ |
int8 n; |
for(n=0; n<10; n++) |
{ |
output_high(SERVO); // Odvysilani impuzu 1 az 2ms pro servo |
delay_us(1000); |
delay_us(stred); |
delay_us(stred); |
delay_us(stred); |
delay_us(angle); |
delay_us(angle); |
output_low(SERVO); |
delay_ms(18); |
} |
} |
inline void SetServoQ(int8 angle) |
{ |
output_high(SERVO); // Odvysilani impuzu 1 az 2ms pro servo |
delay_us(1000); |
delay_us(stred); |
delay_us(stred); |
delay_us(stred); |
delay_us(angle); |
delay_us(angle); |
output_low(SERVO); |
} |
// Couvni po narazu na naraznik |
inline void bum() |
{ |
set_pwm1_duty(0); // couvni, rovne dozadu |
set_pwm2_duty(0); |
output_high(MOT_L); |
output_high(MOT_R); |
disp(0xA5); |
SetServo(CASAVR-CASMIN); |
} |
#include ".\diag.c" |
//---------------------------- INT -------------------------------- |
#int_EXT |
EXT_isr() // Preruseni od prekazky |
{ |
unsigned int8 bearing, bearing_offset, delta_bearing; |
set_pwm1_duty(0); // zabrzdi levym kolem, prave vypni |
set_pwm2_duty(0); |
output_high(MOT_L); |
output_low(MOT_R); |
// Ujistime se, ze prijaty signal je z naseho IR vysilace |
output_high(IRTX); // Vypni LED na detekci prekazky |
delay_ms(2); |
if (IRRX) // stale nas signal? |
{ |
output_low(MOT_L); // je odraz -> vpred |
output_low(MOT_R); |
return; |
}; |
output_low(IRTX); // Zapni LED na detekci prekazky |
i2c_start(); // Cteni kompasu |
i2c_write(COMPAS_ADR); |
i2c_write(0x1); // 0-255 (odpovida 0-359) |
i2c_stop(); |
i2c_start(); |
i2c_write(COMPAS_ADR+1); |
bearing_offset=i2c_read(0); // Poznamenej hodnotu pred cihlou |
i2c_stop(); |
delay_ms(9); |
if (!IRRX) // stale nas signal? |
{ |
output_low(MOT_L); // neni odraz -> vpred |
output_low(MOT_R); |
return; |
}; |
rr=rrold; // Po cihle se pojede opet Rozumnou Rychlosti |
if(stav!=cihla) |
{ |
LogLog(0xFF,3); // Cihla |
}; |
//!!! if(stav==cihla) while(true); // Zastav na furt, konec drahy |
// if(stav==cihla) return; // Po druhe nic neobjizdej |
// Pozor na rozjezd |
if((stav==jizda)||(stav==cihla)) // Objed cihlu |
{ |
#include ".\objizdka_L.c" |
}; |
last_log_odo=get_timer1()+16; // Pul metru po cihle nezaznamenavej do LOGu |
} |
//---------------------------------- MAIN -------------------------------------- |
void main() |
{ |
int8 offset; // Promena pro ulozeni offsetu |
int8 r1; // Rychlost motoru 1 |
int8 r2; // Rychlost motoru 2 |
int16 ble; |
setup_adc_ports(ALL_ANALOG); // Zapnuti A/D prevodniku pro cteni kroutitek |
setup_adc(ADC_CLOCK_INTERNAL); |
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); // Casovac pro mereni casu hrany W/B v radce |
setup_timer_1(T1_EXTERNAL); // Cita pulzy z odometrie z praveho kola |
setup_timer_2(T2_DIV_BY_16,255,1); // Casovac PWM motoru |
//!!! setup_timer_2(T2_DIV_BY_4,255,1); // Casovac PWM motoru |
setup_ccp1(CCP_PWM); // RC1 // PWM pro motory |
setup_ccp2(CCP_PWM); // RC2 |
setup_comparator(NC_NC_NC_NC); |
setup_vref(FALSE); |
set_tris_c(0b11111001); // Nastaveni vstup/vystup pro branu C, protoze se to nedela automaticky |
set_pwm1_duty(0); // Zastav motory |
set_pwm2_duty(0); |
output_low(MOT_L); // Nastav smer vpred |
output_low(MOT_R); |
disp(0); // Zhasni LEDbar |
if(BUMPER) // Kdyz nekdo na zacatku drzi naraznik, vymaz log a spust diagnostiku |
{ |
diag(); |
} |
output_low(IRTX); // Zapni LED na detekci prekazky |
NightRider(1); // Zablikej, aby se poznalo, ze byl RESET |
// Zaroven se musi pockat, nez se rozjede kamera, nez se do ni zacnou posilat prikazy |
//... Nastaveni sonaru ... |
i2c_start(); |
i2c_write(SONAR_ADR); |
i2c_write(0x02); // dosah |
i2c_write(0x03); // n*43mm |
i2c_stop(); |
i2c_start(); |
i2c_write(SONAR_ADR); |
i2c_write(0x01); // zesileni |
i2c_write(0x01); // male, pro eliminaci echa z minuleho mereni |
i2c_stop(); |
//... Nastaveni kamery ... |
i2c_start(); // Soft RESET kamery |
i2c_write(CAMERA_ADR); // Adresa kamery |
i2c_write(0x12); // Adresa registru COMH |
i2c_write(0x80 | 0x24); // Zapis ridiciho slova |
i2c_stop(); |
i2c_start(); // BW |
i2c_write(CAMERA_ADR); |
i2c_write(0x28); |
i2c_write(0b01000001); |
i2c_stop(); |
/* |
i2c_start(); // Contrast (nema podstatny vliv na obraz) |
i2c_write(CAMERA_ADR); |
i2c_write(0x05); |
i2c_write(0xA0); // 48h |
i2c_stop(); |
i2c_start(); // Band Filter (pokud by byl problem se zarivkama 50Hz) |
i2c_write(CAMERA_ADR); |
i2c_write(0x2D); |
i2c_write(0x04 | 0x03); |
i2c_stop(); |
*/ |
i2c_start(); // Fame Rate |
i2c_write(CAMERA_ADR); |
i2c_write(0x2B); |
i2c_write(0x00); // cca 17ms (puvodni hodnota 5Eh = 20ms) |
i2c_stop(); |
i2c_start(); // VSTRT |
i2c_write(CAMERA_ADR); |
i2c_write(0x19); |
i2c_write(118); // prostredni radka |
i2c_stop(); |
i2c_start(); // VEND |
i2c_write(CAMERA_ADR); |
i2c_write(0x1A); |
i2c_write(118); |
i2c_stop(); |
NightRider(1); // Musi se dat cas kamere na AGC a AEC |
{ // Mereni expozice |
int8 t1,t2; |
i2c_start(); // Brightness, zacni od uplne tmy |
i2c_write(CAMERA_ADR); |
i2c_write(0x06); |
i2c_write(0); // 80h default |
i2c_stop(); |
delay_ms(50); |
for(offset=0x04;offset<(255-0x04);offset+=0x04) // Zacni od jasu 10h |
{ |
i2c_start(); // Brightness |
i2c_write(CAMERA_ADR); |
i2c_write(0x06); |
i2c_write(offset); // 80h default |
i2c_stop(); |
disp(offset); |
delay_ms(50); |
t1=0; |
t2=0; |
while(!input(HREF)); // Cekej nez se zacnou posilat pixely z radky |
delay_ms(5); |
while(!input(HREF)); // Cekej nez se zacnou posilat pixely z radky |
set_timer0(0); // Vynuluj pocitadlo casu |
if(!input(PIX)) continue; |
while(input(PIX)); |
t1=get_timer0(); // Precti cas z citace casu hrany |
set_timer0(0); // Vynuluj pocitadlo casu |
while(!input(PIX)); |
t2=get_timer0(); |
if((t1>60) && (t1<140) && (t2>5) && (t2<=10)) break; // Vidis, co mas? |
delay_ms(2); // Preskoc druhou radku z kamery |
}; |
delay_ms(1000); // Nech chvili na displayi zmerenou hodnotu |
} |
set_adc_channel(CERVENA); // --- Kroutitko pro jas --- |
delay_ms(1); |
offset=read_adc(); |
offset &= 0b11111100; // Dva nejnizsi bity ignoruj |
// offset += 0x70; // Jas nebude nikdy nizsi |
disp(offset); |
i2c_start(); // Brightness |
i2c_write(CAMERA_adr); |
i2c_write(0x06); |
i2c_write(offset); // 80h default |
i2c_stop(); |
delay_ms(1000); // Nech hodnotu chvili na displayi |
set_adc_channel(ZELENA); // --- Kroutitko pro vykon motoru --- |
delay_ms(1); |
rr=read_adc()>>2; // 0-63 // Pokud by se zvetsil rozsah, tak zkontrolovat jakonasobeni! |
rr+=27; // 27-90 |
//!!! rr=read_adc()>>1; // 0-128 // Pokud by se zvetsil rozsah, tak zkontrolovat jakonasobeni! |
rrold=rr; |
cas=CASAVR-CASMIN; // Inicializace promenych, aby neslo servo za roh |
// a aby se to rozjelo jeste dneska |
stav=start; // Jsme na startu |
set_timer1(0); // Vynuluj citac odometrie |
log=0; // Zacatek logu v cerne skrince |
last_log_odo=0; // Posledni zaznam odometrie do logu |
// ReadBlackBox(); // Vycteni zaznamu z Black Boxu |
odo_cihla=ODODO_CIHLA-BRZDNA_DRAHA; |
odo_tunel=ODODO_TUNEL-BRZDNA_DRAHA; |
odo_preruseni=ODODO_PRERUSENI-BRZDNA_DRAHA; |
// ........................... Hlavni smycka ................................ |
while(true) |
{ |
int8 pom; |
int8 n; |
int8 gap; |
int16 ododo; |
gap=0; // Vynuluj pocitadlo preruseni |
next_snap: |
pom=0; |
disable_interrupts(GLOBAL); //----------------------- Critical Section |
while(input(HREF)); // Preskoc 1. radku |
while(!input(HREF)); // Cekej nez se zacnou posilat pixely z 2. radky |
set_timer0(0); // Vynuluj pocitadlo casu |
while(input(HREF)) // Po dobu vysilani radky cekej na hranu W/B |
{ |
// !!!!Dodelat rozpoznani cerne cary napric pro zastaveni ? |
if(!input(PIX)) // Pokud se X-krat za sebou precetla CERNA |
if(!input(PIX)) |
// if(!input(PIX)) |
{ |
pom=get_timer0(); // Precti cas z citace casu hrany |
break; |
}; |
}; |
while(input(HREF)); // Pockej na shozeni signalu HREF |
if((pom<CASMAX) && (pom>CASMIN)) cas=pom; // Orizni konce radku |
// Na konci obrazovaho radku to blbne. Jednak chyba od apertury |
// a vubec to nejak na kraji nefunguje. |
output_high(SERVO); // Odvysilani impuzu 1 az 2ms pro servo |
delay_us(1000); |
delay_us(stred); |
delay_us(stred); |
delay_us(stred); |
delay_us(cas); |
delay_us(cas); |
output_low(SERVO); |
// Elektronicky diferencial 1. cast |
if(cas<CASAVR) {r1=cas-CASMIN; r2=CASAVR-CASMIN;}; // Normovani vystupni hodnoty radkoveho snimace |
if(cas==CASAVR) {r1=cas-CASMIN; r2=cas-CASMIN;}; // pro rizeni rychlosti motoru |
if(cas>CASAVR) {r1=CASAVR-CASMIN; r2=CASMAX-cas;}; // Rozsah 1 az 92 |
enable_interrupts(GLOBAL); //----------------------- End Critical Section |
if(pom==0) // Kamera nevidi caru |
{ |
if((cas>(CASMIN+15))&&(cas<(CASMAX-15))) // Nebyla minule cara moc u kraje? |
{ |
gap++; |
if(gap>=3) // Trva preruseni cary alespon 2 snimky? |
{ |
cas=CASAVR-CASMIN; |
// disp(0xAA); |
} |
} |
} |
else |
{ |
gap=0; |
}; |
/* |
if(pom==0) // Kamera nevidi caru, poznamenej to do logu |
{ |
if((cas>(CASMIN+30))&&(cas<(CASMAX-30))) // Nebyla minule cara moc u kraje? |
if(last_log_odo<get_timer1()) // Aby nebyly zaznamy v logu prilis huste, musi se napred neco ujet od minuleho zaznamu |
{ |
gap++; |
} |
} |
else |
{ |
if(gap>=4) // Trva preruseni cary alespon 2 snimky? |
{ |
LogLog(gap,8); // Dalsi mereni nejdrive po ujeti 24 cm |
rr=rrold; // Preruseni cary skoncilo, znovu jed Rozumnou Rychlosti |
cas=CASAVR-CASMIN; |
disp(0xAA); |
} |
gap=0; |
}; |
if(!input(PROXIMITY) && ((stav==jizda)||(stav==cihla))) // Tunel |
{ |
if(last_log_odo<get_timer1()) // Aby nebyly zaznamy v logu prilis huste, musi se napred neco ujet od minuleho zaznamu |
{ |
LogLog(0xDD,16); // Priznak tunelu; dalsi mereni nejdrive po ujeti 48 cm |
rr=rrold; // Vjeli jsme do tunelu, znovu jed rychle |
} |
}; |
*/ |
//ODODO |
ododo=get_timer1(); |
if((ododo>odo_preruseni)&&(ododo<(odo_preruseni+8))) rr=RR_PRERUSENI; |
if((ododo>odo_cihla)&&(ododo<(odo_cihla+8))) rr=RR_PRERUSENI; |
if((ododo>odo_tunel)&&(ododo<(odo_tunel+8))) rr=RR_PRERUSENI; |
// Elektronicky diferencial 2. cast |
if (r1>(CASAVR-CASMIN-rr)) r1=(r1<<1)+rr-(CASAVR-CASMIN); // Neco jako nasobeni |
if (r2>(CASAVR-CASMIN-rr)) r2=(r2<<1)+rr-(CASAVR-CASMIN); // rozsah 1 az 92 pro rr=0 // rozsah 1 az 154 pro rr=63 |
//!!! pro zatuhle prevodovky |
// r1<<=1; // Rychlost je dvojnasobna |
// r2<<=1; // Rozsah 2 az 184 pro rr=0 |
if ((stav==jizda)||(stav==cihla)||(stav==rozjezd)) //||(stav==pocihle)) // Jizda |
{ |
set_pwm1_duty(r1); |
set_pwm2_duty(r2); |
} |
else |
{ |
set_pwm1_duty(0); // Zastaveni |
set_pwm2_duty(0); |
}; |
if((stav==rozjezd)&&(get_timer1()>10)) // musi ujet alespon 31cm |
{ |
ext_int_edge(H_TO_L); // Nastav podminky preruseni od cihly |
INT0IF=0; // Zruseni predesle udalosti od startera |
enable_interrupts(INT_EXT); |
enable_interrupts(GLOBAL); |
stav=jizda; |
}; |
if(stav==start) // Snimkuje, toci servem a ceka na start |
{ |
set_adc_channel(MODRA); // Kroutitko na vystredeni predniho kolecka |
Delay_ms(1); |
stred=read_adc(); |
if(!input(PROXIMITY)) |
{ |
disp(0x80); |
while(input(PROXIMITY)); // Cekej, dokud starter neda ruku pryc |
set_timer1(0); // Vynuluj citac odometrie |
set_pwm1_duty(255); // Rychly rozjezd !!! Zkontrolovat na oscyloskopu |
set_pwm2_duty(255); |
disp(0x01); |
while(get_timer1()<=4) // Ujed alespon 12cm |
{ |
set_adc_channel(LMAX); // Levy UV sensor |
delay_us(40); |
if(read_adc()<THR) {cas=CASMIN; break;}; // Prejeli jsme caru vlevo |
set_adc_channel(RMAX); // Pravy UV sensor |
delay_us(40); |
if(read_adc()<THR) {cas=CASMAX; break;}; // Prejeli jsme caru vpravo |
cas=CASAVR-CASMIN; // Cara je rovne |
}; |
stav=rozjezd; |
}; |
} |
pom=0x80; // Zobrazeni pozice cary na displayi |
for(n=CASMAX/8; n<cas; n+=CASMAX/8) pom>>=1; |
disp(pom); |
while(true) // Ve zbytku casu snimku cti krajni UV senzory a naraznik |
{ |
if(BUMPER) // Sakra, do neceho jsme narazili a nevideli jsme to! |
{ |
bum(); |
SaveLog(); // Zapis Black Boxu do EEPROM |
delay_ms(TUHOS); //!!! Zatuhle prevodovky |
set_pwm1_duty(200); // pomalu vpred |
set_pwm2_duty(200); |
output_low(MOT_L); |
output_low(MOT_R); |
cas=CASAVR-CASMIN; |
}; |
set_adc_channel(LMAX); // Levy UV sensor |
for(n=0;n<20;n++) if(input(HREF)) goto next_snap; |
if(read_adc()<THR) cas=CASMIN; |
set_adc_channel(RMAX); // Pravy UV sensor |
for(n=0;n<20;n++) if(input(HREF)) goto next_snap; |
if(read_adc()<THR) cas=CASMAX; |
}; |
} |
} |
/roboti/istrobot/camerus/SW/876/pred_finale/diag.c |
---|
0,0 → 1,68 |
//--- Diagnostika cidel a vymazani EEPROM --- |
void diag() |
{ |
int8 n; |
// Vymaz Black Box v EEPROM |
for(n=0;n<255;n++) write_eeprom(n,0); |
bb_l[0]=0; // Zapis na pozici 0 vzdalenost 0 |
bb_h[0]=0; |
bb_f[0]=0; |
write_eeprom(EEMAX,0); // Zapis do EEPROM pocet zaznamu 0, tedy jeden zaznam |
for(n=0;n<=4;n++) |
{ |
disp(0x55); // Blikni pro potvrzeni |
delay_ms(200); |
disp(0xAA); |
delay_ms(200); |
}; |
while(true) |
{ |
if(!IRRX) |
{ |
int8 ble; |
i2c_start(); // Cteni kompasu |
i2c_write(COMPAS_ADR); |
i2c_write(0x1); |
i2c_stop(); |
i2c_start(); |
i2c_write(COMPAS_ADR+1); |
ble=i2c_read(0); |
i2c_stop(); |
disp(ble); |
delay_ms(200); |
} |
else |
{ |
i2c_start(); // Diagnostika sonaru |
i2c_write(SONAR_ADR); |
i2c_write(0x02); // dosah |
i2c_write(0x03); // n*43mm |
i2c_stop(); |
i2c_start(); |
i2c_write(SONAR_ADR); |
i2c_write(0x01); // zesileni |
i2c_write(0x01); // male, pro eliminaci echa z minuleho mereni |
i2c_stop(); |
i2c_start(); // Sonar Ping |
i2c_write(0xE0); |
i2c_write(0x0); |
i2c_write(0x51); // 50 mereni v palcich, 51 mereni v cm, 52 v us |
i2c_stop(); |
delay_ms(100); |
i2c_start(); // Odraz ze sonaru |
i2c_write(0xE0); |
i2c_write(0x3); |
i2c_stop(); |
i2c_start(); |
i2c_write(0xE1); |
n=i2c_read(0); |
i2c_stop(); |
disp(n); // Zobrazeni hodnoty ze sonaru a zaroven diagnostika predniho IR cidla |
delay_ms(200); |
} |
} |
} |
/roboti/istrobot/camerus/SW/876/pred_finale/objizdka_L.c |
---|
0,0 → 1,183 |
// **** Objeti cihly vlevo **** LLLL |
#define L_TOUCH 1 // Cara vlevo |
#define R_TOUCH 2 // Cata vpravo |
#define B_TOUCH 3 // Both |
int8 n; |
int8 r1,r2,rr; |
int8 touch; |
enum okolo_cihly {pred_carou,na_care,po_care}; |
okolo_cihly ridic; // V jakem jsme stavu objizdeni cihly |
int8 vzdalenost; |
int8 visualisation; |
stav=cihla; // Dalsi prekazku uz nezaznamenavej (je to s velkou pravdepodobnosti cil) |
odocounter=get_timer1(); |
cihla: |
rr=RR_CIHLA; //!!! Rozumna rychlost pro objizdeni cihly (bylo by lepsi rychlost zvysovat) a pri detekci pohybu zase snizit |
disp(0x99); |
set_pwm1_duty(0); // zabrzdi levym kolem, prave vpred |
set_pwm2_duty(255); |
output_high(MOT_L); |
output_low(MOT_R); |
while(true) // Na zacatku se vyhni cihle, zatoc co muzes |
{ |
cas=CASMIN-5; // jeste vic nez hodne do leva |
if(BUMPER) // Narazili jsme do cihly, musime couvnout! |
{ |
bum(); |
SaveLog(); // Zapis Black Boxu do EEPROM |
delay_ms(TUHOS); //!!! Zatuhle prevodovky |
brzda(); |
goto cihla; // Znovu zacni cihlu objizdet |
}; |
set_pwm1_duty(0); |
set_pwm2_duty(255); // !!! mozna prilis maly vykon pro rozjezd pro zatuhlou prevodovku |
output_high(MOT_L); // leve kolo reverz |
output_low(MOT_R); // prave kolo vpred |
if(get_timer1()>(odocounter+5)) // konec zatacky? |
{ |
disp(0x66); |
break; |
} |
SetServoQ(cas); |
delay_ms(18); |
}; |
//------ Objeti cihly v konstantni vzdalenosti ------ |
touch=0; // Indikator detekce cary pri objizdeni |
ridic=pred_carou; |
cas=CASAVR-CASMIN; // rovne |
output_low(MOT_L); // vpred |
output_low(MOT_R); |
visualisation=0; |
while(true) |
{ |
if(BUMPER) // Narazili jsme do cihly, musime couvnout! |
{ |
bum(); |
SaveLog(); // Zapis Black Boxu do EEPROM |
delay_ms(TUHOS); //!!! Zatuhle prevodovky |
set_pwm1_duty(160); // vpred |
set_pwm2_duty(160); |
output_low(MOT_L); |
output_low(MOT_R); |
cas=CASMIN; |
}; |
delta_bearing=bearing-bearing_offset; |
visualisation=(delta_bearing & 0xF0) | (visualisation & 0x0F); |
if(IRRX) // hrozi celni srazka s cihlou v prubehu objizdeni |
{ |
cas=CASMIN; |
} |
else |
{ |
if((vzdalenost!=0)||!input(PROXIMITY)||((delta_bearing>60)&&(delta_bearing<128))) // Udrzovani konstantni vzdalenosti od cihly |
{ |
if(cas>(CASMIN+30)) cas-=30; |
} |
else |
{ |
if(cas<(CASMAX-30)) cas+=30; |
}; |
}; |
// Elektronicky diferencial |
if(cas<CASAVR) {r1=cas-CASMIN; r2=CASAVR-CASMIN;}; // Normovani vystupni hodnoty radkoveho snimace |
if(cas==CASAVR) {r1=cas-CASMIN; r2=cas-CASMIN;}; // pro rizeni rychlosti motoru |
if(cas>CASAVR) {r1=CASAVR-CASMIN; r2=CASMAX-cas;}; // Rozsah 1 az 92 |
if (r1>(CASAVR-CASMIN-rr)) r1=(r1<<1)+rr-(CASAVR-CASMIN); // Neco jako nasobeni |
if (r2>(CASAVR-CASMIN-rr)) r2=(r2<<1)+rr-(CASAVR-CASMIN); |
//!!! pro zatuhle prevodovky |
// r1<<=1; // Rychlost je dvojnasobna |
// r2<<=1; // Rozsah 2 az 184 pro rr=0 |
set_pwm1_duty(r1); // Nastav rychlost motoru |
set_pwm2_duty(r2); |
SetServoQ(cas); |
i2c_start(); // Sonar Ping |
i2c_write(SONAR_ADR); |
i2c_write(0x0); |
i2c_write(0x52); // mereni v us |
i2c_stop(); |
for(n=1;n<=90;n++) // 18ms testovani cary do dalsi korekce serva |
{ |
set_adc_channel(LMAX); |
delay_us(100); |
if(read_adc()<THR) touch|=L_TOUCH; |
set_adc_channel(RMAX); |
delay_us(100); |
if(read_adc()<THR) touch|=R_TOUCH; |
}; |
i2c_start(); // Odraz ze sonaru |
i2c_write(SONAR_ADR); |
i2c_write(0x3); |
i2c_stop(); |
i2c_start(); |
i2c_write(SONAR_ADR+1); |
vzdalenost=i2c_read(0); |
i2c_stop(); |
i2c_start(); // Cteni kompasu |
i2c_write(COMPAS_ADR); |
i2c_write(0x1); // uhel 0-255 |
i2c_stop(); |
i2c_start(); |
i2c_write(COMPAS_ADR+1); |
bearing=i2c_read(0); |
i2c_stop(); |
if(touch==L_TOUCH) visualisation|=0x2; |
if(touch==R_TOUCH) visualisation|=0x1; |
if((touch==B_TOUCH)&&(ridic==pred_carou)) ridic=na_care; |
if((ridic==na_care)&&(touch==0)) break; |
if(ridic==na_care) touch=0; |
disp(visualisation); |
}; |
disp(0xC3); |
set_pwm1_duty(0); //!!! pred zatuhlejma prevodovkama tam bylo 20 a 200 |
set_pwm2_duty(255); |
output_high(MOT_L); |
output_low(MOT_R); |
delay_us(40); |
odocounter=get_timer1(); // Poznamenej aktualni stav odometrie |
while (true) // Znovu se musime dotknout cary |
{ |
for(n=1;n<=90;n++) // 18ms testovani cary do dalsi korekce serva |
{ |
set_adc_channel(LMAX); // Levy UV sensor |
delay_us(100); |
if(read_adc()<THR) // Dotkli jsme se levym senzorem |
{ |
disp(0xE0); |
cas=CASAVR-CASMIN; // nastavime, ze cara je rovne |
goto cara; |
}; |
set_adc_channel(RMAX); // Pravy UV sensor |
delay_us(100); |
if((get_timer1()>=(odocounter+2)) && (read_adc()<THR)) // Pravym senzorem nesmime caru prejet! |
{ |
disp(0x07); |
cas=CASMAX; // kdyz prejedem, tak nastavime, ze cara je vpravo |
goto cara; |
}; |
} |
SetServoQ(CASMIN-5); // max. max. doleva L |
} |
cara: |
output_low(MOT_L); // oba motory vpred |
output_low(MOT_R); |
/roboti/istrobot/camerus/SW/876/pred_soutezi_rano/camerus.c |
---|
0,0 → 1,633 |
//********* Robot Camerus pro IstRobot 2007 ************ |
//"$Id: camerus.c 253 2007-04-24 09:26:46Z kakl $" |
//***************************************************** |
#include ".\camerus.h" |
#USE FAST_IO (C) // Brana C je ve FAST_IO modu, aby slo rychle cist z kamery |
// Rychlostni konstanty |
#define RR_CIHLA 50 // Rozumna rychlost pro objizdeni cihly |
#define RR_PRERUSENI 50 // Rozumna rychlost pro priblizeni se k preruseni |
#define BRZDNA_DRAHA 0x20 // Jak daleko pred problemem se zacne brzdit |
#define TUHOS 100 // Jak dlouho se bude couvat po narazu na naraznik |
#define ODODO_CIHLA 0xFFF |
#define ODODO_TUNEL 0xFFF |
#define ODODO_PRERUSENI 0xFFF |
// Adresy IIC periferii |
#define COMPAS_ADR 0xC0 |
#define CAMERA_ADR 0xDC |
#define SONAR_ADR 0xE0 |
// A/D vstupy |
#define RMAX 4 // AN4/RA5 - leve cidlo na vyjeti z cary |
#define LMAX 3 // AN3/RA3 - prave cidlo na vyjeti z cary |
#define CERVENA 2 // AN2/RA2 - cervene kroutitko |
#define ZELENA 1 // AN1/RA0 - zelene kroutitko |
#define MODRA 0 // AN0/RA1 - modre kroutitko |
// I/O |
#define HREF PIN_C5 // Signal HREF z kamery (v H po celou dobu radku) |
#define PIX PIN_C6 // Vstup pro body z kamery (za trivstupim hradlem OR (dig. komparator)) |
#define SERVO PIN_B4 // Vystup na servo (1 az 2ms po cca 20ms (synchronizovano snimkovym kmitoctem)) |
#define MOT_L PIN_B5 // Smer otaceni leveho motoru; druhy pol je RC2 |
#define MOT_R PIN_B6 // Smer otaceni praveho motoru; druhy pol je RC1 |
#define MOT_1 PIN_C1 // PWM vystpy motoru |
#define MOT_2 PIN_C2 // |
#define DATA PIN_B2 // K modulu LEDbar data |
#define CP PIN_B1 // K modulu LEDbar hodiny |
//#define ODO PIN_C0 // Ze snimace z odometrie z praveho kola na TIMER1 |
// Jeden impuls je 31,25mm |
#define IRRX !input(PIN_B0) // Vstup INT, generuje preruseni pri prekazce |
#define IRTX PIN_B3 // Modulovani vysilaci IR LED na detekci prekazky |
#define PROXIMITY PIN_C7 // Cidlo kratkeho dosahu na cihlu |
#define BUMPER !input(PIN_A4) // Naraznik |
#define CASMIN 6 // Rozsah radku snimace |
#define CASMAX 192 |
#define CASAVR ((CASMAX+CASMIN) / 2) |
#define EEMAX 255 // Konec EEPROM |
#define MAXLOG 0x10 // Maximalni pocet zaznamu v logu |
#if MAXLOG>(EEMAX/3) |
#error Prekrocena velikost EEPROM |
#endif |
#define OFFSETO 0x9F //0x9F // Vystredeni serva pro objeti prekazky |
#define THR 90 // Threshold pro UV cidla na caru |
#byte INTCON = 0x0B // Interrupt configuration register |
#bit GIE = INTCON.7 |
#bit PEIE = INTCON.6 |
#bit TMR0IE = INTCON.5 |
#bit INT0IE = INTCON.4 |
#bit RBIE = INTCON.3 |
#bit TMR0IF = INTCON.2 |
#bit INT0IF = INTCON.1 |
#bit RBIF = INTCON.0 |
enum stavy {start,rozjezd,jizda,cihla,pocihle,cil}; |
stavy stav; // Kde jsme na trati |
int8 cas; // Cas hrany bila/cerna v radce |
int8 stred; // Vystredeni kolecka |
int16 odocounter; // Zaznamenani aktualniho stavu pocitadla odometrie |
int16 last_log_odo; // Posledni stav odometrie poznamenany do logu |
int16 last_log; // Cislo posledniho zaznamu v logu v EEPROM |
int8 bb_h[MAXLOG]; // Cerna skrinka MSB |
int8 bb_l[MAXLOG]; // Cerna skrinka LSB |
int8 bb_f[MAXLOG]; // Cerna skrinka priznak (typ zaznamu) |
int8 log; // Pocitadlo pro cernou skrinku |
int8 rr; // Promenna na ulozeni Rozumne rychlost |
int8 rrold; |
int16 odo_preruseni, odo_cihla, odo_tunel; // Problemy na trati |
// Zobrazeni jednoho byte na modulu LEDbar |
inline void disp(int8 x) |
{ |
int n; |
for(n=0;n<=7;n++) |
{ |
if (bit_test(x,0)) output_low(DATA); else output_high(DATA); |
output_high(CP); |
x>>=1; |
output_low(CP); |
} |
} |
// Blikani LEDbarem ve stilu Night Rider |
void NightRider(int8 x) |
{ |
int n,i,j; |
for(j=0;j<x;j++) |
{ |
i=0x01; |
for(n=0;n<7;n++) |
{ |
disp(i); |
rotate_left(&i, 1); |
delay_ms(40); |
} |
for(n=0;n<7;n++) |
{ |
disp(i); |
rotate_right(&i, 1); |
delay_ms(40); |
} |
} |
disp(i); |
delay_ms(40); |
i=0; |
disp(i); |
} |
// Zaznam LOGu do EEPROM |
void SaveLog(int8 xlog) |
{ |
int8 n,i; |
i=0; |
for(n=0;n<=(log*3);n+=3) // Ulozeni Black Boxu do EEPROM |
{ |
write_eeprom(n,bb_f[i]); |
write_eeprom(n+1,bb_h[i]); |
write_eeprom(n+2,bb_l[i]); |
i++; |
}; |
write_eeprom(EEMAX,xlog); // Zapis poctu zaznamu na konec EEPROM |
} |
// Zaznam do Logu do RAM |
void LogLog(int8 reason, int16 log_delay) |
{ |
int16 timer_pom; |
timer_pom=get_timer1(); // Timer se musi vycist atomicky |
bb_l[log]=make8(timer_pom,0); // Zaznam |
bb_h[log]=make8(timer_pom,1); |
bb_f[log]=reason; // Typ zaznamu |
if(log<(MAXLOG-1)) log++; // Ukazatel na dalsi zaznam |
last_log_odo=timer_pom+log_delay; // Dalsi mereni nejdrive po ujeti def. vzdalenosti |
rr=rrold; // Problem skoncil, znovu jed Rozumnou Rychlosti |
} |
void ReadBlackBox() |
{ |
last_log=read_eeprom(EEMAX); // Kolik zaznamu mame od minule poznamenano? |
{ |
int8 n,i; |
i=0; |
for(n=0;n<=last_log;n++) |
{ |
if(read_eeprom(i)==0) odo_tunel=MAKE16(read_eeprom(i+2),read_eeprom(i+1)); |
if(read_eeprom(i)==0xFF) odo_cihla=MAKE16(read_eeprom(i+2),read_eeprom(i+1)); |
if((read_eeprom(i)>0) && (read_eeprom(i)<0xFF)) odo_preruseni=MAKE16(read_eeprom(i+2),read_eeprom(i+1)); |
} |
} |
} |
// Brzdeni motorama stridou 1:1 |
void brzda() |
{ |
int8 n,i; |
set_pwm1_duty(0); // vypni PWM |
set_pwm2_duty(0); |
setup_ccp1(CCP_OFF); |
setup_ccp2(CCP_OFF); |
for (n=0;n<200;n++) |
{ |
output_low(MOT_L); |
output_low(MOT_R); |
output_high(MOT_1); |
output_high(MOT_2); |
delay_us(200); |
output_high(MOT_L); |
output_high(MOT_R); |
output_low(MOT_1); |
output_low(MOT_2); |
delay_us(200); |
} |
output_low(MOT_L); // smer vpred |
output_low(MOT_R); |
setup_ccp1(CCP_PWM); // RC1 // Zapni PWM pro motory |
setup_ccp2(CCP_PWM); // RC2 |
} |
void SetServo(int8 angle) |
{ |
int8 n; |
for(n=0; n<10; n++) |
{ |
output_high(SERVO); // Odvysilani impuzu 1 az 2ms pro servo |
delay_us(1000); |
delay_us(stred); |
delay_us(stred); |
delay_us(stred); |
delay_us(angle); |
delay_us(angle); |
output_low(SERVO); |
delay_ms(18); |
} |
} |
inline void SetServoQ(int8 angle) |
{ |
output_high(SERVO); // Odvysilani impuzu 1 az 2ms pro servo |
delay_us(1000); |
delay_us(stred); |
delay_us(stred); |
delay_us(stred); |
delay_us(angle); |
delay_us(angle); |
output_low(SERVO); |
} |
// Couvni po narazu na naraznik |
inline void bum() |
{ |
set_pwm1_duty(0); // couvni, rovne dozadu |
set_pwm2_duty(0); |
output_high(MOT_L); |
output_high(MOT_R); |
disp(0xA5); |
SetServo(CASAVR-CASMIN); |
} |
#include ".\diag.c" |
//---------------------------- INT -------------------------------- |
#int_EXT |
EXT_isr() // Preruseni od prekazky |
{ |
unsigned int8 bearing, bearing_offset, delta_bearing; |
set_pwm1_duty(0); // zabrzdi levym kolem, prave vypni |
set_pwm2_duty(0); |
output_high(MOT_L); |
output_low(MOT_R); |
// Ujistime se, ze prijaty signal je z naseho IR vysilace |
output_high(IRTX); // Vypni LED na detekci prekazky |
delay_ms(2); |
if (IRRX) // stale nas signal? |
{ |
output_low(MOT_L); // je odraz -> vpred |
output_low(MOT_R); |
return; |
}; |
output_low(IRTX); // Zapni LED na detekci prekazky |
i2c_start(); // Cteni kompasu |
i2c_write(COMPAS_ADR); |
i2c_write(0x1); // 0-255 (odpovida 0-359) |
i2c_stop(); |
i2c_start(); |
i2c_write(COMPAS_ADR+1); |
bearing_offset=i2c_read(0); // Poznamenej hodnotu pred cihlou |
i2c_stop(); |
delay_ms(9); |
if (!IRRX) // stale nas signal? |
{ |
output_low(MOT_L); // neni odraz -> vpred |
output_low(MOT_R); |
return; |
}; |
rr=rrold; // Po cihle se pojede opet Rozumnou Rychlosti |
if(stav!=cihla) |
{ |
LogLog(0xFF,3); // Cihla |
}; |
//!!! if(stav==cihla) while(true); // Zastav na furt, konec drahy |
// if(stav==cihla) return; // Po druhe nic neobjizdej |
// Pozor na rozjezd |
if((stav==jizda)||(stav==cihla)) // Objed cihlu |
{ |
#include ".\objizdka_L.c" |
}; |
last_log_odo=get_timer1()+16; // Pul metru po cihle nezaznamenavej do LOGu |
} |
//---------------------------------- MAIN -------------------------------------- |
void main() |
{ |
int8 offset; // Promena pro ulozeni offsetu |
int8 r1; // Rychlost motoru 1 |
int8 r2; // Rychlost motoru 2 |
setup_adc_ports(ALL_ANALOG); // Zapnuti A/D prevodniku pro cteni kroutitek |
setup_adc(ADC_CLOCK_INTERNAL); |
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); // Casovac pro mereni casu hrany W/B v radce |
setup_timer_1(T1_EXTERNAL); // Cita pulzy z odometrie z praveho kola |
setup_timer_2(T2_DIV_BY_16,255,1); // Casovac PWM motoru |
//!!! setup_timer_2(T2_DIV_BY_4,255,1); // Casovac PWM motoru |
setup_ccp1(CCP_PWM); // RC1 // PWM pro motory |
setup_ccp2(CCP_PWM); // RC2 |
setup_comparator(NC_NC_NC_NC); |
setup_vref(FALSE); |
set_tris_c(0b11111001); // Nastaveni vstup/vystup pro branu C, protoze se to nedela automaticky |
set_pwm1_duty(0); // Zastav motory |
set_pwm2_duty(0); |
output_low(MOT_L); // Nastav smer vpred |
output_low(MOT_R); |
disp(0); // Zhasni LEDbar |
if(BUMPER) // Kdyz nekdo na zacatku drzi naraznik, vymaz log a spust diagnostiku |
{ |
diag(); |
} |
output_low(IRTX); // Zapni LED na detekci prekazky |
NightRider(1); // Zablikej, aby se poznalo, ze byl RESET |
// Zaroven se musi pockat, nez se rozjede kamera, nez se do ni zacnou posilat prikazy |
//... Nastaveni sonaru ... |
i2c_start(); |
i2c_write(SONAR_ADR); |
i2c_write(0x02); // dosah |
i2c_write(0x03); // n*43mm |
i2c_stop(); |
i2c_start(); |
i2c_write(SONAR_ADR); |
i2c_write(0x01); // zesileni |
i2c_write(0x01); // male, pro eliminaci echa z minuleho mereni |
i2c_stop(); |
//... Nastaveni kamery ... |
i2c_start(); // Soft RESET kamery |
i2c_write(CAMERA_ADR); // Adresa kamery |
i2c_write(0x12); // Adresa registru COMH |
i2c_write(0x80 | 0x24); // Zapis ridiciho slova |
i2c_stop(); |
i2c_start(); // BW |
i2c_write(CAMERA_ADR); |
i2c_write(0x28); |
i2c_write(0b01000001); |
i2c_stop(); |
/* |
i2c_start(); // Contrast (nema podstatny vliv na obraz) |
i2c_write(CAMERA_ADR); |
i2c_write(0x05); |
i2c_write(0xA0); // 48h |
i2c_stop(); |
i2c_start(); // Band Filter (pokud by byl problem se zarivkama 50Hz) |
i2c_write(CAMERA_ADR); |
i2c_write(0x2D); |
i2c_write(0x04 | 0x03); |
i2c_stop(); |
*/ |
i2c_start(); // Fame Rate |
i2c_write(CAMERA_ADR); |
i2c_write(0x2B); |
i2c_write(0x00); // cca 17ms (puvodni hodnota 5Eh = 20ms) |
i2c_stop(); |
i2c_start(); // VSTRT |
i2c_write(CAMERA_ADR); |
i2c_write(0x19); |
i2c_write(118); // prostredni radka |
i2c_stop(); |
i2c_start(); // VEND |
i2c_write(CAMERA_ADR); |
i2c_write(0x1A); |
i2c_write(118); |
i2c_stop(); |
NightRider(1); // Musi se dat cas kamere na AGC a AEC |
{ // Mereni expozice |
int8 t1,t2; |
i2c_start(); // Brightness, zacni od uplne tmy |
i2c_write(CAMERA_ADR); |
i2c_write(0x06); |
i2c_write(0); // 80h default |
i2c_stop(); |
delay_ms(50); |
for(offset=0x04;offset<(255-0x04);offset+=0x04) // Zacni od jasu 10h |
{ |
i2c_start(); // Brightness |
i2c_write(CAMERA_ADR); |
i2c_write(0x06); |
i2c_write(offset); // 80h default |
i2c_stop(); |
disp(offset); |
delay_ms(50); |
t1=0; |
t2=0; |
while(!input(HREF)); // Cekej nez se zacnou posilat pixely z radky |
delay_ms(5); |
while(!input(HREF)); // Cekej nez se zacnou posilat pixely z radky |
set_timer0(0); // Vynuluj pocitadlo casu |
if(!input(PIX)) continue; |
while(input(PIX)); |
t1=get_timer0(); // Precti cas z citace casu hrany |
set_timer0(0); // Vynuluj pocitadlo casu |
while(!input(PIX)); |
t2=get_timer0(); |
if((t1>60) && (t1<140) && (t2>5) && (t2<=10)) break; // Vidis, co mas? |
delay_ms(2); // Preskoc druhou radku z kamery |
}; |
delay_ms(1000); // Nech chvili na displayi zmerenou hodnotu |
} |
set_adc_channel(CERVENA); // --- Kroutitko pro jas --- |
delay_ms(1); |
offset=read_adc(); |
offset &= 0b11111100; // Dva nejnizsi bity ignoruj |
// offset += 0x70; // Jas nebude nikdy nizsi |
disp(offset); |
i2c_start(); // Brightness |
i2c_write(CAMERA_adr); |
i2c_write(0x06); |
i2c_write(offset); // 80h default |
i2c_stop(); |
delay_ms(1000); // Nech hodnotu chvili na displayi |
set_adc_channel(ZELENA); // --- Kroutitko pro vykon motoru --- |
delay_ms(1); |
rr=read_adc()>>2; // 0-63 // Pokud by se zvetsil rozsah, tak zkontrolovat jakonasobeni! |
rr+=27; // 27-90 |
//!!! rr=read_adc()>>1; // 0-128 // Pokud by se zvetsil rozsah, tak zkontrolovat jakonasobeni! |
rrold=rr; |
cas=CASAVR-CASMIN; // Inicializace promenych, aby neslo servo za roh |
// a aby se to rozjelo jeste dneska |
stav=start; // Jsme na startu |
set_timer1(0); // Vynuluj citac odometrie |
log=0; // Zacatek logu v cerne skrince |
last_log_odo=0; // Posledni zaznam odometrie do logu |
// ReadBlackBox(); // Vycteni zaznamu z Black Boxu |
odo_cihla=ODODO_CIHLA-BRZDNA_DRAHA; |
odo_tunel=ODODO_TUNEL-BRZDNA_DRAHA; |
odo_preruseni=ODODO_PRERUSENI-BRZDNA_DRAHA; |
// ........................... Hlavni smycka ................................ |
while(true) |
{ |
int8 pom; |
int8 n; |
int8 gap; |
int16 ododo; |
gap=0; // Vynuluj pocitadlo preruseni |
next_snap: |
pom=0; |
disable_interrupts(GLOBAL); //----------------------- Critical Section |
while(input(HREF)); // Preskoc 1. radku |
while(!input(HREF)); // Cekej nez se zacnou posilat pixely z 2. radky |
set_timer0(0); // Vynuluj pocitadlo casu |
while(input(HREF)) // Po dobu vysilani radky cekej na hranu W/B |
{ |
// !!!!Dodelat rozpoznani cerne cary napric pro zastaveni ? |
if(!input(PIX)) // Pokud se X-krat za sebou precetla CERNA |
if(!input(PIX)) |
// if(!input(PIX)) |
{ |
pom=get_timer0(); // Precti cas z citace casu hrany |
break; |
}; |
}; |
while(input(HREF)); // Pockej na shozeni signalu HREF |
if((pom<CASMAX) && (pom>CASMIN)) cas=pom; // Orizni konce radku |
// Na konci obrazovaho radku to blbne. Jednak chyba od apertury |
// a vubec to nejak na kraji nefunguje. |
output_high(SERVO); // Odvysilani impuzu 1 az 2ms pro servo |
delay_us(1000); |
delay_us(stred); |
delay_us(stred); |
delay_us(stred); |
delay_us(cas); |
delay_us(cas); |
output_low(SERVO); |
// Elektronicky diferencial 1. cast |
if(cas<CASAVR) {r1=cas-CASMIN; r2=CASAVR-CASMIN;}; // Normovani vystupni hodnoty radkoveho snimace |
if(cas==CASAVR) {r1=cas-CASMIN; r2=cas-CASMIN;}; // pro rizeni rychlosti motoru |
if(cas>CASAVR) {r1=CASAVR-CASMIN; r2=CASMAX-cas;}; // Rozsah 1 az 92 |
enable_interrupts(GLOBAL); //----------------------- End Critical Section |
if(pom==0) // Kamera nevidi caru, poznamenej to do logu |
{ |
if((cas>(CASMIN+30))&&(cas<(CASMAX-30))) // Nebyla minule cara moc u kraje? |
if(last_log_odo<get_timer1()) // Aby nebyly zaznamy v logu prilis huste, musi se napred neco ujet od minuleho zaznamu |
{ |
gap++; |
} |
} |
else |
{ |
if(gap>=2) // Trva preruseni cary alespon 2 snimky? |
{ |
LogLog(gap,8); // Dalsi mereni nejdrive po ujeti 24 cm |
rr=rrold; // Preruseni cary skoncilo, znovu jed Rozumnou Rychlosti |
} |
gap=0; |
}; |
if(!input(PROXIMITY) && ((stav==jizda)||(stav==cihla))) // Tunel |
{ |
if(last_log_odo<get_timer1()) // Aby nebyly zaznamy v logu prilis huste, musi se napred neco ujet od minuleho zaznamu |
{ |
LogLog(0xDD,16); // Priznak tunelu; dalsi mereni nejdrive po ujeti 48 cm |
rr=rrold; // Vjeli jsme do tunelu, znovu jed rychle |
} |
}; |
//ODODO |
ododo=get_timer1(); |
if((ododo>odo_preruseni)&&(ododo<(odo_preruseni+8))) rr=RR_PRERUSENI; |
if((ododo>odo_cihla)&&(ododo<(odo_cihla+8))) rr=RR_PRERUSENI; |
if((ododo>odo_tunel)&&(ododo<(odo_tunel+8))) rr=RR_PRERUSENI; |
// Elektronicky diferencial 2. cast |
if (r1>(CASAVR-CASMIN-rr)) r1=(r1<<1)+rr-(CASAVR-CASMIN); // Neco jako nasobeni |
if (r2>(CASAVR-CASMIN-rr)) r2=(r2<<1)+rr-(CASAVR-CASMIN); // rozsah 1 az 92 pro rr=0 // rozsah 1 az 154 pro rr=63 |
//!!! pro zatuhle prevodovky |
// r1<<=1; // Rychlost je dvojnasobna |
// r2<<=1; // Rozsah 2 az 184 pro rr=0 |
if ((stav==jizda)||(stav==cihla)||(stav==rozjezd)) //||(stav==pocihle)) // Jizda |
{ |
set_pwm1_duty(r1); |
set_pwm2_duty(r2); |
} |
else |
{ |
set_pwm1_duty(0); // Zastaveni |
set_pwm2_duty(0); |
}; |
if((stav==rozjezd)&&(get_timer1()>10)) // musi ujet alespon 31cm |
{ |
ext_int_edge(H_TO_L); // Nastav podminky preruseni od cihly |
INT0IF=0; // Zruseni predesle udalosti od startera |
enable_interrupts(INT_EXT); |
enable_interrupts(GLOBAL); |
stav=jizda; |
}; |
if(stav==start) // Snimkuje, toci servem a ceka na start |
{ |
set_adc_channel(MODRA); // Kroutitko na vystredeni predniho kolecka |
Delay_ms(1); |
stred=read_adc(); |
if(!input(PROXIMITY)) |
{ |
disp(0x80); |
while(input(PROXIMITY)); // Cekej, dokud starter neda ruku pryc |
set_timer1(0); // Vynuluj citac odometrie |
set_pwm1_duty(255); // Rychly rozjezd !!! Zkontrolovat na oscyloskopu |
set_pwm2_duty(255); |
disp(0x01); |
while(get_timer1()<=4) // Ujed alespon 12cm |
{ |
set_adc_channel(LMAX); // Levy UV sensor |
delay_us(40); |
if(read_adc()<THR) {cas=CASMIN; break;}; // Prejeli jsme caru vlevo |
set_adc_channel(RMAX); // Pravy UV sensor |
delay_us(40); |
if(read_adc()<THR) {cas=CASMAX; break;}; // Prejeli jsme caru vpravo |
cas=CASAVR-CASMIN; // Cara je rovne |
}; |
stav=rozjezd; |
}; |
} |
pom=0x80; // Zobrazeni pozice cary na displayi |
for(n=CASMAX/8; n<cas; n+=CASMAX/8) pom>>=1; |
disp(pom); |
while(true) // Ve zbytku casu snimku cti krajni UV senzory a naraznik |
{ |
if(BUMPER) // Sakra, do neceho jsme narazili a nevideli jsme to! |
{ |
bum(); |
SaveLog(log-1); // Zapis Black Boxu do EEPROM |
delay_ms(TUHOS); //!!! Zatuhle prevodovky |
set_pwm1_duty(200); // pomalu vpred |
set_pwm2_duty(200); |
output_low(MOT_L); |
output_low(MOT_R); |
cas=CASAVR-CASMIN; |
}; |
set_adc_channel(LMAX); // Levy UV sensor |
for(n=0;n<20;n++) if(input(HREF)) goto next_snap; |
if(read_adc()<THR) cas=CASMIN; |
set_adc_channel(RMAX); // Pravy UV sensor |
for(n=0;n<20;n++) if(input(HREF)) goto next_snap; |
if(read_adc()<THR) cas=CASMAX; |
}; |
} |
} |
/roboti/istrobot/camerus/SW/876/pred_soutezi_rano/diag.c |
---|
0,0 → 1,68 |
//--- Diagnostika cidel a vymazani EEPROM --- |
void diag() |
{ |
int8 n; |
// Vymaz Black Box v EEPROM |
for(n=0;n<255;n++) write_eeprom(n,0); |
bb_l[0]=0; // Zapis na pozici 0 vzdalenost 0 |
bb_h[0]=0; |
bb_f[0]=0; |
SaveLog(0); // Zapis do EEPROM pocet zaznamu 0, tedy jeden zaznam |
for(n=0;n<=4;n++) |
{ |
disp(0x55); // Blikni pro potvrzeni |
delay_ms(200); |
disp(0xAA); |
delay_ms(200); |
}; |
while(true) |
{ |
if(!IRRX) |
{ |
int8 ble; |
i2c_start(); // Cteni kompasu |
i2c_write(COMPAS_ADR); |
i2c_write(0x1); |
i2c_stop(); |
i2c_start(); |
i2c_write(COMPAS_ADR+1); |
ble=i2c_read(0); |
i2c_stop(); |
disp(ble); |
delay_ms(200); |
} |
else |
{ |
i2c_start(); // Diagnostika sonaru |
i2c_write(SONAR_ADR); |
i2c_write(0x02); // dosah |
i2c_write(0x03); // n*43mm |
i2c_stop(); |
i2c_start(); |
i2c_write(SONAR_ADR); |
i2c_write(0x01); // zesileni |
i2c_write(0x01); // male, pro eliminaci echa z minuleho mereni |
i2c_stop(); |
i2c_start(); // Sonar Ping |
i2c_write(0xE0); |
i2c_write(0x0); |
i2c_write(0x51); // 50 mereni v palcich, 51 mereni v cm, 52 v us |
i2c_stop(); |
delay_ms(100); |
i2c_start(); // Odraz ze sonaru |
i2c_write(0xE0); |
i2c_write(0x3); |
i2c_stop(); |
i2c_start(); |
i2c_write(0xE1); |
n=i2c_read(0); |
i2c_stop(); |
disp(n); // Zobrazeni hodnoty ze sonaru a zaroven diagnostika predniho IR cidla |
delay_ms(200); |
} |
} |
} |
/roboti/istrobot/camerus/SW/876/pred_soutezi_rano/objizdka_L.c |
---|
0,0 → 1,183 |
// **** Objeti cihly vlevo **** LLLL |
#define L_TOUCH 1 // Cara vlevo |
#define R_TOUCH 2 // Cata vpravo |
#define B_TOUCH 3 // Both |
int8 n; |
int8 r1,r2,rr; |
int8 touch; |
enum okolo_cihly {pred_carou,na_care,po_care}; |
okolo_cihly ridic; // V jakem jsme stavu objizdeni cihly |
int8 vzdalenost; |
int8 visualisation; |
stav=cihla; // Dalsi prekazku uz nezaznamenavej (je to s velkou pravdepodobnosti cil) |
odocounter=get_timer1(); |
cihla: |
rr=RR_CIHLA; //!!! Rozumna rychlost pro objizdeni cihly (bylo by lepsi rychlost zvysovat) a pri detekci pohybu zase snizit |
disp(0x99); |
set_pwm1_duty(0); // zabrzdi levym kolem, prave vpred |
set_pwm2_duty(255); |
output_high(MOT_L); |
output_low(MOT_R); |
while(true) // Na zacatku se vyhni cihle, zatoc co muzes |
{ |
cas=CASMIN-5; // jeste vic nez hodne do leva |
if(BUMPER) // Narazili jsme do cihly, musime couvnout! |
{ |
bum(); |
SaveLog(log-1); // Zapis Black Boxu do EEPROM |
delay_ms(TUHOS); //!!! Zatuhle prevodovky |
brzda(); |
goto cihla; // Znovu zacni cihlu objizdet |
}; |
set_pwm1_duty(0); |
set_pwm2_duty(200); // !!! mozna prilis maly vykon pro rozjezd pro zatuhlou prevodovku |
output_high(MOT_L); // leve kolo reverz |
output_low(MOT_R); // prave kolo vpred |
if(get_timer1()>(odocounter+5)) // konec zatacky? |
{ |
disp(0x66); |
break; |
} |
SetServoQ(cas); |
delay_ms(18); |
}; |
//------ Objeti cihly v konstantni vzdalenosti ------ |
touch=0; // Indikator detekce cary pri objizdeni |
ridic=pred_carou; |
cas=CASAVR-CASMIN; // rovne |
output_low(MOT_L); // vpred |
output_low(MOT_R); |
visualisation=0; |
while(true) |
{ |
if(BUMPER) // Narazili jsme do cihly, musime couvnout! |
{ |
bum(); |
SaveLog(log-1); // Zapis Black Boxu do EEPROM |
delay_ms(TUHOS); //!!! Zatuhle prevodovky |
set_pwm1_duty(160); // vpred |
set_pwm2_duty(160); |
output_low(MOT_L); |
output_low(MOT_R); |
cas=CASMIN; |
}; |
delta_bearing=bearing-bearing_offset; |
visualisation=(delta_bearing & 0xF0) | (visualisation & 0x0F); |
if(IRRX) // hrozi celni srazka s cihlou v prubehu objizdeni |
{ |
cas=CASMIN; |
} |
else |
{ |
if((vzdalenost!=0)||!input(PROXIMITY)||((delta_bearing>60)&&(delta_bearing<128))) // Udrzovani konstantni vzdalenosti od cihly |
{ |
if(cas>(CASMIN+30)) cas-=30; |
} |
else |
{ |
if(cas<(CASMAX-30)) cas+=30; |
}; |
}; |
// Elektronicky diferencial |
if(cas<CASAVR) {r1=cas-CASMIN; r2=CASAVR-CASMIN;}; // Normovani vystupni hodnoty radkoveho snimace |
if(cas==CASAVR) {r1=cas-CASMIN; r2=cas-CASMIN;}; // pro rizeni rychlosti motoru |
if(cas>CASAVR) {r1=CASAVR-CASMIN; r2=CASMAX-cas;}; // Rozsah 1 az 92 |
if (r1>(CASAVR-CASMIN-rr)) r1=(r1<<1)+rr-(CASAVR-CASMIN); // Neco jako nasobeni |
if (r2>(CASAVR-CASMIN-rr)) r2=(r2<<1)+rr-(CASAVR-CASMIN); |
//!!! pro zatuhle prevodovky |
// r1<<=1; // Rychlost je dvojnasobna |
// r2<<=1; // Rozsah 2 az 184 pro rr=0 |
set_pwm1_duty(r1); // Nastav rychlost motoru |
set_pwm2_duty(r2); |
SetServoQ(cas); |
i2c_start(); // Sonar Ping |
i2c_write(SONAR_ADR); |
i2c_write(0x0); |
i2c_write(0x52); // mereni v us |
i2c_stop(); |
for(n=1;n<=90;n++) // 18ms testovani cary do dalsi korekce serva |
{ |
set_adc_channel(LMAX); |
delay_us(100); |
if(read_adc()<THR) touch|=L_TOUCH; |
set_adc_channel(RMAX); |
delay_us(100); |
if(read_adc()<THR) touch|=R_TOUCH; |
}; |
i2c_start(); // Odraz ze sonaru |
i2c_write(SONAR_ADR); |
i2c_write(0x3); |
i2c_stop(); |
i2c_start(); |
i2c_write(SONAR_ADR+1); |
vzdalenost=i2c_read(0); |
i2c_stop(); |
i2c_start(); // Cteni kompasu |
i2c_write(COMPAS_ADR); |
i2c_write(0x1); // uhel 0-255 |
i2c_stop(); |
i2c_start(); |
i2c_write(COMPAS_ADR+1); |
bearing=i2c_read(0); |
i2c_stop(); |
if(touch==L_TOUCH) visualisation|=0x2; |
if(touch==R_TOUCH) visualisation|=0x1; |
if((touch==B_TOUCH)&&(ridic==pred_carou)) ridic=na_care; |
if((ridic==na_care)&&(touch==0)) break; |
if(ridic==na_care) touch=0; |
disp(visualisation); |
}; |
disp(0xC3); |
set_pwm1_duty(0); //!!! pred zatuhlejma prevodovkama tam bylo 20 a 200 |
set_pwm2_duty(240); |
output_high(MOT_L); |
output_low(MOT_R); |
delay_us(40); |
odocounter=get_timer1(); // Poznamenej aktualni stav odometrie |
while (true) // Znovu se musime dotknout cary |
{ |
for(n=1;n<=90;n++) // 18ms testovani cary do dalsi korekce serva |
{ |
set_adc_channel(LMAX); // Levy UV sensor |
delay_us(100); |
if(read_adc()<THR) // Dotkli jsme se levym senzorem |
{ |
disp(0xE0); |
cas=CASAVR-CASMIN; // nastavime, ze cara je rovne |
goto cara; |
}; |
set_adc_channel(RMAX); // Pravy UV sensor |
delay_us(100); |
if((get_timer1()>=(odocounter+2)) && (read_adc()<THR)) // Pravym senzorem nesmime caru prejet! |
{ |
disp(0x07); |
cas=CASMAX; // kdyz prejedem, tak nastavime, ze cara je vpravo |
goto cara; |
}; |
} |
SetServoQ(CASMIN-5); // max. max. doleva L |
} |
cara: |
output_low(MOT_L); // oba motory vpred |
output_low(MOT_R); |
/roboti/istrobot/camerus/SW/876/robotchallenge/camerus.c |
---|
0,0 → 1,456 |
//********* Robot Camerus pro IstRobot 2007 ************ |
//"$Id: camerus.c 214 2007-03-23 14:55:54Z kakl $" |
//***************************************************** |
#include ".\camerus.h" |
#USE FAST_IO (C) // Brana C je ve FAST_IO modu, aby slo rychle cist z kamery |
// A/D vstupy |
#define RMAX 4 // AN4/RA5 - leve cidlo na vyjeti z cary |
#define LMAX 3 // AN3/RA3 - prave cidlo na vyjeti z cary |
#define CERVENA 2 // AN2/RA2 - cervene kroutitko |
#define ZELENA 1 // AN1/RA0 - zelene kroutitko |
#define MODRA 0 // AN0/RA1 - modre kroutitko |
// I/O |
#define HREF PIN_C5 // Signal HREF z kamery (v H po celou dobu radku) |
#define PIX PIN_C6 // Vstup pro body z kamery (za trivstupim hradlem OR (dig. komparator)) |
#define SERVO PIN_B4 // Vystup na servo (1 az 2ms po cca 20ms (synchronizovano snimkovym kmitoctem)) |
#define MOT_L PIN_B5 // Smer otaceni leveho motoru; druhy pol je RC2 |
#define MOT_R PIN_B6 // Smer otaceni praveho motoru; druhy pol je RC1 |
#define MOT_1 PIN_C1 // PWM vystpy motoru |
#define MOT_2 PIN_C2 // |
#define DATA PIN_B2 // K modulu LEDbar data |
#define CP PIN_B1 // K modulu LEDbar hodiny |
//#define ODO PIN_A4 // Ze snimace z odometrie z praveho kola / nove je to na RC0 na TIMER1 |
// Jeden impuls je 31,25mm |
#define IRRX PIN_B0 // Vstup INT, generuje preruseni pri prekazce |
#define IRTX PIN_B3 // Modulovani vysilaci IR LED na detekci prekazky |
#define PROXIMITY PIN_C7 // Cidlo kratkeho dosahu na cihlu |
#define CASMIN 6 // Rozsah radku snimace |
#define CASMAX 192 |
#define CASAVR ((CASMAX+CASMIN) / 2) |
#define OFFSETO 0x9F //0x9F // Vystredeni serva pro objeti prekazky |
#define TRESHOLD 128 |
#byte INTCON = 0x0B // Interrupt configuration register |
#bit GIE = INTCON.7 |
#bit PEIE = INTCON.6 |
#bit TMR0IE = INTCON.5 |
#bit INT0IE = INTCON.4 |
#bit RBIE = INTCON.3 |
#bit TMR0IF = INTCON.2 |
#bit INT0IF = INTCON.1 |
#bit RBIF = INTCON.0 |
enum stavy {start,rozjezd,jizda,cihla,pocihle,cil}; |
stavy stav; // Kde jsme na trati |
int8 cas; // Cas hrany bila/cerna v radce |
int8 stred; // Vystredeni kolecka |
int16 odocounter; // Zaznamenani aktualniho stavu pocitadla odometrie |
int8 rr; // Promenna na ulozeni Rozumne rychlost |
int8 rrold; |
// Zobrazeni jednoho byte na modulu LEDbar |
inline void disp(int8 x) |
{ |
int n; |
for(n=0;n<=7;n++) |
{ |
if (x & 1 == 1) output_low(DATA); else output_high(DATA); |
output_high(CP); |
x>>=1; |
output_low(CP); |
} |
} |
// Blikani LEDbarem ve stilu Night Rider |
void NightRider(int8 x) |
{ |
int n,i,j; |
for(j=0;j<x;j++) |
{ |
i=0x01; |
for(n=0;n<7;n++) |
{ |
disp(i); |
rotate_left(&i, 1); |
delay_ms(40); |
} |
for(n=0;n<7;n++) |
{ |
disp(i); |
rotate_right(&i, 1); |
delay_ms(40); |
} |
} |
disp(i); |
delay_ms(40); |
i=0; |
disp(i); |
} |
// Brzdeni motorama stridou 1:1 |
void brzda() |
{ |
int8 n,i; |
set_pwm1_duty(0); // vypni PWM |
set_pwm2_duty(0); |
setup_ccp1(CCP_OFF); |
setup_ccp2(CCP_OFF); |
for (n=0;n<200;n++) |
{ |
output_low(MOT_L); |
output_low(MOT_R); |
output_high(MOT_1); |
output_high(MOT_2); |
delay_us(200); |
output_high(MOT_L); |
output_high(MOT_R); |
output_low(MOT_1); |
output_low(MOT_2); |
delay_us(200); |
} |
output_low(MOT_L); // smer vpred |
output_low(MOT_R); |
setup_ccp1(CCP_PWM); // RC1 // Zapni PWM pro motory |
setup_ccp2(CCP_PWM); // RC2 |
} |
void SetServo(int8 angle) |
{ |
int8 n; |
for(n=0; n<14; n++) |
{ |
output_high(SERVO); // Odvysilani impuzu 1 az 2ms pro servo |
delay_us(1000); |
delay_us(stred); |
delay_us(stred); |
delay_us(stred); |
delay_us(angle); |
delay_us(angle); |
output_low(SERVO); |
delay_ms(18); |
} |
} |
inline void SetServoQ(int8 angle) |
{ |
output_high(SERVO); // Odvysilani impuzu 1 az 2ms pro servo |
delay_us(1000); |
delay_us(stred); |
delay_us(stred); |
delay_us(stred); |
delay_us(angle); |
delay_us(angle); |
output_low(SERVO); |
} |
#int_EXT |
EXT_isr() // Preruseni od prekazky |
{ |
set_pwm1_duty(0); // zabrzdi |
set_pwm2_duty(0); |
output_high(MOT_L); |
output_high(MOT_R); |
// Ujistime se, ze prijaty signal je z naseho IR vysilace |
output_high(IRTX); // Vypni LED na detekci prekazky |
delay_ms(2); |
if (!input(IRRX)) // stale nas signal? |
{ |
output_low(MOT_L); // je odraz -> vpred |
output_low(MOT_R); |
return; |
}; |
output_low(IRTX); // Zapni LED na detekci prekazky |
delay_ms(10); |
if (input(IRRX)) // stale nas signal? |
{ |
output_low(MOT_L); // neni odraz -> vpred |
output_low(MOT_R); |
return; |
}; |
SetServo((CASAVR-CASMIN)); // rovne |
delay_ms(100); |
brzda(); |
//!!! if(stav==cihla) while(true); // Zastav na furt, konec drahy |
// if(stav==cihla) return; // Po druhe nic neobjizdej |
// Pozor na rozjezd |
if(stav==jizda) // Objed cihlu |
{ |
#include ".\objizdka_R.c" |
} |
} |
//---------------------------------- MAIN -------------------------------------- |
void main() |
{ |
int8 offset; // Promena pro ulozeni offsetu |
int8 r1; // Rychlost motoru 1 |
int8 r2; // Rychlost motoru 2 |
setup_adc_ports(ALL_ANALOG); // Zapnuti A/D prevodniku pro cteni kroutitek |
setup_adc(ADC_CLOCK_INTERNAL); |
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); // Casovac pro mereni casu hrany W/B v radce |
setup_timer_1(T1_EXTERNAL); // Cita pulzy z odometrie z praveho kola |
setup_timer_2(T2_DIV_BY_16,255,1); // Casovac PWM motoru |
setup_ccp1(CCP_PWM); // RC1 // PWM pro motory |
setup_ccp2(CCP_PWM); // RC2 |
setup_comparator(NC_NC_NC_NC); |
setup_vref(FALSE); |
set_tris_c(0b11111001); // Nastaveni vstup/vystup pro branu C, protoze se nedela automaticky |
set_pwm1_duty(0); // Zastav motory |
set_pwm2_duty(0); |
output_low(MOT_L); // Nastav smer vpred |
output_low(MOT_R); |
output_low(IRTX); // Zapni LED na detekci prekazky |
NightRider(1); // Aby se poznalo, ze byl RESET |
// taky se musi pockat, nez se rozjede kamera, nez se do ni zacnou posilat prikazy |
//... Nastaveni kamery ... |
i2c_start(); // Soft RESET kamery |
i2c_write(0xC0); // Pro single slave musi mit vsechny zapisy adresu C0h |
i2c_write(0x12); // Adresa registru COMH |
i2c_write(0x80 | 0x24); // Zapis ridiciho slova |
i2c_stop(); |
i2c_start(); // BW |
i2c_write(0xC0); |
i2c_write(0x28); |
i2c_write(0b01000001); |
i2c_stop(); |
/* |
i2c_start(); // Contrast (nema podstatny vliv na obraz) |
i2c_write(0xC0); |
i2c_write(0x05); |
i2c_write(0xA0); // 48h |
i2c_stop(); |
i2c_start(); // Band Filter (pokud by byl problem se zarivkama 50Hz) |
i2c_write(0xC0); |
i2c_write(0x2D); |
i2c_write(0x04 | 0x03); |
i2c_stop(); |
*/ |
i2c_start(); // Fame Rate |
i2c_write(0xC0); |
i2c_write(0x2B); |
i2c_write(0x00); // cca 17ms (puvodni hodnota 5Eh = 20ms) |
i2c_stop(); |
i2c_start(); // VSTRT |
i2c_write(0xC0); |
i2c_write(0x19); |
i2c_write(118); // prostredni radka |
i2c_stop(); |
i2c_start(); // VEND |
i2c_write(0xC0); |
i2c_write(0x1A); |
i2c_write(118); |
i2c_stop(); |
NightRider(1); // Musi se dat cas kamere na AGC a AEC |
{ // Mereni expozice |
int8 t1,t2; |
i2c_start(); // Brightness, zacni od uplne tmy |
i2c_write(0xC0); |
i2c_write(0x06); |
i2c_write(0); // 80h default |
i2c_stop(); |
delay_ms(50); |
for(offset=0x04;offset<(255-0x04);offset+=0x04) // Zacni od jasu 10h |
{ |
i2c_start(); // Brightness |
i2c_write(0xC0); |
i2c_write(0x06); |
i2c_write(offset); // 80h default |
i2c_stop(); |
disp(offset); |
delay_ms(50); |
t1=0; |
t2=0; |
while(!input(HREF)); // Cekej nez se zacnou posilat pixely z radky |
delay_ms(5); |
while(!input(HREF)); // Cekej nez se zacnou posilat pixely z radky |
set_timer0(0); // Vynuluj pocitadlo casu |
if(!input(PIX)) continue; |
while(input(PIX)); |
t1=get_timer0(); // Precti cas z citace casu hrany |
set_timer0(0); // Vynuluj pocitadlo casu |
while(!input(PIX)); |
t2=get_timer0(); |
if((t1>60) && (t1<140) && (t2>5) && (t2<=10)) break; // Vidis, co mas? |
delay_ms(2); // Preskoc druhou radku z kamery |
}; |
delay_ms(1000); // Nech chvili na displayi zmerenou hodnotu |
} |
set_adc_channel(CERVENA); // --- Kroutitko pro jas --- |
delay_ms(1); |
offset=read_adc(); |
offset &= 0b11111100; // Dva nejnizsi bity ignoruj |
// offset += 0x70; // Jas nebude nikdy nizsi |
disp(offset); |
i2c_start(); // Brightness |
i2c_write(0xC0); |
i2c_write(0x06); |
i2c_write(offset); // 80h default |
i2c_stop(); |
delay_ms(1000); // Nech hodnotu chvili na displayi |
set_adc_channel(ZELENA); // --- Kroutitko pro vykon motoru --- |
delay_ms(1); |
rr=read_adc()>>2; // 0-31 // Pokud by se zvetsil rozsah, tak zkontrolovat jakonasobeni !!! |
rrold=rr; |
cas=CASAVR-CASMIN; // Inicializace promenych, aby neslo servo za roh |
// a aby se to rozjelo jeste dneska |
stav=start; // Jsme na startu |
set_timer1(0); // Vynuluj citac odometrie |
// ........................... Hlavni smycka ................................ |
while(true) |
{ |
int8 pom; |
int8 n; |
next_snap: |
pom=0; |
disable_interrupts(GLOBAL); //----------------------- Critical |
while(input(HREF)); // Preskoc 1. radku |
while(!input(HREF)); // Cekej nez se zacnou posilat pixely z 2. radky |
set_timer0(0); // Vynuluj pocitadlo casu |
while(input(HREF)) // Po dobu vysilani radky cekej na hranu W/B |
{ |
// !!!!Dodelat rozpoznani cerne cary napric pro zastaveni ? |
if(!input(PIX)) // Pokud se X-krat za sebou precetla CERNA |
if(!input(PIX)) |
// if(!input(PIX)) |
{ |
pom=get_timer0(); // Precti cas z citace casu hrany |
break; |
}; |
}; |
while(input(HREF)); // Pockej na shozeni signalu HREF |
if((pom<CASMAX) && (pom>CASMIN)) cas=pom; // Orizni konce radku |
// Na konci obrazovaho radku to blbne. Jednak chyba od apertury |
// a vubec to nejak na kraji nefunguje. |
output_high(SERVO); // Odvysilani impuzu 1 az 2ms pro servo |
delay_us(1000); |
delay_us(stred); |
delay_us(stred); |
delay_us(stred); |
delay_us(cas); |
delay_us(cas); |
output_low(SERVO); |
// Elektronicky diferencial |
if(cas<CASAVR) {r1=cas-CASMIN; r2=CASAVR-CASMIN;}; // Normovani vystupni hodnoty radkoveho snimace |
if(cas==CASAVR) {r1=cas-CASMIN; r2=cas-CASMIN;}; // pro rizeni rychlosti motoru |
if(cas>CASAVR) {r1=CASAVR-CASMIN; r2=CASMAX-cas;}; // Rozsah 1 az 92 |
enable_interrupts(GLOBAL); //----------------------- Critical |
if (r1>(CASAVR-CASMIN-rr)) r1=(r1<<1)+rr-(CASAVR-CASMIN); // Neco jako nasobeni |
if (r2>(CASAVR-CASMIN-rr)) r2=(r2<<1)+rr-(CASAVR-CASMIN); |
// r1<<=1; // Rychlost je dvojnasobna |
// r2<<=1; // Rozsah 2 az 184 |
/* Nerozumna rychlost po cihle |
if ((stav==cihla)&&(get_timer1()>(odocounter+5))) // Snizime rychlost po ujeti |
{ |
rr=rrold; |
stav=pocihle; |
}; |
*/ |
if ((stav==jizda)||(stav==cihla)||(stav==rozjezd)) //||(stav==pocihle)) // Jizda |
{ |
set_pwm1_duty(r1); |
set_pwm2_duty(r2); |
} |
else |
{ |
set_pwm1_duty(0); // Zastaveni |
set_pwm2_duty(0); |
}; |
if((stav==rozjezd)&&(get_timer1()>10)) // musi ujet alespon 31cm |
{ |
ext_int_edge(H_TO_L); // Nastav podminky preruseni od cihly |
INT0IF=0; // Zruseni predesle udalosti od startera |
enable_interrupts(INT_EXT); |
enable_interrupts(GLOBAL); |
stav=jizda; |
}; |
if(stav==start) // Snimkuje, toci servem a ceka na start |
{ |
set_adc_channel(MODRA); // Kroutitko na vystredeni predniho kolecka |
Delay_ms(1); |
stred=read_adc(); |
if(!input(PROXIMITY)) |
{ |
disp(0x80); |
while(input(PROXIMITY)); // Cekej, dokud starter neda ruku pryc |
set_timer1(0); // Vynuluj citac odometrie |
set_pwm1_duty(255); // Rychly rozjezd !!! Zkontrolovat na oscyloskopu |
set_pwm2_duty(255); |
disp(0x01); |
while(get_timer1()<=4) // Ujed alespon 12cm |
{ |
set_adc_channel(LMAX); // Levy UV sensor |
delay_us(40); |
if(read_adc()<TRESHOLD) {cas=CASMIN; break;}; // Prejeli jsme caru vlevo |
set_adc_channel(RMAX); // Pravy UV sensor |
delay_us(40); |
if(read_adc()<TRESHOLD) {cas=CASMAX; break;}; // Prejeli jsme caru vpravo |
cas=CASAVR-CASMIN; // Cara je rovne |
}; |
stav=rozjezd; |
}; |
} |
pom=0x80; // Zobrazeni pozice cary na displayi |
for(n=CASMAX/8; n<cas; n+=CASMAX/8) pom>>=1; |
disp(pom); |
while(true) // Ve zbytku casu snimku cti krajni UV senzory |
{ |
set_adc_channel(LMAX); // Levy UV sensor |
for(n=0;n<20;n++) if(input(HREF)) goto next_snap; |
if(read_adc()<TRESHOLD) cas=CASMIN; |
set_adc_channel(RMAX); // Pravy UV sensor |
for(n=0;n<20;n++) if(input(HREF)) goto next_snap; |
if(read_adc()<TRESHOLD) cas=CASMAX; |
}; |
} |
} |
/roboti/istrobot/camerus/SW/876/robotchallenge/objizdka_R.c |
---|
0,0 → 1,167 |
// **** Objeti cihly vpravo **** RRRR |
int8 n,i; |
int16 j; |
set_adc_channel(RMAX); |
SetServo(CASMIN); // max. doleva L |
set_pwm1_duty(0); // vzad |
set_pwm2_duty(0); |
output_low(MOT_L); |
output_high(MOT_R); |
odocounter=get_timer1(); // Poznamenej aktualni stav odometrie |
while(get_timer1()<(odocounter+8)); // Popojed definovanou vzdalenost |
set_pwm1_duty(0); // reverz (zabrzdi) |
set_pwm2_duty(255); |
output_low(MOT_L); |
output_low(MOT_R); |
delay_ms(215); |
brzda(); |
disp(1); |
SetServo((CASAVR-CASMIN)); // rovne S |
set_pwm1_duty(160); // vpred |
set_pwm2_duty(160); |
output_low(MOT_L); |
output_low(MOT_R); |
odocounter=get_timer1(); // Poznamenej aktualni stav odometrie |
for(n=1;n<=7;n++) |
{ |
while(get_timer1()<(odocounter+n)); // Popojed |
SetServoQ((CASAVR-CASMIN)); |
}; |
i=0; |
disp(2); |
set_pwm1_duty(130); |
set_pwm2_duty(140); |
odocounter=get_timer1(); |
for(n=1;n<=10;n++) |
{ |
while(get_timer1()<(odocounter+n)); |
SetServoQ((CASAVR-CASMIN)-i); |
set_pwm1_duty(130-i); |
i+=8; |
}; |
disp(3); |
odocounter=get_timer1(); |
for(n=1;n<=7;n++) |
{ |
while(get_timer1()<(odocounter+n)); |
SetServoQ((CASAVR-CASMIN)-i); |
set_pwm1_duty(130-i); |
i-=8; |
}; |
disp(4); |
odocounter=get_timer1(); |
for(n=1;n<=7;n++) |
{ |
while(get_timer1()<(odocounter+n)); |
SetServoQ((CASAVR-CASMIN)-i); |
set_pwm1_duty(130-i); |
i+=8; |
}; |
disp(5); |
odocounter=get_timer1(); |
//!!!!for(n=1;n<=5;n++) |
for(n=1;n<=4;n++) |
{ |
while(get_timer1()<(odocounter+n)); |
SetServoQ((CASAVR-CASMIN)-i); |
set_pwm1_duty(130-i); |
i-=16; |
}; |
disp(6); |
set_pwm1_duty(80); // vpred |
set_pwm2_duty(80); |
output_low(MOT_L); |
output_low(MOT_R); |
odocounter=get_timer1(); // Poznamenej aktualni stav odometrie |
for(n=1;n<=3;n++) |
{ |
while(get_timer1()<(odocounter+n)); |
SetServoQ((CASAVR-CASMIN)); |
}; |
disp(7); |
while(true) |
{ |
set_adc_channel(LMAX); // Levy UV sensor |
delay_us(40); |
if(read_adc()<TRESHOLD) {delay_us(600); if(read_adc()<TRESHOLD) {cas=CASMIN; break;}; }; // Prejeli jsme caru vlevo |
set_adc_channel(RMAX); // Pravy UV sensor |
delay_us(40); |
if(read_adc()<TRESHOLD) {delay_us(600); if(read_adc()<TRESHOLD) {cas=CASMAX; break;}; }; // Prejeli jsme caru vpravo |
} |
if(cas==CASMIN) |
{ |
set_adc_channel(RMAX); // Pravy UV sensor |
for(j=0;j<10000;j++) |
{ |
if(input(HREF)) {SetServoQ(CASMIN); while(input(HREF));}; // doleva |
if (read_adc()<TRESHOLD) break; |
} |
} |
else |
{ |
set_adc_channel(LMAX); // Levy UV sensor |
for(j=0;j<10000;j++) |
{ |
if(input(HREF)) {SetServoQ(CASMAX); while(input(HREF));}; // doprava |
if (read_adc()<TRESHOLD) break; |
} |
} |
set_adc_channel(RMAX); // Pravy UV sensor |
set_pwm1_duty(0); // zabrzdi |
set_pwm2_duty(0); |
output_high(MOT_L); |
output_high(MOT_R); |
SetServo(CASAVR-CASMIN); // doprostred |
delay_ms(100); |
brzda(); |
// Tady jsou s velkou pravdepodobnosti obe cidla za carou a jsme kolmo k care |
SetServo(CASMIN); // max. doleva L |
set_pwm1_duty(0); // vzad |
set_pwm2_duty(0); |
output_low(MOT_L); |
output_high(MOT_R); |
while (read_adc()>TRESHOLD); |
odocounter=get_timer1(); // Poznamenej aktualni stav odometrie |
while(get_timer1()<(odocounter+4)); // Popojed definovanou vzdalenost |
set_pwm1_duty(0); // reverz (zabrzdi) |
set_pwm2_duty(255); |
output_low(MOT_L); |
output_low(MOT_R); |
SetServo(CASAVR-CASMIN); // doprostred |
delay_ms(100); |
brzda(); |
set_pwm1_duty(255); // max. vpred |
set_pwm2_duty(255); |
output_low(MOT_L); |
output_low(MOT_R); |
odocounter=get_timer1(); // Poznamenej aktualni stav odometrie |
while(get_timer1()<(odocounter+2)) // Ujed kousek |
{ |
set_adc_channel(LMAX); // Levy UV sensor |
delay_us(40); |
if(read_adc()<TRESHOLD) {cas=CASMIN; break;}; // Prejeli jsme caru vlevo |
set_adc_channel(RMAX); // Pravy UV sensor |
delay_us(40); |
if(read_adc()<TRESHOLD) {cas=CASMAX; break;}; // Prejeli jsme caru vpravo |
cas=CASAVR-CASMIN; // Cara je rovne |
}; |
stav=cihla; // Stav po objeti cihly, uz zadna cihla asi nebude |
//odocounter=get_timer1(); // Poznamenej aktualni stav odometrie |
//rr=60; // Nerozumna rychlost pro rozjeti |
/roboti/istrobot/camerus/SW/876/zatuhle_prevodovky/camerus.c |
---|
0,0 → 1,632 |
//********* Robot Camerus pro IstRobot 2007 ************ |
//"$Id: camerus.c 252 2007-04-24 08:53:01Z kakl $" |
//***************************************************** |
#include ".\camerus.h" |
#USE FAST_IO (C) // Brana C je ve FAST_IO modu, aby slo rychle cist z kamery |
// Rychlostni konstanty |
#define RR_CIHLA 25 // Rozumna rychlost pro objizdeni cihly |
#define RR_PRERUSENI 20 // Rozumna rychlost pro priblizeni se k preruseni |
#define BRZDNA_DRAHA 0x20 // Jak daleko pred problemem se zacne brzdit |
#define TUHOS 100 // Jak dlouho se bude couvat po narazu na naraznik |
#define ODODO_CIHLA 0xFFF |
#define ODODO_TUNEL 0xFFF |
#define ODODO_PRERUSENI 0xFFF |
// Adresy IIC periferii |
#define COMPAS_ADR 0xC0 |
#define CAMERA_ADR 0xDC |
#define SONAR_ADR 0xE0 |
// A/D vstupy |
#define RMAX 4 // AN4/RA5 - leve cidlo na vyjeti z cary |
#define LMAX 3 // AN3/RA3 - prave cidlo na vyjeti z cary |
#define CERVENA 2 // AN2/RA2 - cervene kroutitko |
#define ZELENA 1 // AN1/RA0 - zelene kroutitko |
#define MODRA 0 // AN0/RA1 - modre kroutitko |
// I/O |
#define HREF PIN_C5 // Signal HREF z kamery (v H po celou dobu radku) |
#define PIX PIN_C6 // Vstup pro body z kamery (za trivstupim hradlem OR (dig. komparator)) |
#define SERVO PIN_B4 // Vystup na servo (1 az 2ms po cca 20ms (synchronizovano snimkovym kmitoctem)) |
#define MOT_L PIN_B5 // Smer otaceni leveho motoru; druhy pol je RC2 |
#define MOT_R PIN_B6 // Smer otaceni praveho motoru; druhy pol je RC1 |
#define MOT_1 PIN_C1 // PWM vystpy motoru |
#define MOT_2 PIN_C2 // |
#define DATA PIN_B2 // K modulu LEDbar data |
#define CP PIN_B1 // K modulu LEDbar hodiny |
//#define ODO PIN_C0 // Ze snimace z odometrie z praveho kola na TIMER1 |
// Jeden impuls je 31,25mm |
#define IRRX !input(PIN_B0) // Vstup INT, generuje preruseni pri prekazce |
#define IRTX PIN_B3 // Modulovani vysilaci IR LED na detekci prekazky |
#define PROXIMITY PIN_C7 // Cidlo kratkeho dosahu na cihlu |
#define BUMPER !input(PIN_A4) // Naraznik |
#define CASMIN 6 // Rozsah radku snimace |
#define CASMAX 192 |
#define CASAVR ((CASMAX+CASMIN) / 2) |
#define EEMAX 255 // Konec EEPROM |
#define MAXLOG 0x10 // Maximalni pocet zaznamu v logu |
#if MAXLOG>(EEMAX/3) |
#error Prekrocena velikost EEPROM |
#endif |
#define OFFSETO 0x9F //0x9F // Vystredeni serva pro objeti prekazky |
#define THR 90 // Threshold pro UV cidla na caru |
#byte INTCON = 0x0B // Interrupt configuration register |
#bit GIE = INTCON.7 |
#bit PEIE = INTCON.6 |
#bit TMR0IE = INTCON.5 |
#bit INT0IE = INTCON.4 |
#bit RBIE = INTCON.3 |
#bit TMR0IF = INTCON.2 |
#bit INT0IF = INTCON.1 |
#bit RBIF = INTCON.0 |
enum stavy {start,rozjezd,jizda,cihla,pocihle,cil}; |
stavy stav; // Kde jsme na trati |
int8 cas; // Cas hrany bila/cerna v radce |
int8 stred; // Vystredeni kolecka |
int16 odocounter; // Zaznamenani aktualniho stavu pocitadla odometrie |
int16 last_log_odo; // Posledni stav odometrie poznamenany do logu |
int16 last_log; // Cislo posledniho zaznamu v logu v EEPROM |
int8 bb_h[MAXLOG]; // Cerna skrinka MSB |
int8 bb_l[MAXLOG]; // Cerna skrinka LSB |
int8 bb_f[MAXLOG]; // Cerna skrinka priznak (typ zaznamu) |
int8 log; // Pocitadlo pro cernou skrinku |
int8 rr; // Promenna na ulozeni Rozumne rychlost |
int8 rrold; |
int16 odo_preruseni, odo_cihla, odo_tunel; // Problemy na trati |
// Zobrazeni jednoho byte na modulu LEDbar |
inline void disp(int8 x) |
{ |
int n; |
for(n=0;n<=7;n++) |
{ |
if (bit_test(x,0)) output_low(DATA); else output_high(DATA); |
output_high(CP); |
x>>=1; |
output_low(CP); |
} |
} |
// Blikani LEDbarem ve stilu Night Rider |
void NightRider(int8 x) |
{ |
int n,i,j; |
for(j=0;j<x;j++) |
{ |
i=0x01; |
for(n=0;n<7;n++) |
{ |
disp(i); |
rotate_left(&i, 1); |
delay_ms(40); |
} |
for(n=0;n<7;n++) |
{ |
disp(i); |
rotate_right(&i, 1); |
delay_ms(40); |
} |
} |
disp(i); |
delay_ms(40); |
i=0; |
disp(i); |
} |
// Zaznam LOGu do EEPROM |
void SaveLog(int8 log) |
{ |
int8 n,i; |
i=0; |
for(n=0;n<=(log*3);n+=3) // Ulozeni Black Boxu do EEPROM |
{ |
write_eeprom(n,bb_f[i]); |
write_eeprom(n+1,bb_h[i]); |
write_eeprom(n+2,bb_l[i]); |
i++; |
}; |
write_eeprom(EEMAX,log); // Zapis poctu zaznamu na konec EEPROM |
} |
// Zaznam do Logu do RAM |
void LogLog(int8 flag, int16 gap) |
{ |
int16 timer_pom; |
timer_pom=get_timer1(); // Timer se musi vycist atomicky |
bb_l[log]=make8(timer_pom,0); // Zaznam |
bb_h[log]=make8(timer_pom,1); |
bb_f[log]=flag; // Typ zaznamu |
if(log<MAXLOG) log++; // Ukazatel na dalsi zaznam |
last_log_odo=timer_pom+gap; // Dalsi mereni nejdrive po ujeti def. vzdalenosti |
rr=rrold; // Problem skoncil, znovu jed Rozumnou Rychlosti |
} |
void ReadBlackBox() |
{ |
last_log=read_eeprom(EEMAX); // Kolik zaznamu mame od minule poznamenano? |
{ |
int8 n,i; |
i=0; |
for(n=0;n<=last_log;n++) |
{ |
if(read_eeprom(i)==0) odo_tunel=MAKE16(read_eeprom(i+2),read_eeprom(i+1)); |
if(read_eeprom(i)==0xFF) odo_cihla=MAKE16(read_eeprom(i+2),read_eeprom(i+1)); |
if((read_eeprom(i)>0) && (read_eeprom(i)<0xFF)) odo_preruseni=MAKE16(read_eeprom(i+2),read_eeprom(i+1)); |
} |
} |
} |
// Brzdeni motorama stridou 1:1 |
void brzda() |
{ |
int8 n,i; |
set_pwm1_duty(0); // vypni PWM |
set_pwm2_duty(0); |
setup_ccp1(CCP_OFF); |
setup_ccp2(CCP_OFF); |
for (n=0;n<200;n++) |
{ |
output_low(MOT_L); |
output_low(MOT_R); |
output_high(MOT_1); |
output_high(MOT_2); |
delay_us(200); |
output_high(MOT_L); |
output_high(MOT_R); |
output_low(MOT_1); |
output_low(MOT_2); |
delay_us(200); |
} |
output_low(MOT_L); // smer vpred |
output_low(MOT_R); |
setup_ccp1(CCP_PWM); // RC1 // Zapni PWM pro motory |
setup_ccp2(CCP_PWM); // RC2 |
} |
void SetServo(int8 angle) |
{ |
int8 n; |
for(n=0; n<10; n++) |
{ |
output_high(SERVO); // Odvysilani impuzu 1 az 2ms pro servo |
delay_us(1000); |
delay_us(stred); |
delay_us(stred); |
delay_us(stred); |
delay_us(angle); |
delay_us(angle); |
output_low(SERVO); |
delay_ms(18); |
} |
} |
inline void SetServoQ(int8 angle) |
{ |
output_high(SERVO); // Odvysilani impuzu 1 az 2ms pro servo |
delay_us(1000); |
delay_us(stred); |
delay_us(stred); |
delay_us(stred); |
delay_us(angle); |
delay_us(angle); |
output_low(SERVO); |
} |
// Couvni po narazu na naraznik |
inline void bum() |
{ |
set_pwm1_duty(0); // couvni, rovne dozadu |
set_pwm2_duty(0); |
output_high(MOT_L); |
output_high(MOT_R); |
disp(0xA5); |
SetServo(CASAVR-CASMIN); |
} |
#include ".\diag.c" |
//---------------------------- INT -------------------------------- |
#int_EXT |
EXT_isr() // Preruseni od prekazky |
{ |
unsigned int8 bearing, bearing_offset, delta_bearing; |
set_pwm1_duty(0); // zabrzdi levym kolem, prave vypni |
set_pwm2_duty(0); |
output_high(MOT_L); |
output_low(MOT_R); |
// Ujistime se, ze prijaty signal je z naseho IR vysilace |
output_high(IRTX); // Vypni LED na detekci prekazky |
delay_ms(2); |
if (IRRX) // stale nas signal? |
{ |
output_low(MOT_L); // je odraz -> vpred |
output_low(MOT_R); |
return; |
}; |
output_low(IRTX); // Zapni LED na detekci prekazky |
i2c_start(); // Cteni kompasu |
i2c_write(COMPAS_ADR); |
i2c_write(0x1); // 0-255 (odpovida 0-359) |
i2c_stop(); |
i2c_start(); |
i2c_write(COMPAS_ADR+1); |
bearing_offset=i2c_read(0); // Poznamenej hodnotu pred cihlou |
i2c_stop(); |
delay_ms(9); |
if (!IRRX) // stale nas signal? |
{ |
output_low(MOT_L); // neni odraz -> vpred |
output_low(MOT_R); |
return; |
}; |
rr=rrold; // Po cihle se pojede opet Rozumnou Rychlosti |
if(stav!=cihla) |
{ |
LogLog(0xFF,3); // Cihla |
}; |
//!!! if(stav==cihla) while(true); // Zastav na furt, konec drahy |
// if(stav==cihla) return; // Po druhe nic neobjizdej |
// Pozor na rozjezd |
if((stav==jizda)||(stav==cihla)) // Objed cihlu |
{ |
#include ".\objizdka_L.c" |
}; |
last_log_odo=get_timer1()+16; // Pul metru po cihle nezaznamenavej do LOGu |
} |
//---------------------------------- MAIN -------------------------------------- |
void main() |
{ |
int8 offset; // Promena pro ulozeni offsetu |
int8 r1; // Rychlost motoru 1 |
int8 r2; // Rychlost motoru 2 |
setup_adc_ports(ALL_ANALOG); // Zapnuti A/D prevodniku pro cteni kroutitek |
setup_adc(ADC_CLOCK_INTERNAL); |
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); // Casovac pro mereni casu hrany W/B v radce |
setup_timer_1(T1_EXTERNAL); // Cita pulzy z odometrie z praveho kola |
//!!! setup_timer_2(T2_DIV_BY_16,255,1); // Casovac PWM motoru |
setup_timer_2(T2_DIV_BY_4,255,1); // Casovac PWM motoru |
setup_ccp1(CCP_PWM); // RC1 // PWM pro motory |
setup_ccp2(CCP_PWM); // RC2 |
setup_comparator(NC_NC_NC_NC); |
setup_vref(FALSE); |
set_tris_c(0b11111001); // Nastaveni vstup/vystup pro branu C, protoze se to nedela automaticky |
set_pwm1_duty(0); // Zastav motory |
set_pwm2_duty(0); |
output_low(MOT_L); // Nastav smer vpred |
output_low(MOT_R); |
disp(0); // Zhasni LEDbar |
if(BUMPER) // Kdyz nekdo na zacatku drzi naraznik, vymaz log a spust diagnostiku |
{ |
diag(); |
} |
output_low(IRTX); // Zapni LED na detekci prekazky |
NightRider(1); // Zablikej, aby se poznalo, ze byl RESET |
// Zaroven se musi pockat, nez se rozjede kamera, nez se do ni zacnou posilat prikazy |
//... Nastaveni sonaru ... |
i2c_start(); |
i2c_write(SONAR_ADR); |
i2c_write(0x02); // dosah |
i2c_write(0x03); // n*43mm |
i2c_stop(); |
i2c_start(); |
i2c_write(SONAR_ADR); |
i2c_write(0x01); // zesileni |
i2c_write(0x01); // male, pro eliminaci echa z minuleho mereni |
i2c_stop(); |
//... Nastaveni kamery ... |
i2c_start(); // Soft RESET kamery |
i2c_write(CAMERA_ADR); // Adresa kamery |
i2c_write(0x12); // Adresa registru COMH |
i2c_write(0x80 | 0x24); // Zapis ridiciho slova |
i2c_stop(); |
i2c_start(); // BW |
i2c_write(CAMERA_ADR); |
i2c_write(0x28); |
i2c_write(0b01000001); |
i2c_stop(); |
/* |
i2c_start(); // Contrast (nema podstatny vliv na obraz) |
i2c_write(CAMERA_ADR); |
i2c_write(0x05); |
i2c_write(0xA0); // 48h |
i2c_stop(); |
i2c_start(); // Band Filter (pokud by byl problem se zarivkama 50Hz) |
i2c_write(CAMERA_ADR); |
i2c_write(0x2D); |
i2c_write(0x04 | 0x03); |
i2c_stop(); |
*/ |
i2c_start(); // Fame Rate |
i2c_write(CAMERA_ADR); |
i2c_write(0x2B); |
i2c_write(0x00); // cca 17ms (puvodni hodnota 5Eh = 20ms) |
i2c_stop(); |
i2c_start(); // VSTRT |
i2c_write(CAMERA_ADR); |
i2c_write(0x19); |
i2c_write(118); // prostredni radka |
i2c_stop(); |
i2c_start(); // VEND |
i2c_write(CAMERA_ADR); |
i2c_write(0x1A); |
i2c_write(118); |
i2c_stop(); |
NightRider(1); // Musi se dat cas kamere na AGC a AEC |
{ // Mereni expozice |
int8 t1,t2; |
i2c_start(); // Brightness, zacni od uplne tmy |
i2c_write(CAMERA_ADR); |
i2c_write(0x06); |
i2c_write(0); // 80h default |
i2c_stop(); |
delay_ms(50); |
for(offset=0x04;offset<(255-0x04);offset+=0x04) // Zacni od jasu 10h |
{ |
i2c_start(); // Brightness |
i2c_write(CAMERA_ADR); |
i2c_write(0x06); |
i2c_write(offset); // 80h default |
i2c_stop(); |
disp(offset); |
delay_ms(50); |
t1=0; |
t2=0; |
while(!input(HREF)); // Cekej nez se zacnou posilat pixely z radky |
delay_ms(5); |
while(!input(HREF)); // Cekej nez se zacnou posilat pixely z radky |
set_timer0(0); // Vynuluj pocitadlo casu |
if(!input(PIX)) continue; |
while(input(PIX)); |
t1=get_timer0(); // Precti cas z citace casu hrany |
set_timer0(0); // Vynuluj pocitadlo casu |
while(!input(PIX)); |
t2=get_timer0(); |
if((t1>60) && (t1<140) && (t2>5) && (t2<=10)) break; // Vidis, co mas? |
delay_ms(2); // Preskoc druhou radku z kamery |
}; |
delay_ms(1000); // Nech chvili na displayi zmerenou hodnotu |
} |
set_adc_channel(CERVENA); // --- Kroutitko pro jas --- |
delay_ms(1); |
offset=read_adc(); |
offset &= 0b11111100; // Dva nejnizsi bity ignoruj |
// offset += 0x70; // Jas nebude nikdy nizsi |
disp(offset); |
i2c_start(); // Brightness |
i2c_write(CAMERA_adr); |
i2c_write(0x06); |
i2c_write(offset); // 80h default |
i2c_stop(); |
delay_ms(1000); // Nech hodnotu chvili na displayi |
set_adc_channel(ZELENA); // --- Kroutitko pro vykon motoru --- |
delay_ms(1); |
//!!! rr=read_adc()>>2; // 0-63 // Pokud by se zvetsil rozsah, tak zkontrolovat jakonasobeni! |
rr=read_adc()>>3; // 0-31 // Pokud by se zvetsil rozsah, tak zkontrolovat jakonasobeni! |
rrold=rr; |
cas=CASAVR-CASMIN; // Inicializace promenych, aby neslo servo za roh |
// a aby se to rozjelo jeste dneska |
stav=start; // Jsme na startu |
set_timer1(0); // Vynuluj citac odometrie |
log=0; // Zacatek logu v cerne skrince |
last_log_odo=0; // Posledni zaznam odometrie do logu |
// ReadBlackBox(); // Vycteni zaznamu z Black Boxu |
odo_cihla=ODODO_CIHLA-BRZDNA_DRAHA; |
odo_tunel=ODODO_TUNEL-BRZDNA_DRAHA; |
odo_preruseni=ODODO_PRERUSENI-BRZDNA_DRAHA; |
// ........................... Hlavni smycka ................................ |
while(true) |
{ |
int8 pom; |
int8 n; |
int8 gap; |
int16 ododo; |
gap=0; // Vynuluj pocitadlo preruseni |
next_snap: |
pom=0; |
disable_interrupts(GLOBAL); //----------------------- Critical Section |
while(input(HREF)); // Preskoc 1. radku |
while(!input(HREF)); // Cekej nez se zacnou posilat pixely z 2. radky |
set_timer0(0); // Vynuluj pocitadlo casu |
while(input(HREF)) // Po dobu vysilani radky cekej na hranu W/B |
{ |
// !!!!Dodelat rozpoznani cerne cary napric pro zastaveni ? |
if(!input(PIX)) // Pokud se X-krat za sebou precetla CERNA |
if(!input(PIX)) |
// if(!input(PIX)) |
{ |
pom=get_timer0(); // Precti cas z citace casu hrany |
break; |
}; |
}; |
while(input(HREF)); // Pockej na shozeni signalu HREF |
if((pom<CASMAX) && (pom>CASMIN)) cas=pom; // Orizni konce radku |
// Na konci obrazovaho radku to blbne. Jednak chyba od apertury |
// a vubec to nejak na kraji nefunguje. |
output_high(SERVO); // Odvysilani impuzu 1 az 2ms pro servo |
delay_us(1000); |
delay_us(stred); |
delay_us(stred); |
delay_us(stred); |
delay_us(cas); |
delay_us(cas); |
output_low(SERVO); |
// Elektronicky diferencial 1. cast |
if(cas<CASAVR) {r1=cas-CASMIN; r2=CASAVR-CASMIN;}; // Normovani vystupni hodnoty radkoveho snimace |
if(cas==CASAVR) {r1=cas-CASMIN; r2=cas-CASMIN;}; // pro rizeni rychlosti motoru |
if(cas>CASAVR) {r1=CASAVR-CASMIN; r2=CASMAX-cas;}; // Rozsah 1 az 92 |
enable_interrupts(GLOBAL); //----------------------- End Critical Section |
if(pom==0) // Kamera nevidi caru, poznamenej to do logu |
{ |
if((cas>(CASMIN+30))&&(cas<(CASMAX-30))) // Nebyla minule cara moc u kraje? |
if(last_log_odo<get_timer1()) // Aby nebyly zaznamy v logu prilis huste, musi se napred neco ujet od minuleho zaznamu |
{ |
gap++; |
} |
} |
else |
{ |
if(gap>=2) // Trva preruseni cary alespon 2 snimky? |
{ |
LogLog(gap,8); // Dalsi mereni nejdrive po ujeti 24 cm |
rr=rrold; // Preruseni cary skoncilo, znovu jed Rozumnou Rychlosti |
} |
gap=0; |
}; |
if(input(PROXIMITY) && ((stav==jizda)||(stav==cihla))) // Tunel |
{ |
if(last_log_odo<get_timer1()) // Aby nebyly zaznamy v logu prilis huste, musi se napred neco ujet od minuleho zaznamu |
{ |
LogLog(0,16); // Priznak tunelu; dalsi mereni nejdrive po ujeti 48 cm |
rr=rrold; // Vjeli jsme do tunelu, znovu jed rychle |
} |
}; |
//ODODO |
ododo=get_timer1(); |
if((ododo>odo_preruseni)&&(ododo<(odo_preruseni+8))) rr=RR_PRERUSENI; |
if((ododo>odo_cihla)&&(ododo<(odo_cihla+8))) rr=RR_PRERUSENI; |
if((ododo>odo_tunel)&&(ododo<(odo_tunel+8))) rr=RR_PRERUSENI; |
// Elektronicky diferencial 2. cast |
if (r1>(CASAVR-CASMIN-rr)) r1=(r1<<1)+rr-(CASAVR-CASMIN); // Neco jako nasobeni |
if (r2>(CASAVR-CASMIN-rr)) r2=(r2<<1)+rr-(CASAVR-CASMIN); // rozsah 1 az 92 pro rr=0 // rozsah 1 az 154 pro rr=63 |
//!!! pro zatuhle prevodovky |
r1<<=1; // Rychlost je dvojnasobna |
r2<<=1; // Rozsah 2 az 184 pro rr=0 |
if ((stav==jizda)||(stav==cihla)||(stav==rozjezd)) //||(stav==pocihle)) // Jizda |
{ |
set_pwm1_duty(r1); |
set_pwm2_duty(r2); |
} |
else |
{ |
set_pwm1_duty(0); // Zastaveni |
set_pwm2_duty(0); |
}; |
if((stav==rozjezd)&&(get_timer1()>10)) // musi ujet alespon 31cm |
{ |
ext_int_edge(H_TO_L); // Nastav podminky preruseni od cihly |
INT0IF=0; // Zruseni predesle udalosti od startera |
enable_interrupts(INT_EXT); |
enable_interrupts(GLOBAL); |
stav=jizda; |
}; |
if(stav==start) // Snimkuje, toci servem a ceka na start |
{ |
set_adc_channel(MODRA); // Kroutitko na vystredeni predniho kolecka |
Delay_ms(1); |
stred=read_adc(); |
if(!input(PROXIMITY)) |
{ |
disp(0x80); |
while(input(PROXIMITY)); // Cekej, dokud starter neda ruku pryc |
set_timer1(0); // Vynuluj citac odometrie |
set_pwm1_duty(255); // Rychly rozjezd !!! Zkontrolovat na oscyloskopu |
set_pwm2_duty(255); |
disp(0x01); |
while(get_timer1()<=4) // Ujed alespon 12cm |
{ |
set_adc_channel(LMAX); // Levy UV sensor |
delay_us(40); |
if(read_adc()<THR) {cas=CASMIN; break;}; // Prejeli jsme caru vlevo |
set_adc_channel(RMAX); // Pravy UV sensor |
delay_us(40); |
if(read_adc()<THR) {cas=CASMAX; break;}; // Prejeli jsme caru vpravo |
cas=CASAVR-CASMIN; // Cara je rovne |
}; |
stav=rozjezd; |
}; |
} |
pom=0x80; // Zobrazeni pozice cary na displayi |
for(n=CASMAX/8; n<cas; n+=CASMAX/8) pom>>=1; |
disp(pom); |
while(true) // Ve zbytku casu snimku cti krajni UV senzory a naraznik |
{ |
if(BUMPER) // Sakra, do neceho jsme narazili a nevideli jsme to! |
{ |
bum(); |
SaveLog(log-1); // Zapis Black Boxu do EEPROM |
delay_ms(TUHOS); //!!! Zatuhle prevodovky |
set_pwm1_duty(200); // pomalu vpred |
set_pwm2_duty(200); |
output_low(MOT_L); |
output_low(MOT_R); |
cas=CASAVR-CASMIN; |
}; |
set_adc_channel(LMAX); // Levy UV sensor |
for(n=0;n<20;n++) if(input(HREF)) goto next_snap; |
if(read_adc()<THR) cas=CASMIN; |
set_adc_channel(RMAX); // Pravy UV sensor |
for(n=0;n<20;n++) if(input(HREF)) goto next_snap; |
if(read_adc()<THR) cas=CASMAX; |
}; |
} |
} |
/roboti/istrobot/camerus/SW/876/zatuhle_prevodovky/diag.c |
---|
0,0 → 1,67 |
//--- Diagnostika cidel a vymazani EEPROM --- |
void diag() |
{ |
int8 n; |
// Vymaz Black Box v EEPROM |
for(n=0;n<255;n++) write_eeprom(n,0); |
bb_l[0]=0; // Zapis na pozici 0 vzdalenost 0 |
bb_h[0]=0; |
SaveLog(0); // Zapis do EEPROM pocet zaznamu 0, tedy jeden zaznam |
for(n=0;n<=4;n++) |
{ |
disp(0x55); // Blikni pro potvrzeni |
delay_ms(200); |
disp(0xAA); |
delay_ms(200); |
}; |
while(true) |
{ |
if(!IRRX) |
{ |
int8 ble; |
i2c_start(); // Cteni kompasu |
i2c_write(COMPAS_ADR); |
i2c_write(0x1); |
i2c_stop(); |
i2c_start(); |
i2c_write(COMPAS_ADR+1); |
ble=i2c_read(0); |
i2c_stop(); |
disp(ble); |
delay_ms(200); |
} |
else |
{ |
i2c_start(); // Diagnostika sonaru |
i2c_write(SONAR_ADR); |
i2c_write(0x02); // dosah |
i2c_write(0x03); // n*43mm |
i2c_stop(); |
i2c_start(); |
i2c_write(SONAR_ADR); |
i2c_write(0x01); // zesileni |
i2c_write(0x01); // male, pro eliminaci echa z minuleho mereni |
i2c_stop(); |
i2c_start(); // Sonar Ping |
i2c_write(0xE0); |
i2c_write(0x0); |
i2c_write(0x51); // 50 mereni v palcich, 51 mereni v cm, 52 v us |
i2c_stop(); |
delay_ms(100); |
i2c_start(); // Odraz ze sonaru |
i2c_write(0xE0); |
i2c_write(0x3); |
i2c_stop(); |
i2c_start(); |
i2c_write(0xE1); |
n=i2c_read(0); |
i2c_stop(); |
disp(n); // Zobrazeni hodnoty ze sonaru a zaroven diagnostika predniho IR cidla |
delay_ms(200); |
} |
} |
} |
/roboti/istrobot/camerus/SW/876/zatuhle_prevodovky/objizdka_L.c |
---|
0,0 → 1,183 |
// **** Objeti cihly vlevo **** LLLL |
#define L_TOUCH 1 // Cara vlevo |
#define R_TOUCH 2 // Cata vpravo |
#define B_TOUCH 3 // Both |
int8 n; |
int8 r1,r2,rr; |
int8 touch; |
enum okolo_cihly {pred_carou,na_care,po_care}; |
okolo_cihly ridic; // V jakem jsme stavu objizdeni cihly |
int8 vzdalenost; |
int8 visualisation; |
stav=cihla; // Dalsi prekazku uz nezaznamenavej (je to s velkou pravdepodobnosti cil) |
touch=0; // Indikator detekce cary pri objizdeni |
cihla: |
rr=RR_CIHLA; //!!! Rozumna rychlost pro objizdeni cihly (bylo by lepsi rychlost zvysovat) a pri detekci pohybu zase snizit |
disp(0x99); |
set_pwm1_duty(0); // zabrzdi levym kolem, prave vpred |
set_pwm2_duty(255); |
output_high(MOT_L); |
output_low(MOT_R); |
odocounter=get_timer1(); |
while(true) // Na zacatku se vyhni cihle, zatoc co muzes |
{ |
cas=CASMIN-5; // jeste vic nez hodne do leva |
if(BUMPER) // Narazili jsme do cihly, musime couvnout! |
{ |
bum(); |
SaveLog(log-1); // Zapis Black Boxu do EEPROM |
delay_ms(TUHOS); //!!! Zatuhle prevodovky |
brzda(); |
goto cihla; // Znovu zacni cihlu objizdet |
}; |
set_pwm1_duty(0); |
set_pwm2_duty(255); // !!! mozna prilis maly vykon pro rozjezd pro zatuhlou prevodovku |
output_high(MOT_L); // leve kolo reverz |
output_low(MOT_R); // prave kolo vpred |
if(get_timer1()>(odocounter+5)) // konec zatacky? |
{ |
disp(0x66); |
break; |
} |
SetServoQ(cas); |
delay_ms(18); |
}; |
//------ Objeti cihly v konstantni vzdalenosti ------ |
ridic=pred_carou; |
cas=CASAVR-CASMIN; // rovne |
output_low(MOT_L); // vpred |
output_low(MOT_R); |
visualisation=0; |
while(true) |
{ |
if(BUMPER) // Narazili jsme do cihly, musime couvnout! |
{ |
bum(); |
SaveLog(log-1); // Zapis Black Boxu do EEPROM |
delay_ms(TUHOS); //!!! Zatuhle prevodovky |
set_pwm1_duty(160); // vpred |
set_pwm2_duty(160); |
output_low(MOT_L); |
output_low(MOT_R); |
cas=CASMIN; |
}; |
delta_bearing=bearing-bearing_offset; |
visualisation=(delta_bearing & 0xF0) | (visualisation & 0x0F); |
if(IRRX) // hrozi celni srazka s cihlou v prubehu objizdeni |
{ |
cas=CASMIN; |
} |
else |
{ |
if((vzdalenost!=0)||!input(PROXIMITY)||((delta_bearing>60)&&(delta_bearing<128))) // Udrzovani konstantni vzdalenosti od cihly |
{ |
if(cas>(CASMIN+20)) cas-=20; |
} |
else |
{ |
if(cas<(CASMAX-20)) cas+=20; |
}; |
}; |
// Elektronicky diferencial |
if(cas<CASAVR) {r1=cas-CASMIN; r2=CASAVR-CASMIN;}; // Normovani vystupni hodnoty radkoveho snimace |
if(cas==CASAVR) {r1=cas-CASMIN; r2=cas-CASMIN;}; // pro rizeni rychlosti motoru |
if(cas>CASAVR) {r1=CASAVR-CASMIN; r2=CASMAX-cas;}; // Rozsah 1 az 92 |
if (r1>(CASAVR-CASMIN-rr)) r1=(r1<<1)+rr-(CASAVR-CASMIN); // Neco jako nasobeni |
if (r2>(CASAVR-CASMIN-rr)) r2=(r2<<1)+rr-(CASAVR-CASMIN); |
//!!! pro zatuhle prevodovky |
r1<<=1; // Rychlost je dvojnasobna |
r2<<=1; // Rozsah 2 az 184 pro rr=0 |
set_pwm1_duty(r1); // Nastav rychlost motoru |
set_pwm2_duty(r2); |
SetServoQ(cas); |
i2c_start(); // Sonar Ping |
i2c_write(SONAR_ADR); |
i2c_write(0x0); |
i2c_write(0x52); // mereni v us |
i2c_stop(); |
for(n=1;n<=90;n++) // 18ms testovani cary do dalsi korekce serva |
{ |
set_adc_channel(LMAX); |
delay_us(100); |
if(read_adc()<THR) touch|=L_TOUCH; |
set_adc_channel(RMAX); |
delay_us(100); |
if(read_adc()<THR) touch|=R_TOUCH; |
}; |
i2c_start(); // Odraz ze sonaru |
i2c_write(SONAR_ADR); |
i2c_write(0x3); |
i2c_stop(); |
i2c_start(); |
i2c_write(SONAR_ADR+1); |
vzdalenost=i2c_read(0); |
i2c_stop(); |
i2c_start(); // Cteni kompasu |
i2c_write(COMPAS_ADR); |
i2c_write(0x1); // uhel 0-255 |
i2c_stop(); |
i2c_start(); |
i2c_write(COMPAS_ADR+1); |
bearing=i2c_read(0); |
i2c_stop(); |
if(touch==L_TOUCH) visualisation|=0x2; |
if(touch==R_TOUCH) visualisation|=0x1; |
if((touch==B_TOUCH)&&(ridic==pred_carou)) ridic=na_care; |
if((ridic==na_care)&&(touch==0)) break; |
if(ridic==na_care) touch=0; |
disp(visualisation); |
}; |
disp(0xC3); |
set_pwm1_duty(0); //!!! pred zatuhlejma prevodovkama tam bylo 20 a 200 |
set_pwm2_duty(255); |
output_high(MOT_L); |
output_low(MOT_R); |
delay_us(40); |
odocounter=get_timer1(); // Poznamenej aktualni stav odometrie |
while (true) // Znovu se musime dotknout cary |
{ |
for(n=1;n<=90;n++) // 18ms testovani cary do dalsi korekce serva |
{ |
set_adc_channel(LMAX); // Levy UV sensor |
delay_us(100); |
if(read_adc()<THR) // Dotkli jsme se levym senzorem |
{ |
disp(0xE0); |
cas=CASAVR-CASMIN; // nastavime, ze cara je rovne |
goto cara; |
}; |
set_adc_channel(RMAX); // Pravy UV sensor |
delay_us(100); |
if((get_timer1()>=(odocounter+2)) && (read_adc()<THR)) // Pravym senzorem nesmime caru prejet! |
{ |
disp(0x07); |
cas=CASMAX; // kdyz prejedem, tak nastavime, ze cara je vpravo |
goto cara; |
}; |
} |
SetServoQ(CASMIN-5); // max. max. doleva L |
} |
cara: |
output_low(MOT_L); // oba motory vpred |
output_low(MOT_R); |
/roboti/istrobot/camerus/SW/876/zmensena brzdna draha na 0x15/camerus.c |
---|
0,0 → 1,634 |
//********* Robot Camerus pro IstRobot 2007 ************ |
//"$Id: camerus.c 253 2007-04-24 09:26:46Z kakl $" |
//***************************************************** |
#include ".\camerus.h" |
#USE FAST_IO (C) // Brana C je ve FAST_IO modu, aby slo rychle cist z kamery |
// Rychlostni konstanty |
#define RR_CIHLA 50 // Rozumna rychlost pro objizdeni cihly |
#define RR_PRERUSENI 50 // Rozumna rychlost pro priblizeni se k preruseni |
#define BRZDNA_DRAHA 0x15 // Jak daleko pred problemem se zacne brzdit |
#define TUHOS 100 // Jak dlouho se bude couvat po narazu na naraznik |
#define ODODO_CIHLA 0xFFF |
#define ODODO_TUNEL 0xFFF |
#define ODODO_PRERUSENI 0xFFF |
// Adresy IIC periferii |
#define COMPAS_ADR 0xC0 |
#define CAMERA_ADR 0xDC |
#define SONAR_ADR 0xE0 |
// A/D vstupy |
#define RMAX 4 // AN4/RA5 - leve cidlo na vyjeti z cary |
#define LMAX 3 // AN3/RA3 - prave cidlo na vyjeti z cary |
#define CERVENA 2 // AN2/RA2 - cervene kroutitko |
#define ZELENA 1 // AN1/RA0 - zelene kroutitko |
#define MODRA 0 // AN0/RA1 - modre kroutitko |
// I/O |
#define HREF PIN_C5 // Signal HREF z kamery (v H po celou dobu radku) |
#define PIX PIN_C6 // Vstup pro body z kamery (za trivstupim hradlem OR (dig. komparator)) |
#define SERVO PIN_B4 // Vystup na servo (1 az 2ms po cca 20ms (synchronizovano snimkovym kmitoctem)) |
#define MOT_L PIN_B5 // Smer otaceni leveho motoru; druhy pol je RC2 |
#define MOT_R PIN_B6 // Smer otaceni praveho motoru; druhy pol je RC1 |
#define MOT_1 PIN_C1 // PWM vystpy motoru |
#define MOT_2 PIN_C2 // |
#define DATA PIN_B2 // K modulu LEDbar data |
#define CP PIN_B1 // K modulu LEDbar hodiny |
//#define ODO PIN_C0 // Ze snimace z odometrie z praveho kola na TIMER1 |
// Jeden impuls je 31,25mm |
#define IRRX !input(PIN_B0) // Vstup INT, generuje preruseni pri prekazce |
#define IRTX PIN_B3 // Modulovani vysilaci IR LED na detekci prekazky |
#define PROXIMITY PIN_C7 // Cidlo kratkeho dosahu na cihlu |
#define BUMPER !input(PIN_A4) // Naraznik |
#define CASMIN 6 // Rozsah radku snimace |
#define CASMAX 192 |
#define CASAVR ((CASMAX+CASMIN) / 2) |
#define EEMAX 255 // Konec EEPROM |
#define MAXLOG 0x10 // Maximalni pocet zaznamu v logu |
#if MAXLOG>(EEMAX/3) |
#error Prekrocena velikost EEPROM |
#endif |
#define OFFSETO 0x9F //0x9F // Vystredeni serva pro objeti prekazky |
#define THR 90 // Threshold pro UV cidla na caru |
#byte INTCON = 0x0B // Interrupt configuration register |
#bit GIE = INTCON.7 |
#bit PEIE = INTCON.6 |
#bit TMR0IE = INTCON.5 |
#bit INT0IE = INTCON.4 |
#bit RBIE = INTCON.3 |
#bit TMR0IF = INTCON.2 |
#bit INT0IF = INTCON.1 |
#bit RBIF = INTCON.0 |
enum stavy {start,rozjezd,jizda,cihla,pocihle,cil}; |
stavy stav; // Kde jsme na trati |
int8 cas; // Cas hrany bila/cerna v radce |
int8 stred; // Vystredeni kolecka |
int16 odocounter; // Zaznamenani aktualniho stavu pocitadla odometrie |
int16 last_log_odo; // Posledni stav odometrie poznamenany do logu |
int16 last_log; // Cislo posledniho zaznamu v logu v EEPROM |
int8 bb_h[MAXLOG]; // Cerna skrinka MSB |
int8 bb_l[MAXLOG]; // Cerna skrinka LSB |
int8 bb_f[MAXLOG]; // Cerna skrinka priznak (typ zaznamu) |
int8 log; // Pocitadlo pro cernou skrinku |
int8 rr; // Promenna na ulozeni Rozumne rychlost |
int8 rrold; |
int16 odo_preruseni, odo_cihla, odo_tunel; // Problemy na trati |
// Zobrazeni jednoho byte na modulu LEDbar |
inline void disp(int8 x) |
{ |
int n; |
for(n=0;n<=7;n++) |
{ |
if (bit_test(x,0)) output_low(DATA); else output_high(DATA); |
output_high(CP); |
x>>=1; |
output_low(CP); |
} |
} |
// Blikani LEDbarem ve stilu Night Rider |
void NightRider(int8 x) |
{ |
int n,i,j; |
for(j=0;j<x;j++) |
{ |
i=0x01; |
for(n=0;n<7;n++) |
{ |
disp(i); |
rotate_left(&i, 1); |
delay_ms(40); |
} |
for(n=0;n<7;n++) |
{ |
disp(i); |
rotate_right(&i, 1); |
delay_ms(40); |
} |
} |
disp(i); |
delay_ms(40); |
i=0; |
disp(i); |
} |
// Zaznam LOGu do EEPROM |
void SaveLog() |
{ |
int8 n,i,xlog; |
i=0; |
for(n=0;n<=(log*3);n+=3) // Ulozeni Black Boxu do EEPROM |
{ |
write_eeprom(n,bb_f[i]); |
write_eeprom(n+1,bb_h[i]); |
write_eeprom(n+2,bb_l[i]); |
i++; |
}; |
if(log>0) {xlog=log-1;} else {xlog=0;}; |
write_eeprom(EEMAX,xlog); // Zapis poctu zaznamu na konec EEPROM |
} |
// Zaznam do Logu do RAM |
void LogLog(int8 reason, int16 log_delay) |
{ |
int16 timer_pom; |
timer_pom=get_timer1(); // Timer se musi vycist atomicky |
bb_l[log]=make8(timer_pom,0); // Zaznam |
bb_h[log]=make8(timer_pom,1); |
bb_f[log]=reason; // Typ zaznamu |
if(log<(MAXLOG-1)) log++; // Ukazatel na dalsi zaznam |
last_log_odo=timer_pom+log_delay; // Dalsi mereni nejdrive po ujeti def. vzdalenosti |
rr=rrold; // Problem skoncil, znovu jed Rozumnou Rychlosti |
} |
void ReadBlackBox() |
{ |
last_log=read_eeprom(EEMAX); // Kolik zaznamu mame od minule poznamenano? |
{ |
int8 n,i; |
i=0; |
for(n=0;n<=last_log;n++) |
{ |
if(read_eeprom(i)==0) odo_tunel=MAKE16(read_eeprom(i+2),read_eeprom(i+1)); |
if(read_eeprom(i)==0xFF) odo_cihla=MAKE16(read_eeprom(i+2),read_eeprom(i+1)); |
if((read_eeprom(i)>0) && (read_eeprom(i)<0xFF)) odo_preruseni=MAKE16(read_eeprom(i+2),read_eeprom(i+1)); |
} |
} |
} |
// Brzdeni motorama stridou 1:1 |
void brzda() |
{ |
int8 n,i; |
set_pwm1_duty(0); // vypni PWM |
set_pwm2_duty(0); |
setup_ccp1(CCP_OFF); |
setup_ccp2(CCP_OFF); |
for (n=0;n<200;n++) |
{ |
output_low(MOT_L); |
output_low(MOT_R); |
output_high(MOT_1); |
output_high(MOT_2); |
delay_us(200); |
output_high(MOT_L); |
output_high(MOT_R); |
output_low(MOT_1); |
output_low(MOT_2); |
delay_us(200); |
} |
output_low(MOT_L); // smer vpred |
output_low(MOT_R); |
setup_ccp1(CCP_PWM); // RC1 // Zapni PWM pro motory |
setup_ccp2(CCP_PWM); // RC2 |
} |
void SetServo(int8 angle) |
{ |
int8 n; |
for(n=0; n<10; n++) |
{ |
output_high(SERVO); // Odvysilani impuzu 1 az 2ms pro servo |
delay_us(1000); |
delay_us(stred); |
delay_us(stred); |
delay_us(stred); |
delay_us(angle); |
delay_us(angle); |
output_low(SERVO); |
delay_ms(18); |
} |
} |
inline void SetServoQ(int8 angle) |
{ |
output_high(SERVO); // Odvysilani impuzu 1 az 2ms pro servo |
delay_us(1000); |
delay_us(stred); |
delay_us(stred); |
delay_us(stred); |
delay_us(angle); |
delay_us(angle); |
output_low(SERVO); |
} |
// Couvni po narazu na naraznik |
inline void bum() |
{ |
set_pwm1_duty(0); // couvni, rovne dozadu |
set_pwm2_duty(0); |
output_high(MOT_L); |
output_high(MOT_R); |
disp(0xA5); |
SetServo(CASAVR-CASMIN); |
} |
#include ".\diag.c" |
//---------------------------- INT -------------------------------- |
#int_EXT |
EXT_isr() // Preruseni od prekazky |
{ |
unsigned int8 bearing, bearing_offset, delta_bearing; |
set_pwm1_duty(0); // zabrzdi levym kolem, prave vypni |
set_pwm2_duty(0); |
output_high(MOT_L); |
output_low(MOT_R); |
// Ujistime se, ze prijaty signal je z naseho IR vysilace |
output_high(IRTX); // Vypni LED na detekci prekazky |
delay_ms(2); |
if (IRRX) // stale nas signal? |
{ |
output_low(MOT_L); // je odraz -> vpred |
output_low(MOT_R); |
return; |
}; |
output_low(IRTX); // Zapni LED na detekci prekazky |
i2c_start(); // Cteni kompasu |
i2c_write(COMPAS_ADR); |
i2c_write(0x1); // 0-255 (odpovida 0-359) |
i2c_stop(); |
i2c_start(); |
i2c_write(COMPAS_ADR+1); |
bearing_offset=i2c_read(0); // Poznamenej hodnotu pred cihlou |
i2c_stop(); |
delay_ms(9); |
if (!IRRX) // stale nas signal? |
{ |
output_low(MOT_L); // neni odraz -> vpred |
output_low(MOT_R); |
return; |
}; |
rr=rrold; // Po cihle se pojede opet Rozumnou Rychlosti |
if(stav!=cihla) |
{ |
LogLog(0xFF,3); // Cihla |
}; |
//!!! if(stav==cihla) while(true); // Zastav na furt, konec drahy |
// if(stav==cihla) return; // Po druhe nic neobjizdej |
// Pozor na rozjezd |
if((stav==jizda)||(stav==cihla)) // Objed cihlu |
{ |
#include ".\objizdka_L.c" |
}; |
last_log_odo=get_timer1()+16; // Pul metru po cihle nezaznamenavej do LOGu |
} |
//---------------------------------- MAIN -------------------------------------- |
void main() |
{ |
int8 offset; // Promena pro ulozeni offsetu |
int8 r1; // Rychlost motoru 1 |
int8 r2; // Rychlost motoru 2 |
setup_adc_ports(ALL_ANALOG); // Zapnuti A/D prevodniku pro cteni kroutitek |
setup_adc(ADC_CLOCK_INTERNAL); |
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); // Casovac pro mereni casu hrany W/B v radce |
setup_timer_1(T1_EXTERNAL); // Cita pulzy z odometrie z praveho kola |
setup_timer_2(T2_DIV_BY_16,255,1); // Casovac PWM motoru |
//!!! setup_timer_2(T2_DIV_BY_4,255,1); // Casovac PWM motoru |
setup_ccp1(CCP_PWM); // RC1 // PWM pro motory |
setup_ccp2(CCP_PWM); // RC2 |
setup_comparator(NC_NC_NC_NC); |
setup_vref(FALSE); |
set_tris_c(0b11111001); // Nastaveni vstup/vystup pro branu C, protoze se to nedela automaticky |
set_pwm1_duty(0); // Zastav motory |
set_pwm2_duty(0); |
output_low(MOT_L); // Nastav smer vpred |
output_low(MOT_R); |
disp(0); // Zhasni LEDbar |
if(BUMPER) // Kdyz nekdo na zacatku drzi naraznik, vymaz log a spust diagnostiku |
{ |
diag(); |
} |
output_low(IRTX); // Zapni LED na detekci prekazky |
NightRider(1); // Zablikej, aby se poznalo, ze byl RESET |
// Zaroven se musi pockat, nez se rozjede kamera, nez se do ni zacnou posilat prikazy |
//... Nastaveni sonaru ... |
i2c_start(); |
i2c_write(SONAR_ADR); |
i2c_write(0x02); // dosah |
i2c_write(0x03); // n*43mm |
i2c_stop(); |
i2c_start(); |
i2c_write(SONAR_ADR); |
i2c_write(0x01); // zesileni |
i2c_write(0x01); // male, pro eliminaci echa z minuleho mereni |
i2c_stop(); |
//... Nastaveni kamery ... |
i2c_start(); // Soft RESET kamery |
i2c_write(CAMERA_ADR); // Adresa kamery |
i2c_write(0x12); // Adresa registru COMH |
i2c_write(0x80 | 0x24); // Zapis ridiciho slova |
i2c_stop(); |
i2c_start(); // BW |
i2c_write(CAMERA_ADR); |
i2c_write(0x28); |
i2c_write(0b01000001); |
i2c_stop(); |
/* |
i2c_start(); // Contrast (nema podstatny vliv na obraz) |
i2c_write(CAMERA_ADR); |
i2c_write(0x05); |
i2c_write(0xA0); // 48h |
i2c_stop(); |
i2c_start(); // Band Filter (pokud by byl problem se zarivkama 50Hz) |
i2c_write(CAMERA_ADR); |
i2c_write(0x2D); |
i2c_write(0x04 | 0x03); |
i2c_stop(); |
*/ |
i2c_start(); // Fame Rate |
i2c_write(CAMERA_ADR); |
i2c_write(0x2B); |
i2c_write(0x00); // cca 17ms (puvodni hodnota 5Eh = 20ms) |
i2c_stop(); |
i2c_start(); // VSTRT |
i2c_write(CAMERA_ADR); |
i2c_write(0x19); |
i2c_write(118); // prostredni radka |
i2c_stop(); |
i2c_start(); // VEND |
i2c_write(CAMERA_ADR); |
i2c_write(0x1A); |
i2c_write(118); |
i2c_stop(); |
NightRider(1); // Musi se dat cas kamere na AGC a AEC |
{ // Mereni expozice |
int8 t1,t2; |
i2c_start(); // Brightness, zacni od uplne tmy |
i2c_write(CAMERA_ADR); |
i2c_write(0x06); |
i2c_write(0); // 80h default |
i2c_stop(); |
delay_ms(50); |
for(offset=0x04;offset<(255-0x04);offset+=0x04) // Zacni od jasu 10h |
{ |
i2c_start(); // Brightness |
i2c_write(CAMERA_ADR); |
i2c_write(0x06); |
i2c_write(offset); // 80h default |
i2c_stop(); |
disp(offset); |
delay_ms(50); |
t1=0; |
t2=0; |
while(!input(HREF)); // Cekej nez se zacnou posilat pixely z radky |
delay_ms(5); |
while(!input(HREF)); // Cekej nez se zacnou posilat pixely z radky |
set_timer0(0); // Vynuluj pocitadlo casu |
if(!input(PIX)) continue; |
while(input(PIX)); |
t1=get_timer0(); // Precti cas z citace casu hrany |
set_timer0(0); // Vynuluj pocitadlo casu |
while(!input(PIX)); |
t2=get_timer0(); |
if((t1>60) && (t1<140) && (t2>5) && (t2<=10)) break; // Vidis, co mas? |
delay_ms(2); // Preskoc druhou radku z kamery |
}; |
delay_ms(1000); // Nech chvili na displayi zmerenou hodnotu |
} |
set_adc_channel(CERVENA); // --- Kroutitko pro jas --- |
delay_ms(1); |
offset=read_adc(); |
offset &= 0b11111100; // Dva nejnizsi bity ignoruj |
// offset += 0x70; // Jas nebude nikdy nizsi |
disp(offset); |
i2c_start(); // Brightness |
i2c_write(CAMERA_adr); |
i2c_write(0x06); |
i2c_write(offset); // 80h default |
i2c_stop(); |
delay_ms(1000); // Nech hodnotu chvili na displayi |
set_adc_channel(ZELENA); // --- Kroutitko pro vykon motoru --- |
delay_ms(1); |
rr=read_adc()>>2; // 0-63 // Pokud by se zvetsil rozsah, tak zkontrolovat jakonasobeni! |
rr+=27; // 27-90 |
//!!! rr=read_adc()>>1; // 0-128 // Pokud by se zvetsil rozsah, tak zkontrolovat jakonasobeni! |
rrold=rr; |
cas=CASAVR-CASMIN; // Inicializace promenych, aby neslo servo za roh |
// a aby se to rozjelo jeste dneska |
stav=start; // Jsme na startu |
set_timer1(0); // Vynuluj citac odometrie |
log=0; // Zacatek logu v cerne skrince |
last_log_odo=0; // Posledni zaznam odometrie do logu |
// ReadBlackBox(); // Vycteni zaznamu z Black Boxu |
odo_cihla=ODODO_CIHLA-BRZDNA_DRAHA; |
odo_tunel=ODODO_TUNEL-BRZDNA_DRAHA; |
odo_preruseni=ODODO_PRERUSENI-BRZDNA_DRAHA; |
// ........................... Hlavni smycka ................................ |
while(true) |
{ |
int8 pom; |
int8 n; |
int8 gap; |
int16 ododo; |
gap=0; // Vynuluj pocitadlo preruseni |
next_snap: |
pom=0; |
disable_interrupts(GLOBAL); //----------------------- Critical Section |
while(input(HREF)); // Preskoc 1. radku |
while(!input(HREF)); // Cekej nez se zacnou posilat pixely z 2. radky |
set_timer0(0); // Vynuluj pocitadlo casu |
while(input(HREF)) // Po dobu vysilani radky cekej na hranu W/B |
{ |
// !!!!Dodelat rozpoznani cerne cary napric pro zastaveni ? |
if(!input(PIX)) // Pokud se X-krat za sebou precetla CERNA |
if(!input(PIX)) |
// if(!input(PIX)) |
{ |
pom=get_timer0(); // Precti cas z citace casu hrany |
break; |
}; |
}; |
while(input(HREF)); // Pockej na shozeni signalu HREF |
if((pom<CASMAX) && (pom>CASMIN)) cas=pom; // Orizni konce radku |
// Na konci obrazovaho radku to blbne. Jednak chyba od apertury |
// a vubec to nejak na kraji nefunguje. |
output_high(SERVO); // Odvysilani impuzu 1 az 2ms pro servo |
delay_us(1000); |
delay_us(stred); |
delay_us(stred); |
delay_us(stred); |
delay_us(cas); |
delay_us(cas); |
output_low(SERVO); |
// Elektronicky diferencial 1. cast |
if(cas<CASAVR) {r1=cas-CASMIN; r2=CASAVR-CASMIN;}; // Normovani vystupni hodnoty radkoveho snimace |
if(cas==CASAVR) {r1=cas-CASMIN; r2=cas-CASMIN;}; // pro rizeni rychlosti motoru |
if(cas>CASAVR) {r1=CASAVR-CASMIN; r2=CASMAX-cas;}; // Rozsah 1 az 92 |
enable_interrupts(GLOBAL); //----------------------- End Critical Section |
if(pom==0) // Kamera nevidi caru, poznamenej to do logu |
{ |
if((cas>(CASMIN+30))&&(cas<(CASMAX-30))) // Nebyla minule cara moc u kraje? |
if(last_log_odo<get_timer1()) // Aby nebyly zaznamy v logu prilis huste, musi se napred neco ujet od minuleho zaznamu |
{ |
gap++; |
} |
} |
else |
{ |
if(gap>=2) // Trva preruseni cary alespon 2 snimky? |
{ |
LogLog(gap,8); // Dalsi mereni nejdrive po ujeti 24 cm |
rr=rrold; // Preruseni cary skoncilo, znovu jed Rozumnou Rychlosti |
} |
gap=0; |
}; |
if(!input(PROXIMITY) && ((stav==jizda)||(stav==cihla))) // Tunel |
{ |
if(last_log_odo<get_timer1()) // Aby nebyly zaznamy v logu prilis huste, musi se napred neco ujet od minuleho zaznamu |
{ |
LogLog(0xDD,16); // Priznak tunelu; dalsi mereni nejdrive po ujeti 48 cm |
rr=rrold; // Vjeli jsme do tunelu, znovu jed rychle |
} |
}; |
//ODODO |
ododo=get_timer1(); |
if((ododo>odo_preruseni)&&(ododo<(odo_preruseni+8))) rr=RR_PRERUSENI; |
if((ododo>odo_cihla)&&(ododo<(odo_cihla+8))) rr=RR_PRERUSENI; |
if((ododo>odo_tunel)&&(ododo<(odo_tunel+8))) rr=RR_PRERUSENI; |
// Elektronicky diferencial 2. cast |
if (r1>(CASAVR-CASMIN-rr)) r1=(r1<<1)+rr-(CASAVR-CASMIN); // Neco jako nasobeni |
if (r2>(CASAVR-CASMIN-rr)) r2=(r2<<1)+rr-(CASAVR-CASMIN); // rozsah 1 az 92 pro rr=0 // rozsah 1 az 154 pro rr=63 |
//!!! pro zatuhle prevodovky |
// r1<<=1; // Rychlost je dvojnasobna |
// r2<<=1; // Rozsah 2 az 184 pro rr=0 |
if ((stav==jizda)||(stav==cihla)||(stav==rozjezd)) //||(stav==pocihle)) // Jizda |
{ |
set_pwm1_duty(r1); |
set_pwm2_duty(r2); |
} |
else |
{ |
set_pwm1_duty(0); // Zastaveni |
set_pwm2_duty(0); |
}; |
if((stav==rozjezd)&&(get_timer1()>10)) // musi ujet alespon 31cm |
{ |
ext_int_edge(H_TO_L); // Nastav podminky preruseni od cihly |
INT0IF=0; // Zruseni predesle udalosti od startera |
enable_interrupts(INT_EXT); |
enable_interrupts(GLOBAL); |
stav=jizda; |
}; |
if(stav==start) // Snimkuje, toci servem a ceka na start |
{ |
set_adc_channel(MODRA); // Kroutitko na vystredeni predniho kolecka |
Delay_ms(1); |
stred=read_adc(); |
if(!input(PROXIMITY)) |
{ |
disp(0x80); |
while(input(PROXIMITY)); // Cekej, dokud starter neda ruku pryc |
set_timer1(0); // Vynuluj citac odometrie |
set_pwm1_duty(255); // Rychly rozjezd !!! Zkontrolovat na oscyloskopu |
set_pwm2_duty(255); |
disp(0x01); |
while(get_timer1()<=4) // Ujed alespon 12cm |
{ |
set_adc_channel(LMAX); // Levy UV sensor |
delay_us(40); |
if(read_adc()<THR) {cas=CASMIN; break;}; // Prejeli jsme caru vlevo |
set_adc_channel(RMAX); // Pravy UV sensor |
delay_us(40); |
if(read_adc()<THR) {cas=CASMAX; break;}; // Prejeli jsme caru vpravo |
cas=CASAVR-CASMIN; // Cara je rovne |
}; |
stav=rozjezd; |
}; |
} |
pom=0x80; // Zobrazeni pozice cary na displayi |
for(n=CASMAX/8; n<cas; n+=CASMAX/8) pom>>=1; |
disp(pom); |
while(true) // Ve zbytku casu snimku cti krajni UV senzory a naraznik |
{ |
if(BUMPER) // Sakra, do neceho jsme narazili a nevideli jsme to! |
{ |
bum(); |
SaveLog(); // Zapis Black Boxu do EEPROM |
delay_ms(TUHOS); //!!! Zatuhle prevodovky |
set_pwm1_duty(200); // pomalu vpred |
set_pwm2_duty(200); |
output_low(MOT_L); |
output_low(MOT_R); |
cas=CASAVR-CASMIN; |
}; |
set_adc_channel(LMAX); // Levy UV sensor |
for(n=0;n<20;n++) if(input(HREF)) goto next_snap; |
if(read_adc()<THR) cas=CASMIN; |
set_adc_channel(RMAX); // Pravy UV sensor |
for(n=0;n<20;n++) if(input(HREF)) goto next_snap; |
if(read_adc()<THR) cas=CASMAX; |
}; |
} |
} |
/roboti/istrobot/camerus/SW/876/zmensena brzdna draha na 0x15/diag.c |
---|
0,0 → 1,68 |
//--- Diagnostika cidel a vymazani EEPROM --- |
void diag() |
{ |
int8 n; |
// Vymaz Black Box v EEPROM |
for(n=0;n<255;n++) write_eeprom(n,0); |
bb_l[0]=0; // Zapis na pozici 0 vzdalenost 0 |
bb_h[0]=0; |
bb_f[0]=0; |
write_eeprom(EEMAX,0); // Zapis do EEPROM pocet zaznamu 0, tedy jeden zaznam |
for(n=0;n<=4;n++) |
{ |
disp(0x55); // Blikni pro potvrzeni |
delay_ms(200); |
disp(0xAA); |
delay_ms(200); |
}; |
while(true) |
{ |
if(!IRRX) |
{ |
int8 ble; |
i2c_start(); // Cteni kompasu |
i2c_write(COMPAS_ADR); |
i2c_write(0x1); |
i2c_stop(); |
i2c_start(); |
i2c_write(COMPAS_ADR+1); |
ble=i2c_read(0); |
i2c_stop(); |
disp(ble); |
delay_ms(200); |
} |
else |
{ |
i2c_start(); // Diagnostika sonaru |
i2c_write(SONAR_ADR); |
i2c_write(0x02); // dosah |
i2c_write(0x03); // n*43mm |
i2c_stop(); |
i2c_start(); |
i2c_write(SONAR_ADR); |
i2c_write(0x01); // zesileni |
i2c_write(0x01); // male, pro eliminaci echa z minuleho mereni |
i2c_stop(); |
i2c_start(); // Sonar Ping |
i2c_write(0xE0); |
i2c_write(0x0); |
i2c_write(0x51); // 50 mereni v palcich, 51 mereni v cm, 52 v us |
i2c_stop(); |
delay_ms(100); |
i2c_start(); // Odraz ze sonaru |
i2c_write(0xE0); |
i2c_write(0x3); |
i2c_stop(); |
i2c_start(); |
i2c_write(0xE1); |
n=i2c_read(0); |
i2c_stop(); |
disp(n); // Zobrazeni hodnoty ze sonaru a zaroven diagnostika predniho IR cidla |
delay_ms(200); |
} |
} |
} |
/roboti/istrobot/camerus/SW/876/zmensena brzdna draha na 0x15/objizdka_L.c |
---|
0,0 → 1,183 |
// **** Objeti cihly vlevo **** LLLL |
#define L_TOUCH 1 // Cara vlevo |
#define R_TOUCH 2 // Cata vpravo |
#define B_TOUCH 3 // Both |
int8 n; |
int8 r1,r2,rr; |
int8 touch; |
enum okolo_cihly {pred_carou,na_care,po_care}; |
okolo_cihly ridic; // V jakem jsme stavu objizdeni cihly |
int8 vzdalenost; |
int8 visualisation; |
stav=cihla; // Dalsi prekazku uz nezaznamenavej (je to s velkou pravdepodobnosti cil) |
odocounter=get_timer1(); |
cihla: |
rr=RR_CIHLA; //!!! Rozumna rychlost pro objizdeni cihly (bylo by lepsi rychlost zvysovat) a pri detekci pohybu zase snizit |
disp(0x99); |
set_pwm1_duty(0); // zabrzdi levym kolem, prave vpred |
set_pwm2_duty(255); |
output_high(MOT_L); |
output_low(MOT_R); |
while(true) // Na zacatku se vyhni cihle, zatoc co muzes |
{ |
cas=CASMIN-5; // jeste vic nez hodne do leva |
if(BUMPER) // Narazili jsme do cihly, musime couvnout! |
{ |
bum(); |
SaveLog(); // Zapis Black Boxu do EEPROM |
delay_ms(TUHOS); //!!! Zatuhle prevodovky |
brzda(); |
goto cihla; // Znovu zacni cihlu objizdet |
}; |
set_pwm1_duty(0); |
set_pwm2_duty(200); // !!! mozna prilis maly vykon pro rozjezd pro zatuhlou prevodovku |
output_high(MOT_L); // leve kolo reverz |
output_low(MOT_R); // prave kolo vpred |
if(get_timer1()>(odocounter+5)) // konec zatacky? |
{ |
disp(0x66); |
break; |
} |
SetServoQ(cas); |
delay_ms(18); |
}; |
//------ Objeti cihly v konstantni vzdalenosti ------ |
touch=0; // Indikator detekce cary pri objizdeni |
ridic=pred_carou; |
cas=CASAVR-CASMIN; // rovne |
output_low(MOT_L); // vpred |
output_low(MOT_R); |
visualisation=0; |
while(true) |
{ |
if(BUMPER) // Narazili jsme do cihly, musime couvnout! |
{ |
bum(); |
SaveLog(); // Zapis Black Boxu do EEPROM |
delay_ms(TUHOS); //!!! Zatuhle prevodovky |
set_pwm1_duty(160); // vpred |
set_pwm2_duty(160); |
output_low(MOT_L); |
output_low(MOT_R); |
cas=CASMIN; |
}; |
delta_bearing=bearing-bearing_offset; |
visualisation=(delta_bearing & 0xF0) | (visualisation & 0x0F); |
if(IRRX) // hrozi celni srazka s cihlou v prubehu objizdeni |
{ |
cas=CASMIN; |
} |
else |
{ |
if((vzdalenost!=0)||!input(PROXIMITY)||((delta_bearing>60)&&(delta_bearing<128))) // Udrzovani konstantni vzdalenosti od cihly |
{ |
if(cas>(CASMIN+30)) cas-=30; |
} |
else |
{ |
if(cas<(CASMAX-30)) cas+=30; |
}; |
}; |
// Elektronicky diferencial |
if(cas<CASAVR) {r1=cas-CASMIN; r2=CASAVR-CASMIN;}; // Normovani vystupni hodnoty radkoveho snimace |
if(cas==CASAVR) {r1=cas-CASMIN; r2=cas-CASMIN;}; // pro rizeni rychlosti motoru |
if(cas>CASAVR) {r1=CASAVR-CASMIN; r2=CASMAX-cas;}; // Rozsah 1 az 92 |
if (r1>(CASAVR-CASMIN-rr)) r1=(r1<<1)+rr-(CASAVR-CASMIN); // Neco jako nasobeni |
if (r2>(CASAVR-CASMIN-rr)) r2=(r2<<1)+rr-(CASAVR-CASMIN); |
//!!! pro zatuhle prevodovky |
// r1<<=1; // Rychlost je dvojnasobna |
// r2<<=1; // Rozsah 2 az 184 pro rr=0 |
set_pwm1_duty(r1); // Nastav rychlost motoru |
set_pwm2_duty(r2); |
SetServoQ(cas); |
i2c_start(); // Sonar Ping |
i2c_write(SONAR_ADR); |
i2c_write(0x0); |
i2c_write(0x52); // mereni v us |
i2c_stop(); |
for(n=1;n<=90;n++) // 18ms testovani cary do dalsi korekce serva |
{ |
set_adc_channel(LMAX); |
delay_us(100); |
if(read_adc()<THR) touch|=L_TOUCH; |
set_adc_channel(RMAX); |
delay_us(100); |
if(read_adc()<THR) touch|=R_TOUCH; |
}; |
i2c_start(); // Odraz ze sonaru |
i2c_write(SONAR_ADR); |
i2c_write(0x3); |
i2c_stop(); |
i2c_start(); |
i2c_write(SONAR_ADR+1); |
vzdalenost=i2c_read(0); |
i2c_stop(); |
i2c_start(); // Cteni kompasu |
i2c_write(COMPAS_ADR); |
i2c_write(0x1); // uhel 0-255 |
i2c_stop(); |
i2c_start(); |
i2c_write(COMPAS_ADR+1); |
bearing=i2c_read(0); |
i2c_stop(); |
if(touch==L_TOUCH) visualisation|=0x2; |
if(touch==R_TOUCH) visualisation|=0x1; |
if((touch==B_TOUCH)&&(ridic==pred_carou)) ridic=na_care; |
if((ridic==na_care)&&(touch==0)) break; |
if(ridic==na_care) touch=0; |
disp(visualisation); |
}; |
disp(0xC3); |
set_pwm1_duty(0); //!!! pred zatuhlejma prevodovkama tam bylo 20 a 200 |
set_pwm2_duty(240); |
output_high(MOT_L); |
output_low(MOT_R); |
delay_us(40); |
odocounter=get_timer1(); // Poznamenej aktualni stav odometrie |
while (true) // Znovu se musime dotknout cary |
{ |
for(n=1;n<=90;n++) // 18ms testovani cary do dalsi korekce serva |
{ |
set_adc_channel(LMAX); // Levy UV sensor |
delay_us(100); |
if(read_adc()<THR) // Dotkli jsme se levym senzorem |
{ |
disp(0xE0); |
cas=CASAVR-CASMIN; // nastavime, ze cara je rovne |
goto cara; |
}; |
set_adc_channel(RMAX); // Pravy UV sensor |
delay_us(100); |
if((get_timer1()>=(odocounter+2)) && (read_adc()<THR)) // Pravym senzorem nesmime caru prejet! |
{ |
disp(0x07); |
cas=CASMAX; // kdyz prejedem, tak nastavime, ze cara je vpravo |
goto cara; |
}; |
} |
SetServoQ(CASMIN-5); // max. max. doleva L |
} |
cara: |
output_low(MOT_L); // oba motory vpred |
output_low(MOT_R); |
/roboti/istrobot/camerus/SW/876/objizdka_L.c |
---|
0,0 → 1,183 |
// **** Objeti cihly vlevo **** LLLL |
#define L_TOUCH 1 // Cara vlevo |
#define R_TOUCH 2 // Cata vpravo |
#define B_TOUCH 3 // Both |
int8 n; |
int8 r1,r2,rr; |
int8 touch; |
enum okolo_cihly {pred_carou,na_care,po_care}; |
okolo_cihly ridic; // V jakem jsme stavu objizdeni cihly |
int8 vzdalenost; |
int8 visualisation; |
stav=cihla; // Dalsi prekazku uz nezaznamenavej (je to s velkou pravdepodobnosti cil) |
odocounter=get_timer1(); |
cihla: |
rr=RR_CIHLA; //!!! Rozumna rychlost pro objizdeni cihly (bylo by lepsi rychlost zvysovat) a pri detekci pohybu zase snizit |
disp(0x99); |
set_pwm1_duty(0); // zabrzdi levym kolem, prave vpred |
set_pwm2_duty(255); |
output_high(MOT_L); |
output_low(MOT_R); |
while(true) // Na zacatku se vyhni cihle, zatoc co muzes |
{ |
cas=CASMIN-5; // jeste vic nez hodne do leva |
if(BUMPER) // Narazili jsme do cihly, musime couvnout! |
{ |
bum(); |
SaveLog(); // Zapis Black Boxu do EEPROM |
delay_ms(TUHOS); //!!! Zatuhle prevodovky |
brzda(); |
goto cihla; // Znovu zacni cihlu objizdet |
}; |
set_pwm1_duty(0); |
set_pwm2_duty(255); // !!! mozna prilis maly vykon pro rozjezd pro zatuhlou prevodovku |
output_high(MOT_L); // leve kolo reverz |
output_low(MOT_R); // prave kolo vpred |
if(get_timer1()>(odocounter+5)) // konec zatacky? |
{ |
disp(0x66); |
break; |
} |
SetServoQ(cas); |
delay_ms(18); |
}; |
//------ Objeti cihly v konstantni vzdalenosti ------ |
touch=0; // Indikator detekce cary pri objizdeni |
ridic=pred_carou; |
cas=CASAVR-CASMIN; // rovne |
output_low(MOT_L); // vpred |
output_low(MOT_R); |
visualisation=0; |
while(true) |
{ |
if(BUMPER) // Narazili jsme do cihly, musime couvnout! |
{ |
bum(); |
SaveLog(); // Zapis Black Boxu do EEPROM |
delay_ms(TUHOS); //!!! Zatuhle prevodovky |
set_pwm1_duty(160); // vpred |
set_pwm2_duty(160); |
output_low(MOT_L); |
output_low(MOT_R); |
cas=CASMIN; |
}; |
delta_bearing=bearing-bearing_offset; |
visualisation=(delta_bearing & 0xF0) | (visualisation & 0x0F); |
if(IRRX) // hrozi celni srazka s cihlou v prubehu objizdeni |
{ |
cas=CASMIN; |
} |
else |
{ |
if((vzdalenost!=0)||!input(PROXIMITY)||((delta_bearing>60)&&(delta_bearing<128))) // Udrzovani konstantni vzdalenosti od cihly |
{ |
if(cas>(CASMIN+30)) cas-=30; |
} |
else |
{ |
if(cas<(CASMAX-30)) cas+=30; |
}; |
}; |
// Elektronicky diferencial |
if(cas<CASAVR) {r1=cas-CASMIN; r2=CASAVR-CASMIN;}; // Normovani vystupni hodnoty radkoveho snimace |
if(cas==CASAVR) {r1=cas-CASMIN; r2=cas-CASMIN;}; // pro rizeni rychlosti motoru |
if(cas>CASAVR) {r1=CASAVR-CASMIN; r2=CASMAX-cas;}; // Rozsah 1 az 92 |
if (r1>(CASAVR-CASMIN-rr)) r1=(r1<<1)+rr-(CASAVR-CASMIN); // Neco jako nasobeni |
if (r2>(CASAVR-CASMIN-rr)) r2=(r2<<1)+rr-(CASAVR-CASMIN); |
//!!! pro zatuhle prevodovky |
// r1<<=1; // Rychlost je dvojnasobna |
// r2<<=1; // Rozsah 2 az 184 pro rr=0 |
set_pwm1_duty(r1); // Nastav rychlost motoru |
set_pwm2_duty(r2); |
SetServoQ(cas); |
i2c_start(); // Sonar Ping |
i2c_write(SONAR_ADR); |
i2c_write(0x0); |
i2c_write(0x52); // mereni v us |
i2c_stop(); |
for(n=1;n<=90;n++) // 18ms testovani cary do dalsi korekce serva |
{ |
set_adc_channel(LMAX); |
delay_us(100); |
if(read_adc()<THR) touch|=L_TOUCH; |
set_adc_channel(RMAX); |
delay_us(100); |
if(read_adc()<THR) touch|=R_TOUCH; |
}; |
i2c_start(); // Odraz ze sonaru |
i2c_write(SONAR_ADR); |
i2c_write(0x3); |
i2c_stop(); |
i2c_start(); |
i2c_write(SONAR_ADR+1); |
vzdalenost=i2c_read(0); |
i2c_stop(); |
i2c_start(); // Cteni kompasu |
i2c_write(COMPAS_ADR); |
i2c_write(0x1); // uhel 0-255 |
i2c_stop(); |
i2c_start(); |
i2c_write(COMPAS_ADR+1); |
bearing=i2c_read(0); |
i2c_stop(); |
if(touch==L_TOUCH) visualisation|=0x2; |
if(touch==R_TOUCH) visualisation|=0x1; |
if((touch==B_TOUCH)&&(ridic==pred_carou)) ridic=na_care; |
if((ridic==na_care)&&(touch==0)) break; |
if(ridic==na_care) touch=0; |
disp(visualisation); |
}; |
disp(0xC3); |
set_pwm1_duty(0); //!!! pred zatuhlejma prevodovkama tam bylo 20 a 200 |
set_pwm2_duty(255); |
output_high(MOT_L); |
output_low(MOT_R); |
delay_us(40); |
odocounter=get_timer1(); // Poznamenej aktualni stav odometrie |
while (true) // Znovu se musime dotknout cary |
{ |
for(n=1;n<=90;n++) // 18ms testovani cary do dalsi korekce serva |
{ |
set_adc_channel(LMAX); // Levy UV sensor |
delay_us(100); |
if(read_adc()<THR) // Dotkli jsme se levym senzorem |
{ |
disp(0xE0); |
cas=CASAVR-CASMIN; // nastavime, ze cara je rovne |
goto cara; |
}; |
set_adc_channel(RMAX); // Pravy UV sensor |
delay_us(100); |
if((get_timer1()>=(odocounter+2)) && (read_adc()<THR)) // Pravym senzorem nesmime caru prejet! |
{ |
disp(0x07); |
cas=CASMAX; // kdyz prejedem, tak nastavime, ze cara je vpravo |
goto cara; |
}; |
} |
SetServoQ(CASMIN-5); // max. max. doleva L |
} |
cara: |
output_low(MOT_L); // oba motory vpred |
output_low(MOT_R); |
/roboti/istrobot/camerus/SW/876/diag.c |
---|
0,0 → 1,68 |
//--- Diagnostika cidel a vymazani EEPROM --- |
void diag() |
{ |
int8 n; |
// Vymaz Black Box v EEPROM |
for(n=0;n<255;n++) write_eeprom(n,0); |
bb_l[0]=0; // Zapis na pozici 0 vzdalenost 0 |
bb_h[0]=0; |
bb_f[0]=0; |
write_eeprom(EEMAX,0); // Zapis do EEPROM pocet zaznamu 0, tedy jeden zaznam |
for(n=0;n<=4;n++) |
{ |
disp(0x55); // Blikni pro potvrzeni |
delay_ms(200); |
disp(0xAA); |
delay_ms(200); |
}; |
while(true) |
{ |
if(!IRRX) |
{ |
int8 ble; |
i2c_start(); // Cteni kompasu |
i2c_write(COMPAS_ADR); |
i2c_write(0x1); |
i2c_stop(); |
i2c_start(); |
i2c_write(COMPAS_ADR+1); |
ble=i2c_read(0); |
i2c_stop(); |
disp(ble); |
delay_ms(200); |
} |
else |
{ |
i2c_start(); // Diagnostika sonaru |
i2c_write(SONAR_ADR); |
i2c_write(0x02); // dosah |
i2c_write(0x03); // n*43mm |
i2c_stop(); |
i2c_start(); |
i2c_write(SONAR_ADR); |
i2c_write(0x01); // zesileni |
i2c_write(0x01); // male, pro eliminaci echa z minuleho mereni |
i2c_stop(); |
i2c_start(); // Sonar Ping |
i2c_write(0xE0); |
i2c_write(0x0); |
i2c_write(0x51); // 50 mereni v palcich, 51 mereni v cm, 52 v us |
i2c_stop(); |
delay_ms(100); |
i2c_start(); // Odraz ze sonaru |
i2c_write(0xE0); |
i2c_write(0x3); |
i2c_stop(); |
i2c_start(); |
i2c_write(0xE1); |
n=i2c_read(0); |
i2c_stop(); |
disp(n); // Zobrazeni hodnoty ze sonaru a zaroven diagnostika predniho IR cidla |
delay_ms(200); |
} |
} |
} |
/roboti/istrobot/camerus/SW/876/camerus.PJT |
---|
0,0 → 1,57 |
[PROJECT] |
Target=camerus.HEX |
Development_Mode= |
Processor=0x876A |
ToolSuite=CCS |
[Directories] |
Include=C:\Program Files\PICC\devices\;C:\Program Files\PICC\Dr |
Library= |
LinkerScript= |
[Target Data] |
FileList=C:\dokumenty\svn\Kaklik\roboti\istrobot\camerus\SW\876\camerus.c |
BuildTool=C-COMPILER |
OptionString=+FM |
AdditionalOptionString= |
BuildRequired=1 |
[camerus.c] |
Type=4 |
Path= |
FileList= |
BuildTool= |
OptionString= |
AdditionalOptionString= |
[mru-list] |
1=camerus.c |
[Windows] |
0=0000 camerus.c 0 0 796 451 3 0 |
[Opened Files] |
1=C:\dokumenty\svn\Kaklik\roboti\istrobot\camerus\SW\876\camerus.c |
2=C:\dokumenty\svn\Kaklik\roboti\istrobot\camerus\SW\876\camerus.h |
3=C:\Program Files\PICC\devices\16F876A.h |
4=C:\dokumenty\svn\Kaklik\roboti\istrobot\camerus\SW\876\objizdka_L.c |
5=C:\dokumenty\svn\Kaklik\roboti\istrobot\camerus\SW\876\diag.c |
6= |
[debugperif] |
selected=Analog/Digital Conv |
[debugram] |
autoread=1 |
[debugeedata] |
autoread=1 |
[debugbreak] |
count=0 |
[pcwdebug] |
watchcol0=75 |
[debugwatch] |
count=0 |
[debugexpr] |
expr= |
sideeffects=0 |
[Units] |
Count=1 |
1=C:\dokumenty\svn\Kaklik\roboti\istrobot\camerus\SW\876\camerus.c (main) |
/roboti/istrobot/camerus/SW/876/camerus.h |
---|
0,0 → 1,16 |
#include <16F876A.h> |
#device adc=8 |
#FUSES NOWDT //No Watch Dog Timer |
#FUSES HS //High speed Osc (> 4mhz) |
#FUSES NOPUT //No Power Up Timer |
#FUSES NOPROTECT //Code not protected from reading |
#FUSES NODEBUG //No Debug mode for ICD |
#FUSES NOBROWNOUT //No brownout reset |
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O |
#FUSES NOCPD //No EE protection |
#FUSES NOWRT //Program memory not write protected |
#use delay(clock=20000000) |
#use i2c(Master,Fast,sda=PIN_C4,scl=PIN_C3,force_hw) |
/roboti/istrobot/camerus/SW/876 |
---|
Property changes: |
Added: svn:ignore |
+*.bak |
+*.BAK |
+*.cof |
+*.err |
+*.hex |
+*.lst |
+*.sta |
+*.sym |
+*.tre |
/roboti/istrobot/camerus/SW/873/camerus.PJT |
---|
0,0 → 1,55 |
[PROJECT] |
Target=camerus.HEX |
Development_Mode= |
Processor=0x873A |
ToolSuite=CCS |
[Directories] |
Include=C:\Program Files\PICC\devices\;C:\Program Files\PICC\Dr |
Library= |
LinkerScript= |
[Target Data] |
FileList=C:\dokumenty\svn\Kaklik\roboti\istrobot\camerus\SW\873\camerus.c |
BuildTool=C-COMPILER |
OptionString=+FM |
AdditionalOptionString= |
BuildRequired=1 |
[camerus.c] |
Type=4 |
Path= |
FileList= |
BuildTool= |
OptionString= |
AdditionalOptionString= |
[mru-list] |
1=camerus.c |
[Windows] |
0=0000 camerus.c 0 0 796 451 3 0 |
[Opened Files] |
1=C:\dokumenty\svn\Kaklik\roboti\istrobot\camerus\SW\873\camerus.c |
2=C:\dokumenty\svn\Kaklik\roboti\istrobot\camerus\SW\873\camerus.h |
3=C:\Program Files\PICC\devices\16F873A.h |
4= |
[debugperif] |
selected=Analog/Digital Conv |
[debugram] |
autoread=1 |
[debugeedata] |
autoread=1 |
[debugbreak] |
count=0 |
[pcwdebug] |
watchcol0=75 |
[debugwatch] |
count=0 |
[debugexpr] |
expr= |
sideeffects=0 |
[Units] |
Count=1 |
1=C:\dokumenty\svn\Kaklik\roboti\istrobot\camerus\SW\873\camerus.c (main) |
/roboti/istrobot/camerus/SW/873/camerus.c |
---|
0,0 → 1,512 |
//********* Robot Camerus pro IstRobot 2007 ************ |
//"$Id: camerus.c 229 2007-04-09 11:41:19Z kakl $" |
//***************************************************** |
#include ".\camerus.h" |
#USE FAST_IO (C) // Brana C je ve FAST_IO modu, aby slo rychle cist z kamery |
// A/D vstupy |
#define RMAX 4 // AN4/RA5 - leve cidlo na vyjeti z cary |
#define LMAX 3 // AN3/RA3 - prave cidlo na vyjeti z cary |
#define CERVENA 2 // AN2/RA2 - cervene kroutitko |
#define ZELENA 1 // AN1/RA0 - zelene kroutitko |
#define MODRA 0 // AN0/RA1 - modre kroutitko |
// I/O |
#define HREF PIN_C5 // Signal HREF z kamery (v H po celou dobu radku) |
#define PIX PIN_C6 // Vstup pro body z kamery (za trivstupim hradlem OR (dig. komparator)) |
#define SERVO PIN_B4 // Vystup na servo (1 az 2ms po cca 20ms (synchronizovano snimkovym kmitoctem)) |
#define MOT_L PIN_B5 // Smer otaceni leveho motoru; druhy pol je RC2 |
#define MOT_R PIN_B6 // Smer otaceni praveho motoru; druhy pol je RC1 |
#define MOT_1 PIN_C1 // PWM vystpy motoru |
#define MOT_2 PIN_C2 // |
#define DATA PIN_B2 // K modulu LEDbar data |
#define CP PIN_B1 // K modulu LEDbar hodiny |
//#define ODO PIN_C0 // Ze snimace z odometrie z praveho kola na TIMER1 |
// Jeden impuls je 31,25mm |
#define IRRX PIN_B0 // Vstup INT, generuje preruseni pri prekazce |
#define IRTX PIN_B3 // Modulovani vysilaci IR LED na detekci prekazky |
#define PROXIMITY PIN_C7 // Cidlo kratkeho dosahu na cihlu |
#define CASMIN 6 // Rozsah radku snimace |
#define CASMAX 192 |
#define CASAVR ((CASMAX+CASMIN) / 2) |
#define OFFSETO 0x9F //0x9F // Vystredeni serva pro objeti prekazky |
#define THR 90 // Threshold pro UV cidla na caru |
#byte INTCON = 0x0B // Interrupt configuration register |
#bit GIE = INTCON.7 |
#bit PEIE = INTCON.6 |
#bit TMR0IE = INTCON.5 |
#bit INT0IE = INTCON.4 |
#bit RBIE = INTCON.3 |
#bit TMR0IF = INTCON.2 |
#bit INT0IF = INTCON.1 |
#bit RBIF = INTCON.0 |
enum stavy {start,rozjezd,jizda,cihla,pocihle,cil}; |
stavy stav; // Kde jsme na trati |
int8 cas; // Cas hrany bila/cerna v radce |
int8 stred; // Vystredeni kolecka |
int16 odocounter; // Zaznamenani aktualniho stavu pocitadla odometrie |
int8 rr; // Promenna na ulozeni Rozumne rychlost |
int8 rrold; |
//int8 pole_h[0x40]; |
int8 pole_l[0x40]; |
// Zobrazeni jednoho byte na modulu LEDbar |
inline void disp(int8 x) |
{ |
int n; |
for(n=0;n<=7;n++) |
{ |
if (x & 1 == 1) output_low(DATA); else output_high(DATA); |
output_high(CP); |
x>>=1; |
output_low(CP); |
} |
} |
// Blikani LEDbarem ve stilu Night Rider |
void NightRider(int8 x) |
{ |
int n,i,j; |
for(j=0;j<x;j++) |
{ |
i=0x01; |
for(n=0;n<7;n++) |
{ |
disp(i); |
rotate_left(&i, 1); |
delay_ms(40); |
} |
for(n=0;n<7;n++) |
{ |
disp(i); |
rotate_right(&i, 1); |
delay_ms(40); |
} |
} |
disp(i); |
delay_ms(40); |
i=0; |
disp(i); |
} |
// Brzdeni motorama stridou 1:1 |
void brzda() |
{ |
int8 n,i; |
set_pwm1_duty(0); // vypni PWM |
set_pwm2_duty(0); |
setup_ccp1(CCP_OFF); |
setup_ccp2(CCP_OFF); |
for (n=0;n<200;n++) |
{ |
output_low(MOT_L); |
output_low(MOT_R); |
output_high(MOT_1); |
output_high(MOT_2); |
delay_us(200); |
output_high(MOT_L); |
output_high(MOT_R); |
output_low(MOT_1); |
output_low(MOT_2); |
delay_us(200); |
} |
output_low(MOT_L); // smer vpred |
output_low(MOT_R); |
setup_ccp1(CCP_PWM); // RC1 // Zapni PWM pro motory |
setup_ccp2(CCP_PWM); // RC2 |
} |
void SetServo(int8 angle) |
{ |
int8 n; |
for(n=0; n<14; n++) |
{ |
output_high(SERVO); // Odvysilani impuzu 1 az 2ms pro servo |
delay_us(1000); |
delay_us(stred); |
delay_us(stred); |
delay_us(stred); |
delay_us(angle); |
delay_us(angle); |
output_low(SERVO); |
delay_ms(18); |
} |
} |
inline void SetServoQ(int8 angle) |
{ |
output_high(SERVO); // Odvysilani impuzu 1 az 2ms pro servo |
delay_us(1000); |
delay_us(stred); |
delay_us(stred); |
delay_us(stred); |
delay_us(angle); |
delay_us(angle); |
output_low(SERVO); |
} |
//---------------------------- INT -------------------------------- |
#int_EXT |
EXT_isr() // Preruseni od prekazky |
{ |
set_pwm1_duty(0); // zabrzdi levym kolem, prave vypni |
set_pwm2_duty(0); |
output_high(MOT_L); |
output_low(MOT_R); |
// Ujistime se, ze prijaty signal je z naseho IR vysilace |
output_high(IRTX); // Vypni LED na detekci prekazky |
delay_ms(2); |
if (!input(IRRX)) // stale nas signal? |
{ |
output_low(MOT_L); // je odraz -> vpred |
output_low(MOT_R); |
return; |
}; |
output_low(IRTX); // Zapni LED na detekci prekazky |
delay_ms(10); |
if (input(IRRX)) // stale nas signal? |
{ |
output_low(MOT_L); // neni odraz -> vpred |
output_low(MOT_R); |
return; |
}; |
//!!! if(stav==cihla) while(true); // Zastav na furt, konec drahy |
// if(stav==cihla) return; // Po druhe nic neobjizdej |
// Pozor na rozjezd |
if(stav==jizda) // Objed cihlu |
{ |
#include ".\objizdka_L.c" |
} |
} |
//---------------------------------- MAIN -------------------------------------- |
void main() |
{ |
int8 offset; // Promena pro ulozeni offsetu |
int8 r1; // Rychlost motoru 1 |
int8 r2; // Rychlost motoru 2 |
setup_adc_ports(ALL_ANALOG); // Zapnuti A/D prevodniku pro cteni kroutitek |
setup_adc(ADC_CLOCK_INTERNAL); |
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); // Casovac pro mereni casu hrany W/B v radce |
setup_timer_1(T1_EXTERNAL); // Cita pulzy z odometrie z praveho kola |
setup_timer_2(T2_DIV_BY_16,255,1); // Casovac PWM motoru |
setup_ccp1(CCP_PWM); // RC1 // PWM pro motory |
setup_ccp2(CCP_PWM); // RC2 |
setup_comparator(NC_NC_NC_NC); |
setup_vref(FALSE); |
set_tris_c(0b11111001); // Nastaveni vstup/vystup pro branu C, protoze se nedela automaticky |
set_pwm1_duty(0); // Zastav motory |
set_pwm2_duty(0); |
output_low(MOT_L); // Nastav smer vpred |
output_low(MOT_R); |
output_low(IRTX); // Zapni LED na detekci prekazky |
NightRider(1); // Aby se poznalo, ze byl RESET |
// taky se musi pockat, nez se rozjede kamera, nez se do ni zacnou posilat prikazy |
/* |
for(cas=0;cas<=0x3F;cas++) |
{ |
pole_h[cas]=0x80|cas; |
pole_l[cas]=cas; |
} |
for(cas=0;cas<=0x7F;cas+=2) |
{ |
write_eeprom(cas,pole_h[cas/2]); |
write_eeprom(cas+1,pole_l[cas/2]); |
} |
*/ |
while(true) |
{ |
output_high(PIN_B0); |
delay_ms(200); |
output_low(PIN_B0); |
delay_ms(200); |
} |
//... Nastaveni sonaru ... |
i2c_start(); |
i2c_write(0xE0); |
i2c_write(0x02); // dosah |
i2c_write(0x03); // n*43mm |
i2c_stop(); |
i2c_start(); |
i2c_write(0xE0); |
i2c_write(0x01); // zesileni |
i2c_write(0x01); // male, pro eliminaci echa z minuleho mereni |
i2c_stop(); |
// pro ladeni sonaru |
/* |
while(true) |
{ |
i2c_start(); // Sonar Ping |
i2c_write(0xE0); |
i2c_write(0x0); |
i2c_write(0x51); // 50 mereni v palcich, 51 mereni v cm, 52 v us |
i2c_stop(); |
delay_ms(100); |
i2c_start(); // Odraz ze sonaru |
i2c_write(0xE0); |
i2c_write(0x3); |
i2c_stop(); |
i2c_start(); |
i2c_write(0xE1); |
cas=i2c_read(0); |
i2c_stop(); |
disp(cas); |
} |
*/ |
//... Nastaveni kamery ... |
i2c_start(); // Soft RESET kamery |
i2c_write(0xC0); // Pro single slave musi mit vsechny zapisy adresu C0h |
i2c_write(0x12); // Adresa registru COMH |
i2c_write(0x80 | 0x24); // Zapis ridiciho slova |
i2c_stop(); |
i2c_start(); // BW |
i2c_write(0xC0); |
i2c_write(0x28); |
i2c_write(0b01000001); |
i2c_stop(); |
/* |
i2c_start(); // Contrast (nema podstatny vliv na obraz) |
i2c_write(0xC0); |
i2c_write(0x05); |
i2c_write(0xA0); // 48h |
i2c_stop(); |
i2c_start(); // Band Filter (pokud by byl problem se zarivkama 50Hz) |
i2c_write(0xC0); |
i2c_write(0x2D); |
i2c_write(0x04 | 0x03); |
i2c_stop(); |
*/ |
i2c_start(); // Fame Rate |
i2c_write(0xC0); |
i2c_write(0x2B); |
i2c_write(0x00); // cca 17ms (puvodni hodnota 5Eh = 20ms) |
i2c_stop(); |
i2c_start(); // VSTRT |
i2c_write(0xC0); |
i2c_write(0x19); |
i2c_write(118); // prostredni radka |
i2c_stop(); |
i2c_start(); // VEND |
i2c_write(0xC0); |
i2c_write(0x1A); |
i2c_write(118); |
i2c_stop(); |
NightRider(1); // Musi se dat cas kamere na AGC a AEC |
{ // Mereni expozice |
int8 t1,t2; |
i2c_start(); // Brightness, zacni od uplne tmy |
i2c_write(0xC0); |
i2c_write(0x06); |
i2c_write(0); // 80h default |
i2c_stop(); |
delay_ms(50); |
for(offset=0x04;offset<(255-0x04);offset+=0x04) // Zacni od jasu 10h |
{ |
i2c_start(); // Brightness |
i2c_write(0xC0); |
i2c_write(0x06); |
i2c_write(offset); // 80h default |
i2c_stop(); |
disp(offset); |
delay_ms(50); |
t1=0; |
t2=0; |
while(!input(HREF)); // Cekej nez se zacnou posilat pixely z radky |
delay_ms(5); |
while(!input(HREF)); // Cekej nez se zacnou posilat pixely z radky |
set_timer0(0); // Vynuluj pocitadlo casu |
if(!input(PIX)) continue; |
while(input(PIX)); |
t1=get_timer0(); // Precti cas z citace casu hrany |
set_timer0(0); // Vynuluj pocitadlo casu |
while(!input(PIX)); |
t2=get_timer0(); |
if((t1>60) && (t1<140) && (t2>5) && (t2<=10)) break; // Vidis, co mas? |
delay_ms(2); // Preskoc druhou radku z kamery |
}; |
delay_ms(1000); // Nech chvili na displayi zmerenou hodnotu |
} |
set_adc_channel(CERVENA); // --- Kroutitko pro jas --- |
delay_ms(1); |
offset=read_adc(); |
offset &= 0b11111100; // Dva nejnizsi bity ignoruj |
// offset += 0x70; // Jas nebude nikdy nizsi |
disp(offset); |
i2c_start(); // Brightness |
i2c_write(0xC0); |
i2c_write(0x06); |
i2c_write(offset); // 80h default |
i2c_stop(); |
delay_ms(1000); // Nech hodnotu chvili na displayi |
set_adc_channel(ZELENA); // --- Kroutitko pro vykon motoru --- |
delay_ms(1); |
rr=read_adc()>>2; // 0-31 // Pokud by se zvetsil rozsah, tak zkontrolovat jakonasobeni !!! |
rrold=rr; |
cas=CASAVR-CASMIN; // Inicializace promenych, aby neslo servo za roh |
// a aby se to rozjelo jeste dneska |
stav=start; // Jsme na startu |
set_timer1(0); // Vynuluj citac odometrie |
// ........................... Hlavni smycka ................................ |
while(true) |
{ |
int8 pom; |
int8 n; |
next_snap: |
pom=0; |
disable_interrupts(GLOBAL); //----------------------- Critical |
while(input(HREF)); // Preskoc 1. radku |
while(!input(HREF)); // Cekej nez se zacnou posilat pixely z 2. radky |
set_timer0(0); // Vynuluj pocitadlo casu |
while(input(HREF)) // Po dobu vysilani radky cekej na hranu W/B |
{ |
// !!!!Dodelat rozpoznani cerne cary napric pro zastaveni ? |
if(!input(PIX)) // Pokud se X-krat za sebou precetla CERNA |
if(!input(PIX)) |
// if(!input(PIX)) |
{ |
pom=get_timer0(); // Precti cas z citace casu hrany |
break; |
}; |
}; |
while(input(HREF)); // Pockej na shozeni signalu HREF |
if((pom<CASMAX) && (pom>CASMIN)) cas=pom; // Orizni konce radku |
// Na konci obrazovaho radku to blbne. Jednak chyba od apertury |
// a vubec to nejak na kraji nefunguje. |
output_high(SERVO); // Odvysilani impuzu 1 az 2ms pro servo |
delay_us(1000); |
delay_us(stred); |
delay_us(stred); |
delay_us(stred); |
delay_us(cas); |
delay_us(cas); |
output_low(SERVO); |
// Elektronicky diferencial |
if(cas<CASAVR) {r1=cas-CASMIN; r2=CASAVR-CASMIN;}; // Normovani vystupni hodnoty radkoveho snimace |
if(cas==CASAVR) {r1=cas-CASMIN; r2=cas-CASMIN;}; // pro rizeni rychlosti motoru |
if(cas>CASAVR) {r1=CASAVR-CASMIN; r2=CASMAX-cas;}; // Rozsah 1 az 92 |
enable_interrupts(GLOBAL); //----------------------- Critical |
if (r1>(CASAVR-CASMIN-rr)) r1=(r1<<1)+rr-(CASAVR-CASMIN); // Neco jako nasobeni |
if (r2>(CASAVR-CASMIN-rr)) r2=(r2<<1)+rr-(CASAVR-CASMIN); |
// r1<<=1; // Rychlost je dvojnasobna |
// r2<<=1; // Rozsah 2 az 184 |
/* Nerozumna rychlost po cihle |
if ((stav==cihla)&&(get_timer1()>(odocounter+5))) // Snizime rychlost po ujeti |
{ |
rr=rrold; |
stav=pocihle; |
}; |
*/ |
if ((stav==jizda)||(stav==cihla)||(stav==rozjezd)) //||(stav==pocihle)) // Jizda |
{ |
set_pwm1_duty(r1); |
set_pwm2_duty(r2); |
} |
else |
{ |
set_pwm1_duty(0); // Zastaveni |
set_pwm2_duty(0); |
}; |
if((stav==rozjezd)&&(get_timer1()>10)) // musi ujet alespon 31cm |
{ |
ext_int_edge(H_TO_L); // Nastav podminky preruseni od cihly |
INT0IF=0; // Zruseni predesle udalosti od startera |
enable_interrupts(INT_EXT); |
enable_interrupts(GLOBAL); |
stav=jizda; |
}; |
if(stav==start) // Snimkuje, toci servem a ceka na start |
{ |
set_adc_channel(MODRA); // Kroutitko na vystredeni predniho kolecka |
Delay_ms(1); |
stred=read_adc(); |
if(!input(PROXIMITY)) |
{ |
disp(0x80); |
while(input(PROXIMITY)); // Cekej, dokud starter neda ruku pryc |
set_timer1(0); // Vynuluj citac odometrie |
set_pwm1_duty(255); // Rychly rozjezd !!! Zkontrolovat na oscyloskopu |
set_pwm2_duty(255); |
disp(0x01); |
while(get_timer1()<=4) // Ujed alespon 12cm |
{ |
set_adc_channel(LMAX); // Levy UV sensor |
delay_us(40); |
if(read_adc()<THR) {cas=CASMIN; break;}; // Prejeli jsme caru vlevo |
set_adc_channel(RMAX); // Pravy UV sensor |
delay_us(40); |
if(read_adc()<THR) {cas=CASMAX; break;}; // Prejeli jsme caru vpravo |
cas=CASAVR-CASMIN; // Cara je rovne |
}; |
stav=rozjezd; |
}; |
} |
pom=0x80; // Zobrazeni pozice cary na displayi |
for(n=CASMAX/8; n<cas; n+=CASMAX/8) pom>>=1; |
disp(pom); |
while(true) // Ve zbytku casu snimku cti krajni UV senzory |
{ |
set_adc_channel(LMAX); // Levy UV sensor |
for(n=0;n<20;n++) if(input(HREF)) goto next_snap; |
if(read_adc()<THR) cas=CASMIN; |
set_adc_channel(RMAX); // Pravy UV sensor |
for(n=0;n<20;n++) if(input(HREF)) goto next_snap; |
if(read_adc()<THR) cas=CASMAX; |
}; |
} |
} |
/roboti/istrobot/camerus/SW/873/camerus.h |
---|
0,0 → 1,16 |
#include <16F873A.h> |
#device adc=8 |
#FUSES NOWDT //No Watch Dog Timer |
#FUSES HS //High speed Osc (> 4mhz) |
#FUSES NOPUT //No Power Up Timer |
#FUSES NOPROTECT //Code not protected from reading |
#FUSES NODEBUG //No Debug mode for ICD |
#FUSES NOBROWNOUT //No brownout reset |
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O |
#FUSES NOCPD //No EE protection |
#FUSES NOWRT //Program memory not write protected |
#use delay(clock=20000000) |
#use i2c(Master,Fast,sda=PIN_C4,scl=PIN_C3,force_hw) |
/roboti/istrobot/camerus/SW/873 |
---|
Property changes: |
Added: svn:ignore |
+*.bak |
+*.BAK |
+*.cof |
+*.err |
+*.hex |
+*.lst |
+*.sta |
+*.sym |
+*.tre |
/roboti/istrobot/camerus/DOC/camerus.pdf |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/roboti/istrobot/camerus/DOC/Camerus.doc |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/roboti/istrobot/camerus/DOC/CAMERUS.DSN |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/roboti/istrobot/camerus/DOC/prevodovky/prevodovka.fcb |
---|
0,0 → 1,137 |
G90 G40 |
M40 |
M6 T1 |
M3 S6000 |
G0 X0Y0 Z2.5 |
G1 Z-3.4 F100.0 |
G0 Z50. |
X12.49 Y-10. |
Z2.5 |
G1 Z-3.4 |
G0 Z50. |
X21 Y-25.4 |
Z2.5 |
G1 Z-3.4 |
G0 Z50. |
X12.49 |
Z2.5 |
G1 Z-3.4 |
G0 Z50. |
X4 |
Z2.5 |
G1 Z-3.4 |
G0 Z50. |
M30 |
M9 |
M6 T2 |
M3 S6000 |
G0 X-3.071 Y-10.594 |
G0 Z2.5 |
G1 Z0 F100.0 |
X-7.035 Y-11.131 Z-0.5 |
X-5.053 Y-10.863 |
X-3.071 Y-10.594 |
G2 X-1.383 Y-11.879 I-2.87 J-12.081 |
G1 X0.599 Y-26.511 F200.0 |
G3 X24.381 I12.49 J-24.9 |
G1 X26.363 Y-11.879 |
G3 X4.84 Y1.725 I12.49 J-10. |
G2 X3.435 Y2.05 I4.293 J2.563 |
G3 X-1.249 Y-3.8 I0 J0 |
G2 X-0.625 Y-5.1 I-1.561 J-4.75 |
G3 X-1.383 Y-11.879 I12.49 J-10. |
G2 X-2.668 Y-13.567 I-2.87 J-12.081 F100.0 |
G1 X-3.071 Y-10.594 F200.0 |
X-7.035 Y-11.131 Z-1. F100.0 |
X-5.053 Y-10.863 |
X-3.071 Y-10.594 |
G2 X-1.383 Y-11.879 I-2.87 J-12.081 |
G1 X0.599 Y-26.511 F200.0 |
G3 X24.381 I12.49 J-24.9 |
G1 X26.363 Y-11.879 |
G3 X4.84 Y1.725 I12.49 J-10. |
G2 X3.435 Y2.05 I4.293 J2.563 |
G3 X-1.249 Y-3.8 I0 J0 |
G2 X-0.625 Y-5.1 I-1.561 J-4.75 |
G3 X-1.383 Y-11.879 I12.49 J-10. |
G2 X-2.668 Y-13.567 I-2.87 J-12.081 F100.0 |
G1 X-3.071 Y-10.594 F200.0 |
X-7.035 Y-11.131 Z-1.5 F100.0 |
X-5.053 Y-10.863 |
X-3.071 Y-10.594 |
G2 X-1.383 Y-11.879 I-2.87 J-12.081 |
G1 X0.599 Y-26.511 F200.0 |
G3 X24.381 I12.49 J-24.9 |
G1 X26.363 Y-11.879 |
G3 X4.84 Y1.725 I12.49 J-10. |
G2 X3.435 Y2.05 I4.293 J2.563 |
G3 X-1.249 Y-3.8 I0 J0 |
G2 X-0.625 Y-5.1 I-1.561 J-4.75 |
G3 X-1.383 Y-11.879 I12.49 J-10. |
G2 X-2.668 Y-13.567 I-2.87 J-12.081 F100.0 |
G1 X-3.071 Y-10.594 F200.0 |
X-7.035 Y-11.131 Z-2. F100.0 |
X-5.053 Y-10.863 |
X-3.071 Y-10.594 |
G2 X-1.383 Y-11.879 I-2.87 J-12.081 |
G1 X0.599 Y-26.511 F200.0 |
G3 X24.381 I12.49 J-24.9 |
G1 X26.363 Y-11.879 |
G3 X4.84 Y1.725 I12.49 J-10. |
G2 X3.435 Y2.05 I4.293 J2.563 |
G3 X-1.249 Y-3.8 I0 J0 |
G2 X-0.625 Y-5.1 I-1.561 J-4.75 |
G3 X-1.383 Y-11.879 I12.49 J-10. |
G2 X-2.668 Y-13.567 I-2.87 J-12.081 F100.0 |
G1 X-3.071 Y-10.594 F200.0 |
X-7.035 Y-11.131 Z-2.5 F100.0 |
X-5.053 Y-10.863 |
X-3.071 Y-10.594 |
G2 X-1.383 Y-11.879 I-2.87 J-12.081 |
G1 X0.599 Y-26.511 F200.0 |
G3 X24.381 I12.49 J-24.9 |
G1 X26.363 Y-11.879 |
G3 X4.84 Y1.725 I12.49 J-10. |
G2 X3.435 Y2.05 I4.293 J2.563 |
G3 X-1.249 Y-3.8 I0 J0 |
G2 X-0.625 Y-5.1 I-1.561 J-4.75 |
G3 X-1.383 Y-11.879 I12.49 J-10. |
G2 X-2.668 Y-13.567 I-2.87 J-12.081 F100.0 |
G1 X-3.071 Y-10.594 F200.0 |
X-7.035 Y-11.131 Z-3. F100.0 |
X-5.053 Y-10.863 |
X-3.071 Y-10.594 |
G2 X-1.383 Y-11.879 I-2.87 J-12.081 |
G1 X0.599 Y-26.511 F200.0 |
G3 X24.381 I12.49 J-24.9 |
G1 X26.363 Y-11.879 |
G3 X4.84 Y1.725 I12.49 J-10. |
G2 X3.435 Y2.05 I4.293 J2.563 |
G3 X-1.249 Y-3.8 I0 J0 |
G2 X-0.625 Y-5.1 I-1.561 J-4.75 |
G3 X-1.383 Y-11.879 I12.49 J-10. |
G2 X-2.668 Y-13.567 I-2.87 J-12.081 F100.0 |
G1 X-3.071 Y-10.594 F200.0 |
X-7.035 Y-11.131 Z-3.5 F100.0 |
X-5.053 Y-10.863 |
X-3.071 Y-10.594 |
G2 X-1.383 Y-11.879 I-2.87 J-12.081 |
G1 X0.599 Y-26.511 F200.0 |
G3 X24.381 I12.49 J-24.9 |
G1 X26.363 Y-11.879 |
G3 X4.84 Y1.725 I12.49 J-10. |
G2 X3.435 Y2.05 I4.293 J2.563 |
G3 X-1.249 Y-3.8 I0 J0 |
G2 X-0.625 Y-5.1 I-1.561 J-4.75 |
G3 X-1.383 Y-11.879 I12.49 J-10. |
G2 X-2.668 Y-13.567 I-2.87 J-12.081 F100.0 |
G0 z50 |
M6 T1 |
G0 X0 Y0 Z50 |
M30 |
/roboti/istrobot/camerus/DOC/prevodovky/README.txt |
---|
0,0 → 1,3 |
Pøevodovka 5:1 pro motor speed 300 |
Pøi zalepování loisek je nutno dbát, aby loisko v èele u motoru bylo na stranì motoru srovnáno s rovinou èela, jinak by docházelo k vyklánìní osy pøevodovky. |
/roboti/istrobot/camerus/DOC/Fotky/P3110001.JPG |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/roboti/istrobot/camerus/DOC/Fotky/P3110002.JPG |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/roboti/istrobot/camerus/DOC/Fotky/P3110003.JPG |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/roboti/istrobot/camerus/DOC/Fotky/P3110004.JPG |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/roboti/istrobot/camerus/DOC/Fotky/P3180013.JPG |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/roboti/istrobot/camerus/DOC/Fotky/P3180014.JPG |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/roboti/istrobot/camerus/DOC/Fotky/P3180015.JPG |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/roboti/istrobot/camerus/DOC/Fotky/P3180024.JPG |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/roboti/istrobot/camerus/DOC/Fotky/P3180025.JPG |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/roboti/istrobot/camerus/DOC/Fotky/P3180026.JPG |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/roboti/istrobot/camerus/DOC/Fotky/P3180027.JPG |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/roboti/istrobot/camerus/DOC/Fotky/P3180028.JPG |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/roboti/istrobot/camerus/ToDo.txt |
---|
0,0 → 1,11 |
- Tlaèítko na vypnutí, pøípadnì (IRDA) |
- vyrobit modul na oci |
- Udìlat podsvìtlení, aby se robot líbil porotì. |
+- modul s LED, nebo neosadit stabilizator do modulu LEDrobot |
+ |
+- vymyslet postup kalibrace kamery (jak vizualizovat co kamera vidi) |
+ - co pouzit LEDbar? |
+ |
+- projit problemy lonske konstrukce |
/roboti/istrobot/camerus/HW/CAM_AMA/BOARD.pdf |
---|
0,0 → 1,159 |
%PDF-1.3 |
%Çì¢ |
5 0 obj |
<</Length 6 0 R/Filter /FlateDecode>> |
stream |
+óIrÐJÒ˹Zj»ç³°è$gïHKjÒPC>g¥DÝÖM*¦m¸va¸ÎAwj2QéÐÓ`Ë'Ã%KcöNòiXÎÊÄêâ[JÍ"M4CC¤vsaÙ |
+(~¯±Ú±¯hÿ\Èã&õ*ÃïêW)½¢¢cºJÓU[Þ9]¥\Û«¾"㦹ÛtUGãÅéªMÏ` |
+Z·ÞHòþpßÆ |
+ SMʘj |
+Z&½³¢ºîNS@t§[æ°é%ͽ2Ê$±YNÑKÂTSpnt>Ïwb1ס'7égQ¯æÁ) |
+Z&íòlwýp»ÉGÞ1]5øŸØïöjziÁÍÆIWâ ylüô èkÔ6ønoÔF¥»mM'CûVÕ7 |
+Ö'ñ½ Û%>ºÎAö^«®²äáÄN9yo1úÜáµ Ó |
+óhLÍ9hTÞ@ôdØþ³oåá)]I3~ªÆ`ydhå¥üL%Â8Í¢otIÞÍ,X {³ôf2³Pz`ðkf1'÷ÃSÌ,xÁ6:úfyJWYåfÍsÍ=®Z[&ÎÑsÁعM©-<UµEyú8õ çVJº¨-$>)¼´sÐ2)¾d¾ |
+O]½¾çá)]I*¥¼ëÉÖ/åg*qP2ÖY·ø¼©zU£¶ðã¥Y´¶8Y(c ¶0}ÞYP[è¶{´¶8$5³ Ë3Í,ç ®9îðDm©ðáóS¾píÖ^¨%N¾ÁDztTÓ5¼¶Tx9hjÎAˤ§¬Z[kKpÐJRÑ{jmÑrÞ³sµÔ8(EûFÂOÁ»Eº.ö0kKp ÒQM×ðÚÂBkjÎAf©-4K?Í ý³<¥+IÍ,ÁrN3-"ñ%â ¢l[ê==Ñi=Ï |
+eÛ¢Ì3Hpfµ8e·¤½ñ8h½ÇØõlW¤ §¿:-²É='byDò38(ÅF[ôDäÝ̶ Åô0¶-ÎAfJwëHGÅú=ã 3{.á<érimË3Í,ç Ý92ñmI¯cò][ |
+<B¤¨3j1Vú°r§ÝµE>Îð ±ÔIOñ³.zëYÂÃóð®$½}·ÜÙº¿¢©ÄAÉ,¬-²Ý¥àÝÌ"uD÷ö0kKp R| ïfÛáºqEÚ¥f~YÒ¤fÆ@y¦Åò`Ä&'$`vM&U_ÿþ?(=&ûϤç>÷°ï@Ïç9¡Ò'á¬}2O'5ÓvKqbÜFzè«ÎAˤS4`]ç" ó<<¤+Iq¨o²<Ðe¥üL%âUÛÜ,\$±Å¢MÍÒë©fárÍbÌEã °:\:Ô,J\°âacLÍ9htCÍ¢)À,ÁA+IEï©fÑò./åg*qm·d |
+¢Lì>M³(1Ól#Lé±pú tt¦ÛøJ´\ |
+f ¦@³8-r· òùmí|E)?SôCúõºX©¶Áé%-VZe²XzJÞÆÃãLy¦|ùÍ ×þ#ôg:§ÊÍí[Þª®]hÆúÇÂodúeÞxúV!ôVhbçñ±X9Ö±XÎd'^¢Ó1U/çgÜóoç+qÐÒó#(ÅÓh×s ¯ÄAˤ²;§p.)O+§t%é¥g ËVê+JùJgÙ¹£÷ûpôþp't¸ÙÿOrNÿHîòï?rÿù/96¤cC%M©¦øúÛ+É4¾ðþøHG¼ÿè¨/÷æÇvý»íá ÞqXoÔç^xï?òÂ2à>þÒýú®_yû%ÏÀä-8_ºê#yC¾¿zCâãª'¸zCú×`ñ/Góu¬¯ðdüüO=òIyÄ0Rïwõ7¶Õ©ØsÖÍlv<Å_ó-ýí/ëË<XuC·y¸ZilÓÞýör?Xã ¼fDsñM|É÷ýGþ¸ØúÕýîá{ýÊï7ûëv»ð&ÎoùÞò¿âüó_ÿv¬¾ï[Ä·_Å7ë𼮪Å|Éßÿ¿ñßx ÿÞçûw)'öú$õè¯Z£mm6¯úªéÏ~×cÿ#!ðþÎøHg¼ÿè,;©¡säï©ð[}¿:Ïáq"Îðg`'Jä3'ò9é¬ |
+>Òï?:cáãëqí¥P<\u¾"ñKwH2ðbVÎEµ77Äö |
+1Gç"ÎZÌ¥.úÆAx7ç¦_XócJ̹ZÈÌ%Û²æ¤ië!¿lýeWE*÷¹¤·W8§þçô£t×ö+ËÝõüwåÃ¥ã/ä|¤+ß:áú49óÅjs_ׯÜþý»ãç>ÿ¼ÄA×ÇñÓÞoGðãISsJWÙÿÆ1éà÷?pðÃJAKþõ(~÷Ët¸Esê${W¿ñáxÿÑ!~¼.ñc=®_ûáß??,.»Íj4Bws'}ð®õÂh{åLìXóqÀÉ2Cóß80å#áòþpùHGɼÿè(8@ïþþö6?×ÇãÒ!::JýÙ<?;°ç§c n}Ðz4Ñ_<xèWÇ |
+Iäõé£wºÜìú¯?+Ñì¢4|»Övð |
+µwºdíúÅ kËÙº_ØÖíbµv\§¾îÎ9-ÚµoÏKæ>qõÜǸ´s»_U/³~ÁÝôKéô:¼þ |
+wîîKQõ@|·×Ì(ñóù§£-váûI÷6oί¼ÞG1øuÊZ²aÓ,b1G9|XÞ8c ÌCkIeÆeî§ë+YçÈkèY[Ra#¼:7u_kzëáÂ2Ç$sZ< õNIIæ´ð¥bsZXsÖ9Éù-Ì$9-½P]¥xw7'-Ãd®¬ïdÑÇ=ðCâcj3ªxÎAÛ>î>¼säëfêl/MbþÌ#çë¥*Ê÷ÓùF»ý3{üs·ÎAË¥é,9á12¨×{@ª¤åb\Ýn©I*8ÐÒnéÙ!Z3ô-DÍÐÂ¥åyºgqvïàî.XÍÝ]*·úd¾[ ³8ÎA뻾ôÎ-îÐR9ÐT}»wb»thli°³f×sA+ùAºÁþ£vÿ%6å/çòïƧ`dÖÚÚ1¾Úà·)öqã|Ó¿¦ré#íöËà ÎKìQƲGU.ñåT0w=¯Ç/1ÊT°×¤Û×=×tî>ù4)Vó?Ó>ÒåAëRqEF:Ôõ |
+ÍÊeßHÙ>|ìsnðn<xÄ?Ý¥xØ×CÒ+øÐ\©±+Zòý¤Ùèw)\E¼eÇÑr)öl\lzÝÁü¯R®RÏi+\±å |
+gȹ¶+°oÏ9(y®'ð|é>@÷émêãµK;²þ«êíªûã.çݽYéíK¦×qPÜ% |
+Ö3iÀ§{ì®K}ëWéJÒÈ%bìÔk¤©)$uBæRIFÍ0Mÿür¸¿ø$¹]Í íºlu÷EºÇl(¨ó8È{)=L¹ù~»(S9h¹´ùÝÝ{äá!]IN<£UÓe¥üL%¢)¹Î ¯ÜÑ/~Åéпe§yÓ÷Vï@=M^ô¬Ã'Ä$½áë[8Bø×o¾µuO÷ºþË¥-ÅÈ7îç}±k8"ÆWâ åÒÃ¥óöáå£ú¿13m´\*ÉàùöÃõjÜí«t%i\®kNxz¹®n*Ëu÷$]Iê®ÞtiÖ¥aK¡¦<è»Û×(ÅiR+}RÍý£ã`ñ ëdºMø'sºøÃ樂)wêiW%±Êî;:ôNiå ¤3¼uÛÔoW9Rë¯ïÞ¼í7Xÿüìæ^¶nV¿_ã+qÐréáÒù |
+Kñ1¨Ûnv$¶£ùw_PÍWs¯9Ç¥å__é»ks¢®©èæÒ5ï_ÝTã:ù},ÜýÍ¡C¬Ñré®oaU·×áµö)]I±ö¾P©ûÃtV^Îíeº§VR¿9ÏöæPj¥R~ÆÉ`î{¤sðõ³-éÁ<üP·ÌÃÏ3Qö`Ô³pWyÙÙ¹ÎAËýRE:uåÉ{¿¯ÄAË¥Ø3¶ñ+ÙR@Óç´ôòºßKuõÈqÐJÒ˹'Õ(å'O |
+ç|3åW÷иëòÃïåEÜÊ»<¹}UYåU¤=ô¾På ¤3\6ÇÔysXóNß]:y'²ñÏn@mL¹¹´zj5å·¦UÏ{My¯^Îêeo©yªÿ5ÏÎé]TpÐr).~íìÍST¯Ý¿JWÆ%²æ¦º¼ã |
+ZIz9w÷VZMyЩ÷¯1 »´¹.ïÀaìð÷áJMÃÄ1kgº5÷kjº÷Ãï:¦Cæ8¼ÃTNeÞè¹ÀÞelÓJÒËî¢óIê8:½ótÒïî¤í7'ÿüvææn*íZOùí)gÝóÞSÞ»³{Ù÷ÜyªßhödfìîmtºÚÚ¼Ku3]ýÅûû/´6ßHÌ*¥ëÅ¿úIÆ5æú.¸¥wQÁAË¥»¾9¸¡¦[VgæpÿÉÝ©û£éÎîL9ÓÏtO¤<s1ìÍQis]ÞûIÆîZÓáò[SGÏÌÃÒxTrtôCxÉ ÍñoÄ¿¹ÆaÑÝÝùðÆ3·»ßµ¿º°øC/ã[oÐûê°·ó=ÒòÝ~7wUEJåþ²ßVwZÓN»5jÁAáÖVÝ%;å[ |
+|K¾láÁÖ^×ï>nÚªKuö¨ëúÀkË»!÷F;RÜb,ÚôÜÌß,]ÉNh˳9¹éWÅ7W´6M,wÃﹸòtºC奮EáÄïubÂçËëNW¤î¤NLÊA+I/çênPrSبAùJmÅ¥.*¥{Ö,µÍó³¥ül÷âåÑR~¦éiÇÉ+êüxzEÑ÷É8hýxxPa5n:áLç+q{cѧk¨ÔÏK½¿¯Ò¤×ð{Ð4)îi©á¢Ã ͯqÐJÒËyZj|ªq16áMÏæFãâ[VËÌÉLïÆT¶:^«Ü=+Njv©3źIÙU´ÙÉ\4DcíM¼Ø6¹¹KCj±FÑ\wôVØæhFÕA >V^ÎpjOR§!>g¢¹}þ¾~|w1jîâCi±GJÌo9#gÆAË¥KQö<}n>CÙÉL:|оIùêäOéË{Âû *òÔ=VóÜI÷7rÜmÞ1æcÃÓ{ÔêÃþÕÅr}Eo>4Ç9fë§W÷G³O·:ÉN<ÞéxÇð1£ó8h¹(?Ýgå3ù¯¯^-§ÅÅtã ¤sOÞ)QJ[¹Qr`n%6º<»xÕqÐJÒËùpWßv¹ó"Dã+qÐrÝ6UE>øñè|9¯ï4SÜâÎc¹ô´ÔXöAòü>¤+ÙêÁÂ]2%jsÐrH)ѤD-sZ.¼Åj¦p¼Ü«ç!]IÞ9µÌ9h%éåÜÝ'µìáÊÃqõëèáZc:¡søWîÞöäî1{j2Z÷)ÈÖz|¯(Ë&ñn.2ê¯#ç+qmrW©}i)éóøsZ.ÝÝefx |
+#å!KW^?,ï£Ûò38H¯Ç3e{ù×ÑëÆ}sýcºí©ÔÃûº Û¶ÜS%MuÒçD}bÜÿDC| `þ ê¢òtÑÆærZþ«4`¨;0Â$¼H0ÓõÍÏ3]¸WW¥º<p/o_Îûë;w¤¸#ÅX.=<µé¹)¿YºØ ?ªÍt¼æòpqW}k»¹Äûd!=æKmu¶ßVw ©^uvÖ9(Fª;ôä>bï¥ÜJ|Ôxû ̲j |
+GÊC®$½¼ÜÇËÊ3^QÊÏTâ }/® |
+I¹¶X)DKZ¹¶yùwr@z¬k>¥!-B,Ðf±4dF,DòX)DKZsb<µNÍ5ºÍ¢3[Ç,ÿN±²ïQà¹Æ± ;ÓÙ÷G{`ÊciÞÁC¨Íb%mGM!®Ey,ìQ¥!g |
+ÙsÚSíµXR#û£öîé]°X9d2$¿8êÅÜ|XtFÞxªán;þ·ýKûR!8÷On?ß3Dc±bÓðxôô3îyíKÿ·×íÌ|¤ý73Þú#þ³´Â*·±=C6ÿÍ(Ùn#YgdëtÌÉ3DÙC·ÊsòôE¿KCf |
+y¤kÚæ#¤R÷;ÅÒØ·1¤æ0d¼Þ)VÒ6¶2rFÒ6¶ë±GFË%)×cÏÖQmKC=¥!µ+°µ¶ÏZ,pÚö- /ÍÅÒå±Xÿ¨ \Jj±4dGIG²ÛxÔÃû÷üL3êÎú¾ÍBάçRÛ|Ø ïÖ*¥!3jÅÊ!´µÅJÚ´VY¬´yB~Ô+t¤\»EQnÕf±4dX¬-jÛDyê-B |
+¶XIÕcõXÒRÈñÐVBÛö°5ZrÚºäqU§?¶ÚÚbåÚú|ØýÂBFÎÁHÚÌÖÌÏØ#fa¤\=[Ú<C`+æÀcådÑf!5Z>L ÝjÔQ¥!-ìVs-Õ¿A#·ÇJ!Z´!^wJh3çúè£ä{äú°ò´BÒ7Æ3äi± Ýú÷} |
++*µyÒ¤R |
+1Mò38}¸Ynv³o|Q<¶u4Kð8HZÆý4é~®ÝÍ|%Z.ÅKgl×ÙV"g»Ç¦kÌÈq+SÁõ=lËQ½TKøîb[Çci¯ÄAhKë*Þ:_KçKuÉAbLáØ"éJRè=-Ë3_QÊÏTâ mq碶ÈÅãMZ;}êlëX[¯ÄAhKë*Ñ_KÇKuÓ S@m ZI |
+MAÍâ´93³hÙú+JùJ¤fÙ£É=öhrÉÒL»5¹G&×ùJ´ÔA^¥ÖäÒÝqÐr)n÷´&)°ÉuZIRX«eë¯(åg*q¾D%õD%õDÅ{¢â=Ñz¢-õDÛüC*óæ=Ñæ=Ñz¢-õD÷D[ê6ï6ï¶Ômó«t%)Já=Qñ¨¤¨xOTf¸{=ÑiDcqðßu²÷jOä|%W¬RÚL7©_I¥÷ ®iwjOä´¥(Ã&@£©ÄAÙ,ìFL#3_ÿª=ó8ÈÍBi3]¤3Ì¢©¹Yj5³È³f |
+ìVºYÃ&@£©ÄA4Kókkókï{ ïây£6ÿÁWâ %ÒêÒÍuù¤eð8h¹t©®»Nk |
+qº®3ò`ÍHf·©ú¨8^¢à+qÒ9M×ôIËà+qå®øªkºágz4éJR7c®ë<qÇüÙäGÈFPù«CZgÓYà~Æ&7øJdPJ¿Óhêå##R3Z.Ýõòi:54¹ÁA+I³î1Óe¥üL%JfÑæõÆ0tªT--d|%2³PZéaKÍ8h¹ÔÌCåÂfyJWY4Æaº¬©ÄAz½ÍQ½mñ©o,×m:Ë»·-ÎWâ ¹\ÀÖ®Ïö ®Íßkç+qÐ2©´ÃÖ5¶-ÎA+I¡wZ¤R~¦e³°m11d¼YjÓÎÎWâ 7¥ëÚü½v¾¹Y¤=¶ó@SéÑ<¤+IÝ,aSZQÊÏTâ ¥uÿ&ºÙ¿åήc¢·¡Â,ÎWâ ¹=¤í.m¦«ù7Qð8hTB]R<¦@³8$E)ÅèÝtõy0ÊfáKÄ ½ÊNÄSÕÅ/)K|Ü,6ÓÕü(øJäf©ÕÌ"/SàKä´Ôͽ®Þ#ÆA0ËÿñãÿZÛS=endstream |
+endobj |
+6 0 obj |
+17999 |
+endobj |
+4 0 obj |
+<</Type/Page/MediaBox [0 0 612 792] |
+/Rotate 0/Parent 3 0 R |
+/Resources<</ProcSet[/PDF] |
+/ExtGState 8 0 R |
+>> |
+/Contents 5 0 R |
+>> |
+endobj |
+3 0 obj |
+<< /Type /Pages /Kids [ |
+4 0 R |
+] /Count 1 |
+/Rotate 0>> |
+endobj |
+1 0 obj |
+<</Type /Catalog /Pages 3 0 R |
+>> |
+endobj |
+7 0 obj |
+<</Type/ExtGState |
+/OPM 1>>endobj |
+8 0 obj |
+<</R7 |
+7 0 R>> |
+endobj |
+2 0 obj |
+<</Producer(GPL Ghostscript 8.15) |
+/CreationDate(D:20070312220102) |
+/ModDate(D:20070312220102) |
+/Title(BOARD.bin) |
+/Creator(PScript5.dll Version 5.2) |
+/Author(Jakub)>>endobj |
+xref |
+0 9 |
+0000000000 65535 f |
+0000018313 00000 n |
+0000018431 00000 n |
+0000018245 00000 n |
+0000018105 00000 n |
+0000000015 00000 n |
+0000018084 00000 n |
+0000018361 00000 n |
+0000018402 00000 n |
+trailer |
+<< /Size 9 /Root 1 0 R /Info 2 0 R |
+/ID [(ý*i@kìïǼþ)(ý*i@kìïǼþ)] |
+>> |
+startxref |
+18608 |
+%%EOF |
/roboti/istrobot/camerus/HW/CAM_PROFI/BOARD.PHO |
---|
0,0 → 1,315 |
* |
* |
G04 PADS Layout (Build Number 2006.45.1) generated Gerber (RS-274-X) file* |
G04 PC Version=2.1* |
* |
%IN "LEDpanel.pcb"*% |
* |
%MOIN*% |
* |
%FSLAX35Y35*% |
* |
* |
* |
* |
G04 PC Standard Apertures* |
* |
* |
G04 Thermal Relief Aperture macro.* |
%AMTER* |
1,1,$1,0,0* |
1,0,$1-$2,0,0* |
21,0,$3,$4,0,0,45* |
21,0,$3,$4,0,0,135* |
% |
* |
* |
G04 Annular Aperture macro.* |
%AMANN* |
1,1,$1,0,0* |
1,0,$2,0,0* |
% |
* |
* |
G04 Odd Aperture macro.* |
%AMODD* |
1,1,$1,0,0* |
1,0,$1-0.005,0,0* |
% |
* |
* |
G04 PC Custom Aperture Macros* |
* |
* |
* |
* |
* |
* |
G04 PC Aperture Table* |
* |
%ADD024C,0.001*% |
%ADD025C,0.01*% |
* |
* |
* |
* |
G04 PC Copper Outlines (0)* |
G04 Layer Name LEDpanel.pcb - dark (0)* |
%LPD*% |
* |
* |
G04 PC Area=Custom_Thermal* |
* |
G04 PC Custom Flashes* |
G04 Layer Name LEDpanel.pcb - flashes* |
%LPD*% |
* |
* |
G04 PC Circuitry* |
G04 Layer Name LEDpanel.pcb - circuitry* |
%LPD*% |
* |
G54D24* |
G01X120000Y179100D02* |
X120003D01* |
X651200D02* |
X651203D01* |
X651200Y120000D02* |
X651203D01* |
X651200Y179100D02* |
X651203D01* |
G54D25* |
X120000D02* |
X651200D01* |
Y120000* |
X120000* |
Y179100* |
Y212000D02* |
X367827D01* |
X120000D02* |
X130000Y214500D01* |
Y209500* |
X120000Y212000* |
X651200D02* |
X403373D01* |
X651200D02* |
X641200Y209500D01* |
Y214500* |
X651200Y212000* |
X120000Y184100D02* |
Y217000D01* |
X651200Y184100D02* |
Y217000D01* |
X373782Y214812D02* |
X371509D01* |
X371509D02* |
X371282Y212000D01* |
X371509Y212312* |
X371509D02* |
X372191Y212625D01* |
X372873* |
X373555Y212312* |
X373555D02* |
X374009Y211687D01* |
X374009D02* |
X374236Y210750D01* |
X374009Y210125* |
X373782Y209187* |
X373782D02* |
X373327Y208562D01* |
X373327D02* |
X372645Y208250D01* |
X371964* |
X371282Y208562* |
X371282D02* |
X371055Y208875D01* |
X370827Y209500* |
X376736Y214812D02* |
X379236D01* |
X379236D02* |
X377873Y212312D01* |
X377873D02* |
X378555D01* |
X378555D02* |
X379009Y212000D01* |
X379236Y211687* |
X379236D02* |
X379464Y210750D01* |
Y210125* |
X379236Y209187* |
X379236D02* |
X378782Y208562D01* |
X378782D02* |
X378100Y208250D01* |
X377418* |
X376736Y208562* |
X376736D02* |
X376509Y208875D01* |
X376282Y209500* |
X381509Y213562D02* |
X381964Y213875D01* |
X382645Y214812* |
X382645D02* |
Y208250D01* |
X384918Y213250D02* |
Y213562D01* |
X384918D02* |
X385145Y214187D01* |
X385145D02* |
X385373Y214500D01* |
X385827Y214812* |
X385827D02* |
X386736D01* |
X386736D02* |
X387191Y214500D01* |
X387418Y214187* |
X387418D02* |
X387645Y213562D01* |
X387645D02* |
Y212937D01* |
X387645D02* |
X387418Y212312D01* |
X387418D02* |
X386964Y211375D01* |
X384691Y208250* |
X387873* |
X389918Y212625D02* |
Y208250D01* |
Y211375D02* |
X390600Y212312D01* |
X390600D02* |
X391055Y212625D01* |
X391736* |
X392191Y212312* |
X392191D02* |
X392418Y211375D01* |
Y208250* |
Y211375D02* |
X393100Y212312D01* |
X393100D02* |
X393555Y212625D01* |
X394236* |
X394691Y212312* |
X394691D02* |
X394918Y211375D01* |
Y208250* |
X396964Y214812D02* |
X397191Y214500D01* |
X397418Y214812* |
X397418D02* |
X397191Y215125D01* |
X396964Y214812* |
X397191Y212625D02* |
Y208250D01* |
X399464Y214812D02* |
Y208250D01* |
X672000Y120000D02* |
Y142800D01* |
Y120000D02* |
X669500Y130000D01* |
X674500* |
X672000Y120000* |
Y179100D02* |
Y156300D01* |
Y179100D02* |
X674500Y169100D01* |
X669500* |
X672000Y179100* |
X656200Y120000D02* |
X677000D01* |
X656200Y179100D02* |
X677000D01* |
X662909Y152362D02* |
X660636D01* |
X660636D02* |
X660409Y149550D01* |
X660636Y149862* |
X660636D02* |
X661318Y150175D01* |
X662000* |
X662682Y149862* |
X662682D02* |
X663136Y149237D01* |
X663136D02* |
X663364Y148300D01* |
X663136Y147675* |
X662909Y146737* |
X662909D02* |
X662455Y146112D01* |
X662455D02* |
X661773Y145800D01* |
X661091* |
X660409Y146112* |
X660409D02* |
X660182Y146425D01* |
X659955Y147050* |
X668364Y150175D02* |
X668136Y149237D01* |
X668136D02* |
X667682Y148612D01* |
X667682D02* |
X667000Y148300D01* |
X666773* |
X666091Y148612* |
X666091D02* |
X665636Y149237D01* |
X665636D02* |
X665409Y150175D01* |
Y150487* |
X665409D02* |
X665636Y151425D01* |
X666091Y152050* |
X666773Y152362* |
X666773D02* |
X667000D01* |
X667000D02* |
X667682Y152050D01* |
X668136Y151425* |
X668364Y150175* |
Y148612* |
X668364D02* |
X668136Y147050D01* |
X667682Y146112* |
X667682D02* |
X667000Y145800D01* |
X666545* |
X665864Y146112* |
X665864D02* |
X665636Y146737D01* |
X670409Y151112D02* |
X670864Y151425D01* |
X671545Y152362* |
X671545D02* |
Y145800D01* |
X673591Y150175D02* |
Y145800D01* |
Y148925D02* |
X674273Y149862D01* |
X674273D02* |
X674727Y150175D01* |
X675409* |
X675864Y149862* |
X675864D02* |
X676091Y148925D01* |
Y145800* |
Y148925D02* |
X676773Y149862D01* |
X676773D02* |
X677227Y150175D01* |
X677909* |
X678364Y149862* |
X678364D02* |
X678591Y148925D01* |
Y145800* |
X680636Y152362D02* |
X680864Y152050D01* |
X681091Y152362* |
X681091D02* |
X680864Y152675D01* |
X680636Y152362* |
X680864Y150175D02* |
Y145800D01* |
X683136Y152362D02* |
Y145800D01* |
X0Y0D02* |
M02* |
/roboti/istrobot/camerus/HW/CAM_PROFI/BOARD.rep |
---|
0,0 → 1,13 |
Photo-Plotter Apertures Report |
============================== |
Position Width Hgt/ID Shape Qty |
======== ===== ====== ===== === |
24 1 0 RND 4 |
25 10 0 RND 26 |
/roboti/istrobot/camerus/HW/CAM_PROFI/DRILL.DRL |
---|
0,0 → 1,43 |
% |
T1C.035F197S55 |
X014Y014506 |
X014Y015494 |
X01946Y015494 |
X01946Y014506 |
X022219Y013728 |
X022219Y017228 |
X02492Y015494 |
X02492Y014506 |
X03038Y014506 |
X03038Y015494 |
X033113Y017228 |
X033113Y013728 |
X03584Y014506 |
X03584Y015494 |
X038509Y016198 |
X037509Y016198 |
X0381Y0142 |
X0391Y0142 |
X0413Y014506 |
X0413Y015494 |
X039509Y016198 |
X043339Y017228 |
X043339Y013728 |
X044675Y013728 |
X044675Y017228 |
X04676Y015494 |
X04676Y014506 |
X05222Y014506 |
X05222Y015494 |
X054953Y017228 |
X054953Y013728 |
X05768Y014506 |
X05768Y015494 |
X06314Y015494 |
X06314Y014506 |
T2C.12598F035S794 |
X0168Y0134 |
X0278Y0136 |
X0494Y0134 |
X0604Y0134 |
M30 |
/roboti/istrobot/camerus/HW/CAM_PROFI/DRILL.lst |
---|
0,0 → 1,46 |
Drill Listing |
============= |
Drill: .035 Tool: 1 Feed: 197 Speed: 550 |
X 140000 Y 145062 |
X 140000 Y 154937 |
X 194600 Y 154937 |
X 194600 Y 145062 |
X 222186 Y 137284 |
X 222186 Y 172284 |
X 249200 Y 154937 |
X 249200 Y 145062 |
X 303800 Y 145062 |
X 303800 Y 154937 |
X 331129 Y 172284 |
X 331129 Y 137284 |
X 358400 Y 145062 |
X 358400 Y 154937 |
X 385087 Y 161979 |
X 375087 Y 161979 |
X 381000 Y 142000 |
X 391000 Y 142000 |
X 413000 Y 145062 |
X 413000 Y 154937 |
X 395087 Y 161979 |
X 433392 Y 172284 |
X 433392 Y 137284 |
X 446753 Y 137284 |
X 446753 Y 172284 |
X 467600 Y 154937 |
X 467600 Y 145062 |
X 522200 Y 145062 |
X 522200 Y 154937 |
X 549530 Y 172284 |
X 549530 Y 137284 |
X 576800 Y 145062 |
X 576800 Y 154937 |
X 631400 Y 154937 |
X 631400 Y 145062 |
Drill: .12598 Tool: 2 Feed: 35 Speed: 794 |
X 168000 Y 134000 |
X 278000 Y 136000 |
X 494000 Y 134000 |
X 604000 Y 134000 |
End of Listing |
/roboti/istrobot/camerus/HW/CAM_PROFI/DRILL.rep |
---|
0,0 → 1,13 |
Drill Sizes Report |
================== |
Tool Size Pltd Feed Speed Qty |
==== ==== ==== ==== ===== === |
1 35 x 197 550 35 |
2 125.98 x 35 794 4 |
/roboti/istrobot/camerus/HW/CAM_PROFI/V2.PHO |
---|
0,0 → 1,1574 |
* |
* |
G04 PADS Layout (Build Number 2006.45.1) generated Gerber (RS-274-X) file* |
G04 PC Version=2.1* |
* |
%IN "LEDpanel.pcb"*% |
* |
%MOIN*% |
* |
%FSLAX35Y35*% |
* |
* |
* |
* |
G04 PC Standard Apertures* |
* |
* |
G04 Thermal Relief Aperture macro.* |
%AMTER* |
1,1,$1,0,0* |
1,0,$1-$2,0,0* |
21,0,$3,$4,0,0,45* |
21,0,$3,$4,0,0,135* |
% |
* |
* |
G04 Annular Aperture macro.* |
%AMANN* |
1,1,$1,0,0* |
1,0,$2,0,0* |
% |
* |
* |
G04 Odd Aperture macro.* |
%AMODD* |
1,1,$1,0,0* |
1,0,$1-0.005,0,0* |
% |
* |
* |
G04 PC Custom Aperture Macros* |
* |
* |
* |
* |
* |
* |
G04 PC Aperture Table* |
* |
%ADD012R,0.07X0.07*% |
%ADD013C,0.23622*% |
%ADD025C,0.01*% |
%ADD031C,0.07*% |
%ADD042C,0.045*% |
%ADD043R,0.066X0.066*% |
%ADD044C,0.066*% |
%ADD045R,0.065X0.065*% |
%ADD046C,0.08268*% |
%ADD047C,0.035*% |
%ADD048C,0.025*% |
* |
* |
* |
* |
G04 PC Copper Outlines (0)* |
G04 Layer Name LEDpanel.pcb - dark (0)* |
%LPD*% |
* |
* |
G04 PC Area=ANP000000* |
G75* |
G36* |
G01* |
X648700Y123000D02* |
Y176100D01* |
G03* |
X648200Y176600I-500J-0D01* |
G01* |
X555558D01* |
G03* |
X555136Y175833I0J-500D01* |
G02* |
X545345Y167138I-5606J-3548D01* |
G03* |
X545029Y167250I-316J-388D01* |
G01* |
X451254D01* |
G03* |
X450939Y167138I0J-500D01* |
G02* |
X442568I-4186J5147D01* |
G03* |
X442252Y167250I-316J-388D01* |
G01* |
X437893D01* |
G03* |
X437578Y167138I0J-500D01* |
G02* |
X429207I-4186J5147D01* |
G03* |
X428891Y167250I-316J-388D01* |
G01* |
X400923D01* |
G03* |
X400492Y166497I0J-500D01* |
G02* |
X400837Y165229I-2155J-1268D01* |
G01* |
Y158729D01* |
G02* |
X398337Y156229I-2500J0D01* |
G01* |
X391837D01* |
G02* |
X390587Y156564I0J2500D01* |
G03* |
X389837Y156131I-250J-433D01* |
G01* |
Y151057D01* |
G03* |
X389984Y150703I500J-0D01* |
G01* |
X392541Y148146D01* |
G03* |
X392894Y148000I353J354D01* |
G01* |
X394500D01* |
G02* |
X397000Y145500I0J-2500D01* |
G01* |
Y138750D01* |
G03* |
X397500Y138250I500J0D01* |
G01* |
X399969D01* |
G03* |
X400323Y138396I0J500D01* |
G01* |
X407054Y145127D01* |
G03* |
X407200Y145481I-354J354D01* |
G01* |
Y148363D01* |
G02* |
X408401Y150499I2500J-0D01* |
G03* |
X408527Y151245I-260J427D01* |
G02* |
X417600Y158470I4473J3692D01* |
G03* |
X417643Y158421I397J304D01* |
G01* |
X425022Y151042D01* |
G03* |
X425204Y150926I354J353D01* |
G02* |
X426748Y149940I-1462J-3991D01* |
G01* |
X432634Y144054D01* |
G03* |
X433016Y143908I353J353D01* |
G02* |
X439605Y139612I376J-6623D01* |
G03* |
X440541I468J175D01* |
G02* |
X447130Y143908I6212J-2327D01* |
G03* |
X447512Y144054I28J499D01* |
G01* |
X452463Y149005D01* |
G02* |
X454579Y150156I3005J-3005D01* |
G03* |
X454827Y150291I-105J489D01* |
G01* |
X462957Y158421D01* |
G03* |
X463000Y158470I-354J353D01* |
G02* |
X472073Y151245I4600J-3533D01* |
G03* |
X472199Y150499I386J-319D01* |
G02* |
X473089Y149571I-1299J-2136D01* |
G03* |
X473526Y149313I437J242D01* |
G01* |
X476186D01* |
G03* |
X476539Y149459I-0J500D01* |
G01* |
X485022Y157942D01* |
G02* |
X488027Y159187I3005J-3005D01* |
G01* |
X518061D01* |
G03* |
X518390Y159310I0J500D01* |
G02* |
X526673Y151245I3810J-4373D01* |
G03* |
X526799Y150499I386J-319D01* |
G02* |
X528000Y148363I-1299J-2136D01* |
G01* |
Y141763D01* |
G02* |
X525500Y139263I-2500J-0D01* |
G01* |
X518900D01* |
G02* |
X516400Y141763I0J2500D01* |
G01* |
Y148363D01* |
G02* |
X516915Y149883I2500J-0D01* |
G03* |
X516518Y150687I-397J304D01* |
G01* |
X489995D01* |
G03* |
X489641Y150541I-0J-500D01* |
G01* |
X481158Y142058D01* |
G02* |
X478153Y140813I-3005J3005D01* |
G01* |
X473526D01* |
G03* |
X473089Y140555I0J-500D01* |
G02* |
X470900Y139263I-2189J1208D01* |
G01* |
X464300D01* |
G02* |
X461800Y141763I0J2500D01* |
G01* |
Y144036D01* |
G03* |
X460946Y144389I-500J-0D01* |
G01* |
X459552Y142995D01* |
G02* |
X457437Y141844I-3005J3005D01* |
G03* |
X457188Y141709I104J-489D01* |
G01* |
X453522Y138043D01* |
G03* |
X453376Y137661I354J-353D01* |
G02* |
X440541Y134958I-6623J-376D01* |
G03* |
X439605I-468J-176D01* |
G02* |
X426769Y137661I-6213J2327D01* |
G03* |
X426623Y138043I-499J29D01* |
G01* |
X421839Y142828D01* |
G03* |
X421657Y142944I-354J-354D01* |
G02* |
X420113Y143930I1462J3991D01* |
G01* |
X419654Y144389D01* |
G03* |
X418800Y144036I-354J-353D01* |
G01* |
Y141763D01* |
G02* |
X416300Y139263I-2500J-0D01* |
G01* |
X413418D01* |
G03* |
X413064Y139117I-0J-500D01* |
G01* |
X404942Y130995D01* |
G02* |
X401937Y129750I-3005J3005D01* |
G01* |
X378747D01* |
G02* |
X375742Y130995I-0J4250D01* |
G01* |
X366995Y139742D01* |
G02* |
X365750Y142747I3005J3005D01* |
G01* |
Y143486D01* |
G03* |
X365604Y143839I-500J-0D01* |
G01* |
X365054Y144389D01* |
G03* |
X364200Y144036I-354J-353D01* |
G01* |
Y141763D01* |
G02* |
X361700Y139263I-2500J-0D01* |
G01* |
X355100D01* |
G02* |
X352600Y141763I0J2500D01* |
G01* |
Y148363D01* |
G02* |
X353801Y150499I2500J-0D01* |
G03* |
X353927Y151245I-260J427D01* |
G02* |
X363000Y158470I4473J3692D01* |
G03* |
X363043Y158421I397J304D01* |
G01* |
X373005Y148459D01* |
G02* |
X374250Y145453I-3005J-3006D01* |
G01* |
Y144714D01* |
G03* |
X374396Y144361I500J0D01* |
G01* |
X380361Y138396D01* |
G03* |
X380714Y138250I353J354D01* |
G01* |
X384500D01* |
G03* |
X385000Y138750I-0J500D01* |
G01* |
Y142045D01* |
G03* |
X384854Y142398I-500J-0D01* |
G01* |
X381728Y145523D01* |
G02* |
X380337Y148882I3359J3359D01* |
G01* |
Y156131D01* |
G03* |
X379587Y156564I-500J0D01* |
G02* |
X378337Y156229I-1250J2165D01* |
G01* |
X371837D01* |
G02* |
X369337Y158729I0J2500D01* |
G01* |
Y165229D01* |
G02* |
X369841Y166734I2500J0D01* |
G03* |
X369441Y167535I-400J301D01* |
G01* |
X335959D01* |
G03* |
X335621Y167403I0J-500D01* |
G02* |
X326638I-4492J4882D01* |
G03* |
X326299Y167535I-339J-368D01* |
G01* |
X227016D01* |
G03* |
X226678Y167403I0J-500D01* |
G02* |
X216581Y175833I-4492J4882D01* |
G03* |
X216158Y176600I-423J267D01* |
G01* |
X123000D01* |
G03* |
X122500Y176100I0J-500D01* |
G01* |
Y123000D01* |
G03* |
X123000Y122500I500J0D01* |
G01* |
X648200D01* |
G03* |
X648700Y123000I-0J500D01* |
G37* |
G74* |
* |
* |
G04 PC Void Outlines (0)* |
G04 Layer Name LEDpanel.pcb - clear (0)* |
%LPC*% |
* |
* |
G04 PC Area=ANP000000* |
G75* |
G36* |
G01* |
X627590Y159310D02* |
G02* |
X635873Y151245I3810J-4373D01* |
G03* |
X635999Y150499I386J-319D01* |
G02* |
X637200Y148363I-1299J-2136D01* |
G01* |
Y141763D01* |
G02* |
X634700Y139263I-2500J-0D01* |
G01* |
X628100D01* |
G02* |
X625600Y141763I0J2500D01* |
G01* |
Y148363D01* |
G02* |
X626115Y149883I2500J-0D01* |
G03* |
X625718Y150687I-397J304D01* |
G01* |
X599595D01* |
G03* |
X599241Y150541I-0J-500D01* |
G01* |
X590758Y142058D01* |
G02* |
X587753Y140813I-3005J3005D01* |
G01* |
X582726D01* |
G03* |
X582289Y140555I0J-500D01* |
G02* |
X580100Y139263I-2189J1208D01* |
G01* |
X573500D01* |
G02* |
X571000Y141763I0J2500D01* |
G01* |
Y148363D01* |
G02* |
X571515Y149883I2500J-0D01* |
G03* |
X571118Y150687I-397J304D01* |
G01* |
X569150D01* |
G03* |
X568796Y150541I-0J-500D01* |
G01* |
X556299Y138043D01* |
G03* |
X556153Y137661I353J-353D01* |
G02* |
X549907Y143908I-6623J-376D01* |
G03* |
X550288Y144054I28J499D01* |
G01* |
X564177Y157942D01* |
G02* |
X567182Y159187I3005J-3005D01* |
G01* |
X572661D01* |
G03* |
X572990Y159310I0J500D01* |
G02* |
X581273Y151245I3810J-4373D01* |
G03* |
X581399Y150499I386J-319D01* |
G02* |
X582289Y149571I-1299J-2136D01* |
G03* |
X582726Y149313I437J242D01* |
G01* |
X585786D01* |
G03* |
X586139Y149459I-0J500D01* |
G01* |
X594622Y157942D01* |
G02* |
X597627Y159187I3005J-3005D01* |
G01* |
X627261D01* |
G03* |
X627590Y159310I0J500D01* |
G37* |
G74* |
* |
G75* |
G36* |
G01* |
X617000Y172750D02* |
Y163750D01* |
G02* |
X614500Y161250I-2500J0D01* |
G01* |
X585682D01* |
G02* |
X583182Y163750I-0J2500D01* |
G01* |
Y172750D01* |
G02* |
X585682Y175250I2500J0D01* |
G01* |
X614500D01* |
G02* |
X617000Y172750I0J-2500D01* |
G37* |
G74* |
* |
G75* |
G36* |
G01* |
X330753Y143908D02* |
G02* |
X324506Y137661I376J-6623D01* |
G03* |
X324361Y138043I-499J29D01* |
G01* |
X311863Y150541D01* |
G03* |
X311510Y150687I-353J-354D01* |
G01* |
X309482D01* |
G03* |
X309085Y149883I-0J-500D01* |
G02* |
X309600Y148363I-1985J-1520D01* |
G01* |
Y141763D01* |
G02* |
X307100Y139263I-2500J-0D01* |
G01* |
X300500D01* |
G02* |
X298311Y140555I0J2500D01* |
G03* |
X297874Y140813I-437J-242D01* |
G01* |
X294547D01* |
G02* |
X291542Y142058I-0J4250D01* |
G01* |
X283059Y150541D01* |
G03* |
X282705Y150687I-354J-354D01* |
G01* |
X254882D01* |
G03* |
X254485Y149883I-0J-500D01* |
G02* |
X255000Y148363I-1985J-1520D01* |
G01* |
Y141763D01* |
G02* |
X252500Y139263I-2500J-0D01* |
G01* |
X245900D01* |
G02* |
X243400Y141763I0J2500D01* |
G01* |
Y148363D01* |
G02* |
X244601Y150499I2500J-0D01* |
G03* |
X244727Y151245I-260J427D01* |
G02* |
X253010Y159310I4473J3692D01* |
G03* |
X253339Y159187I329J377D01* |
G01* |
X284673D01* |
G02* |
X287678Y157942I-0J-4250D01* |
G01* |
X296161Y149459D01* |
G03* |
X296514Y149313I353J354D01* |
G01* |
X297874D01* |
G03* |
X298311Y149571I-0J500D01* |
G02* |
X299201Y150499I2189J-1208D01* |
G03* |
X299327Y151245I-260J427D01* |
G02* |
X307610Y159310I4473J3692D01* |
G03* |
X307939Y159187I329J377D01* |
G01* |
X313477D01* |
G02* |
X316482Y157942I0J-4250D01* |
G01* |
X330371Y144054D01* |
G03* |
X330753Y143908I354J353D01* |
G37* |
G74* |
* |
G75* |
G36* |
G01* |
X221810D02* |
G02* |
X215563Y137661I376J-6623D01* |
G03* |
X215417Y138043I-499J29D01* |
G01* |
X202920Y150541D01* |
G03* |
X202566Y150687I-354J-354D01* |
G01* |
X200282D01* |
G03* |
X199885Y149883I-0J-500D01* |
G02* |
X200400Y148363I-1985J-1520D01* |
G01* |
Y141763D01* |
G02* |
X197900Y139263I-2500J-0D01* |
G01* |
X191300D01* |
G02* |
X189111Y140555I0J2500D01* |
G03* |
X188674Y140813I-437J-242D01* |
G01* |
X183947D01* |
G02* |
X180942Y142058I-0J4250D01* |
G01* |
X172459Y150541D01* |
G03* |
X172105Y150687I-354J-354D01* |
G01* |
X145682D01* |
G03* |
X145285Y149883I-0J-500D01* |
G02* |
X145800Y148363I-1985J-1520D01* |
G01* |
Y141763D01* |
G02* |
X143300Y139263I-2500J-0D01* |
G01* |
X136700D01* |
G02* |
X134200Y141763I0J2500D01* |
G01* |
Y148363D01* |
G02* |
X135401Y150499I2500J-0D01* |
G03* |
X135527Y151245I-260J427D01* |
G02* |
X141719Y160476I4473J3692D01* |
G03* |
X141850Y160454I148J478D01* |
X141967Y160393I287J410D01* |
G02* |
X143810Y159310I-1967J-5456D01* |
G03* |
X144139Y159187I329J377D01* |
G01* |
X174073D01* |
G02* |
X177078Y157942I-0J-4250D01* |
G01* |
X185561Y149459D01* |
G03* |
X185914Y149313I353J354D01* |
G01* |
X188674D01* |
G03* |
X189111Y149571I-0J500D01* |
G02* |
X190001Y150499I2189J-1208D01* |
G03* |
X190127Y151245I-260J427D01* |
G02* |
X198410Y159310I4473J3692D01* |
G03* |
X198739Y159187I329J377D01* |
G01* |
X204534D01* |
G02* |
X207539Y157942I-0J-4250D01* |
G01* |
X221428Y144054D01* |
G03* |
X221810Y143908I353J353D01* |
G37* |
G74* |
* |
G75* |
G36* |
G01* |
X189000Y172750D02* |
Y163750D01* |
G02* |
X186500Y161250I-2500J0D01* |
G01* |
X142955D01* |
G02* |
X142273Y161345I-0J2500D01* |
G03* |
X142154Y161363I-136J-481D01* |
X142048Y161420I-287J-409D01* |
G02* |
X140455Y163750I907J2330D01* |
G01* |
Y172750D01* |
G02* |
X142955Y175250I2500J0D01* |
G01* |
X186500D01* |
G02* |
X189000Y172750I0J-2500D01* |
G37* |
G74* |
* |
* |
G04 PC Copper Outlines (1)* |
G04 Layer Name LEDpanel.pcb - dark (1)* |
%LPD*% |
* |
* |
G04 PC Area=Custom_Thermal* |
* |
G04 PC Custom Flashes* |
G04 Layer Name LEDpanel.pcb - flashes* |
%LPD*% |
* |
* |
G04 PC Circuitry* |
G04 Layer Name LEDpanel.pcb - circuitry* |
%LPD*% |
* |
G54D12* |
G01X391000Y142000D03* |
G54D13* |
X604000Y134000D03* |
X168000D03* |
X278000Y136000D03* |
X494000Y134000D03* |
G54D25* |
X614000Y171250D02* |
Y166000D01* |
X611818* |
X610182Y171250D02* |
Y166000D01* |
Y171250D02* |
X607818D01* |
X610182Y168750D02* |
X608727D01* |
X610182Y166000D02* |
X607818D01* |
X606182Y171250D02* |
Y166000D01* |
Y171250D02* |
X604909D01* |
X604364Y171000* |
X604000Y170500* |
X603818Y170000* |
X603636Y169250* |
Y168000* |
X603818Y167250* |
X604000Y166750* |
X604364Y166250* |
X604909Y166000* |
X606182* |
X602000Y169500D02* |
Y164250D01* |
Y168750D02* |
X601636Y169250D01* |
X601273Y169500* |
X600727* |
X600364Y169250* |
X600000Y168750* |
X599818Y168000* |
Y167500* |
X600000Y166750* |
X600364Y166250* |
X600727Y166000* |
X601273* |
X601636Y166250* |
X602000Y166750* |
X596000Y169500D02* |
Y166000D01* |
Y168750D02* |
X596364Y169250D01* |
X596727Y169500* |
X597273* |
X597636Y169250* |
X598000Y168750* |
X598182Y168000* |
Y167500* |
X598000Y166750* |
X597636Y166250* |
X597273Y166000* |
X596727* |
X596364Y166250* |
X596000Y166750* |
X594364Y169500D02* |
Y166000D01* |
Y168500D02* |
X593818Y169250D01* |
X593455Y169500* |
X592909* |
X592545Y169250* |
X592364Y168500* |
Y166000* |
X590727Y168000D02* |
X588545D01* |
Y168500* |
X588727Y169000* |
X588909Y169250* |
X589273Y169500* |
X589818* |
X590182Y169250* |
X590545Y168750* |
X590727Y168000* |
Y167500* |
X590545Y166750* |
X590182Y166250* |
X589818Y166000* |
X589273* |
X588909Y166250* |
X588545Y166750* |
X586909Y171250D02* |
Y166000D01* |
X186000Y171250D02* |
Y166000D01* |
X183455Y171250D02* |
X186000Y167750D01* |
X185091Y169000D02* |
X183455Y166000D01* |
X180364Y171250D02* |
X181818Y166000D01* |
X180364Y171250D02* |
X178909Y166000D01* |
X181273Y167750D02* |
X179455D01* |
X177273Y171250D02* |
Y166000D01* |
X174727Y171250D02* |
X177273Y167750D01* |
X176364Y169000D02* |
X174727Y166000D01* |
X173091Y171250D02* |
Y166000D01* |
X170909* |
X169273Y171250D02* |
Y166000D01* |
X167636Y171250D02* |
Y166000D01* |
X165091Y171250D02* |
X167636Y167750D01* |
X166727Y169000D02* |
X165091Y166000D01* |
X159091Y170000D02* |
Y170250D01* |
X158909Y170750* |
X158727Y171000* |
X158364Y171250* |
X157636* |
X157273Y171000* |
X157091Y170750* |
X156909Y170250* |
Y169750* |
X157091Y169250* |
X157455Y168500* |
X159273Y166000* |
X156727* |
X154000Y171250D02* |
X154545Y171000D01* |
X154909Y170250* |
X155091Y169000* |
Y168250* |
X154909Y167000* |
X154545Y166250* |
X154000Y166000* |
X153636* |
X153091Y166250* |
X152727Y167000* |
X152545Y168250* |
Y169000* |
X152727Y170250* |
X153091Y171000* |
X153636Y171250* |
X154000* |
X149818D02* |
X150364Y171000D01* |
X150727Y170250* |
X150909Y169000* |
Y168250* |
X150727Y167000* |
X150364Y166250* |
X149818Y166000* |
X149455* |
X148909Y166250* |
X148545Y167000* |
X148364Y168250* |
Y169000* |
X148545Y170250* |
X148909Y171000* |
X149455Y171250* |
X149818* |
X144182D02* |
X146000Y166000D01* |
X146727Y171250D02* |
X144182D01* |
X648700Y123000D02* |
Y176100D01* |
G75* |
G03X648200Y176600I-500J-0D01* |
G01X555558* |
G03X555136Y175833I0J-500* |
G01X545345Y167138D02* |
G03X555136Y175833I4185J5147D01* |
G01X545345Y167138D02* |
G03X545029Y167250I-316J-388D01* |
G01X451254* |
G03X450939Y167138I0J-500* |
G01X442568D02* |
G03X450939I4185J5147D01* |
G01X442568D02* |
G03X442252Y167250I-316J-388D01* |
G01X437893* |
G03X437578Y167138I0J-500* |
G01X429207D02* |
G03X437578I4185J5147D01* |
G01X429207D02* |
G03X428891Y167250I-316J-388D01* |
G01X400923* |
G03X400492Y166497I0J-500* |
G01X400837Y165229D02* |
G03X400492Y166497I-2500J0D01* |
G01X400837Y165229D02* |
Y158729D01* |
X398337Y156229D02* |
G03X400837Y158729I0J2500D01* |
G01X398337Y156229D02* |
X391837D01* |
X390587Y156564D02* |
G03X391837Y156229I1250J2165D01* |
G01X390587Y156564D02* |
G03X389837Y156131I-250J-433D01* |
G01Y151057* |
G03X389984Y150703I500J-0* |
G01X392541Y148146* |
G03X392894Y148000I353J354* |
G01X394500* |
X397000Y145500D02* |
G03X394500Y148000I-2500J0D01* |
G01X397000Y145500D02* |
Y138750D01* |
G03X397500Y138250I500J0* |
G01X399969* |
G03X400323Y138396I0J500* |
G01X407054Y145127* |
G03X407200Y145481I-354J354* |
G01Y148363* |
X408401Y150499D02* |
G03X407200Y148363I1299J-2136D01* |
G01X408401Y150499D02* |
G03X408527Y151245I-260J427D01* |
G01X417600Y158470D02* |
G03X408527Y151245I-4600J-3533D01* |
G01X417600Y158470D02* |
G03X417643Y158421I397J304D01* |
G01X425022Y151042* |
G03X425204Y150926I354J353* |
G01X426748Y149940D02* |
G03X425204Y150926I-3006J-3005D01* |
G01X426748Y149940D02* |
X432634Y144054D01* |
G03X433016Y143908I353J353* |
G01X439605Y139612D02* |
G03X433016Y143908I-6213J-2327D01* |
G01X439605Y139612D02* |
G03X440541I468J175D01* |
G01X447130Y143908D02* |
G03X440541Y139612I-377J-6623D01* |
G01X447130Y143908D02* |
G03X447512Y144054I28J499D01* |
G01X452463Y149005* |
X454579Y150156D02* |
G03X452463Y149005I889J-4156D01* |
G01X454579Y150156D02* |
G03X454827Y150291I-105J489D01* |
G01X462957Y158421* |
G03X463000Y158470I-354J353* |
G01X472073Y151245D02* |
G03X463000Y158470I-4473J3692D01* |
G01X472073Y151245D02* |
G03X472199Y150499I386J-319D01* |
G01X473089Y149571D02* |
G03X472199Y150499I-2189J-1208D01* |
G01X473089Y149571D02* |
G03X473526Y149313I437J242D01* |
G01X476186* |
G03X476539Y149459I-0J500* |
G01X485022Y157942* |
X488027Y159187D02* |
G03X485022Y157942I0J-4250D01* |
G01X488027Y159187D02* |
X518061D01* |
G03X518390Y159310I0J500* |
G01X526673Y151245D02* |
G03X518390Y159310I-4473J3692D01* |
G01X526673Y151245D02* |
G03X526799Y150499I386J-319D01* |
G01X528000Y148363D02* |
G03X526799Y150499I-2500J-0D01* |
G01X528000Y148363D02* |
Y141763D01* |
X525500Y139263D02* |
G03X528000Y141763I0J2500D01* |
G01X525500Y139263D02* |
X518900D01* |
X516400Y141763D02* |
G03X518900Y139263I2500J-0D01* |
G01X516400Y141763D02* |
Y148363D01* |
X516915Y149883D02* |
G03X516400Y148363I1985J-1520D01* |
G01X516915Y149883D02* |
G03X516518Y150687I-397J304D01* |
G01X489995* |
G03X489641Y150541I-0J-500* |
G01X481158Y142058* |
X478153Y140813D02* |
G03X481158Y142058I0J4250D01* |
G01X478153Y140813D02* |
X473526D01* |
G03X473089Y140555I0J-500* |
G01X470900Y139263D02* |
G03X473089Y140555I0J2500D01* |
G01X470900Y139263D02* |
X464300D01* |
X461800Y141763D02* |
G03X464300Y139263I2500J-0D01* |
G01X461800Y141763D02* |
Y144036D01* |
G03X460946Y144389I-500J-0* |
G01X459552Y142995* |
X457437Y141844D02* |
G03X459552Y142995I-890J4156D01* |
G01X457437Y141844D02* |
G03X457188Y141709I104J-489D01* |
G01X453522Y138043* |
G03X453376Y137661I354J-353* |
G01X440541Y134958D02* |
G03X453376Y137661I6212J2327D01* |
G01X440541Y134958D02* |
G03X439605I-468J-176D01* |
G01X426769Y137661D02* |
G03X439605Y134958I6623J-376D01* |
G01X426769Y137661D02* |
G03X426623Y138043I-499J29D01* |
G01X421839Y142828* |
G03X421657Y142944I-354J-354* |
G01X420113Y143930D02* |
G03X421657Y142944I3006J3005D01* |
G01X420113Y143930D02* |
X419654Y144389D01* |
G03X418800Y144036I-354J-353* |
G01Y141763* |
X416300Y139263D02* |
G03X418800Y141763I0J2500D01* |
G01X416300Y139263D02* |
X413418D01* |
G03X413064Y139117I-0J-500* |
G01X404942Y130995* |
X401937Y129750D02* |
G03X404942Y130995I0J4250D01* |
G01X401937Y129750D02* |
X378747D01* |
X375742Y130995D02* |
G03X378747Y129750I3005J3005D01* |
G01X375742Y130995D02* |
X366995Y139742D01* |
X365750Y142747D02* |
G03X366995Y139742I4250J-0D01* |
G01X365750Y142747D02* |
Y143486D01* |
G03X365604Y143839I-500J-0* |
G01X365054Y144389* |
G03X364200Y144036I-354J-353* |
G01Y141763* |
X361700Y139263D02* |
G03X364200Y141763I0J2500D01* |
G01X361700Y139263D02* |
X355100D01* |
X352600Y141763D02* |
G03X355100Y139263I2500J-0D01* |
G01X352600Y141763D02* |
Y148363D01* |
X353801Y150499D02* |
G03X352600Y148363I1299J-2136D01* |
G01X353801Y150499D02* |
G03X353927Y151245I-260J427D01* |
G01X363000Y158470D02* |
G03X353927Y151245I-4600J-3533D01* |
G01X363000Y158470D02* |
G03X363043Y158421I397J304D01* |
G01X373005Y148459* |
X374250Y145453D02* |
G03X373005Y148459I-4250J0D01* |
G01X374250Y145453D02* |
Y144714D01* |
G03X374396Y144361I500J0* |
G01X380361Y138396* |
G03X380714Y138250I353J354* |
G01X384500* |
G03X385000Y138750I-0J500* |
G01Y142045* |
G03X384854Y142398I-500J-0* |
G01X381728Y145523* |
X380337Y148882D02* |
G03X381728Y145523I4750J0D01* |
G01X380337Y148882D02* |
Y156131D01* |
G03X379587Y156564I-500J0* |
G01X378337Y156229D02* |
G03X379587Y156564I0J2500D01* |
G01X378337Y156229D02* |
X371837D01* |
X369337Y158729D02* |
G03X371837Y156229I2500J0D01* |
G01X369337Y158729D02* |
Y165229D01* |
X369841Y166734D02* |
G03X369337Y165229I1996J-1505D01* |
G01X369841Y166734D02* |
G03X369441Y167535I-400J301D01* |
G01X335959* |
G03X335621Y167403I0J-500* |
G01X326638D02* |
G03X335621I4491J4882D01* |
G01X326638D02* |
G03X326299Y167535I-339J-368D01* |
G01X227016* |
G03X226678Y167403I0J-500* |
G01X216581Y175833D02* |
G03X226678Y167403I5605J-3548D01* |
G01X216581Y175833D02* |
G03X216158Y176600I-423J267D01* |
G01X123000* |
G03X122500Y176100I0J-500* |
G01Y123000* |
G03X123000Y122500I500J0* |
G01X648200* |
G03X648700Y123000I-0J500* |
G01X635873Y151245D02* |
G03X627590Y159310I-4473J3692D01* |
G01X635873Y151245D02* |
G03X635999Y150499I386J-319D01* |
G01X637200Y148363D02* |
G03X635999Y150499I-2500J-0D01* |
G01X637200Y148363D02* |
Y141763D01* |
X634700Y139263D02* |
G03X637200Y141763I0J2500D01* |
G01X634700Y139263D02* |
X628100D01* |
X625600Y141763D02* |
G03X628100Y139263I2500J-0D01* |
G01X625600Y141763D02* |
Y148363D01* |
X626115Y149883D02* |
G03X625600Y148363I1985J-1520D01* |
G01X626115Y149883D02* |
G03X625718Y150687I-397J304D01* |
G01X599595* |
G03X599241Y150541I-0J-500* |
G01X590758Y142058* |
X587753Y140813D02* |
G03X590758Y142058I0J4250D01* |
G01X587753Y140813D02* |
X582726D01* |
G03X582289Y140555I0J-500* |
G01X580100Y139263D02* |
G03X582289Y140555I0J2500D01* |
G01X580100Y139263D02* |
X573500D01* |
X571000Y141763D02* |
G03X573500Y139263I2500J-0D01* |
G01X571000Y141763D02* |
Y148363D01* |
X571515Y149883D02* |
G03X571000Y148363I1985J-1520D01* |
G01X571515Y149883D02* |
G03X571118Y150687I-397J304D01* |
G01X569150* |
G03X568796Y150541I-0J-500* |
G01X556299Y138043* |
G03X556153Y137661I353J-353* |
G01X549907Y143908D02* |
G03X556153Y137661I-377J-6623D01* |
G01X549907Y143908D02* |
G03X550288Y144054I28J499D01* |
G01X564177Y157942* |
X567182Y159187D02* |
G03X564177Y157942I0J-4250D01* |
G01X567182Y159187D02* |
X572661D01* |
G03X572990Y159310I0J500* |
G01X581273Y151245D02* |
G03X572990Y159310I-4473J3692D01* |
G01X581273Y151245D02* |
G03X581399Y150499I386J-319D01* |
G01X582289Y149571D02* |
G03X581399Y150499I-2189J-1208D01* |
G01X582289Y149571D02* |
G03X582726Y149313I437J242D01* |
G01X585786* |
G03X586139Y149459I-0J500* |
G01X594622Y157942* |
X597627Y159187D02* |
G03X594622Y157942I0J-4250D01* |
G01X597627Y159187D02* |
X627261D01* |
G03X627590Y159310I0J500* |
G01X617000Y172750D02* |
Y163750D01* |
X614500Y161250D02* |
G03X617000Y163750I0J2500D01* |
G01X614500Y161250D02* |
X585682D01* |
X583182Y163750D02* |
G03X585682Y161250I2500J0D01* |
G01X583182Y163750D02* |
Y172750D01* |
X585682Y175250D02* |
G03X583182Y172750I-0J-2500D01* |
G01X585682Y175250D02* |
X614500D01* |
X617000Y172750D02* |
G03X614500Y175250I-2500J0D01* |
G01X324506Y137661D02* |
G03X330753Y143908I6623J-376D01* |
G01X324506Y137661D02* |
G03X324361Y138043I-499J29D01* |
G01X311863Y150541* |
G03X311510Y150687I-353J-354* |
G01X309482* |
G03X309085Y149883I-0J-500* |
G01X309600Y148363D02* |
G03X309085Y149883I-2500J-0D01* |
G01X309600Y148363D02* |
Y141763D01* |
X307100Y139263D02* |
G03X309600Y141763I0J2500D01* |
G01X307100Y139263D02* |
X300500D01* |
X298311Y140555D02* |
G03X300500Y139263I2189J1208D01* |
G01X298311Y140555D02* |
G03X297874Y140813I-437J-242D01* |
G01X294547* |
X291542Y142058D02* |
G03X294547Y140813I3005J3005D01* |
G01X291542Y142058D02* |
X283059Y150541D01* |
G03X282705Y150687I-354J-354* |
G01X254882* |
G03X254485Y149883I-0J-500* |
G01X255000Y148363D02* |
G03X254485Y149883I-2500J-0D01* |
G01X255000Y148363D02* |
Y141763D01* |
X252500Y139263D02* |
G03X255000Y141763I0J2500D01* |
G01X252500Y139263D02* |
X245900D01* |
X243400Y141763D02* |
G03X245900Y139263I2500J-0D01* |
G01X243400Y141763D02* |
Y148363D01* |
X244601Y150499D02* |
G03X243400Y148363I1299J-2136D01* |
G01X244601Y150499D02* |
G03X244727Y151245I-260J427D01* |
G01X253010Y159310D02* |
G03X244727Y151245I-3810J-4373D01* |
G01X253010Y159310D02* |
G03X253339Y159187I329J377D01* |
G01X284673* |
X287678Y157942D02* |
G03X284673Y159187I-3005J-3005D01* |
G01X287678Y157942D02* |
X296161Y149459D01* |
G03X296514Y149313I353J354* |
G01X297874* |
G03X298311Y149571I-0J500* |
G01X299201Y150499D02* |
G03X298311Y149571I1299J-2136D01* |
G01X299201Y150499D02* |
G03X299327Y151245I-260J427D01* |
G01X307610Y159310D02* |
G03X299327Y151245I-3810J-4373D01* |
G01X307610Y159310D02* |
G03X307939Y159187I329J377D01* |
G01X313477* |
X316482Y157942D02* |
G03X313477Y159187I-3005J-3005D01* |
G01X316482Y157942D02* |
X330371Y144054D01* |
G03X330753Y143908I354J353* |
G01X215563Y137661D02* |
G03X221810Y143908I6623J-376D01* |
G01X215563Y137661D02* |
G03X215417Y138043I-499J29D01* |
G01X202920Y150541* |
G03X202566Y150687I-354J-354* |
G01X200282* |
G03X199885Y149883I-0J-500* |
G01X200400Y148363D02* |
G03X199885Y149883I-2500J-0D01* |
G01X200400Y148363D02* |
Y141763D01* |
X197900Y139263D02* |
G03X200400Y141763I0J2500D01* |
G01X197900Y139263D02* |
X191300D01* |
X189111Y140555D02* |
G03X191300Y139263I2189J1208D01* |
G01X189111Y140555D02* |
G03X188674Y140813I-437J-242D01* |
G01X183947* |
X180942Y142058D02* |
G03X183947Y140813I3005J3005D01* |
G01X180942Y142058D02* |
X172459Y150541D01* |
G03X172105Y150687I-354J-354* |
G01X145682* |
G03X145285Y149883I-0J-500* |
G01X145800Y148363D02* |
G03X145285Y149883I-2500J-0D01* |
G01X145800Y148363D02* |
Y141763D01* |
X143300Y139263D02* |
G03X145800Y141763I0J2500D01* |
G01X143300Y139263D02* |
X136700D01* |
X134200Y141763D02* |
G03X136700Y139263I2500J-0D01* |
G01X134200Y141763D02* |
Y148363D01* |
X135401Y150499D02* |
G03X134200Y148363I1299J-2136D01* |
G01X135401Y150499D02* |
G03X135527Y151245I-260J427D01* |
G01X141719Y160476D02* |
G03X135527Y151245I-1719J-5539D01* |
G01X141719Y160476D02* |
G03X141850Y160454I148J478D01* |
X141967Y160393I287J410* |
G01X143810Y159310D02* |
G03X141967Y160393I-3810J-4373D01* |
G01X143810Y159310D02* |
G03X144139Y159187I329J377D01* |
G01X174073* |
X177078Y157942D02* |
G03X174073Y159187I-3005J-3005D01* |
G01X177078Y157942D02* |
X185561Y149459D01* |
G03X185914Y149313I353J354* |
G01X188674* |
G03X189111Y149571I-0J500* |
G01X190001Y150499D02* |
G03X189111Y149571I1299J-2136D01* |
G01X190001Y150499D02* |
G03X190127Y151245I-260J427D01* |
G01X198410Y159310D02* |
G03X190127Y151245I-3810J-4373D01* |
G01X198410Y159310D02* |
G03X198739Y159187I329J377D01* |
G01X204534* |
X207539Y157942D02* |
G03X204534Y159187I-3005J-3005D01* |
G01X207539Y157942D02* |
X221428Y144054D01* |
G03X221810Y143908I353J353* |
G01X189000Y172750D02* |
Y163750D01* |
X186500Y161250D02* |
G03X189000Y163750I0J2500D01* |
G01X186500Y161250D02* |
X142955D01* |
X142273Y161345D02* |
G03X142955Y161250I682J2405D01* |
G01X142273Y161345D02* |
G03X142154Y161363I-136J-481D01* |
X142048Y161420I-287J-409* |
G01X140455Y163750D02* |
G03X142048Y161420I2500J0D01* |
G01X140455Y163750D02* |
Y172750D01* |
X142955Y175250D02* |
G03X140455Y172750I-0J-2500D01* |
G01X142955Y175250D02* |
X186500D01* |
X189000Y172750D02* |
G03X186500Y175250I-2500J0D01* |
G54D31* |
G01X381000Y142000D03* |
G54D42* |
X391000D02* |
Y142485D01* |
X391485* |
X385087Y148882* |
Y161979* |
X222186Y172285D02* |
X331129D01* |
X385087Y170000D02* |
X387087Y172000D01* |
X549245* |
X549530Y172285* |
X549530* |
X446753* |
X385087Y170000D02* |
X382802Y172285D01* |
X331129* |
X385087Y161979D02* |
Y170000D01* |
X446753Y172285D02* |
X446753D01* |
X446753* |
X433392D02* |
X446753D01* |
X549530* |
G54D43* |
X194600Y145063D03* |
X358400D03* |
X140000D03* |
X467600D03* |
X522200D03* |
X303800D03* |
X249200D03* |
X576800D03* |
X631400D03* |
X413000D03* |
G54D44* |
X194600Y154937D03* |
X358400D03* |
X140000D03* |
X467600D03* |
X522200D03* |
X303800D03* |
X249200D03* |
X576800D03* |
X631400D03* |
X413000D03* |
G54D45* |
X395087Y161979D03* |
X385087D03* |
X375087D03* |
G54D46* |
X222186Y137285D03* |
Y172285D03* |
X446753Y137285D03* |
Y172285D03* |
X331129Y137285D03* |
Y172285D03* |
X549530Y137285D03* |
Y172285D03* |
X433392Y137285D03* |
Y172285D03* |
G54D47* |
X140000Y154937D02* |
X174073D01* |
X194600Y145063D02* |
X183947D01* |
X174073Y154937* |
X194600D02* |
X204534D01* |
X222186Y137285* |
X303800Y145063D02* |
X294547D01* |
X284673Y154937* |
X249200D02* |
X284673D01* |
X303800D02* |
X313477D01* |
X378747Y134000D02* |
X401937D01* |
X413000Y145063* |
X378747Y134000D02* |
X370000Y142747D01* |
Y145453* |
X359458Y155995* |
X358400Y154937* |
X331129Y137285D02* |
X313477Y154937D01* |
X423742Y146935D02* |
X423119D01* |
X414058Y155995* |
X467600Y154937D02* |
X466542Y155995D01* |
X467600Y145063D02* |
X478153D01* |
X488027Y154937* |
X522200* |
X433392Y137285D02* |
X423742Y146935D01* |
X446753Y137285D02* |
X455468Y146000D01* |
X456547* |
X466542Y155995* |
X413000Y154937D02* |
X414058Y155995D01* |
X549530Y137285D02* |
X567182Y154937D01* |
X576800* |
Y145063D02* |
X587753D01* |
X597627Y154937* |
X631400* |
G54D48* |
X626332Y150131D02* |
X629067Y147396D01* |
X636468Y150131D02* |
X633733Y147396D01* |
X636468Y139995D02* |
X633733Y142730D01* |
X626332Y139995D02* |
X629067Y142730D01* |
X244132Y150131D02* |
X246867Y147396D01* |
X254268Y150131D02* |
X251533Y147396D01* |
X254268Y139995D02* |
X251533Y142730D01* |
X244132Y139995D02* |
X246867Y142730D01* |
X517132Y150131D02* |
X519867Y147396D01* |
X527268Y150131D02* |
X524533Y147396D01* |
X527268Y139995D02* |
X524533Y142730D01* |
X517132Y139995D02* |
X519867Y142730D01* |
X134932Y150131D02* |
X137667Y147396D01* |
X145068Y150131D02* |
X142333Y147396D01* |
X145068Y139995D02* |
X142333Y142730D01* |
X134932Y139995D02* |
X137667Y142730D01* |
X353332Y150131D02* |
X356067Y147396D01* |
X363468Y139995D02* |
X360733Y142730D01* |
X353332Y139995D02* |
X356067Y142730D01* |
X370069Y156961D02* |
X372789Y159681D01* |
X370069Y166997D02* |
X372789Y164277D01* |
X380105Y156961D02* |
X377385Y159681D01* |
X390069Y156961D02* |
X392789Y159681D01* |
X400105Y166997D02* |
X397385Y164277D01* |
X400105Y156961D02* |
X397385Y159681D01* |
G74* |
X0Y0D02* |
M02* |
/roboti/istrobot/camerus/HW/CAM_PROFI/V2.rep |
---|
0,0 → 1,22 |
Photo-Plotter Apertures Report |
============================== |
Position Width Hgt/ID Shape Qty |
======== ===== ====== ===== === |
12 70 0 SQR 1 |
13 236.22 0 RND 4 |
25 10 0 RND 306 |
31 70 0 RND 1 |
42 45 0 RND 17 |
43 66 0 SQR 10 |
44 66 0 RND 10 |
45 65 0 SQR 3 |
46 82.68 0 RND 10 |
47 35 0 RND 32 |
48 25 0 RND 25 |
/roboti/istrobot/camerus/HW/PCB/LEDpanel.pcb |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/roboti/istrobot/camerus/HW/SCH/LEDPANEL.DSN |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/roboti/istrobot/camerus/HW/SCH/LEDPANEL.ONL |
---|
0,0 → 1,274 |
(PCB LEDPANEL |
(description |
(timeStamp "2007 03 11 21 45 48") |
(program "CAPTURE.EXE" (Version "10.5.0.p001 CIS - D")) |
(source "Original data from OrCAD/CAPTURE schematic") |
(title "LEDpanel") |
(date "Sunday, March 11, 2007") |
(document "D:\\KAKLIK\\PROJEKTY\\ROBOTI\\ISTROBOT\\CAMERUS\\HW\\SCH\\LEDPANEL.DSN") |
(revision "") |
(organization "") |
(address1 "") |
(address2 "") |
(address3 "") |
(address4 "") |
(partvaluecombine "{Value}") |
(pcbfootprintcombine "{Device},{Value}@{PCB Footprint}")) |
(structure ) |
(placement |
(component JUMP3 |
(place J1 |
(property |
("PCB Footprint" JUMP3) |
(Device JUMP3) |
(timestamp 000003DB) |
("Source Package" JUMP3) |
(Value JUMP3)))) |
(component RL090 |
(place R1 |
(property |
("PCB Footprint" RL090) |
(Device R) |
(timestamp 000000CF) |
("Source Package" RL090) |
(Value RL090))) |
(place R2 |
(property |
("PCB Footprint" RL090) |
(Device R) |
(timestamp 000000DF) |
("Source Package" RL090) |
(Value RL090))) |
(place R3 |
(property |
("PCB Footprint" RL090) |
(Device R) |
(timestamp 000000EF) |
("Source Package" RL090) |
(Value RL090))) |
(place R4 |
(property |
("PCB Footprint" RL090) |
(Device R) |
(timestamp 000000FF) |
("Source Package" RL090) |
(Value RL090))) |
(place R5 |
(property |
("PCB Footprint" RL090) |
(Device R) |
(timestamp 0000010F) |
("Source Package" RL090) |
(Value RL090)))) |
(component LED5mm |
(place D10 |
(property |
("PCB Footprint" LED5) |
(Device LED) |
(timestamp 000000B6) |
("Source Package" LED5mm) |
(Value LED5mm))) |
(place D1 |
(property |
("PCB Footprint" LED5) |
(Device LED) |
(timestamp 00000026) |
("Source Package" LED5mm) |
(Value LED5mm))) |
(place D2 |
(property |
("PCB Footprint" LED5) |
(Device LED) |
(timestamp 00000036) |
("Source Package" LED5mm) |
(Value LED5mm))) |
(place D3 |
(property |
("PCB Footprint" LED5) |
(Device LED) |
(timestamp 00000046) |
("Source Package" LED5mm) |
(Value LED5mm))) |
(place D4 |
(property |
("PCB Footprint" LED5) |
(Device LED) |
(timestamp 00000056) |
("Source Package" LED5mm) |
(Value LED5mm))) |
(place D5 |
(property |
("PCB Footprint" LED5) |
(Device LED) |
(timestamp 00000066) |
("Source Package" LED5mm) |
(Value LED5mm))) |
(place D6 |
(property |
("PCB Footprint" LED5) |
(Device LED) |
(timestamp 00000076) |
("Source Package" LED5mm) |
(Value LED5mm))) |
(place D7 |
(property |
("PCB Footprint" LED5) |
(Device LED) |
(timestamp 00000086) |
("Source Package" LED5mm) |
(Value LED5mm))) |
(place D8 |
(property |
("PCB Footprint" LED5) |
(Device LED) |
(timestamp 00000096) |
("Source Package" LED5mm) |
(Value LED5mm))) |
(place D9 |
(property |
("PCB Footprint" LED5) |
(Device LED) |
(timestamp 000000A6) |
("Source Package" LED5mm) |
(Value LED5mm)))) |
(component "C-ELYT-CE025X6" |
(place C1 |
(property |
("PCB Footprint" CE025X6) |
(Device "C-ELYT") |
(timestamp 000003AA) |
("Source Package" "C-ELYT-CE025X6") |
(Value 1000uF)))) |
(component HOLE_M3 |
(place M1 |
(property |
("PCB Footprint" HOLE_M3) |
(Device PAD) |
(timestamp 00000619) |
("Source Package" HOLE_M3) |
(Value HOLE_M3))) |
(place M2 |
(property |
("PCB Footprint" HOLE_M3) |
(Device PAD) |
(timestamp 00000643) |
("Source Package" HOLE_M3) |
(Value HOLE_M3))) |
(place M3 |
(property |
("PCB Footprint" HOLE_M3) |
(Device PAD) |
(timestamp 0000066D) |
("Source Package" HOLE_M3) |
(Value HOLE_M3))) |
(place M4 |
(property |
("PCB Footprint" HOLE_M3) |
(Device PAD) |
(timestamp 00000697) |
("Source Package" HOLE_M3) |
(Value HOLE_M3))))) |
(library |
(image RL090 |
(property |
(sourcelib C:\\LIBRARY\\ORCAD9X\\COM_RLC.OLB) |
(Device R)) |
(pin 999 1 |
(property |
(pinname 1) |
(pintype 4))) |
(pin 999 2 |
(property |
(pinname 2) |
(pintype 4)))) |
(image "C-ELYT-CE025X6" |
(property |
(sourcelib C:\\LIBRARY\\ORCAD9X\\COM_RLC.OLB) |
(Device "C-ELYT")) |
(pin 999 A |
(property |
(pinname A) |
(pintype 4))) |
(pin 999 C |
(property |
(pinname C) |
(pintype 4)))) |
(image HOLE_M3 |
(property |
(sourcelib C:\\LIBRARY\\ORCAD9X\\PAD.OLB) |
(Device PAD)) |
(pin 999 1 |
(property |
(pinname PIN) |
(pintype 4)))) |
(image JUMP3 |
(property |
(sourcelib C:\\LIBRARY\\ORCAD9X\\JUMP.OLB) |
(Device JUMP3)) |
(pin 999 1 |
(property |
(pinname 1) |
(pintype 4))) |
(pin 999 2 |
(property |
(pinname 2) |
(pintype 4))) |
(pin 999 3 |
(property |
(pinname 3) |
(pintype 4)))) |
(image LED5mm |
(property |
(sourcelib C:\\LIBRARY\\ORCAD9X\\COM_OPTO.OLB) |
(Device LED)) |
(pin 999 A |
(property |
(pinname A) |
(pintype 4))) |
(pin 999 C |
(property |
(pinname C) |
(pintype 4))))) |
(network |
(net VCC |
(property |
(nettype S)) |
(pins |
R3-2 C1-A J1-2 R5-2 R1-2 R2-2 R4-2)) |
(net GND |
(property |
(nettype S)) |
(pins |
D8-C C1-C D4-C M1-1 D2-C M3-1 M4-1 D6-C J1-3 |
J1-1 M2-1 D10-C)) |
(net N00380 |
(pins |
R1-1 D1-A)) |
(net N00388 |
(pins |
D1-C D2-A)) |
(net N00433 |
(pins |
D4-A D3-C)) |
(net N00446 |
(pins |
D3-A R2-1)) |
(net N00494 |
(pins |
R3-1 D5-A)) |
(net N00649 |
(pins |
D5-C D6-A)) |
(net N00715 |
(pins |
D7-A R4-1)) |
(net N00793 |
(pins |
R5-1 D9-A)) |
(net N00822 |
(pins |
D9-C D10-A)) |
(net N00885 |
(pins |
D7-C D8-A))) |
) |
/roboti/istrobot/camerus/HW/SCH/LEDPANEL.asc |
---|
0,0 → 1,51 |
*PADS-PCB* |
*PART* |
C1 C-ELYT,1000uF@CE025X6 |
D1 LED,LED5mm@LED5 |
D10 LED,LED5mm@LED5 |
D2 LED,LED5mm@LED5 |
D3 LED,LED5mm@LED5 |
D4 LED,LED5mm@LED5 |
D5 LED,LED5mm@LED5 |
D6 LED,LED5mm@LED5 |
D7 LED,LED5mm@LED5 |
D8 LED,LED5mm@LED5 |
D9 LED,LED5mm@LED5 |
J1 JUMP3,JUMP3@JUMP3 |
M1 PAD,HOLE_M3@HOLE_M3 |
M2 PAD,HOLE_M3@HOLE_M3 |
M3 PAD,HOLE_M3@HOLE_M3 |
M4 PAD,HOLE_M3@HOLE_M3 |
R1 R,RL090@RL090 |
R2 R,RL090@RL090 |
R3 R,RL090@RL090 |
R4 R,RL090@RL090 |
R5 R,RL090@RL090 |
*NET* |
*SIGNAL* VCC |
R3.2 C1.A J1.2 R5.2 R1.2 R2.2 R4.2 |
*SIGNAL* GND |
D8.C C1.C D4.C M1.1 D2.C M3.1 M4.1 D6.C |
J1.3 J1.1 M2.1 D10.C |
*SIGNAL* N00380 |
R1.1 D1.A |
*SIGNAL* N00388 |
D1.C D2.A |
*SIGNAL* N00433 |
D4.A D3.C |
*SIGNAL* N00446 |
D3.A R2.1 |
*SIGNAL* N00494 |
R3.1 D5.A |
*SIGNAL* N00649 |
D5.C D6.A |
*SIGNAL* N00715 |
D7.A R4.1 |
*SIGNAL* N00793 |
R5.1 D9.A |
*SIGNAL* N00822 |
D9.C D10.A |
*SIGNAL* N00885 |
D7.C D8.A |
*END* |
/roboti/istrobot/camerus/HW/SCH/LEDPANEL_0.DBK |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/roboti/istrobot/camerus/. |
---|
Property changes: |
Added: svn:ignore |
+*.bak |
+*.BAK |
+*.cof |
+*.err |
+*.hex |
+*.lst |
+*.sta |
+*.sym |
+*.tre |