Académique Documents
Professionnel Documents
Culture Documents
Abstract
The rise of virtual reality and augmented reality provides brand new way of
interaction with digital information. However, virtual reality immerses the users in
simulated world with scarce connection with the real one. Augmented reality
merely overlays virtual objects over real ones with no specific concern about the
interaction in between. By understanding the environment, mixed reality is capable
of blending the virtual objects with the real world. This project proposes a mixed
reality system with multiplayer engagement based on Microsoft HoloLens and
Google Tango tablet. Several innovative applications for creation works, such as
painting in 3-dimensional space and 3D reconstruction, are introduced to
appreciate the interaction and collaboration with the concept of mixed reality. In
terms of technical objectives, the main focus will be put on the implementation of
spatial mapping, Gaze-Gesture-Voice (GGV) input. Up to this point, all the mixed
reality applications on both HoloLens and Tango have been implemented and
tested. The cross-platform multiplayer is also finished and the whole system is now
ready for demonstration.
INTRODUCTION
Since the year of 2013, a collection of virtual reality (VR) headsets including
Oculus Rift and HTC Vive have been introduced to the public. The common point
of VR headsets is that they display the software-generated images to replicate a
virtual world setting. Although such synthetic environments may possess the
properties of the real ones, there can also be no connection between the physical
and virtual world. For example, the basic physical laws may no longer hold.
1
On the other hand, the concept of augmented reality (AR) introduces a real-time
view of the physical world with supplemented elements generated by the computer.
For instance, the mobile game Pokémon GO by Nintendo enable players to catch
pocket monsters that do not really exist. Nevertheless, most implementations of
augmented reality simply overlay the images and information on the physical
world. This makes it more stiff and less interactive if a virtual object and a real one
overlap unnaturally.
2
Mixed reality (MR) shares the same characteristic with augmented reality. Both the
virtual and physical objects are combined. However, in mixed reality, the spatial
mapping of the real environment is perceptible by the computer. Then the objects,
including the real and virtual ones, can have interactions at a level of visual
verisimilitude (see Figure 1). Thus there is enhanced illusion of having both
aspects in the same reality.
2. Objective
The objective of the project is to build a workable demo of mixed reality. The
demo should have the capability of observing the spatial mapping. In other words,
this system is able to recognizing the surface of ceiling, walls, table and floor. In
addition, the demo is planned to take the GazeGesture-Voice (GGV) input as
controlling methods. Multiple users can interact with both the physical and virtual
environment and also collaborate with each other. The scenarios for creation works
as well as their main technical focus include but not limited to:
4
• Complementary application (focus point stabilizer) — GGV (particularly
gaze input)
All the works above are projected at the same place of the physical world.
Therefore users may have better experience in collaboration. With the HoloLens,
anyone can easily participate in this process and realize his or her own design in a
more natural and interactive way than the approach of augmented reality. In the
meantime, the work done is shared among all the other users in realtime.
3. System Details
In this section, the infrastructure of the whole mixed reality system will be
introduced. Reasons will be provided for the choices of hardware and software
platforms. In the second subsection, the scope of the project will follow. The 5-
stage approach for building the system will be explained as the last part of this
section.
Infrastructure
The hardware for the mixed reality system includes two kinds of devices,
Microsoft HoloLens and Google Tango tablets. HoloLens is a head-mounted
display (see Figure 2a) equipped with an inertial measurement unit (IMU), four
environment understanding sensors and a depth camera. It can map the
5
surroundings in a short time with relatively high precision. This provides users
with the most interactive demonstration of the mixed reality and thus makes
HoloLens our first choice.
Figure 2a. Microsoft HoloLens is a headset with Figure 2b. Google Tango tablet
is an Android various sensors and depth cameras for perception based device with
depth sensor. It provides spatial of the surroundings at a relatively high precision.
mapping without extra setups at a more affordable
(image source: Microsoft) price. (image source: Google)
However, the number of HoloLens is limited due to the high price (US$3000).
Since we want more users to get involved, the more affordable Google Tango
tablets (US$512) are used as supplementary devices. They are Android based
devices with a touchscreen, cameras for motion tracking and depth sensing (see
Figure 2b). No extra setup is necessary for new users to participate in the
collaboration. However, the other smart devices such as tablets and mobile phones
with ordinary touchscreen and cameras are ruled out as complex calibration is
necessary before they can be used. All the devices within the mixed reality system
are connected via LAN/WiFi so that the status of the demo can be shared.
The scenarios and features will be implemented with the Unity 3D game
development platform. This is a generally free-to-use software kit for developing
6
games and demos. It has a well written documentation and an active supporting
community. In addition, Unity supports multiple platforms so that little works are
needed to build applications for different devices. Moreover, Photon Unity 3D
Networking Framework SDK is used for realization of multiplayer support. These
are the general practices in individual gaming development and thus we will adopt
them over other choices.
Scope
One of aims of this project is to demonstrate the advantages of mixed reality over
augmented reality and virtual reality in terms of interactiveness in creative works.
Therefore, more attention are paid to the innovation of various demos within the
system. In other words, the system is supposed to include a collection of innovative
scenarios such as painting in three-dimensional space featuring mixed reality,
namely spatial mapping and GGV input. The complexity of a particular
functionality is not within scope. As an example, the implementation of 3D
drawing should not focus on the diversity of pen tools. Although the details will be
refined, this will never be comparable to professional software for digital painting.
The accuracy and level of details of 3D reconstruction will be subject to the actual
performance of the devices. In building this system, an uninterrupted user
experience is preferred over finer details with less consistent performance.
Approach
Figure 3 shows the main flow for building the mixed reality system. Basically five
steps are involved in the procedure.
7
Figure 3. The 5-step approach of building the mixed reality system.
I. Review on hardwares and softwares to be used within this project.
For the first stage, research works has been done on the developing platforms
including hardwares and softwares. As most of them are still under beta testing
and not finalized yet, there may be unforeseen bugs and disfunction.
Furthermore, the limitation of the hardware have been found so that
unrealizable functionalities can be eliminated from the project scope at the
early stage.
8
IV. Refinement of functionalities.
9
of interaction and collaboration will be regarded as the indication of pass for the
project.
4. Project Status
Results — HoloLens Platform
At this time, I have finished all the prototypes of scenarios as stated in previous
sections as well as the complementary parts for the mixed reality system. The
applications are implemented based on the review of the developing platforms
including hardwares and softwares. I have take into consideration of the
recommendations on hologram stabilization and performance by Microsoft in the
course of application design. Furthermore, a number of preliminary testings based
on these prototypes were done to help make clear of the hardware capability.
Certain refinements and adjustments have been carried out to make the system
work with satisfying performance.
11
application mainly utilizes spatial mapping and
GGV input.
The pen strokes are represented by segments consisting of pairs of lines and dots.
One trivial way of assembling the segments is to use Unity primitive objects. One
cylinder (88 vertices, 80 triangles) is to be used as the line and one sphere (515
vertices, 768 triangles) is to be used as the dot. However, as the number of
segments needed for a single pen stroke will be normally at the level of around 102,
this will result in low frame rate and cause discomfort for users. Therefore I
adopted the usage of quads with billboard rendering. Each pair is made up of one
quad (4 vertices, 2 triangles) as rectangle and another one as circle. Both quads will
12
reorient the rotation to face the user if the threshold of user movement is reached.
This radically decreases the number of vertices and triangles to be rendered.
IV. 3D reconstruction
The fourth scenario is 3D reconstruction. This application is capable of scanning
the real objects placed on surfaces such as floors, walls and ceilings and making
virtual replicates. It is also a mock stamping procedure using mixed reality. This
prototype was implemented with surface observer, the Unity API portal for spatial
mapping functionality. This is originally used for understanding the surroundings
and thus the observation volume can not be set to a small value to tightly fit the
object to be scanned. The results of testing during the implementation showed that
a value less than 1 by 1 by 1 cubic meter will cause unexpected exceptions and
13
system halt. Then there will be fallback that the whole room is to be scanned
before the necessary part of mesh is picked.
The reconstruction procedure includes three steps. First, three or more landmarks
are picked for setting up the normal vector, origin plane and clipping volume. Then
the surface observer starts scanning. Finally the object mesh within the clipping
volume will be taken via a multi-threaded post-processing step.
In order to achieve a well balanced performance between latency and quality, the
scanning parameters is set to a medium preset. The precision is 1500 triangles per
cubic meter against the ordinary 500 triangles/m 3 used for spatial mapping. The
theoretic maximum value is 6000 triangles/m 3 but a test has shown that there will
be no notable increase in scanning quality beyond 1500 triangles/m 3. The time
interval between mapping updates is 0.5 second. Smaller interval caused
exceptions in the same test.
Another optimization is the usage of wireframe in rendering the object meshes (see
Figure 6). The main reason is that the meshes got from surface observer API has no
uv information for applying complex textures. On the other hand, the wireframe is
a good-cheap-fast alternative for simple demonstration like the one in this mixed
reality system.
14
Figure 6. The ball is scanned by the 3D
reconstruction application and wireframe is
used to render the mesh for a balance between
latency and quality.
15
V. Interaction with objects
The next scenario is about interaction with objects in scene including paintings,
posters, drawings, reconstructed 3D objects as well as other objects in the future
implementations. At this stage, preliminary interactions such as initialization,
movement and deletion has been implemented. All of these use the integrated user
input of HoloLens. Two main input for HoloLens are voice input and gesture input.
HoloLens showed capability of recognizing voice commands almost instantly
when we tried out the demos. This is also mentioned by the documentation that
processing voice input is hardware accelerated. Therefore, since I have followed
the guidelines of creating concise commands, voice will be a handy input method.
The core interaction includes press, release and bloom (see Figure 7a and 7b).
Moreover, HoloLens can track the movement of user’s hand. Then complex
gestures such as holding, manipulation (1:1 movement) and navigation (like
joystick) can be recognized by combining individual presses and releases.
Figure 7a. Flexing the index finger down (press) Figure 7b. Bloom is to hold
out the hand, palm and then back up (release) makes an air-tap for up, with
fingertips together and then open the selection. (image source: Microsoft) hand.
This gesture is reserved for HoloLens
16
system and thus can not be used for
our own application. (image source:
Microsoft)
In the prototype application, three basic gestures were well recognized. Holding
and navigation worked with high accuracy as well. However, the manipulation
gesture performed below expectation. The virtual object was moved only for a
short distance before the gesture source was lost. It is likely that HoloLens has a
rather limited area for gesture recognition unlike VR devices with external cameras
(see Figure 8). One of our proposed scenarios, painting in threedimensional,
requires such gestures (see Figure 8). The unexpected performance indicate that
there can be difficulties in implementing this functionality. Overall, the user input
offered by this mixed reality system is handy and lightweight. It is supposed to be
extensible for future usage but diversity of gestures is still limited if no external
controllers like Leap Motion is to be officially supported in the near future.
17
is more difficult to develop such painting
application.
18
HoloLens has its default choices of stabilization plane. All the virtual objects
passing through the plane will have best rendering quality (see Figure 9). However
in this mixed reality system, there is a variety of virtual objects attached to
different surfaces in the same 3D space. The choice of focused object will also be
different in various scenarios. For example, the user will probably want to focus on
the pen strokes when drawing. The last application, namely the focus point
manager, was implemented with a custom strategy of choice. A focus point along
with a normal vector is chosen to set up the stabilization plane. At the same time it
has a cache strategy which checks the cached objects to increase efficiency. With
the help of focus point manager, hologram stabilization and user experience are
improved to an acceptable level even if there is a low frame rate.
Fortunately, both HoloLens and Tango take the unit length in Unity editor as one
meter in real. Then the only calibration work that remains is location of origin
point and orientation. Since the origin is defined as the spawning point of the
devices, there is possibility that a physical calibration can be archived by matching
the origin and forward vector of HoloLens and Tango when launching the
19
applications. However, this option is rejected since it may cause inconvenience that
conflicts with a favorable user experience.
For the reason above, we embraced the Vuforia SDK for coordinate calibration. In
general, it is an multi-platform library that can recognize specific images, objects
and markers. One image is printed and prepared at a fixed location for each
instance of the mixed reality system. In this way, both HoloLens and Tango are
capable of figure out the origin location and orientation. In the tests, Vuforia
demonstrated satisfying recognition speed and accuracy and precision of
coordinate calibration was better than the physical method in real-life usage.
20
Limitations
The main limitations encountered is due to the specification and characteristics of
the hardware. First, the limited number of mesh triangles makes it impossible to
deal with complicated surface. It is likely to be avoided if the precision is still
acceptable and we focus on innovation rather than the complexity of the demos.
Second, HoloLens sacrifices the tracking range in order to get extra portability.
Extensive movements can not be captured without external sensor. Therefore we
find it difficult to implement the painter application for HoloLens. This will
possibly have a negative on the user experience but it is likely that this will be
enough in terms of a demonstration instead of a product for marketing.
Another limitation comes from the fact that we are still trying to exploit creative
usage of mixed reality other than those specified in this report. Such scenarios
should also be realizable under the restrictions of the current developing platform.
Although we have already had a few ideas of utilizing mixed reality, it will always
be better if we can come up with more innovation applications.
Finally, the project faces the difficulty of lack of official multi-platform support.
Microsoft has published an open source package called HoloToolkit to simplify the
developing procedure within Unity. The latest release included the updated APIs
for recognizing user input as well as sharing coordinates among HoloLens devices.
It is likely that multiplayer support between HoloLens can be integrated with less
effort. However, the collaborative work using both HoloLens and Tango tablets
receives no official support. We have adopted Vuforia to calibrate the coordinate
system between different devices and then Photon PUN to archive cross-platform
21
synchronization. However, it still breaks our original design principle of building a
“join and play” mixed reality system in any physical environment without
additional setup.
HARDWARE DESIGN
A micro controller is a true computer on a chip. The design incorporates all the
features found in a microprocessor such as CPU, ALU,PC, SP and registers. It also
has some added features needed to make a complete computer ROM, RAM,
parallel I/o, serial I/o, counters and clock circuit. The prime use of a micro
controller is to control the operation of a machine using a fixed program that is
stored in ROM and that does not change over the life time of the system. The areas
if applications of micro controllers include control process, manufacturing process,
medicine, instrumentation etc.
PIC MICROCONTROLLER
23
PICs are popular with both industrial developers and hobbyists alike due to their
low cost, wide availability, large user base, extensive collection of application
notes, availability of low cost or free development tools, and serial programming
(and re-programming with flash memory) capability.
PERIPHERAL FEATURES:
24
Parallel Slave Port (PSP) – 8 bits wide with external RD, WR and CS
controls (40/44-pin only)
Brown-out detection circuitry for Brown-out Reset (BOR)
ANALOG FEATURES:
CMOS TECHNOLOGY:
PIN DIAGRAMS
26
QFN- QUAD-FLAT NO-LEADS PACKAGE
27
28
DEVICE OVERVIEW
This document contains device specific information about the following devices:
PIC16F877A
PIC16F873A/876A devices are available only in 28-pin packages, while
PIC16F874A/877A devices are available in 40-pin and 44-pin packages. All
devices in the PIC16F87XA family share common architecture with the following
differences:
• The PIC16F873A and PIC16F874A have one-half of the total on-chip memory of
the PIC16F876A and PIC16F877A
• The 28-pin devices have three I/O ports, while the 40/44-pin devices have five
• The 28-pin devices have fourteen interrupts, while the 40/44-pin devices have
fifteen
• The 28-pin devices have five A/D input channels, while the 40/44-pin devices
have eight
• The Parallel Slave Port is implemented only on the 40/44-pin devices
30
PIC16F877A PINOUT DESCRIPTION
31
PIN-1 - MCLR/VPP
PIN-2- RA0/AN0
PIN-3-RA1/AN1
PIN-4- RA2/AN2/VREF-/CVREF
PIN-5-RA3/AN3 /VREF+
PIN-6- RA4/T0CKI/C1OUT
32
PIN-7- RA5/AN4/SS/C2OUT
Digital I/O. Analog input 4. SPI slave select input. Comparator 2 output.
PIN-8-RE0/RD/AN5
Digital I/O. Read control for Parallel Slave Port. Analog input 5.
PIN-9- RE1/WR/AN6
Digital I/O. Write control for Parallel Slave Port. Analog input 6.
PIN-10- RE2/CS/AN7
Digital I/O. Chip select control for Parallel Slave Port. Analog input 7.
POWER PIN
PIN-13- OSC1/CLKI
33
Oscillator crystal or external clock input. Oscillator crystal input or external clock
source input. ST buffer when configured in RC mode; otherwise CMOS. External
clock source input. Always associated with pin function OSC1 (see OSC1/CLKI,
OSC2/CLKO pins)
PIN-14- OSC2/CLKO
PIN-15- RC0/T1OSO/T1CKI
PIN-16- RC1/T1OSI/CCP2
Digital I/O. Timer1 oscillator input. Capture2 input, Compare2 output, PWM2
output.
PIN-17- RC2/CCP1
PIN-18- RC3/SCK/SCL
PIN-24- RC5/SDO
PIN-25- RC6/TX/CK
PIN-26- RC7/RX/DT
PIN-19- RD0/PSP0
PIN-20- RD1/PSP1
PIN-21- RD2/PSP2
PIN-22- RD3/PSP3
35
PIN-27- RD4/PSP4
PIN-28- RD5/PSP5
PIN-29- RD6/PSP6
PIN-30- RD7/PSP7
PIN-33- RB0/INT
PIN-34- RB1
Digital I/O.
PIN-35- RB2
Digital I/O.
PIN-36- RB3/PGM
36
Digital I/O. Low-voltage ICSP programming enable pin.
PIN-37- RB4
Digital I/O.
PIN-38- RB5
Digital I/O.
PIN-39- RB6/PGC
PIN-40- RB7/PGD
MEMORY ORGANIZATION
There are three memory blocks in each of the PIC16F87XA devices. The program
memory and data memory have separate buses so that concurrent access can occur
and is detailed in this section. The EEPROM data memory block is detailed in
“Data EEPROM and Flash Program Memory”.
37
8K words x 14 bits of Flash program memory. Accessing a location above the
physically implemented address will cause a wraparound.
The data memory is partitioned into multiple banks which contain the General Purpose Registers and the
Special Function Registers. Bits RP1 (Status<6>) and RP0 (Status<5>) are the bank select bits.
RP1:RP0 Bank
00 0
01 1
10 2
11 3
38
Each bank extends up to 7Fh (128 bytes). The lower locations of each bank are
reserved for the Special Function Registers. Above the Special Function Registers
are General Purpose Registers, implemented as static RAM. All implemented
banks contain Special Function Registers. Some frequently used Special Function
Registers from one bank may be mirrored in another bank for code reduction and
quicker access.
39
DATA EEPROM AND FLASH PROGRAM MEMORY
40
The data EEPROM and Flash program memory is readable and writable during
normal operation (over the full VDD range). This memory is not directly mapped
in the register file space. Instead, it is indirectly addressed through the Special
Function Registers. There are six
SFRs used to read and write this memory:
• EECON1
• EECON2
• EEDATA
• EEDATH
• EEADR
• EEADRH
When interfacing to the data memory block, EEDATA holds the 8-bit data for
read/write and EEADR holds the address of the EEPROM location being accessed.
These devices have 128 or 256 bytes of data EEPROM (depending on the device),
with an address range from 00h to FFh. On devices with 128 bytes, addresses from
80h to FFh are unimplemented and will wraparound to the beginning of data
EEPROM memory. When writing to unimplemented locations, the on-chip charge
pump will be turned off. When interfacing the program memory block, the
EEDATA and EEDATH registers form a two-byte word that holds the 14-bit data
for read/write and the EEADR and EEADRH registers form a two-byte word that
holds the 13-bit address of the program memory location being accessed. These
devices have 4 or 8K words of program Flash, with an address range from 0000h
to 0FFFh for the PIC16F873A/874A and 0000h to 1FFFh for the
PIC16F876A/877A. Addresses above the range of the respective device will
wraparound to the beginning of program memory. The EEPROM data memory
allows single-byte read and write. The Flash program memory allows single-word
41
reads and four-word block writes. Program memory write operations automatically
perform an erase-before write on blocks of four words. A byte write in data
EEPROM memory automatically erases the location and writes the new data
(erase-before-write). The write time is controlled by an on-chip timer. The
write/erase voltages are generated by an on-chip charge pump, rated to operate
over the voltage range of the device for byte or word operations. When the device
is code-protected, the CPU may continue to read and write the data EEPROM
memory. Depending on the settings of the write-protect bits, the device may or
may not be able to write certain blocks of the program memory; however, reads of
the program memory are allowed. When code-protected, the device programmer
can no longer access data or program memory; this does NOT inhibit internal reads
or writes.
42
EECON1 is the control register for memory accesses. Control bit, EEPGD,
determines if the access will be a program or data memory access. When clear, as it
is when reset, any subsequent operations will operate on the data memory. When
set, any subsequent operations will operate on the program memory. Control bits,
RD and WR, initiate read and write or erase, respectively. These bits cannot be
cleared, only set, in software. They are cleared in hardware at completion
of the read or write operation. The inability to clear the WR bit in software
prevents the accidental, premature termination of a write operation. The WREN
bit, when set, will allow a write or erase operation. On power-up, the WREN bit is
clear. The WRERR bit is set when a write (or erase) operation is interrupted by a
MCLR or a WDT Time-out Reset during normal operation. In these situations,
following Reset, the user can check the WRERR bit and rewrite the location. The
data and address will be unchanged in the EEDATA and EEADR registers.
Interrupt flag bit, EEIF in the PIR2 register, is set when the write is complete. It
must be cleared in software.EECON2 is not a physical register. Reading
EECON2will read all ‘0’s. The EECON2 register is used exclusively in the
EEPROM write sequence.
44
2. Write the address to EEADR. Make sure that the address is not larger than the
memory size of the device.
3. Write the 8-bit data value to be programmed in the EEDATA register.
4. Clear the EEPGD bit to point to EEPROM data memory.
5. Set the WREN bit to enable program operations.
6. Disable interrupts (if enabled).
7. Execute the special five instruction sequence:
• Write 55h to EECON2 in two steps (first to W, then to EECON2)
• Write AAh to EECON2 in two steps (first to W, then to EECON2)
• Set the WR bit
8. Enable interrupts (if using interrupts).
9. Clear the WREN bit to disable program operations.
10. At the completion of the write cycle, the WR bit is cleared and the EEIF
interrupt flag bit is set. (EEIF must be cleared by firmware.) If step 1 is not
implemented, then firmware should check for EEIF to be set, or WR to clear, to
indicate the end of the program cycle.
TIMER0 MODULE
45
Figure 5-1 is a block diagram of the Timer0 module and the prescaler shared with
the WDT.
Additional information on the Timer0 module is available in the PICmicro® Mid-
Range MCU Family Reference Manual (DS33023).
Timer mode is selected by clearing bit T0CS (OPTION_REG<5>). In Timer mode,
the Timer0 module will increment every instruction cycle (without prescaler). If
the TMR0 register is written, the increment is inhibited for the following two
instruction cycles. The user can work around this by writing an adjusted value to
the TMR0 register
Counter mode is selected by setting bit T0CS (OPTION_REG<5>). In Counter
mode, Timer0 will increment either on every rising or falling edge of pin
RA4/T0CKI. The incrementing edge is determined by the Timer0 Source Edge
Select bit, T0SE (OPTION_REG<4>). Clearing bit T0SE selects the rising edge.
TIMER1 MODULE
46
The operating mode is determined by the clock select bit, TMR1CS (T1CON<1>).
In Timer mode, Timer1 increments every instruction cycle. In Counter mode, it
increments on every rising
edge of the external clock input. Timer1 can be enabled/disabled by
setting/clearing control bit, TMR1ON (T1CON<0>). Timer1 also has an internal
“Reset input”. This Reset can be generated by either of the two CCP modules
(Section 8.0 “Capture/Compare/PWM Modules”). Register 6-1 shows the Timer1
Control register. When the Timer1 oscillator is enabled (T1OSCEN is set), the
RC1/T1OSI/CCP2 and RC0/T1OSO/T1CKI pins become inputs. That is, the
TRISC<1:0> value is ignored and these pins read as ‘0’. Additional information on
timer modules is available in the PICmicro® Mid-Range MCU Family Reference
Manual (DS33023).
TIMER2 MODULE
Timer2 is an 8-bit timer with a prescaler and a postscaler. It can be used as the
PWM time base for the PWM mode of the CCP module(s). The TMR2 register is
readable and writable and is cleared on any device Reset. The input clock
(FOSC/4) has a prescale option of 1:1, 1:4 or 1:16, selected by control bits
T2CKPS1:T2CKPS0 (T2CON<1:0>). The Timer2 module has an 8-bit period
register, PR2. A Timer2 increment from 00h until it matches PR2 and then resets to
00h on the next increment cycle. PR2 is a readable and writable register. The PR2
register is initialized to FFh upon Reset. The match output of TMR2 goes through
a 4-bit postscaler (which gives a 1:1 to 1:16 scaling inclusive) to generate a TMR2
interrupt (latched in flag bit, TMR2IF (PIR1<1>)). Timer2 can be shut-off by
clearing control bit, TMR2ON (T2CON<2>), to minimize power consumption.
47
POWER SUPPLIES
There are many types of power supply. Most are designed to convert high voltage
AC mains electricity to a suitable low voltage supply for electronics’ circuits and
other devices. A power supply can by broken down into a series of blocks, each of
which performs a particular function.
TRANSFORMER
Transformers convert AC electricity from one voltage to another with little loss of
power. Transformers work only with AC and this is one of the reasons why mains
electricity is AC.
The input coil is called the primary and the output coil is called the secondary.
There is no electrical connection between the two coils, instead they are linked by
48
an alternating magnetic field created in the soft-iron core of the transformer. The
two lines in the middle of the circuit symbol represent the core.
Transformers waste very little power so the power out is (almost) equal to the
power in. Note that as voltage is stepped down current is stepped up.
The ratio of the number of turns on each coil, called the turn’s ratio, determines the
ratio of the voltages. A step-down transformer has a large number of turns on its
primary (input) coil which is connected to the high voltage mains supply, and a
small number of turns on its secondary (output) coil to give a low output voltage.
Transformer
circuit symbol
RECTIFIER
A single diode can be used as a rectifier but this produces half-wave varying DC which
has gaps when the AC is negative. It is hard to smooth this sufficiently well to supply electronic circuits
unless they require a very small current so the smoothing capacitor does not significantly discharge
during the gaps. Please see the Diodes page for some examples of rectifier diodes.
BRIDGE RECTIFIER
A bridge rectifier can be made using four individual diodes, but it is also available in special packages
containing the four diodes required. It is called a full-wave rectifier because it uses all the AC wave (both
positive and negative sections). 1.4V is used up in the bridge rectifier because each diode uses 0.7V
when conducting and there are always two diodes conducting, as shown in the diagram below. Bridge
rectifiers are rated by the maximum current they can pass and the maximum reverse voltage they can
withstand (this must be at least three times the supply RMS voltage so the rectifier can withstand the
peak voltages). Please see the Diodes page for more details, including pictures of bridge rectifiers.
50
Bridge rectifier Output: full-wave varying DC
(using all the AC wave)
SMOOTHING (FILTER)
51
Note that smoothing significantly increases the average DC voltage to almost the
peak value (1.4 × RMS value). For example 6V RMS AC is rectified to full wave
DC of about 4.6V RMS (1.4V is lost in the bridge rectifier), with smoothing this
increases to almost the peak value giving 1.4 × 4.6 = 6.4V smooth DC.
Smoothing is not perfect due to the capacitor voltage falling a little as it discharges,
giving a small ripple voltage. For many circuits a ripple which is 10% of the
supply voltage is satisfactory and the equation below gives the required value for
the smoothing capacitor. A larger capacitor will give fewer ripples. The capacitor
value must be doubled when smoothing half-wave DC.
5 × Io
Smoothing capacitor for 10% ripple, C =
Vs × f
Voltage regulator ICs are available with fixed (typically 5, 12 and 15V) or variable
output voltages. They are also rated by the maximum current they can pass.
Negative VO
To make things really simple let’s start with a simple power supply and it is also
the one they usually give you in your first electronics project. Well the reason is
quite obvious because all electronics circuits require a DC power supply to work.
You really do plug in the wires of your electronic items in AC mains supply but
they do have AC to DC converters too provide DC to the circuits. All this is done
with a power supply in the right place.
1. Unregulated voltage in
2. Ground
53
Voltage regulator
This circuit is a small +5V power supply. The circuit will provide a regulated
voltage to the external circuit which may also I am required in any part of the
external circuit or the whole external circuit. The best part is that you can also use
it to convert AC voltage to DC and then regulate it ,simply You need a transformer
to make the AC main drop down to a safe value i.e 12-15 volts and then us a
rectifier to convert AC into DC.
54
This circuit can give +5V output at about 150 mA current, but it can be increased
to 1 A when good cooling is added to 7805 regulator chip. The circuit has over
overload and terminal protection. The capacitors must have enough high voltage
rating to safely handle the input voltage feed to circuit. The circuit is very easy to
build for example into a piece of overboard.
If you need other voltages than +5V, you can modify the circuit by replacing the
7805 chips with another regulator with different output voltage from regulator
78xx chip family. The last numbers in the chip code tells the output voltage.
Remember that the input voltage must be at least 3V greater than regulator output
voltage to otherwise the regulator does not work well. Don’t forget to check the pin
diagram before connecting the IC.
TRANSFORMER ONLY
The low voltage AC output is suitable for lamps, heaters and special AC motors. It
is not suitable for electronic circuits unless they include a rectifier and a smoothing
capacitor.
55
TRANSFORMER + RECTIFIER
The varying DC output is suitable for lamps, heaters and standard motors. It is not
suitable for electronic circuits unless they include a smoothing capacitor.
The smooth DC output has a small ripple. It is suitable for most electronic circuits.
56
The regulated DC output is very smooth with no ripple. It is suitable for all
electronic circuits.
Circuit Diagram:
Circuit Description:
The 230/240VAC line voltage is applied to the transformer primary. Step down
transformer is used to convert 230VAC to 12V/1A output voltage in the
transformer secondary. This 12VAC supply is applied to the bridge rectifier. The
bridge rectifier voltage rating should be double the Vrms of secondary AC and
higher forward current rating. The bridge rectifier has four diodes in that, available
57
as singular. This is the most important and it produces full-wave varying DC or
pulsating DC. This rectified output is smoothed by using shunt capacitor filter
(C1). The larger the filter capacitor lowers the ripple. The larger capacitor C1
across the input bypasses AC ripples to ground. The pure DC output reaches the
regulator IC. The 7805 Voltage regulator IC (U1) gives 5V /1A regulated output.
The capacitor (C2) across the output improves transient response. Low power red
LED is used in the output for power indication. It has voltage drop of 1.8V and
gives brightness at 20 mA. This is done by current limiting resistor (R1).
R = (Vout – Vf) / I
Where, Vout –output voltage; Vf- led voltage drop; I- led forward current.
From this we get R as 160E. We use the standard value of 220E. The higher value
of limiting resistor gives low brightness but longer life time. So, here 470E is used.
RELAY
A type of relay that can handle the high power required to directly control an
electric motor or other loads is called a contactor. Solid-state relays control power
58
circuits with no moving parts, instead using a semiconductor device to perform
switching. Relays with calibrated operating characteristics and sometimes multiple
operating coils are used to protect electrical circuits from overload or faults; in
modern electric power systems these functions are performed by digital
instruments still called "protective relays".
When a coil of wire is wound on a non magnetic material such as plastic, paper
etc., it is called a air-core solenoid or simply a solenoid .if a soft iron core is
inserted into the coil, it becomes an electromagnet. This electromagnet is the basic
component for relay and many other electromechanical devices such as electric
bell, circuit breaker etc,.
Operation
59
When a current flows through the coil, the resulting magnetic field attracts an
armature that is mechanically linked to a moving contact. The movement either
makes or breaks a connection with a fixed contact. When the current to the coil is
switched off, the armature is returned by a force approximately half as strong as
the magnetic force to its relaxed position. Usually this is a spring, but gravity is
also used commonly in industrial motor starters. Most relays are manufactured to
operate quickly. In a low voltage application, this is to reduce noise. In a high
voltage or high current application, this is to reduce arcing.
If the coil is energized with DC, a diode is frequently installed across the coil, to
dissipate the energy from the collapsing magnetic field at deactivation, which
would otherwise generate a spike of voltage and might cause damage to circuit
components. Some automotive relays already include that diode inside the relay
case. If the coil is designed to be energized with AC, a small copper ring can be
crimped to the end of the solenoid. This “shading ring” creates a small out-of-
phase current, which increases the minimum pull on the armature during the AC
cycle by analogy with the functions of the original electromagnetic device; a solid-
state relay is made with a thyristor or other solid-state switching device. To achieve
electrical isolation, a light-emitting diode (LED) is used with a photo transistor.
Types
Latching relay
60
Latching relay with permanent magnet
A latching relay has two relaxed states (bi-stable). These are also called "impulse",
"keep", or "stay" relays. When the current is switched off, the relay remains in its
last state. This is achieved with a solenoid operating a ratchet and cam mechanism,
or by having two opposing coils with an over-center spring or permanent magnet to
hold the armature and contacts in position while the coil is relaxed, or with a
remanent core. In the ratchet and cam example, the first pulse to the coil turns the
relay on and the second pulse turns it off. In the two coil example, a pulse to one
coil turns the relay on and a pulse to the opposite coil turns the relay off. This type
of relay has the advantage that one coil consumes power only for an instant, while
it is being switched, and the relay contacts retain this setting across a power
outage. A remanent core latching relay requires a current pulse of opposite polarity
to make it change state.
Reed relay
A reed relay is a reed switch enclosed in a solenoid. The switch has a set of
contacts inside an evacuated or inert gas-filled glass tube which protects the
contacts against atmospheric corrosion; the contacts are made of magnetic material
that makes them move under the influence of the field of the enclosing solenoid.
Reed relays can switch faster than larger relays, require only little power from the
control circuit, but have low switching current and voltage ratings. In addition, the
reeds can become magnetized over time, which makes them stick 'on' even when
no current is present; changing the orientation of the reeds with respect to the
solenoid's magnetic field will fix the problem.
61
Top, middle: reed switches, bottom: reed relay
Mercury-wetted relay
A mercury-wetted reed relay is a form of reed relay in which the contacts are
wetted with mercury. Such relays are used to switch low-voltage signals (one volt
or less) where the mercury reduces the contact resistance and associated voltage
drop, for low-current signals where surface contamination may make for a poor
contact, or for high-speed applications where the mercury eliminates contact
bounce. Mercury wetted relays are position-sensitive and must be mounted
vertically to work properly. Because of the toxicity and expense of liquid mercury,
these relays are now rarely used. See also mercury switch.
Polarized relay
A polarized relay placed the armature between the poles of a permanent magnet to
increase sensitivity. Polarized relays were used in middle 20th Century telephone
exchanges to detect faint pulses and correct telegraphic distortion. The poles were
on screws, so a technician could first adjust them for maximum sensitivity and then
apply a bias spring to set the critical current that would operate the relay.
62
Machine tool relay
A machine tool relay is a type standardized for industrial control of machine tools,
transfer machines, and other sequential control. They are characterized by a large
number of contacts (sometimes extendable in the field) which are easily converted
from normally-open to normally-closed status, easily replaceable coils, and a form
factor that allows compactly installing many relays in a control panel. Although
such relays once were the backbone of automation in such industries as automobile
assembly, the programmable logic controller (PLC) mostly displaced the machine
tool relay from sequential control applications.
Ratchet relay
This is again a clapper type relay which does not need continuous current through
its coil to retain its operation.
Contactor relay
63
A contactor is a very heavy-duty relay used for switching electric motors and
lighting loads, although contactors are not generally called relays. Continuous
current ratings for common contactors range from 10 amps to several hundred
amps. High-current contacts are made with alloys containing silver. The
unavoidable arcing causes the contacts to oxidize; however, silver oxide is still a
good conductor.[2] Such devices are often used for motor starters. A motor starter is
a contactor with overload protection devices attached. The overload sensing
devices are a form of heat operated relay where a coil heats a bi-metal strip, or
where a solder pot melts, releasing a spring to operate auxiliary contacts. These
auxiliary contacts are in series with the coil. If the overload senses excess current
in the load, the coil is de-energized. Contactor relays can be extremely loud to
operate, making them unfit for use where noise is a chief concern.
Solid-state relay
A solid state relay (SSR) is a solid state electronic component that provides a
similar function to an electromechanical relay but does not have any moving
components, increasing long-term reliability. With early SSR's, the tradeoff came
from the fact that every transistor has a small voltage drop across it. This voltage
drop limited the amount of current a given SSR could handle. The minimum
voltage drop for such a relay is equal to the voltage drop across one transistor
(~0.6-2.0 volts), and is a function of the material used to make the transistor
(typically silicon). As transistors improved, higher current SSR's, able to handle
100 to 1,200 Amperes, have become commercially available. Compared to
electromagnetic relays, they may be falsely triggered by transients.
64
Solid state relay with no moving parts
A solid state contactor is a heavy-duty solid state relay, including the necessary
heat sink, used for switching electric heaters, small electric motors and lighting
loads; where frequent on/off cycles are required. There are no moving parts to wear
out and there is no contact bounce due to vibration. They are activated by AC
control signals or DC control signals from Programmable logic controller (PLCs),
PCs, Transistor-transistor logic (TTL) sources, or other microprocessor and
microcontroller controls.
65
Buchholz relay
A Buchholz relay is a safety device sensing the accumulation of gas in large oil-
filled transformers, which will alarm on slow accumulation of gas or shut down the
transformer if gas is produced rapidly in the transformer oil. it is connected in
between conservator tank and main tank. it is use in above 750 kva transformer.
This relay is developed by max buchholz
A forced-guided contacts relay has relay contacts that are mechanically linked
together, so that when the relay coil is energized or de-energized, all of the linked
contacts move together. If one set of contacts in the relay becomes immobilized, no
other contact of the same relay will be able to move. The function of forced-guided
contacts is to enable the safety circuit to check the status of the relay. Forced-
guided contacts are also known as "positive-guided contacts", "captive contacts",
"locked contacts", or "safety relays".
Electric motors need over current protection to prevent damage from over-loading
the motor, or to protect against short circuits in connecting cables or internal faults
in the motor windings. One type of electric motor overload protection relay is
operated by a heating element in series with the electric motor. The heat generated
66
by the motor current heats a bimetallic strip or melts solder, releasing a spring to
operate contacts. Where the overload relay is exposed to the same environment as
the motor, a useful though crude compensation for motor ambient temperature is
provided.
Since relays are switches, the terminology applied to switches is also applied to
relays. A relay will switch one or more poles, each of whose contacts can be
thrown by energizing the coil in one of three ways:
Normally-open (NO) contacts connect the circuit when the relay is activated; the
circuit is disconnected when the relay is inactive. It is also called a Form A contact
or “make” contact.
Normally-closed (NC) contacts disconnect the circuit when the relay is activated;
the circuit is connected when the relay is inactive. It is also called a Form B contact
or “break” contact.
SPST – Single Pole Single Throw. These have two terminals which can be
connected or disconnected. Including two for the coil, such a relay has four
terminals in total. It is ambiguous whether the pole is normally open or normally
closed. The terminology “SPNO” and “SPNC” is sometimes used to resolve the
ambiguity.
67
SPDT – Single Pole Double Throw. A common terminal connects to either of two
others. Including two for the coil, such a relay has five terminals in total.
DPST – Double Pole Single Throw. These have two pairs of terminals. Equivalent
to two SPST switches or relays actuated by a single coil. Including two for the coil,
such a relay has six terminals in total. It is ambiguous whether the poles are
normally open, normally closed, or one of each.
DPDT – Double Pole Double Throw. These have two rows of change-over
terminals. Equivalent to two SPDT switches or relays actuated by a single coil.
Such a relay has eight terminals, including the coil.
QPDT - Quadruple Pole Double Throw. Often referred to as Quad Pole Double
Throw, or 4PDT. These have four rows of change-over terminals. Equivalent to
four SPDT switches or relays actuated by a single coil or two DPDT relays. In
total, fourteen terminals including the coil
RELAY DRIVER
68
PMOS, NMOS - which operate at low voltages and low currents) and acts as a
relay of sorts itself, switching on or off a higher level signal on the opposite side.
A TTL signal operates from 0-5V, with everything between 0.0 and 0.8V
considered "low" or off, and 2.2 to 5.0V being considered "high" or on. The
maximum power available on a TTL signal depends on the type, but generally does
not exceed 25mW (~5mA @ 5V), so it is not useful for providing power to
something like a relay coil. Computers and other electronic devices frequently
generate TTL signals. On the output side the ULN2803 is generally rated at
50V/500mA, so it can operate small loads directly. Alternatively, it is frequently
used to power the coil of one or more relays, which in turn allow even higher
voltages/currents to be controlled by the low level signal. In electrical terms, the
ULN2803 uses the low level (TTL) signal to switch on/turn off the higher
voltage/current signal on the output side.
ULN2803
The eight NPN Darlington connected transistors in this family of arrays are ideally
suited for interfacing between low logic level digital circuitry (such as TTL,
CMOS or PMOS/NMOS) and the higher current/voltage requirements of lamps,
relays, printer hammers or other similar loads for a broad range of computer,
69
industrial, and consumer applications. All devices feature open–collector outputs
and freewheeling clamp diodes for transient suppression. The ULN2803 is
designed to be compatible with standard TTL families while the ULN2804 is
optimized for 6 to 15 volt high level CMOS or PMOS.
MOTOR
70
in large sizes to operate steel rolling mills and paper machines. Modern DC motors
are nearly always operated in conjunction with power electronic devices.
71
Let's start by looking at a simple 2-pole DC electric motor (here red represents a
magnet or winding with a "North" polarization, while green represents a magnet or
winding with a "South" polarization).
Every DC motor has six basic parts -- axle, rotor (a.k.a., armature), stator,
commutator, field magnet(s), and brushes. In most common DC motors (and all
that Beamers’ will see), the external magnetic field is produced by high-strength
permanent magnets1. The stator is the stationary part of the motor -- this includes
the motor casing, as well as two or more permanent magnet pole pieces. The rotor
(together with the axle and attached commutator) rotates with respect to the stator.
The rotor consists of windings (generally on a core), the windings being
electrically connected to the commutator. The above diagram shows a common
motor layout -- with the rotor inside the stator (field) magnets.
The geometry of the brushes, commutator contacts, and rotor windings are such
that when power is applied, the polarities of the energized winding and the stator
magnet(s) are misaligned, and the rotor will rotate until it is almost aligned with
the stator's field magnets. As the rotor reaches alignment, the brushes move to the
next commutator contacts, and energize the next winding. Given our example two-
pole motor, the rotation reverses the direction of current through the rotor winding,
leading to a "flip" of the rotor's magnetic field, driving it to continue rotating.
72
In real life, though, DC motors will always have more than two poles (three is a
very common number). In particular, this avoids "dead spots" in the commutator.
You can imagine how with our example two-pole motor, if the rotor is exactly at
the middle of its rotation (perfectly aligned with the field magnets), it will get
"stuck" there. Meanwhile, with a two-pole motor, there is a moment where the
commutator shorts out the power supply (i.e., both brushes touch both commutator
contacts simultaneously). This would be bad for the power supply, waste energy,
and damage motor components as well. Yet another disadvantage of such a simple
motor is that it would exhibit a high amount of torque "ripple" (the amount of
torque it could produce is cyclic with the position of the rotor).
One pole is fully energized at a time (but two others are "partially" energized). As
each brush transitions from one commutator contact to the next, one coil's field
will rapidly collapse, as the next coil's field will rapidly charge up (this occurs
within a few microsecond). We'll see more about the effects of this later, but in the
meantime you can see that this is a direct result of the coil windings' series wiring:
73
There's probably no better way to see how an average DC motor is put together,
than by just opening one up. Unfortunately this is tedious work, as well as
requiring the destruction of a perfectly good motor.
Luckily for you, I've gone ahead and done this in your stead. The guts of a
disassembled Mabuchi FF-030-PN motor (the same model that Solarbotics sells)
are available for you to see here (on 10 lines / cm graph paper). This is a basic 3-
pole DC motor, with 2 brushes and three commutator contacts.
The use of an iron core armature (as in the Mabuchi, above) is quite common, and
has a number of advantages2. First off, the iron core provides a strong, rigid
support for the windings -- a particularly important consideration for high-torque
motors. The core also conducts heat away from the rotor windings, allowing the
motor to be driven harder than might otherwise be the case. Iron core construction
is also relatively inexpensive compared with other construction types.
But iron core construction also has several disadvantages. The iron armature has a
relatively high inertia which limits motor acceleration. This construction also
results in high winding inductances which limit brush and commutator life.
74
DC MOTOR BEHAVIOR
High-speed output
This is the simplest trait to understand and treat -- most DC motors run at very high
output speeds (generally thousands or tens of thousands of RPM). While this is fine
for some BEAM bots (say, photo poppers or solar rollers), many BEAM bots
(walkers, heads) require lower speeds -- you must put gears on your DC motor's
output for these applications.
Back EMF
Just as putting voltage across a wire in a magnetic field can generate motion,
moving a wire through a magnetic field can generate voltage. This means that as a
DC motor's rotor spins, it generates voltage -- the output voltage is known as back
EMF. Because of back EMF, a spark is created at the commutator as a motor's
brushes switch from contact to contact. Meanwhile, back EMF can damage
sensitive circuits when a motor is stopped suddenly.
A number of things will cause a DC motor to put noise on its power lines:
commutation noise (a function of brush / commutator design & construction),
75
roughness in bearings (via back EMF), and gearing roughness (via back EMF, if
the motor is part of a gear motor) are three big contributors.
Even without these avoidable factors, any electric motor will put noise on its
power lines by virtue of the fact that its current draw is not constant throughout its
motion. Going back to our example two-pole motor, its current draw will be a
function of the angle between its rotor coil and field magnets:
Since most small DC motors have 3 coils, the coils' current curves will overlay
each other:
Added together, this ideal motor's current will then look something like this:
76
Reality is a bit more complex than this, as even a high-quality motor will display a
current transient at each commutation transition. Since each coil has inductance
(by definition) and some capacitance, there will be a surge of current as the
commentator’s brushes first touch a coil's contact, and another as the brushes leave
the contact (here, there's a slight spark as the coil's magnetic field collapses).
In this case, the peak-to-peak current ripple is approximately 0.29 mA, while the
average motor current is just under 31 mA. So under these conditions, the motor
puts about less than 1% of current ripple onto its power lines (and as you can see
from the "clean" traces, it outputs essentially no high-frequency current noise).
Note that since this is a 3-pole motor, and each coil is energized in both directions
over the course of a rotor rotation, one revolution of the rotor will correspond to
six of the above curves (here, 6 x 2.4 ms = 0.0144 sec, corresponding to a motor
rotation rate of just under 4200 RPM).
77
PARAMETERIZING DC MOTOR PERFORMANCE
as you tinker around with DC motors, you'll start to run across some interesting
relationships. Namely you'll discover that torque and current are linearly
proportional to each other, as are speed and voltage. Under a fixed load (torque),
voltage and current will also be proportional to each other.
Digging into the math (and I'll spare you this), it turns out that the current a motor
draws is ultimately determined by the torque the motor produces. The generated
torque is dependent upon the current I, and factors determined by the materials and
internal geometry of the motor. Since the construction of a finished motor will not
(!) change during operation, a constant of proportionality between the motor
current and the materials / geometry dependent factors can be calculated for a
given motor. This constant, the torque constant Kt, describes the torque generated
by the motor for a specific motor current:
Kt = T / I
Because of the interrelationship of torque, speed, current, and voltage, the constant
current operation of a DC motor produces constant output torque regardless of
speed. Given a constant load (i.e. torque) the speed of a motor is solely dependent
78
on the voltage applied to the motor. For DC motors operated at a constant voltage,
the speed and torque produced are inversely related (the higher the torque, the
lower the speed of the motor).
We earlier saw that an EMF will be developed across a motor's brushes when its
coil is rotated by an external torque -- the magnitude of this EMF is dependent
upon materials / geometry factors, and upon the speed at which the coil is rotated.
Once again, there is a constant of proportionality which describes the relationship
between coil rotational speed and materials / geometry factors, commonly known
as the back EMF constant (Ke). The back EMF constant is typically given in volts
per unit of rotational speed (which in turn is generally expressed either in RPM or
radians / second).
If one takes the reciprocal of the back EMF constant, the result is a proportionality
constant which relates the voltage applied to the motor terminals to the rotational
speed of the coil. This version of the motor constant is commonly known as the
velocity constant, Kv. The velocity constant is given in units of rotational speed
(again, either RPM or radians / second) per volt.
Since the motor construction does not change, regardless of what we're measuring,
it turns out that these three constants (Kt, Ke, Kv) are all essentially the same
number. The differences between the torque constant and the back EMF constant
are simply a matter of the units used, while the velocity constant is simply a useful
form of the back EMF constant.
If the torque constant is specified in N-m / A and the back EMF constant in V-sec /
rad, then:
Kt = Ke = 1 / Kv
79
Those of us who live in the U.S., though, are stuck with using more colorful units.
Commonly used units for small motors are oz-in for torque and RPM for rotational
speed. Using these units of measure, torque constants are often given in oz-in / A,
back EMF constants in mV / RPM, and velocity constants in RPM / V. In imperial
units, the relationships between motor constants are then as follows:
With
Kt in units of oz-in / A
Ke in units of mV / RPM
Kv in units of RPM / volt
Then
Kt = 1352.4 / Kv
Ke= Kt / 1.3524
Ke = 1000 / Kv
Kv = 1000 / Ke
So what good is all this? It means that given a source of known rotational speed
(an electric drill, or drill press if you have one), you can compute Ke for a given
motor (clamp the motor shaft in the drill's jaws, measure the resulting open-circuit
voltage, then do the math).
Ke, along with the above information will then give you Kt (so you can compute
your motor's theoretical torque at any given current), and Kv (so you can compute
your motor's maximum speed at any given voltage). If you can measure stall
80
torque, you can then compute motor efficiency (measured torque expressed as a
percentage of the theoretical torque).
MOTOR DRIVER
The L293 and L293D are quadruple high-current half-H drivers. The L293 is
designed to provide bidirectional drive currents of up to 1 A at voltages from 4.5 V
to 36 V. The L293D is designed to provide bidirectional drive currents of up to
600-mA at voltages from 4.5 V to 36 V. Both devices are designed to drive
inductive loads such as relays, solenoids, dc and bipolar stepping motors, as well
as other high-current/high-voltage loads in positive-supply applications. All inputs
are TTL compatible. Each output is a complete totem-pole drive circuit, with a
Darlington transistor sink and a pseudo- Darlington source. Drivers are enabled in
pairs, with drivers 1 and 2 enabled by 1,2EN and drivers 3 and 4 enabled by
3,4EN. When an enable input is high, the associated drivers are enabled, and their
outputs are active and in phase with their inputs. When the enable input is low,
those drivers are disabled, and their outputs are off and in the high-impedance
state. With the proper data inputs, each pair of drivers forms a full-H (or bridge)
reversible drive suitable for solenoid or motor applications.
81
Featuring Unitrode L293 and L293D
Thermal Shutdown
High-Noise-Immunity Inputs
Logic diagram
RF MODULE
83
system, the digital data is represented as variations in the amplitude of carrier
wave. This kind of modulation is known as Amplitude Shift Keying (ASK).
84
The RF module is often used along with a pair of encoder/decoder. The
encoder is used for encoding parallel data for transmission feed while reception is
decoded by a decoder. HT12E-HT12D, HT640-HT648, etc. are some commonly
used encoder/decoder pair ICs.
The 212 decoders are a series of CMOS LSIs for remote control system
applications. They are paired with Holtek’s 212 series of encoders. For proper
operation, a pair of encoder/decoder with the same number of addresses and data
format should be chosen. The decoders receive serial addresses and data from a
programmed 212 series of encoders that are transmitted by a carrier using an RF or
an IR transmission medium. They compare the serial input data three times
continuously with their local addresses. If no error or unmatched codes are found,
the input data codes are decoded and then transferred to the output pins. The VT
pin also goes high to indicate a valid transmission. The 212 series of decoders are
capable of decoding information’s that consist of N bits of address and 12-N bits of
data. Of this series, the HT12D is arranged to provide 8 address bits and 4 data
bits, and HT12F is used to decode 12 bits of address information.
85
4.4.1.2 Features
86
Figure 4.11 Pin Diagram for HT12D
A0~A7 (HT12D) - Input pins for address A0~A7 setting these pins can be
externally set to VSS or left open.
D8~D11 (HT12D) - Output data pins, power-on state is low. CMOS OUT
DIN- Serial data input pin CMOS IN
VT - Valid transmission, active high CMOS OUT
OSC1 - Oscillator input pin
OSC2 - Oscillator output pin
VSS - Negative power supply, ground
VDD- Positive power supply
The 212 encoders are a series of CMOS LSIs 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 38 kHz carrier for infrared systems.
4.4.2.2 Features
Operating voltage
o 2.4V~12V for the HT12E
87
Low power and high noise immunity CMOS technology
Low standby current: 0.1A (typ.) at VDD=5V
HT12A with a 38 kHz carrier for infrared transmission medium
Minimum transmission word: Four words for the HT12E
Built-in oscillator needs only 5% resistor
Data code has positive polarity
Minimal external components
Pair with Holtek’s 212 series of decoders
18-pin DIP, 20-pin SOP package
A0~A7 (HT12E) - Input pins for address A0~A7 setting these pins can be
externally set to VSS or left open.
AD8~AD11 (HT12E) - Input pins for data D8~D11 setting and transmission
enable, active low CMOS IN Pull high
DOUT- Encoder data serial transmission output CMOS OUT
TE - Transmission enable, active low CMOS IN Pull high
88
OSC1 - Oscillator input pin
OSC2 - Oscillator output pin
VSS - Negative power supply, ground
VDD- Positive power supply
RF Transmitter RF Receiver
434MHZ Serial data 434MHZ
Encoder Decoder
HT12E HT12D
In this document
89
Using the Step Counter Sensor
Sensor
SensorEvent
SensorManager
SensorEventListener
Related samples
Accelerometer Play
See also
Sensors
Sensors Overview
Position Sensors
Environment Sensors
90
The Android platform provides several sensors that let you monitor the motion of a
device.
The gravity, linear acceleration, rotation vector, significant motion, step counter,
and step detector sensors are either hardware-based or software-based.
Motion sensors are useful for monitoring device movement, such as tilt, shake,
rotation, or swing. The movement is usually a reflection of direct user input (for
example, a user steering a car in a game or a user controlling a ball in a game), but
it can also be a reflection of the physical environment in which the device is sitting
(for example, moving with you while you drive your car). In the first case, you are
monitoring motion relative to the device's frame of reference or your application's
frame of reference; in the second case you are monitoring motion relative to the
world's frame of reference. Motion sensors by themselves are not typically used to
monitor device position, but they can be used with other sensors, such as the
91
geomagnetic field sensor, to determine a device's position relative to the world's
frame of reference (see Position Sensors for more information).
All of the motion sensors return multi-dimensional arrays of sensor values for each
SensorEvent. For example, during a single sensor event the accelerometer returns
acceleration force data for the three coordinate axes, and the gyroscope returns rate
of rotation data for the three coordinate axes. These data values are returned in a
float array (values) along with other SensorEvent parameters. Table 1 summarizes
the motion sensors that are available on the Android platform.
Where the magnitude of the rotation vector is equal to sin(θ/2), and the direction of the rotation
vector is equal to the direction of the axis of rotation.
92
Figure 1. Coordinate system used by the rotation vector sensor.
The three elements of the rotation vector are equal to the last three components of a
unit quaternion (cos(θ/2), x*sin(θ/2), y*sin(θ/2), z*sin(θ/2)). Elements of the
rotation vector are unitless. The x, y, and z axes are defined in the same way as the
acceleration sensor. The reference coordinate system is defined as a direct
orthonormal basis (see figure 1). This coordinate system has the following
characteristics:
X is defined as the vector product Y x Z. It is tangential to the ground at the
device's current location and points approximately East.
Y is tangential to the ground at the device's current location and points
toward the geomagnetic North Pole.
Z points toward the sky and is perpendicular to the ground plane.
The Android SDK provides a sample application that shows how to use the rotation
vector sensor. The sample application is located in the API Demos code ( OS -
RotationVectorDemo).
9.1 COMPILER
93
3. Click on the Project menu from the title bar
5. Save the Project by typing suitable project name with no extension in u r own folder
sited in either C:\ or D:\
94
6. Then Click on Save button above.
95
10. Then Click on “OK”
14. Now double click on the Target1, you would get another option “Source group 1” as
shown in next page.
96
15. Click on the file option from menu bar and select “new”.
16. The next screen will be as shown in next page, and just maximize it by double
clicking on its blue boarder.
97
17. Now start writing program in either in “EMBEDDED C” or “ASM”.
18. For a program written in Assembly, then save it with extension “. asm” and for
“EMBEDDED C” based program save it with extension “ .C”
19. Now right click on Source group 1 and click on “Add files to Group Source”.
98
20. Now you will get another window, on which by default “EMBEDDED C” files will
appear.
21. Now select as per your file extension given while saving the file
23. Now Press function key F7 to compile. Any error will appear if so happen.
99
24. If the file contains no error, then press Control+F5 simultaneously.
27. Now click on the Peripherals from menu bar, and check your required port as shown
in fig below.
100
28. Drag the port a side and click in the program file.
29. Now keep Pressing function key “F11” slowly and observe.
101