0% found this document useful (0 votes)
522 views64 pages

Printed Report

The word Clinometer is derived from _clino' which means slope or incline. A Clinometer can help measure the height of a tree, for instance, or show the angle of a slope that the user is standing on. The idea is to measure the angle with an eye toward identifying any amount of slope.

Uploaded by

Chethan Gowda
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
522 views64 pages

Printed Report

The word Clinometer is derived from _clino' which means slope or incline. A Clinometer can help measure the height of a tree, for instance, or show the angle of a slope that the user is standing on. The idea is to measure the angle with an eye toward identifying any amount of slope.

Uploaded by

Chethan Gowda
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 64

Clinometer

Chapter 1

INTRODUCTION
1.1 Definition of Clinometer
The word Clinometer is derived from clino which means slope or incline. Clinometer is an instrument whose main purpose is to find the height and the distance from one given point to the top of a building/object.

Alternatively, we can define it as A Clinometer is a scientific instrument used to measure angles and is used by scientists, engineers and other professionals to gather data during field work. For example, an engineer might use a Clinometer, also known as an inclinometer, to survey land, determine its slope or calculate the height of objects such as trees, buildings. There are multiple types of clinometers, but all perform measurements and provide data for use in a set of related formulas. The name Clinometer comes from the word "incline," although the device is also known as a tilt meter, slope gauge, declinometer, and level meter. A Clinometer is a device used to measure specific angles by sight, usually how far above a horizontal line, such as the ground or a person's line of sight. A Clinometer can help measure the height of a tree, for instance, or show the angle of a slope that the user is standing on. Clinometer are measuring devices that may be used in several different professions. Also known as an inclinometer, the essential function of the device is to determine accurate measurements as they relate to sloping, height and distance. The Clinometer is often used in the profession of meteorology, as well as in forestry and surveying.

Department of ECE

H.K.B.K.C.E

Clinometer

One of the most common applications of the Clinometer is measuring angles as they relate to the slope of natural formations or buildings and other human construction projects. The idea is to measure the angle with an eye toward identifying any amount of slope. The Clinometer may be used to measure both inclines and declines, based on the perspective of the individual calculating the measurements. Along with measuring inclines, the Clinometer is also used in the field of forestry. While measuring natural formations found in wooded areas, the Clinometer is also utilized as a means of measuring the height of trees. Using the directed beam that is emitted by the device, it is possible to determine height without having to use conventional means of actually measuring the tree. The Clinometer has been around since the early 20th century. Early versions relied heavily on weights as a means of determining slope and distance. Later incarnations of the Clinometer made use of curved glass tubes filled with some type of damping liquid and a steel ball to chart angles and slopes. Today, the use of electronic sensors is an important component in the design and function of the modern Clinometer.

Department of ECE

H.K.B.K.C.E

Clinometer

Fig 1.1 Clinometer

1.2 Need for the project


Clinometer is an instrument whose main purpose is to find the height and the distance from one given point to the top of a building/object. The height of the object is calculated along with the distance from the foot of the object to the place where we are standing. Over the years Clinometer is being used to measure either the height or the distance of an object manually by using trigonometric functions. But in applications such as topographic mapping it becomes difficult to find both at a time. The objective of this project is that we attempt to find both the height and the distance of the object simultaneously and display the height and distance in terms of meters on a LCD screen. The task of calculating the height and distance can be accomplished with in a very short duration of time. In this way, we can get accurate results with minimum human efforts.

Department of ECE

H.K.B.K.C.E

Clinometer

1.3 Working
The Proposed Project consists of a P89V51RD2 microcontroller, 3 switches, 2 of which are angle freezing switches and the third is for the purpose of displaying. The first step is to point towards the object of interest and press the first switch S1 for freezing the angle, this angle (T1) is recorded. The initial angle (T1) is first displayed on the LCD display. Then we move forward by a certain distance say 1 meter and repeat step 1 and then press the second switch S2 for freezing the angle, this angle (T2) is recorded. The second angle (T2) is then displayed on the LCD display. On pressing the 3rd switch the height of the building/object is calculated internally and displayed along with the distance from the foot of the building/object to the place where we are standing. The hardware requirements for the model as shown in fig 1.2 are:

SWITCH: It is a device that is used to freeze the angles. The switches being used here are single pole switches.

ADC (Analog to Digital Converter): ADC0803/0804CMOS 8-bit A/D converters. The resolution of ADC is 256bits. Rotational knob which gives the angular variation for height of object/building in analogous form is converted to its digital equivalent by 8 channel ADC.

LCD (Liquid Crystal display): Alpha numeric display used to display the message. It is 2x16 LCD.

Microcontroller: Philips 89v51RD2 microcontroller is used. It is an 80C51 microcontroller with 64kB Flash and 1024 bytes of data RAM. The

Department of ECE

H.K.B.K.C.E

Clinometer

Flash program memory supports both parallel and serial In-System Programming (ISP).

Rotational knob: A 10k potentiometer is used as a rotational knob.

Power Supply: A 5v supply is used.

1.4 Block diagram

Fig 1.2 Block Diagram of Clinometer

Department of ECE

H.K.B.K.C.E

Clinometer

1.5 How to use a Clinometer?


A Clinometer is an instrument used to measure the height of objects at a distance. Clinometers take advantage of the geometry of triangles to allow us to determine the height visually rather than measuring the height physically. For example, clinometers are commonly used to measure the height of trees, plants, buildings, towers, poles and other objects, taking physical measurements of which would have been time-consuming or otherwise impractical. For every type of clinometer, the basic steps of use are the same.

1.5.1. Instructions
Point towards the object with the help of pointer by adjusting the potentiometer.

Press switch S1, the switch S1 will freeze the first angle T1. The freezed angle is displayed on the LCD screen.

Press switch Sm (motor switch), this will automatically make the device move a distance of 1 meter. However if the object is at a far distance then the clinometers may be moved by a distance of 10 meters towards the object.

For the second reading, repeat step 1.

Press switch S2, the switch S2 will freeze the second angle T2. The freezed angle is displayed on the LCD screen.

Department of ECE

H.K.B.K.C.E

Clinometer

Press switch S3, to calculate and display the result (if the object is at a short distance).

Press switch S4, to calculate and display the result (if the object is at a far distance).

The result is obtained based on the two angles that were recorded. The height and distance in terms of meters will be displayed on the LCD screen after trigonometric calculations.

Department of ECE

H.K.B.K.C.E

Clinometer

Chapter 2

ANCIENT CLINOMETERS
The ancient clinometers include an optical device for measuring elevation angles above horizontal. The most common of them being used are compass-clinometers from Suunto or Silva. Compass clinometers are fundamentally just magnetic compasses held with their plane vertical so that a plummet or its equivalent can point to the elevation of the sight line. A better version of Clinometer is the Abney hand spirit level clinometers, where the object sighted and the level bubble can be seen simultaneously, so that the index can be set accurately. An Abney Clinometer is shown in the figure 2.1. A spirit level is called so because it contains alcohol in a tube of large radius, in which the bubble moves to the highest point. Spirit levels are used for accurate surveying, although automatic levels that go back to the principle of the plummet are now frequently found, and are easy to use.

Fig 2.1 Abney clinometer The Abney clinometer has a sighting tube with an angle scale reading from -90 to +90, and a spirit level with a Vernier index that can be moved along the scale while the user looks through the sighting tube. A small mirror and lens makes the level bubble visible in the field of view. When the object is aligned with the crosshair in the sighting tube, the spirit level is rotated so that the bubble is bisected by the crosshair. Then, the elevation of the line of sight can be read off on the scale. The Vernier can be read to 10', but it requires a magnifier to do this. The clinometer can read easily and accurately angles

Department of ECE

H.K.B.K.C.E

Clinometer

of elevation that would be very difficult to measure in any other simple and inexpensive way. A fairly common use of a clinometer is to measure the height of trees, which is easily done. A point should be marked with a stake from the centre of the trunk of the tree as its estimated height, so that the elevation angle is about 45, which gives the best "geometry." This distance D is measured with a tape. The observer then stands over the stake and sights the top of the tree, finding its elevation angle . The height H of the tree is
then H = D tan + HI, where HI, the height of instrument, is the height of the observer's eye. All

this is illustrated in the following figures.

Fig. 2.2a Height of a tree With the levelling rod, the HI can easily be obtained. Set the index at 0, and the clinometer comes at level. Sight the rod from close by, and read the HI. This can, of course, be done by simply making a mark on a wall just in front of your eyes, and then measuring its height.

Fig 2.2b Levelling

Department of ECE

H.K.B.K.C.E

Clinometer

The determination of the difference in elevation of two points is called levelling, and can be carried out with the clinometer set at 0. The place where you stand in level is called a turning point, TP. Your rod person holds the rod on the first point, and you make a backsight, BS, by reading the rod. The reading is the HI above the fist point. Now the rod is held on the second point, and a foresight, FS, is taken. Foresights and backsights should be roughly equal in distance. The difference in elevation of the two points is BS FS. This procedure is illustrated at the left. If both points cannot conveniently be viewed from one TP, a chain of turning points is used, with an intermediate elevation between each one. The difference in elevation is the sum of the backsights less the sum of the foresights. If the sights are short, such as those that are practical with the clinometer, the curvature of the earth will be taken into account automatically. The procedure for finding the height of a tree can be inverted to find the distance D when H is known. This is an application of the method of stadia. The difference in elevation angles of two points on the rod (say top and bottom) is measured, and trigonometry is used to find D in terms of distance. If one of the points has an elevation angle of 0, then D = H/tan . The clinometer is really not well-adapted to this, but it may be of use occasionally.

Department of ECE

10

H.K.B.K.C.E

Clinometer

Chapter 3

POWER SUPPLY
The power supply circuit is built using filters, rectifiers, and then voltage regulators. Starting with an AC voltage, a steady DC voltage is obtained by rectifying the AC voltage, then filtering it to a DC level, and finally, regulating it to obtain a desired fixed DC voltage. The regulation is usually obtained from an IC voltage regulator unit, which takes a DC voltage and provides an approximate lower DC voltage, which remains the same even if the input DC voltage varies, or the output load connected to the DC voltage changes.

3.1 Transformer
Transformers convert high AC voltage from the supply to low voltage with little loss of power. They work only with AC and this is one of the reasons why the main supply is AC. Step-up transformers increase voltage while step-down transformers decrease voltage. Most power supplies use step-down transformers to reduce dangerously high voltage to a safe low level voltage. The input coil is called the secondary. There is no electrical connection between the two coils, instead they are linked by an alternating magnetic field created in the soft iron core of the transformer. Transformers waste very little power so the output power is almost equal to the input power. Also, as the voltage is stepped down, current is stepped up. The ratio of the number of turns of each coil is called the Turns ratio,which determines the ratio of voltages. A step-down transformer has a large number of turns in its primary which are connected to high voltage mains supply, and a small number of turns which are connected to the secondary to give a low output voltage. Turns ratio=Vp/Vs=Np/Ns and power out= power in; Vs*Is=Vp*Ip Vp= primary input voltage.

Department of ECE

11

H.K.B.K.C.E

Clinometer

Vs= secondary output voltage. Np= number of turns in primary. Ns= number of turns in secondary. Ip= primary current. Is= secondary current.

3.2 Bridge Rectifier


The rectification is carried out by employing diodes and there are different ways of connecting diodes to make a rectifier convert AC to DC. The bridge rectifier is the most important and it produces full wave varying DC. A full wave rectifier can also be made using just two diodes if a centre tap transformer is used but this method is rarely used since the diodes are not expensive. A bridge rectifier can be made using four individual diodes. It is also available in special packages containing the four diodes that are required. It is called a full-wave rectifier because it uses the entire AC wave. 1.4V is used up because each diode uses 0.7V when conducting and there are always two diodes conducting. Bridge rectifiers are rated by the maximum current they can pass and the peak inverse voltage they can withstand.

Figure 3.1: Full-wave bridge rectifier.

Department of ECE

12

H.K.B.K.C.E

Clinometer

Figure 3.2: Input-Output waveforms. As mentioned earlier, one can also implement a single-phase full-wave rectifier using four diodes. The diagram of the full-wave bridge rectifier and associated waveforms are shown in figure 3.2. In the positive half cycle of the transformer, diodes D1 and D2 conduct, supplying voltage to the load. In the negative half cycle of supply voltage, diodes D3 and D4 conduct supplying this voltage to the load. It can be seen from the waveforms that the peak inverse voltage of the diodes is only Vm. The average output voltage is the same as that for the center-tapped transformer full-wave rectifier.

Figure 3.3: Commercially available bridge rectifier.

Department of ECE

13

H.K.B.K.C.E

Clinometer

3.3 Filtering
It is performed by a large value electrolytic capacitor connection across the DC supply to act as a reservoir, supplying current when the varying DC voltage from the rectifier is falling. The capacitor charges quickly near the peak of the varying DC, and then discharges as it supplies current to the output. Smoothing significantly increases the average DC voltage to almost the peak value(1.4xRMS value). For example, 6V RMS AC is rectified to full wave DC of about 4.6V RMS (1.4V is lost in bridge), with smoothing this increases almost to the peak value giving 6.4V smooth DC. Smoothing is not perfect due to capacitor voltage falling a little as it discharges, giving a small ripple voltage. For many circuits ripple which is 10% of the supply voltage is satisfactory. A large capacitor gives fewer ripples. The capacitor value must be doubled when smoothing half-wave DC.

3.4 Voltage Regulator


Voltage regulator ICs are available with fixed (typically 5, 12 and 15V) or variable output voltages. They are rated by the maximum current they can pass. Negative voltage regulators are available but mainly for dual supplies. Most regulators include some automatic protection from excessive current (overload protection) and over heating (thermal protection). The voltage regulator IC used in this project is the 7805 which outputs a constant voltage of 5V.

Figure 3.4: Block diagram of voltage regulator.

Department of ECE

14

H.K.B.K.C.E

Clinometer

Many of the fixed voltage regulator ICs has three leads and look like power transistors, such as the 7808 +8V regulator. They include a hole at top of common ground pin for attachment of heat sink if necessary.

Figure 3.5: Image of voltage regulator.

Department of ECE

15

H.K.B.K.C.E

Clinometer

Chapter4

HARDWARE DESCRIPTION
4.1 Microcontroller P89V51RD2
4.1.1 Description
The P89V51RD2 is an 80C51 microcontroller with 64 KB Flash and 1024 bytes of data RAM. A key feature of the P89V51RD2 is its X2 mode option. The design engineer can choose to run the application with the conventional 80C51 clock rate (12 clocks per machine cycle) or select the X2 mode (6 clocks per machine cycle) to achieve twice the throughput at the same clock frequency. Another way to benefit from this feature is to keep the same performance by reducing the clock frequency by half, thus dramatically reducing the EMI. The Flash program memory supports both parallel programming and in serial In-System Programming (ISP). Parallel programming mode offers gang-programming at high speed, reducing programming costs and time to market. ISP allows a device to be reprogrammed in the end product under software control. The capability to field/update the application firmware makes a wide range of applications possible. The P89V51RD2 is also InApplication Programmable (IAP), allowing the Flash program memory to be reconfigured even while the application is running.

4.1.2 Features
80C51 Central Processing Unit 5 V Operating voltage from 0 to 40 MHz 64 KB of on-chip Flash program memory with ISP (In-System Programming) IAP (In-Application Programming) Supports 12-clock (default) or 6-clock mode selection via software or ISP SPI (Serial Peripheral Interface) PCA (Programmable Counter Array) with PWM

Department of ECE

16

H.K.B.K.C.E

Clinometer

Four 8-bit I/O ports with three high-current Port 1 pins (16mA each) Three 16-bit timers/counters Programmable Watchdog timer (WDT) Eight interrupt sources with four priority levels Second DPTR register TTL- and CMOS-compatible logic levels Power-down mode with external interrupt wake-up PDIP40, PLCC44 and TQFP44 package.

Department of ECE

17

H.K.B.K.C.E

Clinometer

4.1.3 Memory organization


The device has separate address spaces for program and data memory. Internal and external data memory structure.

Department of ECE

18

H.K.B.K.C.E

Clinometer

Fig4.1: Memory Organization Flash program memory There are two internal flash memory blocks in the device. Block 0 has 64 Kbytes and contains the users code. Block 1 contains the Philips-provided ISP/IAP routines and may be enabled such that it overlays the first 8 Kbytes of the user code memory. The 64 kB Block 0 is organized as 512 sectors, each sector consists of 128 bytes. Access to the IAP routines may be enabled by clearing the BSEL bit in the FCF register. However, caution must be taken when dynamically changing the BSEL bit. Since this will cause different physical memory to be mapped to the logical program address space, the user must avoid clearing the BSEL bit when executing user code within the address range 0000H to 1FFFH.

Data RAM memory


The data RAM has 1024 bytes of internal memory. The device can also address up to 64 kB for external data memory.

In-System Programming (ISP)


In-System Programming is performed without removing the microcontroller from

the system. The In-System Programming facility consists of a series of internal hardware resources coupled with internal firmware to facilitate remote programming of the P89V51RD2 through the serial port. This firmware is provided by Philips and embedded within each P89V51RD2 device. The Philips In-System Programming facility has made in-circuit programming in an embedded application possible with a minimum of additional expense in components and circuit board area. The ISP function uses five pins (VDD, VSS, TxD, RxD, and RST). Only a small connector needs to be available to interface your application to an external circuit in order to use this feature.

Department of ECE

19

H.K.B.K.C.E

Clinometer

4.1.4 General description of Microcontroller


A & B CPU registers:

The architecture of 89v51 contains 34 general purpose, or working registers. Two of these, registers A and B, hold results of many instructions, particularly math and logical operation of the 89v51 central processing unit (CPU). The other32 are arranged as a part of internal RAM in four banks, B0-B3, of eight registers. The A (accumulator) is the most versatile of the two CPU registers and is used for mathematical operations and Boolean operations. The B register is used with A register for multiplication and division operation and has no other function other than as a location where data may be stored.

Department of ECE

20

H.K.B.K.C.E

Clinometer

Program status word register: 7 CY 6 AC 5 FO 4 RS1 3 RS0 2 OV 1 0 P

BIT 7 6 5 4 3

SYMBOL CY AC FO RS1 RS0 RS1 0 0 1 1 RS0 0 1 0 1

FUNCTION Carry flag Auxiliary carry flag User flag Register bank select bit 1 Register bank select bit 0

Select register bank 0 Select register bank 1 Select register bank 2 Select register bank 3 Over flow flag Reserved for future use Parity flag

2 1 0

OV P

Table 4.1 PSW pin detail

Department of ECE

21

H.K.B.K.C.E

Clinometer

Program counter and data pointer: The 89C52 contains two 16-bit registersprogram counter (PC) and the data pointer (DPTR). Each is used to hold the address of the byte in memory. Program instruction bytes are fetched from locations in memory that are addressed by the PC. The PC is automatically incremented after every instruction byte is fetched and may also be altered by certain instructions. The PC is the only register that does not have any internal address. DPTR register is made up of two 8-bit registers, named DPH and DPL, which are used to furnish memory address from internal and external code access and external data access. Data pointer can also be addressed with its 16-bit name, DPTR or by each individual byte named DPH and DPL. These two individuals have internal address.

4.1.5. Pin Functional Description


The microcontroller pins that have been utilized in the circuit for the project descriptions as follows: Port1 pins which is a pure i/o (input output) this port is used for dual purpose, one for the liquid crystal display (LCD) and the other is for the ADC (analog to digital converter) the digital converted value is accepted through this port pins 1 to 8.The microcontroller has two external interrupt pins INT0 pin12 and INT1 pin13 are given to the ADC EOC(end of conversion) and SOC( start of conversion) pins respectively so when the INT1 pin goes low, then the ADC starts the conversion and when the conversion is completed it signals/alerts the microcontroller by giving EOC to INT0 pin so that the converted digital value is on the data lines of the ADC chip.

The data from ADC to microcontroller is latched by the help of RD pin 17 and WR pin 16 of the microcontroller the microcontroller WR pin is given to ALE pin22 of ADC and OE(output enable) Pin9ADC is given to the RD pin of microcontroller when the data conversion is completed the microcontroller latches the converted digital data from ADC

Department of ECE

22

H.K.B.K.C.E

Clinometer

to port1 by asserting WR pin high and WR pin low which is given to output enable signal of ADC . Similarly when the data to LCD is to be transmitted then the external counter/timer inputs are used to control the LCD timer0 T0 pin 14 of microcontroller is given to pin4 of LCD which is register select (RS) pin when RS = 0, LCD selects the command register so that microcontroller can send commands like clear display screen, select two lines 5X7 matrix LCD etc. When RS = 1, then data register is selected so that data can be displayed on LCD. Port0 bit P0.0 pin 39, P0.1 pin 38, and P0.2 pin 37 is given to ADC pins A2 pin 25, A1 pin 24.And A0 pin 23 respectively, which are the address select pins of ADC, which are used to select any one of the input from 8 input pins of the ADC. Port2 bit 7 pin 28is given to the not gate 7404 for the purpose of selecting any one com port for serial communication between GPS and GSM since microcontroller at any given time can handle only one UART com port.

4.2 Analog to Digital converter


4.2.1 Description
The ADC0804 is CMOS 8-bit successive approximation A/D converters that use a differential potentiometric ladder-similar to the 256R products. These converters are designed to allow operation with the NSC800 and INS8080A derivative control bus with TRI-STATE output latches directly driving the data bus. These A/Ds appear like memory locations or I/O ports to the microprocessor and no interfacing logic is needed.

Differential analog voltage inputs allow increasing the common-mode rejection and offsetting the analog zero input voltage value. In addition, the voltage reference input can be adjusted to allow encoding any smaller analog voltage span to the full 8 bits of resolution.

Department of ECE

23

H.K.B.K.C.E

Clinometer

Fig 4.2: Pin configuration of ADC0804

Department of ECE

24

H.K.B.K.C.E

Clinometer

4.2.2. Features
Compatible with 8080 P derivatives-no interfacing logic needed - access time - 135 ns. Easy interface to all microprocessors, or operates "stand alone". Differential analog voltage inputs. Logic inputs and outputs meet both MOS and TTL voltage level specifications Works with 2.5V (LM336) voltage reference. On-chip clock generator. 0V to 5V analog input voltage range with single 5V supply. No zero adjustment is required. 0.3[Prime] standard width 20-pin DIP package. 20-pin moulded chip carrier or small outline package. Operates ratio metrically or with 5 VDC, 2.5 VDC, or analog span adjusted voltage reference.

Fig. 4.3: Top View of A2D Converter

Department of ECE

25

H.K.B.K.C.E

Clinometer

4.2.3 Key Specification

Resolution Total error

8 bits LSB, LSB and 1 LSB

Conversion time 100 s

4.2.4. Typical Application Schematic

Fig. 4.4: Interfacing with microcontroller As shown in the typical circuit, ADC0804 can be interfaced with any microcontroller. We need a minimum of 11 pins to interface ADC0804, eight for data pins

Department of ECE

26

H.K.B.K.C.E

Clinometer

and 3 for control pins. As shown in the typical circuit the chip select pin can be made low if you are not using the microcontroller port for any other peripheral . There is a universal rule to find out how to use an IC. All we need is the datasheet of the IC you are working with and take a look at the timing diagram of the IC which shows how to send the data, which signal to assert and at what time the signal should be made high or low etc.

Fig.4.5: Start Conversion

Department of ECE

27

H.K.B.K.C.E

Clinometer

Fig 4.6: Output Enable and Reset INTR The above timing diagrams are from ADC0804 datasheet. The first diagram Fig. 4.5 shows how to start a conversion . Also you can see which signals are to be asserted and at what time to start a conversion . So looking into the timing diagram, Fig 4.6. We note down the steps or say the order in which signals are to be asserted to start a conversion of ADC. As we have decided to make Chip select pin as low so we need not to bother about the CS signal in the timing diagram. Below steps are for starting an ADC conversion. Make chip select (CS) signal low. 1. Make write (WR) signal low. 2. Make chip select (CS) high. 3. Wait for INTR pin to go low (means conversion ends). Once the conversion in ADC is done, the data is available in the output latch of the ADC. Looking at the Fig. 4.6which shows the timing diagram of how to read the converted value from the output latch of the ADC. Data of the new conversion is only available for reading after ADC0804 made INTR pin low or say when the conversion is over. Below are the steps to read output from the ADC0804.

Department of ECE

28

H.K.B.K.C.E

Clinometer

1. Make chip select (CS) pin low. 2. Make read (RD) signal low. 3. Read the data from port where ADC is connected. 4. Make read (RD) signal high. 5. Make chip select (CS) high.

4.2.5. Successive approximation ADC


One method of addressing the digital ramp ADC's shortcomings is the so-called successive-approximation register ADC as shown in fig 4.7. The only change in this design is a very special counter circuit known as a successive approximation register. Instead of counting up in binary sequence, this register counts by trying all values of bits starting from bits with the most-significant bit and finishing at the least-significant bit. Throughout the count process, the register monitors the comparator's output to see if the binary count is less than or greater than the analog signal input, adjusting the bit values accordingly. The way the register counts is identical to the "trial and fit" method of decimal-to-binary conversion, whereby different values of bits are tried from MSB to LSB to get a binary number that equals the original decimal number. The advantage to this counting strategy is much faster results: the DAC output converges on the analog signal input in much larger steps than with the 0-to-full-count sequence of a regular counter.

Department of ECE

29

H.K.B.K.C.E

Clinometer

Fig. 4.7: ADC using SAR

Where, DAC = digital-to-analog converter EOC = end of conversion SAR = successive approximation register S/H = sample and hold circuit Vin = input voltage Vref = reference voltage

Department of ECE

30

H.K.B.K.C.E

Clinometer

It should be noted that the SAR is generally capable of outputting the binary number in serial (one bit at a time) format, thus eliminating the need for a shift register. Plotted over time, the operation of a successive-approximation ADC looks like this:

Fig. 4.8: Input and output waveforms

4.2.6. SAR Algorithm


The successive approximation analog to digital converter circuit typically consists of four chief sub circuits: 1. A sample and hold circuit to acquire the input voltage (Vin). 2. An analog voltage comparator that compares Vin to the output of the internal DAC and outputs the result of the comparison to the successive approximation register (SAR). 3. A successive approximation register sub circuit designed to supply an approximate digital code of Vin to the internal DAC. 4. An internal reference DAC that supplies the comparator with an analog voltage equivalent of the digital code output of the SAR for comparison with Vin.

Department of ECE

31

H.K.B.K.C.E

Clinometer

The successive approximation register is initialized so that the most significant bit (MSB) is equal to a digital 1. This code is fed into the DAC which then supplies the analog equivalent of this digital code (Vref/2) into the comparator circuit for comparison with the sampled input voltage. If this analog voltage exceeds Vin the comparator causes the SAR to reset this bit; otherwise, the bit is left a 1. Then the next bit is set to 1 and the same test is done, continuing this binary search until every bit in the SAR has been tested. The resulting code is the digital approximation of the sampled input voltage and is finally output by the DAC at the end of the conversion (EOC). Mathematically, let Vin = xVref, so x in [-1, 1] is the normalized input voltage. The objective is to approximately digitize x to an accuracy of 1/2n. The algorithm proceeds as follows: 1. Initial approximation x0 = 0. 2. ith approximation xi = xi-1 - s(xi-1 - x)/2i. where, s(x) is the signum-function(sgn(x)) (+1 for x 0, -1 for x < 0). It follows using mathematical induction that |xn - x| 1/2n. As shown in the above algorithm, a SAR ADC requires: 1. An input voltage source Vin. 2. A reference voltage source Vref to normalize the input. 3. A DAC to convert the ith approximation xi to a voltage. 4. A Comparator to perform the function s(xi - x) by comparing the DAC's voltage with the input voltage. 5. A Register to store the output of the comparator and apply x i-1 - s(xi-1 x)/2i.

Department of ECE

32

H.K.B.K.C.E

Clinometer

4.3 MAX 232 connection to RS232 and Microcontroller.


The details of the Physical connection of the microcontroller to RS232 connectors are given. The RS232 standard is not compatible, therefore it requires a line driver such as the MAX232 chip to convert RS232 voltage levels to TTL levels and vice versa. The microcontroller has two pins that are used specifically for transferring and receiving data serially. These two pins are called TxD and RxD and are part of the port3. These pins are TTL compatible therefore they require a line driver to make RS232 compatible. The one such line driver is MAX232 chip. The connection between the microcontroller and the RS232 is shown in the below figure.

Fig 4.9: MAX 232 Connection to RS232 and Microcontroller

Department of ECE

33

H.K.B.K.C.E

Clinometer

4.3.1. MAX232 Line Drivers


The MAX232 has two sets of line drivers for transferring and receiving data, as shown in fig. The line drivers used for TxD are called T1 and T2, while the line drivers for RxD are designated R1 and R2. In many applications only one of each is used. Notice in MAX232 that the T1 line driver has a designation of T1in and T1out on pin numbers 11 and 14, respectively. The T1in pin is the TTL side and is connected to the TxD of the microcontroller, while T1out is the RS232 side that is connected to the RxD pin of the RS232 DB connector. The R1 line driver has a designation of R1in and R1out on pin numbers 13 and 12, respectively. The R1in (pin 13) is the RS232 side that is connected to the TxD pin of the RS232 DB connector, and R1out (pin 12) is the TTL side that is connected to the RxD pin of the microcontroller.

Fig 4.10 MAX232 Line Drivers

Department of ECE

34

H.K.B.K.C.E

Clinometer

4.3.2. Applications of MAX 232:


Battery-Powered Systems. Terminals. Modems. Computers.

4.4. LCD Module

Fig.4.11. LCD Module

LCD displays designed around LCD module, are inexpensive, easy to use, and it is even possible to produce a readout using the 8 x 80 pixels of the display. Hitachi LCD displays have a standard ASCII set of characters plus Japanese, Greek and mathematical symbols.

Department of ECE

35

H.K.B.K.C.E

Clinometer

For an 8-bit data bus, the display requires a +5V supply plus 11 I/O lines. For a 4bit data bus it only requires the supply lines plus seven extra lines. When the LCD display is not enabled, data lines are tri-state which means they are in a state of high impedance (as though they are disconnected) and this means they do not interfere with the operation of the microcontroller when the display is not being addressed. The LCD also requires 3 "control" lines from the microcontroller. The Enable (E)line allows access to the display through R/W and RS lines. When this line is low, the LCD is disabled and ignores signals from R/W and RS. When (E) line is high, the LCD checks the state of the two control lines and responds accordingly. The Read/Write(R/W) line determines the direction of data between the LCD and microcontroller. When it is low, data is written to the LCD. When it is high, data is read from the LCD. With the help of the Register select (RS)line, the LCD interprets the type of data on data lines. When it is low, an instruction is being written to the LCD. When it is high, a character is being written to the LCD. Logic status on control lines:

0 Access to LCD disabled 1 Access to LCD enabled

R/W

0 Writing data to LCD 1 Reading data from LCD

RS

0 Instruction 1 Character

Department of ECE

36

H.K.B.K.C.E

Clinometer

Writing data to the LCD is done in several steps: Set R/W bit to low Set RS bit to logic 0 or 1 (instruction or character) Set data to data lines (if it is writing) Set E line to high Set E line to low Read data from data lines (if it is reading)

Reading data from the LCD is done in the same way, but control line R/W has to be high. When we send a high to the LCD, it will reset and wait for instructions. Typical instructions sent to LCD display after a reset are: turning on a display, turning on a cursor and writing characters from left to right. When the LCD is initialized, it is ready to continue receiving data or instructions. If it receives a character, it will write it on the display and move the cursor one space to the right.

4.5 RS-232
4.5.1 Introduction to RS232 Pin Connection
Serial communication is basically the transmission or reception of data one bit at a time. Today's computers generally address data in bytes or some multiple thereof. A byte contains 8 bits. A bit is basically either a logical 1 or zero. Every character on this page is actually expressed internally as one byte. The serial port is used to convert each byte to a stream of ones and zeroes as well as to convert streams of ones and zeroes to bytes. The serial port contains an electronic chip called a Universal Asynchronous

Receiver/Transmitter (UART) that actually does the conversion.

Department of ECE

37

H.K.B.K.C.E

Clinometer

Fig 4.12: Serial connector and cable The serial port has many pins. We will discuss the transmit and receive pin first. Electrically speaking, whenever the serial port sends a logical one (1) a negative voltage is effected on the transmit pin. Whenever the serial port sends a logical zero (0) a positive voltage is affected. When no data is being sent, the serial port's transmit pin's voltage is negative (1) and is said to be in a MARK state. Note that the serial port can also be forced to keep the transmit pin at a positive voltage (0) and is said to be the SPACE or BREAK state. (The terms MARK and SPACE are also used to simply denote a negative voltage (1) or a positive voltage (0) at the transmit pin respectively). When transmitting a byte, the UART (serial port) first sends a START BIT which is a positive voltage (0), followed by the data (general 8 bits, but could be 5, 6, 7, or 8 bits) followed by one or two STOP BITs which is a negative(1) voltage. The sequence is

Department of ECE

38

H.K.B.K.C.E

Clinometer

repeated for each byte sent. Figure 4.13 shows a diagram of how a byte transmission would look like.

Fig 4.13: Byte transmission At this point you may want to know what is the duration of a bit is. In other words, how long does the signal stay in a particular state to define a bit. The answer is simple. It is dependent on the baud rate. The baud rate is the number of times the signal can switch states in one second. Therefore, if the line is operating at 9600 baud, the line can switch states 9,600 times per second. This means each bit has the duration of 1/9600 of a second or about 100 sec. when transmitting a character there are other characteristics other than the baud rate that must be known or that must be setup. These characteristics define the entire interpretation of the data stream. The first characteristic is the length of the byte that will be transmitted. This length in general can be anywhere from 5 to 8 bits. The second characteristic is parity. The parity characteristic can be even, odd, mark, space, or none. If even parity, then the last data bit transmitted will be a logical 1 if the data transmitted had an even amount of 0 bits. If odd parity, then the last data bit transmitted will be a logical 1 if the data transmitted had an odd amount of 0 bits. If MARK parity, then the last transmitted data bit will always be a logical 1. If SPACE parity, then the last transmitted data bit will always be a logical 0. If no parity then there is no parity bit transmitted. The third characteristic is the amount of stop bits. This value in general is 1 or 2.Assume we want to send the letter 'A' over the serial port. The binary representation of the letter 'A' is 01000001. Remembering that bits are transmitted from least significant bit

Department of ECE

39

H.K.B.K.C.E

Clinometer

(LSB) to most significant bit (MSB), the bit stream transmitted would be as follows for the line characteristics 8 bits, no parity, 1 stop bit, and 9600 baud. LSB (0 1 0 0 0 0 0 1 0 1) MSB The above represents (Start Bit) (Data Bits) (Stop Bit) To calculate the actual byte transfer rate simply divide the baud rate by the number of bits that must be transferred for each byte of data. In the case of the above example, each character requires 10 bits to be transmitted for each character. As such, at 9600 baud, up to 960 bytes can be transferred in one second. The above discussion was concerned with the "electrical/logical" characteristics of the data stream. We will expand discussion to the line protocol. Serial communication can be half duplex or full duplex. Full duplex communication means that a device can receive and transmit data at the same time. Half duplex means that the device cannot send and receive at the same time. It can do them both, but not at the same time. Half duplex communication is all but outdated except for a very small focused set of applications. Half duplex serial communication needs at a minimum two wires, signal ground and the data line. Full duplex serial communication needs at a minimum three wires, signal ground, transmit data line, and receive data line. The RS232 specification governs the physical and electrical characteristics of serial communications. This specification defines several additional signals that are asserted (set to logical 1) for information and control beyond the data signals and signal ground. These signals are the Carrier Detect Signal (CD), asserted by modems to signal a successful connection to another modem, Ring Indicator (RI), asserted by modems to signal the phone ringing, Data Set Ready (DSR), asserted by modems to show their presence, Clear To Send (CTS), asserted by modems if they can receive data, Data Terminal Ready (DTR), asserted by terminals to show their presence, Request To Send (RTS), asserted by terminals if they can receive data. The section RS232 Cabling describes these signals and how they are connected.

Department of ECE

40

H.K.B.K.C.E

Clinometer

The above paragraph related to hardware flow control. Hardware flow control is a method that two connected devices use to tell each other electronically when to send or when not to send data. A modem in general drops (logical 0) its CTS line when it can no longer receive characters. It re-asserts it when it can receive again. A terminal does the same thing instead with the RTS signal. Another method of hardware flow control in practice is to perform the same procedure in the previous paragraph except that the DSR and DTR signals are used for the handshake. Note that hardware flow control requires the use of additional wires. The benefit to this however is crisp and reliable flow control. Another method of flow control used is known as software flow control. This method requires a simple 3 wire serial communication link, transmit data, receive data, and signal ground. If using this method, when a device can no longer receive, it will transmit a character that the two devices agreed on. This character is known as the XOFF character. This character is generally a hexadecimal 13. When a device can receive again it transmits an XON character that both devices agreed to. This character is generally a hexadecimal 11.

Department of ECE

41

H.K.B.K.C.E

Clinometer

Pin outs The following table lists commonly-used RS-232 signals and pin assignments.

Signal Name Common Ground Transmitted Data Received Data

Origin Abbreviation DTE DCE G TxD RxD

DE-9 (TIA-574)

5 3 2 4 6 7 8 1 9

Data Terminal Ready DTR Data Set Ready Request To Send Clear To Send Carrier Detect Ring Indicator DSR RTS CTS DCD RI

Table 4.2: Pin assignment of RS 232

The signals are named from the standpoint of the DTE. The ground signal is a common return for the other connections; it appears on two pins in the Yost standard but is the same signal. The DB-25 connector includes a second "protective ground" on pin 1.

Department of ECE

42

H.K.B.K.C.E

Clinometer

Connecting this to pin 7 (signal reference ground) is a common practice but not recommended. Use of a common ground is one weakness of RS-232: if the two devices are far enough apart or on separate power systems, the ground will degrade between them and communications will fail, which is a difficult condition to trace.

Signals Commonly-used signals are: Transmitted Data (TxD) Data sent from DTE to DCE. Received Data (RxD) Data sent from DCE to DTE. Ready to Send (RTS) Asserted (set to logic 0, positive voltage) by DTE to prepare DCE to receive data. This may require action on the part of the DCE, e.g. transmitting a carrier or reversing the direction of a half-duplex channel. For the modern usage of "RTS/CTS handshaking," see the section of that name.

Ready to Receive (RTR) Asserted by DTE to indicate to DCE that DTE is ready to receive data. If in use, this signal appears on the pin that would otherwise be used for Request To Send, and the DCE assumes that RTS is always asserted; see RTS/CTS handshaking for details. Clear To Send (CTS) Asserted by DCE to acknowledge RTS and allow DTE to transmit. This signalling was originally used with half-duplex modems and by slave terminals on multidrop lines: The DTE would raise RTS to indicate that it had data to send, and the modem would raise CTS to indicate that transmission was possible. For the modern usage of "RTS/CTS handshaking," see the section of that name.

Department of ECE

43

H.K.B.K.C.E

Clinometer

Data Terminal Ready (DTR) Asserted by DTE to indicate that it is ready to be connected. If the DCE is a modem, this may "wake up" the modem, bringing it out of a power saving mode. This behaviour is seen quite often in modern PSTN and GSM modems. When this signal is deasserted, the modem may return to its standby mode, immediately hanging up any calls in progress.

Data Set Ready (DSR) Asserted by DCE to indicate the DCE is powered on and is ready to receive commands or data for transmission from the DTE. For example, if the DCE is a modem, DSR is asserted as soon as the modem is ready to receive dialing or other commands; DSR is not dependent on the connection to the remote DCE (see Data Carrier Detect for that function). If the DCE is not a modem (e.g. a null modem cable or other equipment), this signal should be permanently asserted (set to 0), possibly by a jumper to another signal.

Data Carrier Detect (DCD) Asserted by DCE when a connection has been established with remote equipment.

Ring Indicator (RI)

Asserted by DCE when it detects a ring signal from the telephone line.

Serial Cable The standard does not define a maximum cable length but instead defines the maximum capacitance that a compliant drive circuit must tolerate. A widely-used rule-ofthumb indicates that cables more than 50 feet (15 metres) long will have too much capacitance, unless special cables are used. By using low-capacitance cables, full speed

Department of ECE

44

H.K.B.K.C.E

Clinometer

communication can be maintained over larger distances up to about 1,000 feet.[7] For longer distances, other signal standards are better suited to maintain high speed. Since the standard definitions are not always correctly applied, it is often necessary to consult documentation, test connections with a breakout box, or use trial and error to find a cable that works when interconnecting two devices. Connecting a fully-standardcompliant DCE device and DTE device would use a cable that connects identical pin numbers in each connector (a so-called "straight cable"). "Gender changers" are available to solve gender mismatches between cables and connectors. Connecting devices with different types of connectors requires a cable that connects the corresponding pins according to the table above. Cables with 9 pins on one end and 25 on the other are common. Manufacturers of equipment with 8P8C connectors usually provide a cable with either a DB-25 or DE-9 connector (or sometimes interchangeable connectors so they can work with multiple devices). Poor-quality cables can cause false signals by crosstalk between data and control lines (such as Ring Indicator).

4.6 POTENTIOMETER

Fig 4.14(a) potentiometer

Department of ECE

45

H.K.B.K.C.E

Clinometer

Fig 4.14(b) potentiometer

Working
In a POT, when the value of the resistance is zero the voltage is also zero. Hence the voltage to the ADC will be zero. Therefore there is no conversion taking place in the ADC. However as the resistance is varied, there will be a variation in the voltage value. This variation in the voltage value is fed to the ADC which is an 8 bit ADC having (28-1) i.e.; 0-255 steps . Each variation in the POT is recorded in the program so that each variation in the POT results in a corresponding variation in the voltage which is fed to the ADC. This specific voltage is converted into its equivalent digital form in the ADC which gets converted into a corresponding degree in the program. So by varying the POT we in turn change the angle or degree to get the specific voltage.

Department of ECE

46

H.K.B.K.C.E

Clinometer

4.7 DC Gear Motor


4.7.1 What is a Gear Motor?
A gear motor is a type of electrical motor. Like all electrical motors, it uses the magnetism induced by an electrical current to rotate a rotor that is connected to a shaft. The energy transferred from the rotor to the shaft is then used to power a connected device. In a gear motor, the energy output is used to turn a series of gears in an integrated gear train. There are a number of different types of gear motors, but the most common are AC (alternating current) and DC (direct current).

Fig. 4.15: Dc Gear motor Gear motors are complete motive force systems consisting of an electric motor and a reduction gear train integrated into one easy-to-mount and -configure package. This greatly reduces the complexity and cost of designing and constructing power tools, machines and appliances calling for high torque at relatively low shaft speed or RPM. Gear motors allow the use of economical low-horsepower motors to provide great motive force at low speed such as in lifts, winches, medical tables, jacks and robotics. They can be large enough to lift a building or small enough to drive a tiny clock. A gear motor converts power from one source, such as electricity or internal combustion, into rotational power. This power can be applied in a variety of contexts, from turning other gears to driving pistons up and down. The key, though, is that the gear in the gear motor has the ability to vary a power source's torque.

Department of ECE

47

H.K.B.K.C.E

Clinometer

4.7.2 Principle of Operation


Most synchronous electric motors have output ranges of from 1,200 to 3,600
revolutions per minute. They also have both normal speed and stall-speed torque specifications. The reduction gear trains used in gear motors are designed to reduce the output speed while increasing the torque. The increase in torque is inversely proportional to the reduction in speed. Reduction gearing allows small electric motors to move large driven loads, although more slowly than larger electric motors. Reduction gears consist of a small gear driving a larger gear. There may be several sets of these reduction gear sets in a

reduction gear box.

4.7.3 Gear types


There are several gear types, each with their respective advantages and limitations. Amongst the list are Worm Spur and Helical gears.

Worm gears are relatively inexpensive and are available in high ratios in single gear set up to 100:1, also available in right angle configurations. They will tolerate high shock loads, and are quiet. However they are less efficient than other forms of gearing.

Fig. 4.16: Worm Gears

Department of ECE

48

H.K.B.K.C.E

Clinometer

Spur gears are produced by many manufactures and therefore are easy to locate. They are compact, efficient, and are available in a parallel shaft arrangement. They are available in 10:1 ratio per gear stage. The limitations are that spur gears are slightly more expensive, are more likely to produce noise and have less shock capability (compared to worm gears).

Fig. 4.17: Spur Gears

Department of ECE

49

H.K.B.K.C.E

Clinometer

Helical gears can be used on nonparallel and even perpendicular shafts, and can carry heavier loads than spur gears. They are compact, efficient, and are available in 5:1 ratio per gear stage. Limitations of helical gears are that they are slightly less efficient than a spur gear of the same size, are more expensive, and produce thrust loading on the bearings.

Fig. 4.18: Helical Gears

Gear Ratios

The key point of a gear motor system is the gear ratio. This is the ratio of teeth on the ring gear to the pinion gear. If, for example, the ring gear has 20 teeth and the pinion gear has 10, the ratio is 2:1. For every one time the ring gear spins, the pinion gear needs to spin twice. The higher the gear ratio, the more torque the system will have. The lower the gear ratio, the more speed it will have.

Speed Reduction

Sometimes the goal of using a gear motor is to reduce the rotating shaft speed of a motor in the device being driven, such as in a small electric clock where the tiny synchronous motor may be spinning at 1,200 rpm but is reduced to one rpm to drive the second hand, and further reduced in the clock mechanism to drive the minute and hour hands. Here the amount of driving force is irrelevant as long as it is sufficient to overcome the frictional effects of the clock mechanism.

Department of ECE

50

H.K.B.K.C.E

Clinometer

Torque Multiplication

Another goal achievable with a gear motor is to use a small motor to generate a very large force albeit at a low speed. These applications include the lifting mechanisms on hospital beds, power recliners, and heavy machine lifts where the great force at low speed is the goal.

4.7.4 Applications
What power Can openers, garage door openers, stair lifts, rotisserie motors, timer cycle knobs on washing machines, power drills, cake mixers and electromechanical clocks have in common is that they all use various integrations of gear motors to derive a large force from a relatively small electric motor at a manageable speed. In industry, gear motor applications in jacks, cranes, lifts, clamping, robotics, conveyance and mixing are too numerous to count.

Department of ECE

51

H.K.B.K.C.E

Clinometer

Chapter 5

SOFTWARE TOOLS
The softwares which are used to developed this project are, Keil IDE compiler Languages used: Embedded C

5.1 Introduction to Keil software


Keil MicroVision is an integrated development environment used to create software to be run on embedded systems (like a microcontroller). It allows such software to be written both in assembly or C programming languages and for that software to be simulated on a computer before being loaded onto the microcontroller.

5.1.1 What is Vision3?


Vision3 is an IDE (Integrated Development Environment) that helps write, compile, and debug embedded programs. It encapsulates the following components:

A project manager. A make facility. Tool configuration. Editor. A powerful debugger.

5.1.2 Steps followed in creating an application in vision3


To create a new project in uVision3: 1. Select Project - New Project. 2. Select a directory and enter the name of the project file. 3. Select Project Select Device and select a device from Device Database. 4. Create source files to add to the project 5. Select Project - Targets, Groups, and Files. Add/Files, select Source Group1,

Department of ECE

52

H.K.B.K.C.E

Clinometer

and add the source files to the project. 6. Select Project - Options and set the tool options. Note that when the target device is selected from the Device Database all-special options are set automatically. Default memory model settings are optimal for most applications. 7. Select Project - Rebuild all target files or Build target To create a new project, simply start MicroVision and select Project=>New Project from the pulldown menus. In the file dialog that appears, choose a name and base directory for the project. It is recommended that a new directory be created for each project, as several files will be generated. Once the project has been named, the dialog shown in the figure below will appear, prompting the user to select a target device. In this lab, the chip being used is the P89v51RD2.

Fig. 5.1: Window for choosing the target device

Department of ECE

53

H.K.B.K.C.E

Clinometer

Next, MicroVision must be instructed to generate a HEX file upon program compilation. A HEX file is a standard file format for storing executable code that is to be loaded onto the microcontroller. In the Project Workspace pane at the left, rightclick on Target 1 and select Options for Target 1 .Under the Output tab of the resulting options dialog, ensure that both the Create Executable and Create HEX File options are checked. Then click OK as shown in the two figures below.

Fig. 5.2: Project Workspace Pane

Fig. 5.3: Project Options Dialog

Next, a file must be added to the project that will contain the project code. To do this, expand the Target 1 heading, rightclick on the Source Group 1 folder, and select Add files Create a new blank file (the file name should end in .asm), select it, and click Add. The new file should now appear in the Project Workspace pane under the Source Group 1 folder. Double-click on the newly created file to open it in the editor. All code for this lab will go in this file. To compile the program, first save all source files by clicking on the Save All button, and then click on the Rebuild All Target Files to compile the program as shown in the figure below. If any errors or warnings occur during compilation, they will be displayed in the output window at the bottom of the screen.

Department of ECE

54

H.K.B.K.C.E

Clinometer

All errors and warnings will reference the line and column number in which they occur along with a description of the problem so that they can be easily located. Note that only errors indicate that the compilation failed, warnings do not (though it is generally a good idea to look into them anyway).

Fig.5.4: Save All and Build All Target Files buttons

When the program has been successfully compiled, it can be simulated using the integrated debugger in Keil MicroVision. To start the debugger, select Debug=>Start/Stop Debug Session from the pulldown menus. At the left side of the debugger window, a table is displayed containing several key parameters about the simulated microcontroller, most notably the elapsed time (circled in the figure below). Just above that, there are several buttons that control code execution. The Run button will cause the program to run continuously until a breakpoint is reached, whereas the Step Into button will execute the next line of code and then pause (the current position in the program is indicated by a yellow arrow to the left of the code).

Department of ECE

55

H.K.B.K.C.E

Clinometer

Fig. 5.5: Vision3 Debugger window

Breakpoints can be set by doubleclicking on the grey bar on the left edge of the window containing the program code. A breakpoint is indicated by a red box next to the line of code.

Department of ECE

56

H.K.B.K.C.E

Clinometer

Fig. 5.6: Reset, Run and Step into options

The current state of the pins on each I/O port on the simulated microcontroller can also be displayed. To view the state of a port, select Peripherals=>I/O Ports=>Port n from the pulldown menus, where n is the port number. A checked box in the port window indicates a high (1) pin, and an empty box indicates a low (0) pin. Both the I/O port data and the data at the left side of the screen are updated whenever the program is paused. The debugger will help eliminate many programming errors, however the simulation is not perfect and code that executes properly in simulation may not always work on the actual microcontroller.

Department of ECE

57

H.K.B.K.C.E

Clinometer

5.1.3 Device database


A unique feature of the Keil Vision3 IDE is the Device Database, which contains information a b out more than 400 supported m i crocont ro l l ers . When you create a new Vision3 project and select the target chip from the database, Vision3 sets all assembler, compiler, linker, and debugger options for you. The only option you must configure is the memory map.

5.1.4 Peripheral simulation


The Vision3 Debugger provides complete simulation for the CPU and on-chip peripherals of most embedded devices. To discover which peripherals of a device are supported, in Vision3 select the Simulated Peripherals item from the Help menu. You may also use the web-based Device Database. We are constantly adding new devices and simulation support for on-chip peripherals so be sure to check Device Database often.

5.2 Proload programming software


ProLoad is a software working as a user friendly interface for programmer boards from Sunrom Technologies. Proload gets its name from Program Loader term, because that is what it is supposed to do. It takes in compiled HEX file and loads it to the hardware. Any compiler can be used with it, Assembly or C, as all of them generate compiled HEX files. ProLoad accepts the Intel HEX format file generated from compiler to be sent to target microcontroller. It auto detects the hardware connected to the serial port. It also auto detects the chip inserted and bytes used. The software is developed in Delphi and requires no overhead of any external DLL. The programmer connects to the computers serial port (Comm 1, 2, 3 or 4) with a standard DB9 Male to DB9 Female cable. Baud Rate - 57600, COMx Automatically selected by window software. No PC Card Required.

Department of ECE

58

H.K.B.K.C.E

Clinometer

After making the necessary selections, the Auto Program button is clicked as shown in the figure below which burns the selected hex file onto the microcontroller.

Fig 5.7: Programming window

Department of ECE

59

H.K.B.K.C.E

Clinometer

5.3 Embedded C
The embedded c programming language is used in the microcontrollers. The embedded c language is a general-purpose programming language that provides code efficiency, elements of structured programming and a rich set of operators. Embedded c is not a big language and is not designed for any one particular area of application. Its generally combined with its absence of restriction, makes embedded c a convenient and effective programming solution for a wide variety of software tasks. Many applications can be solved more easily and efficiently with embedded c than with other more specialized languages. The embedded c language on its own is not capable of performing operations (such as input and output) that would normally require intervention from the operating system. Instead, these capabilities are provided as a part of standard library. Because these functions are separated from the language itself, embedded c is especially suited for producing code that is portable across wide platforms.

5.3.1. Advantages of Embedded C


High code efficiency Applicable in any platforms Easy to compile

Department of ECE

60

H.K.B.K.C.E

Clinometer

Chapter 6

APPLICATIONS OF CLINOMETER
Clinometer has different applications based on the professions in which they are used. The Clinometer is a versatile and exacting instrument used by many professions that makes streets and sidewalks safer, keeps buildings from sliding off hillsides and provides formulas for building stabilized bridges for crossing expanses of water and deep ravines. This remarkable instrument determines heights of mountains, measures the true distance of a horizon and calculates the grade of an incline. All of these are necessary for surveying, building cities and skyscrapers.

1. Geologists and Surveyors


Using Clinometer with a specific mathematical formula--height x distance y angle-assists geologists to assess the height of a tree or a mountain. On the other hand, surveyors use this multipurpose instrument for measuring angles with reference to the ground level. This provides important details of road building for the grade of a slope, to be used by vehicles. Surveyors also use clinometers to mark mining claims.

2. Winter Hikers and Skiers


Using Clinometer, winter hikers and skiers make certain their activities are safe. This instrument reveals the angle of a snow-covered slope, information that can be used to avoid the risk of an avalanche. Higher incidents of the life-threatening landslides occur at 25- and 45-degree angles .

3. Sailors
Before the invention of satellite weather monitors for seafaring vessels, sailors more commonly depended on the Clinometer to warn them of dangerous storms. Using a

Department of ECE

61

H.K.B.K.C.E

Clinometer

sight Clinometer, a seaman would calculate the height of clouds, which can determine if inclement weather is brewing in the atmosphere.

4. City Planners
Assessing road safety, appropriate runoff for streets and sidewalks as well as accessibility for pedestrians with special needs makes the Clinometer a valuable tool for city planners. The quality of life of city dwelling depends partly on roads and pedestrian pathways having the appropriate slope.

5. Engineers
Engineers designing bridges and structures use the inclinometer (another type of Clinometer) for measuring the incline of the land. By incorporating this important feature of design, the engineer has more diversity for assuring a structural plan in harmony with the land.

6. Forest Rangers
Forest rangers use Clinometer to measure how steep a hill is or how high a tree reaches. Clinometer is particularly important to foresters and the field work in which they engage. Foresters use the device for basic tasks such as determining tree height and volume data, which is needed, for example, to provide measurements for wildlife habitats or to monitor the health and growth of trees and other plants in a specific geographical area.

Department of ECE

62

H.K.B.K.C.E

Clinometer

6.1 Advantages and Disadvantages of Clinometer


6 .1 .1 Advantages:
1. Clinometer makes calculation of distance and height of objects simple. 2. Both height and distance can be calculated simultaneously 3. Human errors are reduced. 4. It is user friendly. 5. It is economical.

6.1.2 Disadvantages:
1. Accuracy of determining the height and distance of any building or object depends mainly on the operators vision. 2. Clinometer cannot be used for applications below ground level. 3. The distance and height of moving objects cannot be determined.

Department of ECE

63

H.K.B.K.C.E

Clinometer

Chapter 7

CONCLUSION AND FUTURE SCOPE


7.1 Conclusion
This is a simple and wonderful innovation which would be extremely beneficial to mankind as it makes the evaluation of the height and distance of both far and near objects very convenient. By using Clinometer we can find the height and distance of any object or building from a point within fraction of seconds with utmost accuracy. Human errors can be minimized as the height and distance does not require any manual calculation.

7.2 Future scope


With some extra implementations and programming, the system can be made more advanced and a lot more features can be added. Drilling and mining equipment. Construction equipment. Navigation and GPS Compensation. Antenna positioning. In the marine industry, clinometers can be used on ships and oil rigs to measure how much a vessel slants while being on still water and when the water is choppy. Surveying landscapes and determining the height of waterfalls and etc. .

Department of ECE

64

H.K.B.K.C.E

You might also like