Professional Documents
Culture Documents
High Level Design:: ∇ × ∇ × E=−μ d (∇× E) dt
High Level Design:: ∇ × ∇ × E=−μ d (∇× E) dt
High Level Design:: ∇ × ∇ × E=−μ d (∇× E) dt
INTRODUCTION
When we were little, remote controllable toys such as RC car always fascinated
us. The idea of controlling a moving object from distance had been fabulous for us.
Even more, controlling an object in the air would have been even better. The purpose of
our project is to build a helium lifted airship with propellers for controlling motion that
is controllable from distance by use of radiofrequency communication. First, we started
by building building-blocks of the whole program simultaneously building the
hardware block necessary to test the program blocks. After building the sub-programs
(motor control, radiofrequency transmission and reception, analog to digital
conversion), we assembled all the subprogram. Our major difficulty was due to the fact
that we overestimated the lifting power of helium. Thus we had to reduce weight
radically to try to lift up our ship.
The main idea of the airship is that the helium balloons are not capable of lifting
the motor/MCU module just by little bit. Therefore, when the lifting motors are turned
on, the thrust from the two motors are enough to generating enough lifting force to
bring up the airship. In addition, there are two motors that put thrust in the sideway.
By changing the ratio of speed between the two side motors, the airship can rotate
either left or right. These lift motors and directional motors enable the three
dimensional control over the airship.
d (∇× E )
∇ × ∇ × E=−μ ………. (1.1)
dt
1.3 THEORY:
For the wireless control, a radio frequency (RF) transceiver was implemented. The
operation of such transceiver is governed by the antenna theory which is described
briefly in this section.
Recalling two of the Maxwell’s equations:
2
dH dE
∇ × E=−μ And ∇ × H=J + ε …………(1.2)
dt dt
dA
[
∇ × E+
dt ]
=0 …………………………(1.4)
dA
E+ E+ =−∇ φ ………...............(1.5)
dt
3
G ( θ )= sin 2 θ …………(1.6)
2
The pre-factor is rather less of importance; rather, what is important there is that
the angle has to be 90 degrees in order for the maximum gain, and there for alignments
of the transmitter antenna and the receiver antenna become important.
The quarter wave antenna has a single wire in one end but it behaves as a dipole
antenna with the imaginary antenna part on the other end. This in effect behaves as a
half-wave dipole antenna with the half the power. For the quarter wave antenna, it is
ok to have the antenna length to be the multiples of the quarter of the wavelength used
for the wireless communication. However, multiple of a fraction of the quarter
wavelength could bring destructive effect to reduce the transmission efficiency of the
transceiver.
Helium Lift Force:
Helium weighs 0.1785 grams per litre while the air weighs about 1.25 grams per
litre. Due to the difference in the helium weight and the air weight, about litre of
helium can lift about 1 gram from the following equation:
ρair
(
m lift =mass gas × 1−
ρgas ) ………………………(1.7)
3
1 KB RAM
4 I/O ports
1 Serial communication
9 Snap switches
8 onboard LED’s
1 LCD
o 7-Segment Display
o ADC module
Serial Cable
A PC available with RS232 port. If the port has 25-pin connector, a 9 pin male
to 25 pin female adapter may be required.
Keil uV3
Flash Magic.
2.2 MCU
Nanosier Incorporation 8051 Starter kit is equipped with P89V51RD2 a +5V
8051based micro controller from Philips (NXP). The chip being in 40 pin DIP package is
hole mounted on the board over the IC base.
The controller has 64KB on-chip Flash ROM and 1 KB on-chip RAM, and supports up to
40 MHz frequency. It also has 32 I/O lines, 3 Timers/Counters, 8 interrupts, 5 channels
PCA, SPI, WDT. It can also operate in a special X2 mode in which 1 machine cycle
consumes 6 crystal frequencies (by default (Normal mode) takes 12 crystal
frequency/machine cycle). P89V51RD2 supports serial In-system Programming for
programming 64KB Flash memory.
5
2.3 CRYSTAL
XTAL1 is an 11.0592MHz crystal connected across pins 18 and 19 of MCU.
This crystal provides accurate baud rate for serial communications. 11.0592MHz is
maximum clock frequency that the standard 8051 will support.
REVIEW OF LITERATURE
8
The main idea of the airship is that the helium balloons are not capable of lifting
the motor/MCU module just by little bit. Therefore, when the lifting motors are turned
on, the thrust from the two motors are enough to generating enough lifting force to
bring up the airship. In addition, there are two motors that put thrust in the sideway.
By changing the ratio of speed between the two side motors, the airship can rotate
either left or right. These lift motors and directional motors enable the three
dimensional control over the airship.
The control of the airship is done through remote controller. The controller,
which is controlled by three potentiometers, sends RF signals to the airship. In turn,
the airship receives the signal – through an antenna if necessary – to obtain information
on how to control the fans (motors). By controlling the motorized fans on the airship,
one can manipulate the directionality and acceleration of the airship navigation.
Fig.3.1: Airship
9
Since the airship is lift using helium balloons and more balloons are needed to
lift more weights, there is an intrinsic trade off between the size of the airship and the
size of the motor. Though bigger motors can exert more torque, hence lift more
weight, it might require additional balloons because the bigger motors are much
heavier. Also, as more balloons and bigger motors are used, they add to extra cost,
hence there is trade of between such items and the cost of the project.
10
The airship complies IEEE safety standard to avoid any possible hazard. The
propeller is in soft plastic to avoid any cutting injuries. In addition no high power will
be used for the safety reason as well.
This project does meet the regulation imposed by FCC, which is shown in Table 3
below, to incorporate with legal considerations.
3.4.1 Transmitter
(1) TIMER0
Mega644 has TIMERX modules which increase at user specified rate independently
from program execution. The program has number of tasks to be run. In order to
control the timing of each tasks, we used TIMER0 to generate 1 millisecond time base.
During initialization routine, we set the CS<02:0> bits in TCCR0B register to 011 to
change pre-scale to 1:64, OCIE0A bit in TIMSK0 register to 1, and OCR0A register to
249 thereby making TIMER0 interrupt every 250 timer count. Thus, we were able to
generate 64/16000000 * 250 = 0.001s time base. During TIMER0 compare match
interrupt service routine, we incremented timer for each of the tasks. Thus, we were
able to make the task for transmitting data and the task for taking analog to digital
conversion data every 50ms. During initialization, we made sure that the two timing
variables for our tasks didn’t time out at the same time by initializing one timing
variable to be 0 and the other timing variable to be 25.
(2) Analog to Digital Conversion
Mega644 board has an analog to digital converter (ADC) which has 8 software
multiplexed channel with prescalable clock. The analog to digital converter converts
the analog value linearly and stores the result in 8bit or 10bit form, which can be read
by user. The transmitter board takes in user-input through analog values from three
potentiometers. As reference voltage, A Vdd was used. Each potentiometer was to
control upward thrust, forward thrust, and turn. Turning up the potentiometers for
upward and forward thrust, would make the propeller in the airship turn faster giving it
more power. The third potentiometer was designed to work like a car handle. Turning
the potentiometer knob left would make the airship turn left. Similarly, turning the
potentiometer knob right would make the airship turn right.
To implement the analog to digital conversion from three different sources, we
had to manipulate analog to digital converter channels. Thus we changed MUX4:0 in
ADMUX bit to change channel before each conversion to take in three different data
from three different sources. For ease of programming we set the ADLAR bit in
ADMUX to one thereby making the processor right adjust the result. Right adjusting
the data made us able to use the value stored in ADCH register for eight bit analog to
digital conversion result. Since the airship we designed would be very large compared
to the restricted power we have due to weight constraint, we figured that full 10bit
resolution for analog to digital conversion was unnecessary. Thus we only took the
upper eight bit by taking the value of ADCH register. Of course, we had to set the
ADEN bit in ADCRA register to enable the analog to digital conversion. At first, above
register configuration for the analog to digital converting peripheral did not produce
correct converted value.
After trying many times to make it work by changing various other registers, we
figured out the reason that the converter didn’t work was that the clock input to the
analog to digital converter inside the microcontroller was too fast because we were
using 16Mhz crystal without prescaler. The clock speed was too fast for the analog to
digital converter to charge up. Thus we had to change the prescaler to 1:128 to give the
12
analog to digital converter enough time to convert. Lastly, we made the digital I/O
function of the PORTA(which should be used for analog to digital conversion port) by
setting DIDR0 register to value 0xFF. Also, we changed the port direction of PORTA
to inputs by changing DDRA register to value 0x00. The correctly setup analog to
digital conversion routine was carried out every 50 millisecond. In the routine that
takes the analog to digital converted user input, 1) we changed analog to digital channel
by changing ADMUX register, 2)initiated conversion by setting ADSC bit in ADCSRA
register to one, 3) waited for the conversion to finish by monitoring ADIF bit in
ADCSRA register, and finally read the value of ADCH register. We did the above step
three times to take in three different data from three different sources. The converted
value ranged from 1 to 255 since we used only eight bit result. For upward and forward
data, 1 meant least power and 255 meant maximum power. For Left or Right handling,
the value of 1 meant turning the handle to the left fully and the value of 255 meant
turning the handle to the right fully.
(3) Data packaging
gain adjust bytes, we sent 3 bytes(bit balanced) which we called sync bytes(0x35, 0x69,
and 0xAC) to sync with the receiver. On the receiver end, the software simulated state
machine kept track of each byte received and it recognized our data only after the three
sync bytes are received in order. In other words, only after sending the gain adjust bytes
and “Sync byte” we sent the actual data.
3.4.2 Receiver
The most important aspect of our receiver board design is the motor control. For motor
control, we use two timers, TIMER0 and TIMER2 for PWM output. In order to use the
PWM peripheral, we set COM0A<1:0> in TCCR0A register to 10 to use OCOA pin as
the non-inverting PWM output to drive upward motor. The OCOA pin will be high as
long as the value of the TIMER0 is lower than OCROA register. We wanted simple
fast PWM mode so we set the WGM<1:0> bits in TCCR0A register to 11. In previous
lab regarding digital tachometer(lab4 in ECE 4760 at Cornell) we noticed that the
frequency of PWM output which controls motor was important because frequency that
was too high would not pass across the onto isolator and the frequency that is too low
would give erratic response of motor. Thus, we set the pre scalar of the TIMER0 and
TIMER2 to 64 to make about 1Khz PWM frequency, the same frequency we used For
TIMER2, we set the COM2A<1:0> bits and COM2B<1:0> bits to 10 to use OC2A and
OC2B pins as PWM output for controlling left motor and right motor. Through
radiofrequency communication, we receive three bytes(“upward”, “forward”, and “Left
or Right”) which corresponds to the upward thrust, forward thrust, and left or right turn.
Upward byte goes directly into OCR0A register for direct translation of upward thrust
and the data sent from the transmitter to control the duty rate. The duty rate for the
motors that provides forward thrust is calculated by combining the latter two bytes sent
by the transmitter. The duty rate for the left motor is determined by “forward”/2 plus
(255 - “Left or Right”)/2. The duty rate for the right motor is determined by
“forward”/2 plus “Left or Right”/2. Thus, for left and right motor, half of the thrust
depends on “forward” byte and the other half depends on “Left or Right” byte.
The calculated duty rate “Left” and “Right” is then written to OCR2A and
OCR2B register respectively. Please note that we chose the above three PWM output
pins for soldering ease. Without that consideration, we could have chosen any three
PWM output pins from all six PWM output pins to drive motors. Lastly, our
radiofrequency transmitter and receiver pair had only limited range, we needed to have
safety mechanism for retrieving our airship in case the airship lost and the transmitter
lost contact. Thus, we kept another timer, to count the time from the last reception of
data arrays. If the airship did not receive for prolonged period of time(in
microcontroller sense), it was programmed to turn off all of the motor. That way, we
would be able to retrieve the ship even if it loses connection because it would fall
slowly by gravitational force.
(3) Watchdog Timer
Due to the nature of our project that used the actuator that generated heavy noise, even
with opto isolation, and the fact that we had to use small lithium battery(which turned
out to be very unreliable) to power the MCU, we had to make sure that the system was
self correcting in case of runaway code, probably due to corrupted program counter.
Thus, we decided to use watchdog timer built inside the mega644 MCU. The watchdog
timer is just like any other timers that we used for controlling the motors except that it
is clocked from different source and it resets the processor when it expires. Thus, the
watchdog timer has to be reset periodically to prevent the unwanted processor reset.
The watchdog timer is very useful because when the code runs away, it is very likely
that the program won’t reset the watchdog timer on time making the timer reset the
CPU. In order to use watchdog timer, we set the WDE bit in WDTCSR register to one
to enable watchdog timer. Also, in order to change the time out period for watchdog
15
timer to the value we want, we had to first set WDCE bit in WDTCSR register and then
change WDP bits in WDTCSR register. We set the WDP bits to 101 to make the
watchdog timer time out at 0.5 second. However, even with watchdog timer, the system
is not fail proof. For example, if the program enters an infinite loop that constantly
clears watchdog timer, it can never recover. Also, the hardware, not the software,
condition persists; it is very likely that the processor will reset constantly.
Embedded C kit provides Keil uvision3 evaluation version along with the kit.
This is an IDE that combines project management, make facilities, source code editing,
and program debugging and complete simulation under one powerful environment.
μVision includes traditional features like simple and complex breakpoints, watch
windows and execution control as well as sophisticated features like trace capture,
execution profiler, code coverage and logic analyzer.
The μVision Debugger provides a number of ways to display variables and program
objects.
Source Code Windows display your high-level language and assembly program
source code.
The Disassembly Window shows mixed high-level language and assembly code.
The Registers Tab of the Project Workspace shows system registers.
The Symbol Window hierarchy displays program symbols in your application.
The Output Window displays the output of various debugger commands.
The Memory Window displays up to four regions of code or data memory.
The Watch Window displays local variables, user-defined watch expression lists,
and the call stack.
Breakpoints - Both simple and complex breakpoints are supported by the μVision
Debugger.
The Logic Analyzer shows how various signals and variables in your program
change over time.
3.5.4 Simulation
Simulation capabilities make it possible to test your target system without target
hardware.
Instruction Simulation simulates the exact effects and timing of each MCU
instruction.
Interrupt Simulation simulates the cause and effect of a system or peripheral
interrupt.
Peripheral Simulation simulates the effects of on-chip peripherals including special
function registers.
Debugger Functions allow you to expand the command scope of the debugger and
create and respond to stimuli.
Toolbox Buttons are a convenient way for you to connect debugger functions
buttons on the user-interface.
17
►STEP 1
Load the keil
►STEP 2
Once keil is loaded an empty work space is displayed, if previously no projects were
opened. Else if any projects were opened previously, then the same project will be
opened.
►STEP 3
To create a new project, go to Project, a drop down menu will be displayed from this
select new project.
18
►STEP 4
Within the “Create New Project window” select the path for the new project , as in
above snap shot desktop is selected and within this path right click and create a new
folder and here it is named as “demo”.
►STEP 5
Double click on the newly created folder and type in the project name and click on
save.
19
►STEP 6
Once the project is saved the target chip that has to be programmed need to be selected
from the window shown below:
►STEP 7
For our purpose goto Generic and then select 8051(all variants). Click OK.
20
►Step 8
The above window will be displayed and to add the “Startup file click on Yes.
►STEP 9
The Startup file for 8051 gets added to the source group of the current project.
21
►STEP 10
Go to File Menu select new. A new file gets opened where you can start editing the
program codes.
►STEP 11
22
►STEP 12
Click Save.
►STEP 13
23
Now add the file to the current project. For this right click on source group, and click
on Add Files to Group 'Source Group 1'.
►STEP 14
Now select the .c file and click on Add and close the Add files to Group window.
►STEP 15
24
Now the program has to be compiled click on the compile button and build target i.e.
Project Menu --> Build Target.
►STEP 16
If no Errors and Warnings, then the program can be debugged by entering into debug
mode. The path is go to Debug Menu and select Start/Stop Debug Session. If any errors
present in the list of errors will be displayed.
►STEP 17
The register content after each instruction execution will be displayed in the register
window towards the left hand side.
25
►STEP 1
Being outside the debug mode right click on the Target folder in the Project work space
and select the Options for Target 'Target name'
►STEP 2
Select Output option and click in the check box of Create HEX File and click OK.
26
►STEP 3
Now build the program again to generate the HEX File. The Hex file will be saved in
the current project folder as .HEX file. This file is downloadable to the 89V51RD2
Flash.
The above window gets displayed upon which the following configuration has to be
made.
A) Step 1: Communications
COM Port: COM1
Baud Rate: 9600(if you’re connecting to your PC)
Device: 89V51RD2
Interface: None [ISP]
B) Step 2: Erase
Select Erase all Flash Magic
C) Step 3: Hex File
Click on browse, select the path of the hex file generated
D) Step 4: Options
Select Verify after programming
►STEP2
28
Check for, the connection has been established between Flash Magic and the target
system. Click on ISP--->Read Device Signature + Reset Button on the target board
simultaneously.
►STEP 3
Once the device gets detected the manufacture Id and Device Id are displayed
►Step 4
29
If the board is not detected the following window will be displayed. Check for proper
hardware connections and reset the board.
►Step 5
Once the board is detected and the hex file path has been provided click on Start. You
Observe a blue band increasing, gives you the info about the amount of the code been
downloaded till that moment. Once blue band disappears the program has been
downloaded.
Now wait until the Verifying message toward bottom left disappears.
Finally, after all the above procedures reset the switch on your board to get into
execution mode.
30
3.6 MICROCONTROLLERS
3.6.1 History of Microprocessors and Microcontrollers
The Intel 8051 is Harvard architecture, single chip microcontroller (µC) which
was developed by Intel in 1980 for use in embedded systems. Intel's original
versions were popular in the 1980s and early 1990s, but has today largely been
superseded by a vast range of faster and/or functionally enhanced 8051-compatible
devices manufactured by more than 20 independent manufacturers including Atmel,
Infineon Technologies (formerly Siemens AG), Maxim Integrated Products (via its
Dallas Semiconductor subsidiary), NXP (formerly Philips Semiconductor), Nuvoton
(formerly Winbond), ST Microelectronics, Silicon Laboratories (formerly Cygnal),
Texas Instruments and Cypress Semiconductor. Intel's official designation for the
8051 family of µCs is MCS 51.
Intel's original 8051 family was developed using NMOS technology, but later
versions, identified by a letter C in their name (e.g., 80C51) used CMOS technology
and were less power-hungry than their NMOS predecessors. This made them more
suitable for battery-powered devices. It's also low power consumption max 5v.
The past two decades have seen the introduction of a technology that has radically
changed the way in which we analyze and control the world around us. Born of
parallel developments in computer architecture and integrated circuit fabrication, the
microprocessor, or "computer on a chip," first became a commercial reality in 1971
with the introduction of the 4-bit 4004 by a small, unknown company by the name
of Intel Corporation. Other, more well-established, semiconductor firms soon
followed Intel's pioneering technology so that by the late 1970s one could choose
from a half dozen or so microprocessor types. The 1970s also saw the growth of the
number of personal computer users from a handful of hobbyists and "hackers" to
millions of business, industrial, governmental, defence, educational, and private
users now enjoying the advantages of inexpensive computing.
A by-product of microprocessor development was the microcontroller. The
same fabrication techniques and programming concepts that make possible the
general-purpose microprocessor also yielded the microcontroller.
Microprocessors and microcontrollers stem from the same basic idea, are made by
the same people, and are sold to the same types of system designers and
programmers. What is the difference between the two?
A µp, as the term has come to be known, is a general-purpose digital computer
central processing unit. Although popularly known as a "computer on a chip," the µp
is in no sense a complete digital computer.
3.6.1.1 Building Blocks of Microprocessor
3.6.2 Microcontrollers
Microcontrollers are not as well known to the general public, or even the
technical community, as are the more glamorous microprocessors. The public is,
however, very well aware that "something" is responsible for all of the smart VCRs,
clock radios, washers and dryers, video games, telephones, microwaves, TVs,
automobiles, toys, vending machines, copiers, elevators, irons, and a myriad of other
articles that have suddenly become intelligent and "programmable." Companies are
also aware that being competitive in this age of the microchip requires their products,
or the machinery they use to make those products, to have some "smarts."
Microcontrollers Microprocessors
Microcontrollers may have one, or two Microprocessors have many operational codes
operational codes (op codes) for moving (op codes) for moving data from external
data from external memory to the CPU. memory to the CPU.
Microcontrollers have many types of bit- Microprocessors may have one or two types of
handling instructions. bit-handling instructions.
Microcontroller is concerned with rapid Microprocessor is concerned with rapid
movement of bits within the chip. movement of code and data from external
addresses to the chip.
µC can function as a computer with the Microprocessor must have many additional
addition of no external parts. parts to be operational.
Table 3.2: Comparison between µp & µc
3.9 APPLICATIONS
popularity in the game console market, where it is often used instead of EEPROM’s or
battery-powered SRAM for game save data.
Boolean instruction
Variety of Addressing mode
Special Function Registers (SFR’s)
4K ROM on chip Program Memory
128 bytes of on chip Data RAM
32 bidirectional and individually addressable I/O lines.
Two 16 bit timers/counters
Serial I/O port Full Duplex (UART).
6-sources/5-vector interrupts structure with two priority levels.
On chip clock oscillator.
The 8052 has 256 bytes of internal RAM and 8K of internal code ROM. The
8051 and 8052 internal ROM cannot be programmed by the user. The user must supply
the program to the manufacturer, and the manufacturer programs the microcontrollers
during production. Due to the setup costs, the factory masked ROM option is not
economical for small quantity productions.
The 8751 and 8752 are the Erasable Programmable Read Only Memory
(EPROM) versions of the 8051 and 8052. Many manufacturers offer the EPROM
versions in windowed ceramic and non-windowed plastic packages. These are user
programmable. However, the non-windowed versions cannot be erased. These are
usually referred to as One-Time- Programmable (OTP) microcontrollers, which are
more suitable for experimental work or for small production runs.
The 8951 and 8952 contain FLASH EEPROM’s (Electrically Erasable
Programmable Read Only Memory). These chips can be programmed as the EPROM
versions, using a chip programmer. Moreover, the memory may be erased. Similar to
EPROM’s, Erasing FLASH memory sets all data bits (data bytes become 0FFH). A bit
may be cleared (made 0) by programming. However, a zero bit may not be
programmed to a one. This requires erasing the chip.
Some larger FLASH memories are organized in banks or sectors. Rather than
erasing the entire chip, you may erase a given sector and keep the remaining sectors
unchanged. During the past decade, many manufacturers introduced enhanced
members of the 8051 microcontroller. The enhancements include more memory, more
ports, analog to digital converters, more timers with compare, reload and capture
facilities, more interrupt sources, higher precision multiply and divide units, idle and
power down mode support, watchdog timers, and network communication subsystems.
All microcontroller of the family use the same set of machine instructions, the MCS-
51. The enhanced features are programmed and controlled by additional SFR’s.
3.12 PIN OUT DESCRIPTION
39
If there is no intention to use external memory then these port pins are configured
as general inputs/outputs.
In case external memory is used, the higher address byte, i.e. addresses A8-A15
will appear on this port. Even though memory with capacity of 64KB is not used,
which means that not all eight port bits are used for its addressing, the rest of them
are not available as inputs/outputs.
Pin 29: PSEN,
If external ROM is used for storing program then a logic zero (0) appears on it
every time the microcontroller reads a byte from memory.
Pin 30: ALE Prior to reading from external memory, the microcontroller puts
the lower address byte (A0-A7) on P0 and activates the ALE output. After
receiving signal from the ALE pin, the external register memorizes the state of P0
and uses it as a memory chip address. Immediately after that, the ALU pin is
returned its previous logic state and P0 is now used as a Data Bus. As seen, port
data multiplexing is performed by means of only one additional (and cheap)
integrated circuit. In other words, this port is used for both data and address
transmission.
Pin 31: EA
By applying logic zero to this pin, P2 and P3 are used for data and address
transmission with no regard to whether there is internal memory or not. It means
that even there is a program written to the microcontroller, it will not be executed.
Instead, the program written to external ROM will be executed.
By applying logic one to the EA pin, the microcontroller will use both memories,
first internal then external (if exists).
Pin 32-39: Port 0
Similar to P2, if external memory is not used, these pins can be used as general
inputs/outputs. Otherwise, P0 is configured as address output (A0-A7) when the
ALE pin is driven high (1) or as data output (Data Bus) when the ALE pin is driven
low (0).
Pin 40: VCC +5V power supply.
Depending on the model in use (we are still talking about the 8051 microcontroller
family in general) at most a few Kb of ROM and 128 or 256 bytes of RAM is used.
All 8051 microcontrollers have a 16-bit addressing bus and are capable of addressing
64 kb memory. It is neither a mistake nor a big ambition of engineers who were
working on basic core development. It is a matter of smart memory organization which
makes these microcontrollers a real “programmers’ goody“.
All 80C51 devices have separate address spaces for program and data memory, as
shown in Figures 1 and 2. The logical separation of program and data memory allows
the data memory to be accessed by 8-bit addresses, which can be quickly stored and
manipulated by an 8-bit CPU. Nevertheless, 16-bit data memory addresses can also be
generated through the DPTR register.
EA = 0
In this case, the microcontroller completely ignores internal program memory
and executes only the program stored in external memory.
EA = 1
In this case, the microcontroller executes first the program from built-in ROM,
then the program stored in external memory.
Note: In both cases, P0 and P2 are not available for use since being used for data and
address transmission. Besides, the ALE and PSEN pins are also used.
Internal Data Memory addresses are always one byte wide, which implies an address
space of only 256 bytes. However, the addressing modes for internal RAM can in fact
accommodate 384 bytes, using a simple trick.
Direct addresses higher than 7FH access one memory space and
Indirect addresses higher than 7FH access a different memory space. Thus
Figure 6 shows the Upper 128 and SFR space occupying the same block of
addresses, 80H through FFH, although they are physically separate entities.
3.14.1 Port 0
The P0 port is characterized by two functions. If external memory is used then
the lower address byte (addresses A0-A7) is applied on it. Otherwise, all bits of this
port are configured as inputs/outputs.
The other function is expressed when it is configured as an output. Unlike other
ports consisting of pins with built-in pull-up resistor connected by its end to 5 V power
supply; pins of this port have this resistor left out. This apparently small difference has
its consequences:
If any pin of this port is configured as an input then it acts as if it “floats”. Such
an input has unlimited input resistance and undetermined potential.
When the pin is configured as an output, it acts as an “open drain”. By applying logic 0
to a port bit, the appropriate pin will be connected to ground (0V). By applying logic 1,
the external output will keep on “floating”. In order to apply logic 1 (5V) on this output
pin, it is necessary to built in an external pull-up resistor.
44
3.14.2 Port 1
P1 is a true I/O port, because it doesn't have any alternative functions as is the
case with P0, but can be configured as general I/O only. It has a pull-up resistor built-in
and is completely compatible with TTL circuits.
3.14.3 Port 2
P2 acts similarly to P0 when external memory is used. Pins of this port occupy
addresses intended for external memory chip. This time it is about the higher address
byte with addresses A8-A15. When no memory is added, this port can be used as a
general input/output port showing features similar to P1.
3.14.4 Port 3
All port pins can be used as general I/O, but they also have an alternative
function. In order to use these alternative functions, a logic one (1) must be applied to
appropriate bit of the P3 register. In tems of hardware, this port is similar to P0, with
the difference that its pins have a pull-up resistor built-in.
3.14.5 8051 Timers and Counters
The 80C51 has two 16-bit Timer/Counter registers: Timer 0 and Timer 1. Both
can be configured to operate either as timers or event counters (see Figure 6).
In the “Timer” function, the register is incremented every machine cycle. Thus,
one can think of it as counting machine cycles. Since a machine cycle consists of 12
oscillator periods, the count rate is 1/12 of the oscillator frequency.
In the “Counter” function, the register is incremented in response to a 1-to-0
transition at its corresponding external input pin, T0 or T1. Since it takes 2 machine
cycles (24 oscillator periods) to recognize a 1-to-0 transition, the maximum count rate
is 1/24 of the oscillator frequency. There are no restrictions on the duty cycle of the
external input signal, but to ensure that a given level is sampled at least once before it
changes, it should be held for at least one full cycle. In addition to the “Timer” or
“Counter” selection, Timer 0 and Timer 1 have four operating modes from which to
select.
3.15 DIFFERENCE BETWEEN TIMERS AND COUNTERS
Timer Counter
The register is incremented every machine The register is incremented in response to a 1-
cycle. to-0 transition at its corresponding external
input pin (T0, T1).
Maximum count rate is 1/12 of oscillator Maximum count rate is 1/24 of oscillator
frequency frequency
4.1 RF TRANSMITTER
The TWS-434 and RWS-434 are extremely small, and are excellent for
applications requiring short-range RF remote controls. The transmitter module is only
1/3 the size of a standard postage stamp, and can easily be placed inside a small plastic
enclosure.
TWS-434: The transmitter output is up to 8mW at 433.92MHz with a range of
approximately 400 foot (open area) outdoors. Indoors, the range is approximately 200
foot, and will go through most walls.....
Fig.4.1: TWS-434A(Transmitter)
The TWS-434 transmitter accepts both linear and digital inputs can operate
from 1.5 to 12 Volts-DC, and makes building a miniature hand-held RF transmitter
very easy. The TWS-434 is approximately the size of a standard postage stamp.
4.2 RF RECEIVER
RWS-434: The receiver also operates at 433.92MHz, and has a sensitivity of 3uV.
The RWS-434 receiver operates from 4.5 to 5.5 volts-DC, and has both linear and
digital outputs.
The 212 encoders are a series of CMOS LSI’s for remote control system
applications. They are capable of encoding information which consists of N address
bits and 12_N data bits. Each address/data input can be set to one of the two logic
states. The programmed addresses/data are transmitted together with the header bits via
an RF or an infrared transmission medium upon receipt of a trigger signal. The
capability to select a TE trigger on the HT12E or a DATA trigger on the HT12A
further enhances the application flexibility of the 212 series of encoders. The HT12A
additionally provides a 38kHz carrier for infrared systems.
48
inductor when the motor is suddenly unpowered, in order to protect the NMOSFET
transistor from breaking.
5.3.1 Transmitter:
5.3.1.1 TIMER0
Mega644 board has an analog to digital converter (ADC) which has 8 software
multiplexed channel with prescalable clock. The analog to digital converter converts
the analog value linearly and stores the result in 8bit or 10bit form, which can be read
by user. The transmitter board takes in user-input through analog values from three
potentiometers. As reference voltage, A Vdd was used. Each potentiometer was to
control upward thrust, forward thrust, and turn. Turning up the potentiometers for
upward and forward thrust, would make the propeller in the airship turn faster giving
it more power. The third potentiometer was designed to work like a car handle.
Turning the potentiometer knob left would make the airship turn left.
Similarly, turning the potentiometer knob right would make the airship turn
right. To implement the analog to digital conversion from three different sources, we
had to manipulate analog to digital converter channels. Thus we changed MUX4:0 in
ADMUX bit to change channel before each conversion to take in three different data
from three different sources. For ease of programming we set the ADLAR bit in
ADMUX to one thereby making the processor right adjust the result. Right adjusting
the data made us able to use the value stored in ADCH register for eight bit analog to
digital conversion result. Since the airship we designed would be very large compared
to the restricted power we have due to weight constraint, we figured that full 10bit
resolution for analog to digital conversion was unnecessary. Thus we only took the
upper eight bit by taking the value of ADCH register. Of course, we had to set the
ADEN bit in ADCRA register to enable the analog to digital conversion. At first,
above register configuration for the analog to digital converting peripheral did not
produce correct converted value.
After trying many times to make it work by changing various other registers, we
figured out the reason that the converter didn’t work was that the clock input to the
53
analog to digital converter inside the microcontroller was too fast because we were
using 16Mhz crystal without prescaler. The clock speed was too fast for the analog to
digital converter to charge up. Thus we had to change the prescaler to 1:128 to give
the analog to digital converter enough time to convert. Lastly, we made the digital I/O
function of the PORTA(which should be used for analog to digital conversion port)
by setting DIDR0 register to value 0xFF. Also, we changed the port direction of
PORTA to inputs by changing DDRA register to value 0x00. The correctly setup
analog to digital conversion routine was carried out every 50 millisecond. In the
routine that takes the analog to digital converted user input, 1) we changed analog to
digital channel by changing ADMUX register, 2)initiated conversion by setting
ADSC bit in ADCSRA register to one, 3) waited for the conversion to finish by
monitoring ADIF bit in ADCSRA register, and finally read the value of ADCH
register. We did the above step three times to take in three different data from three
different sources. The converted value ranged from 1 to 255 since we used only eight
bit result. For upward and forward data, 1 meant least power and 255 meant
maximum power. For Left or Right handling, the value of 1 meant turning the handle
to the left fully and the value of 255 meant turning the handle to the right fully.
5.3.1.3 Data packaging
54
The most important aspect of our receiver board design is the motor control. For
motor control, we use two timers, TIMER0 and TIMER2 for PWM output. In order to
use the PWM peripheral, we set COM0A<1:0> in TCCR0A register to 10 to use
OCOA pin as the non-inverting PWM output to drive upward motor. The OCOA pin
will be high as long as the value of the TIMER0 is lower than OCROA register. We
wanted simple fast PWM mode so we set the WGM<1:0> bits in TCCR0A register to
11. In previous lab regarding digital tachometer(lab4 in ECE 4760 at Cornell) we
noticed that the frequency of PWM output which controls motor was important because
frequency that was too high would not pass across the opto isolator and the frequency
that is too low would give erratic response of motor. Thus, we set the pre scaler of the
TIMER0 and TIMER2 to 64 to make about 1Khz PWM frequency, the same frequency
we used For TIMER2, we set the COM2A<1:0> bits and COM2B<1:0> bits to 10 to
use OC2A and OC2B pins as PWM output for controlling left motor and right motor.
59
period of time(in microcontroller sense), it was programmed to turn off all of the
motor. That way, we would be able to retrieve the ship even if it loses connection
because it would fall slowly by gravitational force.
6.3.2 Watchdog Timer
Due to the nature of our project that used the actuator that generated heavy noise, even
with opto isolation, and the fact that we had to use small lithium battery(which turned
out to be very unreliable) to power the MCU, we had to make sure that the system was
self correcting in case of runaway code, probably due to corrupted program counter.
Thus, we decided to use watchdog timer built inside the mega644 MCU. The watchdog
timer is just like any other timers that we used for controlling the motors except that it
is clocked from different source and it resets the processor when it expires. Thus, the
watchdog timer has to be reset periodically to prevent the unwanted processor reset.
The watchdog timer is very useful because when the code runs away, it is very likely
that the program won’t reset the watchdog timer on time making the timer reset the
CPU. In order to use watchdog timer, we set the WDE bit in WDTCSR register to one
to enable watchdog timer. Also, in order to change the time out period for watchdog
timer to the value we want, we had to first set WDCE bit in WDTCSR register and then
change WDP bits in WDTCSR register. We set the WDP bits to 101 to make the
watchdog timer time out at 0.5 second. However, even with watchdog timer, the system
is not fail proof. For example, if the program enters an infinite loop that constantly
clears watchdog timer, it can never recover. Also, the hardware, not the software,
condition persists; it is very likely that the processor will reset constantly.
-Receive RF Signal
- The
signal contains command for upward thrust, forward
boost, left or right turn.
RESULTS
61
Even if we reduced the weight of the parts mounted under the balloon as much
as we could, we had to use very big volume of helium filled balloon to lift up the
airship. Also, because of the weight constraint we could not use motors with big torque.
Instead, we had to use mini motors that were light weighted. Thus, we only had limited
amount of thrust for maneuvering airship. Therefore although the response to the
radiofrequency transmission was very fast(almost instantaneous translation to PWM
output), the speed of our airship was could not be very fast. Nevertheless, we were able
to move the airship with reasonable speed as to make keep the controller entertained.
The speed of the airship is best demonstrated in the video attached for demo testing.
7.2 ACCURACY
For our purpose, the only accuracy that we needed to carefully consider was the
accuracy of the sent data. Before we adjusted the antenna length to be quarter wave
length of the carrier frequency, we had erratic transmission even when we moved the
transmitter about 10 meters away from the receiver. However, after readjusting the
antenna to quarter wave length, and making the sync byte arrays more restrictive, we
were able to safely extend the range of the reception to about 100 meters without any
corruption in data as specified in the datasheet of RCT/R 433.
7.3 SAFETY
The major safety concern we worried about was the receiver going out of
control for various reasons. As described in software section, we designed the receiver
program to turn off all the motors if no valid signal was received from the transmitter
for prolonged period of time. Plus, we used the watchdog timer to monitor correct
program execution. Nevertheless, if both of the safety measure failed, there could be
little safety hazard because helium is not flammable and nontoxic. In earlier design
phase, we also considered using hydrogen gas. However, we decided that that would be
extremely dangerous although it would provide much more lifting force per volume.
Thus, even if the balloon containing helium blew apart, there would be little hazard
other than possible hearing loss, and heart attack from sudden noise. Thus, we advise
people with heart problem avoid using the device we created.
CONCLUCIONS
62
This project was successful in a sense that the airship met the specification
initially imposed. For instance, it was possible to lift the airship as well as to change
directions in both left and right. For improvements, the motor modules could be
combined such that all the four modules can be built on one piece of board, which
would save some extra room. Also, a better qualify regulator could be implemented to
reduce the amount of batteries required for the MCU control, which could aid to
reducing the amount of the helium needed. In addition, the more efficient propeller
could be adapted in order to extract more lifting force from the motor.
In terms of ethical considerations, first of all, the airship satisfies the demand of
green trend which advocates for less carbon mono-oxide emission. Because it does not
consume a carbon fuel, this airship is totally environmental friendly, emitting no carbon
mono-oxide. In terms of the safety consideration, the propellers are small and made of
soft plastics such that there is the minimal cutting hazard. In addition, the airship is
operated at a very low power device in consideration for the safety of the general
public. Such low power feature also coincides with the electronic engineering society’s
emphasis on low power devices. This could be helpful to be implemented in the
defense related missions where the low power is the key to the success of the mission.
We accepted no bribes to this project which we are very proud of and planning
to keep our work ethic up to the standard of IEEE. After all, this project was a
sincerely great opportunity to expand our knowledge on electronics that we only learn
through textbooks. We take prides in keeping up with state of art technologies in motor
control and wireless communication and being able to find a suitable application for the
composite of the technologies. Lastly, we also have graciously accepted the productive
criticisms from the Prof. Land as well as teaching assistant, all of which added
invaluable value to this project.
FURTHER ENHANCEMENT
63
the motor speed as long as their sizes were the same, brand-named batteries ran the
motors for much longer than what the low-name batteries could do – almost twice as
long.
After the motor battery has been replaced, there came the problem in controlling
the motors through MCU. It was later found that it was also a problem with a battery
as well. Initially used three serially connected three button batteries were not enough to
keep the MCU running. The set of batteries had too small of power, and therefore,
could not provide enough voltage and current for the regulator – 7.5 volts. At the end,
serially connected five button cell batteries and serially connected five coin cell
batteries were paralleled connected to be used for MCU in the airship in order to
provide sufficient voltage and current for the motor control.
In order to reduce the mass of the airship module as much as possible, we tried
to make a motor module without using an opto-isolator. Nonetheless, this resulted in a
miserable failure as the inductive coupling-induced voltage spikes and noise created too
much of disturbance for MCU to function properly. Essentially, the disturbance was
large enough that the motors were not able
REFERENCES
65
10. 1 JOURNELS
i. [1] Mueller, J. B., Zhao, Y., and Paluszek, M., “Development of an
Aerodynamic Model and Control Law
ii. Design for a High-Altitude Airship,” AIAA Unmanned Unlimited Conference,
No. AIAA-6479, AIAA,
iii. Chicago, IL, 2004.
iv. [2] Zhao, Y., Garrard, W., and Mueller, J. B., “Bennefits of Trajectory
Optimization for Airship Flights,”
v. AIAA Unmanned Unlimited Conference, No. AIAA-6527, AIAA, Chicago, IL,
2004.
vi. [3] Jones, S. P. and DeLaurier, J. D., “Aerodynamic Estimation Techniques for
Aerostats and Airships,”
vii. AIAA Lighter-than-Air Systems Conference, AIAA, Annapolis, MD, 1981.
viii. Guidance and Control of High-Altitude Navigation Airships.
ix. Development of an Aero dynamical Model and control law for airship.
10.2 BOOKS
i. [4]Antenna Theory by Constantnie A. Balanis.
ii. [5]Radio and Wave Propogation by K.D. Prasad
10.3 WEBSITES:
i. [6]www.engineersgarage.com
ii. [7]www.radiotronix.com
iii. [8]www.allpinout.com
iv. [9]www.atmel.com