[Joonas] became frustrated with cheap but crappy MIDI to USB converters, and the better commercial ones were beyond his budget. He used a Teensy LC to build one for himself and it did the job quite well. But he needed several converters, and using the Teensy LC was going to cost him a lot more than he was willing to spend. With some tinkering, he was able to build one using an Adafruit Pro Trinket which has onboard hardware UART (but no USB). This lack of USB support was a deal killer for him, so after hunting some more he settled on a clone of the Sparkfun Pro Micro. Based on the ATmega32U4, these clones were just right for his application, and the cheapest to boot. He reckons it cost him about $5 to build each of his cheap USB MIDI adapters which receive notes and pedal data from the keyboard’s MIDI OUT and transmit them to a computer
Besides the Pro Micro clone, the only other parts he used are a generic opto-coupler, a couple of resistors and a MIDI connector. After testing his simple circuit on a bread board, he managed to squeeze it all inside an old USB dongle housing, stuffing it in dead-bug style.
The heavy lifting is all done in the firmware, for which [Joonas] used LUFA — the Lightweight USB Framework for AVR’s. He wrote his own code to handle MIDI (UART) to USB MIDI messages conversion. The interesting part is his use of a 32.15 kbps baud rate even though the MIDI specification requires 31.25 kbps. He found that a slightly higher baud rate fixes a problem in the AVR USART implementation which tends to miss consecutive bytes due to the START edge not being detected. Besides this, his code is limited in functionality to only handle a few messages, mainly for playing a piano, and does not have full-fledged MIDI capabilities.
We’ve featured several of [Joonas]’s hacks here over the years, the most recent being the Beaglebone Pin-Toggling Torture Test and from earlier, How to Turn A PC On With a Knock And An ATTiny.
Learning how magnets and magnetic fields work is one thing, but actually being able to measure and see a magnetic field is another thing entirely! [Stanley’s] latest project uses a magnetometer attached to a robotic arm with 3 degrees of freedom to measure magnetic fields.
Using servos and aluminium mounting hardware purchased from eBay, [Stanley] build a simple robot arm. He then hooked an HMC5883L magnetometer to the robotic arm. [Stanley] used an Atmega32u4 and the LUFA USB library to interface with this sensor since it has a high data rate. For those of you unfamiliar with LUFA, it is a Lightweight USB Framework for AVRs (formerly known as MyUSB). The results were plotted in MATLAB (Octave is free MATLAB alternative), a very powerful mathematical based scripting language. The plots almost perfectly match the field patterns learned in introductory classes on magnetism. Be sure to watching the robot arm take the measurements in the video after the break, it is very cool!
[Stanley] has graciously provided both the AVR code and the MATLAB script for his project at the end of his write-up. It would be very cool to see what other sensors could be used in this fashion! What other natural phenomena would be interesting to map in three dimensions?
Continue reading “Measuring Magnetic Fields with a Robotic Arm”
A month ago [Andreas] started playing Starcraft 2 again. As he was not comfortable with the default hotkeys on a normal keyboard, [Andreas] decided to build his own.
He started by salvaging keys from an old keyboard he had lying around, then 3D printed the case you see in the picture above to fit them. The keyboard electrical design is a simple matrix and it appears that he etched the PCB himself. To provide the required USB connectivity, the Atmega8U2 was chosen. It comes with a pre-programmed USB bootloader that [Andreas] chose to activate when the left key is pressed at the system startup. The HID class was implemented using the LUFA-USB Framework and the final product is definitely good looking.
All the files required to duplicate his design can be found here. You can also checkout another starcraft keyboard and an ergonomic keyboard that we previously featured.
This is a fascinating concept. We’re not sure of its usefulness, but it definitely stands on its own just for the concept. [Dean Camera] just added a new HID class to the LUFA project that lets you flash AVR chips by printing to them. This means once you have a file like the one seen open in Notepad above, you can just click on File, then on Print, and the firmware will be uploaded to the chip.
[Dean] is the creator of the LUFA project and still likes to get his hands dirty hacking around with it. This idea came to him while he was exploring the concept of using the MIDI protocol to program a chip. That didn’t pan out because of the way Microsoft has handled MIDI in newer versions of Windows. But he did get the idea of making LUFA identify itself as a simple USB printer. He dug into the specification and figured out how to do that. Once Windows connects to the device it doesn’t really care what data gets sent to it. So [Dean] wrote a parser for the bootloader which could accept the incoming hex code and write it to the chip’s program memory.
Looks like the Lightweight USB Framework for AVRs (LUFA) has just been ported for ARM microcontrollers. NXP recently released a package for their LPC Cortex M3 family of ARM controllers. You won’t find a reference to LUFA on their nxpUSBlib description page (which we think is kind of sad), but if you grab a copy of the beta code the Version.h header file shows that it is indeed a port of the project. This is further backed up by the LUFA creator, [Dean Camera], who consulted with the NXP team doing the work.
The package provides an open-source USB stack that you can use in your projects as a USB host or USB device. We’re advocates of open source packages like this one as it makes it much easier for hobbyists to get help using the tools, and it allows the community to give back through bug fixes and feature additions.
We’ve highlighted a few LUFA projects, like this keyboard remapper and this AVR programmer. We’re looking to seeing the first set of NXP LUFA projects roll through!
[Nav] wanted to change his keyboard mapping for one particular keyboard, rather than on each operating system. He used an AT90USBKey as a replacement PCB by soldering to all of the contacts on the key matrix. This allows him to remap the keys by following onscreen prompts.
The board enumerates as an HID device, and has a special mode which is accesses by plugging the keyboard in while holding down any key. If a text editor window is active you’ll see prompts from the microcontroller to press a series of keys. This is a routine used to learn how the key matrix is organized, and it’s your opportunity to change how each key is mapped. Since the mapping is saved to EEPROM, you can use any computer to map the keys, then plug the device into a systems that don’t offer software remapping. It could also be useful as a gaming keyboard, assuming there aren’t latency issues
As with the AVR-based arcade controller, this project uses the LUFA package to handle the USB stack.
[Jamie] built his own USB connected arcade controller. We’ve been seeing a lot of these lately, and they usually involve soldering buttons to a keyboard PCB. But [Jamie] decided to go a different route and use his own microcontroller. This method always gets a bit hairy when it comes to deciding how to connect it to a computer. Dealing with the USB stack used to be quite tricky, but the LUFA project is slowly taking the pain out of the process.
The Lightweight USB Framework for AVRs is an open source project that handles the hard work associated with USB capable AVR microcontrollers. [Jamie] knew that they already had a sample implementation of a hardware joystick. He’s not using one of the supported boards and so wasn’t able to just compile and go. But porting the code to work with his minimus board was simple enough. With the code in place, the physical build was quite simple. The buttons and joystick were mounted on the surface of an overturned drawer. Each is connected to one pin of the controller board and to ground. LUFA makes sure that the device enumerates as a joystick, and [Jamie] was gaming in no time.