Friday, August 17, 2012

RoboCar: A Robotic Awesomness

Robotic Cars are truly full of awesomeness, it is a world full of engineering, design, challenges, coding, components, datasheet, hardware and reverse engineering sometimes.

It is about transforming a simple 10$ RC car





To XBee enabled, sensor armed, camera monitored, MCU + Steering Wheel + Brake/Acceleration Pedals controlled awesomeness





Photos after fixing IR Proximity Sensor/ Headlight LEDs/ Camera


My plan is to build a remotely controlled car from a base station 






So, first thing I started disassembling the poor car






And the control electronics to be replaced as well




Instead of the PCB, I've added a breadboard with an ATmega328







And installed a 1.5m range IR proximity sensor from sparkfun



and through in some code, the result:
















 #include <avr/io.h>  
 #include <USART.h>  
 #include <util/delay.h>  
 #define SETBIT(ADDRESS,BIT) (ADDRESS |= (1<<BIT))     //Macro to set an individual pin  
 #define CLEARBIT(ADDRESS,BIT) (ADDRESS &= ~(1<<BIT))     //Macro to reset (clear) an individual pin  
 void init_ADC(void);  
 uint8_t ADC_read(uint8_t pin);  
 int main (void)  
 {  
      DDRB=0xFF;     //PORTB as output  
      DDRD=0xFF;     //PORTB as output  
      //PB0-PB5 + PD6 + PD7 are used for the 8-Bit DAC, PB6 & PB7 are used for XTAL  
      init_ADC();     //Setup ADC  
      uint8_t VAL;//Used to read ADC value  
      for (;;)  
      {  
           VAL = ADC_read(0);     //Read ADC Value; (connected to PC0)  
           PORTD=VAL;     //Output the 8-bit number through PORTD (8-Bit Port)  
           SETBIT(PORTB,PB0);     //PB0 connected to WR signal, DAC read the data on WR rising edge  
           CLEARBIT(PORTB,PB0);// Prepare for next reading  
      }  
      return 0;  
 }  
 void init_ADC(void)          //Prepare ADC Module  
 {  
      DDRC = 0x00;  
      PORTC= 0x00;  
      ADMUX |= (1<<ADLAR);     //Input from ch.0 , reference is taken from AREF pin, Left Adjusted Result  
      ADCSRA |= (1<<ADEN) | (1<<ADSC);     //Enable ADC, Start Conversion, no CLK prescaling  
      loop_until_bit_is_clear(ADCSRA, ADSC);  
 }  
 uint8_t ADC_read(uint8_t pin)     //Read an 8-Bit ADC  
 {  
      ADCSRA |= _BV(ADSC);  
      loop_until_bit_is_clear(ADCSRA, ADSC);  
      return ADCH;  
 }  





Original Signal




Signal out of ADC


On the screen...





[ To be Continued]


No comments:

Post a Comment