Download The Improved Parking Meter - Preston M. Green Electrical

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Sound level meter wikipedia , lookup

Resistive opto-isolator wikipedia , lookup

Alternating current wikipedia , lookup

Pulse-width modulation wikipedia , lookup

Immunity-aware programming wikipedia , lookup

Peak programme meter wikipedia , lookup

Switched-mode power supply wikipedia , lookup

Buck converter wikipedia , lookup

Metadyne wikipedia , lookup

Multimeter wikipedia , lookup

Opto-isolator wikipedia , lookup

Transcript
Washington University in St. Louis
School of Engineering and Applied Science
Electrical and Systems Engineering Department
ESE498
Ultrasonic Sensometer: The
Improved Parking Meter
By
Ruth Nan, Sydney Saito, and Kaichen Zhang
Supervisor
Robert Morley
Submitted in Partial Fulfillment of the Requirement for the BSEE
Degree,
Electrical and Systems Engineering Department, School of
Engineering and Applied Science,
Washington University in St. Louis
May 2012
Table&of&Contents&
Problem Statement .......................................................................................................................... 3!
Problem Formulation ...................................................................................................................... 3!
Project Specifications...................................................................................................................... 4!
General Design Specifications .................................................................................................... 4!
Sensor Specifications .................................................................................................................. 4!
Battery Specifications ................................................................................................................. 4!
LED Specifications ..................................................................................................................... 5!
Concept Synthesis ........................................................................................................................... 6!
Literature Review........................................................................................................................ 6!
Concept Generation .................................................................................................................... 7!
Concept Reduction ...................................................................................................................... 9!
Sensors .................................................................................................................................... 9!
Output Signal .......................................................................................................................... 9!
States ..................................................................................................................................... 11!
Circuit ................................................................................................................................... 11!
Detailed Engineering Analysis and Design Presentation.............................................................. 13!
Ultrasonic Sensor ...................................................................................................................... 13!
States ......................................................................................................................................... 14!
LED ........................................................................................................................................... 16!
Resistor Choice ......................................................................................................................... 19!
Completed Design ..................................................................................................................... 19!
Power Consumption Calculation .............................................................................................. 21!
Nan, Saito, and Zhang
1
Cost Analysis ............................................................................................................................ 23!
Bill of Materials ........................................................................................................................ 24!
Hazards and Failure Analysis ................................................................................................... 25!
Conclusions ................................................................................................................................... 25!
References ..................................................................................................................................... 26!
Appendices .................................................................................................................................... 27!
Code .......................................................................................................................................... 27!
Ping.ino: UltrasoundSensor.ino ............................................................................................ 27!
Blink.ino: LED Sample Code ............................................................................................... 28!
Switch.ino: Switch Sample Code .......................................................................................... 28!
Final Project Code................................................................................................................. 29!
Datasheets ................................................................................................................................. 34!
&
&
Nan, Saito, and Zhang
2
Problem&Statement&
Current methods of monitoring parking meters involve the inconvenience of parking
meter attendants peering into the cloudy display to determine state of a parked car. Only two
states, expired or paid, are conveyed by the output of the parking meter, causing a parking meter
to display a red background even when cars are not present. Our project seeks to improve the
parking meter by detecting the presence of a car at the parking meter, displaying an LED that is
visible from 10 meters, and indicating whether the car is paid for, about to run out of time, or
overdue.
Problem&Formulation&
We expect to develop an add-on to the parking meter, a device that would operate
assuming signals are given from the parking meter. The device takes a paid signal and fiveminute remaining signal from the parking meter and denotes the state of the system by having
different flashing patterns of an LED. The device has four possible states: SLEEP, CHECK,
WARN, and OVERDUE. Most of the time, the parking meter is in the SLEEP mode of the
Arduino, where the Arduino powers down so it consumes little power. Every 15 minutes, it
wakes up to CHECK if there is a car or not. If a car is not present, the Arduino goes back to
SLEEP. When no car is present, the Arduino can only enter the SLEEP and CHECK states. The
following cases enumerate the possible cases for when a car is present. If a car is not paid for, the
device goes to the OVERDUE state, where the LED starts to flash rapidly in order to notify the
parking meter attendant. If a car is paid for and there is more than five minutes remaining, the
device goes to back to SLEEP for 10 minutes. If a car is paid for and only has five minutes or
less left, the device will go to a WARN state, where the LED will flash at a low frequency to
alert the car owner and the parking meter attendant that the parking meter will expire soon.
Nan, Saito, and Zhang
3
Project&Specifications&
General&Design&Specifications&
•
Device will wake itself up and not depend on any external timer
•
No more than $100 production cost for prototype and under $40/unit for mass-production
•
LED bright to be seen in a certain distance (10 meters)
•
Can be used in all kinds of climate
•
0.27 mA per hour power consumption
•
Assume the device will receive a high signal for when there is money in the meter and a
high signal for when there is five minutes or less remaining.
Sensor&Specifications&
•
Can detect objects with distances of up to 3 meters
•
Detects the presence of the car in various weather situations
•
Accuracy within a range of 25 cm
•
Easy to program and manipulate signals
•
Less than 5 cm in all dimensions
•
Still detect an object when the plane is within 30˚ above or below normal incidence
We assume that people usually park their cars within 2 meters of the parking meter, so
the sensor needs to be able to detect car-shaped objects up to 2 meters away. Since parking
meters operate on average between the hours of 7am and 5am, our sensor needs to detect the
presence of a car for 10 hours, regardless of the temperature of the surroundings and the length
of parked time. Since cars vary in curvature, the sensor needs to be able to detect objects whose
surfaces are not flat.
Battery&Specifications&
•
Last a year under average conditions
•
Relatively inexpensive to replace, under $5
•
Little to no modification of existing batteries in parking meters
Nan, Saito, and Zhang
4
In our model of the Ultrasonic Sensometer, we wished to use a battery similar to the ones
that power traditional parking meters. In the real implementation of our device, we will simply
run the device on the same battery than powers the parking meter, which varies from city to city.
In Los Angeles, the traditional parking meter typically uses 6 AA batteries, whereas in Portland,
the alkaline 9V batteries are used.
LED&Specifications&
•
Must be visible from 10 meters away in broad daylight
•
Low current draw for the distance it is visible from
•
Must draw attention to the overdue and warn state and use the least amount of current to
do so
Essentially, we needed a bright, but low-powered LED. Initially we were using an old,
rusty LED whose specs were unknown except through self-tests, and it was very dim even when
we put a lot of current through the LED. Eventually, we switched to the LED provided by
SparkFun electronics, and this proved to be very bright even when we ran a very small amount of
current through the LED (3 mA).
Nan, Saito, and Zhang
5
Concept&Synthesis&&
Literature&Review&
1) Hush Little Microprocessor… AVR and Arduino sleep mode basics 1
This blog was focused on how to implement sleep mode into an Arduino project in order
to save power:
•
5 different sleep modes on standard 8-bit Atmel AVR Atmega 328:
•
Waking up the Arduino from sleep mode
•
Code example
2) Control Structures 2
This article was focused on how to implement switches case into an Arduino project so as
to have the microcontroller do different things in different cases:
•
Circuit set up and implementation for switch cases
•
LED connection if there is one to interface to switch cases
•
Code example
3) Analog I/O 3
This article was focused on how to fade an LED, so the LED can have different levels of
lightness:
•
The use of analog output (Pulse Width Modulation (PWM)) to fade an LED
•
Circuit set up for interfacing LED
•
Code example
4) 9V Battery Adapter for the Arduino 4
This article was focused on how to use a 9V battery to power up the Arduino:
•
Power adapter build up steps
&
Nan, Saito, and Zhang
6
Concept&Generation&
The idea of the Ultrasonic Sensometer began when one of our members was walking by a
parking meter on the South 40 and noticed that a car was overdue but not ticketed. Even though a
parking meter attendant was in the vicinity, he did not seem to notice the illegally parked car.
Since visitors often find that parking on campus is very difficult, it is frustrating when cars are
parked illegally at expired parking meters. If expired cars are often ticketed, there would be more
available parking spaces around since people would be less likely to keep their cars parked at
parking meters without paying the meter. This would make it easier for visitors to find parking
spaces since the cars that would be parked illegally as soon as their car is expired or pay the
meter to extend their time at the parking space. We realized we needed have a sensor that would
detect the presence of a car as well as have some sort of signal indicating if there is a car in an
expired parking meter spot to alert the parking police from afar (10 meters away) of illegally
parked cars in parking spaces and help enforce the rule to pay for parking at the parking meter.
Our intention was to improve the current parking meter so that the overdue state of the
parking meter would be visible from afar and the parking meter attendant would not have to
consciously walk by every parking meter to check if the car was parked illegally. We
brainstormed various ways for our design to operate. We first thought about the sensor. We
thought of having a sensor detect if a car was present, and if it was present and the parking meter
was expired, there would be some sort of obvious signal that would occur until the car either left
or became legally parked with more money. We also thought of having a video sensor that would
be positioned on asphalt where the car must drive over when they park at the parking meter. We
would have the video sensor remember the image of the environment and check periodically to
update the image. When it detects a change, the sensor knows that a car is present and checks the
time on the parking meter. Another idea was to have an infrared sensor attached to the parking
meter to determine if a car is present based off of heat detection and car movement. The last idea
we had was to use an ultrasonic sensor to determine if a car is present by emitting an ultrasonic
pulse and detecting the echo.
We then thought of ways to indicate the parking meter’s state. One idea was to use sound
as the signal to indicate an overdue spot. We thought about having a beeping noise or a siren that
would go off when the car was parked illegally (when the time on the parking meter has
Nan, Saito, and Zhang
7
expired). We also considered using a light emitting diode (LED) as the output signal. People
respond to LEDs because they are accustomed to seeing it in our daily lives like in traffic lights,
ambulance lights, and police car lights. The colors green, red, and yellow already have
established connotations in society. Green means go, accepted, good, and safe; red means stop,
rejected, bad, hazardous, and illegal; and yellow means warning, caution, and be careful. The last
option was to have a red LED that would blink at different rates to denote different states of the
parking meter. The color red is explained later in the Concept Reduction section.
Figure 1 illustrates process we undertook to arrive at our final design concept. In the
following section, we traverse the tree as we explore the various choices in our design project.
Parking(Meter(Design(
Ideas(for(Determining(if(
a(Car(is(Parked(Legally
Video(
Sensor
Beeping
Infrared(
Sensor
LED
3(LED’s
Beeping
1(LED
Ultrasonic(
Sensor
LED
3(LED’s
Beeping
1(LED
LED
3(LED’s
Figure 1: Ultrasonic Sensometer Design Tree
&
Nan, Saito, and Zhang
8
1(LED
Concept&Reduction&
Sensors&
The three sensors we considered were the video, infrared, and ultrasonic sensors. The
first sensor we thought of, the video sensor, had major flaws for the specifications because it
would not work under all weather conditions. For example, when it snows in the winter, the
camera would get covered up with snow and would be unable to detect changes in the
environment. This could cause the device to continually think that there is a car present even if
no car is present.
The second sensor we thought of was an infrared sensor. However, we quickly realized
that in Montana’s freezing winters, the sensor would be completely ineffective after a short
amount of time. Infrared sensors detect the electromagnetic radiation of heat, which a car engine
generates, but after a couple of minutes, the infrared sensor loses its ability to detect the presence
of an object. This would not allow the device to correctly detect the presence of a car, especially
under frigid conditions.
The final sensor we considered was the ultrasonic rangefinder. The rangefinder was the
most viable of the three options because it is very versatile and is able to detect a far distance. It
is dependent on the speed of sound, which is approximately constant in different environments.
A rangefinder is also able to detect the distance of an object, so we can calibrate what distance
we wish to detect an object within.
Output&Signal&
To get the attention of a parking meter attendant 10 meters away, we thought that a loud
sound or a bright object would be appropriate. The loud sound was not an appealing design
choice for several reasons. Not only would it be annoying to people in the vicinity, but also, it
would not solve the problem of having parking meter attendants check each meter individually.
A sound source is much more difficult to localize than a light source in three-dimensional space
[6], so the police would have to identify the direction that the sound is being heard from and
walk towards a cluster of parking meters in order to identify which car is parked illegally.
Nan, Saito, and Zhang
9
We agreed on using LEDs in our design because they are relatively inexpensive, not
obnoxious, and would be easy to program with multiple states. It is also easier to discern
different frequencies of flashing light than of pulsing sounds. Although we had decided on the
output of the Ultrasonic Sensometer to be an LED, our initial idea was to use a different color for
every state. We wanted to turn on a green LED when a car was parked legally, a yellow LED
when five minutes remained on the parking meter, and a red LED when the car was parked
illegally. When no car was present, none of the LEDs were to be lit. Because our idea required at
least one of the LEDs to be on most of the time, we quickly realized that this format of
communication was highly inefficient, since the same information could be communicated with
one LED flashing at various frequencies. Also, if we used separate LEDs for the different
messages, it would require the LED to be on for a fixed duty cycle, whereas using one LED
allows for variation of the frequency (speed of the flashing LED) and duty cycle (percentage of
time per period that the LED is on). We chose a 1/6 duty cycle for the LED in one of the states
because previous psychophysical studies have shown that humans have an elevated sensitivity to
flashing phenomenon in their periphery versus a constant, unchanging stimulus [7]. The low duty
cycle was also a way to conserve power, which was needed for one of our design specifications
in the General Design Specifications section. The red LED was a deliberate choice for power
savings as well, because we observed that the eye can detect the “on” state of the red LED better
than the blue, green, and yellow LEDs, given the same current. Not only does red denote an
urgent message, the red LED is more efficient than the other LED colors at catching the attention
of the eye. Under laboratory conditions, the red LED required less current to deliver the message
than blue, green, or yellow LEDs [8].
&
Nan, Saito, and Zhang
10
States&
To design the device that would detect an overdue car, we considered the features we
desired to have in our design. We knew that we wanted to denote when there was only five
minutes remaining on a parking meter and when a car was parked illegally. Originally, we
wanted to differentiate between a car that was initially paid for and ran out of money and a car
that never paid in the first place. However, we decided that for our purposes, an extra state would
have been gratuitous because either way, the car is parked illegally, and the device should draw
attention to the illegally parked car. Generally, cities only have one fine for an illegally parked
car, and the four states (asleep, check, overdue, and warning) of the Ultrasonic Sensometer will
adapt with the ordinances of the city. If a police department desires more states, we would be
happy to customize the device for several thousand meters.
Circuit&
A summary of our design choices are shown below in Figure 2. For the prototype, we
also picked a battery, a microcontroller, and switches. In the actual implementation of our
design, we will use the battery of the parking meter, but in our prototype, we chose an Energizer
9V battery because it is cheaper than 6 AA batteries. The parking meter research showed that
typically, parking meters operate on AA or 9V batteries [9]. Since the Arduino has a built in 5V
regulator that takes in a range of 7V to 12V, we chose the standard 9V battery as the supply since
this is within the range of voltage that the Arduino requires for an external power supply.
In choosing the microcontroller, we chose a cheap, common microcontroller that has an
easy programming interface. Since we all knew how to program in C++ and Java, the code for
the Arduino IDE was very easy to pick up. We also considered using the BASIC Stamp 2,
manufactured by Parallax, but we already had an Arduino available, and the BASIC Stamp 2
required us to learn BASIC language. Also, the BASIC Stamp costs $100 compared to the $30
for the Arduino Uno.
In the prototype, we modeled the signals from the parking meter as switches. Originally,
we had a third switch to wake up the Arduino from the Power Down Sleep Mode. However, our
specifications stated that the device would wake up automatically from its SLEEP state by using
its internal timer rather than an external event. In our first case, the external event was the wakeNan, Saito, and Zhang
11
up switch is flipped, closing the circuit. In the second state, the event that triggers the Arduino to
wake up is when the watchdog timer has reached zero. The watchdog timer (WDT) counts down
from a specified value and wakes up when time has run out. Because the parking meter cannot
tell time, we have the Arduino wake itself up every fifteen minutes. Although the WDT is
inaccurate, we are not too concerned, because as long as it wakes up occasionally, the device will
check for the presence of a car. We do not care if it sleeps for 17 minutes instead of 15 minutes.
The switches are modeled on the following page in Figure 4.
Parking(Meter
(Component(Choices
States
(
49States
(
LED
(
(
59States
(
Red
(
Arduino(Uno
(
Pink(LED
(
Bryan(Lab(LED
(
Sensor
(
Parallax(BASIC(
Stamp(2
(
(
Ultrasonic(
Sensor
(
Yellow
(
9V
(
Sparkfun(LED
(
(
Micro9
controller
(
Battery
3(Switches
(
6(AA(Batteries
(
PING)))(Ultrasonic(
Sensor
(
&
12
2(Switches
(
Infrared(Sensor
(
Watchdog(Timer
(
MaxSonarEZ0
(
Figure 2: Concept Reduced Tree Diagram
Nan, Saito, and Zhang
Switches
(
Detailed&Engineering&Analysis&and&Design&Presentation&
Our design is split into several subsystems as illustrated above in Figure 2. First, the
ultrasonic sensor emits an ultrasonic pulse and waits for an echo. If the echo traveled further than
4m round trip, no car is detected. If a car is within 2 meter of the sensor, then the system will
check if the parking meter is paid for. Depending on the state, the system will flash an LED or
fall back asleep. In the sleep state, the watchdog timer will count down from a specified snooze
time and wake up when it reaches zero.
Ultrasonic&Sensor&
To determine which ultrasonic sensor to use, Pugh chart analysis was performed. Pugh
chart analysis is a way to quantify the choosing of one option over another by giving different
weights for each factor and rating each of the options. We considered a Parallax PING)))
Ultrasonic Sensor and a MaxBotix MaxSonar-EZ0 for parameters such as distance, cost,
sensitivity, and ease of integration with the Arduino.
The PING))) sensor can sense from 2 cm to 3 m, and the MaxBotix can detect small
objects from 0 m to 6.45 m. They are comparable in cost, with the PING))) costing $29.99 and
the MaxSonar-EZ0 costing $29.95. The PING))) has a slightly better resolution of 1 cm versus
the MaxSonar’s 1 in. The PING))) was easier to interface with the Arduino because many people
have already done so, and there is an entire community dedicated to projects using PING)))
sensors and the Arduino. In the end, we chose the PING))) sensor because of its compatibility
with the Arduino as well as its ability to filter noise, i.e., it does not require the programmer to
differentiate between large and small objects.
The PING))) sensor emits a short ultrasonic burst and then listens for the echo. Sound
travels at 345 m/s at 25˚C. The PING))) sends out a high pulse as long as the echo has not come
back. To convert the time traveled by the pulse to the distance from the sample, the code divides
by 29 microseconds (the amount of time it takes for the sound to travel 1 cm) and 2 (the distance
is half of the amount of time required to travel round trip). Figure 3a below shows the diagram of
the PING))) sensor ports. Figure 3b shows how the distance is eventually obtained from the
ultrasonic waves getting emitted and bouncing off to which it is received by the sensor. Figure 3c
shows how the PING))) sensor operates. The PING))) sensor provides a high output pulse to the
Nan, Saito, and Zhang
13
Arduino that ends when the echo is detected. This allows the programmer to calculate the
distance to the target using the width of the pulse, as seen in Equation 1.
!!(!" ) =
!(!!) 1
!"
∙ = ! (!!) ∙ 0.0345
29 2
!!
Equation 1: PING))) Distance Calculation
Figure 3 The PING))) Ultrasonic Sensor (a) detects the distance of an object (b) by emitting a short
40 kHz ultrasonic burst (c).
We tested the accuracy of the PING))) ultrasonic sensor by running the example codes in
Appendix A. We measured with a meter stick, and found the accuracy of the PING))) sensor to
be within one centimeter. Since exact distance measurements are not critical for the operation of
this device, a 1 cm uncertainty exceeds our expectations for the distance sensing portion of this
project.
States&
Figure 4 shows the state diagram that controls the Arduino. In order to arrive at the state
diagram for the device, we considered all the cases that the device could experience. We started
the Arduino in the check state. If no car is present (the distance returned by the PING))) sensor is
greater than 2 m), the Arduino will fall back asleep for 15 minutes. In the sleep state, we put the
sleep command in a loop so that we can control the length of time that the Arduino is asleep for.
In the case that a car is present, the Arduino will check the signals passed to it by the parking
meter: paid and fiveMin. The paid signal tells the Arduino that the car is paid for, and the
fiveMin signal tells the Arduino that five minutes or less is remaining on the meter. If the paid
signal is low, i.e. the car is unpaid for, the Arduino goes into the overdue state and flashes an
LED at a fast frequency of 5 Hz.
Nan, Saito, and Zhang
14
If the paid signal is high and there are five minutes remaining, the Arduino goes into the
warn state and flashes an LED at a slow frequency of 5/6 Hz. If only the paid signal is high,
indicating that there are more than five minutes remaining on the meter, the Arduino goes back
to sleep for 10 minutes. This sleep command is in a different loop that wakes up after a shorter
amount of time. All of the code for the Arduino can be found in Appendix A.
Figure 4: Arduino State Diagram
Nan, Saito, and Zhang
15
LED&
We initially started with two Bryan LEDs given to us by Professor Richter. One was an
opaque pink and the other one was a clear red. Of the two LEDs found in Bryan, we chose to
work with the clear red LED, herein referred to as the Bryan LED, because it was easier to
determine whether the Bryan LED was on or off, unlike the pink LED. The pink LED did not
allow as much light through, since it was not translucent. We also had a brand new SparkFun
LED that came with the Arduino kit. We tested the IV characteristics of the Bryan LED and the
SparkFun LED using NI Instrument Launcher’s Two-Wire Current-Voltage Analyzer. The IV
curve of the two LEDs are shown below in Figures 5 and 6.
Figure 5: SparkFun LED IV Curve
Nan, Saito, and Zhang
16
Figure 6: Bryan LED IV Curve
The threshold voltages of the SparkFun LED and the Bryan LED are both 1.7V, as seen
by the steep rise in current when the voltage passes 1.7V. From the two LED curves, we can see
that the SparkFun LED is much more sensitive to a small change in voltage and that the Bryan
LED is relatively insensitive to the change in voltage after the threshold voltage. The threshold
voltage was later useful in calculations as the forward voltage drop across the diode.
We tested the LEDs using the configuration shown in Figure 7. We varied the voltage
from 2V to 5V because the threshold voltage of the LED is 1.7V and the maximum voltage
supplied by the Arduino is 5V. We limited the current by choosing a 170Ω resistor. The FGEN
already has a built-in 50Ω resistor, so we used a 120Ω resistor to be in series with the LED. The
maximum forward current that our LED could tolerate is 30 mA. To find the minimum resistance
value, we solve for R = V/I = (Vs-Vt)/I = (5V-1.7V)/0.03A = 170Ω. To vary the voltage, we used
FGEN square wave on the Elvis II Board and set the duty cycle to be 100%. To compensate for
the fact that a square wave is centered at 0V, we offset the voltage by half of the amplitude of the
desired voltage. Figure 8 shows the distances that the on state of the LED is still visible for the
two LEDs.
Nan, Saito, and Zhang
17
Figure 7: LED Visibility Testing Circuit Schematic
Distance)LED)Visible)(m))
Distance)LED)Visible)vs)Current)
20!
18!
16!
14!
12!
10!
8!
6!
4!
2!
0!
Sparkfun!LED!
Bryan!Lab!LED!
0!
2!
4!
6!
8!
10!
12!
14!
16!
18!
Current)(mA))
Figure 8: Visible Distance vs. Current for the Two LEDs
&
Nan, Saito, and Zhang
18
20!
Resistor&Choice&
For the switches, we designed a pull-down resistor so that when the switch is open, the
Arduino gets a signal of 0V from the ground. When the switch is closed, the large resistor allows
very little current to flow down that branch: I = V/R = 5V/4.7 MΩ = 1.06 μA. This is a very
negligible amount of power consumption, so we can essentially ignore it. We needed the current
that flows down that branch to be greater than the leakage current so that the Arduino does not
confuse a HIGH signal for a LOW signal, or vice versa.
Figure 9: Switch Circuit Diagram
For the LED, we choose a 620Ω resistor so that we drew the least amount of current that
we can still observe the LED from afar. At this resistance, the LED consumes a mere 3.73 mA
when measured through the DMM ammeter.
Completed&Design&
All these components enabled us to create the final project seen below in Figure 10. As
seen in Figure 10, the PING))) sensor is the leftmost object containing two silver cylinders
connected to a flat rectangular blue plastic circuit board. The black object with the white pins is
the set of switches used to control the “paid” and “five minutes or less remaining” signals that
the parking meter communicates to this device. The red object at the bottom middle is the red
LED used to signal the parking meter attendant (and the car owner) that the parking meter is
either overdue or has less than five minutes until it expires. The rightmost blue circuit board is
the Arduino Uno board that contains the ATMega328 microprocessor to control the system. The
two resistors on the right of the switch correspond to Figure 9. Each of the two switches contain
Nan, Saito, and Zhang
19
a 4.7MΩ resistor on the side of the Arduino to pull the voltage down to ground when the switch
is open. The resistor at the bottom of the figure is connected in series to the red LED to prevent
the Arduino from delivering too much current to the LED.
Figure 10: Final Design Prototype
Figure 11 below shows the wiring schematic used to create our prototype.
Figure 11: Schematic of the Arduino Connections
Nan, Saito, and Zhang
20
Power&Consumption&Calculation&
Table 1 shows the parts and the respective current draw that we measured. Each
component was measured by hooking up a DMM Ammeter in series with the component. To
find the current drawn from the LED on the PING))) sensor, we measured the voltage drop to be
2.81V across the resistor in series with the LED. We measured the resistance using an ohmmeter
and found the resistance to be 270Ω. The total current passing through the PING))) sensor LED
is then 2.81V/270Ω = 10.4 mA. If we could remove the LED from the PING))) sensor, since it is
unnecessary for design, it would give us a 10.4 mA savings on the PING))) sensor, bringing the
current draw down to 15.8 mA – 10.4 mA = 5.4 mA.
Table 1: Measured Current Draw for all Parts
Part
Measured Current (mA)
Red LED
3.7
PING))) Sensor
15.8
PING))) Sensor (without PING LED)
5.4
Entire device current draw
17
The 9V battery supplied by Energizer has 700 mA·h. The Ultrasonic Sensometer will be
used 10 hours a day (7 AM to 5 PM), 5 days a week, and 52 weeks a year. We aim for the device
to last one year, so the average power consumption must be under 700 mA·h/(10 hr/day*5
days/wk*52 wk/yr) = 0.269 mA.
Nan, Saito, and Zhang
21
Our device uses an average of 0.242 mA, as shown below in Table 2.
Table 2: Power Calculations for the Ultrasonic Sensometer
State
LED Current
(mA)
Ping Current
(mA)
Weight (fraction of
time spent in state)
No car
0
0
0.25
Paid
0
0
0.7
Warn
0.62
2.83
0.04
Overdue
1.86
8.48
0.01
Total Current:
0.242 mA
We measured the current of each component using the Elvis II board DMM ammeter in
series. The parking meter would spend different amounts of time in each state, so we estimated a
percentage for each of the four states as:
•
No car for 25% of the time
•
Paid for 70% of the time
•
Warn for 4% of the time
•
Overdue for 1% of the time
The total current in the table above is shown below:
0.242 mA = (0+0)*0.25 + (0+0)*0.7 + (0.62+2.83)*0.04 + (1.86+8.58)*0.01
When we compare the power consumption of our desired average current per hour, we find that
the actual current consumption, 0.242 mA, is less than our goal of 0.269 mA per hour,
theoretically causing our design to meet the goal of lasting a year. Please note these weights will
change based off the location of the parking meter and the parking patterns of the commuters.
Local police departments can lengthen the time between battery maintenances by choosing the
appropriate battery for their purposes.
Nan, Saito, and Zhang
22
Cost&Analysis&
The prototype costs are shown below. Table 3 shows the prototype cost breakdown of
producing one unit of our product. Table 4 shows the unit cost per mass-producing 1,000 units.
The unit cost for 1,000 units is much cheaper because after we develop the first model, only the
ATMega328 microprocessor is used for the manufacturing process.
Table 3: Prototype Cost of Materials
Item
Unit Cost ($)
# Units
Total Cost ($)
Source
Arduino Uno SMD
29.95
1
29.95
SparkFun Electronics
Arduino and
3.95
1
3.95
SparkFun Electronics
0.35
1
0.35
China Young Sun LED
Breadboard Holder
Red LED
Technology Co., LTD.
(YSL-R531R3D-D2)
Parallax PING)))
29.99
1
29.99
Parallax, Inc.
0.068
2
0.068
Digi-Key
Ultrasonic Rangefinder
4.7 Mega-ohm resistor
(CFR-25JB-52-4M7)
620 ohm resistor
(4.7MQBK-ND)
0.068
1
0.068
(CFR-25JB-52-620R)
Energizer 9V Battery
Total
Nan, Saito, and Zhang
Digi-Key
(620QBK-ND)
3.49
1
3.49
Energizer Batteries
1
67.93
Innovasian, Inc.
23
Table 4: Production per Unit Cost of Materials for 1000 Quantity
Item
Unit Cost ($)
# Units
Total Cost ($)
Source
ATMega328
3.44
1
3.44
Atmel
0.35
1
0.35
China Young Sun LED
Microcontroller
Red LED
Technology Co., LTD.
(YSL-R531R3D-D2)
Parallax PING)))
23.99
1
23.99
Parallax, Inc.
4.7 Mega-ohm resistor
0.035
2
.07
Chaney Electronics, Inc.
620 ohm resistor
0.01087
1
0.01087
Digi-Key 620QBK-ND
3.49
1
3.49
Energizer Batteries
1
31.35
Innovasian, Inc.
Ultrasonic Rangefinder
(CFR-25JB-52-620R)
Energizer 9V Battery
Total
Bill&of&Materials&
Yageo, CFR-25JB-52-620R:
http://search.digikey.com/us/en/products/CFR-25JB-52-620R/620QBK-ND/2682
Yageo, CFR-25JB-52-4M7:
http://search.digikey.com/us/en/products/CFR-25JB-52-4M7/4.7MQBK-ND/1849
Energizer Batteries, ALK 9V 522:
http://www.jameco.com/webapp/wcs/stores/servlet/Product_10001_10001_198731_-1
Parallax, 28015: http://www.parallax.com/tabid/768/ProductID/92/Default.aspx
Nan, Saito, and Zhang
24
Hazards&and&Failure&Analysis&
The resistors, Arduino Uno, 9V Energizer battery, PING))) sensor, and Sparkfun red
LED are all RoHS compliant, meaning they do not pose any abnormal threats to the
environment. Since all these parts are durable, the system should not need replacement parts
other than changing out the battery when the battery is completely drained. One failure possible
with the Ultrasonic Sensometer is the gradual wear that it will experience from being in an
outside environment. One way to slow down the accumulation of rust, dirt, and natural elements
is to encase the sensometer in a weatherproof box. Another issue that may arise is that the device
many not be properly installed on the parking meter. If the device is not placed about 40 cm
above the ground, the ultrasonic pulse may reflect off of the hood of the car, causing the device
to think that no car is present when there is indeed a car present.
Conclusions&
We completed our Senior Design project after making many design decisions during the
semester. The Ultrasonic Sensometer works pretty well; it is able to detect a parked car within 2
meters of the parking meter. Our design fulfilled the specifications we set for the project (see
Specifications section); in fact, the design exceeded expectations because the LED was visible
from at least 20 meters away.
Throughout the semester, our design team explored many concepts and ideas regarding
the Ultrasonic Sensometer. The major choices we made for the project include the sensor to be
used for the parking meter improvement, which LED to use, the duty cycle the LED flashes at,
and what states to incorporate into the code.
The recommendations we give for improved design include running the Arduino on an
external clock to reduce the current the Arduino uses. We were unable to implement an 128 kHz
processor speed because this required an external crystal. For other power savings, we would
request that the LED on the PING))) sensor be sawed off or not included when being massproduced.
Nan, Saito, and Zhang
25
References&
[1] EngBlaze Blog (2011, Oct). Hush Little Microprocessor… AVR and Arduino sleep mode
basics [Online]. Available: http://www.engblaze.com/hush-little-microprocessor-avr-andArduino-sleep-mode-basics/
[2] Arduino Forum (2010 Summer). Control Structures [Online]. Available:
http://Arduino.cc/en/Tutorial/SwitchCase2
[3] Arduino Forum (2010 Summer). Analog I/O [Online]. Available:
http://Arduino.cc/en/Tutorial/Fading
[4] Arduino Playground (2009 Summer). 9V Battery Adapter for the Arduino [Online].
Available: http://arduino.cc/playground/Learning/9VBatteryAdapter
[5] Energizer [Online]. Available: http://data.energizer.com/PDFs/522.pdf
[6] Bian X., Abowd G., Rehg J. “Using Sound Source Localization to Monitor and Infer
Activities in the Home.” [Online]. Available:
http://smartech.gatech.edu/xmlui/bitstream/handle/1853/3729/04-20.pdf?sequence=1
[7] NASA Ames Research Center. “Blinking, Flashing, and Temporal Response.” [Online].
Available: http://colorusage.arc.nasa.gov/flashing.php
[8] Sea M.S., Bierman A., Yuan, Z. “Vision Psychophysics and LEDs for Remote Airfield
Lighting.” [Online]. Available: www.iesalc.org/?wpfb_dl=4
[9] Angelos, Constantine. “Electronic Parking Meters Take Any Coin, Are ‘User Friendly’.” The
Seattle Times. October 3, 1993. Available:
http://community.seattletimes.nwsource.com/archive/?date=19931003&slug=1724212
Nan, Saito, and Zhang
26
Appendices&
Code&
Ping.ino:&UltrasoundSensor.ino&
/* Ultrasound Sensor
*-----------------*
* Reads values (00014-01199) from an ultrasound sensor (3m sensor)
* and writes the values to the serialport.
*
* http://www.xlab.se | http://www.0j0.org
* copyleft 2005 Mackie for XLAB | DojoDave for DojoCorp
*
*/
int
int
int
int
int
ultraSoundSignal = 7; // Ultrasound signal pin
val = 0;
ultrasoundValue = 0;
timecount = 0; // Echo counter
ledPin = 13; // LED connected to digital pin 13
void setup() {
beginSerial(9600);
pinMode(ledPin, OUTPUT);
}
// Sets the baud rate to 9600
// Sets the digital pin as output
void loop() {
timecount = 0;
val = 0;
pinMode(ultraSoundSignal, OUTPUT); // Switch signalpin to output
/* Send low-high-low pulse to activate the trigger pulse of the sensor
* ------------------------------------------------------------------*/
digitalWrite(ultraSoundSignal, LOW); // Send low pulse
delayMicroseconds(2); // Wait for 2 microseconds
digitalWrite(ultraSoundSignal, HIGH); // Send high pulse
delayMicroseconds(5); // Wait for 5 microseconds
digitalWrite(ultraSoundSignal, LOW); // Holdoff
/* Listening for echo pulse
* ------------------------------------------------------------------*/
pinMode(ultraSoundSignal, INPUT); // Switch signalpin to input
val = digitalRead(ultraSoundSignal); // Append signal value to val
while(val == LOW) { // Loop until pin reads a high value
val = digitalRead(ultraSoundSignal);
}
while(val == HIGH) { // Loop until pin reads a high value
val = digitalRead(ultraSoundSignal);
timecount = timecount +1;
// Count echo pulse time
}
/* Writing out values to the serial port
* -------------------------------------------------------------------
Nan, Saito, and Zhang
27
*/
ultrasoundValue = timecount; // Append echo pulse time to ultrasoundValue
serialWrite('A'); // Example identifier for the sensor
printInteger(ultrasoundValue);
serialWrite(10);
serialWrite(13);
/* Lite up LED if any value is passed by the echo pulse
* ------------------------------------------------------------------*/
if(timecount > 0){
digitalWrite(ledPin, HIGH);
}
/* Delay of program
* ------------------------------------------------------------------*/
delay(100);
}
Blink.ino:&LED&Sample&Code&
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(led, HIGH);
// turn the LED on (HIGH is the voltage level)
delay(1000);
// wait for a second
digitalWrite(led, LOW);
// turn the LED off by making the voltage LOW
delay(1000);
// wait for a second
}
Switch.ino:&Switch&Sample&Code&
/*
*
*
*
*
*
*
*
*
switch
Each time the input pin goes from LOW to HIGH (e.g. because of a push-button
press), the output pin is toggled from LOW to HIGH or HIGH to LOW. There's
a minimum delay between toggles to debounce the circuit (i.e. to ignore
noise).
David A. Mellis
21 November 2006
Nan, Saito, and Zhang
28
*/
int inPin = 2;
int outPin = 13;
// the number of the input pin
// the number of the output pin
int state = HIGH;
int reading;
int previous = LOW;
// the current state of the output pin
// the current reading from the input pin
// the previous reading from the input pin
// the follow variables are long's because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long time = 0;
// the last time the output pin was toggled
long debounce = 200;
// the debounce time, increase if the output flickers
void setup()
{
pinMode(inPin, INPUT);
pinMode(outPin, OUTPUT);
}
void loop()
{
reading = digitalRead(inPin);
//
//
//
if
if the input just went from LOW and HIGH and we've waited long enough
to ignore any noise on the circuit, toggle the output pin and remember
the time
(reading == HIGH && previous == LOW && millis() - time > debounce) {
if (state == HIGH)
state = LOW;
else
state = HIGH;
time = millis();
}
digitalWrite(outPin, state);
previous = reading;
}
Final&Project&Code&
#include <avr/sleep.h>
#include <avr/power.h>
#include <avr/wdt.h>
#define WDTO_8S 9
int pingPin = 12;
//the pin you put the ping sensor
const int SLEEP=1;
const int CHECK=2;
const int WARN=3;
const int OVERDUE=4;
const int pinFiveVolt=8;
const int min5Pin = 7;
//the 5 min pin. almost due, between 0~5min
const int paidPin = 2;
//if paid or not paid pin
boolean present;
//initialize the car presence to false
boolean ping = false;
//initialize the ping to false
int five, paid;
const int ledPin = 10;
// the number of the LED pin
int state = 2;
Nan, Saito, and Zhang
29
int cm;
void setup()
{
Serial.begin(9600);
pinMode(pinFiveVolt, OUTPUT);
pinMode(min5Pin, INPUT);
pinMode(paidPin, INPUT);
pinMode(ledPin, OUTPUT);
wdt_enable(WDTO_8S); // setup Watch Dog Timer to 8 sec
Serial.print("Initialization Complete.");
}
void loop(){
paid=digitalRead(paidPin);
five=digitalRead(min5Pin);
//swTwo
//swThree
//if(present){
switch (state) {
case CHECK:
//check state
paid=digitalRead(paidPin);
//swTwo
five=digitalRead(min5Pin);
cm=pinging();
present=pres(cm);
if (present == true) {
if (paid == LOW){
Serial.println("this is messded up.");
state = OVERDUE;
}
else{
if (five == HIGH) {
state = WARN;
}
else {
paid=digitalRead(paidPin);
//swTwo
five=digitalRead(min5Pin);
//swThree
for (int i=0; i<1; i++) {
sleepNow();
}
state = CHECK;
}
}
}
Serial.println("Checking.");
break;
case WARN:
//warning state
cm=pinging();
present=pres(cm);
if (present) {
if (five == LOW) {
if (paid == HIGH){
state = CHECK;
}
else {
Nan, Saito, and Zhang
30
state = OVERDUE;
}
}
else{
if (paid == LOW) {
state = OVERDUE;
}
else {
state = WARN;
}
}
}
Serial.println("Five minute warning.");
break;
case OVERDUE:
//overdue state
cm=pinging();
present=pres(cm);
if (present){
if (paid == LOW){
state = OVERDUE;
}
else{
state = CHECK;
}
}
Serial.println("Overdue.");
break;
}
Serial.print("State is: ");
if (state == 1){
Serial.println("SLEEP");
}
else if (state == 2){
Serial.println("CHECK");
}
else if (state == 3){
Serial.println("WARN");
}
else {
Serial.println("OVERDUE");
}
// } else {
if (!present) {
for (int i=0; i<3; i++) {
sleepNow();
// Goes to sleep
}
// present = true;
// so that when it wakes up it will not automatically go back
to sleep because present will be true
state = CHECK;
paid=digitalRead(paidPin);
//swTwo
five=digitalRead(min5Pin);
Serial.println("Paid: " + paid);
Serial.println("Five minute: " + five);
}
// so that it will PING it
// }
if (state == WARN){
blinkWarn();
}
Nan, Saito, and Zhang
31
else if (state == OVERDUE){
blinkOverdue();
}
}
// watchdog interrupt
ISR (WDT_vect)
{
wdt_disable(); }
void sleepNow(){ // 8 second watchdog sleep
// digitalWrite(pinFiveVolt,LOW); //to control ping Volt to 0V
// disable ADC
ADCSRA = 0;
digitalWrite(pinFiveVolt,LOW); //to control ping Volt to 5V with pullup resistor
// clear various "reset" flags
MCUSR = 0;
// allow changes, disable reset
WDTCSR = _BV (WDCE) | _BV (WDE);
// set interrupt mode and an interval
WDTCSR = _BV (WDIE) | _BV (WDP3) | _BV (WDP0);
// set WDIE, and 8 seconds delay
wdt_reset(); // pat the dog
set_sleep_mode (SLEEP_MODE_PWR_DOWN);
sleep_enable();
// turn off brown-out enable in software
MCUCR = _BV (BODS) | _BV (BODSE);
MCUCR = _BV (BODS);
sleep_cpu ();
// cancel sleep as a precaution
sleep_disable();
}
long microsecondsToCentimeters(long microseconds)
{ return microseconds / 29 / 2; }
long pinging()
{
long duration, distance;
//
digitalWrite(pinFiveVolt,HIGH); //to control ping Volt to 5V with pullup resistor
pinMode(pingPin, OUTPUT);
digitalWrite(pingPin, LOW);
delayMicroseconds(2);
digitalWrite(pingPin, HIGH);// activating the internal 20kohm pull-up resistor
delayMicroseconds(5);
digitalWrite(pingPin, LOW);
pinMode(pingPin, INPUT);
duration = pulseIn(pingPin, HIGH);
distance = microsecondsToCentimeters(duration);
Serial.print(distance);
Serial.println("cm");
Serial.println();
return distance;
}
boolean pres(int x)
Nan, Saito, and Zhang
32
{
return x <= 200;
}
void blinkWarn () {
digitalWrite(ledPin,HIGH);
delay(200);
digitalWrite(ledPin,LOW);
delay(1000);
}
void blinkOverdue () {
digitalWrite(ledPin,HIGH);
delay(100);
digitalWrite(ledPin,LOW);
delay(100);
}
Nan, Saito, and Zhang
33
Datasheets&
Nan, Saito, and Zhang
34