final project  1
ping.c File Reference

distance measurement for ping sensor More...

#include "main.h"

Go to the source code of this file.

Macros

#define period   20
 
#define clockwise   0x4E000
 
#define cclockwise   0x47500
 
#define TIMER4B_PRESCALER   50
 

Functions

void TIMER3B_Handler (void)
 handles interrupts More...
 
void ping_init ()
 initializes ping sensor More...
 
void send_pulse ()
 sends a pulse to the ping sensor More...
 
int ping_read ()
 reads the response pulse from the ping sensor More...
 
double time2dist (int time)
 convert a sonar pulse width time to a distance More...
 
void clock_timer_init3 (void)
 initializes a clock timer More...
 

Variables

volatile int overflow
 
volatile int rise_time
 
volatile int fall_time
 
volatile int j
 
volatile float servo_angle
 

Detailed Description

distance measurement for ping sensor

Author
Steven, Kynara, Saba, Bailey, Brett, Austin
Date
4/24/18

Definition in file ping.c.

Function Documentation

◆ clock_timer_init3()

void clock_timer_init3 ( void  )

initializes a clock timer

sets up the interrupt timer

Definition at line 123 of file ping.c.

◆ ping_init()

void ping_init ( )

initializes ping sensor

initializes registers and ports for the ping sensor

Definition at line 55 of file ping.c.

◆ ping_read()

int ping_read ( )

reads the response pulse from the ping sensor

start and read the ping sensor once, return distance in cm

Definition at line 85 of file ping.c.

◆ send_pulse()

void send_pulse ( )

sends a pulse to the ping sensor

sends a pulse to activate the ping sensor set pin to output, set high for 5us, set low, set to input

Definition at line 69 of file ping.c.

◆ time2dist()

double time2dist ( int  time)

convert a sonar pulse width time to a distance

convert pulse width to cm

Parameters
timeis length of pulse from ping sensor time it took to send and receive a sonar pulse

Definition at line 112 of file ping.c.

◆ TIMER3B_Handler()

void TIMER3B_Handler ( void  )

handles interrupts

detects rising and falling edges of the sensor pin

Definition at line 32 of file ping.c.