I am in the process of building a MIDI USB device, using a PIC18F4550. I have trimmed the Microchip USB framework MIDI example, and is using this code as my base. It is a blessing to not have to code the entire USB stack with descriptors, from scratch, but it is a pain using someone elses code, and learning to use this framework as a sort of black box.

The goal is a combined MIDI to USB converter and knob box.

MIDI

MIDI is an interface for sending musical notations and messages through a wire. I will only brush up on the protocol of MIDI in this text.

A MIDI message consists of a status byte and up to 2 data bytes, the protocol is serial, and runs at 31250 baud. A table with all messages can be found here. On thing that was not obvious to me was that only the bytes needed are send, no zeroes. As an example an "active sense" message only sends the status byte. This may seem obvious, but starting from the USB side of this stuff made it seem otherwise.

Another thing that I wasted a fair amount of time discovering, is "running status". When you sent the same voice or mode command multiply times you can omit the status byte from all but the first message.  An example, you want to sent "note on" on channel 1, key number 60, and a velocity of 128, when a key is pressed. Then "note on" on channel 1, key number 60, and a velocity of 0, when a key is depressed. For the second package you only send the data, e.g. key number 60, velocity 0, the receiver assumes the status and channel are the same as the first message.

USB MIDI

MIDI packages on the USB cable are 4-byte fixed length packages, unused bytes are zeroed. The first byte is the cable number (16 virtual cables) and the Code Index Number, which acts sort of the same as the first 4 bits of a MIDI status. The following 3 bytes are an ordinary midi message. The standard is here.

MIDI to USB MIDI

For a long time, a note on page 17 of the USB MIDI standard eluded me. I thought that since the  Code Index Number almost mirrors the ordinary status of a MIDI message, I would have to parse and classify every message coming from the MIDI port. It turns out that you can send each byte received along without out classifying it, and set the Code Index Number to 0xF. Using this Code Index Number every byte received on the MIDI port is simply packaged in a 4 byte package, first 4 bits, the cable number, then 0xF, then the byte from the MIDI port, and in the end padded with 2 zero bytes.

I have some PIC18F4550s lying around, and I want to play with the USB features of this chip, therefore I made this breakout board. It contains enough components to get the PICMicro running, and nothing more, all the pins are routed to pin-headers to use with an experimenter board.

Features:

  • ICSP connector (In-Circuit Serial Programming, AKA PicKit 2 & 3)
  • USB-B Connector
  • 20Mhz clock crystal



Eagle files:  PIC18F4550 USB ICSP breakout board

Energia IDE

I never really caught on to the Arduino craze, not because of any dislikes as such, but because I was familiar with Microchips PICMICRO range. I had the parts, the programmer, and the knowledge to program them in both asm and C, so I guess I have had no need for the Arduino platform.

It turns out that the Arduino IDE has been ported to both the Stellaris Launchpad, and the MSP430 Launchpad from Texas Instruments. and is called Energia. This is nice, since it is then quite easy to port the vast amount of sketches and libraries from the Arduino IDE to Energia IDE and the Texas Instruments Launchpads.

Getting it going on Gentoo Linux

First to run Energia, 32-bit java support is needed, so

app-emulation/emul-linux-x86-java

needs to be emerged. When running Energia you must make sure

emul-linux-x86-java-1.6

is selected as user VM with eselect. Create a file called /etc/udev/rules.d/62-stellarpad.rules with these contents:

ATTRS{idVendor}=="1cbe", ATTRS{idProduct}=="00fd", MODE="0660", GROUP="plugdev"

Reload udev and add yourself to the "plugdev" group, plug-in in the Launchpad and you should be good to go!

While designing a fan control into another microcontroller project, I stumpled upon this nice design using only an external diode and capacitor. I used a 1N4148 standard diode and a 560pf capacitor.

http://www.edn.com/design/analog/4326575/Simple-microcontroller-temperature-measurement-uses-only-a-diode-and-a-capacitor

I will walk through copying a bootable Windows 7 installation from a VirtualBox VM to real iron.

  • Insert an external hard drive in the USB port and share it with your Windows 7 VM.
  • Ask windows to make a system image "Control Panel -> Back up your computer -> Create system image", and save it to the external hard drive.
  • Boot the Windows 7 install disk, click through, and select "Repair windows installation". The drives that you do not put on the exclude list, will be repartitioned and formatted, so make sure to exclude everything you want to keep.
  • Let it chew on your backup, and when done, boot Windows.

Felt like doing a demo effect, I have done this once before in C and asm. The year was something like 1996, and the processor a Cyrix/IBM 6x86 120+. This is slooow, not only because it is written in Python, but because it isn't optimised.

Source: fdtunnel.tar.bz2

On Gentoo I needed to point the configure script at libbfd.so. On my system it is in /usr/lib/binutils/x86\_64-pc-linux-gnu/2.22/ hence:

./configure --prefix=/usr/local/ --with-bfd=/usr/lib/binutils/x86\_64-pc-linux-gnu/2.22/

Generated on 2018-03-06 19:14:41.120202