Exemplo n.º 1
0
/*
This function first rotates the bot by 5 degree till 360 
Stores the voltage at each angle in array
Find maximum value of voltage from the array
Aligns the bot at that value of voltage.
*/
void bot_rotation360()
{    
     init_devices_motion();
	 init_devices_adc();
	 int bot_ang=0;
	 float panel_voltage[72];
	 float max_panel_volt=0;
	 float bat_voltage = 0.0;
	 int j;
	
	
	 for(j=0;j<72;j++)
	 {
		 
		 soft_right();
		                           // halting right wheel and moving only the left wheel for specified time to get the desired angle of rotation(according to calculation)
		 _delay_ms(rot_time);      // rot_time is calculated according to power from the battery
		 
		  stop();
		  _delay_ms(delay_time);
		
		 panel_voltage[j]=value_in_volt(ADC_Conversion(10)); // channel 10 contains voltage reading 
		 lcd_print(2,1,panel_voltage[j],3);
		 bat_voltage=batt_volt(ADC_Conversion(0));
		 lcd_print(1,13,bat_voltage,4);      // Printing battery voltage.
		
	 }
	  _delay_ms(1000);      // Stopping the bot momentarily.
	  
	  // for getting the angle of bot corresponding to maximum voltage and maximum voltage also.
	  for( j=0;j<72;j++)
	  {      
		  if(panel_voltage[j]>max_panel_volt)
		  {
			  max_panel_volt=panel_voltage[j];
			  bot_ang=j;
		  }
	  }
     lcd_print(2,1,panel_voltage[bot_ang],3);      // Printing maximum voltage.
	 
	                                // Realigning the bot at the maximum angle of intensity in circular plane
	   j=1;         
	  while(j!=bot_ang)            // Since the bot_ang variable contains the angle for which the intensity was maximum
	  {
		  
		  soft_right();       //left wheel forward leaving the right wheel at rest to get
		                     //soft rotation at the axis of right wheel
		  _delay_ms(rot_time2);
		  float servo_volt=value_in_volt(ADC_Conversion(10));
		  lcd_print(2,5,servo_volt,3);
		  j++;
		  stop();
		  _delay_ms(delay_time);
		  
	  }
	   lcd_print(2,5,panel_voltage[bot_ang],3);
	 	
	  max_angle_of_bot=bot_ang;
	 
}
Exemplo n.º 2
0
//Main Function
int main(void)
{   
	//all initializations
    init_devices_motion();
	init_devices();
	init_devices_lf();
	lcd_set_4bit();
	lcd_init();

	//setting gripper arm 
	initial_angle = 120;
	servo1_init();
	servo_2(initial_angle);
	servo_3(180);
	//UDR0 = 0x31;
	//line_follower();
	//pluck_fruit();

	while(1);
}
Exemplo n.º 3
0
// MAIN FUNCTION 
int main()
{ 
	
	//init_devices2();
	 
	
	// White Line Following
	while(1) 
	{
		init_devices_motion();
		init_devices_adc();
		lcd_set_4bit();
		lcd_init();
		
		unsigned char flag = 0;
		unsigned char Left_white_line = 0;
		unsigned char Center_white_line = 0;
		unsigned char Right_white_line = 0;
		unsigned char lwl=0;
		unsigned char cwl=0;
		unsigned char rwl=0;
		
		while(1)
		{
            
			Left_white_line = ADC_Conversion(3);	//Getting data of Left WL Sensor
			Center_white_line = ADC_Conversion(2);	//Getting data of Center WL Sensor
			Right_white_line = ADC_Conversion(1);	//Getting data of Right WL Sensor

			flag=0;

			print_sensor(1,1,3);	//Prints value of White Line Sensor1
			print_sensor(1,5,2);	//Prints Value of White Line Sensor2
			print_sensor(1,9,1);	//Prints Value of White Line Sensor3
			
			

			if(Center_white_line<0x10)
			{
				flag=1;
				forward();
				velocity(100,100);
				//_delay_ms(10000);
			}

			if((Left_white_line>0x10) && (flag==0))
			{   
				
				//bot_charging_process();
				flag=1;
				forward();
				velocity(130,30);
			}

			if((Right_white_line>0x10) && (flag==0))
			{
				//bot_charging_process();
				flag=1;
				forward();
				velocity(30,130);
			}

			if(Center_white_line>0x10 && Left_white_line>0x10 && Right_white_line>0x10)
			{
				forward();
				velocity(0,0);
			}
			
			if((((Center_white_line-Right_white_line>0)&&(Center_white_line-Right_white_line<=10))||((Right_white_line-Center_white_line>0)&&(Right_white_line-Center_white_line<=10)))&&
			   (((Center_white_line-Left_white_line>0)&&(Center_white_line-Left_white_line<=10))||((Left_white_line-Center_white_line>0)&&(Left_white_line-Center_white_line<=10)))&&
			   (((Left_white_line-Right_white_line>0)&&(Left_white_line-Right_white_line<=10))||((Right_white_line-Left_white_line>0)&&(Right_white_line-Left_white_line<=10)))
		
		          ) // recognising node position that is if the reading at all three white line sensors differ maximum by 10 then that point will be node
		       {	
			     lwl=Left_white_line;
				 cwl=Center_white_line;
				 rwl=Right_white_line;
				 stop();
			     _delay_ms(500);
			      break;		   
			  }
		  }	
	  bot_charging_process();
	 //buzzer();
	 
	 
	for(int t=max_angle_of_bot;t>=0;t--)
	 {
		  soft_left_2();       //left wheel forward leaving the right wheel at rest to get
		                       //soft rotation at the axis of right wheel
		  _delay_ms(rot_time);
		  
		  stop();
		  _delay_ms(100);
	 }	
	 
	 forward();
	 _delay_ms(100);  	 
   }
}