Rose-Hulman Robotics Team

Changeset 446

Show
Ignore:
Timestamp:
03/08/09 14:41:58 (3 years ago)
Author:
kleinjt
Message:

changed killswitch digital out pins, changed switching.

Location:
trunk/electronics/avr/killswitch
Files:
1 removed
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/electronics/avr/killswitch/killremote.c

    r444 r446  
    4343{ 
    4444        DDRB = 0x0F; 
    45         DDRC = 0x00; 
     45        DDRC = 0b00011000; 
    4646        DDRD = 0b11111110; 
    4747} 
     
    4949static void adc_init() 
    5050{ 
    51         ADCSRA |= (1 << ADPS2) | (1 << ADPS1) | (1 << ADPS0); 
    52         ADMUX |= (1 << REFS0); 
    53         ADMUX |= (1 << ADLAR); 
    54         ADCSRA |= (1 << ADFR); 
    55         ADCSRA |= (1 << ADEN); 
    56         ADCSRA |= (1 << ADIE); 
     51        ADCSRA |= (1 << ADPS2) | (1 << ADPS1) | (1 << ADPS0); // 128 ADC clock prescale, 62.5KHz @ 8MHz clock 
     52        ADMUX |= (1 << REFS0) | (1 << REFS1); // 1.1v internal ref 
     53        ADCSRA |= (1 << ADEN); // enable adc 
     54        ADCSRA |= (1 << ADIE); // enable interrupts 
    5755} 
    5856 
     
    6664        sei(); 
    6765         
    68         uint8_t c; 
    69  
    7066        while (1) { 
    71                 uint8_t in = 'f'; 
    72                 c = PINC; 
    73                 c &= (1<<2); 
    74                 usart_put(!c ? 's' : 'g');       
     67                usart_put('g');  
    7568                _delay_ms(100); 
    7669                 
    7770                if(UCSR0A & (1<<7)) { 
    7871                        in = usart_get(); 
    79                         if(in == 'c') sbi(PORTB, 2);//PORTB |= 0x03; 
    8072                        counter = 500;   
    8173                } 
    8274                 
    83                 if(!counter) cbi(PORTB, 2);//PORTB &= 0xFC; 
    84                 if(!c) PORTB sbi(PORTB, 1);//&= 0xF3; 
    85                 else cbi(PORTB, 1);//PORTB |= 0x0C; 
     75                if(!counter) cbi(PORTC, 4); 
     76                else cbi(PORTC, 4); 
     77                 
     78                ADCSRA |= (1 << ADSC) | (1 << ADIE); 
    8679        } 
    8780 
     
    9790ISR(ADC_vect) 
    9891{ 
    99         if(ADCH < 128) sbi(PORTB, 0); 
    100         else cbi(PORTB, 0);      
     92        if(ADCH < 630) sbi(PORTC, 5); // low battery at 2.7V, minimum voltage for AVR and xbee 
     93        else cbi(PORTC, 5);      
    10194} 
  • trunk/electronics/avr/killswitch/killrobot.c

    r423 r446  
    7171                        usart_put('c'); 
    7272                } 
    73                 else if(in == 's' || !counter) { 
     73                else if(!counter) { 
    7474                        PORTB = 0x00; 
    7575                        usart_put('c');