Wednesday, 25 March 2015

Sprint #3 : Hervé Luyindula

Objective:
  • Proof of concept (Parallax Sonar)
Features:
  • Ultrasonic Range: 0.02 to 3 metres.
  • Pulse Width Modulation
Operation: 
  • The sensor transmits a ultrasonic burst that is echoed back after colliding with the object within range.
  • The time between transmission and reception of the ultrasonic burst is converted into a pulse.


Figure 1: Ultrasonic Burst

Design:
  • LCD: local display
  • SERIAL: local display 
  • LED: proximity indicator
  • PWM: Analogue input acquisition 
  • THREADS


Results:
  • Maximum distance: 3.161896 metres    
  • Frequency of operation: 1.303KHz
  • Pulse Rise/Fall Time: 8.197us
  • Pulse Range: approx. 0.5 to 18 ms
  • Issues regarding the sensitivity of the sonar  


Figure 2: Minimum PWM length

Figure 3: Maximum PWM length 


Figure 5: PWM @ approx. 1.88 metres
Video:





Next Directive:
  • Investigate the sensitivity issues related to the sonar.
  • Incorporation of the servo motion with the PARALLAX sonar.
Reference:
  • http://che126.che.caltech.edu/28015-PING-Sensor-Product-Guide-v2.0.pdf
Program :

#include "rtos.h"
#include "mbed.h"
#include "C12832_lcd.h"
#include "RangeFinder.h"

// Seeed ultrasound range finder
RangeFinder rf(p21, 10, 5800.0, 100000);
BusOut myleds(LED1, LED2, LED3, LED4);
C12832_LCD lcd;

float sonar_data;


void lcd_display(void const *args) {
    while (true) {
        lcd.locate(0,0);
        if (sonar_data == -1.0)  {
            lcd.printf("Timeout Error.\n");   
        } else if (sonar_data > 5.0) {  
            lcd.printf("No object within detection range.\n");         
        } else  {
            lcd.printf("Distance = %f m.\n", sonar_data);
        }
        Thread::wait(250);
    }
}

void led_display(void const *args) {
    while (true) {
            float led_m = 0.790474;
        if (sonar_data <= led_m)  
            {
             myleds = 15;
             }
        else if (sonar_data > led_m && sonar_data <= 2*led_m ) 
            {
            myleds = 7;      
            }
        else if (sonar_data > 2*led_m && sonar_data <= 3*led_m )  
            {
            myleds = 3;      
            }
        else  
            {
            myleds = 1;      
            }
    
        Thread::wait(250);
    }
}

void serial_display(void const *args) {
    while (true) {
        lcd.locate(0,0);
        if (sonar_data == -1.0)  {
            printf("Timeout Error.\n");   
        } else if (sonar_data > 5.0) {  
            printf("No object within detection range.\n");         
        } else  {
            printf("Distance = %f m.\n", sonar_data);
        }
        Thread::wait(250);
    }
}


int main()  {    
    lcd.cls();
        
    Thread thread1(led_display);
    Thread thread2(lcd_display);
    Thread thread3(serial_display);
    
    while (1)   {
        sonar_data = rf.read_m();
        Thread::wait(250);
    }
}     

Hervé Luyindula

No comments:

Post a Comment