Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:examples:sensor:lidar [2012/06/04 15:57] heikopikneren:examples:sensor:lidar [2020/07/20 09:00] (current) – external edit 127.0.0.1
Line 4: Line 4:
 //Necessary knowledge: [HW] [[en:hardware:homelab:communication]], [HW] [[en:hardware:homelab:digi]],  [LIB] [[en:software:homelab:library:usart]], [LIB] [[en:software:homelab:library:module:lcd_graphic]], [LIB] [[en:software:homelab:library:module:sensor]]// //Necessary knowledge: [HW] [[en:hardware:homelab:communication]], [HW] [[en:hardware:homelab:digi]],  [LIB] [[en:software:homelab:library:usart]], [LIB] [[en:software:homelab:library:module:lcd_graphic]], [LIB] [[en:software:homelab:library:module:sensor]]//
  
 +===== Theory =====
  
-[{{   :en:examples:sensor:lidar3.jpg?220|SICK Laser Rangefinder (LIDAR)}}] +[{{  :en:examples:sensor:lidar3.jpg?220|SICK Laser Rangefinder (LIDAR)}}]
- +
- +
-===== Theory =====+
  
 LIDAR (Light Detection and Ranging) is an optical remote sensing system which can measure the distance of a target by illuminating it with light. LIDAR technology is being used in Robotics for the perception of the environment as well as object classification. The ability of LIDAR technology to provide 2D elevation maps of the terrain, high precision distance to the ground, and approach velocity can enable safe landing of robotic and manned vehicles with a high degree of precision. LIDAR (Light Detection and Ranging) is an optical remote sensing system which can measure the distance of a target by illuminating it with light. LIDAR technology is being used in Robotics for the perception of the environment as well as object classification. The ability of LIDAR technology to provide 2D elevation maps of the terrain, high precision distance to the ground, and approach velocity can enable safe landing of robotic and manned vehicles with a high degree of precision.
Line 72: Line 70:
  
 <code c> <code c>
- 
 #include <stdio.h> #include <stdio.h>
 #include <homelab/delay.h> #include <homelab/delay.h>
Line 79: Line 76:
 #include <homelab/usart.h> #include <homelab/usart.h>
  
-// +// Defining USART interface.
-// Determining USART interface. +
-//+
 usart port = USART(0); usart port = USART(0);
  
-// +// Defining button pins.
-//Setting pins for buttons. +
-//+
 pin button1 = PIN(C, 0); pin button1 = PIN(C, 0);
 pin button2 = PIN(C, 1); pin button2 = PIN(C, 1);
  
- 
-// 
 // Initialize // Initialize
-// 
 static inline void init() static inline void init()
 { {
- // Button init+ // Setting buttons pins as inputs.
  pin_setup_input_with_pullup(button1);  pin_setup_input_with_pullup(button1);
  pin_setup_input_with_pullup(button2);  pin_setup_input_with_pullup(button2);
   
- // LCD init+ // Set-up of the LCD.
  lcd_gfx_init();  lcd_gfx_init();
-  +  // Cleaning the screen.
- // Clear screen+
  lcd_gfx_clear();  lcd_gfx_clear();
-  +  // Switching on the background light.
- // Turn on backlight.+
  lcd_gfx_backlight(true);   lcd_gfx_backlight(true);
-  +  // Displaying the name of the program.
- // Print program name+
  lcd_gfx_goto_char_xy(3, 1);  lcd_gfx_goto_char_xy(3, 1);
  lcd_gfx_write_string("Lidar");  lcd_gfx_write_string("Lidar");
Line 121: Line 108:
  USART_PARITY_NONE,  USART_PARITY_NONE,
  USART_BAUDRATE_ASYNC(9600)  USART_BAUDRATE_ASYNC(9600)
- ); + );
-  +
-  +
- +
 } }
  
-//***************************************************************************** +// Main program
-// +
-//MAIN +
-// +
-//*****************************************************************************+
 int main(void) int main(void)
 {  {
- unsigned char new_value1, old_value1 = 0, new_value2,  + unsigned char new_value1, new_value2, old_value1 = 0, old_value2 = 0;
- old_value2 = 0;+
   
  char c;  char c;
Line 145: Line 124:
  init();   init();
  
- + // Endless cycle
  while (1)  while (1)
  {    {  
- + // Reads buttons states
- // Reads a button states+
  new_value1 = pin_get_debounced_value(button1);  new_value1 = pin_get_debounced_value(button1);
  new_value2 = pin_get_debounced_value(button2);  new_value2 = pin_get_debounced_value(button2);
      
- // Button S1 is pressed+ // Button S1 is pressed.
  if((!new_value1) && (old_value1))  if((!new_value1) && (old_value1))
  {   {
Line 168: Line 146:
  }  }
  
- // Nupp S2 alla vajutatud+ // Button S2 is pressed.
  if((!new_value2) && (old_value2))  if((!new_value2) && (old_value2))
  {  {
- //Send "0x  02 00 02 00 20 25 35 08" to stop scanning. + //Send "0x 02 00 02 00 20 25 35 08" to stop scanning.
- +
  usart_send_char(port, 0x02);  usart_send_char(port, 0x02);
  usart_send_char(port, 0x00);  usart_send_char(port, 0x00);
Line 181: Line 158:
  usart_send_char(port, 0x35);  usart_send_char(port, 0x35);
  usart_send_char(port, 0x08);   usart_send_char(port, 0x08);
- 
  }  }
- 
      
- // Jätab eelmised nupuväärtused meelde+ // Remembers the last keys values.
  old_value1 = new_value1;  old_value1 = new_value1;
  old_value2 = new_value2;  old_value2 = new_value2;
-  
   
  // Try to read serial port  // Try to read serial port
  if (usart_try_read_char(port, &c))  if (usart_try_read_char(port, &c))
  {  {
- //Find a header "0x 02 81 D6 02 B0 69 41" + // Find a header "0x 02 81 D6 02 B0 69 41" 
 + // Very basic package start search.
  if(c == 0x02) i++;  if(c == 0x02) i++;
  if(c == 0x81) i++;   if(c == 0x81) i++;
Line 201: Line 176:
  if(c == 0x69) i++;   if(c == 0x69) i++;
  if(c == 0x41) i++;  if(c == 0x41) i++;
-  
   
  //If there is an header  //If there is an header
Line 209: Line 183:
  count++;  count++;
  
- //and print it on LCD.+ //Displaying packet count on the LCD.
  lcd_gfx_goto_char_xy(0, 3);  lcd_gfx_goto_char_xy(0, 3);
  
Line 218: Line 192:
  i=0;  i=0;
  }  }
- 
  }   }
- 
  }  }
 } }
- 
- 
- 
- 
 </code> </code>
- 
en/examples/sensor/lidar.1338825433.txt.gz · Last modified: 2020/07/20 09:00 (external edit)
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0