<?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>Ripples in the Ether &#187; Coding</title>
	<atom:link href="http://www.nt7s.com/blog/category/coding/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.nt7s.com/blog</link>
	<description>Emanations from Amateur Radio Station NT7S</description>
	<lastBuildDate>Wed, 01 Feb 2012 10:41:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>avs3a Google Code Page</title>
		<link>http://www.nt7s.com/blog/2008/10/avs3a-google-code-page/</link>
		<comments>http://www.nt7s.com/blog/2008/10/avs3a-google-code-page/#comments</comments>
		<pubDate>Thu, 16 Oct 2008 10:20:26 +0000</pubDate>
		<dc:creator>Jason Milldrum</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[FPGA]]></category>
		<category><![CDATA[xilinx]]></category>

		<guid isPermaLink="false">http://www.nt7s.com/blog/?p=165</guid>
		<description><![CDATA[A few quick updates to the avs3a software that I've writting for the Avnet Spartan-3A Eval Kit (as mentioned in a previous post). First, many thanks to George Gallant from the Avnet Spartan-3A Eval Kit mailing list for rewriting the code to fix the horrible configuration time, as well as for the many error checking [...]]]></description>
			<content:encoded><![CDATA[<p>A few quick updates to the avs3a software that I've writting for the Avnet Spartan-3A Eval Kit (as mentioned in a <a href="http://www.nt7s.com/blog/2008/09/configuring-the-avnet-spartan-3a-eval-board-on-linux-alpha/">previous post</a>). First, many thanks to George Gallant from the Avnet Spartan-3A Eval Kit mailing list for rewriting the code to fix the horrible configuration time, as well as for the many error checking and usability improvements. Secondly, I've taken the latest version of George's code revision and uploaded it to a new <a href="http://code.google.com/p/avs3a/">Google Code site</a>, where it will now be hosted. Go there for the latest download of the project tarball or to check out your own copy from Subversion.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nt7s.com/blog/2008/10/avs3a-google-code-page/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Configuring the Avnet Spartan-3A Eval Board on Linux (Alpha)</title>
		<link>http://www.nt7s.com/blog/2008/09/configuring-the-avnet-spartan-3a-eval-board-on-linux-alpha/</link>
		<comments>http://www.nt7s.com/blog/2008/09/configuring-the-avnet-spartan-3a-eval-board-on-linux-alpha/#comments</comments>
		<pubDate>Thu, 25 Sep 2008 17:03:54 +0000</pubDate>
		<dc:creator>Jason Milldrum</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[FPGA]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[spartan-3a]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.nt7s.com/blog/?p=123</guid>
		<description><![CDATA[As I mentioned on the Avnet Spartan-3A Eval Kit Google Group, I've created a C program that will allow you to configure the FPGA via your Linux box. I don't have a lot of time to elaborate on how to use this program, but the basic steps are listed below. These instructions assume that you [...]]]></description>
			<content:encoded><![CDATA[<p>As I mentioned on the <a href="http://groups.google.com/group/avnet-spartan-3a-eval-kit">Avnet Spartan-3A Eval Kit</a> Google Group, I've created a C program that will allow you to configure the FPGA via your Linux box. I don't have a lot of time to elaborate on how to use this program, but the basic steps are listed below. These instructions assume that you are at least moderately familiar with using the shell in your distribution and building a program from source code. This code is in an alpha state and I have only tested this on my Ubuntu Hardy Heron box, so your mileage may vary. I'm sure there's much I can do to improve it (clean up, refactor, etc.), but it seems to do what it needs to for now.</p>
<p>Right now, the program is controlled by three command line switches. I've created these options with a mind for expansion in the future (at least the serial flash part). Here's the help printout from the program:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">Usage: avs3a [options]
Options:
  -b, --bitstream=BITSTREAM	Bitstream used to configure FPGA
  -p, --port=SERIAL-PORT	Serial port connected to eval board
  -s, --slaveser		Configure FPGA in Slave Serial mode</pre></div></div>

<ol>
<li>Download the source code <a href="http://www.nt7s.com/media/avs3a.tar.gz">here</a>.</li>
<li>Unpack the archive in the location where you intend to use the program.

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">tar</span> xzvf avs3a.tar.gz</pre></div></div>

</li>
<li>Change to the avs3a directory.

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> avs3a</pre></div></div>

</li>
<li>Build the program from source.

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">make</span> all</pre></div></div>

</li>
<li>Make sure that your eval board is plugged into a USB port.</li>
<li>If you don't know the serial port of the eval board, then find it. I'm not sure what you will see, but on my Ubuntu Hardy box, my board enumerates as /dev/ttyACM0 or /dev/ttyACM1

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">dmesg</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> tty</pre></div></div>

</li>
<li>Make sure you have a bitstream file to use.</li>
<li>Issue the command to program the board

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">.<span style="color: #000000; font-weight: bold;">/</span>avs3a <span style="color: #660033;">-s</span> <span style="color: #660033;">-p</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>ttyACM0 <span style="color: #660033;">-b</span> sample_bitstream.bit</pre></div></div>

</li>
</ol>
<p>If you try this and find it useful, or find a problem with the program then please, <em>please</em>, let me know in the comments below (or e-mail me). Thank you for testing this!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nt7s.com/blog/2008/09/configuring-the-avnet-spartan-3a-eval-board-on-linux-alpha/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Learning DSP Concepts with BasicDSP</title>
		<link>http://www.nt7s.com/blog/2008/08/learning-dsp-concepts-with-basicdsp/</link>
		<comments>http://www.nt7s.com/blog/2008/08/learning-dsp-concepts-with-basicdsp/#comments</comments>
		<pubDate>Wed, 13 Aug 2008 19:47:47 +0000</pubDate>
		<dc:creator>Jason Milldrum</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[dsp]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.nt7s.com/blog/?p=35</guid>
		<description><![CDATA[Completely by accident, I happened to stumble upon a program that gives you an easy way to learn DSP techniques by focusing on the underlying algorithms and not the hardware details. The program is called BasicDSP and is available as a Linux source tarball or Windows executable. BasicDSP was created by PA3FWM and PE1OIT as [...]]]></description>
			<content:encoded><![CDATA[<p>Completely by accident, I happened to stumble upon a program that gives you an easy way to learn DSP techniques by focusing on the underlying algorithms and not the hardware details. The program is called <a href="http://wwwhome.cs.utwente.nl/~ptdeboer/ham/basicdsp/">BasicDSP</a> and is available as a Linux source tarball or Windows executable. BasicDSP was created by PA3FWM and PE1OIT as a tool to allow you to experiment with signal processing algorithms from basic building blocks such as filters and mixers, up to complete receiver systems in code. The program can take its input from a variety of sources, such as the soundcard, a file, or an internally generated signal. A simple scripting language is then used to manipulate the input data using a variety of DSP techniques (including some built-in functions). The resulting audio is them piped back out to the soundcard, as well as optional spectrum and oscilloscope displays.</p>
<p><a href="http://www.nt7s.com/blog/wp-content/uploads/2008/08/basicdspscreenshot.png" rel="lightbox[35]"><img class="size-medium wp-image-36 alignleft" style="border: 0pt none; margin-left: 5px; margin-right: 5px;" title="BasicDSP Screenshot" src="http://www.nt7s.com/blog/wp-content/uploads/2008/08/basicdspscreenshot-300x235.png" alt="BasicDSP running on my Ubuntu Hardy notebook" width="300" height="235" /></a></p>
<p>The source tarball didn't want to compile on my Ubuntu Hardy machine on the first try. It threw some cryptic errors about some of the wxWidget objects in the code. A bit of Googling and some lucky guessing enabled me to figure out that the code wanted to compile with wxWidgets 2.6, not the version 2.8 that is standard on Hardy. I forced the linker to use 2.6 and managed to get the code to compile (although it was still complaining about a few warnings). Once I got over that speed bump, the program seemed to work as advertised, with one exception. As you can see in the attached screenshot, something is seriously wrong with the spectrum display. For some reason, the program is drawing vertical lines across the entire spectrum where there should be nothing. Since I had access to the code, I thought that maybe I would give a shot a locating any glaring problems that might be causing this. I know a bit of C++, but have very little experience in coding for *nix machines, and know virtually nothing about wxWidgets. However, the code to draw the spectrum display seemed fairly obvious and I couldn't find anything wrong with it. You can still see a signal on the display if you look hard enough, but its very difficult to tell with all of the offending vertical lines. My best guess is that something is wrong in the array which holds the FFT data plotted by the spectrum display, but that's only a guess. I just don't have the expertise or the proper tools to properly debug this type of problem.</p>
<p>Ignoring that flaw, this is otherwise a really neat program. The syntax is very simple and allows you to easily try different processing concepts in just a few lines of code. There are two special variables that get used in every script: <em>in</em> and <em>out</em>. The <em>in</em> variable represents the data flowing into BasicDSP from the chosen source, while <em>out</em> is the variable that you send your processed data to in order to output it to the speaker. The simplest script that you can write for BasicDSP is a passthrough function, where no processing of the data is performed:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">out = in</pre></div></div>

<p>In the above example, each sample is directly passed to the output. If you could not hear the output very well, you can amplify the signal by performing multiplication with a constant.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">out = in * 100</pre></div></div>

<p>By multiplying the sample by 100, you are increasing the signal level by 40 dB.<br />
<p style='text-align:center;'><span class='MathJax_Preview'><img src='http://www.nt7s.com/blog/wp-content/plugins/latex/cache/tex_32fc33f7ec145c1c54875c42fd78e8c2.gif' style='' class='tex' alt="20\ \log\ 100 = 40\ \text{dB}" /></span></p></p>
<p>There are four slider controls which are accessible via variable (<em>slider1</em> - <em>slider4</em>). These allow you to dynamically alter variables in the script. For example, if you wanted to be able to change the signal level with a slider, it's a simple as:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">out = in * slider1</pre></div></div>

<p>There are other special variables and functions included in the scripting language that help to enable common DSP tasks. These can all be put together to create simple circuit blocks like low-pass filters, up to more complex tasks like quadrature receivers. A basic direct conversion receiver can be put together quite simply using these functions. The following code (taken from a reprint of a <a href="http://www.vf.utwente.nl/~ptdeboer/ham/basicdsp/BasicDSP_SPRAT.pdf">SPRAT tutorial</a>) implements the DC receiver in code by creating a sawtooth oscillator (in lines 2 &amp; 3), mixing the input signal to baseband (just a simple multiplication at line 4), then sending the signal through two stages of low-pass filtering (lines 5 &amp; 6).</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="text" style="font-family:monospace;">samplerate = 48000
sawtooth = mod1(sawtooth+slider1)
osc = sin1(sawtooth)
mix = osc * in
lpfa = lpfa + slider2*(mix-lpfa)
lpfb = lpfb + slider2*(lpfa-lpfb)
out = lpfb</pre></td></tr></table></div>

<p>There's some more information on the program and some good example code on the website of <a href="http://home.tiscali.nl/curious_about/PE1OIT/basicdsp/index.html">PE1OIT</a>. If you have even a small bit of interest in the inner workings of a SDR receiver, you owe it to yourself to download this software and try it out.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nt7s.com/blog/2008/08/learning-dsp-concepts-with-basicdsp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Programming AVR Microcontrollers in Eclipse</title>
		<link>http://www.nt7s.com/blog/2008/07/programming-avr-microcontrollers-in-eclipse/</link>
		<comments>http://www.nt7s.com/blog/2008/07/programming-avr-microcontrollers-in-eclipse/#comments</comments>
		<pubDate>Mon, 07 Jul 2008 10:23:15 +0000</pubDate>
		<dc:creator>Jason Milldrum</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Microcontrollers]]></category>
		<category><![CDATA[avr]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.nt7s.com/blog/?p=18</guid>
		<description><![CDATA[Lately, I have been using my Ubuntu Hardy Heron box for coding and programming my AVR projects using the simple combination of gedit, the avr-gcc toolchain and the USBtinyISP. It's a little bit of a pain to get set up correctly, but it works very well once it's up and running. I've been pretty happy [...]]]></description>
			<content:encoded><![CDATA[<p>Lately, I have been using my <a href="http://www.ubuntu.com/">Ubuntu</a> Hardy Heron box for coding and programming my AVR projects using the simple combination of <a href="http://www.gnome.org/projects/gedit/">gedit</a>, the <a href="http://www.avrfreaks.net/index.php?module=FreaksTools&amp;func=viewItem&amp;item_id=145">avr-gcc</a> toolchain and the <a href="http://www.ladyada.net/make/usbtinyisp/">USBtinyISP</a>. It's a little bit of a pain to get set up correctly, but it works very well once it's up and running. I've been pretty happy with editing code in gedit then compiling and programming the AVR via command line. It's pretty easy to quickly make changes to the code and save the C file in gedit, then use the command history of the terminal to re-run make and avrdude.</p>
<p>However, I recently ran across <a href="http://www.avrfreaks.net/index.php?name=PNphpBB2&amp;file=viewtopic&amp;t=65879">this</a> posting when browsing the AVR Freaks forum. The author kindly gives instructions on how to set up the <a href="http://www.eclipse.org/">Eclipse IDE</a> for use in AVR development on the Ubuntu platform. This looked really promising, since I've always been a sucker for nice IDEs (yes, I know that probably lowers my geek cred a few notches). So I gave it a go and found that the instructions worked nearly flawlessly. The only hiccup I encountered was at the very end of the build process when Eclipse was waiting for the sudo password for avrdude (oddly enough, you have to run avrdude as root to access the USB programmer, unless you implement a little workaround that I'll show you in a second). I didn't see any way to enter the root password into a terminal, so I had to cancel the whole process.</p>
<p>A bit of thought and much more searching brought me to the answer to the problem. There is a way to get non-root access to the USBtinyISP. You have to create a <a href="http://en.wikipedia.org/wiki/Udev">udev</a> rule to tell the kernel to change permissions on the USBtinyISP. The <a href="http://ladyada.net/make/usbtinyisp/avrdude.html">documentation</a> on the ladyada website tells you to do this, but it only gives you half of the story. First of all, it doesn't mention exactly where to place the new rule that you are creating. Her documentation stated that I needed to put the rule in a file in /etc/udev/rules.d/. The problem is that this doesn't state whether I need to place the rule in an existing file or create a new one. After a bit of trial-and-error and yet some more Google searching, I found out that I needed to create a new file for the USBtinyISP. So a new file named <em>50-usbtinyisp.rules</em> was created. The other problem is that the actual rule given on the ladyada site seems to have a typo in the MODE parameter. Comparing this rule to some other rule examples, it appears that the correct rule is:</p>
<p><em>SUBSYSTEM=="usb", SYSFS{idVendor}=="1781", SYSFS{idProduct}=="0c9f", GROUP="users", MODE="0666"</em></p>
<p>Once you get the udev rule set up correctly, you no longer need root to access the USBtinyISP, and the entire build process in Eclipse works flawlessly.</p>
<p>So far, using Eclipse as an AVR development platform has been a real pleasure. There's a lot of nice little touches, like having quick access to all of the special function registers of each device and easy configuration of the build parameters via GUI. If you are like me and like the convenience that an IDE gives you, then the AVR/Eclipse environment is an excellent choice, and may even be better than WinAVR.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nt7s.com/blog/2008/07/programming-avr-microcontrollers-in-eclipse/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

