<?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>Kiwi&#039;s Blog &#187; arduino</title>
	<atom:link href="http://kiwized.net/tag/arduino/feed/" rel="self" type="application/rss+xml" />
	<link>http://kiwized.net</link>
	<description>Things and other interesting things</description>
	<lastBuildDate>Sat, 16 Jan 2010 04:02:06 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Environmental temperature readings with Arduino.</title>
		<link>http://kiwized.net/2009/12/24/environmental-temperature-readings-with-arduino/</link>
		<comments>http://kiwized.net/2009/12/24/environmental-temperature-readings-with-arduino/#comments</comments>
		<pubDate>Thu, 24 Dec 2009 00:44:33 +0000</pubDate>
		<dc:creator>kiwi</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[minimal]]></category>
		<category><![CDATA[sensors]]></category>

		<guid isPermaLink="false">http://kiwi.tastybra.in/blog/?p=89</guid>
		<description><![CDATA[Some days ago, while I was reading the ATMEGA328P datasheet, I found an interesting (little known?) feature. The IC has an integrated thermistor!
As it is integrated in the die the readings are not really environmental, but anyway the IC doesn&#8217;t make much heat, so we are quite close to the right temperature.
There is no support [...]]]></description>
			<content:encoded><![CDATA[<p>Some days ago, while I was reading the ATMEGA328P <a href="http://www.atmel.com/dyn/resources/prod_documents/doc8161.pdf" target="_blank">datasheet</a>, I found an interesting (little known?) feature. The IC has an integrated thermistor!</p>
<p>As it is integrated in the die the readings are not really environmental, but anyway the IC doesn&#8217;t make much heat, so we are quite close to the right temperature.</p>
<p>There is no support in the Arduino own libraries so I had to code everything from scratch. The datasheet is quite clear on how to get the raw readings. Just set the multiplexer to the thermistor input, set the ADC voltage reference to &#8220;internal&#8221; and we are ready to do the readings.</p>
<p>I don&#8217;t find the readings from my Arduino consistent with the datasheet. Maybe the table is wrong, or maybe they don&#8217;t care much of the scale as the declared precision is ±20 C°, but the sensitivity is around 1mV/C°.<br />
By assuming linear response, I got this formula:<br />
t_celsius = raw_t / vref_mv * adc_top * t_factor &#8211; t_constant<br />
Getting t_factor by interpolating the datasheet&#8217;s table and t_constant by my poor measurements (I don&#8217;t want to put my Arduino running in a thermostatic oven or fridge!) I get the formula:<br />
t_celsius = raw_t / 1100 * 1024 * 1.028 &#8211; 307.28<br />
which can be approximated by:<br />
t_celsius = raw_t &#8211; 322</p>
<p>So here is the code:</p>
<p><code><br />
#include &lt;avr/interrupt.h&gt;<br />
#include &lt;avr/sleep.h&gt;<br />
#include &lt;avr/io.h&gt;</code></p>
<p>#ifndef cbi<br />
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &amp;= ~_BV(bit))<br />
#endif<br />
#ifndef sbi<br />
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))<br />
#endif</p>
<p>void setup() {<br />
Serial.begin(9600);<br />
ADMUX = 0xc8; // 1100.1000 -&gt; c.8<br />
}</p>
<p>void loop() {<br />
uint8_t h;<br />
uint8_t l;<br />
int t;<br />
sbi(ADCSRA, ADSC);<br />
while (bit_is_set(ADCSRA, ADSC));<br />
l = ADCL;<br />
h = ADCH;<br />
t = (h &lt;&lt; 8 ) | l;<br />
delay(100);<br />
//Serial.println( t );<br />
Serial.println( t &#8211; 322);<br />
}<br />
</code></p>
<p>If you try it, please tell me about your experience and whether you find better values. Don't melt Arduinos in the process. Or at least make a youtube vid of it <img src='http://kiwized.net/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p>It would be way better if I used timer + interrupts so the IC can sleep, draw less power and produce less heat and give better readings, but I'm lazy. Actually I tried but after the first reading the CPU never woke up, I got something wrong.<br />
So, nice hacking! If you find this useful and you do something fun with it let me know <img src='http://kiwized.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?&amp;linkurl=http%3A%2F%2Fkiwized.net%2F2009%2F12%2F24%2Fenvironmental-temperature-readings-with-arduino%2F&amp;linkname=Environmental%20temperature%20readings%20with%20Arduino."><img src="http://kiwi.tastybra.in/blog/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share/Save/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://kiwized.net/2009/12/24/environmental-temperature-readings-with-arduino/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Un piccolo hack di un LCD (KL SN102)</title>
		<link>http://kiwized.net/2009/10/15/un-piccolo-hack-di-un-lcd-kl-sn102/</link>
		<comments>http://kiwized.net/2009/10/15/un-piccolo-hack-di-un-lcd-kl-sn102/#comments</comments>
		<pubDate>Wed, 14 Oct 2009 22:17:39 +0000</pubDate>
		<dc:creator>kiwi</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[electronics]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[hardware]]></category>
		<category><![CDATA[it]]></category>
		<category><![CDATA[LCD]]></category>

		<guid isPermaLink="false">http://kiwi.tastybra.in/blog/?p=32</guid>
		<description><![CDATA[Ho comprato questo LCD (KL SN102) alla Fiera dell&#8217;elettronica di Gonzaga (in realtà due, uno per vrde). Si tratta uno dei soliti LCD paralleli compatibili con lo HD44780, che si possono attaccare alla porta parallela e che sono abbastanza facili da programmare.
A me non interessava collegarlo al computer, bensì all&#8217;Arduino per farlo comunicare un po&#8217; [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left"><img class="alignright size-full wp-image-31" src="http://kiwized.net/files/2009/10/board_zoomed-smaller1.jpg" alt="board_zoomed-smaller" width="377" height="297" />Ho comprato questo LCD (KL SN102) alla Fiera dell&#8217;elettronica di Gonzaga (in realtà due, uno per <a title="Blog di Vrde" href="http://vrde.wordpress.com" target="_blank">vrde</a>). Si tratta uno dei soliti LCD paralleli compatibili con lo <a href="http://en.wikipedia.org/wiki/HD44780_Character_LCD">HD44780</a>, che si possono attaccare alla porta parallela e che sono abbastanza facili da programmare.</p>
<p style="text-align: left">A me non interessava collegarlo al computer, bensì all&#8217;<a href="http://www.arduino.cc">Arduino</a> per farlo comunicare un po&#8217; meglio con il mondo esterno.</p>
<p style="text-align: left">Uno dei motivi del successo di questi piccoli display è che richiedono poche linee dati, 8 oppure  4. Quando comunicano a 4 le prestazioni diminuiscono, ma in fondo gli LCD hanno ben altri problemi, prima di tutto la fisica.</p>
<p style="text-align: left">Utilizzare poche linee dati è molto importante per l&#8217;Arduino visto che non ne ha tantissime e soprattutto quelle libere possono servire ad altro. Vuol dire anche pochi collegamenti, che è semplicemente comodo.</p>
<p style="text-align: left">Nel modello specifico che ho comprato (KL SN102) l&#8217;alimentazione della backlight è esterna. Come se non ha bastasse la massa non è in comune e non c&#8217;è nessuna resistenza integrata per farla andare a 5V come il resto dell&#8217;LCD. La fotocopia della fotocopia della fotocopia della documentazione diceva di farlo andare a 4.2 V che non è così lontano da 5. Ho provato a farlo andare a 5. Un po&#8217; troppa luce, un po&#8217; troppo caldo&#8230; No <img src='http://kiwized.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p style="text-align: left">Quindi altri fili, altre resistenze&#8230; Anche no!</p>
<p style="text-align: left">Così ho studiato un attimo la board. C&#8217;erano vari componenti non saldati e alcuni &#8220;jumpers&#8221; aperti. Non i jumpers come quelli delle vecchie schede madri, ma dei piccoli ponti sulla PCB chiudibili con lo stagno (v J2 e J3 nella foto). Di questi due erano collegati al LED, ai suoi piedini di alimentazione della backlight e ad uno dei due integrati. Il collegamento verso l&#8217;integrato era interrotto.</p>
<p style="text-align: left">Ho provato a chiuderlo con una matita e ho visto che effettivamente serviva ad alimentare la backlight!</p>
<p style="text-align: left">Così ho modificato il circuito in modo da rendere il cambiamento definitivo. Le operazioni da fare sono:</p>
<ul>
<li>spostare R8 (un ponte, o resistenza a 0 Ohm) su R9 (appena sotto, poco leggibile per il flash);</li>
<li>asportare lo stagno da J2;</li>
<li>collegare J3 con un po di stagno;</li>
</ul>
<p>In questo modo si scollegano anche i piedini esterni e si evita di fare pasticci, altrimenti basta solo collegare J3.</p>
<p>La foto sopra rappresenta il (cattivo) lavoro finito, purtroppo non ho fatto una foto prima di iniziare.</p>
<p>Spero che sia utile a qualcuno, cercando la sigla di quell&#8217;LCD non si trova niente di utile.</p>
<p>Il prossimo passaggio sarà vedere se esiste un modo per comandare la backlight dall&#8217;integrato. Non mi aspetto un controller PWM supergranulare, ma due valori intermedi più &#8220;off&#8221; magari si <img src='http://kiwized.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?&amp;linkurl=http%3A%2F%2Fkiwized.net%2F2009%2F10%2F15%2Fun-piccolo-hack-di-un-lcd-kl-sn102%2F&amp;linkname=Un%20piccolo%20hack%20di%20un%20LCD%20%28KL%20SN102%29"><img src="http://kiwi.tastybra.in/blog/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share/Save/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://kiwized.net/2009/10/15/un-piccolo-hack-di-un-lcd-kl-sn102/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
