Subversion Repositories svnkaklik

Rev

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

Rev 203 Rev 205
Line 1... Line 1...
1
// Program pro MiniSumo na R-Day 2006
1
// Program pro MiniSumo na R-Day 2006
-
 
2
//"$Id: camerus.c 204 2007-03-21 09:14:22Z kakl $"
-
 
3
 
2
#include "cholerik.h"
4
#include "cholerik.h"
3
 
5
 
4
// Konstanty
6
// Konstanty
5
#define TRESHOLD     0x254        // rozhodovaci uroven pro okraj areny
7
#define TRESHOLD     0x250        // rozhodovaci uroven pro okraj areny
6
//#define DEBUG1 1   // Diagnostika pohonu
8
//#define DEBUG1 1   // Diagnostika pohonu
7
 
9
 
8
//motory            //Napred vypnout potom zapnout!
10
//motory            //Napred vypnout potom zapnout!
9
#define FR         output_low(PIN_B5); output_high(PIN_B4)  // Vpred
11
#define FR         output_low(PIN_B5); output_high(PIN_B4)  // Vpred
10
#define FL         output_low(PIN_B7); output_high(PIN_B6)
12
#define FL         output_low(PIN_B7); output_high(PIN_B6)
Line 51... Line 53...
51
   if (((FRONT && stav) || (!FRONT && !stav))) {if (f<255) f++;} else {f=0;};
53
   if (((FRONT && stav) || (!FRONT && !stav))) {if (f<255) f++;} else {f=0;};
52
   majak++;
54
   majak++;
53
   stav = ((majak & 0b1) == 0b1);
55
   stav = ((majak & 0b1) == 0b1);
54
   if (stav)
56
   if (stav)
55
   {
57
   {
56
      if (read_adc(ADC_READ_ONLY) > 250) arena_l=TRUE; else arena_l=FALSE;
58
      if (read_adc(ADC_READ_ONLY) > TRESHOLD) arena_l=TRUE; else arena_l=FALSE;
57
      set_adc_channel(R); // prepnuti kanalu ADC, je treba min 10us na ustaleni
59
      set_adc_channel(R); // prepnuti kanalu ADC, je treba min 10us na ustaleni
58
      delay_us(10);
60
      delay_us(10);
59
      read_adc(ADC_START_ONLY);
61
      read_adc(ADC_START_ONLY);
60
      set_pwm1_duty(27);      // 1:1
62
      set_pwm1_duty(27);      // 1:1
61
   }
63
   }
62
   else
64
   else
63
   {
65
   {
64
      if (read_adc(ADC_READ_ONLY) > 250) arena_r=TRUE; else arena_r=FALSE;
66
      if (read_adc(ADC_READ_ONLY) > TRESHOLD) arena_r=TRUE; else arena_r=FALSE;
65
      set_adc_channel(L); // prepnuti kanalu ADC, je treba min 10us na ustaleni
67
      set_adc_channel(L); // prepnuti kanalu ADC, je treba min 10us na ustaleni
66
      delay_us(10);
68
      delay_us(10);
67
      read_adc(ADC_START_ONLY);
69
      read_adc(ADC_START_ONLY);
68
      set_pwm1_duty(55);      // 1:0
70
      set_pwm1_duty(55);      // 1:0
69
   };
71
   };