Java Grinder Spits Out DsPIC And MSP430 Assembly Code

java-code-grinder

[Michael Kohn] sent in a link to the set of projects he’s been working on lately. The Java Grinder is a project that converts Java code for use on microcontrollers. This actually started back in 2009, when he mentioned that the project was worthless because there were already a ton of Java virtual machines out there. But if he had really thought that he’d never learn anything. We’re glad [Michael] picked this back up and made something out of it.

The image above shows the proof of concept. It’s a box bouncing around the Nokia 6100 screen. He wrote the animation in Java, and used his grinder to turn the code into dsPIC assembly, which was then compiled and flashed onto the microcontroller. That’s not all, he’s also coded a Mandelbrot set generator or the same hardware. As it stands he can also produce assembly code for use on MSP430 chips.

This kind of exploration is great for the brain. We see it as a natural extension of the learning you acquire from Nand2Tetris which walks through the essential text The Elements of Computing Systems. If you’re not familiar, that’s a trip from building your first logic gate, which you plunk together with others to build an ALU, then start coding all the way up to a virtual machine to run on your simulated hardware.

Video of the bouncing box and Mandelbrot set is below.

Continue reading “Java Grinder Spits Out DsPIC And MSP430 Assembly Code”

Happy Birthday, Son. Here’s Your Very Own Claw Machine

mrclawIf [Will Baden] is in the running for Father of the Year, he’s a shoe-in. His son requested a robot-themed birthday party, so [Will] did what any superhero father would do and built him a toy claw machine.

[Will] harvested many of the parts from copy machines: both the 5V and 24V power supplies, the limit switches, 2/3 of the motors, and the 24V solenoid coil in the claw. The carriage is from a commercial printer. He made many of the mounts, including the ones holding the 3 stepper motors from Pololu.

A PIC16F870 is running the show. [Will] programmed it in assembly using Timer2 for stepper pulsing and RB0 interrupt to drop the claw when the button is pushed. He also added a WDT to get out of code trouble if needed. The claw’s solenoid is driven by a ULN2001A Darlington array. [Will] put a kickback diode on the coil so the pulses don’t go farther than they need to. He formed the fingers of the claw by bending pieces of brake line.

Not your kind of claw? Check out these incredible Wolverine claws!

Continue reading “Happy Birthday, Son. Here’s Your Very Own Claw Machine”

Making An ARM Powered MIDI Synthesizer

What you see in the picture above is a hand-made 4-oscillator synthesizer with MIDI input, multi-mode filter and a handful of modulation options. It was built by [Matt], an AVR accustomed electronics enthusiast who made an exception to his habits for this project. The core of the platform is a DIP packaged 32-bit Cortex-M0 ARM processor (LPC1114), stuffed with ‘hand’ written assembly code and compiled C functions. With a 50MHz clock speed, the microcontroller can output samples at 250kHz on the 12bit DAC while being powered by 3 AA batteries.

Reading [Matt]’s write-up, we discover that the firmware he created uses 4 oscillators (sawtooth or pulse shape) together with a low frequency oscillator (triangle, ramp, square, random shapes). It also includes a 2-pole state-variable filter and the ability to adjust the attack-release envelopes (among others). The system takes MIDI commands from a connected device. We embedded videos of his creation in action after the break.

Continue reading “Making An ARM Powered MIDI Synthesizer”

Trimming The Fat From AVR GCC

avr

[Ralph] has been working on an extraordinarily tiny bootloader for the ATtiny85, and although coding in assembly does have some merits in this regard, writing in C and using AVR Libc is so much more convenient. Through his trials of slimming down pieces of code to the bare minimum, he’s found a few ways to easily trim a few bytes off code compiled with AVR-GCC.

To test his ideas out, [Ralph] first coded up a short program that reads the ATtiny85’s internal temperature sensor. Dissassembling the code, he found the a jump to a function called __ctors_end: before the jump to main. According to the ATtiny85 datasheet, this call sets the IO registers to their initial values. These initial values are 0, so that’s 16 bytes that can be saved. This function also sets the stack pointer to its initial value, so another 16 bytes can be optimized out.

If you’re not using interrupts on an ATtiny, you can get rid of 30 bytes of code by getting rid of the interrupt vector table. In the end, [Ralph] was able to take a 274 byte program and trim it down to 190 bytes. Compared to the 8k of Flash on the ‘tiny85, it’s a small amount saved, but if you’re banging your head against the limitations of this micro’s storage, this might be a good place to start.

Now if you want to hear some stories about optimizing code you’ve got to check out the Once Upon Atari documentary. They spent months hand optimizing code to make it fit on the cartridges.

Hackaday Links: Sunday, June 23rd, 2013

hackaday-links-chain

Need to connect a male pinheader to male jumper wires? [Scoops] came up with a brilliant method using jumpers meant for dual-pin headers like on motherboards.

Atanua, a real-time logic simulator, was just upgraded for the first time in a few years. We’ve liked this one since way back. The changes mostly involve performance improvements.

You can see what’s inside of Google Glass without shelling out $1500 for your own hardware. [Thanks Itay]

Coding a Minecraft clone in x86 assembly is pretty impressive. We had to install nasm and qemu to get it to compile but it does work. If you don’t want to build the project just check out the demo video. There’s no sign of creepers but dig too deep and you’ll fall out of the world. [Thanks Dmitry]

Here’s a way to use multiple Google Drive accounts as a RAID array.

[Sick Sad] produced some really trippy photographs using long exposures with a laser line on a servo. The result is a photorealistic image of the subject (faces in this example) that looks like it was melted à la [Salvador Dalí]. If you’re just interested in using the laser for light painting check out Hackaday alum [Jeremy Cook’s] work in that area.

And finally, two monitors are better than one. [Bryan] put his both together in portrait orientation using a laser-cut mounting bracket of his own design.

The Meaning Of Being A Hard-core Hacker From A 1985 Recollection

6502-hand-assembling-and-programming

Gather ’round children, we’re about to hear a story about the good old days. Except that this is really more of a horror story of what it used to be like as a code monkey. [John Graham-Cumming] shares his experience programming a 6502-based KIM-1 machine back in 1985. Simple, right? The caveat being that there was no assembler or hardware for loading the finished code!

The machine in question was a label application tool for a production line. You know, product goes in bottle, label gets slapped on the side. But the slapping needed to be perfect because consumers shy away from packaging that looks shoddy. Computer control would end up being far superior than the mechanical means the factory had been using because it simplifies the ability to adjust calibration and other parameters. [John] started from square one by interfacing the KIM-1 with the existing hardware. It has a hex keyboard which is how the program was entered into the device. But first he wrote the software on sheets of notebook paper like the one seen above. It includes his hand assembled code, which was then typed in on the keypad. Kind of makes you appreciate all the tools you take for granted (like Eclipse), huh?

[via Reddit]

 

AVR VGA Generator

avr-vga-generator

This simple circuitry makes up the hardware for [Andrew’s] AVR-based VGA generator. He managed to get an ATmega1284 to output a stable VGA signal. Anyone who’s looked into the VGA standard will know that this is quite an accomplishment. That’s because VGA is all about timing, and that presented him with a problem almost immediately.

The chip is meant to run at a top speed of 20 MHz. [Andrew] did manage to get code written that implemented the horizontal and vertical sync at this speed. But there weren’t enough clock cycles left to deal with frame buffering. His solution was to overclock the chip to 25 MHz. We assume he chose that because he had a crystal on hand, because we think it would have been easier to use a 25.174 MHz crystal which is one of the speeds listed in the specification.

Red, green, and blue each get their own two-bit range selected via a set of resistors for a total of 64 colors. As you can see in the video after the break, the 128×96 pixel video is up and running. [Andrew] plans to enlarge the scope of the project from here to make it more versatile than just showing standard images. The code (written in assembly) is available at his GitHub repository.

Continue reading “AVR VGA Generator”