<?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>ntsdt.net &#187; electronics</title>
	<atom:link href="http://ntsdt.net/tag/electronics/feed/" rel="self" type="application/rss+xml" />
	<link>http://ntsdt.net</link>
	<description>never the same day twice</description>
	<lastBuildDate>Wed, 02 Jun 2010 16:35:01 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Burning the Arduino Bootloader</title>
		<link>http://ntsdt.net/2009/08/22/burning-the-arduino-bootloader/</link>
		<comments>http://ntsdt.net/2009/08/22/burning-the-arduino-bootloader/#comments</comments>
		<pubDate>Sat, 22 Aug 2009 15:02:01 +0000</pubDate>
		<dc:creator>lukus</dc:creator>
				<category><![CDATA[arduino]]></category>
		<category><![CDATA[hardware]]></category>
		<category><![CDATA[avrdude]]></category>
		<category><![CDATA[bootloader]]></category>
		<category><![CDATA[electronics]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://ntsdt.net/?p=245</guid>
		<description><![CDATA[The Arduino bootloader is a small program burnt into the ATmega&#8217;s flash memory, which enables sketches to be uploaded without the use of an external programming board.  Any new ATmega8/168/328p microprocessor needs to be programmed with a version of the Arduino bootloader firmware before it can be used with the Arduino IDE.
Many places sell ATmega [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://arduino.cc/en/Tutorial/Bootloader" target="_blank">Arduino bootloader </a>is a small program burnt into the ATmega&#8217;s flash memory, which enables sketches to be uploaded without the use of an external programming board.  Any new ATmega8/168/328p microprocessor needs to be programmed with a version of the Arduino bootloader firmware before it can be used with the Arduino IDE.</p>
<p>Many places sell ATmega chips with the Arduino bootloader pre-loaded. To actually burn the bootloader yourself, you <strong>do need</strong> an external programmer.  Fear not though &#8211; in a previous post, I discovered how to use an Arduino board (together with the mega-isp project) as a make-shift external programmer -&gt; <a href="http://ntsdt.net/2009/08/07/programming-an-atmega8-using-arduino/" target="_blank">see this post for details</a>.</p>
<p><span id="more-245"></span></p>
<h3>Putting the Boot-in..</h3>
<p>The version of the bootloader that you need to use, depends on the type of hardware that you intend to program.  The Arduino IDE supplies versions of the bootloader for a range of ATmega / Arduino combinations .. see the &#8216;./hardware/bootloaders/&#8217; sub-directory within your arduino installation directory for more info.</p>
<p>There are also custom versions of the bootloader created by third-parties -&gt; ladyada has produced some <a href="http://www.ladyada.net/library/arduino/bootloader.html" target="_blank">bootloader hacks</a> and another <a href="http://www.wulfden.org/TheShoppe/freeduino/ADABOOT.shtml" target="_blank">unified version of the bootloader can be found here</a>.</p>
<div id="attachment_246" class="wp-caption alignright" style="width: 310px"><img class="size-medium wp-image-246 " title="atmega8" src="http://ntsdt.net/wp-content/uploads/2009/08/atmega8-300x225.jpg" alt="Atmel's ATmega8 microprocessor" width="300" height="225" /><p class="wp-caption-text">Atmel&#39;s ATmega8 microprocessor</p></div>
<p>Once you&#8217;ve decided which bootloader you want to use, you can use AVRdude to upload the code.</p>
<h3>Steps Required to Burn the Bootloader</h3>
<ol>
<li>Unlock the bootloader segment</li>
<li>Upload the bootloader code</li>
<li>Relock the bootloader segment</li>
</ol>
<h4>Step 1: Unlock</h4>
<p>First of all, it&#8217;s a good idea to make sure that you can communicate with your programmer successfully.  To do so, you can issue a simple command via AVRdude, which will give you a nice &#8216;all clear&#8217; status message as long as everything is set-up correctly.</p>
<p>The parameters that you use might vary according to your system settings and the external programmer you&#8217;re using.</p>
<pre class="code">avrdude -p m8 -P /dev/ttyUSB0 -c avrisp -b 19200</pre>
<p>Briefly,<em> &#8216;-p&#8217;</em> defines the chip I&#8217;m programming, <em>&#8216;-P&#8217;</em> is the port that my programmer is connected to, <em>&#8216;-c&#8217;</em> is the programmer type and the baud-rate is specified by <em>&#8216;-b&#8217;</em>.  You can run <em>&#8216;avrdude &#8211;help&#8217;</em> to discover the full range of options.</p>
<p>This returned:</p>
<pre class="code">avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.13s

avrdude: Device signature = 0x1e9307

avrdude: safemode: Fuses OK

avrdude done.  Thank you.</pre>
<p>.. which is good.  This means that the stage is set for programming and we can begin to set the fuses to unlock the bootloader segment of the AVRdude.</p>
<p>Each ATmega chip has a number of Fuses which can be set.  I think of the fuses as configuration bits -&gt; they define the way that the chip is going to function on a very low level.  I&#8217;ve been using a <a href="http://fusecalc.engbedded.com/" target="_blank">fuse-calculator</a> to simplify the process, and I&#8217;d suggest that you do the same.</p>
<pre class="code">avrdude -p m8 -P /dev/ttyUSB0 -c avrisp -b 19200 -e -U lock:w:0x3F:m -U lfuse:w:0xc4:m -U hfuse:w:0xd9:m</pre>
<p>The <em>&#8216;-U lock:w:0&#215;3F:m&#8217;</em> performs the unlock and <em>&#8216;-U lfuse:w:0xc4:m -U hfuse:w:0xd9:m&#8217;</em> is used to set the chip&#8217;s low and high fuse values.</p>
<p>I want to use this particular ATmega chip as a minimal Arduino, so I&#8217;ve set the fuses to instruct the chip to use it&#8217;s own internal 8 MHz oscillator rather than an external crystal oscillator.</p>
<pre class="code">avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.13s

avrdude: Device signature = 0x1e9307
avrdude: erasing chip
avrdude: reading input file "0xc4"
avrdude: writing lfuse (1 bytes):

Writing | ################################################## | 100% 0.04s

avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0xc4:
avrdude: load data lfuse data from input file 0xc4:
avrdude: input file 0xc4 contains 1 bytes
avrdude: reading on-chip lfuse data:

Reading | ################################################## | 100% 0.04s

avrdude: verifying ...
avrdude: 1 bytes of lfuse verified
avrdude: reading input file "0xd9"
avrdude: writing hfuse (1 bytes):

Writing | ################################################## | 100% 0.04s

avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0xd9:
avrdude: load data hfuse data from input file 0xd9:
avrdude: input file 0xd9 contains 1 bytes
avrdude: reading on-chip hfuse data:

Reading | ################################################## | 100% 0.04s

avrdude: verifying ...
avrdude: 1 bytes of hfuse verified

avrdude: safemode: Fuses OK

avrdude done.  Thank you.</pre>
<h4>Step 2: The Burn</h4>
<p>The chip has now been set up &#8211; the next stage involves uploading the new firmware.</p>
<pre class="code">avrdude -p m8 -P /dev/ttyUSB0 -c avrisp -b 19200 -D -U flash:w:/opt/arduino/hardware/bootloaders/atmega8/ATmegaBOOT.hex</pre>
<p>&#8230; which produces &#8230;</p>
<h4>Step 3: Re-lock</h4>
<p>The final stage involves re-setting the lock fuse:</p>
<pre class="code">avrdude -p m8 -P /dev/ttyUSB0 -c avrisp -b 19200 -U lock:w:0x0F:m</pre>
<p>And that&#8217;s it!</p>
]]></content:encoded>
			<wfw:commentRss>http://ntsdt.net/2009/08/22/burning-the-arduino-bootloader/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Kenwood CS-1575a Oscilloscope</title>
		<link>http://ntsdt.net/2009/08/18/kenwood-cs-1575a-oscilloscope/</link>
		<comments>http://ntsdt.net/2009/08/18/kenwood-cs-1575a-oscilloscope/#comments</comments>
		<pubDate>Tue, 18 Aug 2009 15:16:47 +0000</pubDate>
		<dc:creator>lukus</dc:creator>
				<category><![CDATA[hardware]]></category>
		<category><![CDATA[analog oscillosope]]></category>
		<category><![CDATA[CS-1575a]]></category>
		<category><![CDATA[electronics]]></category>
		<category><![CDATA[kenwood]]></category>
		<category><![CDATA[oscilloscope]]></category>
		<category><![CDATA[service manual]]></category>

		<guid isPermaLink="false">http://ntsdt.net/?p=250</guid>
		<description><![CDATA[An oscillosope is a pretty useful thing to own when working with microprocessors; so I was super happy when I was given an old Kenwood &#8217;scope earlier this week.  At the moment it switches on and produces a trace &#8211; but only intermittently.  The trace intensity varies &#8211; and eventually fades.  I&#8217;m hoping that bringing [...]]]></description>
			<content:encoded><![CDATA[<p>An oscillosope is a pretty useful thing to own when working with microprocessors; so I was super happy when I was given an old Kenwood &#8217;scope earlier this week.  At the moment it switches on and produces a trace &#8211; but only intermittently.  The trace intensity varies &#8211; and eventually fades.  I&#8217;m hoping that bringing it back to life won&#8217;t be too difficult; to help equip me, I&#8217;m trying to get hold of a service manual for the scope</p>
<div id="attachment_251" class="wp-caption alignleft" style="width: 510px"><img class="size-full wp-image-251 " title="Kenwood CS-1575a Oscilloscope" src="http://ntsdt.net/wp-content/uploads/2009/08/scope.jpg" alt="Kenwood CS-1575a Oscilloscope" width="500" height="361" /><p class="wp-caption-text">Kenwood CS-1575a Oscilloscope</p></div>
<p>I haven&#8217;t had any luck yet &#8211; so far I managed to source a <a href="downloads/Trio-CS-1560A-Oscilloscope-Service-Manual.pdf" target="_blank">service manual for a Trio CS-1560a</a>.</p>
<p>If anyone has a copy of the manual for the CS-1575a (that they&#8217;re willing to share), please get in contact.</p>
<p>To be honest though, I&#8217;m a bit worried about killing myself via the high voltage on the board.  Whatever I do &#8211; I will proceed with caution!</p>
<p><span id="more-250"></span></p>
<p>I&#8217;ve read that it&#8217;s possible the capacitors might have dried out &#8211; at first I thought the gunk emanating from the base of the larger electrolytic capacitors was a sign of this &#8211; but on closer inspection I found it was just glue, which was disappointing, as changing the caps seemed like it was something I&#8217;d be capable of carrying out.</p>
<p>Any (and all) suggestions on how to proceed will be gratefully received.</p>
<div id="attachment_252" class="wp-caption alignleft" style="width: 310px"><a href="http://ntsdt.net/wp-content/uploads/2009/08/caps.jpg"><img class="size-medium wp-image-252 " title="Some of the capacitors used by the 'scopes power circuits." src="http://ntsdt.net/wp-content/uploads/2009/08/caps-300x225.jpg" alt="Some of the capacitors used by the 'scopes power circuits." width="300" height="225" /></a><p class="wp-caption-text">Some of the capacitors used by the &#39;scopes power circuits.</p></div>
<div id="attachment_253" class="wp-caption alignleft" style="width: 310px"><a href="http://ntsdt.net/wp-content/uploads/2009/08/board.jpg"><img class="size-medium wp-image-253 " title="The effects of high voltage on the PCB..." src="http://ntsdt.net/wp-content/uploads/2009/08/board-300x225.jpg" alt="The effects of high voltage on the PCB..." width="300" height="225" /></a><p class="wp-caption-text">The effects of high voltage on the PCB...</p></div>
]]></content:encoded>
			<wfw:commentRss>http://ntsdt.net/2009/08/18/kenwood-cs-1575a-oscilloscope/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>building a mini +5v regulated power supply</title>
		<link>http://ntsdt.net/2009/08/10/building-a-mini-5v-regulated-power-supply/</link>
		<comments>http://ntsdt.net/2009/08/10/building-a-mini-5v-regulated-power-supply/#comments</comments>
		<pubDate>Mon, 10 Aug 2009 02:59:39 +0000</pubDate>
		<dc:creator>lukus</dc:creator>
				<category><![CDATA[arduino]]></category>
		<category><![CDATA[hardware]]></category>
		<category><![CDATA[7805]]></category>
		<category><![CDATA[electronics]]></category>
		<category><![CDATA[power supply]]></category>
		<category><![CDATA[stripboard]]></category>
		<category><![CDATA[veecad]]></category>
		<category><![CDATA[voltage regulator]]></category>

		<guid isPermaLink="false">http://ntsdt.net/?p=214</guid>
		<description><![CDATA[Well, in my quest to be able to build self-contained devices I decided that it was worth looking at ways to power my microprocessor and attached devices.  Up until now I&#8217;ve been powering everything using the power supplied from my laptop&#8217;s USB supply &#8211; but in the future it&#8217;s going to be useful to be [...]]]></description>
			<content:encoded><![CDATA[<p>Well, in my quest to be able to build self-contained devices I decided that it was worth looking at ways to power my microprocessor and attached devices.  Up until now I&#8217;ve been powering everything using the power supplied from my laptop&#8217;s USB supply &#8211; but in the future it&#8217;s going to be useful to be able to power my arduino (or ATmega micro) independently.</p>
<p><span id="more-214"></span></p>
<div id="attachment_225" class="wp-caption alignleft" style="width: 310px"><a href="http://ntsdt.net/wp-content/uploads/2009/08/5v_power_reg_stripboard2.png"><img class="size-medium wp-image-225" title="5v_power_reg_stripboard" src="http://ntsdt.net/wp-content/uploads/2009/08/5v_power_reg_stripboard2-300x113.png" alt="Stripboard design for the +5V DC power regulator circuit (copper side up)" width="300" height="113" /></a><p class="wp-caption-text">Stripboard design for the +5V DC power regulator circuit (copper side up)</p></div>
<p>There are lots of different schematics available to produce a 5V dc regulated current, after searching around I chose one at <a href="http://stuff.nekhbet.ro/2006/06/18/how-to-build-a-5v-regulator-using-78l05-7805.html" target="_blank">http://stuff.nekhbet.ro/2006/06/18/how-to-build-a-5v-regulator-using-78l05-7805.html</a>.  I used this as the basis for my design, but I also added a quick blow fuse to limit the amount of current that can be drawn &#8211; the 7805 regulator IC the circuit uses has a maximum rating of 1A.</p>
<p>The circuit was drawn up in VeeCAD (which is good for designing stripboard circuits.)</p>
<p>The finished product fits on a 9&#215;25 piece of strip-board and produces a nice steady 5 volts from my 12V power adapter.</p>
<h3>Parts List</h3>
<p>9&#215;25 stripboard (veroboard)<br />
7805 voltage regulator<br />
a &#8216;to220&#8242; heatsink<br />
10uF 25V electrolytic capacitor<br />
220uF 25V electrolytic capacitor<br />
fuse holder + a quick blow fuse<br />
1n4007 rectifier diode<br />
some terminal blocks &#8211; to make connecting to the regulator easier</p>
<ul></ul>
<div id="attachment_217" class="wp-caption alignnone" style="width: 520px"><img class="size-full wp-image-217" title="voltage_reg_5v_shot" src="http://ntsdt.net/wp-content/uploads/2009/08/voltage_reg_5v_shot1.jpg" alt="The finished board" width="510" height="383" /><p class="wp-caption-text">The finished board</p></div>
]]></content:encoded>
			<wfw:commentRss>http://ntsdt.net/2009/08/10/building-a-mini-5v-regulated-power-supply/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>programming an atmega8 using arduino</title>
		<link>http://ntsdt.net/2009/08/07/programming-an-atmega8-using-arduino/</link>
		<comments>http://ntsdt.net/2009/08/07/programming-an-atmega8-using-arduino/#comments</comments>
		<pubDate>Fri, 07 Aug 2009 20:44:42 +0000</pubDate>
		<dc:creator>lukus</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[atmega]]></category>
		<category><![CDATA[avrdude]]></category>
		<category><![CDATA[electronics]]></category>
		<category><![CDATA[programmer]]></category>

		<guid isPermaLink="false">http://ntsdt.net/?p=184</guid>
		<description><![CDATA[The ATmega8/168/328 are a range of microprocessors at the heart of the Arduino.  Rather than having to include an external Arduino board with my projects, I&#8217;d like to be able to create self-contained devices which have the ATmega chip embedded.
Programming the ATmega
It&#8217;s possible to program Atmel microprocessors using an Arduino board and the megaISP [...]]]></description>
			<content:encoded><![CDATA[<p>The ATmega8/168/328 are a range of microprocessors at the heart of the Arduino.  Rather than having to include an external Arduino board with my projects, I&#8217;d like to be able to create self-contained devices which have the ATmega chip embedded.</p>
<h3>Programming the ATmega</h3>
<p>It&#8217;s possible to program Atmel microprocessors using an Arduino board and the megaISP project.  This post documents my attempt.</p>
<p><span id="more-184"></span></p>
<p>Before starting of got hold of a copy of the datasheet for the ATmega8 (<a href="http://www.atmel.com/dyn/resources/prod_documents/doc2486.pdf)" target="_blank">http://www.atmel.com/dyn/resources/prod_documents/doc2486.pdf</a>)</p>
<h3>Step 1: Upload mega-isp to Arduino</h3>
<p>I downloaded the mega-isp source, and uploaded it to my Arduino board.  The source can be found at google code (<a href="http://code.google.com/p/mega-isp/" target="_blank">http://code.google.com/p/mega-isp/</a>).</p>
<h3>Step 2: Set up breadboard</h3>
<div class="wp-caption alignleft" style="width: 510px"><img title="mega-isp: programming an atmega8 with arduino" src="http://farm3.static.flickr.com/2447/3798709025_dc18d9e25a.jpg" alt="mega-isp: programming an atmega8 with arduino" width="500" height="375" /><p class="wp-caption-text">mega-isp: programming an atmega8 with arduino</p></div>
<p>First of all, I set up the breadboard according the advice given at <a href="http://www.uchobby.com/index.php/2007/11/04/arduino-avr-in-system-programmer-isp/" target="_blank">http://www.uchobby.com/index.php/2007/11/04/arduino-avr-in-system-programmer-isp/</a></p>
<p>The article mentions something called a bypass capacitor .. which is something I hadn&#8217;t come across before.  Basically, it&#8217;s a small capacitor that&#8217;s used to smooth out small changes in voltage &#8211; and should be used whenever you set up a microprocessor in a circuit.  I learnt about them here (<a href="http://www.seattlerobotics.org/Encoder/jun97/basics.html" target="_blank">http://www.seattlerobotics.org/Encoder/jun97/basics.html</a>)</p>
<p>Because I&#8217;m trying to program an ATmega8 (and not the Tiny18 mentioned in the  article) I needed to adjust the pins.  I also added another LED to signal when megaisp is actually programming (which was mentioned in the Arduino source code).</p>
<div id="attachment_232" class="wp-caption alignright" style="width: 310px"><img class="size-medium wp-image-232 " title="ATMEGA8.pinconfig" src="http://ntsdt.net/wp-content/uploads/2009/08/ATMEGA8.pinconfig-300x273.png" alt="ATmega8/168/328p pinout diagram" width="300" height="273" /><p class="wp-caption-text">ATmega8/168/328p pinout diagram</p></div>
<p>The only pins that I needed to consider were:</p>
<table border="0">
<tbody>
<tr>
<th colspan="3"><strong>The SPI interface</strong></th>
</tr>
<tr>
<td>ATMEGA-PIN19</td>
<td>⇔</td>
<td>ARDUINO-PIN13(SCK)</td>
</tr>
<tr>
<td>ATMEGA-PIN18</td>
<td>⇔</td>
<td>ARDUINO-PIN12(MISO)</td>
</tr>
<tr>
<td>ATMEGA-PIN17</td>
<td>⇔</td>
<td>ARDUINO-PIN11(MOSI)</td>
</tr>
<tr>
<th colspan="3"><strong>Power / Gnd</strong><br />
(I added a bypass capacitor between 7/22 on the atmega)</th>
</tr>
<tr>
<td>ATMEGA-PIN8</td>
<td>⇔</td>
<td>ARDUINO-GND</td>
</tr>
<tr>
<td>ATMEGA-PIN22</td>
<td>⇔</td>
<td>ARDUINO-GND</td>
</tr>
<tr>
<td>ATMEGA-PIN7</td>
<td>⇔</td>
<td>ARDUINO-5V</td>
</tr>
<tr>
<td>ATMEGA-PIN20</td>
<td>⇔</td>
<td>ARDUINO-5V</td>
</tr>
<tr>
<th colspan="3"><strong>Reset</strong></th>
</tr>
<tr>
<td>ATMEGA-PIN1</td>
<td>⇔</td>
<td>ARDUINO-PIN10</td>
</tr>
<tr>
<th colspan="3"><strong>Status LEDs</strong><br />
(each connected to ground via a resistor)</th>
</tr>
<tr>
<td>heartbeat LED</td>
<td>⇔</td>
<td>ARDUINO-PIN9</td>
</tr>
<tr>
<td>error LED</td>
<td>⇔</td>
<td>ARDUINO-PIN8</td>
</tr>
<tr>
<td>programming LED</td>
<td>⇔</td>
<td>ARDUINO-PIN7</td>
</tr>
</tbody>
</table>
<h3>Step 3: Connecting via AVRdude</h3>
<p><a href="http://savannah.nongnu.org/projects/avrdude/" target="_blank">AVRdude</a> is an open-source utility for programming Atmel AVR Microcontrollers.</p>
<p>Running the following from a terminal</p>
<pre class="code">avrdude -p atmega8 -c avrisp -P /dev/ttyUSB0 -b 19200</pre>
<p>produced</p>
<pre class="code">avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.13s

avrdude: Device signature = 0x1e9307

avrdude: safemode: Fuses OK

avrdude done.  Thank you.</pre>
<p>Which indicated that AVRdude had communicated  with the mega-isp successfully.</p>
<div id="_mcePaste" style="overflow: hidden; position: absolute; left: -10000px; top: 684px; width: 1px; height: 1px;">&amp;hArr;</div>
]]></content:encoded>
			<wfw:commentRss>http://ntsdt.net/2009/08/07/programming-an-atmega8-using-arduino/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>creating an led matrix using stripboard</title>
		<link>http://ntsdt.net/2009/08/05/creating-an-led-matrix/</link>
		<comments>http://ntsdt.net/2009/08/05/creating-an-led-matrix/#comments</comments>
		<pubDate>Wed, 05 Aug 2009 03:34:56 +0000</pubDate>
		<dc:creator>lukus</dc:creator>
				<category><![CDATA[arduino]]></category>
		<category><![CDATA[hardware]]></category>
		<category><![CDATA[circuit design]]></category>
		<category><![CDATA[electronics]]></category>
		<category><![CDATA[led matrix]]></category>
		<category><![CDATA[leds]]></category>
		<category><![CDATA[pwm]]></category>
		<category><![CDATA[stripboard]]></category>
		<category><![CDATA[tlc5940]]></category>
		<category><![CDATA[veecad]]></category>

		<guid isPermaLink="false">http://blog.ntsdt.net/?p=144</guid>
		<description><![CDATA[I spent an evening last week constructing a simple LED matrix.  I&#8217;ve been experimenting with Arduino for a while, and had previously ordered sample chips from various semiconductor manufacturers.  One sample chip I&#8217;d been planning to use for a while is the TLC5940 &#8211; which is can be used to drive up to 16 LEDs [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>I spent an evening last week constructing a simple LED matrix.  I&#8217;ve been experimenting with <a href="http://arduino.cc" target="_blank">Arduino</a> for a while, and had previously ordered sample chips from various semiconductor manufacturers.  One sample chip I&#8217;d been planning to use for a while is the TLC5940 &#8211; which is can be used to drive up to 16 LEDs (daisy-chained it can drive even more).</p></blockquote>
<p>You might think there&#8217;s nothing special sounding about this.. and you&#8217;d be right &#8211; only the TLC5940 also takes care of something called PWM (pulse width modulation) which allows control over LED brightness.  Not a huge deal, but still pretty neat.</p>
<p><span id="more-144"></span></p>
<h3>Interfacing the TLC5940 with Arduino</h3>
<p>A library has already been produced  (by Alex Leone) to allow the Arduino to be linked with the TLC5940.  <a href="http://www.arduino.cc/playground/Learning/TLC5940" target="_blank">More info about the library can be found here</a>.  The <a href="http://focus.ti.com/lit/ds/symlink/tlc5940.pdf">datasheet provided by TI </a>is also actually also pretty useful for working out how to create the supporting circuit.</p>
<p>I built the actual circuit using stripboard.  Stripboard (also known as veroboard) is handy for prototyping circuits.  It&#8217;s constructed from a board embossed with strips of copper, which have been punctuated with with evenly spaced holes.  The holes are used for placing the various through-hole components that your circuit requires.</p>
<p>I&#8217;ve found that stripboard is much like a permanent form of breadboard &#8211; another simple tool used for electronics prototyping.</p>
<h3>Planning the circuit</h3>
<p>Planning a circuit using stripboard requires a degree of ingenuity, due to the limited amount of copper strips available.  Often to makes the most efficient use of space, the copper needs to be broken at various points to route the flow of electricity.  Previously I&#8217;d tried to constuct my circuit on paper before putting iron to solder&#8230; but this time I&#8217;d heard about a program called <a href="http://veecad.com/free.html" target="_blank">VeeCAD</a> so I used that.  I really recommend VeeCAD .. it makes the process of visualising how the circuit will work much, much easier.</p>
<div class="wp-caption alignleft" style="width: 510px"><img title="Schematic produced in VeeCAD" src="http://farm4.static.flickr.com/3534/3790441794_2964e87e6c.jpg" alt="Schematic produced in VeeCAD" width="500" height="358" /><p class="wp-caption-text">Fig. 1 - Schematic produced in VeeCAD</p></div>
<h3>Creating the circuit board</h3>
<p>After producing the schematic &#8211; translating the design onto stripboard was pretty straightforward.  The first step involved marking out where the copper needed to be broken on the board.</p>
<p>When working with stripboard you need to break the flow of electricity in various places in the circuit. Previously I&#8217;d used a screwdriver to scrape away the copper, but small bits of metal were occasionally left behind, making short-circuits an eventuality &#8230; so this time I decided to use a drill.</p>
<p>Once the holes had been drilled I could go about assembling the rest of the circuit.</p>
<p>My soldering skills are not the best, but they&#8217;re slowing improving.  If you&#8217;re a beginner like me, I&#8217;d suggest you take it slowly and plan as much as possible before hand.  I tried to approach the building of the board in a measured way; tackling wiring first, followed by the IC sockets and the LEDs.  I found that as long as I took one step at a time I was fine.</p>
<p>Once I&#8217;d built the board, I checked continuity with a multimeter and loaded the TLC5940 into the IC socket.  After hooking the board up to my Arduino using some jump leads, I was able to load up some of the demo code from the TLC5940 library and watch it in action.</p>
<div class="wp-caption alignleft" style="width: 250px"><img title="Drilled holes to break the flow of electricity in the circuit" src="http://farm3.static.flickr.com/2675/3789896716_b9bff39fa0_m.jpg" alt="Drilled holes to break the flow of electricity in the circuit" width="240" height="182" /><p class="wp-caption-text">Fig. 2 - Drilled holes to break the flow of electricity in the circuit</p></div>
<div class="wp-caption alignleft" style="width: 250px"><img title="Board minus the TLC5940, resistors and LEDs" src="http://farm4.static.flickr.com/3581/3789155371_18f836baf2_m.jpg" alt="Board minus the TLC5940, resistors and LEDs" width="240" height="181" /><p class="wp-caption-text">Fig. 3 - Board minus the TLC5940, resistors and LEDs</p></div>
<div class="wp-caption alignnone" style="width: 510px"><img title="Final board" src="http://farm4.static.flickr.com/3473/3789966112_0b73d634fe.jpg" alt="Finished Board" width="500" height="365" /><p class="wp-caption-text">Fig. 4 - Final board</p></div>
<div class="wp-caption alignnone" style="width: 510px"><img title="Glowing LED Matrix" src="http://farm4.static.flickr.com/3502/3790441624_0dc63dd789.jpg" alt="Glowing LED Matrix" width="500" height="372" /><p class="wp-caption-text">Fig. 5 - Glowing LED Matrix</p></div>
<div id="_mcePaste" style="overflow: hidden; position: absolute; left: -10000px; top: 359px; width: 1px; height: 1px;">
<p>Once the holes had been drilled I could go about assembling the rest of the circuit.</p>
<p>My soldering skills are not the best, but they&#8217;re slowing improving.  If you&#8217;re a beginner like me, I&#8217;d suggest you take it slowly and plan as much as possible before hand.  I tried to approach the building of the board in a measured way; tackling wiring first, followed by the IC sockets and the LEDs.  I found that as long as I took one step at a time I was fine.</p>
<p>Once I&#8217;d built the board, I checked continuity with a multimeter and loaded the TLC5940 into the IC socket.  After hooking the board up to my Arduino using some jump leads, I was able to load up some of the demo code from the TLC5940 library and watch it in action.</p>
<p>Next project will be to produce an LED cube.</p></div>
]]></content:encoded>
			<wfw:commentRss>http://ntsdt.net/2009/08/05/creating-an-led-matrix/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>first steps with atmel assembly</title>
		<link>http://ntsdt.net/2008/08/08/first-steps-with-atmel-assembly/</link>
		<comments>http://ntsdt.net/2008/08/08/first-steps-with-atmel-assembly/#comments</comments>
		<pubDate>Fri, 08 Aug 2008 01:26:57 +0000</pubDate>
		<dc:creator>lukus</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[assembly language]]></category>
		<category><![CDATA[atmega]]></category>
		<category><![CDATA[atmel]]></category>
		<category><![CDATA[avr studio]]></category>
		<category><![CDATA[electronics]]></category>

		<guid isPermaLink="false">http://blog.ntsdt.net/?p=85</guid>
		<description><![CDATA[I&#8217;ve been experimenting with Arduino for quite a while and have had a lot of fun using it.  Arduino is an open-source hardware platform which has become very popular with digital-artists, hardware-hackers and people interested in finding ways to make computing more physical.
While the Arduino IDE is suitable for most tasks, there are times [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been experimenting with Arduino for quite a while and have had a lot of fun using it.  Arduino is an open-source hardware platform which has become very popular with digital-artists, hardware-hackers and people interested in finding ways to make computing more physical.</p>
<p>While the Arduino IDE is suitable for most tasks, there are times when more granular control over the way that the ATMega microprocessor executes instructions is useful.  This is where an understanding of Atmel&#8217;s assembly language comes in handy.</p>
<p><span id="more-85"></span>To be honest, I initially thought that assembly language would involve concepts that my brain would have a lot of difficulty comprehending.  Luckily (for me) the process turned out to be far simpler than I initially imagined, and I was able to start using Atmel Assembly last night.  I decided to post my experiences here in case it helps anyone else (and to cement the info in my own mind).  Thanks go to a guy called eadthem on #freenode irc for help and guidance.</p>
<div id="attachment_229" class="wp-caption alignleft" style="width: 778px"><img class="size-full wp-image-229" title="atmega8" src="http://ntsdt.net/wp-content/uploads/2008/08/atmega8.jpg" alt="ATmega8 Microprocessor" width="768" height="576" /><p class="wp-caption-text">ATmega8 Microprocessor</p></div>
<h3>AVR Studio</h3>
<p>One of the great things about the ATmega chip (which is the family of microprocessor chips at the heart of the Arduino platform) is the range of free development tools which it&#8217;s parent company Atmel provides. In this case, I used an IDE called AVR Studio 3.5 (<a href="http://www.atmel.com/dyn/products/tools_card.asp?tool_id=2724" target="_blank">http://www.atmel.com/dyn/products/tools_card.asp?tool_id=2724</a>)</p>
<p>As I run linux, I needed to use wine to run AVR Studio.  There wasn&#8217;t any problem doing so.  Wine decompresses to a folder in the fake &#8216;windows/temp&#8217; directory&#8230;. you simply need to navigate and open &#8216;~/.wine/drive_c/windows/temp/cdrom/SETUP.EXE&#8217; which runs and completes the installation process.  After installation, Atmel Studio was available in application menu (Applications -&gt; Wine -&gt; Programs-&gt;Atmel AVR Tools-&gt;AVR Studio 3.56).</p>
<h3>Obtaining Supporting Documentation</h3>
<p>There are various versions of the ATmega chip in production &#8211; and each has a different range of capabilities associated with it. I&#8217;m using an Atmega8 microprocessor, so it was important that I made sure I had the relevant datasheet at hand and the AVR 8-bit Instruction Set documents.  You can find these via the links below.</p>
<p>[*1] (<a href="http://www.atmel.com/dyn/resources/prod_documents/doc2486.pdf" target="_blank">http://www.atmel.com/dyn/resources/prod_documents/doc2486.pdf</a>)</p>
<p>[*2] (<a href="http://www.atmel.com/dyn/resources/prod_documents/doc0856.pdf" target="_blank">http://www.atmel.com/dyn/resources/prod_documents/doc0856.pdf</a>) &lt;- pages 10 to 14 are especially relevant.</p>
<h3>Setting up the Project</h3>
<p>Okay, first task was to set-up a new project in AVR Studio.</p>
<pre class="code">Project -&gt; new -&gt; [give it a name] / [pick AVR assembler].</pre>
<p>This creates a blank project.  Next we need a new text file to put our assembly code.</p>
<pre class="code">File -&gt; new text file -&gt; [give it the name 'main.asm']</pre>
<p>As far as I know, the name isn&#8217;t important &#8211; what <strong><em>is</em></strong> important is that when you right click this file, &#8216;assembler entry file&#8217; is ticked.  You also need to drag this file into the Assembler Files folder.</p>
<p>Next, right click the route node of the project, and select the &#8216;project settings&#8217;.  Change the output file format to &#8216;intel hex&#8217;.  This defines the format that will eventually be used by the programmer software / board to upload the code to the microprocessor.</p>
<h3>Writing the Code</h3>
<p>Okay &#8211; next step is to produce the required code.</p>
<p>Open up the text file created a few steps ago.</p>
<p>The very first stage involves setting the start point in your program memory, to hex address 3A.  You need to add the following line at the begining of this newly opened file.</p>
<pre class="code">.ORG $3A</pre>
<p>and then continue to add the following lines of code &#8230;</p>
<pre class="code">START:	LDI	r16,high(ramend)	;ramend=$025F p7-9
	OUT	sph,r16
	LDI	r16,low(ramend)
	OUT	spl,r16</pre>
<p>It&#8217;s worth running through some of the conventions here.</p>
<ul>
<li> The word preceding the colon, defines a point in the program code which can be called or jumped to later on. This is then used to enable us to call subroutines and create loops.</li>
<li> The semicolon defines a comment.</li>
<li> LDI and OUT are instructions &#8230; (a full list of the AVR instruction set can be found in the guide linked above [*2], pages 10-14)</li>
<li> r16 is a register.  Registers can be though of as internal variables, which are able to be accessed very quickly by the processor; some are specific and can only be used in certain circumstances, while others are general purpose.</li>
<li> sph and spl refer to the AVR stack pointer (which is implemented as two 8-bit registers). The stack is a stack of data &#8211; you can add (push) data to the stack, or take (pop) data from the stack.  Find out more about the stack on page 13 of [*1].</li>
<li> As far as I can tell ramend, is a device specific constant, which refers to the end of the available data RAM.</li>
</ul>
<p>For this first program, I simply wanted to make an LED flash.  To do this, I need to output a HIGH signal followed by a LOW signal to one of the ports on the ATmega.</p>
<p>I was a bit confused here, thinking that port is another word for pin&#8230; it isn&#8217;t.  The Atmega8 has three ports labelled BCD which are responsible for looking after 23 IO general purpose IO lines/pins.</p>
<dl>
<dt> Port B </dt>
<dd> looks after 8 I/O lines (PB7-0) </dd>
<dt> Port C </dt>
<dd> looks after 7 I/O lines (PC6-0) &#8230; but note that PC6 is special case and is different to others, it&#8217;s used as an IO pin or reset see page 5 of [*1] for more info. </dd>
<dt> Port D </dt>
<dd> looks after 8 I/O lines (PD7-0) </dd>
</dl>
<p>Each port pin consists of three register bits ( DDxn, PORTxn, PINxn).  By using a bit of cleverness, all the required physical ports can be accessed through address lookups.</p>
<ul>
<li> DDxn bits are accessed at the DDRx I/O address,</li>
<li> PORTxn bits are accessed at the PORTx I/O address</li>
<li> PINxn bits are accessed at the PINx I/O address.</li>
</ul>
<p>(N/B Page 65 of [*1] is a useful overview of how data is output (PORTxn), how pin direction is defined (DDRxn) and where input data is stored/accessed (PINxn), in relation to the available ports and pins.)</p>
<p>Because the ports and IO lines/pins are general purpose, we need to be able to define which are used for input and which are used for output.  This is done by setting the port direction.</p>
<pre class="code">	LDI r18,0b10000000
	OUT ddrb,r18</pre>
<p>LDI is the instruction for &#8216;load immediate&#8217;, OUT is the instruction for &#8216;out to i/o location&#8217;.</p>
<p>Next, we preload registers r18 and r19 with the data that we&#8217;ll use to make our LED flash&#8230; because we use these values many times, the assignment happens before the main loop.</p>
<pre class="code">	LDI r18,0b10000000; set register to pin 7 high
	LDI r19,0b00000000; set register to all pins low</pre>
<p>Then we can add the main loop &#8230;</p>
<pre class="code">MAINLOOP:
	out portb,r18
	out portb,r19
	jmp MAINLOOP</pre>
<div id="attachment_203" class="wp-caption alignright" style="width: 310px"><a href="http://ntsdt.net/wp-content/uploads/2008/08/avrstudio_screenshot1.gif"><img class="size-medium wp-image-203" title="avrstudio_screenshot1" src="http://ntsdt.net/wp-content/uploads/2008/08/avrstudio_screenshot1-300x220.gif" alt="AVR Studio Screenshot" width="300" height="220" /></a><p class="wp-caption-text">AVR Studio Screenshot</p></div>
<p>Now, the great thing about AVR Studio &#8211; is that you can use it to run your code in a simulator, which allows you to debug the code, while monitoring the status of registers, i/o ports etc..</p>
<p>Before we can simulate the code we need to include a file in our AVR Studio project (which gives device dependant info) at the beginning of the code. (a range of inc files can be found in the &#8216;Appnotes&#8217; subdirectory of yr AVR Studio install)</p>
<pre class="code">.include "m8def.inc"</pre>
<p>Then select; Project -&gt; Build and run&#8230; You&#8217;ll need to select the chip you&#8217;re working with.  Select View -&gt; &#8216;registers&#8217; &amp; &#8216;new io view&#8217;&#8230; then you can step through yr code with F10 and examine it&#8217;s effect.</p>
]]></content:encoded>
			<wfw:commentRss>http://ntsdt.net/2008/08/08/first-steps-with-atmel-assembly/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
