335 lines
32 KiB
HTML
335 lines
32 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
|
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
|
<meta name="generator" content="Doxygen 1.8.13"/>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
<title>Arduino {code}racer API: Methods</title>
|
|
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="../../jquery.js"></script>
|
|
<script type="text/javascript" src="../../dynsections.js"></script>
|
|
<link href="../../navtree.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="../../resize.js"></script>
|
|
<script type="text/javascript" src="../../navtreedata.js"></script>
|
|
<script type="text/javascript" src="../../navtree.js"></script>
|
|
<script type="text/javascript">
|
|
$(document).ready(initResizable);
|
|
</script>
|
|
<link href="../../search/search.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="../../search/searchdata.js"></script>
|
|
<script type="text/javascript" src="../../search/search.js"></script>
|
|
<link href="../../doxygen.css" rel="stylesheet" type="text/css" />
|
|
</head>
|
|
<body>
|
|
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
|
<div id="titlearea">
|
|
<table cellspacing="0" cellpadding="0">
|
|
<tbody>
|
|
<tr style="height: 56px;">
|
|
<td id="projectlogo"><img alt="Logo" src="../../coderace_logo.JPG"/></td>
|
|
<td id="projectalign" style="padding-left: 0.5em;">
|
|
<div id="projectname">Arduino {code}racer API
|
|
</div>
|
|
<div id="projectbrief">... better know the details.</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<!-- end header part -->
|
|
<!-- Generated by Doxygen 1.8.13 -->
|
|
<script type="text/javascript">
|
|
var searchBox = new SearchBox("searchBox", "../../search",false,'Search');
|
|
</script>
|
|
<script type="text/javascript" src="../../menudata.js"></script>
|
|
<script type="text/javascript" src="../../menu.js"></script>
|
|
<script type="text/javascript">
|
|
$(function() {
|
|
initMenu('../../',true,false,'search.php','Search');
|
|
$(document).ready(function() { init_search(); });
|
|
});
|
|
</script>
|
|
<div id="main-nav"></div>
|
|
</div><!-- top -->
|
|
<div id="side-nav" class="ui-resizable side-nav-resizable">
|
|
<div id="nav-tree">
|
|
<div id="nav-tree-contents">
|
|
<div id="nav-sync" class="sync"></div>
|
|
</div>
|
|
</div>
|
|
<div id="splitbar" style="-moz-user-select:none;"
|
|
class="ui-resizable-handle">
|
|
</div>
|
|
</div>
|
|
<script type="text/javascript">
|
|
$(document).ready(function(){initNavTree('d6/dfc/group__lowerlevelusmeths.html','../../');});
|
|
</script>
|
|
<div id="doc-content">
|
|
<!-- window showing the filter options -->
|
|
<div id="MSearchSelectWindow"
|
|
onmouseover="return searchBox.OnSearchSelectShow()"
|
|
onmouseout="return searchBox.OnSearchSelectHide()"
|
|
onkeydown="return searchBox.OnSearchSelectKey(event)">
|
|
</div>
|
|
|
|
<!-- iframe showing the search results (closed by default) -->
|
|
<div id="MSearchResultsWindow">
|
|
<iframe src="javascript:void(0)" frameborder="0"
|
|
name="MSearchResults" id="MSearchResults">
|
|
</iframe>
|
|
</div>
|
|
|
|
<div class="header">
|
|
<div class="summary">
|
|
<a href="#func-members">Functions</a> </div>
|
|
<div class="headertitle">
|
|
<div class="title">Methods<div class="ingroups"><a class="el" href="../../da/daf/group__lowerlevelus.html">Lower level ultra sonic methods and getters</a></div></div> </div>
|
|
</div><!--header-->
|
|
<div class="contents">
|
|
<table class="memberdecls">
|
|
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
|
|
Functions</h2></td></tr>
|
|
<tr class="memitem:ga5f034198a28b069478c454c63dbfa225"><td class="memItemLeft" align="right" valign="top">unsigned long </td><td class="memItemRight" valign="bottom"><a class="el" href="../../d6/dfc/group__lowerlevelusmeths.html#ga5f034198a28b069478c454c63dbfa225">CodeRacer::usonic_measure_cm</a> ()</td></tr>
|
|
<tr class="memdesc:ga5f034198a28b069478c454c63dbfa225"><td class="mdescLeft"> </td><td class="mdescRight">Measures the distance to the next object in front of the ultra sonic sensor in cm. <a href="#ga5f034198a28b069478c454c63dbfa225">More...</a><br /></td></tr>
|
|
<tr class="separator:ga5f034198a28b069478c454c63dbfa225"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:gaa01602a576fd57609bc7e08f8ef32e58"><td class="memItemLeft" align="right" valign="top">unsigned long </td><td class="memItemRight" valign="bottom"><a class="el" href="../../d6/dfc/group__lowerlevelusmeths.html#gaa01602a576fd57609bc7e08f8ef32e58">CodeRacer::usonic_measure_us</a> ()</td></tr>
|
|
<tr class="memdesc:gaa01602a576fd57609bc7e08f8ef32e58"><td class="mdescLeft"> </td><td class="mdescRight">Measures the distance to the next object in front of the ultra sonic sensor in microseconds. <a href="#gaa01602a576fd57609bc7e08f8ef32e58">More...</a><br /></td></tr>
|
|
<tr class="separator:gaa01602a576fd57609bc7e08f8ef32e58"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:gafdd5c75d7a8e7b7c993e512ee93dde9a"><td class="memItemLeft" align="right" valign="top">unsigned long </td><td class="memItemRight" valign="bottom"><a class="el" href="../../d6/dfc/group__lowerlevelusmeths.html#gafdd5c75d7a8e7b7c993e512ee93dde9a">CodeRacer::usonic_measure_cm</a> (unsigned long max_echo_run_time_us)</td></tr>
|
|
<tr class="memdesc:gafdd5c75d7a8e7b7c993e512ee93dde9a"><td class="mdescLeft"> </td><td class="mdescRight">Measures the distance to the next object in front of the ultra sonic sensor in cm. <a href="#gafdd5c75d7a8e7b7c993e512ee93dde9a">More...</a><br /></td></tr>
|
|
<tr class="separator:gafdd5c75d7a8e7b7c993e512ee93dde9a"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:ga1f3401ef472cb11997e7dc98ef3e2424"><td class="memItemLeft" align="right" valign="top">unsigned long </td><td class="memItemRight" valign="bottom"><a class="el" href="../../d6/dfc/group__lowerlevelusmeths.html#ga1f3401ef472cb11997e7dc98ef3e2424">CodeRacer::usonic_measure_us</a> (unsigned long max_echo_run_time_us)</td></tr>
|
|
<tr class="memdesc:ga1f3401ef472cb11997e7dc98ef3e2424"><td class="mdescLeft"> </td><td class="mdescRight">Measures the distance to the next object in front of the ultra sonic sensor in microseconds. <a href="#ga1f3401ef472cb11997e7dc98ef3e2424">More...</a><br /></td></tr>
|
|
<tr class="separator:ga1f3401ef472cb11997e7dc98ef3e2424"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:ga0c00edbbf4a3169613c9ea84d6e7dc13"><td class="memItemLeft" align="right" valign="top">unsigned long </td><td class="memItemRight" valign="bottom"><a class="el" href="../../d6/dfc/group__lowerlevelusmeths.html#ga0c00edbbf4a3169613c9ea84d6e7dc13">CodeRacer::usonic_measure_single_shot_cm</a> ()</td></tr>
|
|
<tr class="memdesc:ga0c00edbbf4a3169613c9ea84d6e7dc13"><td class="mdescLeft"> </td><td class="mdescRight">Measures the distance to the next object in front of the ultra sonic sensor in cm. <a href="#ga0c00edbbf4a3169613c9ea84d6e7dc13">More...</a><br /></td></tr>
|
|
<tr class="separator:ga0c00edbbf4a3169613c9ea84d6e7dc13"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:gad4309b6da17085575fb0c55559e240b8"><td class="memItemLeft" align="right" valign="top">unsigned long </td><td class="memItemRight" valign="bottom"><a class="el" href="../../d6/dfc/group__lowerlevelusmeths.html#gad4309b6da17085575fb0c55559e240b8">CodeRacer::usonic_measure_single_shot_us</a> ()</td></tr>
|
|
<tr class="memdesc:gad4309b6da17085575fb0c55559e240b8"><td class="mdescLeft"> </td><td class="mdescRight">Measures the distance to the next object in front of the ultra sonic sensor in microseconds. <a href="#gad4309b6da17085575fb0c55559e240b8">More...</a><br /></td></tr>
|
|
<tr class="separator:gad4309b6da17085575fb0c55559e240b8"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:gab413551ea8a67e1b60eda1671029b645"><td class="memItemLeft" align="right" valign="top">unsigned long </td><td class="memItemRight" valign="bottom"><a class="el" href="../../d6/dfc/group__lowerlevelusmeths.html#gab413551ea8a67e1b60eda1671029b645">CodeRacer::usonic_measure_single_shot_cm</a> (unsigned long max_echo_run_time_us)</td></tr>
|
|
<tr class="memdesc:gab413551ea8a67e1b60eda1671029b645"><td class="mdescLeft"> </td><td class="mdescRight">Measures the distance to the next object in front of the ultra sonic sensor in cm. <a href="#gab413551ea8a67e1b60eda1671029b645">More...</a><br /></td></tr>
|
|
<tr class="separator:gab413551ea8a67e1b60eda1671029b645"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:ga1b5b43372082f5daeee47410a09a590c"><td class="memItemLeft" align="right" valign="top">unsigned long </td><td class="memItemRight" valign="bottom"><a class="el" href="../../d6/dfc/group__lowerlevelusmeths.html#ga1b5b43372082f5daeee47410a09a590c">CodeRacer::usonic_measure_single_shot_us</a> (unsigned long max_echo_run_time_us)</td></tr>
|
|
<tr class="memdesc:ga1b5b43372082f5daeee47410a09a590c"><td class="mdescLeft"> </td><td class="mdescRight">Measures the distance to the next object in front of the ultra sonic sensor in microseconds. <a href="#ga1b5b43372082f5daeee47410a09a590c">More...</a><br /></td></tr>
|
|
<tr class="separator:ga1b5b43372082f5daeee47410a09a590c"><td class="memSeparator" colspan="2"> </td></tr>
|
|
</table>
|
|
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
|
|
<h2 class="groupheader">Function Documentation</h2>
|
|
<a id="ga5f034198a28b069478c454c63dbfa225"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#ga5f034198a28b069478c454c63dbfa225">◆ </a></span>usonic_measure_cm() <span class="overload">[1/2]</span></h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">unsigned long CodeRacer::usonic_measure_cm </td>
|
|
<td>(</td>
|
|
<td class="paramname"></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Measures the distance to the next object in front of the ultra sonic sensor in cm. </p>
|
|
<p>This is the medium one out of 3 measurements. The maximum measured distance is about 100cm and defined by the US_MAX_ECHO_TIME_US setting in the header file. </p><dl class="section return"><dt>Returns</dt><dd>The measured distance in cm. </dd></dl>
|
|
|
|
<p class="definition">Definition at line <a class="el" href="../../d4/da7/_code_racer_8cpp_source.html#l00672">672</a> of file <a class="el" href="../../d4/da7/_code_racer_8cpp_source.html">CodeRacer.cpp</a>.</p>
|
|
<div class="fragment"><div class="line"><a name="l00673"></a><span class="lineno"> 673</span> {</div><div class="line"><a name="l00674"></a><span class="lineno"> 674</span>  <span class="keywordflow">return</span>(usonic_measure_cm(US_MAX_ECHO_TIME_US));</div><div class="line"><a name="l00675"></a><span class="lineno"> 675</span> }</div></div><!-- fragment -->
|
|
</div>
|
|
</div>
|
|
<a id="gaa01602a576fd57609bc7e08f8ef32e58"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#gaa01602a576fd57609bc7e08f8ef32e58">◆ </a></span>usonic_measure_us() <span class="overload">[1/2]</span></h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">unsigned long CodeRacer::usonic_measure_us </td>
|
|
<td>(</td>
|
|
<td class="paramname"></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Measures the distance to the next object in front of the ultra sonic sensor in microseconds. </p>
|
|
<p>This is the medium one out of 3 measurements. The maximum measured distance is about 6000 microseconds and defined by the US_MAX_ECHO_TIME_US setting in the header file. </p><dl class="section return"><dt>Returns</dt><dd>The measured distance in microseconds. </dd></dl>
|
|
|
|
<p class="definition">Definition at line <a class="el" href="../../d4/da7/_code_racer_8cpp_source.html#l00682">682</a> of file <a class="el" href="../../d4/da7/_code_racer_8cpp_source.html">CodeRacer.cpp</a>.</p>
|
|
<div class="fragment"><div class="line"><a name="l00683"></a><span class="lineno"> 683</span>  {</div><div class="line"><a name="l00684"></a><span class="lineno"> 684</span>  <span class="keywordflow">return</span>(usonic_measure_us(US_MAX_ECHO_TIME_US));</div><div class="line"><a name="l00685"></a><span class="lineno"> 685</span>  }</div></div><!-- fragment -->
|
|
</div>
|
|
</div>
|
|
<a id="gafdd5c75d7a8e7b7c993e512ee93dde9a"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#gafdd5c75d7a8e7b7c993e512ee93dde9a">◆ </a></span>usonic_measure_cm() <span class="overload">[2/2]</span></h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">unsigned long CodeRacer::usonic_measure_cm </td>
|
|
<td>(</td>
|
|
<td class="paramtype">unsigned long </td>
|
|
<td class="paramname"><em>max_echo_run_time_us</em></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Measures the distance to the next object in front of the ultra sonic sensor in cm. </p>
|
|
<p>This is the medium one out of 3 measurements. Be careful with high values for max_echo_run_time_us - this may increase run time due to the fact that if there is nothing in range of the sensor it will wait until this specified run time of the echo is over. The maximum range the sensor is specified for is about 300cm. </p><dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">max_echo_run_time_us</td><td>Defines the maximum echo run time and by that the maximum of distance that can be measured. </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section return"><dt>Returns</dt><dd>The measured distance in cm. </dd></dl>
|
|
|
|
<p class="definition">Definition at line <a class="el" href="../../d4/da7/_code_racer_8cpp_source.html#l00694">694</a> of file <a class="el" href="../../d4/da7/_code_racer_8cpp_source.html">CodeRacer.cpp</a>.</p>
|
|
<div class="fragment"><div class="line"><a name="l00695"></a><span class="lineno"> 695</span> {</div><div class="line"><a name="l00696"></a><span class="lineno"> 696</span>  <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> echo_runtime_us = usonic_measure_us(max_echo_run_time_us);</div><div class="line"><a name="l00697"></a><span class="lineno"> 697</span>  <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> distance_cm = echo_runtime_us * 0.0172;</div><div class="line"><a name="l00698"></a><span class="lineno"> 698</span>  <span class="comment">//Serial.print("MEASURE_DISTANCE. Distance in cm is: ");</span></div><div class="line"><a name="l00699"></a><span class="lineno"> 699</span>  <span class="comment">//Serial.println(distance_cm);</span></div><div class="line"><a name="l00700"></a><span class="lineno"> 700</span>  _usonic_distance_cm = distance_cm;</div><div class="line"><a name="l00701"></a><span class="lineno"> 701</span>  <span class="keywordflow">return</span>(distance_cm);</div><div class="line"><a name="l00702"></a><span class="lineno"> 702</span> }</div></div><!-- fragment -->
|
|
</div>
|
|
</div>
|
|
<a id="ga1f3401ef472cb11997e7dc98ef3e2424"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#ga1f3401ef472cb11997e7dc98ef3e2424">◆ </a></span>usonic_measure_us() <span class="overload">[2/2]</span></h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">unsigned long CodeRacer::usonic_measure_us </td>
|
|
<td>(</td>
|
|
<td class="paramtype">unsigned long </td>
|
|
<td class="paramname"><em>max_echo_run_time_us</em></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Measures the distance to the next object in front of the ultra sonic sensor in microseconds. </p>
|
|
<p>This is the medium one out of 3 measurements. Be careful with high values for max_echo_run_time_us - this may increase run time due to the fact that if there is nothing in range of the sensor it will wait until this specified run time of the echo is over. The maximum range the sensor is specified for is about 300cm. </p><dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">max_echo_run_time_us</td><td>Defines the maximum echo run time in microseconds and by that the maximum of distance that can be measured. </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section return"><dt>Returns</dt><dd>The measured distance in microseconds. </dd></dl>
|
|
|
|
<p class="definition">Definition at line <a class="el" href="../../d4/da7/_code_racer_8cpp_source.html#l00711">711</a> of file <a class="el" href="../../d4/da7/_code_racer_8cpp_source.html">CodeRacer.cpp</a>.</p>
|
|
<div class="fragment"><div class="line"><a name="l00712"></a><span class="lineno"> 712</span> {</div><div class="line"><a name="l00713"></a><span class="lineno"> 713</span>  <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> echo_runtime_us[3] = { 0,0,0 };</div><div class="line"><a name="l00714"></a><span class="lineno"> 714</span>  uint8_t measnr = 0;</div><div class="line"><a name="l00715"></a><span class="lineno"> 715</span> </div><div class="line"><a name="l00716"></a><span class="lineno"> 716</span>  <span class="keywordflow">do</span> {</div><div class="line"><a name="l00717"></a><span class="lineno"> 717</span>  echo_runtime_us[measnr] = usonic_measure_single_shot_us(max_echo_run_time_us);</div><div class="line"><a name="l00718"></a><span class="lineno"> 718</span>  <span class="keywordflow">if</span> (echo_runtime_us[measnr] > 200) {</div><div class="line"><a name="l00719"></a><span class="lineno"> 719</span>  measnr++;</div><div class="line"><a name="l00720"></a><span class="lineno"> 720</span>  }</div><div class="line"><a name="l00721"></a><span class="lineno"> 721</span>  } <span class="keywordflow">while</span> (measnr < 3);</div><div class="line"><a name="l00722"></a><span class="lineno"> 722</span> </div><div class="line"><a name="l00723"></a><span class="lineno"> 723</span>  <span class="comment">// we will take the medium out of 3 values ... </span></div><div class="line"><a name="l00724"></a><span class="lineno"> 724</span>  <span class="keywordflow">if</span> (echo_runtime_us[0] > echo_runtime_us[1]) { std::swap(echo_runtime_us[0], echo_runtime_us[1]); }</div><div class="line"><a name="l00725"></a><span class="lineno"> 725</span>  <span class="keywordflow">if</span> (echo_runtime_us[1] > echo_runtime_us[2]) { std::swap(echo_runtime_us[1], echo_runtime_us[2]); }</div><div class="line"><a name="l00726"></a><span class="lineno"> 726</span>  <span class="keywordflow">if</span> (echo_runtime_us[0] > echo_runtime_us[1]) { std::swap(echo_runtime_us[0], echo_runtime_us[1]); }</div><div class="line"><a name="l00727"></a><span class="lineno"> 727</span> </div><div class="line"><a name="l00728"></a><span class="lineno"> 728</span>  <span class="comment">//Serial.print("MEASURE_DISTANCE_US. Echo runtime in us is: ");</span></div><div class="line"><a name="l00729"></a><span class="lineno"> 729</span>  <span class="comment">//Serial.println(echo_runtime_us[1]);</span></div><div class="line"><a name="l00730"></a><span class="lineno"> 730</span> </div><div class="line"><a name="l00731"></a><span class="lineno"> 731</span>  <span class="comment">// if the stop at minimal distance is enabeled - check for minimal distance is reached</span></div><div class="line"><a name="l00732"></a><span class="lineno"> 732</span>  <span class="keywordflow">if</span> (<span class="keyword">true</span> == _coderacer_stop_at_distance_enabled) {</div><div class="line"><a name="l00733"></a><span class="lineno"> 733</span>  <span class="keywordflow">if</span> (echo_runtime_us[1] <= _usonic_stop_distance_us) {</div><div class="line"><a name="l00734"></a><span class="lineno"> 734</span>  _coderacer_stopped_at_min_distance = <span class="keyword">true</span>;</div><div class="line"><a name="l00735"></a><span class="lineno"> 735</span>  stop_driving();</div><div class="line"><a name="l00736"></a><span class="lineno"> 736</span>  _coderacer_stop_at_distance_enabled = <span class="keyword">false</span>;</div><div class="line"><a name="l00737"></a><span class="lineno"> 737</span>  }</div><div class="line"><a name="l00738"></a><span class="lineno"> 738</span>  }</div><div class="line"><a name="l00739"></a><span class="lineno"> 739</span>  _usonic_distance_us = echo_runtime_us[1];</div><div class="line"><a name="l00740"></a><span class="lineno"> 740</span>  <span class="keywordflow">return</span>(echo_runtime_us[1]);</div><div class="line"><a name="l00741"></a><span class="lineno"> 741</span> }</div></div><!-- fragment -->
|
|
</div>
|
|
</div>
|
|
<a id="ga0c00edbbf4a3169613c9ea84d6e7dc13"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#ga0c00edbbf4a3169613c9ea84d6e7dc13">◆ </a></span>usonic_measure_single_shot_cm() <span class="overload">[1/2]</span></h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">unsigned long CodeRacer::usonic_measure_single_shot_cm </td>
|
|
<td>(</td>
|
|
<td class="paramname"></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Measures the distance to the next object in front of the ultra sonic sensor in cm. </p>
|
|
<p>This is a one shot measurement. The maximum measured distance is about 6000 microseconds and defined by the US_MAX_ECHO_TIME_US setting in the header file. </p><dl class="section return"><dt>Returns</dt><dd>The measured distance in cm. </dd></dl>
|
|
|
|
<p class="definition">Definition at line <a class="el" href="../../d4/da7/_code_racer_8cpp_source.html#l00748">748</a> of file <a class="el" href="../../d4/da7/_code_racer_8cpp_source.html">CodeRacer.cpp</a>.</p>
|
|
<div class="fragment"><div class="line"><a name="l00749"></a><span class="lineno"> 749</span> {</div><div class="line"><a name="l00750"></a><span class="lineno"> 750</span>  <span class="keywordflow">return</span>(usonic_measure_single_shot_cm(US_MAX_ECHO_TIME_US));</div><div class="line"><a name="l00751"></a><span class="lineno"> 751</span> }</div></div><!-- fragment -->
|
|
</div>
|
|
</div>
|
|
<a id="gad4309b6da17085575fb0c55559e240b8"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#gad4309b6da17085575fb0c55559e240b8">◆ </a></span>usonic_measure_single_shot_us() <span class="overload">[1/2]</span></h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">unsigned long CodeRacer::usonic_measure_single_shot_us </td>
|
|
<td>(</td>
|
|
<td class="paramname"></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Measures the distance to the next object in front of the ultra sonic sensor in microseconds. </p>
|
|
<p>This is a one shot measurement. The maximum measured distance is about 6000 microseconds and defined by the US_MAX_ECHO_TIME_US setting in the header file. </p><dl class="section return"><dt>Returns</dt><dd>The measured distance in microseconds. </dd></dl>
|
|
|
|
<p class="definition">Definition at line <a class="el" href="../../d4/da7/_code_racer_8cpp_source.html#l00758">758</a> of file <a class="el" href="../../d4/da7/_code_racer_8cpp_source.html">CodeRacer.cpp</a>.</p>
|
|
<div class="fragment"><div class="line"><a name="l00759"></a><span class="lineno"> 759</span> {</div><div class="line"><a name="l00760"></a><span class="lineno"> 760</span>  <span class="keywordflow">return</span>(usonic_measure_single_shot_us(US_MAX_ECHO_TIME_US));</div><div class="line"><a name="l00761"></a><span class="lineno"> 761</span> }</div></div><!-- fragment -->
|
|
</div>
|
|
</div>
|
|
<a id="gab413551ea8a67e1b60eda1671029b645"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#gab413551ea8a67e1b60eda1671029b645">◆ </a></span>usonic_measure_single_shot_cm() <span class="overload">[2/2]</span></h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">unsigned long CodeRacer::usonic_measure_single_shot_cm </td>
|
|
<td>(</td>
|
|
<td class="paramtype">unsigned long </td>
|
|
<td class="paramname"><em>max_echo_run_time_us</em></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Measures the distance to the next object in front of the ultra sonic sensor in cm. </p>
|
|
<p>This is a one shot measurement. Be careful with high values for max_echo_run_time_us - this may increase run time due to the fact that if there is nothing in range of the sensor it will wait until this specified run time of the echo is over. The maximum range the sensor is specified for is about 300cm. </p><dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">max_echo_run_time_us</td><td>Defines the maximum echo run time in microseconds and by that the maximum of distance that can be measured. </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section return"><dt>Returns</dt><dd>The measured distance in cm. </dd></dl>
|
|
|
|
<p class="definition">Definition at line <a class="el" href="../../d4/da7/_code_racer_8cpp_source.html#l00770">770</a> of file <a class="el" href="../../d4/da7/_code_racer_8cpp_source.html">CodeRacer.cpp</a>.</p>
|
|
<div class="fragment"><div class="line"><a name="l00771"></a><span class="lineno"> 771</span> {</div><div class="line"><a name="l00772"></a><span class="lineno"> 772</span>  <span class="comment">// convert into cm ... 344m/sec is the speed of noise - thus 34400cm/sec ... or 34,400cm/milisec ... or 0,0344cm/microsec</span></div><div class="line"><a name="l00773"></a><span class="lineno"> 773</span>  <span class="comment">// the echo has to go the distance twice - forth and back - so the duration has to be the half of the measured one</span></div><div class="line"><a name="l00774"></a><span class="lineno"> 774</span>  <span class="comment">// distance_cm = echo_duration/2 * 0,0344 or distance_cm = echo_duration/2 / 29,1 or distance_cm = echo_duration * 0,0172</span></div><div class="line"><a name="l00775"></a><span class="lineno"> 775</span>  <span class="comment">// distance_cm = (echo_duration/2) / 29.1;</span></div><div class="line"><a name="l00776"></a><span class="lineno"> 776</span>  <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> echo_runtime_us = usonic_measure_single_shot_us(max_echo_run_time_us);</div><div class="line"><a name="l00777"></a><span class="lineno"> 777</span>  <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> distance_cm = echo_runtime_us * 0.0172;</div><div class="line"><a name="l00778"></a><span class="lineno"> 778</span>  <span class="comment">//Serial.print("MEASURE_DISTANCE. Distance in cm is: ");</span></div><div class="line"><a name="l00779"></a><span class="lineno"> 779</span>  <span class="comment">//Serial.println(distance_cm);</span></div><div class="line"><a name="l00780"></a><span class="lineno"> 780</span>  _usonic_distance_cm = distance_cm;</div><div class="line"><a name="l00781"></a><span class="lineno"> 781</span>  <span class="keywordflow">return</span>(distance_cm);</div><div class="line"><a name="l00782"></a><span class="lineno"> 782</span> }</div></div><!-- fragment -->
|
|
</div>
|
|
</div>
|
|
<a id="ga1b5b43372082f5daeee47410a09a590c"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#ga1b5b43372082f5daeee47410a09a590c">◆ </a></span>usonic_measure_single_shot_us() <span class="overload">[2/2]</span></h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">unsigned long CodeRacer::usonic_measure_single_shot_us </td>
|
|
<td>(</td>
|
|
<td class="paramtype">unsigned long </td>
|
|
<td class="paramname"><em>max_echo_run_time_us</em></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Measures the distance to the next object in front of the ultra sonic sensor in microseconds. </p>
|
|
<p>This is a one shot measurement. Be careful with high values for max_echo_run_time_us - this may increase run time due to the fact that if there is nothing in range of the sensor it will wait until this specified run time of the echo is over. The maximum range the sensor is specified for is about 300cm. </p><dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">max_echo_run_time_us</td><td>Defines the maximum echo run time in microseconds and by that the maximum of distance that can be measured. </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section return"><dt>Returns</dt><dd>The measured distance in microseconds. </dd></dl>
|
|
|
|
<p class="definition">Definition at line <a class="el" href="../../d4/da7/_code_racer_8cpp_source.html#l00791">791</a> of file <a class="el" href="../../d4/da7/_code_racer_8cpp_source.html">CodeRacer.cpp</a>.</p>
|
|
<div class="fragment"><div class="line"><a name="l00792"></a><span class="lineno"> 792</span>  {</div><div class="line"><a name="l00793"></a><span class="lineno"> 793</span>  <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> echo_runtime_us;</div><div class="line"><a name="l00794"></a><span class="lineno"> 794</span>  <span class="comment">// start measurement - send a short pulse "HIGH" to the TRIG pin of the ultrasonic sensor</span></div><div class="line"><a name="l00795"></a><span class="lineno"> 795</span>  pinMode(_us_echo_pin, OUTPUT);</div><div class="line"><a name="l00796"></a><span class="lineno"> 796</span>  pinMode(_us_echo_pin, INPUT);</div><div class="line"><a name="l00797"></a><span class="lineno"> 797</span>  digitalWrite(_us_trigger_pin, LOW);</div><div class="line"><a name="l00798"></a><span class="lineno"> 798</span>  delayMicroseconds(2);</div><div class="line"><a name="l00799"></a><span class="lineno"> 799</span>  digitalWrite(_us_trigger_pin, HIGH);</div><div class="line"><a name="l00800"></a><span class="lineno"> 800</span>  delayMicroseconds(10);</div><div class="line"><a name="l00801"></a><span class="lineno"> 801</span>  digitalWrite(_us_trigger_pin, LOW);</div><div class="line"><a name="l00802"></a><span class="lineno"> 802</span>  <span class="comment">// measure runtime in microseconds until the ECHO pin aof the sensor goes HIGH</span></div><div class="line"><a name="l00803"></a><span class="lineno"> 803</span>  echo_runtime_us = pulseInLong(_us_echo_pin, HIGH, max_echo_run_time_us);</div><div class="line"><a name="l00804"></a><span class="lineno"> 804</span>  <span class="keywordflow">if</span> (echo_runtime_us == 0) {</div><div class="line"><a name="l00805"></a><span class="lineno"> 805</span>  echo_runtime_us = max_echo_run_time_us; <span class="comment">// US_MAX_ECHO_TIME_US;</span></div><div class="line"><a name="l00806"></a><span class="lineno"> 806</span>  }</div><div class="line"><a name="l00807"></a><span class="lineno"> 807</span>  <span class="comment">//Serial.print("MEASURE_DISTANCE_US. Echo runtime in us is: ");</span></div><div class="line"><a name="l00808"></a><span class="lineno"> 808</span>  <span class="comment">//Serial.println(echo_runtime_us);</span></div><div class="line"><a name="l00809"></a><span class="lineno"> 809</span>  _usonic_distance_us = echo_runtime_us;</div><div class="line"><a name="l00810"></a><span class="lineno"> 810</span>  <span class="keywordflow">return</span>(echo_runtime_us);</div><div class="line"><a name="l00811"></a><span class="lineno"> 811</span>  }</div></div><!-- fragment -->
|
|
</div>
|
|
</div>
|
|
</div><!-- contents -->
|
|
</div><!-- doc-content -->
|
|
<!-- start footer part -->
|
|
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
|
|
<ul>
|
|
<li class="footer">Generated on Tue Nov 13 2018 11:13:48 for Arduino {code}racer API by
|
|
<a href="http://www.doxygen.org/index.html">
|
|
<img class="footer" src="../../doxygen.png" alt="doxygen"/></a> 1.8.13 </li>
|
|
</ul>
|
|
</div>
|
|
</body>
|
|
</html>
|