Revision: 1333
Author: sebastien.lelong
Date: Sat Sep 19 14:18:54 2009
Log: first draft for DITA documents: tutorials book
http://code.google.com/p/jallib/source/detail?r=1333

Added:
  /trunk/doc/dita
  /trunk/doc/dita/tutorials
  /trunk/doc/dita/tutorials/images
  /trunk/doc/dita/tutorials/images/cable.jpg
  /trunk/doc/dita/tutorials/images/circuit.jpg
  /trunk/doc/dita/tutorials/images/circuit_pic.jpg
  /trunk/doc/dita/tutorials/images/circuit_ranger.jpg
  /trunk/doc/dita/tutorials/images/connectors.jpg
  /trunk/doc/dita/tutorials/images/diode.jpg
  /trunk/doc/dita/tutorials/images/gp2d02_schematics.png
  /trunk/doc/dita/tutorials/images/timingchart.jpg
  /trunk/doc/dita/tutorials/images/wires.jpg
  /trunk/doc/dita/tutorials/tutorial_gp2d02.xml
  /trunk/doc/dita/tutorials/tutorials.ditamap

=======================================
--- /dev/null   
+++ /trunk/doc/dita/tutorials/images/cable.jpg  Sat Sep 19 14:18:54 2009
Binary file, no diff available.
=======================================
--- /dev/null   
+++ /trunk/doc/dita/tutorials/images/circuit.jpg        Sat Sep 19 14:18:54 2009
Binary file, no diff available.
=======================================
--- /dev/null   
+++ /trunk/doc/dita/tutorials/images/circuit_pic.jpg    Sat Sep 19 14:18:54  
2009
Binary file, no diff available.
=======================================
--- /dev/null   
+++ /trunk/doc/dita/tutorials/images/circuit_ranger.jpg Sat Sep 19 14:18:54  
2009
Binary file, no diff available.
=======================================
--- /dev/null   
+++ /trunk/doc/dita/tutorials/images/connectors.jpg     Sat Sep 19 14:18:54 2009
Binary file, no diff available.
=======================================
--- /dev/null   
+++ /trunk/doc/dita/tutorials/images/diode.jpg  Sat Sep 19 14:18:54 2009
Binary file, no diff available.
=======================================
--- /dev/null   
+++ /trunk/doc/dita/tutorials/images/gp2d02_schematics.png      Sat Sep 19  
14:18:54 2009
Binary file, no diff available.
=======================================
--- /dev/null   
+++ /trunk/doc/dita/tutorials/images/timingchart.jpg    Sat Sep 19 14:18:54  
2009
Binary file, no diff available.
=======================================
--- /dev/null   
+++ /trunk/doc/dita/tutorials/images/wires.jpg  Sat Sep 19 14:18:54 2009
Binary file, no diff available.
=======================================
--- /dev/null
+++ /trunk/doc/dita/tutorials/tutorial_gp2d02.xml       Sat Sep 19 14:18:54 2009
@@ -0,0 +1,92 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd">
+<topic id="topic_gp2d02">
+  <title>Interfacing a Sharp GP2D02 IR ranger</title>
+  <abstract>Sharp IR rangers are widely used out there. There are many  
different references, depending on the beam pattern, the minimal and  
maximal distance you want to be able to get, etc... The way you got results  
also make a difference: either <b>analog</b> (you&apos;ll get a voltage  
proportional to the distance), or <b>digital</b> (you&apos;ll directly get  
a digital value). This nice article will explain these details (and now I  
know GP2D02 seems to be discontinued...)</abstract>
+  <prolog>
+    <author>Sébastien Lelong</author>
+    <publisher>Jallib Group</publisher>
+    <copyright>
+      <copyryear year="2009"/>
+      <copyrholder>Jallib Group</copyrholder>
+    </copyright>
+  </prolog>
+  <body>
+    <section>
+      <title>Overview of GP2D02 IR ranger</title>
+      <p>GP2D02 IR ranger is able to measure distances between approx.  
10cm and 1m. Results are available as digital values you can access through  
a dedicated protocol. One pin, Vin, will be used to act on the ranger.  
Another pin, Vout, will be read to determine the distance. Basically,  
getting a distance involves the following:</p>
+      <p><ol>
+          <li>First you wake up the ranger and tell it to perform a  
distance measure</li>
+          <li>Then, for each bit, you read Vout in order to reconstitute  
the whole byte, that is, the distance</li>
+          <li>finally, you switch off the ranger</li>
+        </ol>The following timing chart taken from the datasheet will  
explain this better.</p>
+      <fig>
+        <title>GD2D02 IR ranger : timing chart</title>
+        <image href="images/timingchart.jpg" width="400"  
placement="break"/>
+      </fig>
+      <note>the distances obtained from the ranger aren&apos;t linear,  
you&apos;ll need some computation to make them so.</note>
+      <p><b>Sharp GP2D02 IR ranger</b> looks like this:</p>
+      <image href="images/wires.jpg" width="400"/>
+      <p><ul>
+          <li><i>Red</i> wire is for +5V</li>
+          <li><i>Black</i> wire ground</li>
+          <li><i>Green</i> wire is for Vin pin, used to control the  
sensor</li>
+          <li><i>Yellow</i> wire is for Vout pin, from which 8-bits  
results read</li>
+        </ul><i>(make a mental note of this...)</i></p>
+    </section>
+    <section>
+      <title>Interfacing the Sharp GP2D02 IR ranger</title>
+      <p>Interfacing such a sensor is quite straight forward. The only  
critical point is <b>Vin</b> ranger pin can&apos;t handle high logic level  
of the PIC&apos;s output, <i>this level mustn&apos;t exceed 3.3 volts</i>.  
A <b>zener diode</b> can be used to limit this level.</p>
+      <note>be careful while connecting this diode. Don&apos;t forget it,  
and don&apos;t put it in the wrong side. You may damage your sensor. And  
I&apos;m not responsible for ! You&apos;ve been warned... That&apos;s said,  
I already forgot it, put it in the wrong side, and thought I&apos;d killed  
my GP2D02, but this one always got back to life. Anyway, be  
cautious !</note>
+      <p>Here&apos;s the whole schematic. The goal here is to collect data  
from the sensor, and light up a LED, more or less according to the read  
distance. That&apos;s why we&apos;ll use a LED driven by PWM.</p>
+      <fig>
+        <title>Interfacing Sharp GP2D02 IR range : schematic</title>
+        <image href="images/gp2d02_schematics.png"/>
+      </fig>
+      <p>Here&apos;s the ranger with the diode soldered on the green wire  
(which is Vin pin, using your previously created mental note...):</p>
+      <image href="images/diode.jpg" width="400" placement="break"/>
+      <p>I&apos;ve also added thermoplastic rubber tubes, to cleanly join  
all the wires:</p>
+      <image href="images/cable.jpg" width="400" placement="break"/>
+      <p>Finally, in order to easily plug/unplug the sensor, I&apos;ve  
soldered nice polarized connectors:</p>
+      <image href="images/connectors.jpg" width="400" placement="break"/>
+    </section>
+    <section>
+      <title>Writing the program</title>
+      <p>jallib &gt;=0.3 contains a library, <xref  
href="http://code.google.com/p/jallib/source/browse/trunk/include/external/ranger/ir/ir_ranger_gp2d02.jal";
  
format="html">ir_ranger_gp2d02.jal</xref>, used to handle this kind of  
rangers. The setup is quite straight forward: just declare your Vin and  
Vout pins, and pass them to the <codeph>gp2d02_read_pins()</codeph>. This  
function returns the distance as a raw value. Directly passing pins allows  
you to have multiple rangers of this type (many robots have many of them  
arranged in the front and back sides, to detect and avoid obstacles).</p>
+      <p>Using PWM libs, we can easily make our LED more or less bright.  
In the mean time, we&apos;ll also transmit the results through a serial  
link.</p>
+      <codeblock>var volatile bit gp2d02_vin is pin_a4
+var volatile bit gp2d02_vout is pin_a6
+var bit gp2d02_vin_direction is pin_a4_direction
+var bit gp2d02_vout_direction is pin_a6_direction
+include ir_ranger_gp2d02
+-- set pin direction (careful: &quot;vin&quot; is the GP2D02 pin&apos;s  
name,
+-- it&apos;s an input for GP2D02, but an output for PIC !)
+gp2d02_vin_direction = output
+gp2d02_vout_direction = input
+
+var byte measure
+forever loop
+   -- read distance from ranger num. 0
+   measure = gp2d02_read_pins(gp2d02_vin,gp2d02_vout)
+   -- results via serial
+   serial_hw_write(measure)
+   -- now blink more or less
+   pwm1_set_dutycycle(measure)
+end loop</codeblock>
+      <note>I could directly pass <codeph>pin_A4</codeph> and  
<codeph>pin_A6</codeph>, but to avoid confusion, I prefer using  
<i>aliases</i>.</note>
+      <p>A sample, <xref  
href="http://code.google.com/p/jallib/source/browse/trunk/sample/16f88_ir_ranger_gp2d02.jal";
  
format="html">16f88_ir_ranger_gp2d02.jal</xref>, is available in <xref  
href="http://code.google.com/p/jallib/source/browse/trunk/include/external/ranger/ir/ir_ranger_gp2d02.jal";
  
format="html">jallib SVN repository</xref>jallib released packages, and  
also in , starting from version 0.3. You can access downloads <xref  
href="http://code.google.com/p/jallib/downloads/list";  
format="html">here</xref>.</p>
+    </section>
+    <section>
+      <title>Building the whole on a breadboard</title>
+      <p>Building the whole on a breadboard<image  
href="images/circuit.jpg" width="400" placement="break"/></p>
+      <p>I usually power two tracks on the side, used for the PIC and for  
the ranger:<image href="images/circuit_ranger.jpg" width="400"  
placement="break"/></p>
+      <p>Using the same previously created mental note, I connected the  
yellow Vout pin using a yellow wire, and the green Vin pin using a green  
wire...<image href="images/circuit_pic.jpg" width="400"  
placement="break"/></p>
+    </section>
+    <section>
+      <title>Testing (and the video)</title>
+      <p>Time to test this nice circuit ! Power the whole, and check no  
smoke is coming from the PIC or (and) the ranger. Now get an object, like  
you hand, more or less closed to the ranger and observe the LED, or the  
serial output... Sweet !</p>
+      <p><xref href="http://www.youtube.com/watch?v=l5AZwv7LzyM";  
format="html">http://www.youtube.com/watch?v=l5AZwv7LzyM</xref></p>
+      <p><i>Sébastien Lelong</i></p>
+    </section>
+  </body>
+</topic>
=======================================
--- /dev/null
+++ /trunk/doc/dita/tutorials/tutorials.ditamap Sat Sep 19 14:18:54 2009
@@ -0,0 +1,27 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- This document was created with Syntext Serna Free. --><!DOCTYPE  
bookmap PUBLIC "-//OASIS//DTD DITA BookMap//EN" "bookmap.dtd" []>
+<bookmap id="bookmap_tutorials">
+  <booktitle>
+    <mainbooktitle>The Tutorial Book</mainbooktitle>
+    <booktitlealt>Have fun with PIC microcontrollers,Jal v2 and  
Jallib</booktitlealt>
+  </booktitle>
+  <bookmeta>
+    <author>Sébastien Lelong</author>
+    <bookrights>
+      <copyrfirst>
+        <year>2009</year>
+      </copyrfirst>
+      <bookowner>
+        <organization>Jallib Group</organization>
+      </bookowner>
+    </bookrights>
+  </bookmeta>
+  <frontmatter>
+    <booklists>
+      <toc/>
+    </booklists>
+  </frontmatter>
+  <chapter>
+    <topicref href="tutorial_gp2d02.xml"/>
+  </chapter>
+</bookmap>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jallib" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/jallib?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to