Subversion Repositories svnkaklik

Rev

Rev 214 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 214 Rev 215
Line 1... Line 1...
1
//********* Robot Camerus pro IstRobot 2007 ************
1
//********* Robot Camerus pro IstRobot 2007 ************
2
//"$Id: camerus.c 214 2007-03-23 14:55:54Z kakl $"
2
//"$Id: camerus.c 215 2007-03-24 21:17:01Z kakl $"
3
//*****************************************************
3
//*****************************************************
4
 
4
 
5
#include ".\camerus.h"
5
#include ".\camerus.h"
6
 
6
 
7
#USE FAST_IO (C)     // Brana C je ve FAST_IO modu, aby slo rychle cist z kamery
7
#USE FAST_IO (C)     // Brana C je ve FAST_IO modu, aby slo rychle cist z kamery
Line 33... Line 33...
33
#define CASMAX 192
33
#define CASMAX 192
34
#define CASAVR ((CASMAX+CASMIN) / 2)
34
#define CASAVR ((CASMAX+CASMIN) / 2)
35
 
35
 
36
#define OFFSETO   0x9F //0x9F         // Vystredeni serva pro objeti prekazky
36
#define OFFSETO   0x9F //0x9F         // Vystredeni serva pro objeti prekazky
37
 
37
 
-
 
38
#define TRESHOLD 128
-
 
39
 
38
#byte INTCON      = 0x0B         // Interrupt configuration register
40
#byte INTCON      = 0x0B         // Interrupt configuration register
39
   #bit GIE       = INTCON.7
41
   #bit GIE       = INTCON.7
40
   #bit PEIE      = INTCON.6
42
   #bit PEIE      = INTCON.6
41
   #bit TMR0IE    = INTCON.5
43
   #bit TMR0IE    = INTCON.5
42
   #bit INT0IE    = INTCON.4
44
   #bit INT0IE    = INTCON.4
Line 425... Line 427...
425
            disp(0x01);
427
            disp(0x01);
426
            while(get_timer1()<=4) // Ujed alespon 12cm
428
            while(get_timer1()<=4) // Ujed alespon 12cm
427
            {
429
            {
428
               set_adc_channel(LMAX);    // Levy UV sensor
430
               set_adc_channel(LMAX);    // Levy UV sensor
429
               delay_us(40);
431
               delay_us(40);
430
               if(read_adc()<128) {cas=CASMIN; break;};  // Prejeli jsme caru vlevo
432
               if(read_adc()<TRESHOLD) {cas=CASMIN; break;};  // Prejeli jsme caru vlevo
431
               set_adc_channel(RMAX);    // Pravy UV sensor
433
               set_adc_channel(RMAX);    // Pravy UV sensor
432
               delay_us(40);
434
               delay_us(40);
433
               if(read_adc()<128) {cas=CASMAX; break;};  // Prejeli jsme caru vpravo
435
               if(read_adc()<TRESHOLD) {cas=CASMAX; break;};  // Prejeli jsme caru vpravo
434
               cas=CASAVR-CASMIN;    // Cara je rovne
436
               cas=CASAVR-CASMIN;    // Cara je rovne
435
            };
437
            };
436
            stav=rozjezd;
438
            stav=rozjezd;
437
         };
439
         };
438
      }
440
      }
Line 443... Line 445...
443
 
445
 
444
      while(true) // Ve zbytku casu snimku cti krajni UV senzory
446
      while(true) // Ve zbytku casu snimku cti krajni UV senzory
445
      {
447
      {
446
         set_adc_channel(LMAX);    // Levy UV sensor
448
         set_adc_channel(LMAX);    // Levy UV sensor
447
         for(n=0;n<20;n++) if(input(HREF)) goto next_snap;
449
         for(n=0;n<20;n++) if(input(HREF)) goto next_snap;
448
         if(read_adc()<128) cas=CASMIN;
450
         if(read_adc()<TRESHOLD) cas=CASMIN;
449
         set_adc_channel(RMAX);    // Pravy UV sensor
451
         set_adc_channel(RMAX);    // Pravy UV sensor
450
         for(n=0;n<20;n++) if(input(HREF)) goto next_snap;
452
         for(n=0;n<20;n++) if(input(HREF)) goto next_snap;
451
         if(read_adc()<128) cas=CASMAX;
453
         if(read_adc()<TRESHOLD) cas=CASMAX;
452
      };
454
      };
453
   }
455
   }
454
}
456
}