Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use 8051 and HC-SR04 to measure distance in the range of 1 to 8 inches. 1.35/100 = 1/x => 74.074 us for 1 inch one

Use 8051 and HC-SR04 to measure distance in the range of 1 to 8 inches.

1.35/100 = 1/x => 74.074 us for 1 inch one direction), so in both 2 direction it is 148.148 us and code need to modify is below, thank you..

Summary of the 8051 software you develop:

Configure timer peripherals

use 8051 to generate 10us TRIGGER pulse for HC-SR04

use 8051 to measure ECHO pulse from HC-SR04

convert ECHO pulse to distance in inches and display distance on P1 LEDs as a bar graph

Distance from the sensor in Inches will be displayed on the LED as a bar graph according to the table below

 Distance D (inches) 
 LEDs 7-0 ( - is off, + is on ) 
 less than 1 
 ---- ---- 
1 to 2
 ---- ---+ 
2 to 3
 ---- --++ 
3 to 4
 ---- -+++ 
4 to 5
 ---- ++++ 
5 to 6
 ---+ ++++ 
6 to 7
 --++ ++++ 
7 to 8
 -+++ ++++ 
more than 8
 ++++ ++++ 

Your program should perform about 1 measurement per second

#define TH0_INITIAL_VALUE 0xFC

#define TL0_INITIAL_VALUE 0x68

#include

unsigned int msCount;

// timer should execute every ms when gate pin == 1

void timer0() interrupt 1{

msCount++;

TH0 = TH0_INITIAL_VALUE; // reload timer high 0

TL0 = TL0_INITIAL_VALUE; // reload timer low 0

//TF0 = 0; // clear timer flag - statement not needed

}

void timer0_Config1(){

// Configure timer 0 in mode 1 with GATE control

TMOD |= 0x09; // Tiemr0 Gate = 1 and {M1,M0} = 0b01

TH0 = TH0_INITIAL_VALUE;

TL0 = TL0_INITIAL_VALUE;

ET0 = 1; // Enable timer0 interrupts

TR0 = 1; // Start timer 0

EA = 1; // Enable All interrupts

}

void main( void ){

timer0_Config1();

P1 = 0; // initialize P1

while( 1 ){ // BEGIN super loop

msCount = 0; // initialize microsecond count

while( !INT0 ); // wait for port 3 pin 2 to go to logic 1

while( INT0 ); // wait while the external interrupt pin is high

P1 = msCount;

// while( P0 != 0xF0 ) ; // wait until unlock code is entered on P0

} // END of super loop

}

/*

CALCULATION

Machine Cycle Frequencey = Fc / 12

Machine Cycle Frequencey = 11.0592MHz / 12 = 921600Hz

Machine Cycle Frequency = 921.6kHz

Machine Cycle Time = 1/921600

Machine Cycle Time = 1.085us

timerTickTime = Machine Cycle Time

1ms count requires how many timeouts?

numTimerTicks = 1ms / 1.085us

numTimerTicks = 1000us / 1.085us

numTimerTicks = 921

{ TH0, TL0 } = -920 -> FC68

*/

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Using Entity Relationship Diagrams

Authors: Sikha Saha Bagui, Richard Walsh Earp

3rd Edition

103201718X, 978-1032017181

More Books

Students also viewed these Databases questions

Question

13-4 What are alternative methods for building information systems?

Answered: 1 week ago

Question

What are the stages of project management? Write it in items.

Answered: 1 week ago

Question

why do consumers often fail to seek out higher yields on deposits ?

Answered: 1 week ago

Question

Provide examples of KPIs in Human Capital Management.

Answered: 1 week ago

Question

What are OLAP Cubes?

Answered: 1 week ago