When implementing USB on a microcontroller, most people are going to reach for V-USB if they’re using an AVR, one of Microchip’s USB libraries if a PIC is involved, or any number of the USB libraries for various ARM processors. [Kevin] had a different idea. As a challenge to himself, he wrote a USB device driver for the Teensy 3.1 microcontroller board, getting as close to the bare metal as he could get.
Writing a USB device driver first required a literature review. There are a few peculiarities in the Freescale K20 family of microcontrollers – the one found in the Teensy 3.1 – that dictate the need for a specific memory layout, using several clocks, and handling all the USB descriptors. [Kevin] started with the clocks, every last one of which must be enabled. The clock is generated by the Multipurpose Clock Generator from a 16MHz crystal, PLL’ed to the frequencies the USB module needs, and sent out over the System Integration Module.
Following the flowcharts and sequences found in the Freescale reference guide told [Kevin] exactly what needed to be done with the startup sequence, and offered a few suggestions on what needed to be done to set up all the interrupts. [Kevin] spent an incredible amount of time documenting, programming, and smashing his head against the keyboard for this tutorial, but he does give everyone a great opportunity to learn from his struggles.
While [Kevin] has a mostly complete USB device driver, his work is far from done. That’s alright, because this project wasn’t meant to be a full-featured driver; it’s still missing real error handling, strings in the configuration, and a real VID/PID. That’s alright, it’s still a great exercise in building something from scratch, especially something that very few people have built successfully.
Oh, blatant Hackaday Store plug for the Teensy 3.1.
It all started with a conversation about the early days of computing. The next thing he knew, [Tim Jagenberg’s] colleague gave him a stack of punch cards and a challenge. [Tim] attempted to read them with a mechanical contact and failed. Undeterred, he decided to make a punch card-to-keyboard interface using optical parts from disassembled HP print stations. Specifically, he took apart the slotted optical interrupter switches to use their IR-LEDs and photo-transistors. Next, [Tim] drilled holes into two pieces of plastic, gluing the LEDs on one piece of plastic and the photo-transistors on the other. The photo-transistors tell the Teensy 3.1 whenever a hole is detected.
[Tim] developed an interpreter on the Teensy that reads the punch card according to IBM model 029 keypunch codes. The Teensy enumerates as a USB keyboard when connected to a computer. As a punch card is read, the Teensy outputs the decoded characters as key presses. When a punch card has been completely read, an ‘Enter’ key press is transmitted. Tweeting the punch cards is no more complicated than typing the text yourself. Naturally, the first message posted on Twitter from the stack of punch cards was “Hello World!” [Tim’s] binary and source code is available for download on Github.
We’ve enjoyed covering the backstory of the punch card and a previous project reading these cards using a digital camera setup. It’s always interesting to see the clever ways people use current technology and can-do attitude to read data from obsolete systems that would otherwise be lost. We wonder what is on the rest of those punch cards? Let’s hope [Tim] has more punch card tweets soon!
[jimmayhugh] is a homebrewer and has multiple fermentation chambers and storage coolers scattered around his home. Lucky him. Nevertheless, multiple ways of making and storing beer requires some way to tell the temperature of his coolers and fermenters. There aren’t many temperature controllers that will monitor more than two digital thermometers or thermocouples, so he came up with his own. It’s called TeensyNet, and it’s able to monitor and control up to 36 1-wire devices and ties everything into his home network.
Everything in this system uses the 1-Wire protocol, a bus designed by Dallas Semiconductor that can connect devices with only two wires; data and ground. (To be a fly on the wall during that marketing meeting…) [jimmay] is using temperature sensors, digital switches, thermocouples, and even a graphic LCD with his 1-wire system, with everything controlled by a Teensy 3.1 and Ethernet module to push everything up to his network.
With everything connected to the network, [jimmay] can get on his personal TeensyNet webpage and check out the status of all the devices connected to any of his network controllers. This is something the engineers at Dallas probably never dreamed of, and it’s an interesting look at what the future of Home Automation will be, if not for a network connected relay.
New today in the Hackaday Store is the Teensy 3.1. This development board blows away most others in its class. The board plays nicely with the Arduino IDE, but embedded developers who are hardcore enough have the option of bare metal programming for the Coretex-M4 chip.
Why would we say this blows most others away? In our minds, the 64k of RAM and 72 MHz clock speed place this far outside of what you would normally see hanging out in the Arduino ecosystem. That may be changing with new players like the Edison, but the Teensy 3.1 doesn’t require a host board and comes in just under $20 compared to the Edison’s $50 price tag.
[Paul Stoffregen], the developer of the Teensy, is a hacker’s hacker and is known to be found round these parts. All year [Paul] has been developing an Audio Library that takes advantage of the Teensy 3.1’s powerful processor (including its DMA features; we’ve been pestering him to write an article for us on that topic). We covered the library back in September and are stocking the audio add-on board in the store as well. Quite frankly, the quality of sound that this puts out is astonishing. If you’re working on a project that calls for playback of recorded sound this is one of the least-complicated ways to get there.
[Paul Stoffregen], known as father of the Teensy, has leveraged the Teensy 3.1’s hardware to obtain some serious speed gains with SPI driven TFT LCDs. Low cost serial TFT LCDs have become commonplace these days. Many of us have used Adafruit’s TFT LCD library to drive these displays on an Arduino. The Adafruit library gives us a simple API to work with these LCDs, and saves us from having to learn the intricacies of various driver chips.
[Paul] has turbocharged the library by using hardware available on Teensy 3.1’s 32 Freescale Kinetis K20 microcontroller. The first bump is raw speed. The Arduino’s ATmega328 can drive the SPI bus at 8MHz, while the Teensy’s Kinetis can ramp things up to 24MHz.
Speed isn’t everything though. [Paul] also used the Freescale’s 4 level FIFO to buffer transfers. By using a “Write first, then block until the FIFO isn’t full” algorithm, [Paul] ensured that new data always gets to the LCD as fast as possible.
Another huge bump was SPI chip select. The Kinetis can drive up to 5 SPI chip select pins from hardware. The ATmega328 doesn’t support chip selects. so they must be implemented with GPIO pins, which takes even more time.
The final result is rather impressive. Click past the break to see the ATmega based Arduno race against the Kinetis K20 powered Teensy 3.1.
Paul’s library is open source and available on Github.
Continue reading “TFT LCDs Hit Warp Speed with Teensy 3.1″
Don’t like sunglasses? Deal with it. They’re the pixeley, retro sunglasses from your favorite animated .GIFs, made real in laser cut acrylic. Points of interest include heat-bent frames made out of a single piece of acrylic.
Remember this really small FPGA board? The kickstarter is ending really soon and they’re upgrading it (for an additional $30) with a much better FPGA.
Sparkfun is now hosting the Internet of Things. They’re giving people a tiny bit of space to push data to, and you can also deploy your own server. That’s interesting, and you can expect us doing a full post on this soon.
Need waveforms? [Datanoise] is building a wavetable synthesizer, and he’s put all his waveforms online. Now if we could just get a look at the synth…
If you only have $20 to spend on a board, you’ll want to pick up at Teensy 3.1. [Karl] wrote some bare metal libraries for this awesome board, and while it’s not as extensive as the standard Arduino libs, it’s more than enough to get most projects off the ground. Included are UARTs, string manipulation tools, support for the periodic interval timers on the chip, and FAT and SD card support.
Things don’t always run the way we want them to or operate at the ideal temperature out of the box. Instead of spending extra for power controls that may or may not meet your needs, wouldn’t it make more sense to dial in the ideal level from the source? That’s what [dekuNukem] had in mind when he decided to make Powerduino, an arduino-compatible programmable power strip.
With Powerduino, [dekuNukem] can control the electrical consumption of all kinds of things without ever worrying about the irreversible deadliness of mains voltage. It actually uses a Teensy 3.1 which can be programmed with the Arduino IDE through the micro USB connector. He’s really tricked it out to the point of putting Kill A Watt meters to shame. A wi-fi module lets him control any of the outlets from anywhere, and the RTC module lets him make customized schedules for them. Powerduino has an SD card slot for logging energy consumption, and a 20 x 4 LCD screen makes it easy to directly interface with the power strip.
The Powerduino code is up on GitHub, and [dekuNukem]’s walkthrough video is after the jump.
Continue reading “Go On a Power Trip with Powerduino”