A better template for your STM32 F3 dev board

If you’ve picked up one of those really cool STM32 ARM dev boards, you’ve probably poked around looking for a good toolchain. No fear, then, because [Matt] has your back. He put together a template for the ARM Cortex-M4 powered STM32 board.

[Matt] had been using a template for the STM32 F4 we’d covered before, but found the implementation a bit lacking. Wanting to exploit the functionality of his fancy STM32 F3 board, [Matt] took the F0 template whipped up by our very own [Mike S] and got it to work with the newer, fancier dev board.

There are a few bonuses to using [Matt]‘s template; the ARM chip in the F3 Discovery board has a hardware floating-point unit that is inaccessible using the Code Sourcery G++: Lite Edition toolchain. [Matt]‘s use of gcc-arm-embedded allows access to the hardware FPU, a great benefit for a great board.

Evolutionary algorithms computes the best blackjack strategy

blackjack_banner

Don’t want to learn about evolutionary algorithms the usual way, by generating sentences from random letters, or randomly placing pixels to generate the Mona Lisa? Then make your own evolutionary algorithm! With blackjack!

[Brian] has been playing around with evolutionary algorithms, and wanted a task that’s well suited for optimization. He chose blackjack, because of the limited number of hands that can be dealt to the player (32) and low number of hands the dealer can have (10).

Even with the low number of initial conditions for the player and the dealer, there are still 4.562 x 10^192 possible combinations of hands, so brute forcing a blackjack strategy would require the computational power of the entire planet. An easier way to compute a good strategy is an evolutionary algorithm, implemented by [Brian] with the Watchmaker Java library.

For each generation in [Brian]‘s program, a 32×10 grid was generated, one cell each for possible player’s hands against the dealer’s hand. In each cell, the computer put a ‘hit’, ‘stay’, or ‘double down’, and played thousands of hands with that strategy. The best strategies were bred and eventually [Brian] ended up with a good blackjack strategy.

The resulting best strategy is pretty good – using his strategy, he can walk out of an Atlantic City casino with 96% of the money he arrived with.

Computer tracking of billiard balls

The folks at the London-based startup GoCardless have a pool table at their office. Being the techies they are, they decided to build a system that automatically scores games. The results, while not fully complete, are still pretty impressive for something whipped up during a 48 hour hackathon.

The automated score keeper uses a webcam duct taped to the ceiling right above the center of the pool table, The balls – red and yellow balls replace the rainbow of solids and stripes to make things easier – are found using OpenCV.

This build isn’t quite finished yet. The people at GoCardless are looking to improve the accuracy of their setup by using a camera with a higher frame rate and possibly moving on to physics simulation to predict where the balls should be. If these guys get the time, they could add something like augmented reality pool table to improve shot accuracy.

Vidia after the break.

[Read more...]

Giving the Arduino deques, vectors and streams with the standard template library

The Arduino IDE is extremely similar to C++, but judging from the sketches you can find on the Internet, you’d never know it. Simpler Arduino projects can make do with just toggling IO pins, reading values, and sending serial data between two points. More complex builds fall into the category of real software development, and this is where the standard Arduino IDE falls miserably short.

[Andy] saw this lack of proper libraries for more complicated pieces of software as a terrible situation and decided to do something about it. He ported the SGI Standard Template Library to bring all those fun algorithms and data structures to any AVR chip, including the Arduino.

Going over what’s included in [Andy]‘s port reads just like a syllabus for an object-oriented programming class. Stacks, queues, and lists make the cut, as do strings and vectors. Also included is just about everything in the   and headers along with a few Arduino-oriented additions like a hardware serial and liquid crystal streams.

With all these objects floating around, [Andy] says it will make an impact on Flash and SRAM usage in an AVR. Still, with all the hullabaloo over faster and larger ARM micros, it’s nice to see the classic 8-bit microcontroller becoming a bit more refined.

Debugging the Stellaris with OpenOCD

It looks as though Texas Instruments are really reaching out to the hacker community with their new ARM-powered Stellaris dev board. On the Stellarisiti forums, a member asked about the debugging options for the Stellaris board. The Stellaris already features an In-Circuit Debug Interface (ICDI), but unfortunately it’s a little hard to get working in Linux-ey environments.

One of the devs for the Open On-Chip Debugger was already talking with TI to get the ICDI spec released for the Stellaris board. TI released the info, and after quite a bit of work, everything is open for all to see.

Right now, OpenOCD support for the Stellaris is still incomplete, but there is an project up on the Gits that allows for multi-platform development for TI’s new board.

Needless to say, getting everything up and running is still a chore. That’s not really a concern, though; the Stellaris has only been around for a few months and it takes devs time to put all the required tools into nice, neat packages. We’re just glad TI is being so forthcoming with the relevant documentation, lest development becomes a million times harder.

μJ, a Java virtual machine for microcontrollers

[Dimitri] sent in a project he’s been working on that implements a Java Virtual Machine purely in C, and is easily portable between microcontrollers such as the AVRs and PICs we normally see, ARM devices, and even the lowly 386.

Before going into the ‘how’, [Dimitri] first covers why he wanted to run Java bytecode on a microcontroller. Basically, he found existing solutions like the Arduino environment too complex for people just wanting to program a chip. Arduino and PICAXE require C-like syntax and pointers; not the easiest thing when everyone and their mother can program in Java.

As for how [Dimitri] managed to pack a JVM into a microcontroller, that’s another story entirely. Everything in the JVM, from double, long, and float data types to exceptions, neat thread-related functions such as ‘synchronize’ and even methods such as String.charAt() and String.length() are completely optional. If your microcontroller is too small, just disable the functions you don’t need.

As for how well – and how fast – μJ is able to run, [Dimitri] threw up a demo of an ATMega644 and PIC24 running his JVM and a small Java app. You can check those videos out after the break, or just download the source for μJ on [Dimitri]‘s site.

[Read more...]

Have a baby? Build another one!

Ever since his daughter was born, [Markus] has been keeping logs full of observations of human behavior. Despite how it sounds, this sort of occurrence isn’t terribly odd; the field of developmental psychology is filled with research of this sort. It’s what [Markus] is doing with this data that makes his project unique. He’s attempting to use stochastic learning to model the behavior of his daughter and put her mind in a robot. Basically, [Markus] is building a robotic version of his newborn daughter.

The basics of stochastic learning (PDF with more info) is that a control system is modeled on an existing system – in this case, a baby – by telling a robot if it is doing a good or bad job. Think of it as classical conditioning for automatons that can only respond to a 1 or 0.

[Markus] built a robotic platform based on an Arduino Mega and a few ultrasonic distance sensors. By looking at its surrounding environment, the robot makes judgments as to what it should do next. In the video after the break, [Markus] shows off his robot finding its way around an obstacle course – really just a pair of couch cushions.

It’s a long way from crawling around on all fours, paying attention to shiny things, and making a complete mess of everything, but we’re loving [Markus]‘ analytical approach to creating a rudimentary artificial intelligence.

[Read more...]