📄 introductionhardwaresoftwareresu.htm
字号:
80. When they output low, as it does over dark paper, the ADC reading is
never above 40. If every sensor is giving a reading above 80, then the
car is over white paper and does not move. If any one of the sensors
reads below 40, then the program turns on the rear motors first and then
transitions to state <I>straight</I>. </FONT></SPAN></P>
<P class=MsoNormal style="TEXT-INDENT: 0.5in"><SPAN
style="FONT-FAMILY: Palatino Linotype"><FONT size=4>We use the timer0 PWM to
power the rear motors. Fast PWM mode is enabled and the compare output
mode is set to clear OC0 when the timer0 counter equals OCR0, and to set OC0
at top. With the timer0 clock set at a prescaler of 256 and OCR0 set to
128, we will get a PWM signal with a period of 256/16MHz x 256 = 4 msec and a
duty cycle of 50%. The PWM waveform is output through port B3, which is
connected to the gate of the two BJTs that turn on the rear motors.
Therefore, the rear motors turn on and off in equal measure.
</FONT></SPAN></P>
<P class=MsoNormal style="TEXT-INDENT: 0.5in"><SPAN
style="FONT-FAMILY: Palatino Linotype"><FONT size=4>While the car is moving,
the program returns to reading the sensors. A full sweep of the three
sensors reveals any changes in the course of the path. In general, a low
output from one of the two non-center sensors and a high output from the other
reveal a turn. For left turns, the program sends a high signal to
transistors 3 and 4 while for right turns, transistors 5 and 6 turn on.
Immediately afterwards, the program transitions into state <I>left_turn </I>or
state <I>right_turn</I> depending on the turn. In either state, if the
sensors detect that the middle sensor is not over a path, the car will
continue to turn. As a self-adjusting measure, the program checks if the
other non-centered sensor every outputs low. If so, then the car has
turned too much in one direction and will start to turn in the other
direction. Once the middle sensor reads low again, the car will stop the
steering motor and return to state <I>straight</I>. If all three sensors
read high, the program will turn off the PWM and transition to state
<I>stop</I>. </FONT></SPAN></P>
<P class=MsoNormal style="TEXT-INDENT: 0.5in" align=center><IMG height=400
src="IntroductionHardwareSoftwareResu.files/state_machine_2.bmp" width=640
border=0></P>
<P class=MsoNormal style="TEXT-INDENT: 0.5in" align=center>Figure 6: State
Machine for Car Movement</P>
<P class=MsoNormal><I><SPAN style="FONT-FAMILY: Palatino Linotype"><FONT
size=4> Issues: </FONT></SPAN></I><SPAN
style="FONT-FAMILY: Palatino Linotype"><FONT size=4>We had a number of issues
reconciling how we wanted the program to work with the mechanics of the toy
car. The car’s speed became the first issue we encountered. In an
earlier version of the program, we sent the motor a constant logical high
signal. During testing, we noticed that the car would travel so fast
that it would overshoot turns. The sensors would detect the turn but by
the time the program could initiate a turn, the car had already driven off the
road and would stop. At Professor Land’s suggestion, we instead used the
PWM to drive the rear motors. This slowed the car to half its original
speed, which is not surprising considering our PWM waveform’s 50% duty
cycle. </FONT></SPAN></P>
<P class=MsoNormal><SPAN style="FONT-FAMILY: Palatino Linotype"><FONT
size=4>
Slowing the car allowed more time for the program to react to turns but the
car’s inherent turning radius is fairly wide. The car was likely to go
off the road and stop even at the slower speed. The program addresses
this by initiating a turn first and then waiting 1.5 seconds before reading
the sensor data again. The car will therefore continue to turn during
the delay even if it has gone off the road; this hopefully gives the car
enough time to readjust itself to the course. </FONT></SPAN></P>
<P class=MsoNormal><FONT size=4><SPAN
style="FONT-FAMILY: Palatino Linotype">
</SPAN></FONT><A
href="http://instruct1.cit.cornell.edu/courses/ee476/FinalProjects/s2007/bl222_wh84/bl222_wh84/index.html#top">Back
to Top</A> </P></BLOCKQUOTE></DIV>
<H1><FONT face="Palatino Linotype"><A id=res></A>Result</FONT></H1>
<BLOCKQUOTE>
<P class=MsoNormal
style="TEXT-JUSTIFY: inter-ideograph; TEXT-INDENT: 0.5in; TEXT-ALIGN: justify"><SPAN
style="FONT-FAMILY: Palatino Linotype"><FONT size=4>The car is able to follow
a straight path without much trouble. It performs less well on turns,
particularly turns sharper than 45°. The turn radius of the car is not
wide enough for it to consistently make sharp turns. The car can make
turns wider than 45°, especially with the 1.5 second delay added.
However, one will notice after making a turn, the car will oscillate around
the track rather than follow it completely straight. Due to the car’s
tendency to overshoot the track and then turn back into it, the car turns back
to the road at an angle. For example, look at the diagram to the left
where the car is making a right turn. The middle sensor will eventually
detect the path and the program will turn off the turn motor but because the
<IMG height=169 src="IntroductionHardwareSoftwareResu.files/index1.gif"
width=197 align=left border=0>car will be moving straight at an angle to the
road, the left sensor will go over and the middle sensor will go off the
track. This tells the car to make a left turn. The car will
continue to adjust itself in this wobbling manner, although each time the
angle at which it comes into the path is reduced. Therefore, we found
that the path after a turn should be sufficiently long to allow for this
adjusting. </FONT></SPAN></P>
<P class=MsoNormal
style="TEXT-JUSTIFY: inter-ideograph; TEXT-INDENT: 0.5in; TEXT-ALIGN: justify"><SPAN
style="FONT-FAMILY: Palatino Linotype"><FONT size=4>The photosensors also were
the source of some errors. The sensors work best when placed 0.8 cm off
the surface; at this level, the sensors can clearly distinguish between a
light and dark colored background and the output is a stable high for light
and stable low for dark. At a distance higher than 0.8 cm, the sensor
output begins to fluctuate. The output voltage levels over light and
dark surfaces begin to overlap so that the program cannot properly discern if
the car is over a path. At a distance lower than 0.8 cm, the sensors
tend only to output low. We also found that the sensors work best with
black and white, and placing the sensors over a different color leads to a
fluctuating output. We believe this occurs because colors other than
black would absorb some infrared waves while reflecting others. If the
amount of reflected infrared varies, then the output will fluctuate.
This behavior unfortunately rules out the prospect of using backgrounds and
tracks of different colors. </FONT></SPAN></P>
<P class=MsoNormal
style="TEXT-JUSTIFY: inter-ideograph; TEXT-INDENT: 0.5in; TEXT-ALIGN: justify"><SPAN
style="FONT-FAMILY: Palatino Linotype"><FONT size=4>This project is
essentially a toy so anyone can use it. All one needs to do is place the
car over a track and turn it on. It is, however, unlikely to be a very
marketable toy because it requires three 9 V batteries to run and the motor
consumes battery power too quickly. We noticed that if the battery
voltage for the turn motor drops below 7 V, the car will not be able to turn
at all.</FONT> </SPAN></P>
<P class=MsoNormal
style="TEXT-JUSTIFY: inter-ideograph; TEXT-INDENT: 0.5in; TEXT-ALIGN: justify"><A
href="http://instruct1.cit.cornell.edu/courses/ee476/FinalProjects/s2007/bl222_wh84/bl222_wh84/index.html#top">Back
to Top</A> </P></BLOCKQUOTE>
<H1><FONT face="Palatino Linotype"><A id=concl></A>Conclusion</FONT></H1>
<BLOCKQUOTE>
<BLOCKQUOTE>
<P class=MsoNormal align=justify><SPAN
style="FONT-FAMILY: Palatino Linotype"><FONT size=4> A line-following
car is certainly not the most nefarious project that has ever been
undertaken but we must still consider the IEEE Code of Ethics
nonetheless.</FONT></SPAN></P>
<P class=MsoNormal style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in"><SPAN
style="FONT-FAMILY: Palatino Linotype"><FONT size=4>1)</FONT><SPAN
style="FONT-WEIGHT: normal; FONT-STYLE: normal; FONT-FAMILY: Times New Roman; FONT-VARIANT: normal"><FONT
size=4> </FONT></SPAN></SPAN><I><SPAN
style="FONT-FAMILY: Palatino Linotype"><FONT size=4>To accept responsibility
in making decisions consistent with the safety, health and welfare of the
public, and to disclose promptly factors that might endanger the public or
the environment: </FONT></SPAN></I><SPAN
style="FONT-FAMILY: Palatino Linotype"><FONT size=4>Even at its original
fast speed, the car does not have enough mass to hurt someone if it were to
run into him or her. However, we certainly did not want someone to
trip over it so we tested the car in a safe area in the Phillips Hall, away
from heavy foot traffic. Also, we tested the circuitry to make sure no
component would get hot enough to hurt anyone using the
car.</FONT></SPAN></P>
<P class=MsoNormal style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in"><SPAN
style="FONT-FAMILY: Palatino Linotype"><FONT size=4>2)</FONT><SPAN
style="FONT-WEIGHT: normal; FONT-STYLE: normal; FONT-FAMILY: Times New Roman; FONT-VARIANT: normal"><FONT
size=4> </FONT></SPAN></SPAN><I><SPAN
style="FONT-FAMILY: Palatino Linotype"><FONT size=4>To avoid real or
perceived conflicts of interest whenever possible, and to disclose them to
affected parties when they do exists: </FONT></SPAN></I><SPAN
style="FONT-FAMILY: Palatino Linotype"><FONT size=4>No conflicts of
interests arose during this project</FONT></SPAN></P>
<P class=MsoNormal style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in"><SPAN
style="FONT-FAMILY: Palatino Linotype"><FONT size=4>3)</FONT><SPAN
style="FONT-WEIGHT: normal; FONT-STYLE: normal; FONT-FAMILY: Times New Roman; FONT-VARIANT: normal"><FONT
size=4> </FONT></SPAN></SPAN><I><SPAN
style="FONT-FAMILY: Palatino Linotype"><FONT size=4>To be honest and
realistic in stating claims or estimates based on available data:
</FONT></SPAN></I><SPAN style="FONT-FAMILY: Palatino Linotype"><FONT
size=4>All data, schematics, hardware/software descriptions, costs, and
results in this report are correct.</FONT></SPAN></P>
<P class=MsoNormal style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in"><SPAN
style="FONT-FAMILY: Palatino Linotype"><FONT size=4>4)</FONT><SPAN
style="FONT-WEIGHT: normal; FONT-STYLE: normal; FONT-FAMILY: Times New Roman; FONT-VARIANT: normal"><FONT
size=4> </FONT></SPAN></SPAN><I><SPAN
style="FONT-FAMILY: Palatino Linotype"><FONT size=4>To reject bribery in all
its forms: </FONT></SPAN></I><SPAN
style="FONT-FAMILY: Palatino Linotype"><FONT size=4>Nobody would have bribed
us for this project. </FONT></SPAN></P>
<P class=MsoNormal style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in"><SPAN
style="FONT-FAMILY: Palatino Linotype"><FONT size=4>5)</FONT><SPAN
style="FONT-WEIGHT: normal; FONT-STYLE: normal; FONT-FAMILY: Times New Roman; FONT-VARIANT: normal"><FONT
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -