<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Lionel&#039;s Tetalab &#38; Co WIP &#187; RPM</title>
	<atom:link href="http://tetalab.org/lionel/tag/rpm/feed/" rel="self" type="application/rss+xml" />
	<link>http://tetalab.org/lionel</link>
	<description>Just another Tetalab weblog</description>
	<lastBuildDate>Thu, 10 Jun 2010 19:26:30 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Compteur RPM à affichage LCD (la revanche)</title>
		<link>http://tetalab.org/lionel/2009/09/23/compteur-rpm-a-affichage-lcd-la-revanche/</link>
		<comments>http://tetalab.org/lionel/2009/09/23/compteur-rpm-a-affichage-lcd-la-revanche/#comments</comments>
		<pubDate>Wed, 23 Sep 2009 08:17:22 +0000</pubDate>
		<dc:creator>lionel</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[RPM Meter]]></category>
		<category><![CDATA[compte tour]]></category>
		<category><![CDATA[hall effect sensor]]></category>
		<category><![CDATA[LCD]]></category>
		<category><![CDATA[RPM]]></category>
		<category><![CDATA[tachometer]]></category>

		<guid isPermaLink="false">http://tetalab.org/lionel/?p=27</guid>
		<description><![CDATA[Fabrice, mon ami d&#8217;en face, a suggéré une épuration du code a base de ruse de renard.
C&#8217;est plus clean, y&#8217;a plus de calcul de modulo dans le loop, c&#8217;est mieux. Je mets a jour. J&#8217;ai commenté le code, ça devrait se lire.
A noter qu&#8217;on pourrait cabler le LCD différement pour libèrer la sortie digitale 1 [...]]]></description>
			<content:encoded><![CDATA[<p>Fabrice, mon ami d&#8217;en face, a suggéré une épuration du code a base de ruse de renard.</p>
<p>C&#8217;est plus clean, y&#8217;a plus de calcul de modulo dans le loop, c&#8217;est mieux. Je mets a jour. J&#8217;ai commenté le code, ça devrait se lire.</p>
<p>A noter qu&#8217;on pourrait cabler le LCD différement pour libèrer la sortie digitale 1 et ainsi écrire la valeur en même temps sur le port série. J&#8217;ai essayé, ça marche&#8230;</p>
<pre>
<span style="color: #7E7E7E">/*</span>
<span style="color: #7E7E7E">&nbsp;*&nbsp;Effet&nbsp;hall&nbsp;Tachometer&nbsp;LCD&nbsp;display</span>
<span style="color: #7E7E7E">&nbsp;*</span>
<span style="color: #7E7E7E">&nbsp;*&nbsp;Uses&nbsp;hall&nbsp;effect&nbsp;sensor&nbsp;to&nbsp;implement&nbsp;a&nbsp;tachometer.</span>
<span style="color: #7E7E7E">&nbsp;*&nbsp;A&nbsp;status&nbsp;LED&nbsp;is&nbsp;connected&nbsp;to&nbsp;pin&nbsp;8.</span>
<span style="color: #7E7E7E">&nbsp;*&nbsp;Pin&nbsp;2&nbsp;(interrupt&nbsp;0)&nbsp;is&nbsp;connected&nbsp;across&nbsp;the&nbsp;hall&nbsp;effect&nbsp;sensor.</span>
<span style="color: #7E7E7E">&nbsp;*&nbsp;</span>
<span style="color: #7E7E7E">&nbsp;*/</span>

<span style="color: #7E7E7E">//&nbsp;include&nbsp;the&nbsp;library&nbsp;code:</span>
#include&nbsp;&lt;<span style="color: #CC6600">LiquidCrystal</span>.h&gt;

<span style="color: #7E7E7E">//&nbsp;initialize&nbsp;the&nbsp;lcd&nbsp;library&nbsp;with&nbsp;the&nbsp;numbers&nbsp;of&nbsp;the&nbsp;interface&nbsp;pins</span>
<span style="color: #CC6600">LiquidCrystal</span> lcd(12, 11, 5, 4, 3, 1);

<span style="color: #CC6600">int</span> statusPin = 8;             <span style="color: #7E7E7E">// Status LED connected to digital pin 8</span>

volatile&nbsp;<span style="color: #CC6600">byte</span> rpmcount;
volatile&nbsp;<span style="color: #CC6600">int</span> <span style="color: #CC6600">status</span>;
<span style="color: #CC6600">unsigned</span> <span style="color: #CC6600">int</span> rpm;
<span style="color: #CC6600">unsigned</span> <span style="color: #CC6600">long</span> timeold;

&nbsp;<span style="color: #CC6600">void</span> <span style="color: #CC6600"><b>setup</b></span>()
&nbsp;{
<span style="color: #7E7E7E">//&nbsp;&nbsp;&nbsp;Serial.begin(9600);</span>
&nbsp;&nbsp;&nbsp;<span style="color: #CC6600">attachInterrupt</span>(0, rpm_fun, <span style="color: #006699">RISING</span>);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #7E7E7E">//Use statusPin to flash along with interrupts</span>
&nbsp;&nbsp;&nbsp;<span style="color: #CC6600">pinMode</span>(statusPin, <span style="color: #006699">OUTPUT</span>);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #7E7E7E">// set up the LCD's number of rows and columns: </span>
&nbsp;&nbsp;lcd.<span style="color: #CC6600">begin</span>(16, 2);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #7E7E7E">// Shift display 1 character to the left </span>
&nbsp;&nbsp;lcd.<span style="color: #CC6600">scrollDisplayLeft</span>();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #7E7E7E">// initial values</span>
&nbsp;&nbsp;&nbsp;rpmcount&nbsp;=&nbsp;0;
&nbsp;&nbsp;&nbsp;rpm&nbsp;=&nbsp;0;

&nbsp;}
&nbsp;<span style="color: #CC6600">void</span> <span style="color: #CC6600"><b>loop</b></span>()
&nbsp;{
&nbsp;&nbsp;&nbsp;<span style="color: #CC6600">if</span> (rpmcount &gt;= 20) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #7E7E7E">//Update RPM every 20 counts, increase this for better RPM resolution,</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #7E7E7E">//decrease for faster update</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #7E7E7E">//detach interrupt during calculation</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #CC6600">detachInterrupt</span>(0);
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #7E7E7E">//Note that this would be 60*1000/(millis() - timeold)*rpmcount if the interrupt</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #7E7E7E">//happened once per revolution instead of twice. Other multiples could be used</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #7E7E7E">//for multi-bladed propellers or fans</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #7E7E7E">//To keep the rpm value 4 digits long, I add 10000 to the rpm value and hide </span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #7E7E7E">//the first digit using lcd.scrollDisplayLeft() in setup()</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #7E7E7E">//Nice trick from sack <img src='http://tetalab.org/lionel/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  thx !</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rpm&nbsp;=&nbsp;10000&nbsp;+&nbsp;15*1000/(<span style="color: #CC6600">millis</span>() - timeold)*rpmcount;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;timeold&nbsp;=&nbsp;<span style="color: #CC6600">millis</span>();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rpmcount&nbsp;=&nbsp;0;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #7E7E7E">//print rpm value on LCD</span>
<span style="color: #7E7E7E">//&nbsp;Serial.println((rpm-10000),DEC);</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;lcd.<span style="color: #CC6600">setCursor</span>(0,1);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;lcd.<span style="color: #CC6600">print</span>(rpm);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;lcd.<span style="color: #CC6600">setCursor</span>(6,1);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;lcd.<span style="color: #CC6600">print</span>(<span style="color: #006699">"RPM"</span>);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #7E7E7E">//detach interrupt during calculation</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #CC6600">attachInterrupt</span>(0, rpm_fun, <span style="color: #006699">RISING</span>);
&nbsp;&nbsp;&nbsp;}
&nbsp;}
&nbsp;<span style="color: #CC6600">void</span> rpm_fun()
&nbsp;{
&nbsp;&nbsp;&nbsp;rpmcount++;
&nbsp;&nbsp;&nbsp;<span style="color: #7E7E7E">//Each rotation, this interrupt function is run twice</span>
&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #7E7E7E">//Toggle status LED   </span>
&nbsp;&nbsp;&nbsp;<span style="color: #CC6600">if</span> (<span style="color: #CC6600">status</span> == <span style="color: #006699">LOW</span>) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #CC6600">status</span> = <span style="color: #006699">HIGH</span>;
&nbsp;&nbsp;&nbsp;}&nbsp;<span style="color: #CC6600">else</span> {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #CC6600">status</span> = <span style="color: #006699">LOW</span>;
&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;<span style="color: #CC6600">digitalWrite</span>(statusPin, <span style="color: #CC6600">status</span>);
&nbsp;}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://tetalab.org/lionel/2009/09/23/compteur-rpm-a-affichage-lcd-la-revanche/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Compteur RPM à affichage LCD</title>
		<link>http://tetalab.org/lionel/2009/09/22/compteur-rpm-a-affichage-lcd/</link>
		<comments>http://tetalab.org/lionel/2009/09/22/compteur-rpm-a-affichage-lcd/#comments</comments>
		<pubDate>Tue, 22 Sep 2009 18:35:47 +0000</pubDate>
		<dc:creator>lionel</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[RPM Meter]]></category>
		<category><![CDATA[compte tour]]></category>
		<category><![CDATA[hall effect sensor]]></category>
		<category><![CDATA[LCD]]></category>
		<category><![CDATA[RPM]]></category>
		<category><![CDATA[tachometer]]></category>

		<guid isPermaLink="false">http://tetalab.org/lionel/?p=6</guid>
		<description><![CDATA[Yopa !
Aujourd&#8217;hui et pour ne pas oublier, présentation du compte tours avec affichage LCD.
Alors ça compte les tours/minutes d&#8217;un ventilateur de PC équipé d&#8217;un capteur a effet hall.
Le but ultime étant de de régler le ralenti de ma voiture en collant un aimant sur la poulie, utiliser un capteur a effet hall et lire la vitesse [...]]]></description>
			<content:encoded><![CDATA[<p>Yopa !</p>
<p>Aujourd&#8217;hui et pour ne pas oublier, présentation du compte tours avec affichage LCD.</p>
<p>Alors ça compte les tours/minutes d&#8217;un ventilateur de PC équipé d&#8217;un capteur a effet hall.</p>
<p>Le but ultime étant de de régler le ralenti de ma voiture en collant un aimant sur la poulie, utiliser un capteur a effet hall et lire la vitesse de rotation en tour/min .</p>
<p>Synoptique de cablage (merci <a href="http://fritzing.org/" target="_blank">fritzing</a>&#8230;), ouvrir l&#8217;image pour zoom.</p>
<p><img class="size-full wp-image-7 alignnone" src="http://tetalab.org/lionel/files/2009/09/Rpm_Magnet_lcd_2_bb.png" alt="Rpm_Magnet_lcd_2_bb" width="485" height="365" /></p>
<p>Le code :</p>
<p>Note Importante : Je suis une grosse quiche en codage, j&#8217;ai donc compilé des exemples un peu partout sur le net, genre <a href="http://www.arduino.cc/playground/Main/ReadingRPM" target="_blank">là</a> ou <a href="http://www.instructables.com/id/Arduino-Based-Optical-Tachometer/" target="_blank">là</a>, merci d&#8217;être indulgent.</p>
<p>Si vous voyez des trucs débiles, ou si vous avez des ruses pour faire mieux, je prends&#8230; Enfin là tel quel, c&#8217;est tombé en marche <img src='http://tetalab.org/lionel/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<pre><span style="color: #7E7E7E">/*</span>
<span style="color: #7E7E7E"> * Effet hall Tachometer LCD display</span>
<span style="color: #7E7E7E"> *</span>
<span style="color: #7E7E7E"> * Uses hall effect sensor to implement a tachometer.</span>
<span style="color: #7E7E7E"> * A status LED is connected to pin 12.</span>
<span style="color: #7E7E7E"> * Pin 2 (interrupt 0) is connected across the hall effect sensor.</span>
<span style="color: #7E7E7E"> *</span>
<span style="color: #7E7E7E"> * </span>
<span style="color: #7E7E7E"> */</span>

<span style="color: #7E7E7E">// include the library code:</span>
#include &lt;<span style="color: #CC6600">LiquidCrystal</span>.h&gt;

<span style="color: #7E7E7E">// initialize the library with the numbers of the interface pins</span>
<span style="color: #CC6600">LiquidCrystal</span> lcd(12, 11, 5, 4, 3, 1);

<span style="color: #CC6600">int</span> statusPin = 8;             <span style="color: #7E7E7E">// Status LED connected to digital pin 8</span>

volatile <span style="color: #CC6600">byte</span> rpmcount;
volatile <span style="color: #CC6600">int</span> <span style="color: #CC6600">status</span>;

<span style="color: #CC6600">unsigned</span> <span style="color: #CC6600">int</span> rpm;
<span style="color: #CC6600">unsigned</span> <span style="color: #CC6600">long</span> timeold;
<span style="color: #CC6600">unsigned</span> <span style="color: #CC6600">int</span> unite;
<span style="color: #CC6600">unsigned</span> <span style="color: #CC6600">int</span> dizaine;
<span style="color: #CC6600">unsigned</span> <span style="color: #CC6600">int</span> centaine;
<span style="color: #CC6600">unsigned</span> <span style="color: #CC6600">int</span> millier;
<span style="color: #CC6600">unsigned</span> <span style="color: #CC6600">int</span> dmillier;

 <span style="color: #CC6600">void</span> <span style="color: #CC6600"><strong>setup</strong></span>()
 {
   <span style="color: #7E7E7E">//Serial.begin(9600);</span>
   <span style="color: #CC6600">attachInterrupt</span>(0, rpm_fun, <span style="color: #006699">RISING</span>);
      <span style="color: #7E7E7E">//Use statusPin to flash along with interrupts</span>
   <span style="color: #CC6600">pinMode</span>(statusPin, <span style="color: #006699">OUTPUT</span>);
        <span style="color: #7E7E7E">// set up the LCD's number of rows and columns: </span>
  lcd.<span style="color: #CC6600">begin</span>(16, 2);
     <span style="color: #7E7E7E">// Print a message to the LCD.</span>
  lcd.<span style="color: #CC6600">print</span>(<span style="color: #006699">"RPM"</span>);
   rpmcount = 0;
   rpm = 0;
   timeold = 0;
   unite = 0;
   dizaine = 0;
   centaine = 0;
   millier = 0;
   dmillier = 0;
 }
 <span style="color: #CC6600">void</span> <span style="color: #CC6600"><strong>loop</strong></span>()
 {
   <span style="color: #CC6600">if</span> (rpmcount &gt;= 20) {
     <span style="color: #7E7E7E">//Update RPM every 20 counts, increase this for better RPM resolution,</span>
     <span style="color: #7E7E7E">//decrease for faster update</span>
        <span style="color: #CC6600">detachInterrupt</span>(0);
          <span style="color: #7E7E7E">//Note that this would be 60*1000/(millis() - timeold)*rpmcount if the interrupt</span>
   <span style="color: #7E7E7E">//happened once per revolution instead of twice. Other multiples could be used</span>
   <span style="color: #7E7E7E">//for multi-bladed propellers or fans</span>
     rpm = 15*1000/(<span style="color: #CC6600">millis</span>() - timeold)*rpmcount;
     timeold = <span style="color: #CC6600">millis</span>();
     rpmcount = 0;
     unite = rpm%10;
     dizaine = (rpm%100)/10;
     centaine = (rpm%1000)/100;
     millier = (rpm%10000)/1000;
     dmillier = rpm/10000;
     <span style="color: #7E7E7E">//Serial.println(rpm,DEC);</span>
      lcd.<span style="color: #CC6600">setCursor</span>(1, 1);
      lcd.<span style="color: #CC6600">print</span>(dmillier);
      lcd.<span style="color: #CC6600">setCursor</span>(2, 1);
      lcd.<span style="color: #CC6600">print</span>(millier);
      lcd.<span style="color: #CC6600">setCursor</span>(3, 1);
      lcd.<span style="color: #CC6600">print</span>(centaine);
      lcd.<span style="color: #CC6600">setCursor</span>(4, 1);
      lcd.<span style="color: #CC6600">print</span>(dizaine);
      lcd.<span style="color: #CC6600">setCursor</span>(5, 1);
      lcd.<span style="color: #CC6600">print</span>(unite);
        <span style="color: #CC6600">attachInterrupt</span>(0, rpm_fun, <span style="color: #006699">RISING</span>);
   }
 }
 <span style="color: #CC6600">void</span> rpm_fun()
 {
   rpmcount++;
   <span style="color: #7E7E7E">//Each rotation, this interrupt function is run twice</span>

      <span style="color: #7E7E7E">//Toggle status LED   </span>
   <span style="color: #CC6600">if</span> (<span style="color: #CC6600">status</span> == <span style="color: #006699">LOW</span>) {
     <span style="color: #CC6600">status</span> = <span style="color: #006699">HIGH</span>;
   } <span style="color: #CC6600">else</span> {
     <span style="color: #CC6600">status</span> = <span style="color: #006699">LOW</span>;
   }
   <span style="color: #CC6600">digitalWrite</span>(statusPin, <span style="color: #CC6600">status</span>);
 }</pre>
<p><img class="size-full wp-image-22 alignnone" src="http://tetalab.org/lionel/files/2009/09/install.jpg" alt="install" width="414" height="311" /></p>
<p>(ça tourne vraiment, c&#8217;est une photo là&#8230;)</p>
<p>J&#8217;ai ajouté une mesure de fréquence au multimètre pour vérifier la valeur affichée (sur la led de status qui m&#8217;indique quand le capteur est activé) :</p>
<p>Sachant qu&#8217;il y a deux pulses par tour,  45 Hz affiché donne 22,5 tr/s soit 22,5&#215;60=1350 tours/min&#8230; cool, j&#8217;affiche 1300 <img src='http://tetalab.org/lionel/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>La vidéo <a href="http://vimeo.com/6705333/l:transcoded_email">http://vimeo.com/6705333</a></p>
]]></content:encoded>
			<wfw:commentRss>http://tetalab.org/lionel/2009/09/22/compteur-rpm-a-affichage-lcd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>