Hardware

fiercebunElectronics - Devices

Nov 2, 2013 (3 years and 5 months ago)

63 views

216.382 Microcontroller Application


Group A


Project: Water flow meter

Pr
esentation



Group Member: Mantang KE, Dan, Jia Xu


Page
1

of
7





Analogue Input


Introduction:


Group
A’s project is to design a ‘Water Flow Meter’ for a rain water system.


The water flow
meter
is an

important aspect of the system as it can be used to monitor
the influx of rain water into the
system
when attached to the input pipe, o
r ensure
faultless supply of the water when attached to the outflow pipe of
the
system.



Design O
verview
:


The design focus for this project was the relationship that DC voltage ou
tput is
proportional to the

speed of rotation of the generator.




E
=
Blv



Where:

E
is the induced e.m.f


B

is the flux density (T)


l
is the length of the conductor in the magnetic field (m)



v
is the velocity (m/s)


Th
e

varying DC

voltage

with speed
could then be

used as the analogue input into the
microcontroller and
conv
erted into a digital signal to drive a seven segment display.



Block Diagram:










Power
Supply

10V


µPC78L05J

5V Regulator

First
Motor

(Turbine)


Second
Motor

(DC generator)


Filter

&
Protection



MIC
RO

ADC

seven

segment
display

216.382 Microcontroller Application


Group A


Project: Water flow meter

Pr
esentation



Group Member: Mantang KE, Dan, Jia Xu


Page
2

of
7


Hardware Design:


Lab Tests
:



The DC Generator Output


The picture below shows the DC generator output be
fore any signal
conditioning circuitry is added. The oscilloscope shows an inverted full
-
wave
rectified
output;

note the amount of noise evident in the waveform. Further
testing sh
owed the DC content of the wave
form increased as the RPM

of the
generator in
creased.













216.382 Microcontroller Application


Group A


Project: Water flow meter

Pr
esentation



Group Member: Mantang KE, Dan, Jia Xu


Page
3

of
7


Analogue Input

Circuitry
:



The actual system uses a turbine as a mechanical transducer
,

converting the
movement of t
he water into mechanical
energy;

this in

turn drives a small DC
generato
r (DC motor working in reverse).
In

order t
o replicate the turbine

an
additional small DC motor is used to provide the mechanical energy to drive the
DC generator. Upon measuring the output of this signal with the oscilloscope,
we found that it
was necessary to add

the following signal conditioning

components
:



1.

C
noise


-

0.01µ
F

noise suppression cap


(see microcontroller)
.



2.

D1
diode
-

Back

EMF protection diode
.


T
his is used in case

the turbine

suddenly stops

due to

a

foreign
object

in
the water supply
, thus

causing an instant collapse of

the magn
etic field
of the generator
inducing a
high voltage
reverse polarity
spike

(
V=

-
L
di/
dt
)

potentially damaging the microcontroller
.


3.

C
filter
-

reservoir capacitor
.


T
o smooth the
full
-
wave rectified
voltage
outpu
t from the DC generator.
This capacitor value

was found
via experimentation in the lab using
range of capacitor values. The 470µF capacitor gave the requi
red
smooth DC output voltage. (
Xc

= 1/2
π
f
C
) as

capacitance increases
capacitor reactance

decreases

thus filtering the ripple frequency
.

Also
the

formulae for voltage
in

a capacitor
V=Q/C
,

where Q is charge
loss,

shows as the capacitance increases the voltage

reduction

decreases.

Working voltage

of the capacitor should be ≥ 10V


4.

D4
diod
e

& D5
diode
-

I
nput protection circuit


Protection f
or the A/D converter and

the HC08QY4 microcontroller
(a
clamp system)
, consist
ing of two diodes
-

it clamps the voltage input
range to approximately 0V


5V. If
the analogue input increases to 5.6V
the upper diode will conduct clamping the input to the
+5V
supply rail,
if the input drops below 0V to
-
0.6V

then the lower diode conducts
clamping the input to ground potential
.


(Note all diodes rated at 7A insures t
hat they will adequately handle any high currents)


216.382 Microcontroller Application


Group A


Project: Water flow meter

Pr
esentation



Group Member: Mantang KE, Dan, Jia Xu


Page
4

of
7





Schematic Diagram

of analogue input

















216.382 Microcontroller Application


Group A


Project: Water flow meter

Pr
esentation



Group Member: Mantang KE, Dan, Jia Xu


Page
5

of
7




HC08QY4
M
icrocontroller:


The conditioned

analogue signal

of this generator
must be

measured
by the
HC08QY4 microcontroller and
display

it
on a
7 segment display.

This can be
done by using o
ne of the six ADC

converter channels and using one of the
output ports to drive the display


T
he output pins of the microcontroller are limited to about 20mA

sourcing &

sinking current (possibly a little more w
ith sinking)


1.

Pin 12 is used as the analogue input on the micro
controller

as according
to the data sheet this pin has a priority
for

Analogue to Digital
conversion
. The rest of the functions of this pin will be disabled by the
software
program

i.e. keyboar
d interrupt etc
.
(pg 20 of data sheet)


2.

According to the datasheet (p46), a 0.01uF capacitor can be used to
improve the performance of ADC

by reducing
noise;

i
t needs to be
placed as close a
s possible to the package pins. Since the microcontroller
board is
already populated, the cap was placed at the source of the noise
i.e. at the DC generator.


3.

The analogue
input
voltage

to the
microcontroller must

lie between
VDD and VSS in order to give an accurate
conversion;

hence

the
clamping helps insure this (pg 37)
. The analogue to digital conversion
will be done in the 8
-
bit mode, since we only have a 7 bit output to the
display.


4.

Port B (B0
-
B7) will be configured as an output via the DDR data
direction register
and
used to drive the display with B7 used to switch
between the two seven segment displays, since B7 is just the decimal
place LED.


5.

The power supply for the micro is provided by the µPC78L05J 5V
regulator;

this nominally works of a 10V supply according to its data
sheet.

It is

vital to put a 0.1µF across
VDD

and VSS
pins of the
microcontroller
(this is provided by the board design already)
. The
following

caps
and
diode
s

may be required to protect

against the power
supply used with the project.








216.382 Microcontroller Application


Group A


Project: Water flow meter

Pr
esentation



Group Member: Mantang KE, Dan, Jia Xu


Page
6

of
7







6.

All unused pins of the microcontroller will be ma
de an input and
internally held high

by the pull up enable registers
, as

unused pins must
never be connected directly to the supply rail or ground.
(pg 20 of data
sheet)
















216.382 Microcontroller Application


Group A


Project: Water flow meter

Pr
esentation



Group Member: Mantang KE, Dan, Jia Xu


Page
7

of
7


Display
Output:


Schematic Diagram







Seven segment display output


C
omponents Chosen


R0 to R6 are all have the same
value;

they

are

u
sed to protect the
microcontroller output by

limit
ing

the output current

to

less than 20mA.
Typically

10mA

into each LED
branch
in the

7
-
segment

display

(
Internet
source
)

so in this case we
will use

10mA.








So, Ro, R1, R2, R3, R4, R5 and R6 are 360 ohms.


BC327 is a genetic PNP type transistor. It has
absolute maximum Ic of 8
00mA,
at saturation Ib=
-
50mA and Ic=
-
500mA






So, Rb =100 Ohm.

Since total current from 7
-
segment pass throu
gh transistor is 7x10mA=70mA,
Rc or the load resistor is not required as the current is limited at the
microcontroller end.