72
Wirelessly Robotic Car Control System using Touch Screen Habib Ullah M Raza Shah M ASIF ASIF FEROZ

Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

Embed Size (px)

Citation preview

Page 1: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

Wirelessly Robotic Car Control System using

Touch Screen

Habib UllahM Raza Shah

M ASIF ASIF FEROZ

Page 2: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock
Page 3: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

Approval Certificate

This is to certify that the Thesis submitted by Mr. HabibUllah, and Mr.

Raza Shah is of sufficient standard to justify its acceptance by the Department

of Electrical Engineering, University of Engineering and Technology, UET

Peshawar Pakistan.

Page 4: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

Abstract

Page 5: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

AcknowledgementWe would like to express our deep and sincere gratitude to our honorable teacher and project supervisor, Engr. Sahibzada Fahim whose guidance and encouragement enabled us to complete our project and thesis.

We would also like to thank our parents for their support and encouragement throughout our educational careers. We would also like to thank our all respected teachers for helping us throughout our Engineering Career.

Page 6: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

TABLE OF CONTENTSTITLE PAGE APPROVAL SHEET ………………………………………………………………………... iLIST OF ABBREVIATIONS ………………………………………………………………. ii ABSTRACT ………………………………………………………………………………… iii ACKNOWLEDGEMENTS ………………………………………………………………… v TABLE OF CONTENTS ………………………………………………………………….... viLIST OF FIGURES …………………………………………………………………………. ix

Chapter 1: Introduction …………………………………………………………………… 1 1.1. Robotic System ….………………………………………………………....................... 3 1.2. Touch Screens ……………………………………………………………....................... 31.2. Wireless Links……………………………………………………………........................ 31.2. BasicOperation ..…………………………………………………………....................... 3

Chapter 2: Nuts and Bolts………………………………………………………………… 1 1.1. Sainsmart 3.2 TFT Display ……………………………………………....................... 3 1.2. 27 MHZ transmitter ………………………………………………………....................... 31.2. PIC MCUs ……………………………………………………………........................ 31.2. MPLABX ..…………………………………………………………....................... 31.2. Roboic Toy Car ..…………………………………………………………....................... 31.2. Embedded Tool ..…………………………………………………………....................... 3

Chapter 3: Implementation ………………………………………………………………… 1 1.1. Touch Display Operation ……………………………………………....................... 3 1.2. Touch Screen Reading ……………………………………………………....................... 31.2. Commands Transmission ………………………………………………........................ 31.2. Robot Moment ..…………………………………………………………....................... 31.2. Code ..…………………………………………………………....................... 3

Chapter 4: Application………………………………………………………………… 1 1.1. App. In Mining Engg.……………………………………………....................... 3 1.2. Security System ……………………………………………………....................... 31.2. National Geographic’s ………………………………………………........................ 31.2. Robot Moment ..………………………………………………………....................... 3

Page 7: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

CHAPATER-1

IntroductionROBOTIC SYSTEMrobot, any automatically operated machine that replaces human effort, though it may not resemble human beings in appearance or perform functions in a humanlike manner. By extension, robotics is the engineering discipline dealing with the design, construction, and operation of robots. The word robot comes from the Slavic word robota, which means labor. The play begins in a factory that makes artificial people called robots, creatures who can be mistaken for humans The word robotics first appeared in Isaac Asimov’s science-fiction story “Runaround” (1942). Along with Asimov’s later robot stories, it set a new standard of plausibility about the likely difficulty of developing intelligent robots and the technical and social problems that might result. “Runaround” also contained Asimov’s famous Three Laws of Robotics:

1. A robot may not injure a human being, or, through inaction, allow a human being to come to harm.

2. A robot must obey the orders given it by human beings except where such orders would conflict with the First Law.

3. A robot must protect its own existence as long as such protection does not conflict with the First or Second Law.

Robotics is the branch of technology that deals with the design, construction, operation, and application of robots,[1] as well as computer systems for their control, sensory feedback, and information processing. These technologies deal with automated machines that can take the place of humans in dangerous environments or manufacturing processes, or resemble humans in appearance, behavior, and/or

Page 8: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

cognition. Many of today's robots are inspired by nature contributing to the field of bio-inspired robotics.The concept of creating machines that can operate autonomously dates back to classical times, but research into the functionality and potential uses of robots did not grow substantially until the 20th century.[2] Throughout history, robotics has been often seen to mimic human behavior, and often manage tasks in a similar fashion. Today, robotics is a rapidly growing field, as technological advances continue, research, design, and building new robots serve various practical purposes, whether domestically, commercially, or militarily. Many robots do jobs that are hazardous to people such as defusing bombs, exploring shipwrecks, and mines.

Page 9: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

Touch ScreenA touchscreen is an electronic visual display that can detect the presence and location of a touch within the display area. The term generally refers to touching the display of the device with a finger or hand. Touch screens can also sense other passive objects, such as a stylus. In other words, a touchscreen is any monitor, based either on LCD (Liquid Crystal Display) or CRT (Cathode Ray Tube) technology that accepts direct onscreen input. The ability for direct onscreen input is facilitated by an external (light pen) or an internal device (touch overlay and controller) that relays the X, Y coordinates to the computer. The touchscreen has two main attributes. First, it enables one to interact directly with what is displayed, rather than indirectly with a cursor controlled by a mouse or touchpad. Secondly, it lets one do so without requiring any intermediate device that would need to be held in the hand Touchscreen technology has the potential to replace most functions of the mouse and keyboard. The touchscreen interface is being used in a wide variety of applications to improve human -computer interaction. As the technology advances, people may be able to operate computers without mice and keyboards. Because of its convenience, touch screen technology solutions has been applied more and more to industries, applications, products and services, such as Kiosks, POS (Point-of-Sale), consumer electronics, tablet PC, moderate to harsh Machine Control, Process Control, System Control/Office Automation and Car PC, etc.

TYPES OF TOUCHSCREEN TECHNOLOGYThe touch panels themselves are based around four basic screen technologies: Resistive, Capacitive, Surface Acoustical Wave (SAW) and Infrared (IR). Each of those designs has dis tinct advantages and disadvantages. The detailed study of each is as follows:

ResistiveResistive LCD touchscreen monitors rely on touch overlay, which is composed of a flexible top layer and a rigid bottom layer separated by insulating dots, attached to a touchscreen controller. The inside surface of each of the two layers is coated with a transparent metal oxide coating of Indium Tin Oxide (ITO) that facilitates a gradient across each layer when voltage is applied. Pressing the flexible top sheet creates electrical contact between the resistive layers, producing a switch closing in the circuit. The

Page 10: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

control electronics alternate voltage between the layers and pass the resulting X and Y touch coordinates to the touchscreen controller. The touchscreen controller data is then passed on to the computer operating system for processing. Resistive touch screen panels are generally more affordable but offer only 75% clarity and the layer can be damaged by sharp objects. Resistive touch screen panels are not affected by outside elements such as dust or water. Resistive touchscreens are used in food-service; retail Point-Of-Sale (POS), medical monitoring devices, portable and handheld products, industrial process control and instrumentation. Resistive Technology is divided into two broad categories:

4 -Wire Resistive Touchscreen TechnologyFour-wire resistive technology is the simplest to understand and manufacture. It uses both the upper and lower layers in the touchscreen "sandwich" to determine the X an d Y coordinates. Typically constructed with uniform resistive coatings of ITO on the inner sides of the layers and silver buss bars along the edges, the combination sets up lines of equal potential in both X and Y.

In the illustration below, the controller first applies 5V to the back layer. Upon touch, it probes the analog voltage with the coversheet, reading 2.5V, which represents a left -right position or X axis.It then flips the process, applying 5V to the covershe et, and probes from the back layer to calculate an up-down position or Y axis. At any time, only three of the four wires are in use.

Page 11: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

The primary drawback of four-wire technology is that one coordinate axis (usually the Y axis), uses the outer layer, the flexible coversheet, as a uniform voltage gradient. The constant flexing that occurs on the outer coversheet with use will eventually cause microscopic cracks in the ITO coating, changing its electrical characteristics (resistance), degrading the linearity and accuracy of this axis.2.1.2) 5-Wire Resistive Touchscreen TechnologyIn the five-wire design, one wire goes to the coversheet (E) which serves as the voltage probe for X and Y. Four wires go to corners of the back glass layer (A, B, C, and D). The controller first applies 5V to corners A and B and grounds C and D, causing voltage to flow uniformly across the screen from the top to the bottom. Upon touch, it reads the Y voltage from the coversheet at E. Then the controller applies 5V to corners A and C and grounds B and D, and reads the X voltage from E again.

Page 12: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

So, a five-wire touchscreen uses the stable bottom layer for both X- and Y-axis measurements. The flexible coversheet acts only as a voltage-measuring probe. This means the touchscreen continues working properly even with non-uniformity in the coversheet's conductive coating. The result is an accurate, durable and more reliable touchscreen over four- and eight-wire designs. Microscopic cracks in the coversheet coating might occur, but they would no longer cause non-linearities as in the case of 4 wire resistive touch screen. 2.2 CapacitiveA capacitive touch screen panel is coated with a material that stores electrical charges. When the panel is touched, a small amount of charge is drawn to the point of contact. Circuits located at each corner of the panel measure the charge and send the information to the controller for processing. Capacitive touch screen panels must be touched with a finger unlike resistive and surface wave panels that can use fingers and stylus.Capacitive touch screens have excellent clarity, and there are no moving parts to wear out. Liquids, dirt, grease, or other contaminants do not affect them. Unfortunately, gloved fingers will not activate the system. It is divided into two broad categories as follows:2.2.1) Surface capacitive technologyIn this technology, only one side of the insulator is coated with a conductive layer. A small voltage is applied to the layer, resulting in a uniform electrostatic field. When a conductor, such

Page 13: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

as a human finger, touches the uncoated surface, a capacitor is dynamically formed. The sensor's controller can determine the location of the touch indirectly from the change in the capacitance as measured from the four corners of the panel. As it has no moving parts, it is moderately durable, has limited resolution and is prone to false signals from parasitic capacitivecoupling. It is therefore most often used in simple applications such as industrial controls and kiosks.2.2.2) Projected capacitive technologyProjected Capacitive Touch (PCT) technology is a capacitive technology which permits more accurate and flexible operation, by etching the conductive layer. An X-Y grid is formed either by etching a single layer to form a grid pattern of electrodes, or byetching two separate, perpendicular layers of conductive material with parallel lines or tracks to form the grid. A finger on a grid of conductive traces changes the capacitance of the nearest traces. This change in trace capacitance is measured and finger position is computed. The use of an X-Y grid permits a higher resolution than resistive technology. Projected capacitive touch screens are clear, durable, solid state, scratch resistant and allow gloved hand use. All these features make them ideal for harsh, industrial, or outdoor applicationsThe trend of using touch pad in smart appliances is growing day by day. Touch LCD not only provide ease of use but also facilitate end user interface up to great extant. A touchscreen is an electronic visual display that the user can control through simple or multi-touch gestures by touching the screen with one or more fingers. Some touchscreens can also detect objects such as a stylus or ordinary or specially coated gloves. The user can use the touchscreen to react to what is displayed and to control how it is displayed (for example by zooming the text size).

Wireless linksWireless The term wireless means without wire, cable or any other physical connecting link.Here in this technology the elements or devices are connected and communicating without any physical link.Wireless operations permit services, such as long-range communications, that are impossible or impractical to implement with the use of wires. The term is commonly used in the telecommunications industry to refer to telecommunications systems (e.g. radio transmitters and receivers, remote controls etc.) which use some form of energy (e.g. radio waves, acoustic

Page 14: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

energy, etc.) to transfer information without the use of wires. [1] Information is transferred in this manner over both short and long distances.Wireless communication is the transfer of information between two or more points that are not connected by an electrical conductor.Answering the call of customers frustrated with cord clutter, many manufacturers of computer peripherals turned to wireless technology to satisfy their consumer base. Originally these units used bulky, highly limited transceivers to mediate between a computer and a keyboard and mouse; however, more recent generations have used small, high-quality devices, some even incorporating Bluetooth. These systems have become so ubiquitous that some users have begun complaining about a lack of wired peripherals. Wireless devices tend to have a slightly slower response time than their wired counterparts; however, the gap is decreasing.Modes of wireless communication

Wireless communications can be via:

radio  communication, microwave  communication, for example long-range line-of-sight via

highly directional antennas, or short-range communication, light, visible and infrared (IR) for example consumer IR devices such

as remote controls or via Infrared Data Association (IrDA). sonic, especially ultrasonic short range communication electromagnetic induction  short range communication and powerApplications The application of wireless communicationm involve point-to-point communication, point-to-multipoint communication, broadcasting, cellular networks and other wireless networks.

Wi-Fi technology.

Page 15: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

CHAPTER # 2NUTS AND BOLTS

Sainsmart 3.2tft Display:In this project we will use 3.2TFT LCD touch screen to provide different functionality to

end user. Some of these features include:

1) In vehicle user call facility2) In vehicle car conditions facility including speed, oil gauge, head lights etc…3) In vehicle graphical display for different application…

The figure below shows the 3.2TFT sainsmart Touch LCD.

Page 16: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

Pin Diagram:

Procedure for LCD:1) Set Pin RD, CS to be 1 2) Set Pin CS to be 0 3) Send 8Bit Command Set to 8Bit Data Bus Lower and then send 0x00 to 8 Bit Data Bus Upper 4) Set Pin RS to be 0 5) Set Pin WR to be 06) Set Pin WR to be 1 7) Set Pin RS to be 1 After sent the command set successfully, user needs to send the data of the command as follows; 8) Still set Pin CS to be 0 and still set Pin RS, RD to be 1 9) Send 16Bit Data of the command set to all 16Bit Data Bus. 10) Set Pin WR to be 0 11) Set Pin WR to be 1 12) Set Pin CS to be 1

Procedure for Touch Interfacing:

Page 17: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

1) Read status from Pin PEN of ADS7846; if it is 0 (touching the screen), start reading

value in the next step 2; on the other hand, if it is 1 (not touching any screen yet), reads

repeatedly.

2) Set Pin DCLK, CS, DOUT to be 0

3) Send Control Byte 0x0D to Pin DIN (MOSI) of ADS7846 to specify reading 12Bit

ACD value on the X axis.

4) Send Data 0x00 to Pin DIN (MOSI) of ADS7846. While sending out data in each bit,

ADS7846 will also shift out the ADC value to Pin DOUT(MISO). The first bit data that is

shifted out is the 11th bit at the falling edge of the second DCLK. When all 8 of DCLK

are sent out completely, it reads data on the X axis as 0x0ddddddd (d=data bit11bit5).

5) Send Control Byte 0x90 to Pin DIN (MOSI) of ADS7846 to specify reading 12Bit

ADC value on Y axis. While sending out this Control Byte, the last 5Bit data ADC on X

axis will be also sent out. It begins with bit4 to bit0 and Data is arranged as 0xddddd000

(d=data bit4bit0).

6) Send Data 0x00 to Pin DIN (MOSI) of ADS7846. While sending out data in each bit,

ADS7846 will also shift out ADC value to Pin DOUT(MISO). The first bit data that is

shifted out is the 11th bit at the falling edge of the second DCLK. When all 8 of DCLK is

sent completely, it reads on the Y axis as 0x0ddddddd (d=data bit11 bit5).

7) Send Data 0x00 to Pin DIN (MOSI) of ADS7846. While sending out Data, the last 5Bit

ADC data on the Y axis will be also sent out. It begins with bit4 to bit 0 and Data is

arranged as 0xddddd000 (d=data bit4 bit0).

8) When the ADC values on both axes are read completely, need to set Pin CS to be 1 to

finish reading values from ADS7846.

9) If user wants to read the new value, repeatedly start the step 1. 10) After got the ADC value on each axis completely, user needs to arrange the values. The variable that is used to store the ADC value should be read as 16Bit. When the first 7Bit of data ADC is read, it is stored in the 16Bit variable as 0x000000000ddddddd ; and the next 5Bit when it is stored in the 16bit variable is 0x000000000ddddddd. Then shift out the first 7Bit data that is read to the left side 5Bit and then shift out the next 5Bit that is read to the right side 3Bit. Finally, must OR(|) both sets together, user got 12Bit data ADC of the axis that is read as 0x000ddddddddddddd. This is the complete value and is ready to use.

Page 18: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

THE 27MHz TRANSMITTER In this discussion we cover 27MHz transmitters and receivers as found in remote control cars,aeroplanes, walkie talkies and some of the older-style garage door openers. We have provided a number of circuits so you can work out the best type for your application and these circuits will also help you understand which components are critical and which components can be changed. It's a matter of looking at each circuit and seeingthe general layout, and comparing it to the other circuits. In this way you are building up a conceptof "building blocks" and this is the basis to learning electronics. Talking Electronics does not provide any kits for these circuits as the products (toy cars, wireless doorbells etc) are readily available in toy shops, hobby shops and many of the $2.00 "junk Shops." You cannot buy many of the special components and the cost of the completed item is less than buying the components! Let's start: 6 bands (or frequencies) were allocated for the 27MHz band, Channel Frequency 1 26.9952 27.045 3 27.095 4 27.145 5 27.195 6 27.255

and these were very popular for transmission - especially in countries where transmitting was strictlycontrolled. Both 27MHz and 49MHz circuitry produced very low cost devices and they are still available. But you

Page 19: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

must be careful as some of the latest types are much more sophisticated (and sometimes cost less than the older types). We will investigate how they work and how they can be modified. Very little is available on how these circuits workand this article will cover the "building blocks."When we use the term "building block" we mean a group of components making up a circuit that carries out a particular function and can be connected to another circuit to achieve a final result. In this way you can create your own project without having to design each of the sections. A typical example is the 5-channel remote control circuit we have modified to produce an on-off action from two of the outputs. You can build these circuits from scratch,but why re-invent the wheel?If you want a 27MHz or 49MHzlink, the best idea is to buy a toy and modify it. If you want voice communication, get a walkie talkie. If you want a single on-off operation, get a remote control car. Some remote control cars have up to 5 channels and sell for less than $20.00. You can get everything you need on 2 printed circuit boards, ready for modification, without having to source the components.Look for 4 function models that require 3v operation for both remote and receiver. The fifth function is "turbo" and is not used in some of the designs. Thephoto below is the 4(5) function 27MHz remote control car we discussed above:

Page 20: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

. The first two circuits (figs 1& 2) form a single-channel transmitter-receiver link. The second receiver (fig 7) uses a split supply to power a motor in theforward and reverse direction (it uses the same transmitter as shown in fig 1). The third transmitter & receiver, (figs 12 & 22) is a multi-channel design, with a chip in the receiver. Then we cover a 27MHz walkie talkie. This is a 4 transistor model. It uses the same type of super-regenerative front-end as our receiver circuits and injects Amplitude Modulated(AM) audio onto the signal. The result is a very noisy transmission but a very effective way to achieve both transmission and reception with the minimum ofcomponents. Most of the parts have a dual function, operating in both transmit and receive mode. This makes the circuit very efficient, component-wise. Before we start, some of the Japanese transistors have either a very high frequency capability or a very high collector current. These transistors needto have an equivalent for the circuit to work successfully. Here is a list of some of the type you will come across and some equivalents

Page 21: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

Fig 1 shows a simple 27MHz transmitter producing a carrier.

Page 22: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

The 27MHz transmitter PC boardThis means it produces an unmodulated 27MHz signal and when picked up by a receiver, such as shown in fig 2, the result is a clean, noise-free reception. To increase the output of the transmitter, the 390R resistor is replaced by a 220R. This increasesthe current from 7mA to 12mA. The resistor could be decreased to 150R for more output .

Page 23: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

When the transmitter is off, the car moves forward.When the transmitter is on, the car reverses and moves in a circular pattern. This allows the operator to guide the car around obstacles. It's a very awkward way to control a car and although it is very simple and clever, it is not really successful inpractice. We will not be going into the mechanics of how the car steers, only the fact that the transmitter causes the motor to reverse direction. In place of the motor you could use a relay or two separate motors to carry out a number of functions and we will show how the circuit can be modified todo this. The receiver works on a "tone," "no-tone" principlebut the transmitter doesn't actually send a tone as this would require additional circuitry. What happens is the receiver picks up random noise from the airwaves when the transmitter is not operating and this functions as the tone part of the reception. This random noise is amplified by the second transistor and passed to a 0.47u electrolytic that keeps the third transistor in conduction for the majority of the time. The operation of this will be discussed later.

Page 24: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

The 10u on the output of the third transistor keepsthe output low for the short periods when the third transistor is not low. The motor is connected in a bridge formation via four transistors and these change the polarity of the supply to the motor. When the transmitter is operating, and the receiveris within range, it picks up a 27MHz carrier that over-rides the random noise and produces a CARRIER.This means the second transistor will not see any noise and thus the 0.47u electrolytic will charge and turn off the third transistor. The 10u will charge via the 2k2 and the input to the bridge willchange from a LOW to a HIGH. This will turn on theopposite half of the bridge to supply current to the motor in the reverse direction. Now we will cover the circuit in detail. HOW THE TRANSMITTER WORKS The transmitter is a very simple crystal oscillator. The heart of the circuit is the tuned circuit consisting of the primary of the transformer and a 10p capacitor. These two components oscillate when a voltage is applied to them. The frequency is adjusted by a ferrite slug in the centre of the coil until it is exactly the same as the crystal. The crystal will then maintain the frequency over a wide range of temperatureand supply voltage fluctuations. The transistor is configured as a common emitter amplifier. It has a resistor on the emitter for biasing purposes but the 82p across the 390R effectively takes the emitterto the negative rail as far as the signal is concerned. The 390R resistor prevents a high current passingthrough the transistor as the resistance of the transformer is very low. The tuned circuit operates atexactly the third harmonic (also called the third overtone - an overtone is a multiple of a fundamental frequency) of the crystal so that the crystal will oscillate at its third overtone (27MHz) and in-turn, keep

Page 25: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

the frequency of the circuit stable. The transformer in the collector of the transistor performs two functions. 1. It matches the impedance of the transistor to the impedance of the antenna, and 2. Creates a resonant circuit at 27MHz to make sure the crystal oscillates at this frequency. You can seethe transformer creates a resonant circuit by the fact that it has a capacitor across the primary winding. These two components create a "resonant" or "tuned " circuit and this is where the circuit "gets its frequency." The crystal has a fundamental of about 9MHz and it will oscillate at this frequency unless assisted tooscillate at a higher frequency. This is done by the tuned circuit oscillating at 27MHz. Now we will look at the impedance-matching feature of the transformer. The impedance of the output of the transistor is about 1k to 5k and this means it is the impedance (resistance) "it works at." In other words, it is the characteristic impedance of the transistor in this type of stage. The impedance of a whip antenna is about 50 ohms and the transformer matches these two by having a TURNS RATIO. The primary has about 12 turns and the secondary about 3 turns. This provides part of the matching requirement. The `pi' network, made up of the 150p,15 turn air-cored coil and 100p capacitor assists further in matching the output of the transformer to the antenna. When the power is applied, the transistor turns on fairly hard due to the 82p in the emitter being uncharged. This puts a pulse of energy through the 10p and as the transistor turns off slightly due to the 82p charging, the energy in the 10p capacitor is passedto the primary of the transformer to start the 27MHz cycle. The action of the emitter rising and falling during start-up, allows the base to rise andfall and this puts a pulse on the crystal to start it oscillating.

Page 26: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

The frequency of oscillation OF THE CIRCUIT is generated by the tuned circuit in the primary of the transformer and the crystal merely keeps the circuit operating at exactly 27.145MHz (or 27.240MHz, depending on the frequency of the crystal). The turns ratio of the transformer converts a high voltagewaveform (that has little current) from the transistor, into a low voltage waveform with a higher current. This is exactly what the antenna requires. But before the signal passes into the antenna it goes through the pi network, then an 8 turn Radio Frequency Choke. This is 8 turns of enamelled wire wound on a ferrite core and is called a base-load for the antenna. The result is a 27MHz frequency called a CARRIER. The carrier produces a clean spot on the band that is free from background noise. HOW THE RECEIVER WORKS The first thing you have to realize is the receiveris really a transmitter. It's a very weak transmitter and delivers a low level signal to the surroundings viathe antenna. When another signal (from the transmitter) comes in contact with the transmissionfrom the receiver it creates an interference pattern that reflects down the antenna and into the first stage of the receiver. The receiver is a super-regenerative design. This means it is self-oscillating (or already oscillating) and makes it very sensitive to nearby signals. It is much more sensitive than receiving a signal and making it oscillate a transistor. A super-regenerative design is not universally usedbecause it is much more noisy than conventional reception and is not suitable for voice transmission. However it is used in simple walkie-talkies and this is why they are so noisy - as will be shown at the end of this article. When a signal of the same frequency as the super-regenerative circuit passes near the antenna, the circuit has difficulty radiating

Page 27: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

a signal. This means the circuit current VARIES. These variations appear across the 2k2 load resistor as a change in voltage and the signal is picked off via a 100n capacitor and passed to the second and thirdstages for amplification. The 22n across the first stage is designed to remove the high-frequency component from the waveform. If this were not present, the circuit would never change state. The receiver is tuned to thefrequency of the crystal in the transmitter via a slug-tuned coil in the collector. When the transmitter is off, the receiver picks up background noise and amplifies it to produce random-noise. This is amplified by the second transistor and passed to the third via a 0.47u electrolytic. This electrolytic is designed to keepthe third transistor ON for the major part of the time and it does this in a very clever way. We will assume the supply has just been turned on and the second transistor is not receiving a signal. The 0.47u will be uncharged and it will charge via the 10k collector resistor and the base-emitter junction ofthe third transistor. The action of the current flowing through the base of the third transistor will turn it ON but after ashort time the electrolytic will be fully charged and thecurrent will cease and the transistor will turn off. A 10u on the collector of the third transistor will then begin to charge via the 2k2 resistor and after a period of time called the DELAY TIME, the output will be HIGH and change the state of the bridge. But if a signal is present on the collector of the second transistor, (in our case this will be backgroundhash), the voltage on the collector will be rising and falling. When the voltage goes low, it takes the positive end of the 0.47u low and the other end must follow. The voltage on the negative end will go below the negative rail and at -0.7v it gets clamped by the

Page 28: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

diode. This means the electrolytic gets discharged very rapidly when the second transistor turns on. The result is the electrolytic takes a long time tocharge and a short time to discharge, even when random noise (hash) is being processed. The action of the 0.47u is amazing and will be explained in more detail in a moment. During the short periods of time when the third transistor is not turned on, the 10u on the collector will take over and hold the signal low. It's only when a long durationof silence is encountered, that the circuit will change state. This period of silence is when the transmitter turns ON and the time is very short in real terms. Transistor Q3 is called the switching transistor. It changes between HIGH and LOW to create the forward and reverse direction. The switching transistor feeds two driver transistors, Q4 and Q9. Each of these drives two output transistors. Q4 drives Q6 and Q7. Q9 drives Q5 and Q8. Follow these transistors on the circuit and you will see how the supply is directed to the motor, firstly in one direction and then the other. The printed circuit board is quite complex because of the number of driver transistors. But since these cost less than 2 cents when bought in the million, it is not cheaper to use a chip. HOW THE 0.47u WORKSThe 0.47u electrolytic on the base of the third transistor needs explaining as its operation is very clever.

Page 29: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

Charging the 0.47u electrolytic is represented as a battery.The electrolytic is simply a tiny re-chargeable battery and when the circuit first turns on, it is uncharged. The charging current passes through the base-emitter junction of the third transistor and keeps it ON as shown in fig: 3. If the electrolyticis allowed to fully charge, the current will fall to zero and the third transistor will turn off. But the second transistor discharges the electrolytic quickly before it has time to fully charge. It does this by turning ON. How the electrolytic discharges is shown in fig: 4. The only components involved in the discharge are Q2 and the diode. Transistor Q2 is turned on and it will have zero volts (0.3v) on the collector. Discharging the 0.47u electrolytic.This means the positive lead of the electrolytic (equivalent to the positive terminal of the battery) will drop from say nearly 3v, to 0.3v. The negative leadmust follow and normally it would be at -2.7v. Yes, the negative lead would have a negative voltage on it relative to the 0v rail, if the diode was not

Page 30: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

present. BUT the diode on the negative lead gets turned on as soon as the voltage on the negative lead falls to -0.7v and prevents it going below -0.7v. As the positive lead falls, the energy in the electrolytic is quickly discharged through the diode and when the second transistor turns OFF, the electrolytic is ready for charging, through the 10kresistor.

PIC MICROCONTROLLERPIC18F452PIC32MX250F128B

The PIC16 series of microcontrollers have been around for many years. Although they are excellent general-purpose microcontrollers, they have certain limitations. For example, the program and data memory capacities are limited, the stack is small, and the interrupt structure is primitive – all interrupt sources share the same interrupt vector. The PIC16 series of microcontrollers also do not provide direct support for advanced peripheral interfaces, such as USB and CAN bus, and it is rather complex to interface to such devices easily. The instruction set of these microcontrollers is also limited. For example, there are no instructions for multiplication or division and branching is rather simple and is made out of a combination of skip and goto instructions. Microchip Inc. has developed the PIC18 series of microcontrollers for high-pin-count, high-d ensity, and complex applications.

Figure 2.1 shows the current PIC microcontroller family of products. At the lowest end of the family, we have the PIC10 microcontrollers, operating at approximately 5 MIPS and with small form factors, less memory, and a low cost. Then we have the PIC12 and PIC16 series of micro -controllers with midrange architectures, 5–8 MIPS operating performance, and reasonable size of memory. The microcontrollers of the PIC18 family are advanced high-performance devices, with 10–16 MIPS, and offer a large amount of memory with various on-chip peripheral support modules. As shown in Figure 2.1, the higher end of the family consists of 16-bit devices, such as the PIC24 and the dsPIC, and 32-bit devices, such as the dsPIC33 and the PIC32 series.

The PIC18 microcontroller family consists of three architectures: the standard PIC18F series, the PIC18J series, and the PIC18K series. PIC18J series are 10–12 MIPS, low-voltage, high-

Page 31: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

performance microcontrollers with integrated USB, Ethernet, or LCD. PIC18K series are 16 MIPS, high-performance, and low-power devices.

The PIC18F microcontrollers can be used in cost-efficient solutions for general-purpose applications written in C, using a real-time operating system (RTOS), and require complex communication protocol stack, such as TCP/IP, CAN, USB, or ZigBee. PIC18F devices provide flash program memory in sizes from 8 to 128 KB and data memory from 256 to 4 KB, operating at 2.0–5.0 V at speeds from DC to 40 MHz.

The basic features of the PIC18F series of microcontrollers are as follows:

77 instructions. PIC16 source code compatible. Program memory addressing up to 2 MB Data memory addressing up to 4 KB DC to 40-MHz operation

8 × 8 hardware multiplier

Page 32: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

Interrupt priority levels 16-bit wide instructions, 8-bit wide data path Up to two 8-bit timer/counters Up to three 16-bit timer/counters Up to four external interrupts High-current (25 mA) sink/source capability Up to five capture/compare/pulse width modulation (PWM) modules Master synchronous serial port module (serial peripheral interface [SPI] and

I2C modes) Up to two universal synchronous-asynchronous receiver-transmitter (USART)

modules Parallel slave port (PSP) Fast 10-bit analog-to-digital (A/D) converter Programmable low-voltage detection (LVD) module Power-on reset (POR), power-up timer (PWRT), and oscillator start-up timer

(OST) Watchdog timer (WDT) with on-chip RC oscillator In-circuit programming

In addition, some microcontrollers in the family offer the following special features:

Direct CAN 2.0B bus interface Direct USB 2.0 bus interface Direct LCD control interface TCP/IP interface ZigBee interface Direct motor control interface

There are many devices in the PIC18F family, and most of them are source compatible with each other. Table below gives the characteristics of some of the popular devices in this family. In this chapter, the PIC18FXX2 microcontrollers are chosen for detailed study. Most of the other microcontrollers in the family have similar architectures.

Page 33: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

Pic18 Family Architecture:As shown in Table 2.1, the PIC18FXX2 series consists of four devices. PIC18F2X2 microcontrollers are 28-pin devices, and PIC18F4X2 microcontrollers are 40-pin devices. The architectures of both groups are almost identical except that the larger devices have more I/O ports and more A/D converter channels. In this section, we shall be looking at the architectureof the PIC18F452 microcontrollers in detail. The architectures of other standard PIC18F series microcontrollers are very similar, and the knowledge gained in this section should be enough to understand the operation of other PIC18F series microcontrollers.

The pin configuration of the PIC18F452 microcontroller (DIP package) is shown in Figure. This is a 40-pin microcontroller housed in a DIL package and has a pin configuration similar to that of the popular PIC16F877.

Figure shows the internal block diagram of the PIC18F452 microcontrollers. The CPU is at the center of the diagram and consists of an 8-bit ALU, a n 8-bit working accumulator register (WREG), and a 8 × 8 hardware multiplier. The higher byte and the lower byte of a multiplication are stored in two 8-bit registers called PRODH and PRODL, respectively.

The program counter and the program memory are shown at the top left corner of the diagram. Program memory addresses consist of 21 bits and are capable of accessing 2 MB of program memory locations. PIC18F452 has only 32 KB of program memory, which requires only 15 bits; thus, the remaining six address bits are redundant and not used. A table pointer provides

Page 34: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

access to tables and to the data stored in the program memory. The program memory contains a 31-level stack, which is normally used to store the interrupt and subroutine return addresses.

The data memory can be seen at the top central part of the diagram. The data memory address bus is 12 bits wide and is capable of accessing 4 KB of data memory locations. As we shall study later, the data memory consists of the SFR and the general-purpose registers (GPR), all organized in banks.

Page 35: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock
Page 36: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

The bottom part of the diagram shows the timers/counters, capture/compare/PWM registers, USART, A/D converter, and the EEPROM data memory. PIC18F452 consists of

Four counters/timers Two capture/compare/PWM modules Two serial communication modules Eight 10-bit A/D converter channels 256-byte EEPROM

The oscillator circuit is located at the left-hand side of the diagram. This circuit consists of

PWRT OST POR WDT Brown-out reset (BOR) Low-voltage programming In-circuit debugger (ICD) PLL circuit Timing generation circuit

The PLL is new to the PIC18F series, and it provides the option of multiplying the oscillator frequency to speed up the overall operation. The WDT can be used to force a restart of the microcontroller in the event of a program crash. The ICD is useful during program development, and it can be used to return diagnostic data, including the register values, as the microcontroller is executing a program.

The I/O ports are located at the right-hand side of the diagram. PIC18F452 consists of five parallel ports named PORTA, PORTB, PORTC, PORTD, and PORTE. Most port pins have multiple functions. For example, PORTA pins can be used as either parallel I/O or analog inputs. PORTB pins can be used as either parallel I/O or interrupt inputs.

Code Memory Organization:The program memory map is shown in Figure 2.4. Each PIC18F member has a 21-bit

program counter and hence is capable of addressing 2 MB of memory space. User memory space on the PIC18F452 microcontroller is 00000H to 7FFFH. Accessing a nonexistent memory location (8000H to 1FFFFFH) will cause a read of all 0s. The reset vector where the program starts after a reset is at address 0000H. Addresses 0008H and 0018H are reserved for the vectors of high-priority and low-priority interrupts, respectively, and interrupt service routines must be written to start at one of these locations.

Page 37: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

The PIC18F microcontroller has a 31-entry stack that is used to hold the return addresses for subroutine calls and interrupt processing. The stack is not a part of the program or a data memory space. The stack is controlled by a 5-bit stack pointer, which is initialized to 00000 after a reset. During a subroutine call (or interrupt), the stack pointer is first incremented, and the memory location pointed to by the stack pointer is written using the contents of the program counter. During a return from a subroutine call (or interrupt), the memory location pointed to by the stack pointer is decremented. Program memory is addressed in bytes and instructions are store d as 2 or 4 bytes in programmemory. The least significant byte of an instruction word is always stored in an even addressof the program memory.

An instruction cycle consists of four cycles: A fetch cycle begins with the program counter incrementing in Q1. In the execution cycle, the fetched instruction is latched into the instruction register in cycle Q1. This instruction is then decoded and executed during the Q2, Q3, and Q4 cycles. A data memory location is read during Q2 and written during Q4.

Page 38: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

Data Memory Organization:The data memory map of the 18F452 microcontroller is shown in Figure below. The data

memory address bus is 12 bits, with the capability of addressing up to 4 MB. The memory in general consists of 16 banks, each of 256 bytes. PIC18F452 has 1536 bytes of data memory (6 banks × 256 bytes each) occupying the lower end of the data memory. Bank switching is done automatically when using a high-level language compiler, and thus the user need not worry about selecting memory banks during programming.

Page 39: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

The special function register (SFR) occupies the upper half of the top memory bank. SFR contains registers that control the operations of the microcontroller, such as the peripheral devices, timers/counters, A/D converter, interrupts, USART, and so on.

Input Output Ports:The parallel ports of the 18F family are very similar to those of the PIC16 series. The

number of I/O ports and port pins varies depending on the PIC18F family member used, but all versions have at least PORTA and PORTB. The pins of a port are labeled as RPn, where P is the port letter and n is the port bit number. For example, PORTA pins are labeled RA0 to RA7, PORTB pins are labeled RB0 to RB7, and so on.

When working with a port, we may want to Set port direction Set an output value Read an input value Set an output value and then read back the output value

The first three operations are the same between the PIC16 and the PIC18F series. In some applications, we may want to send a value to the port and then read back the value just sent. In the PIC16 series, there is a weakness in the port design a nd the value read from a port may be different from the value just written to it. This is because the reading is the actual port bit pin value, and this value could be changed by external devices connected to the port pin. In the PIC18F series, a latch register (e.g., LATA for PORTA) is introduced to the I/O ports to hold the actual value sent to a port pin. From the port, the latched value is read, which is not affected by any external devices.

Port-A:In PIC18F452 microcontroller, PORTA is 7 bits wide and port pins are shared with other

functions. Table 2.6 shows the PORTA pin functions.The architecture of PORTA is shown in Figure. There are three registers associated with

PORTA:

Port data register – PORTA Port direction register – TRISA Port latch register – LATA

PORTA is the name of the port data register. The TRISA register defines the direction of PORTA pins, where logic 1 in a bit position defines the pin as an input pin, and a 0 in a bit position defines it as an output pin. LATA is the output latch register, which shares the same

Page 40: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

data latch as PORTA. Writing to one is equivalent to writing to the other one as well. But reading from LATA activates the buffer at the top of the diagram, and the value held in PORTA/LATA data latch is transferred to the data bus, independent of the state of the actual output pin of the microcontroller.

Bits 0 through 3 and 5 of PORTA are also used as analog inputs. After a device reset, these pins are programmed as analog inputs, and RA4 and RA6 are confi gured as digital inputs.

To program the analog inputs as digital I/O, the ADCON1 register (A/D register) must be programmed accordingly. Writing 7 to ADCON1 configures all PORTA pins as digital I/O.

The RA4 pin is multiplexed with the Timer 0 clock input (T0CKI). This is a Schmitt trigger input and an open drain output.

Page 41: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

RA6 can be used as a general-purpose I/O pin, or as the OSC2 cl ock input, or as a clock output providing FOSC/4 clock pulses.

Port-B:In the PIC18F452 microcontroller, PORTB is an 8-bit bidirectional port shared with

interrupt pins and serial device programming pins. Table below gives the PORTB bit functions.

PORTB is controlled by registers, and they are as follows: Port data register – PORTB Port direction register – TRISB Port latch register – LATB

The general operation of PORTB is similar to that of PORTA. Figure 2.24 shows the architecture of PORTB. Each port pin has a weak internal pull-up, which can be enabled by clearing bit RBPUof register INTCON2. These pull-ups are disabled on a POR and when the port pin is configured as an output. On POR, PORTB pins are configured as digital inputs. Internal pull-ups allow input devices, such as switches, to be connected to PORTB pins without the use of external pull-up resistors. This saves cost because of the reduced component count and less wiring requirements.

Port pins RB4–RB7 can be used as interrupt on change inputs, whereby a change on any of pins 4–7 causes an interrupt flag to be set. The interrupt enable and flag bits RBIE and RBIF are in register INTCON.

Page 42: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

Port-C,D,E:In addition to PORTA and PORTB, PIC18F452 has 8-bit bidirectional ports PORTC and

PORTD, and 3-bit PORTE. Each port has its own data register (e.g., PORTC), data direction register (e.g., TRISC), and data latch register (e.g., LATC). The general operation of these ports is similar to PORTA.

In the PIC18F452 microcontroller, PORTC is multiplexed with several peripheral functions, as shown in Table 2.8. On a POR, PORTC pins are configured as digital inputs.

In the PIC18F452 microcontroller, PORTD has Schmitt Trigger input buffers. On a POR, PORTD is configured as digital inputs. PORTD can be configured as an 8-bit PSP (i.e.,

Page 43: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

microprocessor port) by setting bit 4 of the TRISE register. Table 2.9 shows functions of PORTD pins.

In the PIC18F452 microcontroller, PORTE is only 3 bits wide. As shown in Table 2.10, port pins are shared with analog inputs and parallel slave port read/write control bits. On a POR, PORTE pins are configured as analog inputs, and register ADCON1 must be programmed to change these pins to digital I/O.

Page 44: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

Serial Communication (USART):Hardware USART functions enable RS232 type serial communication to be implemented

using the hardware USART module of the microcontroller. In general, hardware-based USART can give faster and more reliable communication. In addition, the processor can

carry out other tasks while the USART is handling the serial communication.C18 compiler provides the USART functions given in Table 4.22 (in microcontrollers

with more than one USART a number is added to the end of these functions to identify the USARTs). The header file “usart.h” must be defined at the beginning of a program using these functions.

The definition of these functions is given in the below table.

BusyUSART:This function returns a “1” if the USART transmitter is busy transmitting a character. This function should be checked before sending a new byte to the USART. The function returns a “0” if the USART transmitter is idle.

CloseUSART: This function disables the USART.DataRdyUSART: This function returns a “1” if data is available in the USART read

buffer. A “0” indicates that data is not available in the read buffer.getcUSART: This function reads a byte from the USART buffer. An example is given

below:

int result;result = getcUSART( );

getsUSART: This function reads a string of characters from the USART. This function waits and reads a specified number of characters. There is no timeout and the program will wait forever if the specified numbers of characters are not received. An example is given below to show how this function can be used:

char buff[20];

Page 45: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

getsUSART(buff, 6); // Wait to receive 6 characters

OpenUSART: This function configures the USART. Two arguments are required: a configuration argument called config and an integer called spbrg, which specifies the value to be written to the baud rate generator register to determine the baud rate.config

Interrupt on transmission:USART_TX_INT_ON Transmit interrupt ONUSART_TX_INT_OFF Transmit interrupt OFF

Interrupt on reception:USART_RX_INT_ON Receive interrupt ONUSART_RX_INT_OFF Receive interrupt OFF

USART mode:USART_ASYNCH_MODE Asynchronous modeUSART_SYNCH_MODE Synchronous mode

Transmission width:`USART_EIGHT_BIT 8-bit transmit/receiveUSART_NINE_BIT 9-bit transmit/receive

Slave/Master selectUSART_SYNC_SLAVE Synchronous slaveUSART_SYNCH+MASTER Synchronous master

Reception mode:USART_SINGLE_RX Single receptionUSART_CONT_RX Continuous reception

Baud rate:USART_BRGH_HIGH High baud rateUSART_BRGH_LOW Low baud rate

spbrg:

This is the value written onto the baud rate generator register to define the baud rate to be used. The formula for the baud rate is as follows:

For High Speed (USART_BRGH_HIGH),Baud = FOSC/[16 * (spbrg + 1)]

or

spbrg = FOSC/(16 * baud) − 1

Page 46: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

and

For Low Speed (USART_BRGH_LOW),Baud = FOSC/[16 * (spbrg + 1)]

or

spbrg = FOSC/(64 * baud) −1,where FOSC is the microcontroller clock frequency.putcUSART: This function sends a byte to USART.putsUSART: This function sends a string of characters to USART from the data

memory. An example is given below:

putrsUSART("My Computer");putrsUSART: This function sends a string of characters to USART from the program

memory.baudUSART: This function sets the baud rate configuration bits for enhance d USART

operation. The valid arguments can be formed from bitwise AND of the following definitions:

Clock idle state:BAUD_IDLE_CLK_HIGH Clock idle state is high levelBAUD_IDLE_CLK_LOW Clock idle state is low level

Baud rate generation:BAUD_16_BIT_RATE 16-bit baud rate generationBAUD_8_BIT_RATE 8-bit baud rate generation

RX pin monitoring:BAUD_WAKEUP_ON RX pin monitoredBAUD_WAKEUP_OFF RX pin not monitored

Baud rate measurement:BAUD_AUTO_ON Autobaud rate measurement enabledBAUD_AUTO_OFF Autobaud rate measurement disabled

Page 47: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

MPLABXThere are several C compilers on the market for the PIC18 series of microcontrollers. Most of the features of these compilers are similar, and they can all be used to develop C-based high-level programs for the PIC18 series of microcontrollers.Some of the popular C compilers used in the development of commercial, industrial, and edu-cational PIC18 microcontroller applications are as follows: • mikroC C compiler • PICC18 C compiler • CCS C compiler • MPLAB C18 C compiler mikroC C compiler has been developed by MikroElektronika( Web site: http://www.mikroe.com) and is one of the easy-to-learn compilers with rich resources, such as a large number of library functions and an integrated development environment with built-in simulator and an in-circuit-debugger (e.g., mikroICD). A demo version of the compiler with a 2K-program limit is available from MikroElektronika.PICC18 C compiler is another popular C compiler developed by Hi-Tech Software( Web site: http://www.htsoft.com). This compiler has two versions: the standard compiler and the professional version. A powerful simulator and an integrated development environment ( Hi-Tide) are provided by the company. PICC18 is supported by the Proteus simulator (http://www.labcenter.co.uk), whichcan be used to simulate PIC microcontroller-based systems. A limited-period demo version of this compiler is available from the developer’s Web site.CCS C compiler has been developed by Custom Computer Systems Inc.( Web site: http://www.ccsinfo.com). The company provides a limited-period demo version of their compiler. CCS compiler provides a large number of built-in functions and supports an in-circuit-debugger (e.g., ICD-U40), which aids greatly in the development of PIC18 microcontroller-based systems.MPLAB C18 C compiler is a product of Microchip Inc. ( Web site: http://www .microchip.com). An evaluation version with limited functionality is available from the Microchip Web site. MPLAB C18 includes a simulator and supports hardware and software development tools such as in-circuit-emulators (e.g., ICE2000) and in-circuit-debuggers (e.g., ICD2 and ICD3). In this book, we will be using the MPLAB C18 compiler for all the projects. MPLaB C18 Compiler

Page 48: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

MPLAB C18 compiler (or the C18 compiler) is one of the mostpopular C compilers available for thePIC18 series of microcontrollers. This compiler has been developed by Microchip Inc. An evaluation version (student version) of the compiler is available from the Microchip Web site free of charge. This evaluation version includes all functionality of the full version of the compiler for the first 60 days. However, some optimization routines are disabled after 60 days, and PIC18 extended mode (extended instruction set and indexed with literal offset addressing) is not supported after 60 days.MPLAB C18 is a cross compiler, where programs are developed on a PC and are then loaded to the memory of the target microcontroller using a suitable programming device.The installation and use of the MPLAB C18 compiler and detailsof programming using the compiler are given in this chapter.

Page 49: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

CHAPTER #3IMPLEMENTATION

TOUCH DISPLAY OPERATIONA resistive touch screen is constructed with two transparent layers coated with a conductive materialstacked on top of each other. When pressure is applied by a finger or a stylus on the screen, the top layer makes contact with the lower layer. When a voltage is applied across one of the layers, a voltage divider is created. The coordinates of a touch can be found by applying a voltage across one layer in the Ydirection and reading the voltage created by the voltage divider to find the Y coordinate, and then applying a voltage across the other layer in the X direction and reading the voltage created by the voltage divider to find the X coordinate.

Detecting a TouchTo know if the coordinate readings are valid, there must be a way to detect whether the screen is being touched or not. This can be done by applying a positive voltage (VCC) to Y+ through a pullup resistor and applying ground to X–. The pullup resistor must be significantly larger than the total resistance of the touch screen, which is usually a few hundred ohms. When there is no touch, Y+ is pulled up to the positive voltage. When there is a touch, Y+ is pulled down to ground as shown in Figure 1. This voltage-level change can be used to generate a pin-change interrupt.

Page 50: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

TOUCH SCREEN READINGReading a 4-Wire ScreenA 4-wire resistive touch screen is constructed as shown in Figure 2.

The x and y coordinates of a touch on a 4-wire touch screen can be read in two steps. First, Y+ is driven high, Y– is driven to ground, and the voltage at X+ is measured. The ratio of this measured voltage to the drive voltage applied is equal to the ratio of the y coordinate to the height of the touch screen. The y coordinate can be calculated as shown in Figure 3. The x coordinate can be similarly obtained by driving X+ high, driving X– to ground, and measuring the voltage at Y+. The ratio of this measured voltage to the drive voltage applied is equal to the ratio of the x coordinate to the width of the touch screen. This measurement scheme is shown in Figure 3.

Page 51: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

Reading an 8-Wire ScreenAn 8-wire resistive touch screen is constructed as shown in Figure 4.

In comparison to a 4-wire touch screen, an 8-wire touch screen adds sense wires to the end of each of the conductive bars. This allows any voltage offset created by the wiring or drive circuitry to be calibrated out during operation. An 8-wire touch screen is calibrated by measuring voltage extremes on either coordinate. First, Y+

Page 52: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

drive is driven high and Y– drive is driven low. The corresponding voltages measured at Y+ sense and Y– sense are denoted VYmax and VYmin. A similar procedure yields VXmax and VXmin. These are the maximum and minimum possible voltages across each coordinate.The coordinates of a touch on an 8-wire touch screen can be read by first driving Y+ drive high, driving Y–drive to ground, and reading the voltage at X+ sense. Using the maximum and minimum results obtained during calibration, the y coordinate can be calculated as shown in the equations in Figure 5. The x coordinate can be obtained by driving X+ drive high, driving X– drive to ground, and reading the voltage at Y+ sense. This process is shown in Figure 5.

Page 53: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

Chapter # 4APPLICATIONS

Security system Robotics have been a staple of advanced manufacturing for over half a century. As robots and their peripheral equipment become more sophisticated, reliable and miniaturized, these systems are increasingly being utilized for military and law enforcement purposes.

“Military and battlefield applications continue to grow at an accelerated pace due to demand fueled by government investment. Over the past decade, we have seen increasing levels of investment in autonomous vehicles used for surveillance and security,” says Rush LaSelle, Vice President and General Manager with Adept Technology Inc. (Pleasanton, California) “Applications range from monitoring perimeters of secured areas such as airports to acting as a night watchman.”

Robots go to WarMobile robotics play an increasingly important role in military matters, from patrol to dealing with potential explosives. “With suitable sensors and cameras to perform different missions, mobile robots are operated remotely for reconnaissance patrol and relay back video images to an operator,” says Dr. Andrew Goldenberg, PhD, Chief Executive Officer and President of Engineering Services Inc. (ESI, Toronto Ontario, Canada) “Robots can neutralize suspicious objects that may explode. The platform has a robot arm to pick up explosives or suspected hazards in military or civilian settings.”

Goldenberg goes on to say, “The mobile robotic platform is mounted on a rectangular box with electronic equipment. The platform moves on wheels or tracks, or both, and is usually battery-powered. Communication equipment

Page 54: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

and sensors can detect images, sounds, gases and other hazards. The communication systems read sensors and relay that information to the

operator.”

Robotics help meet challenges posed by the specter of urban terrorism. “Instead of having people get close to hazards such as unattended objects or car bombs, robots are used. If an operator concludes a dangerous object might explode, the robot could neutralize that object by shooting to detonate it,” Goldenberg says. “Mobile robots detect and explode in-ground mines or improvised explosive devices.” These same mobile robotic systems are used for neutralizing or exploding forgotten ordnance and mines after conflicts cease.

Autonomy or ControlThe level of autonomy separates industrial robotics from their battlefield counterparts. “Mobile robotic platforms are operated remotely and do not have the autonomy of industrial robots. Security robotic systems are under the total control of the operator, typically military personnel,” says Goldenberg. “Security robots have not yet been made autonomous, given the purpose of the vehicles, especially if armed.” Due to a handful of instances of friendly fire, the trend has been against providing security robot systems the autonomy of their industrial equivalent, Goldenbergre calls.Consequently, operator fatigue results from people directing mobile robotic systems denied industrial-strength autonomy, says Goldenberg. “I have heard about concerns with operators of military robots being over-loaded and

Page 55: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

fatigued while controlling the robot. The robot is given some intelligence, but that intelligence is limited.”

The limited intelligence extends to networking the mobile robots with global positioning satellites. (GPS) Again Andrew Goldenberg: “Mobile robotic systems make use of GPS to navigate. The robot will decide how it will get to its destination and is able to detect a target and the rest of the surrounding environment.”Obstacle CourseMobile robotic platforms used in national security applications must move within unstructured environments. “The ability to operate over challenging terrain and the ability to autonomously navigate in unstructured environments are areas of focus,” LaSelle points out. “The

migration of automated systems from factory lines to moving freely throughout facilities and beyond has created demands on system design

Page 56: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

INDUSTRIES AND MINING ENGINEERINGRobots will be doing jobs like laying explosives, goingunderground after blasting to stabilize a mine roof or mining in areas where it is impossible for humans to work..Examples of the trend to mining automation include:Tele-operated and automated load-haul-dump trucks that self-navigate through tunnels, clearing the walls by centimetersThe worlds largest robot, a 3500 tonne coal drag linefeaturing automated loading and unloading.A robot device for drilling and bolting mine roofs to stabilize them after blasting.A pilot less burrowing machine for mining in flooded grave ls and sands underground, where human operators cannot go.A robotic drilling and blasting device for inducing controlled caving.Fig.1. A few mining vehicle-related a

Page 57: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

R o b o t i c technology offers significant potential to improve the difficulty of the rescue workers by reducing exposures to hazardous conditions. A robotic vehicle can explore the mine and provide valuable information to the teams to assist in planning and implementing search and rescue operations. Industrial robots have been made a significant contribution toward automating the manufacturing processes. The efficient use of robots shows productivity increase, p r o d u c t i o n c o s t r e d u c t i o n , a n d p r o d u c t q u a l i t y improvement. However, most robots currently in use perform simple repetitive jobs, such as pick-and-place, machine loading and unloading, spry painting and spot welding. A basic approach has been assumed for the testing of the performance of the semi-autonomous robot. It has been seen that this performs well under the simple a s s u m p t i o n s o f t h e c o n d i t i o n s e s t a b l i s h e d a t t h e underground mining excavation sites. The recent fatality statistics for both underground as well as open cast mining operations worldwide point out that the most serious risks to the personnel are from different mining condition especially that from the

Page 58: Web viewCommands Transmission ... The least significant byte of an instruction word is always stored in an even ... or as the OSC2 cl ock

inaccessible areas of the mines  where  regular  systematic  monitoring and maintenance operations are difficult and hence, none of these operations are not carried out on a systematic basis. It is true that there is no control of the human operators on such unwanted happenings. In general, underground and opencast mining conditions are a cooperative enterprise of powerful, mobile equipment and the workers who operate it. If mining equipment could be automated to function without a worker’s full attention ,the mining industry could enhance productivity, access unworkable mineral seams, and reduce human exposure to the inhospitable environment of dust, noise, gas, water, moving equipment and roof fall. The critical missing link to enable mine automation is the capability of equipment to estimate its position relative to its surrounding. The lack of accurate maps of inactive, underground mines poses a serious threat to public safety. According to a recent study tens o f thousands, perhaps even hundreds o f   thousands, of abandoned mines exist today in the United States. Not even the U.S. Bureau of Mines knows the exact number, because federal recording of mining claims was not required until 1976. Hazardous operating conditions and difficult access routes suggest that robotic exploration and mapping of abandoned mines may be a viable option. For maintain the working environment safety, it is now essential to implemented robotic systems in underground