Section 2 - Background Therory PDF Print E-mail
Written by Michael   
Thursday, 11 June 2009 15:31

2.0 Background Theory

This project builds on a large amount of previous work and makes use of various pieces of hardware which are readily available, saving development time. Various techniques have been developed in many areas to achieve common goals. All these are discussed here to aid the reader in understanding this project.

2.1 Previous Work

There has been much previous work carried out in the area relating to a XY scanning communications channel. An honours project carried out by Boasman, N (1999) titled “A Laser Scanning Communications Link” is directly relevant and it is what the current project builds on.

The focus of Boasman’s work was on developing a laser based duplex communications link capable of scanning a specified area and achieving mutual lock on, between two identical, stationary scanning units. The project was designed to be developed further with the end goal of an underwater link for communication between a submerged vehicle and a vessel on the surface.

The project culminated in a successful prototype being built to enable a transmitter to locate the receiver and also modulate data across the link. Software was also developed in an earlier version of Borland C++ builder. This was achieved by using a class 3A visible laser with built in internal modulation capability. The laser was scanned across the area using two small galvanometer motors, which had miniature mirrors mounted on the end of each shaft.

Galvanometer Scanner

Figure 6 - Galvanometer scanner

 

Galvanometers can be considered to be like a very simple motor. The principle of how they work is similar to ammeters. A coil mounted on the shaft is free to rotate, suspended between a permanent magnet[ii]. When voltage is applied to the coil the shaft rotates till the field’s line up, giving the rotational motion. The galvanometers used had a deflection of around 40˚.

Boasman’s technique for achieving lock on was simple, and was itself based on earlier work by Wade, S (1991) and Tennant, A (1991) which centres on an underwater laser communications link between submerged ROVs. Both ends of the link incorporate a laser transmitter/ modulator and a receiver. Considering just one stationary receiver at time t=0; begins to modulate its current co-ordinate position onto a laser. The laser is then scanned across the area. Providing that the second unit is within the area, it will receive at some point in time unit ones co-ordinate position, Unit 2 now moves its laser to this position and modulates its current position onto the beam. Unit 1 receives unit 2’s position and moves its laser back to this position. The two units should now be locked on and the link is now active.

Further work by Mew, S (1996) was completed in tracking a moving laser source using a quadrant photo-detector. The system moved the receiver so that the laser was always locked on and in the centre of the receiver.

Types of Quadrant Photo Detector

Figure 7 - Types of Quadrant Photo detectors

 

Quadrant Photo Detectors come in two different varieties. These are shown above, the grey area is the active area and when light falls on this section, the output will chance either in voltage or resistance. The idea behind the work is that if the laser is centred in the middle and moves to either side, the receiver detects this and corrects the error by moving in the opposite direction till the beam is in the middle again. A major drawback with quadrant photo detectors is that they tend to be extremely small and also very expensive.


2.2 Hardware

2.2.1 PIC Microcontroller

The term PIC actually refers to a general type of chip known as a Programmable Integrated Circuit, which is a type of chip used to build re-programmable or re-configurable digital circuits. However it also confusingly refers to a type of microcontroller produced by Microchip. The second definition is the one that is used throughout this project[iii].

A microcontroller (uC) is a specific version of a Programmable Integrated Circuit, which can be configured by programming it with specific instructions to perform one by one on digital data. It is essentially a miniature computer. The microcontrollers produced by Microchip, are all Harvard Architecture, meaning they have separate memory and pathways for data and instructions. Instructions are the specific commands you give it to perform on the data. Microcontrollers are found in many items located around the home including TV’s microwaves and remote controls.

Microcontroller manufacturers produce literally thousands of different microcontrollers, all with different processing speed’s, instruction sets, data memory size, program memory size and different add on peripherals. The PIC microcontroller used in this project is a variant known as the PIC16F877A, used due to its low cost and also due to the author having a great deal of prior experience with this variant.

The PIC16F877A, has a reduced instruction set meaning the instructions are all very basic in nature but quick to execute, allowing simple tasks to by accomplished in the minimum amount of time. The PIC also has 14 Kbytes of program memory, 368 Bytes of RAM, 33 I/O pins and supports a clock speed of up to 20MHz. It also comes with built in hardware subsystems such as analogue comparators, I2C Bus and a RS232 UART[iv].

To operate, the PIC requires two things, a regulated power supply and a clock. Power supply needs to be as noise free and have no spikes or dips as this could cause an instruction to be missed. The clock is required to time everything and synchronise the PICs operation. Power can be supplied via a 7805 power regulator which regulates a voltage to 5V. Clocks can come from a number of sources; the easiest is to use a dedicated IC. The dedicated IC simply requires a power signal and an enable line which will then enable it to output a continuous signal at the specified frequency. These are much easier to use than oscillators and resonators.


2.2.2 PIC Brick

The PIC brick is a name given to a Microcontroller system used by the EPS department. It contains a PIC microcontroller mounted within a plastic box along with an array of pins for all the inputs and outputs. There are a number of versions available using different microcontrollers including the 16F877A & 18F452 variants.

The unit also contains all the inbuilt circuitry to power the circuit (0.5A power regulator) and generate the 20MHz clock signal. It also houses a MAX232 transceiver chip and an RS232 socket to facilitate serial programming. The PICs contain the TinyBootloader program enabling programming from computers in laboratory 1.81 and any other PC containing the TinyBootloader downloader program.

USB Brick Unit

Figure 8 - USB Brick Unit

 

2.2.3 USB Brick

 

The USB brick is again a name given to a piece of hardware used by the EPS department. It essentially a USB I/O chip mounted within a robust plastic enclosure.

At the heart of the unit is a chip by Active Wire Inc, with 15 digital outputs. The chip decodes instructions sent to it from the USB connection found on the majority of new computers, and every computer within the EPS department. The commands sent to it specify what to output on the outputs. It is essentially a USB to Digital I/O convertor.

In Order to write to the USB connection a specific driver is needed. This driver can then be accessed in the majority of programming languages and environments that support DLL and OCX files.

2.2.4 FPGA

 

An FPGA is a Field Programmable Gate Array[v], which is a type of programmable integrated circuit known as a Programmable Logic Controller (PLC). It is very similar to a microcontroller in that it can be used to perform desired actions, on digital data or signals.

The FPGA differs from a microcontroller however because it is basically a massive array of the basic logic functions (AND, OR, NOT) connected together into an array with programmable fuses. By programming the board you set the individual fuses and these control which block is connected to which.

Each of the AND, OR & NOT functions can then be combined into what’s known as logic blocks, and these can be combined into flip-flops and other combinational digital logic functions. These can then also be combined into memory registers to store data and state machines, which can perform actions one by one like a microcontroller.

The key operational difference between a microcontroller and a FPGA, is that a microcontroller executes one program line by line, whereas a FPGA can perform thousands of complex mathematical tasks as the same time as long as there is enough logic blocks available.

One of the FPGA’s available with the Heriot-Watt EPS department is the Altera Cyclone II, with 18,752[vi] logic elements. This is mounted on a development board with all the control circuitry for programming and power built in. It also comes with a UART chip and approximately 100 I/O pins. The FPGA itself has 315 pins however some of these are used for clock signals, buttons, LEDs and displays built into the development board.

Cyclone II Development Board

Figure 9 - Cyclone II Development Board

 

2.2.5 Servo Motors

 

The extremely common DC motor is found in many devices. When a voltage is applied to its terminals, it will spin round continuously in one direction. A servo motor is a variation on the DC motor, fitted with a gearbox, a potentiometer and a feedback controller.

Dissasembled Servo Motor

Figure 10 - Disassembled Servo Motor

 

The purpose of the gear box is to slow down the output of the DC motor, since motors are generally quite fast. The potentiometer is a small sensor that is mounted on the output shaft of the motor. As the motor shaft turns, the potentiometer turns telling the feedback controller its current position. The job of the feedback controller is to make the motor spin in the right direction until the shaft is in the desired position. The desired position is taken as a specific angle of the output shaft.

Servo motors therefore do not turn continuously, rather they move to a set angular position as determined by a stream of pulses on the control line. Typically servos can move between ±90˚ although some only move ±45˚. They have a good holding ability and are reasonably accurate and fast.

Servos typically have three wires coming from them, white, red and black. Red is the positive line of the power supply, which requires around 5V to operate. Black is connected to the ground line of the power supply. The final, white wire, is the signal line. Different manufactures sometimes use different colours for the wires, these colours refer to Futuba servos.

Servo Timing

Figure 11 - Servo Timing

The signal line of the servo is the one that tells the controller where about to position the servo. To do this it requires a specific waveform on the line. A positive pulse on the line repeated approximately every 20ms controls the servo. The pulse width should be between 1ms and 2ms, with 1ms representing -45˚, 1.5ms representing 0˚ and 2ms representing +45˚

2.2.6 Optical Components.

 

The most common optoelectronic is the semiconductor light emitting diode, or LED. The advantages of LEDs are that they are both small, cheap and are available in many different colours and sizes. As the light exits the LED it begins to diverge, typical LED’s have a viewing angle of around 60˚ and directional LEDs around 20˚. Due to this divergence it can be hard to detect at a distance.

LEDs are relatively safe as a component as they are generally not that powerful. In recent years there has been a lot of development in high power LEDs in both blue and white. This has led to a greater usage of LEDs in lighting products and products designed to replace traditional light sources. Although some countries like the USA consider all LED’s to be safe, in the UK they have to be tested by the manufacturers to the same regulations as lasers[vii]. Although in practical terms most if not all fall into the lowest, intrinsically safe category, unless they are a specifically high power LED.

A laser is a semiconductor device that produces light by the stimulated emission of radiation[viii]. Lasers create a very pure form of light often only 1 wavelength. The light produced is coherent i.e. light is in phase and the beam is extremely narrow. It is possible to get lasers that have a beam divergence of 0.2˚[ix], making them good for detecting at a distance. A drawback with lasers is that they are more powerful than an equivalent LED and can cause eye damage when the beam is focused by the retina into an even smaller spot. This can be caused by direct exposure or slight reflections depending on the laser safety class.

The class of a laser describes its power and what safety precautions should be taken[x]. These are:

  • Class I/1 is inherently safe, usually because the light is contained in an enclosure.
  • Class II/2 is safe during normal use; the blink reflex of the eye will prevent damage. Usually up to 1mW power, for example laser pointers.
  • Class IIIa/3R lasers are usually up to 5mW and involve a small risk of eye damage within the time of the blink reflex. Staring into such a beam for several seconds is likely to cause (minor) eye damage.
  • Class IIIb/3B can cause immediate severe eye damage upon exposure. Usually lasers up to 500mW, such as those in CD and DVD burners.
  • Class IV/4 lasers can burn skin, and in some cases, even scattered light can cause eye and/or skin damage. Many industrial and scientific lasers are in this class.

Light is simply electromagnetic waves, the colour is dictated by the frequency of the waves. Both Lasers and LED’s come in many different colours from the visible part of the electromagnetic spectrum and also from the ultra-violet (UV) and infra red (IR) part of the spectrum. Both IR and UV are invisible to the human eye although both can be detected by cameras and other light detectors.

Electromagnetic Spectrum

Figure 12 - Electromagnetic Spectrum

The visible part of the spectrum is in the middle, and goes from violet to red. Infrared literally means in front of red, infra meaning below in Latin[xi], and ultraviolet is beyond violet. IR radiation in the form of heat is emitted from every heat source. The sun also outputs IR radiation. Because of this IR can be used for thermal imaging cameras or heat detection. UV radiation is also emitted from the sun and can be detected in electric arcs. UV light can cause chemical reactions and is the principal cause of sunburn to human tissue.

2.2.7 Wii Remote Control.

 

The Nintendo Wii gaming console is one of the most popular consoles of modern time, outselling at times, more powerful and advanced machines[xii]. The reason is due to its innovative human computer interface. Its main control the Wii Remote assumes a one-handed remote control-based design instead of the traditional gamepad controllers of previous gaming consoles. The remote is equipped with a wireless Bluetooth connection, 3 axis ±3g accelerometer and a small 1024x768 pixel infra red camera with inbuilt image processor.

The chip tracks up to 4 IR LEDs in view of the camera at up to 100 times a second. It is also fitted with an I2C bus to communicate with the rest of the remote. The Wii also comes with a “Sensor Bar” to be used in conjunction with the Wii remote. The sensor bar is fitted with a group of IR LEDs mounted at each end of the remote. By triangulation the Wii can then determine the distance of the remote from the TV and more importantly the direction it is pointing.

Wii IR Camera & Object Tracker

Figure 13 - Wii IR Camera & Object Tracker

The IR camera chip itself incorporates an I2C bus for communication with the main control chip. There are examples on the internet of using the I2C connection direct from the chip to read the data such as LED position (See Appendix D). The Bluetooth connection on the Wii remote uses a HID driver to communicate with the Wii, meaning it is possible to connect the remote to a PC. There has been C# DLL libraries developed for reading the position values from the chip via Bluetooth[xiii].

There has been a great deal of development done by third party users in creating software to access and use the data that comes from the remote control. University researchers such as Johnny Chung Lee have developed ways of using the chip to provide human computer interaction in a much more intuitive way, such as interactive projector based whiteboards[xiv].

2.3 Standards

Standards or the process of standardization is necessary to ensure equipment from different manufactures can communicate and work with other pieces of equipment. Some of the standards used in this project are described below.

2.3.1 RS232

RS232 is an equipment communications standard, describing the method and physical characteristics of a communications link between electrical equipment. In a basic form it defines an asynchronous serial data channel, where data is sent one bit at a time along a transmit or receive line[xv]. RS232 or Serial Port as it is sometimes known is fitted to the majority of personal computers available. It is also commonly used to connect controllers of industrial machinery together or to a main controller. RS232 is simple to implement in a research environment as is incorporated into most microcontrollers and FPGA’s that are currently available. If a dedicated controller is not implemented, it can be implemented with minimal coding and common driver chips.

The standard defines several connections however the most common is known as the D-sub miniature 9 or DB9 connector. This has 9 pins. RS232 uses various handshake lines for the transfer of data, however only 3 are needed in the most basic implementation ground receive and transmit.

RS232 Waveform

Figure 14 - RS232 Waveform

 

The RS232 protocol defines a 0 as a voltage between +3V and +15V, and a 1 as a voltage between -3V and -15V. In order for a microcontroller to drive these voltages, a transceiver chip such as the maxim 232 to convert the TTL 0-5V to ±12V. Data is transferred with a start bit (1) and ends with a stop bit (0). A parity bit can be included although it is often not. Data is transferred in 8 or 9 bit chunks, typically as ASCII characters although this is not part of the standard. There are different speeds data is transferred at, known as the baud rate. Both receiver and transmitter must know the speed of the link, the number of data bits and whether parity is added in order to be able to use the link.


2.3.2 Phillips RC5

 

In any communication system it is necessary to modulate the signal in order to make it detectable and make it stand out against the noise. Similarly to serial communication, there is defined standards for transmitting data over infrared links. One of the most common is called RC5[xvi], which was developed by Phillips. RC5 is extremely common and it is likely to be implemented in many remote controls which you may find around your house.

36kHz Manchester Coded Signal

Figure 15 - 36kHz Manchester coded signal

 

RC5 Data bits use a modulation technique known as Manchester or Bi-Phase coding, where each bit state is defined by a transition. In RC5 a 0 is defined as a HIGH to LOW transition and a 1 is a LOW to HIGH transition. The signal is modulated from baseband to a carrier of 36kHz, meaning the HIGH bits are actually being pulsed on and off at 36kHz.

RC5 Command

Figure 16 - RC5 Command

 

This system allows for a data length of 11 bits. Two start bits (1’s) are used to signify the start of a transmission and to allow the receiver to adjust its automatic gain control, minimising transmission errors. The toggle bit (T) is defined so that a receiver such as a TV can distinguish if a button is being held down or released and pressed again, implementation of this is down to the receiver. Five bits are given for the address which is allocated to individual devices, so that a TV doesn’t react to a command meant for another piece of equipment. The command instruction specifies the actual action to perform.

An infrared link is extremely cheap to implement due to the low cost of the components. All that is required is an IR LED, a driver circuit and a modulator or transmitter. Typical IR LEDs draw more current than a typical visible LED, some as high as 1A and this is often much more than a microcontroller or FPGA can output.

In order to decode and receive an RC5 modulated signal would require several components such as a receiver, demodulator and a filter. However many companies manufacture complete integrated circuits designed to do just this. One such chip is the HIM602 from Hero.

36kHz IR Demodulator IC

Figure 17 - 36kHz IR Demodulator IC

 

This chip has all the built in systems and hardware to extract the signal being sent from the transmitter and output a baseband signal. All the chip requires is a 5V power connection. Bits appear inverted at the output, so when nothing is being received 5V will be output. When a 1 is being received, output will be low (0V).

2.4 Host Software

The Software used in this project within a Microsoft Windows PC environment is discussed below.

2.4.1 Borland C++ Builder

Borland C++ builder (BCB) is a rapid application development environment used for programming in the C++ programming language. Programs written are compiled into machine readable code. The environment enables you to develop windows based applications using a graphical user interface (GUI), making use of a wealth of windows libraries for creating buttons, text boxes and many more. The GUI interface is what everyone is familiar with that uses a modern version of Windows.

The less familiar version is the console program. Every program that runs is essentially a console program, except that instead of creating a windows form with controls, the program displays a command line window which displays output from the program and allows input.

C++ is an extremely popular programming language and there are plenty of sources of information regarding the program in books and many websites. Examples of code are easy to come by and there is support within the language for using serial ports and accessing nearly all of the hardware found within a modern PC.

2.4.2 Matlab

Matlab is a high level programming language and development environment for running Matlab programs. The Matlab language is designed for performing complex mathematical calculations quickly and easily. Matlab is designed to be used for application specific tasks and comes with a number of optional toolboxes containing specific functions to perform. It is used heavily in the engineering world and also by many industries from financial to biological computing. Two of the toolboxes used in this project are the image acquisition and image processing toolboxes.

The main defining characteristic of Matlab is that the main data type is the matrix. A matrix can be a single value, a row of values, a table of values or a 3D table of values or greater. Matlab is very user friendly and has a similar syntax to many other high level programming languages such as C. A program written is run line by line and not compiled like other languages. Programs can be exported into other languages or made into a standalone program with or without a GUI. Importantly Matlab provides the ability to use the serial port and imaging devices installed on the PC.

2.5 Embedded Software

Embedded software is software that is written for special purpose hardware. Its function is not information technology; instead it is used for controlling machines or electronics that may interact with the real world.

2.5.1 Verilog

Verilog is a hardware description language (HDL) and is used to physically define the inter-component connections between logic blocks built into a FPGA. The concept of a FPGA is discussed in section 2.2.2 FPGA.

Verilog like other languages uses a similar syntax common to most high level languages. The key difference is the time dependence and multiple execution paths. Systems are designed in modules, with each module having specified inputs, outputs and possible synchronising signals. These modules are then synthesised into a netlist of connections between discreet components (AND, OR, NOT ect) which can be programmed onto a FPGA or PLC.

Each manufacturer of logic hardware will typically provide a development environment for programming their chips. In the case of Altera (Manufacturers of the Cyclone II FPGA) the software suite known as Quartus is provided.


2.5.2 Assembly

An assembly language is a low-level language for programming computers and embedded microcontrollers. It uses a symbolic representation of the numeric machine codes and other constants needed to program a particular CPU architecture. This representation is usually defined by the hardware manufacturer, and is based on abbreviations or commands that help the programmer remember individual instructions, registers, etc. An assembly language is therefore specific to a certain physical computer architecture in contrast to most high-level languages, which are usually portable between individual systems.

Due to the low level nature of the language, all commands represent specific calculations to perform e.g. add 1 to the working register, or jump to a specific address in the program memory. Typically assembly languages are reduced instruction sets meaning simple programs can be designed quickly. More complex programs may require a program to be written in a higher level language and then translated into assembly language.

A program known as an assembler assembles the program into machine readable code for direct programming to a microcontroller. The Assembler program commonly used for assembling programs for a Microchip PIC microcontroller is Microchips MPLAB. MPLAB is an integrated development environment (IDE) providing the ability to compile assembly programs for PICs and also simulation of the internal operation of the PIC microcontroller running a program.

Once the program has been written and assembled, it needs to be downloaded to the hardware. This is performed using a Bootloader program which is installed on the PIC. This runs every time the PIC is reset and it allows a program to be downloaded over the TxD line of the PIC. A common Bootloader is the TinyBootloader[xvii].

Rather than programming the PIC (in circuit) to verify the correct operation, it is possible to simulate a microcontroller program within a circuit with ISIS from Proteus. This is an industry standard SPICE package for simulating circuits; however it also comes with plug-ins to enable the simulation of time dependant microcontroller programs which are not able to be simulated in other SPICE packages. This has the advantage that programs can be simulated and problems solved without having to waste time programming physical hardware.



Last Updated on Friday, 17 July 2009 20:28
 
User Rating: / 1
PoorBest      
Copyright © 2012 Michael-Jones.name. All Rights Reserved.