Code Craft – Embedding C++: Multitasking

We’re quite used to multitasking computer systems today. Our desktops run email, a couple of browsers in different workspaces, a word processor, and a few other applications, apparently all at once. Looking behind the scenes using a system monitor or task manager program reveals a multitude of other programs running in support of our activities. Of course, any given CPU is running a maximum of one program at a time. Multitasking is simply the practice of switching between active processes fast enough to give the illusion of simultaneity.

The roots of multiasking go way back. In the early days, when computers cost tons of money, the thought of an idle system was anathema. Teletype IO was slow compared to the processor, and leaving the processor waiting idle for a card reader to slurp in the next card was outrageous. The gurus of the time worked to fill that idle time with productive work. That eventually led to systems that would run multiple programs at one time, and eventually to more finely grained multitasking within a program.

Modern multitasking depends on support from the underlying API of an operating system. Each OS uses its own techniques, making it difficult to write portable code. The C++ 2011 standard increased the portability of the language by adding concurrency routines to the Standard Template Library (STL). These routines use the API of the OS. For instance, the Linux version uses the POSIX threading library, pthread. The result is a minimal, but useful, capability for building upon in later standards. The C++ 2017 standard development activities include work on parallelism and concurrency.

In this article, I’ll work through some of the facilities for and pitfalls in writing threaded code in C++.

Continue reading “Code Craft – Embedding C++: Multitasking”

Government Drones To Toss M&Ms To Prarie Dogs

We hear a lot about drone surveillance, drone package delivery, drone this, and drone that. Honestly, though, the best use of drones has been taking cool aerial videos and posting them online. Until now.

The US Fish and Wildlife Service plans to cover acres upon acres of prairie-dog habitat with vaccine-laced, peanut-butter coated M&Ms. The snacks also include a dye that will show up in the whiskers of prairie dogs that take the bait, allowing scientists to assess the efficacy of the program. And this is all in the name of saving endangered black-footed ferrets which share burrows with the prairie dogs. It seems they were getting the plague from the prairie dogs.

The quads are outfitted with a “glorified gumball machine” that spreads the vaccine tidbits around. Why a quad? They can cover more space with less disruption to the animals’ habitat. That’s a great application in our book.

But if you think this is a case of the USF&WS showing outrageous innovation, consider the way rabies was all but eliminated in Europe: throwing hundreds of thousands of vaccine-doped chicken heads out of helicopters across France, Switzerland, and Germany. You couldn’t make this up.

(Via [Popular Science], where the title is even more clickbaity than ours. Get it? “Clickbait”?)

Headline image: US Fish and Wildlife Service Mountain-Prairie

A quick brush over the part with some sand paper and it quickly transforms from obviously plastic to metallic.

Learn Resin Casting Techniques: Cold Casting

Sometimes we need the look, feel, and weight of a metal part in a project, but not the metal itself. Maybe you’re going for that retro look. Maybe you’re restoring an old radio and you have one brass piece but not another. It’s possible to get a very metal like part without all of the expense and heat required in casting or the long hours in the metal fabrication shop.

Before investing in the materials for cold casting, it’s best to have practical expectations. A cold cast part will not take a high polish very well, but for brushed and satin it can be nearly indistinguishable from a cast part. The cold cast part will have a metal weight to it, but it clinks like ceramic. It will feel cool and transfers heat fairly well, but I don’t have numbers for you. Parts made with brass, copper, and iron dust will patina accordingly. If you want them to hold a bright shine they will need to be treated with shellac or an equivalent coating afterward; luckily the thermoset resins are usually pretty inert so any coating used on metal for the same purpose will do.

It is best to think of the material as behaving more or less like a glass filled nylon such as the kind used for the casing of a power tool. It will be stiff. It will flex a relatively short distance before crazing and then cracking at the stress points. It will be significantly stronger than a 3D printed part, weaker than a pure resin part, and depending on the metal; weaker than the metal it is meant to imitate.

Continue reading “Learn Resin Casting Techniques: Cold Casting”

Nirvana Like You’ve Never Heard Them Before

If you were an early 1990s youth, the chances are [Nirvana]’s Smells Like Teen Spirit is one of those pieces of music that transports you straight back to those times. As your writer it evokes a student radio studio and the shelves of its record library, and deafening badly-lit discos with poorly adjusted PA systems and unpleasantly sticky dance floors.

One of our finds this morning therefore comes as an evocative diversion, Smells Like Teen Spirit on [SileNT]’s Floppotron. The Floppotron is a music player composed of a huge array of floppy drives, hard drives, and a couple of flatbed scanners. The scanners are controlled by off-the-shelf Arduino boards and the hard drives have ATMega16s with H-bridge drivers.

This build is the most refined floppy drive organ we’ve seen yet. The floppies are divided into single-voice blocks of eight controlled by an ATMega16, with dynamic volume envelopes mad possible by the number of simultaneously running drives, so the sounds can fade in and out like “natural” musical instruments. The hard drives and scanners are run against their mechanical stops, providing percussion. All the boards are daisychained via SPI to an Arduino that acts as a PC interface, and the PC schedules the performance with a Python script.

He’s provided a couple of pieces as YouTube videos, the floppy motors work particularly well for [Nirvana]’s grunge, but perhaps a bit more mechanical for Hawaii Five-O. This last track will be more evocative than the first if you attended a particular university in the North of England where it was the end-of night record played as the lights came up in one of the discos that had a much better-adjusted PA because the technician knew what she was doing. For those of you with different childhoods, there’s also the Imperial March.

Continue reading “Nirvana Like You’ve Never Heard Them Before”

Another Small Linux Computer With Pi In Its Name

Since the introduction of the Raspberry Pi, the embedded Linux scene has been rocked by well supported hardware that is produced in quantity, a company that won’t go out of business in six months, and a huge user base. Yes, there are a few small problems with the Raspberry Pi and its foundation – some stuff is still closed source, the Foundation itself plays things close to their chests, and there are some weird binary blobs somebody will eventually reverse engineer. Viewed against the competition, though, nothing else compares.

Here’s the NanoPi Neo, the latest quad-core Allwinner board from a company in China you’ve never heard of.

The NanoPi Neo is someone’s answer to the Raspberry Pi Zero, the very small and very cheap single board Linux computer whose out-of-stock percentage has led some to claim it’s completely fake and a media conspiracy. The NanoPi Zero features an Allwinner H3 quad-core Cortex-A7 running at 1.2 GHz, 256MB RAM, with a 512MB version being released shortly. Unlike the Raspberry Pi Zero, the NanoPi Neo features a 10/100 Ethernet port. No, it does not have PoE.

As with anything comparing itself to the Raspberry Pi Zero, only two things are important: size and price. The NanoPi Neo is a mere 40mm square, compared to the 65x30mm measurements of the Pi Zero. The NanoPi Neo is available for $7.99, with $5 shipping to the US. Yes, for just three dollars more than a Pi Zero with shipping, you get a poorly supported Linux board. What a time to be alive.

If you’re looking for another wonderful tale of what happens with cheap, powerful ARM chips and contract manufacturers in China, check out my review of the Pine64.

I2C Bit Injection Adds Memory Banks To Everything

[Igor] wished to upgrade his newly acquired radio — a Baofeng UV-82 — with a larger memory for storing additional scanning channels, and came up with a very elegant solution: Replacing it’s EEPROM with a larger one and injecting the additional memory address bits into the I2C data line.

Continue reading “I2C Bit Injection Adds Memory Banks To Everything”

Micropython Binaries For The ESP8266 To Be Released

MicroPython is a Kickstarted project that brings Python to small, embeddable devices. As part of the terms of the Kickstarter, supporters were to get exclusive access to binary builds, with a few exceptions. Now it looks like the ESP8266-version is going to be added to the binary list. This is awesome news for anyone who enjoys playing around with the popular WiFi chip.

But even more heartwarming is the overwhelming response of the Kickstarter’s backers for making the binary builds public. Basically everyone was in favor of opening the binaries up to the general public, and many wrote that they wanted public binaries all along. People can be so giving.

But there’s also something in it for them! The more people get behind MicroPython, the more (free and paid) development support it will warrant, and the more bug reports it will garner. Wins all around. So keep clicking refresh on the binary list until you see it live. Or better yet, if you’re interested, head over to the forum. (Or just wait for us to cover it here. You know we will.)