Blog

.NET Micro Framework Midi Player

.NET Micro Framework Midi Player

A few days ago, I was working on a project where I needed to control a stepper motor using the .NET Micro Framework on the GHI Embedded Master microprocessor. Stepper motors are a unique type of motor - the velocity is controlled by a pulse wave input. The faster the pulse frequency, the faster the motor rotates.

It turns out that most stepper motors will tend to vibrate enough that they can produce quite an audible tone at the frequency at which you are providing pulses. For instance, if you provided a pulse frequency of 440 Hz, the stepper motor would hum the pitch of concert A.

It occurred to me very quickly that I could easily program my device to use the stepper motor as a "speaker" and play a song! Programming each note one by one seemed too tedious, so I programmed a simple MIDI parser.

My project reads a MIDI file in from a USB flash drive, parses the file to gather note events, then plays the song using the PWM output on the microprocessor.

Below is a video of the player in action. Of course, the classic Mario theme was my song of choice!

Comments and suggestions are definitely welcome! I've attached my project files, so feel free to build on them.

Download Project Files

Comments

Tanaka
SHEDS FOR THEM TO DOWNLOAD ERROR READ THIS!Without downloading anthying OTHER METHOD:They're vacant to start on Search place .After a few minutes, some files appear , which will eliminate.-After that you can install the without problems.
Ed Brey
That's great to hear (a lot better than the embedded devices we work with currently). Thanks for the info.
Dan Freve
# Dan Freve
The device I'm currently working with (GHI Embedded Master) has three available debugging interfaces: Serial, USB, and TCP/IP. I typically stick with USB; it usually takes around 10 seconds to compile->deploy->run. Serial is a little slower. I haven't played around with the TCP/IP interface. It may be slightly faster (although I've seen some comments on GHI's forums that suggest that it is less stable than the USB when stepping through code).
Ed Brey
In my experience, too often when you think you're 99% done with an embedded project, you're really only 80% done because you find these weird crashing and performance problems that occur for use cases you wish you'd tested for earlier. I've been following the .NET Micro Framework with in interest for a while now, hoping the royalty price would come down and platform availability would expand, since like it would all but eliminate the crashing problems associated with C/C++.

Sounds like the performance problems you're still on your own for, although it's not so bad if you have good I/O and a quick code/test cycle. Dan, on the platform you work with, about how long does it take from the time you make a code change until that change is compiled, downloaded to the target, and ready to run?
Dan Freve
# Dan Freve
Programming and debugging are very simple. The language is C# (so you get all the advantages of a managed environment), and you can step through your code line by line in Visual Studio, as if your were developing a windows app.

You can see how many threads are running in Visual Studio while you are debugging, but profiling is a little manual at this point...you'd probably have to write some custom code to do it.
Ed Brey
Very nice. I like the reference to concert A440. I was just at the latest Manitowoc Symphonic Orchestra concert, and this could have fit right in - well, kinda. :-)

How is the .NET Micro Framework to program and debug? Is it good at profiling what threads are running when, how memory consumption, etc.?
Joe
# Joe
Creative ! :) I like it.

Post a comment

Name (required)

Email (required)

CAPTCHA image
Enter the code shown above:

Related Blog Posts