Using the GPU from JavaScript

Everyone knows that writing programs that exploit the GPU (Graphics Processing Unit) in your computer’s video card requires special arcane tools, right? Well, thanks to [Matthew Saw], [Fazil Sapuan], and [Cheah Eugene], perhaps not. At a hackathon, they turned out a Javascript library that allows you to create “kernel” functions to execute on the GPU of the target system. There’s a demo available with a benchmark which on our machine sped up a 512×512 calculation by well over five times. You can download the library from the same page. There’s also a GitHub page.

The documentation is a bit sparse but readable. You simply define the function you want to execute and the dimensions of the problem. You can specify one, two, or three dimensions, as suits your problem space. When you execute the associated function it will try to run the kernels on your GPU in parallel. If it can’t, it will still get the right answer, just slowly.

Continue reading “Using the GPU from JavaScript”

3D printed Math Grenade

Calculator hacks are fun and educational and an awesome way to show-off how 1337 your skills are. [Marcus Wu] is a maker who likes 3D printing and his Jumbo Curta Mechanical Calculator is a project from a different era. For those who are unfamiliar with the Curta, it is a mechanical calculator that was the brainchild of Curt Herzstark of Austria from the 1930s. The most interesting things about the design were the compactness and the complexity which baffled its first owners.

The contraption has setting sliders for input digits on the side of the main cylindrical body. A crank at the top of the device allows for operations such as addition and subtraction with multiplication and division requiring a series of additional carriage shift operations. The result appears at the top of the device after each crank rotation that performs the desired mathematical operation. And though all this may seem cumbersome, the original device fit comfortably in one hand which consequently gave it the nick name ‘Math Grenade’.

[Marcus Wu] has shared all the 3D printable parts on Thingiverse for you to make your own and you should really take a look at the video below for a quick demo of the final device. There is also a detailed set of images (82 or so) here that present all the parts to be printed. This project will test your patience but the result is sure to impress your friends. For those looking to dip your toes in big printed machines, check out these Big Slew Bearings for some inspiration.

Hacking iBeacons For Automating Routines

Every self-respecting hacker has an automation hack somewhere in his/her bag of tricks. There are a lot of modern-day technologies that facilitate the functionality like GPS, scripting apps, and even IFTTT. In an interesting hack, [Nick Lee] has combined iBeacons and a reverse engineered Starbucks API to create an automated morning routine.

By creating a mobile app that scans for iBeacons, [Nick Lee] was able to reduce the effort made every morning while heading to his office. When the app encounters a relevant beacon, a NodeJS app sitting in the cloud is triggered. This consequently leads to desired actions like ordering an Uber ride and placing an order for an iced latte.

[Nick Lee] shares the code for the Starbucks application on GitHub for anyone who wants to order their favorite cup of joe automatically. This project can be easily expanded to work with GPS or even RFID tags and if you feel like adding IoT to a coffee machine, you could automate all of your beverage requirements in one go.

Best Product Entry: Emulating Memory

For this year’s Hackaday Prize, we’re giving everyone the opportunity to be a hardware startup. This is the Best Product portion of the Hackaday Prize, a contest that will award $30,000 and a residency in our Design Lab to the best hardware project that is also a product.

Imagine all the memory chips in all the landfills in the world. What if we could easily recover those hosed motherboards and swap out ROM files on malware-damaged chips. That’s the promise of [Blecky]’s EEPROM/Flash Emulator project on Hackaday.io. This project seeks to be the ultimate memory interface, emulating SPI-interface EEPROM or Flash memory chipsets with ease. It can also be used as a security device, checking the BIOS for untoward changes.

The EEEmu packs an Atmel SAM4S Cortex-M4 processor-based microcontroller, an SD card reader, a micro USB for reprogramming, boost converter, voltage regulator, and includes additional 3.3V GPIO/I2C ports, all on a wee 51.5x20mm circuit board. Version 2 is slated to include more features to facilitate use as a normal micro controller: more GPIO pins, USB voltage monitoring, and high-Z control for SPI output.

EEEmu is completely open source, with [Blecky] sharing his code on GitHub and even has created an EEEmu Fritzing part, also found in his repository.

Ask Hackaday: Selling Yourself as a Hacker

While there are plenty of hackers that hack just for the love of it, it’s no secret that many of us are looking to hit it big someday. Tales of the businesses like HP and Apple that started in someone’s garage inevitably lead to musings like, “Hey, I’ve got a garage!” and grand plans to turn that special idea into the Next Big Thing™. Many will try, most will fail for one reason or another, but hope springs eternal, and each new widget seems to start the entrepreneurial cycle again.

But for as much pressure as we may feel to be the next Packard, Wozniak, or Musk, not everyone is cut out to be the boss. Some of us have no interest in or aptitude for business — we don’t want to hire or fire people, we don’t want to wheel and deal, and we certainly don’t want to worry about salesmanship. Some of us just want to abstract all that complexity away and just find a job, preferably one that leverages the things we love to do.
Continue reading “Ask Hackaday: Selling Yourself as a Hacker”

Completely Owning the Dreamcast Add-on You Never Had

If you’ve got a SEGA Dreamcast kicking around in a closet somewhere, and you still have the underutilized add-on Visual Memory Unit (VMU), you’re in for a treat today. If not, but you enjoy incredibly detailed hacks into the depths of slightly aged silicon, you’ll be even more excited. Because [Dmitry Grinberg] has a VMU hack that will awe you with its completeness. With all the bits in place, the hacking tally is a new MAME emulator, an IDA plugin, a never-before ROM dump, and an emulator for an ARM chip that doesn’t exist, running Flappy Bird. All in a month’s work!

The VMU was a Dreamcast add-on that primarily stored game data in its flash memory, but it also had a small LCD display, a D-pad, and inter-VMU communications functions. It also had room for a standalone game which could interact with the main Dreamcast games in limited ways. [Dmitry] wanted to see what else he could do with it. Basically everything.

We can’t do this hack justice in a short write-up, but the outline is that he starts out with the datasheet for the VMU’s CPU, and goes looking for interesting instructions. Then he started reverse engineering the ROM that comes with the SDK, which was only trivially obfuscated. Along the way, he wrote his own IDA plugin for the chip. Discovery of two ROP gadgets allowed him to dump the ROM to flash, where it could be easily read out. Those of you in the VMU community will appreciate the first-ever ROM dump.

On to doing something useful with the device! [Dmitry]’s definition of useful is to have it emulate a modern CPU so that it’s a lot easier to program for. Of course, nobody writes an emulator for modern hardware directly on obsolete hardware — you emulate the obsolete hardware on your laptop to get a debug environment first. So [Dmitry] ported the emulator for the VMU’s CPU that he found in MAME from C++ to C (for reasons that we understand) and customized it for the VMU’s hardware.

Within the emulated VMU, [Dmitry] then wrote the ARM Cortex emulator that it would soon run. But what ARM Cortex to emulate? The Cortex-M0 would have been good enough, but it lacked some instructions that [Dmitry] liked, so he ended up writing an emulator of the not-available-in-silicon Cortex-M23, which had the features he wanted. Load up the Cortex emulator in the VMU, and you can write games for it in C. [Dmitry] provides two demos, naturally: a Mandlebrot set grapher, and Flappy Bird.

Amazed? Yeah, we were as well. But then this is the same guy emulated an ARM chip on the AVR architecture, just to run Linux on an ATMega1284p.

Conventional Current Vs. Electron Current

Electric current comes in many forms: current in a wire, flow of ions between the plates of a battery and between plates during electrolysis, as arcs, sparks, and so on. However, here on Hackaday we mostly deal with the current in a wire. But which way does that current flow in that wire? There are two possibilities depending on whether you’re thinking in terms of electron current or conventional current.

Electron current vs. conventional current
Electron current vs. conventional current

In a circuit connected to a battery, the electrons are the charge carrier and flow from the battery’s negative terminal, around the circuit and back to the positive terminal.

Conventional current takes just the opposite direction, from the positive terminal, around the circuit and back to the negative terminal. In that case there’s no charge carrier moving in that direction. Conventional current is a story we tell ourselves.

But since there is such a variety of forms that current comes in, the charge carrier sometimes does move from the positive to the negative, and sometimes movement is in both directions. When a lead acid battery is in use, positive hydrogen ions move in one direction while negative sulfate ions move in the other. So if the direction doesn’t matter then having a convention that ignores the charge carrier makes life easier.

Saying that we need a convention that’s independent of the charge carrier is all very nice, but that seems to be a side effect rather than the reason we have the convention. The convention was established long before there was a known variety of forms that current comes in — back even before the electron, or even the atom, was discovered. Why do we have the convention? As you’ll read below, it started with Benjamin Franklin.

Continue reading “Conventional Current Vs. Electron Current”