Editing Your FPGA Source

[Dave] noted that in a recent poll of FPGA developers, emacs was far and away the most popular VHDL and Verilog editor. There are a few reasons for this – namely, emacs comes with packages for editing your HDL of choice. For those of us not wanting to install (and learn) the emacs operating system, [Dave] got Notepad++ to work with these packages.

Notepad++ already has VHDL and Verilog highlighting along with other advanced text editor features, but [Dave] wanted templates, automated declarations and beautification. To do this, he used the FingerText to store code as snippets and call them up at the wave of a finger.

As [Dave] writes his code, the component declarations constantly need to be updated, and with the help of a Perl script [Dave] can update them with the click of a hotkey. Beautification is a harder nut to crack, as Notepad++ doesn’t even have a VHDL or Verilog beautifier plugin. This was accomplished by installing emacs and running the beautification process as a batch script. Nobody can have it all, but we’re thinking [Dave]’s method of getting away from emacs is pretty neat.

From 0 To C: Teaching Programming Without A Computer

It’s no secret that learning how to program is very hard, and teaching it doubly so, requiring the student to wrap their head around very unorthodox concepts. [Ubi de Feo] over at the Amsterdam tech collective Hello, Savants! has a unique solution for taking someone who knows nothing of programming and turning them into a computer aficionado capable of deftly wielding semicolons and parens. It’s called From 0 to C, and aims to teach students programming in an environment without computers.

For his class, [Ubi] made up a lot of wooden boxes with eight subdivisions representing the bits in a byte. By putting ping-pong balls in each slot, [Ubi]’s students can grasp the concept of counting by powers of two and quickly move on to hexidecimal and more advanced concepts like bit shifting.

After learning the ins and outs of how stupid computers actually are, [Ubi]’s students then learn the syntax of a language of their choice (C, JavaScript, or Python, for example), and write a few programs.

Although we’re sure most of our readers are far past the ‘learning programming from a blank slate’ portion of their hacker and maker career, anything that gets more people solving their own problems is okay in our book. [Ubi] has a pretty neat take on the pedagogy of teaching programming, and we’d really like to see his work expand outside his Amsterdam collective.

Make A Game For A Retro Console, Win Prizes

For all you old-school console hackers out there, there’s a homebrew coding competition being held by NeoTeam for all the retro (and not so retro) consoles of yesteryear. If you’ve ever programmed for the NES, GBA, PC Engine, N64, or even the Dreamcast, now’s your chance to write a game or app and hopefully win a small prize and a great deal of street cred.

Last year, the Neo Coding Competition saw some very cool entries such as [smealum]’s amazing work in bringing Minecraft to the Nintendo DS ([smealum]’s non-forum DScraft page is here). DScraft won [smealum] a cool $500 USD, but the bragging rights for bringing Minecraft to the DS are far more valuable than any monetary reward.

There are two categories for the competition, an app division and a game division. All the retro platforms are open for development in this contest, so if you want to write something for your Master System, NES, 32X, or Saturn, you better get started: the contest ends August 20th.

Creating A Decadent, Insane, And Depressed Robot From Internet Ramblings

Have you ever wondered what a Tumblr written by a psychotic robot would look like? Wonder no more, because [Lars] has that all figured out.

A few years ago, [Lars] stumbled across lowbrow.com (now defunct, but mirrored here), an online confessional and bathroom wall meant to host people’s most private thoughts and actions anonymously. [Lars] wrote a script to pull a random lowbrow post down every minute and threw every unique result into a database.

With about 50 pages of the most depraved and depressing posts of questionable veracity, [Lars] trained a Markov chain algorithm to produce paragraphs that imitated the style of lowbrow contributors. This gave [Lars]  pages of computer-generated text describing the most decadent, depressing, insane, inane, but overwhelmingly human experiences possible. A few choice quotes from the output are:

The llama: nature’s random number generator.

Over 7000 watts of Ol’ Barry whining his ass cheeks to soften the blows.

All through school I was being pulled behind the local St. Benedictine  Monastary where I was afraid I don’t know what I thought was the founder pulls back from a discussion about homestarrunner.com

While [Lars]’ script wouldn’t pass a Turing test, we’ve met people who couldn’t do the same. As far as creating a real-life version of Hedonism Bot, HAL, and Marvin from Hitchhiker’s Guide, we’re thinking [Lars] hit the mark.

After the break you can check out a gallery of pics [Lars] put together of from his computer-generated text. You can also grab the full lowbrow corpus and the ruby script to build your robotic [Kerouac].

Continue reading “Creating A Decadent, Insane, And Depressed Robot From Internet Ramblings”

A Detailed Tutorial On Speeding Up AVR Division

[Alan Burlison] is working on an Arduino project with an accelerometer and a few LEDs. Having the LEDs light up as his board is tilted to one side or another is an easy enough project a computer cowboy could whip out in an hour, but [Alan] – ever the perfectionist – decided to optimize his code so his accelerometer-controlled LEDs don’t jitter. The result is a spectacular blog post chronicling the pitfalls of floating point math and division on an AVR.

To remove the jitter from his LEDs, [Alan] used a smoothing algorithm known as an exponential moving average. This algorithm uses multiplication and is usually implemented using floating point arithmetic. Unfortunately, AVRs don’t have floating point arithmetic so [Alan] used fixed point arithmetic – a system similar to balancing your checkbook in cents rather than dollars.

With a clever use of bit shifting to calculate the average with scaling, [Alan] was able to make the fixed point version nearly six times faster than  the floating point algorithm implementation. After digging into the assembly of his fixed point algorithm, he was able to speed it up to 10 times faster than floating point arithmetic.

The takeaway from [Alan]’s adventures in arithmetic is that division on an AVR is slow. Not very surprising after you realize the AVR doesn’t have a division instruction. Of course, sometimes you can’t get around having to divide so multiplying by the reciprocal and using fixed point arithmetic is the way to go if speed is an issue.

Sure, squeezing every last cycle out of an 8 bit microcontroller is a bit excessive if you’re just using an Arduino as a switch. If you’re doing something with graphics or need very fast response times, [Alan] gives a lot of really useful tips.

Teaching A Computer To Learn

[Łukasz Kaiser] programmed a computer to play Tic-tac-toe. That doesn’t sound very remarkable until you realize he never told his computer the rules of Tic-tac-toe. The computer learned the rules by itself after watching a video of two people playing the game (link to actual paper – PDF warning).

[Łukasz] wrote a small program in C++ to recognize the placement of objects on a Tic-tac-toe, Connect 4, and Breakthough board. This program sifts through winning and losing games along with illegal moves to generate a Lambda calculus-like rule set for the relevant game. Even though [Łukasz] has only programmed a computer to learn simple games such as Tic-tac-toe, Connect 4, and Breakthrough, he plans to move up to more complex games such as Chess.

The fact that [Łukasz] programmed a computer to actually learn the rules of a game gives us pause; in one of the fabulous lectures [Richard Feynman] gave to freshman physics students in 1964, the subject of Chess came up. [Feynman] drew parallels between learning Chess and performing research. Every move is hypothesis testing, and when a very strange move occurs – castling, en passant, and the promotion of a pawn, for instance – the theory of the rules of the game must be reworked. Likewise, when extremely strange stuff happens in physics – particle/wave duality, and the existence of black holes – scientific theory is advanced.

Yes, teaching a computer to learn the rules of Tic-tac-toe may seem irrelevant, but given the same learning process can be applied to other fields such as medicine, economics, and just about every science, it’s not hard to see how cool [Łukasz]’ work is.

via extremetech

Video-based Radar For Your Car

[Gustaf] has been playing around with machine vision for a while and sent in his latest project in on our tip line. It’s a video based car radar system that can detect cars in a camera’s field of vision while cruising down the highway.

Like [Gustaf]’s previous experiments with machine vision where he got a computer to recognize and count yellow cylinders and green rectangles, the radar build uses ADABoost and the AForge AI/Machine Vision C# framework. [Gustef] used an evolutionary algorithm to detect the presence of a car in a video frame, first by selecting 150 images of cars from a pre-recorded video, and the another 1,850 images were selected by a computer and confirmed as a car by a human eye.

With 2000 images of cars in its database, [Gustaf]’s machine vision algorithm is able to detect a car in real-time as he drove down a beautiful Swedish highway. In addition to overlaying a rectangle underneath each car in a video frame and an awesome  Terminator-style HUD in the upper right corner, [Gustaf] also a distance display above the hood of his car.

It’s an awesome build that makes us wonder if [Gustef] is building an autonomous car. Even if he’s not, it really makes us want to install a video HUD in our whip, just to see this in action.