Web edits
[beagleboard.org.git] / db / 2819.xml
blob65f5a57bcafb1acfd94ef4317ec90a5e38c73595
1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <?xml-stylesheet type="text/xsl" href="helma.xsl"?>
3 <xmlroot xmlns:hop="http://www.helma.org/docs/guide/features/database">
4   <hopobject id="2819" name="Ultrasonic_Sensor" prototype="Page" created="1372690591672" lastModified="1387489017908">
5   <hop:parent idref="2471" prototyperef="Page"/>
6     <is_xhtml type="boolean">true</is_xhtml>
7     <http_remotehost>192.94.94.105</http_remotehost>
8     <http_language>en-US,en;q=0.8,fr;q=0.6</http_language>
9     <uri>Ultrasonic_Sensor</uri>
10     <http_browser>Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36</http_browser>
11     <time type="date">19.12.2013 15:36:57 CST</time>
12     <hopsession>192.94.94.9otttzsp6btn</hopsession>
13     <body>&lt;script src=&quot;/static/bonescript-demo.js&quot;&gt;&lt;/script&gt;\r
14 &lt;div id=&apos;side-menu&apos; class=&quot;t3_sidebar&quot;&gt;\r
15     &lt;ul class=&quot;left-menu&quot;&gt;&lt;strong&gt;Navigation&lt;/strong&gt;\r
16         &lt;li&gt;&lt;a href=&quot;/static/side-menu.html&quot;&gt;Menu contents&lt;/a&gt;&lt;/li&gt;\r
17     &lt;/ul&gt;\r
18 &lt;/div&gt;\r
19 &lt;div class=&quot;t3_content_1&quot;&gt;&lt;div id=&apos;connect-status&apos;&gt;&lt;/div&gt;&lt;div id=&quot;content_child&quot;&gt;\r
20 &lt;h1&gt;Demo: Maxbotic Ultrasonic Sensor&lt;/h1&gt;\r
21 &lt;p&gt;The &lt;a href=&quot;http://www.maxbotix.com/Ultrasonic_Sensors/MB1020.htm&quot;&gt;LV-MaxSonar-EZ2 High Performance Sonar Range Finder&lt;/a&gt; provides very short\r
22 to long-range detection and ranging, in an incredibly small package. The sonar\r
23 detects objects from 0-254 inches and provides sonar range information from 6-inches\r
24 out to 254-inches with 1-inch resolution.\r
25 &lt;/p&gt;\r
26 &lt;i&gt;Note: Each time after the Sonar is powered up, it will calibrate\r
27 during its first read cycle. The sensor uses this stored \r
28 information to range a near object. It is important that objects\r
29 not be close to the sensor during this calibration cycle. The\r
30 best sensitivity is obtained when it is clear for fourteen \r
31 inches, but good results are common when clear for at least\r
32 seven inches. If an object is too bear the Sonar during the calibration\r
33 cycle, the sensor may then ignore the objects at that distance.\r
34 To calibrate the LV-MAX Sonar, cycle power then command a read\r
35 cycle.&lt;/i&gt;&lt;br&gt;&lt;br&gt;\r
37 The AN pin outputs a voltage with a scaling factor of (V&lt;sub&gt;cc&lt;/sub&gt;/512) per inch. Since the AIN pin has a maximum voltage capacity of 1.8V, we will set a voltage divider to account for that difference. With the voltage divider, a supply of 5V yields ~6.99mV/in. and 3.3V yields ~4.57mV/in.\r
38 &lt;br&gt;\r
42 &lt;h2&gt;Example\r
43  &lt;button class=&quot;dynlink&quot; onclick=&quot;demoRun(&apos;code&apos;)&quot;&gt;run&lt;/button&gt;\r
44  &lt;button class=&quot;dynlink&quot; onclick=&quot;demoRestore(&apos;code&apos;)&quot;&gt;restore&lt;/button&gt;\r
45 &lt;/h2&gt;\r
46 &lt;pre id=&quot;code&quot; class=&quot;use-editor&quot; style=&quot;height:310px;&quot;&gt;\r
47 var b = require(&apos;bonescript&apos;);\r
48 var analogVoltage = 0;\r
50 /* Check the sensor values every 2 seconds*/\r
51 setInterval(read, 2000);\r
53 function read(){\r
54     b.analogRead(&apos;P9_40&apos;, printStatus);\r
55 }\r
57 function printStatus(x) {\r
58     var distanceInches;\r
59     analogVoltage = x.value*1.8; // ADC Value converted to voltage\r
60     console.log(&apos;x.value = &apos; + analogVoltage); \r
61     distanceInches = analogVoltage / 0.00699;\r
62     console.log(&quot;There is an object &quot; + \r
63     parseFloat(distanceInches).toFixed(3) + &quot; inches away.&quot;);\r
64 }\r
65 &lt;/pre&gt;\r
66 &lt;div readonly id=&apos;console-output&apos; style=&quot;height:100px;&quot;&gt;&lt;/div&gt;\r
67 &lt;br&gt;&lt;/br&gt;\r
68 &lt;img align=&quot;right&quot; width=&quot;60%&quot; src=&quot;http://beagleboard.org/static/uploads/VD%20Ultrasonic%20Sensor.PNG&quot;/&gt;\r
69 &lt;br&gt;&lt;/br&gt;\r
70 &lt;h2&gt;Build and execute instructions&lt;/h2&gt;\r
71 &lt;ul&gt;\r
72  &lt;li&gt;Connect the &quot;GND&quot; pin from the sensor to P9_1 of the board&lt;/li&gt;\r
73  &lt;li&gt;Connect the &quot;+5&quot; pin from the sensor to P9_3 of the board&lt;/li&gt;\r
74  &lt;li&gt;Connect the 1.2kohm resistor to the AN pin of the supersonic sensor.&lt;/li&gt;\r
75  &lt;li&gt;Connect the 3k ohm resistor in series with the 1.2k ohm resistor and tie the bottom to ground, as shown in the diagram.&lt;/li&gt;\r
76  &lt;li&gt;Connect P9_40 of BeagleBone in series with the 3k ohm and 1.k ohm resistor.&lt;/li&gt;\r
77  &lt;li&gt;Click &quot;Run&quot; on the code and it will output the distance, in inches, that the\r
78  sensor is detecting... updating every 5 seconds&lt;/li&gt;\r
79  &lt;li&gt;Move the sensor nearer to or farther from an object to see the change in distance&lt;/li&gt;\r
80 &lt;/ul&gt;\r
82 &lt;h2&gt;See also&lt;/h2&gt;\r
83 &lt;h3&gt;Related functions&lt;/h3&gt;\r
84 &lt;ul&gt;\r
85  &lt;li&gt;&lt;a href=&quot;/Support/BoneScript/#require&quot;&gt;require&lt;/a&gt;&lt;/li&gt;\r
86  &lt;li&gt;&lt;a href=&quot;/Support/BoneScript/analogRead/&quot;&gt;analogRead&lt;/a&gt;&lt;/li&gt;\r
87  &lt;li&gt;&lt;a href=&quot;http://beagleboard.org/Support/BoneScript/#timers&quot;&gt;setInterval&lt;/a&gt;&lt;/li&gt;\r
88 &lt;/ul&gt;\r
90 &lt;h3&gt;Where to buy&lt;/h3&gt;\r
91 &lt;ul&gt;\r
92 &lt;li&gt; &lt;a href=&quot;http://elinux.org/CircuitCo:BeagleBone_Breadboard#Distributors&quot;&gt;BreadBoard&lt;/a&gt;&lt;/li&gt;\r
93 &lt;li&gt;&lt;a href=&quot;https://www.sparkfun.com/products/11026&quot;&gt;Jumper wires&lt;/a&gt;&lt;/li&gt;\r
94 &lt;li&gt; &lt;a href=&quot;https://www.sparkfun.com/search/products?sort_by=relevance%7Casc&amp;per_page=500&amp;term=resistor&quot;&gt;Resistors&lt;/a&gt;&lt;/li&gt;\r
95  &lt;li&gt;&lt;a href=&quot;http://www.adafruit.com/products/980&quot;&gt;Ultrasonic sensor&lt;/a&gt;&lt;/li&gt;\r
96 &lt;/ul&gt;\r
98 &lt;h2&gt;See it in action&lt;/h2&gt;\r
99 &lt;iframe width=&quot;560&quot; height=&quot;315&quot; src=&quot;//www.youtube.com/embed/SFdKIRi7T3s&quot; frameborder=&quot;0&quot; allowfullscreen&gt;&lt;/iframe&gt;</body>
100     <pseudoparent idref="2471" prototyperef="Page"/>
101     <http_referer>http://beagleboard.org/support/BoneScript/Ultrasonic_Sensor/edit</http_referer>
102     <http_host>beagleboard.org</http_host>
103     <user>jessica.lynne.callaway@gmail.com</user>
104     <lang>en-us</lang>
105   </hopobject>
106 </xmlroot>