<?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>HackMe</title>
	<atom:link href="http://hackmeopen.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://hackmeopen.com</link>
	<description>Open Source Electronics</description>
	<lastBuildDate>Mon, 04 Mar 2013 20:12:02 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Getting Started with Electronics</title>
		<link>http://hackmeopen.com/2013/03/getting-started-with-electronics/</link>
		<comments>http://hackmeopen.com/2013/03/getting-started-with-electronics/#comments</comments>
		<pubDate>Mon, 04 Mar 2013 20:12:02 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[General Electronics]]></category>
		<category><![CDATA[electronics design]]></category>
		<category><![CDATA[Embedded Programming]]></category>
		<category><![CDATA[embedded systems]]></category>
		<category><![CDATA[getting started in electronics]]></category>
		<category><![CDATA[newbie electronics]]></category>

		<guid isPermaLink="false">http://hackmeopen.com/?p=1035</guid>
		<description><![CDATA[So you&#8217;re thinking of getting into electronics design? I think that&#8217;s a great idea. I have to warn you though, It&#8217;s going to take some work. While I&#8217;m no hardcore grizzled veteran, I&#8217;ve been at this long enough now to be able to reflect a little bit about the journey and offer a little advice [...]]]></description>
				<content:encoded><![CDATA[<p>So you&#8217;re thinking of getting into electronics design? I think that&#8217;s a great idea. I have to warn you though, It&#8217;s going to take some work. While I&#8217;m no hardcore grizzled veteran, I&#8217;ve been at this long enough now to be able to reflect a little bit about the journey and offer a little advice for anyone starting out in the field. Electronics can be a very intimidating subject to the outsider with layers and layers of difficult subject material loaded with jargon. It doesn&#8217;t help that people commonly in possession of the knowledge often aren&#8217;t all that keen on sharing what they view as their job security. So what&#8217;s the best path for a newbie? I get asked this question often enough that I thought I&#8217;d write up a stock response.</p>
<h1>Where to Start</h1>
<p>You&#8217;ve got to start somewhere. I spent years on the periphery, reading magazine articles and obsessing about recording equipment before I had the realization that I wanted to learn how to design it myself. I&#8217;d been to school a couple times before, so I went with what I knew.</p>
<h2>School?</h2>
<p>Call it old school, but I went to school (it was old; Thomas Jefferson started it) to study electrical engineering. To me, there is no complete substitute for serious education when it comes to a difficult technical subject, like electronics. While there are many exceptions, people I&#8217;ve worked with in the field, without a rigorous academic degree, often have gaps in their knowledge stemming from the fact that they haven&#8217;t been exposed to the underlying theoretical bases. For example, it&#8217;s one thing to understand that adjusting a capacitor&#8217;s value will adjust a filter&#8217;s frequency and another to anticipate the effect of coupling between parallel traces on a PCB caused by unwanted capacitance. Applied Electromagnetics is not an easy subject. There&#8217;s just no way I would&#8217;ve learned it on my own. Most people who don&#8217;t go the school route will probably never learn it either and they&#8217;ll lack a fundamental building block of electronics knowledge. What they&#8217;ll be lacking is a piece of the problem solving repertoire required to work quickly and effectively. There are many other similar subjects. That said, I have met truly exceptional engineers who have never attended a day of formal engineering education. What these people seem to have possessed was both an undying commitment to learning the art and the benefit of a strong mentor.</p>
<p>Many people just don&#8217;t have the opportunity to attend a traditional engineering school, and for them, we are at the dawn of a new day. Massive Open Online Courses (MOOCs) are just getting started. You can take an MIT introductory electronics class for <a title="MIT Electronics" href="https://6002x.mitx.mit.edu/" target="_blank">free</a>. You can also take a large number of programming classes from a number of MOOC providers. However, to get the most out of it, you&#8217;ve really got to apply yourself. You don&#8217;t get the benefit of being motivated by an interested professor or by the need to get the most out of your education dollar. If you&#8217;re going to go this route, you&#8217;ll need to be your own taskmaster to make sure that you truly learn the subject.</p>
<h2>Books?</h2>
<p>Even if you were able to get a formal engineering education, you&#8217;ll always need books to learn new things. I&#8217;m working, albeit slowly, to make some of the things that I learn available for free. But, the serious engineering masters seem to broadly require a fee for their knowledge, the price of their book. You can&#8217;t blame them for monetizing their knowledge, but it confines the best engineering writing to textbooks. You can scour the web and find tidbits, like mine with examples that show you how to build something, but some of it isn&#8217;t written very well (sorry) and a lot of it is just copying an implementation. With the latter, you&#8217;ll never understand how it really works, only how to build this example. You can copy it, but what happens when you incorporate it into a larger system and the behavior changes? The best method is to start from the basics and build on them. Old-fashioned books are still the best source of complete information on electronics design from the ground up. By far, my favorite book of all time on the subject of fundamentals of electronics is <a href="http://www.amazon.com/Art-Electronics-Paul-Horowitz/dp/0521370957">The Art of Electronics</a>. It&#8217;s got all the basics covered and it&#8217;s written in a more prosaic, less jargon and math focused way that is rewarding for the rookie reader. It&#8217;s pretty old though and won&#8217;t help you with embedded systems development. For embedded programming, I got some miles out of Michael Barr&#8217;s book <a href="http://www.amazon.com/Programming-Embedded-Systems-Development-Tools/dp/0596009836/ref=sr_1_2?s=books&amp;ie=UTF8&amp;qid=1362424538&amp;sr=1-2&amp;keywords=embedded+programming">Programming Embedded Systems</a>. There are many books about embedded hardware development, but most of what I know on this subject, I learned by doing.</p>
<h2>Hands-On</h2>
<p><span style="font-size: 1rem;">I was able to build solid knowledge foundations in school, but I feel like most of what I really deeply learned came from working, building, and doing. The good news is that the maker movement has produced a wide array of hands-on starter kits and tools. If you don&#8217;t know <a href="http://www.arduino.cc/">Arduino</a>, you should. It is by far the easiest way to get started with embedded electronics and with the wide availability of shields, hardware extensions, it&#8217;s a great way to learn. It&#8217;s also a convenient medium for quick development, even used by &#8220;serious&#8221; professionals to make prototypes. Last year, the Raspberry Pi came out featuring some serious embedded hardware.  If you&#8217;re more interested in higher-level embedded software development, particularly with Linux, it could be the way to go. There are quite a few of these pre-built embedded foundation systems available and more and more all the time. There seems to be an emerging hardware battle for systems built around ARM microcontrollers. It&#8217;s a good time to be a nerd. </span></p>
<p><span style="font-size: 1rem;">On the hardware side, there are many vendors of quality introductory electronics kits. Most people know about <a href="http://www.adafruit.com/">Adafruit </a>and <a href="http://www.sparkfun.com/">Sparkfun</a>, both of whom sell quality novice electronics kits. Find a kit that does something that interests you. Build it. Then, understand how it works. Modify it. Make it do something else. Make it work better. </span></p>
<h2>Smart People</h2>
<p>Beginning in electronics can be scary, but there&#8217;s no better antidote to that than knowledge. I catch myself, when speaking to someone who wants me to work on something I haven&#8217;t yet and don&#8217;t understand, with a moment of internal panic. I have to reassure myself that, with enough effort, this too I can learn. There&#8217;s no shame in the answer, &#8220;I don&#8217;t know.&#8221; In fact, it&#8217;s often the best response because it presents a learning opportunity. Finding smart people with the answers is a great thing, particularly if they&#8217;re willing to share them. I often find that nerds are so happy to find someone interested in what they do, they&#8217;ll gladly spend some time to teach it to you.</p>
<h2>Go Forth</h2>
<p>Building and making is a profoundly human endeavor. It satisfies our desire to create. No matter which way you decide to go about it, it&#8217;s important just to start. Without taking that first step, you&#8217;ll never understand it. If you need encouragement, just let me know&#8230;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://hackmeopen.com/2013/03/getting-started-with-electronics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RTOS Quick Tour</title>
		<link>http://hackmeopen.com/2013/02/freertos-getting-to-know-you/</link>
		<comments>http://hackmeopen.com/2013/02/freertos-getting-to-know-you/#comments</comments>
		<pubDate>Fri, 08 Feb 2013 21:23:13 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Embedded Design]]></category>
		<category><![CDATA[K-DSC-1]]></category>
		<category><![CDATA[C Programming]]></category>
		<category><![CDATA[Embedded Programming]]></category>
		<category><![CDATA[FreeRTOS]]></category>
		<category><![CDATA[Open Source Electronics]]></category>
		<category><![CDATA[RTOS]]></category>

		<guid isPermaLink="false">http://hackmeopen.com/?p=993</guid>
		<description><![CDATA[Here&#8217;s the scenario: you&#8217;ve got a microcontroller-based synthesizer. The synthesizer has a lot to do. It needs to check inputs like potentiometers, sliders, and keys. It needs to indicate its state to the user with LEDs and displays. And most importantly, it needs to generate noise. The standard method of handling all these tasks is [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://hackmeopen.com/wp-content/uploads/2012/12/freertos-image.jpeg"><img class="aligncenter size-full wp-image-994" alt="freertos image" src="http://hackmeopen.com/wp-content/uploads/2012/12/freertos-image.jpeg" width="367" height="137" /></a> Here&#8217;s the scenario: you&#8217;ve got a microcontroller-based synthesizer. The synthesizer has a lot to do. It needs to check inputs like potentiometers, sliders, and keys. It needs to indicate its state to the user with LEDs and displays. And most importantly, it needs to generate noise. The standard method of handling all these tasks is to order them in a loop and handle them one at a time ad infinitum. But, not all of these tasks are as important as the other tasks. How can they be sorted and how can the system ensure that the most important tasks are handled before tasks of lesser importance? Let&#8217;s dig in.<span id="more-993"></span> The most important task a synthesizer handles is generating audio. In a digital synthesizer, the audio generation is a strictly timed process; perfection is required. If the timing is not exact, the audio will contain anomalous artifacts. If the timing is simply inconsistent, it will be noisy, either like a haze has been placed over it or with added static white noise. If it&#8217;s consistently or repetitively off-timed, the frequency of the inconsistency will be audibly layered on top of the desired sound. The synthesizer must output samples consistently at the exact appropriate time, not allowing the handling of other tasks to interfere. This means the next sample must be calculated and auxiliary tasks must be processed before the time to output an audio sample arrives, ensuring that the system is totally idle and waiting for the right time.</p>
<p>There are a number of problems with this standard approach. One, this is a heavily manual design process. Assuring the accuracy of the timing throughout the development process, as new features are added, can become a headache. Two, some processor time is guaranteed to be wasted. Not all tasks take the same amount of time to run; some less, some more. When short tasks are handled, the processor will be idle for potentially useful periods of time. If a task grows to the point that it can no longer be safely completed within the time between samples, i.e. the sample period, the timing of the audio generation may be compromised. Neither problem is desirable. As they say, there must be a better way. And there is. It called an RTOS.</p>
<h1>What is an RTOS?</h1>
<p>An RTOS is a Real-Time Operating System. It&#8217;s &#8220;Real-Time&#8221; because it&#8217;s primary concern is that events happen when they should, not in clock cycle, microprocessor-time terms, but in Real Time. Instead of manually managing the task timing, the RTOS handles running the tasks at a designated time and frequency. Tasks in an RTOS environment can be assigned priorities, ensuring that higher priority tasks have bulletproof timing. Any task of higher priority can preempt any lower priority task. Once the higher priority task runs, the system returns to the lower priority task.</p>
<p>For a synthesizer, this works great. Inputs can be checked and processed and the interface generated with relative freedom while still guaranteeing that the audio stream is extremely consistent and artifact free.</p>
<p>Let&#8217;s look at what makes up an RTOS a little closer. I&#8217;m familiar with <a title="FreeRTOS" href="http://www.freertos.org/" target="_blank">FreeRTOS</a>, which is what I&#8217;ve been using on my latest projects. As it&#8217;s name suggests, it&#8217;s free. There are many others. FreeRTOS just happened to be the one that worked well for me. So, my examples will be based on what I&#8217;ve developed using FreeRTOS. If you&#8217;d like to use my FreeRTOS files, you can download them at the bottom of the page.</p>
<h1>Tasks</h1>
<p>There&#8217;s quite a bit going on behind the scenes with an RTOS, but, you don&#8217;t have to pay too much attention to the man behind the curtain. You also don&#8217;t have to deeply modify code to convert it to run in an RTOS environment. You do have to write it in an RTOS specific way, and that is to divide it into tasks and register them with the RTOS. Software is traditionally divided into tasks anyway, so the transition is fairly easy. Let&#8217;s take an example.</p>
<p>Suppose we need to blink an LED at a constant rate. If this task were written in standard C, in an oversimplified fashion, the function might look something like this:</p>
<pre class="brush: cpp; title: ; notranslate">
void LEDBlinkTask(void)
{
  static uint8_t u8ledIO;

  /*Toggle the I/O pin*/
  u8ledIO ^= 0x01;
}
</pre>
<p>This function would be called in an endless loop with some timing associated. In the simplest situation, the microcontroller wouldn&#8217;t have anything else to do during the time in between toggling the LED and a timer would be used to stall the processor until the correct time arrives.</p>
<pre class="brush: cpp; title: ; notranslate">
while(1)
{
  wait(1);//wait one second
  LEDBlinkTask();
}
</pre>
<p>That&#8217;s pretty simple and it&#8217;s not much more complicated to configure a timer with an interrupt that sets a flag whenever necessary to avoid the problem of idling the processor. The timing would suffer a little if the processor was still busy with other tasks too long after a flag was set, but it could suffice, particularly in this situation.</p>
<pre class="brush: cpp; title: ; notranslate">
while(1)
{
  if(u8LEDBlinkFlag == TRUE)
  {
    LEDBlinkTask();
    u8LEDBlinkFlag = FALSE;
  }

  //do other stuff...
}
</pre>
<p>This method is fairly common, particularly in applications where the timing is not critical. And even if it were, the required code could be run inside an interrupt handler directly. The timing of that function would be pretty accurate, although the length of time to enter an interrupt does vary. An RTOS offers a simple solution to this problem. Let&#8217;s examine what an RTOS version of the LED blink code would look like.</p>
<pre class="brush: cpp; title: ; notranslate">
void vTaskBlinky(void *pvParameters)
{
   while(1)
   {
     LEDBlinkTask();
     vTaskDelay(1000);//time to delay in milliseconds
   }
}
</pre>
<p>It looks suspiciously similar to the while loop because it&#8217;s just as simple, yet it&#8217;s vastly superior. With this simple routine, the RTOS inserts this routine into the schedule with the specified delay and goes about it&#8217;s business running other things. Note how the code is contained inside an endless loop inside the task. In an RTOS environment, all the tasks contain infinite loops. Also, note that the delay is specified in millisecond increments. These increments are called ticks, or time slices, whose length is specified rather simply in a configuration file. A useful length of time in a synthesizer is the sample rate, which gets to the point of having accurate audio output timing. A tick rate of the length of the time between audio samples synchronizes the process, but we also have to be certain that the synthesis routine runs predictably at exactly that time. The mechanism for certainty is priority.</p>
<h1>Priority</h1>
<p>Each task in an RTOS system is given a priority. Any task with a higher priority preempts any task of a lower priority. The priority is assigned when the task is registered with the system. It can also be changed later and there are advanced mechanisms which allow a tasks priority to temporarily change. A little more about that later, but for now lets look at how a task&#8217;s priority is set, at least in FreeRTOS.</p>
<pre class="brush: cpp; title: ; notranslate">
xTaskCreate(
  vTaskBlinky,/*Function Name*/
  (const signed char *)&quot;LED Handler&quot;,/*Handle*/
  70,/*Stack Depth*/
  NULL,/*Task Parameter*/
  3,/*Priority*/
  NULL/*Task Handle*/
);
</pre>
<p>There are a few parameters being passed to the xTaskCreate function that I haven&#8217;t mentioned, and won&#8217;t dig into, as they access more advanced RTOS features, but there you can see the priority being set. In FreeRTOS, a lower number equates to higher priority. This task has a priority of 3 and this system has a maximum priority of 5, a variable set in the configuration file. So this task preempts tasks of priority 4 and 5 when it needs to run and can be preempted by tasks of 0,1, and 2 priority when they need to run. When this task or any other is preempted, the RTOS saves the task&#8217;s state, stops processing it, moves to the higher priority task, and later will return to this task at exactly the point it left off.<a href="http://hackmeopen.com/wp-content/uploads/2013/02/task-preemption.jpg"><img class="aligncenter size-full wp-image-1014" alt="task preemption" src="http://hackmeopen.com/wp-content/uploads/2013/02/task-preemption.jpg" width="345" height="146" /></a></p>
<p>One important fact to note is that priority zero is reserved for the idle task. The idle task is run whenever no other task needs to be run. Although we&#8217;re trying to avoid idle time with the RTOS, the idle task must run occasionally to clean up memory usage. You can, although it&#8217;s not wise, assign a task to priority 0 along with the idle task. It just can&#8217;t be a total processor hog, not allowing the Idle Task to get it&#8217;s job done.</p>
<h1>Complications</h1>
<p>If you&#8217;re a sharp embedded thinker, you may see that not everything is totally rosy in RTOSland. Despite the serious benefits of an RTOS, there are some complications. You could imagine a situation where a task of lower priority is preempted by a task of higher priority right in the middle of calculating some critical value. Then, not knowing any better, the higher priority task may try to access the result of the lower priority task&#8217;s operation before it&#8217;s actually calculated. This is a problem of data integrity which could compromise the entire system. Fear not though, the good RTOS people have foreseen this problem and have provided a solution.</p>
<h1>Mutexes</h1>
<p>A mutex, short for mutual exclusion, allows the lower priority task to block the higher task&#8217;s access to the critical data until it has finished its calculation. Typically, the mutex conveys a mechanism of priority inheritance, wherein the lower priority task inherits the higher priority tasks priority level until the mutex is released by the formerly lower priority task. Basically, a mutex can only be &#8220;held&#8221; by one task at a time. The lower priority task &#8220;takes&#8221; the mutex preventing anyone else from taking it. When the lower priority task is finished with the data, it &#8220;gives&#8221; the mutex, thereby allowing the mutex to be taken by another task.</p>
<p>The implementation of this type of data control can be one of the more difficult aspects of dealing with an RTOS for a novice. In one instance, I had a task which updated LEDs based on a menu system. The LEDs were connected to shift registers via a SPI bus. The LED task was low priority because I didn&#8217;t need to update the LEDs all that often and when I did, it wasn&#8217;t critical that it happened in nanoseconds. The SPI task is high priority because it&#8217;s transmitting in the MHz frequency range and I couldn&#8217;t allow for pauses or interruptions in the transmission. So, the LED task was writing variables indicating LED state which the SPI task would send to the shift registers. Unfortunately, the SPI task occasionally picked up a value which was an intermediate number in a calculation. This was visible on the LEDs with occasional short flickers. So, I created a mutex which prevented this corruption and all was well.</p>
<h1>More Features</h1>
<h2>Queues</h2>
<p>There a number of other critical features of RTOSes which make them worth using. We already discussed how events could be scheduled to run based on time, but they can also be scheduled based on the availability of some data or input. Microcontrollers can spend a lot of time just checking if some event has occurred or if some data has been received. With an RTOS, much like waiting for a time, the microcontroller can freeze a task until some input or data needs a response. The device for implementing this feature in an RTOS is called a queue. A queue is a bank of memory which can be filled and emptied by tasks. One task or interrupt can send information to another task. This allows for communication between tasks and allows the tasks to use data when it&#8217;s appropriate.</p>
<h2>Semaphores</h2>
<p>A semaphore is a feature which allows tasks to be synchronized. It is taken and given like a mutex, but does not involve protecting data. One task can inform another that it&#8217;s time to run and vice versa, a task can wait to run until another has. I have used this feature in a number of ways, but a good example is how I synchronize my sequencer. If I have eight tracks, I&#8217;ll have eight semaphores and one synchronization routine. The central routine notifies each track that its time to start back at the beginning. Here&#8217;s what the code for the synchronization routine looks like:</p>
<pre class="brush: cpp; title: ; notranslate">
for(;;)
{
  if(++u8sixteenthNoteCount == NUMBER_OF_SIXTEENTH_NOTES_PER_LOOP)
  {
    u8sixteenthNoteCount = 0;
    u8currentStep = 0;
    xSemaphoreGive(xSemaphoreTrack1Sync);
    xSemaphoreGive(xSemaphoreTrack2Sync);
    xSemaphoreGive(xSemaphoreTrack3Sync);
    xSemaphoreGive(xSemaphoreTrack4Sync);
    xSemaphoreGive(xSemaphoreTrack5Sync);
    xSemaphoreGive(xSemaphoreTrack6Sync);
    xSemaphoreGive(xSemaphoreTrack7Sync);
    xSemaphoreGive(xSemaphoreTrack8Sync);
  }

  vTaskDelay(TICKS_PER_SIXTEENTH_NOTE);
}
</pre>
<p>Pretty simple, n&#8217;est-ce pas? The synchronization routine is the highest priority and the tracking routines are below it, a necessary arrangement because they may need to interrupt one of the tracking routines to inform it that it&#8217;s time to begin again. Here&#8217;s a puzzle for you: Imagine what happens if a high priority task is waiting for a semaphore from a lower priority task. I&#8217;ll leave you to think about that one.</p>
<h1>Summing it up</h1>
<p>An RTOS is a truly great way to organize code, particularly in situations where timing is of the essence. There are many places to learn more and many RTOSes to use. As with anything in electronics, the best way to learn is to start doing. So get going!</p>
<p>Here is a package of files that I&#8217;ve successfully used with STM32 microcontrollers:</p>
<p><a href="http://hackmeopen.com/wp-content/uploads/2013/02/FreeRTOS1.rar">FreeRTOS</a></p>
]]></content:encoded>
			<wfw:commentRss>http://hackmeopen.com/2013/02/freertos-getting-to-know-you/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>K-DSC-1: Microcontroller Selection</title>
		<link>http://hackmeopen.com/2012/09/k-dsc-1-microcontroller-selection/</link>
		<comments>http://hackmeopen.com/2012/09/k-dsc-1-microcontroller-selection/#comments</comments>
		<pubDate>Thu, 27 Sep 2012 20:37:48 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Embedded Design]]></category>
		<category><![CDATA[K-DSC-1]]></category>
		<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Embedded Programming]]></category>
		<category><![CDATA[Open Source Electronics]]></category>

		<guid isPermaLink="false">http://hackmeopen.com/?p=954</guid>
		<description><![CDATA[A wise grizzled old engineer once told me that the most important rule of embedded engineering is, &#8220;Always use quality tools.&#8221; Without quality tools that you can 100% trust, you&#8217;ll never be certain of the source of a problem. You&#8217;ll constantly be asking yourself, &#8220;Is it me or is it the tools?&#8221; I&#8217;ve validated this [...]]]></description>
				<content:encoded><![CDATA[<div id="attachment_955" class="wp-caption aligncenter" style="width: 239px"><a href="http://hackmeopen.com/wp-content/uploads/2012/09/stm32.jpg"><img class="size-full wp-image-955" title="STM32 ARM Processor" src="http://hackmeopen.com/wp-content/uploads/2012/09/stm32.jpg" alt="" width="229" height="220" /></a><p class="wp-caption-text">STM32 ARM Processor</p></div>
<p style="font-style: normal; line-height: 24px;"><span style="color: #333333; font-style: normal; line-height: 24px;">A wise grizzled old engineer once told me that the most important rule of embedded engineering is, &#8220;Always use quality tools.&#8221; Without quality tools that you can 100% trust, you&#8217;ll never be certain of the source of a problem. You&#8217;ll constantly be asking yourself, &#8220;Is it me or is it the tools?&#8221; I&#8217;ve validated this engineer&#8217;s axiom multiple times, staring for glacial epochs staring at code which should work but doesn&#8217;t. I once spent a solid month tweaking and tweaking simple code only to find in the end that a manufacturer&#8217;s compiler was incapable of executing logical shifts correctly. I&#8217;ve vowed in the past never to suffer again and I reinforced my opinion during this microcontroller selection process. That&#8217;s a later part of this story. First, let&#8217;s look at how I started this selection process.</span></p>
<p style="font-style: normal; line-height: 24px;"><span id="more-954"></span></p>
<h1>The Contenders: Atmel vs. ST</h1>
<p>In choosing a microcontroller for the synth cube project, I basically looked at the two companies I know the best, Atmel and ST Microelectronics. I struggled with the decision at first, but now that I&#8217;m down the road, I&#8217;m not looking back. They&#8217;re both fine manufacturers and, for different projects or different people, I might recommend one over the other at different times. For this project and probably for here on out for me, only one micro could reign supreme.</p>
<h1>Atmel AVR: The Good and The Bad</h1>
<p>I&#8217;ve been intimate with Atmel for many years through the AVR line of micros. I used the 8-bit ATMEGA micros for my first synthesizers and I played with the 32-bit AVR32 micros for the Illmatic sequencer. You can read about my selection of the ATMEGA for Rockit <a title="8 Bit Synth: The Microcontroller: Part One: Selection" href="http://hackmeopen.com/2010/03/8-bit-synth-the-microcontroller-part-one-selection/">here</a>. I&#8217;ve built a solid relationship with AVR micros and they&#8217;re a great choice for many reasons.</p>
<h3>Atmel studio = Open Source Happiness</h3>
<p>Atmel is an appealing solution for the open source enthusiast. The GCC compiler integrates seamlessly with Atmel Studio with one click compilation and programming. Atmel Studio, since version 5, now 6, is hands down the best microcontroller development environment I&#8217;ve ever used. It&#8217;s available for the right price, <strong>free</strong>, and is based on Microsoft Visual Studio, which is rightfully awesome tool. My favorite feature is never having to remeber variable or function names. You just start typing and it offers suggestions. It sounds simple, but it speeds up the process so much that you&#8217;ll miss those little suggestions dearly when you have to live without them.<strong> </strong>Atmel also provides, like most manufacturers, a very nice standard library and sample projects that greatly accelerate the startup process. With Atmel Studio, you can go from nothing to running in hours without having to dwell on the intricacies of compilers, linker scripts, startup code or any other embedded matters that are generally toxic to quick development.</p>
<h3>Price</h3>
<p>AVR micros provide an excellent low cost entry point for the hobbyist and have proven popular particularly because of their use in Arduino boards. However, the case for AVR becomes decidedly less rosy as you move from hobbyist to certified maker. Where AVR isn&#8217;t competitive, at least in sub-100,000 unit volume, is cost. AVR micros are expensive relative to competitive chips from ST and Atmel offers no decent price break for volume in my production range. For instance, an AVR32 chip, the AT32UC3A1128 is $6.34 on Digikey with no break on price above 100 pieces. An STM32F103CB, a comparable micro, is $4.99 at 100 pieces and the price falls to $3.51 at 2,000 pieces with likely breaks for volumes above that. For a small manufacturer of a niche product, this presents a serious problem. Using Atmel micros will add several dollars to the price of my product or reduce my profit by that amount should the market not bear my higher price. For a small manufacturer, profit really means what buys food and shelter. This is pretty much a dealbreaker. No matter what other advantages there are, cost is king.</p>
<h2>STM32</h2>
<p>As I mentioned, ST is the price leader. Not just for 32-bit micros, but down the line to the 8-bit STM8 as well. I&#8217;ve used STM8 micros for years. They&#8217;re in the millions of battery chargers and power supplies that I&#8217;ve designed. Pricing on STM8 micros borders on ridiculous with pricing for totally useful chips in the low tens of pennies range. No other manufacturer comes anywhere close. Believe me, I&#8217;ve looked.</p>
<h3>Development</h3>
<p>For the STM8, ST does provide a development environment, ST Visual Develop, but it&#8217;s nowhere near the quality of Atmel Studio. And they don&#8217;t make a compiler, leaving you at the mercy of third party vendors. They&#8217;ll get you hooked with a free compiler for small code sizes, but start charging you for an unlimited version. For the STM32, they don&#8217;t offer any IDE at all and leave you to find your own way. This is by far the greatest problem with using an STM32 microcontroller. For a rookie, this challenge may very well be unsurmountable. The initial learning curve of embedded development is a steep one. Without some serious cash, you&#8217;ll be at the mercy of the internet to figure out how to get started. If you&#8217;re well-funded, you can buy a Keil IDE and compiler for many thousands of dollars. It will work beautifully, just like Atmel Studio, probably even better, but few of us have thousands of dollars to relish on our hobbies. So, what&#8217;s a broke electronics nerd to do?</p>
<h3>Eclipse</h3>
<p>Fortunately, some pioneering and enterprising individuals have developed a way for the poor embedded masses to access powerful chips on the cheap. Eclipse is an open source development environment that can be used for a huge variety of projects, from Java x86 GUIs to lowly microcontrollers. Being open source, developers can make plug-ins and drivers to make Eclipse speak the right language to compile, program, and debug STM32, and any other ARM-based microcontroller as well. The open source nature has a side effect though.  Not being developed by a single cash-loving entity, it&#8217;s a piecemeal approach. You&#8217;ll have to get the compiler from over here, find a linker script there, figure out the startup code, dabble with a library, and on and on. What was a small investment of a few hours to get Atmel Studio running can stretch to days or weeks with an open source approach to STM32. You&#8217;ll learn a lot in the process if you get to the end, but you may just give up before you get there. There are a number of tutorials on the web, but I found them to be lacking and sometimes conflicting. So, after a week of struggling with the fully open source approach, I started looking for alternatives.</p>
<h3>Low Cost IDE</h3>
<p>Some enterprising companies have noticed the gulf between basic open source Eclipse and Keil, and offer some intriguing alternatives, which work well and won&#8217;t end your marriage when the credit card bill arrives.</p>
<p>Mikroelectronika is a popular and cost-reasonable option. At $249 for the compiler, IDE, and some libraries, it can be money well spent. The libaries provide easy-to-use functions for handling most basic tasks. The problem for me is that these libraries are proprietary and not internally debuggable. And, MikroC is their internally developed compiler, which makes it unique and less likely to be interactive with open source libraries designed to work with GCC.</p>
<p>For these reasons, I chose to go with Code Bench from Mentor Graphics. Code Bench also comes with optimized run-time libraries which reduce code size, particulary for some of the more space hungry functions, like malloc(). I also wanted to learn more about using an RTOS, preferably an open source free one, and those are much more likely to be designed to work with GCC. Code Bench costs a little bit more, $399, but it just better met my needs, so I didn&#8217;t mind the extra cost.</p>
<h1>STM32 IT IS</h1>
<p>So far, developing with Code Bench and STM32 has been a lot of fun, especially since I ported over FreeRTOS. I&#8217;ll be back with a post about FreeRTOS and getting it running with STM32. If you&#8217;ve got the patience and the will, learning to develop with STM32 can be a worthwhile endeavor, particularly if you&#8217;re interested in developing a product that you intend to sell. The cost alone makes the effort worthwhile and just think how big your brains will be after all that learning! I&#8217;m doing neck exercises just to support all this new information.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://hackmeopen.com/2012/09/k-dsc-1-microcontroller-selection/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Synth Cube Update</title>
		<link>http://hackmeopen.com/2012/09/synth-cube-update/</link>
		<comments>http://hackmeopen.com/2012/09/synth-cube-update/#comments</comments>
		<pubDate>Thu, 27 Sep 2012 02:47:14 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[K-DSC-1]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://hackmeopen.com/?p=952</guid>
		<description><![CDATA[Work continues on the K-DSC-1 synth cube. I&#8217;ve settled on a microcontroller. This cube&#8217;s going to run an ARM processor, which is going to provide lots of processor overhead for a sweet well-featured sequencer. We&#8217;re planning some cool features. There will be a USB port, a standard MIDI jack, and the K-Connect jack for hooking [...]]]></description>
				<content:encoded><![CDATA[<p>Work continues on the K-DSC-1 synth cube. I&#8217;ve settled on a microcontroller. This cube&#8217;s going to run an ARM processor, which is going to provide lots of processor overhead for a sweet well-featured sequencer. We&#8217;re planning some cool features. There will be a USB port, a standard MIDI jack, and the K-Connect jack for hooking cubes together. What&#8217;s really going to make this awesome though will be the interface. We&#8217;ve put some good thought into the button operation, but the killer will be the accelerometer tilt action. I&#8217;m really excited about how it&#8217;s going to turn out.</p>
<p>I&#8217;ve been learning quite a bit about working with ARM processors and open source tools for developing with them. Stay tuned for some technical posts about what I&#8217;ve found.</p>
]]></content:encoded>
			<wfw:commentRss>http://hackmeopen.com/2012/09/synth-cube-update/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Kinektron K-DSC-1</title>
		<link>http://hackmeopen.com/2012/08/kinektron-k-dsc-1/</link>
		<comments>http://hackmeopen.com/2012/08/kinektron-k-dsc-1/#comments</comments>
		<pubDate>Mon, 06 Aug 2012 20:41:49 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[K-DSC-1]]></category>

		<guid isPermaLink="false">http://hackmeopen.com/?p=932</guid>
		<description><![CDATA[I&#8217;ve finally settled into my new project and I&#8217;m ready to announce it. I was toiling away on a sequencer of my own for a while, a product to which I plan to return, but I&#8217;m changing gears to work with other people for a change, building the K-DSC-1 Synth Cube. It&#8217;s going to be [...]]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve finally settled into my new project and I&#8217;m ready to announce it. I was toiling away on a sequencer of my own for a while, a product to which I plan to return, but I&#8217;m changing gears to work with other people for a change, building the <a href="http://www.kinektron.com/products/kinektron-synth-cubes/">K-DSC-1 Synth Cube</a>. It&#8217;s going to be super awesome and totally unique. I&#8217;m working on the electronics hardware and software while the other fellas work on the case design. This will have a proper enclosure made by real mechanical designers, something which I have found difficult to accomplish on my own. The fundamentals of the synth cube are:</p>
<ul>
<li>8&#215;8/16 step sequencer</li>
<li>Accelerometer interface (tilt and shake)</li>
<li>General MIDI synth engine</li>
<li>Really solid polyphony with drum parts and synth lines together</li>
<li>Delay effect</li>
<li>USB-MIDI and DIN MIDI</li>
<li>USB Bootloader</li>
<li>Computer programming interface</li>
</ul>
<p>That&#8217;s a bit of it. It&#8217;s ideally going to be the first in a series of interconnectable cubes. We&#8217;ve got plans for a whole bunch and they&#8217;ll all work together. It&#8217;s going to be great for noodling, writing, and really fun for performing. I&#8217;m working with some clever guys and I&#8217;m really hopeful that it&#8217;s gonna be fun to use and a really innovative design.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://hackmeopen.com/2012/08/kinektron-k-dsc-1/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Sprockit&#8217;s Case is Here!</title>
		<link>http://hackmeopen.com/2012/06/sprockits-case-is-here/</link>
		<comments>http://hackmeopen.com/2012/06/sprockits-case-is-here/#comments</comments>
		<pubDate>Sat, 02 Jun 2012 19:32:03 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Sprockit]]></category>
		<category><![CDATA[Case Design]]></category>
		<category><![CDATA[DIY Electronics]]></category>
		<category><![CDATA[DIY Synth]]></category>
		<category><![CDATA[HackMe Sprockit]]></category>

		<guid isPermaLink="false">http://hackmeopen.com/?p=913</guid>
		<description><![CDATA[Isn&#8217;t it awesome! I&#8217;m trying to have production cases ready for next weekend&#8217;s Experimental Garage Sale. I hope to see you there!]]></description>
				<content:encoded><![CDATA[<p><a href="http://hackmeopen.com/wp-content/uploads/2012/06/Sprockit.jpg"><img class="aligncenter size-full wp-image-914" title="Sprockit's Case" src="http://hackmeopen.com/wp-content/uploads/2012/06/Sprockit.jpg" alt="" width="1280" height="853" /></a></p>
<p>Isn&#8217;t it awesome! I&#8217;m trying to have production cases ready for next weekend&#8217;s Experimental Garage Sale. I hope to see you there!</p>
]]></content:encoded>
			<wfw:commentRss>http://hackmeopen.com/2012/06/sprockits-case-is-here/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Experimental Garage Sale 5 on June 9 2012 in Chicago</title>
		<link>http://hackmeopen.com/2012/05/experimental-garage-sale-5-on-june-9-2012-in-chicago/</link>
		<comments>http://hackmeopen.com/2012/05/experimental-garage-sale-5-on-june-9-2012-in-chicago/#comments</comments>
		<pubDate>Mon, 07 May 2012 16:09:07 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[General Electronics]]></category>
		<category><![CDATA[DIY Electronics]]></category>
		<category><![CDATA[DIY Synth]]></category>
		<category><![CDATA[Experimental Garage Fair]]></category>
		<category><![CDATA[HackMe Electronics]]></category>

		<guid isPermaLink="false">http://hackmeopen.com/?p=899</guid>
		<description><![CDATA[GetLoFi.com announced the 5th installment of the experimental garage sale. Read about it over there. Featuring lots of cool homemade gizmos, it should be lots of noise and fun. So mark your calendars. I&#8217;ll be set up there with my synths.]]></description>
				<content:encoded><![CDATA[<p>GetLoFi.com announced the 5th installment of the experimental garage sale. Read about it over <a title="getlofi" href="http://www.getlofi.com/?p=5255">there</a>. Featuring lots of cool homemade gizmos, it should be lots of noise and fun. So mark your calendars. I&#8217;ll be set up there with my synths.</p>
]]></content:encoded>
			<wfw:commentRss>http://hackmeopen.com/2012/05/experimental-garage-sale-5-on-june-9-2012-in-chicago/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rockit Firmware 1.12</title>
		<link>http://hackmeopen.com/2012/05/887/</link>
		<comments>http://hackmeopen.com/2012/05/887/#comments</comments>
		<pubDate>Wed, 02 May 2012 18:32:55 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Rockit]]></category>
		<category><![CDATA[DIY Electronics]]></category>
		<category><![CDATA[DIY Synth]]></category>
		<category><![CDATA[DIY Synth Code]]></category>
		<category><![CDATA[Embedded Programming]]></category>
		<category><![CDATA[Hackme Rockit]]></category>
		<category><![CDATA[Open Source Electronics]]></category>

		<guid isPermaLink="false">http://hackmeopen.com/?p=887</guid>
		<description><![CDATA[Rockit firmware 1.12 is available. The changes are mostly limited to MIDI. I&#8217;ve implemented a soft MIDI Thru. Messages not intended for Rockit, meaning on a different channel, are passed through to the MIDI Output. The MIDI channel can now be changed. To change the MIDI channel, hold down the Select button until the display [...]]]></description>
				<content:encoded><![CDATA[<p>Rockit firmware 1.12 is available. The changes are mostly limited to MIDI. I&#8217;ve implemented a soft MIDI Thru. Messages not intended for Rockit, meaning on a different channel, are passed through to the MIDI Output. The MIDI channel can now be changed. To change the MIDI channel, hold down the Select button until the display starts flashing. Then, use the Save and Recall buttons to change the MIDI channel. Finally, hold down the select button until the display stops flashing and that&#8217;s it. Otherwise, I fixed a bug that caused the audio to stop when the arpeggiator was running and drone mode was entered. That&#8217;s about it. Some other transparent changes were made for an improvement in the number of clock cycles required to perform various tasks. Have some fun and let me know if you find any funny business going on. Download the <a href="http://hackmeopen.com/?page_id=515" title="Rockit Source Code">hex file here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://hackmeopen.com/2012/05/887/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hackme at maker faire</title>
		<link>http://hackmeopen.com/2012/04/hackme-at-maker-faire/</link>
		<comments>http://hackmeopen.com/2012/04/hackme-at-maker-faire/#comments</comments>
		<pubDate>Sat, 21 Apr 2012 14:47:20 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Rockit]]></category>
		<category><![CDATA[Sprockit]]></category>
		<category><![CDATA[DIY Electronics]]></category>
		<category><![CDATA[Hackme Rockit]]></category>

		<guid isPermaLink="false">http://hackmeopen.com/?p=877</guid>
		<description><![CDATA[All set up at maker faire. Come on down and make some racket with Rockit and Sprockit!]]></description>
				<content:encoded><![CDATA[<p><a href="http://hackmeopen.com/wp-content/uploads/2012/04/20120421-094532.jpg"><img class="alignnone size-full" src="http://hackmeopen.com/wp-content/uploads/2012/04/20120421-094532.jpg" alt="20120421-094532.jpg" /></a></p>
<p>All set up at maker faire. Come on down and make some racket with Rockit and Sprockit!</p>
]]></content:encoded>
			<wfw:commentRss>http://hackmeopen.com/2012/04/hackme-at-maker-faire/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HackMe at Chicago Mini-Maker Faire</title>
		<link>http://hackmeopen.com/2012/04/hackme-at-chicago-mini-maker-faire/</link>
		<comments>http://hackmeopen.com/2012/04/hackme-at-chicago-mini-maker-faire/#comments</comments>
		<pubDate>Mon, 16 Apr 2012 17:45:16 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[chicago maker faire]]></category>

		<guid isPermaLink="false">http://hackmeopen.com/?p=869</guid>
		<description><![CDATA[I&#8217;ll be setting up a booth at the Chicago Mini-Maker Faire this Saturday, April 21st at the Carl Shurz High School. Stop by, chat, and play with my creations. Rockit and Sprockit will be available built and in kit form at special Maker Faire discounted prices. Check out the poster for the event. I&#8217;m looking [...]]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ll be setting up a booth at the Chicago Mini-Maker Faire this Saturday, April 21st at the Carl Shurz High School. Stop by, chat, and play with my creations. Rockit and Sprockit will be available built and in kit form at special Maker Faire discounted prices. Check out the poster for the event. I&#8217;m looking forward to meeting fellow nerds and makers.</p>
<p><a href="http://hackmeopen.com/wp-content/uploads/2012/04/makerfaireposter2.pdf">makerfaireposter</a></p>
]]></content:encoded>
			<wfw:commentRss>http://hackmeopen.com/2012/04/hackme-at-chicago-mini-maker-faire/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
