Who Ate All The Pi?

Wednesday was the last day of February, and leap year questions aside that date marks the anniversary of the Raspberry Pi launch. The oldest commercially available Pi is now 6 years old, and to mark the occasion the Raspberry Pi people have put up a retrospective of all their different models.

There is a primordial prototype from [Eben Upton]’s bench that involves an Atmel processor, but the first board dangled in front of the public was a Broadcom one, the BCM2763 ‘micro DB’. This was a form factor like one of those Android TV sticks, and while it was not a Raspberry Pi internal design or indeed sporting the SoC to be used by the Pi itself, it was sufficient to capture the imagination of what would become the Raspberry Pi community.

If you got out of bed early (British time) on the 29th of February 2012 and tried to order one of the first commercially available boards, you were most likely to be out of luck. The relatively small first batch from China was oversubscribed massively, both the RS and Farnell websites went down completely for most of the day. We received our model at some point in May. It’s an over-used phrase, “And the rest is history”, but it seems entirely appropriate here. The Pi has passed through several iterations and increased in both computing power and memory, it has spawned a whole industry of peripherals, a huge community, and a host of competitors. We have quite a few of the boards in the blog post, but some of the more exotic ones have evaded us.

It’s not the best or most powerful board out there, many of its competitors can beat it on performance, but it remains the one to beat in small and cheap Linux-capable single board computers. Why is this the case? It has probably the best-supported Linux distro of all of them, and that community has already answered many of the queries you might find with your board.

So there’s the story, a successful product line, community, and foundation. The Pi blog piece is very much their PR, but it doesn’t need to gild the lily. However, that will not stop competitors from taking aim at its crown, and the field remains open for one of them to topple it. Which of course makes for fascinating stories for us here at Hackaday, so we’d encourage anybody with an electronics factory in China, a bright team, and some good ideas to give it a try. Meanwhile, we’ll be looking towards Cambridge for whatever new products will sport the fruity logo.

Building A Portable Solar Powered Spot Welder: Charging Supercapacitors

Before Lunar New Year, I had ordered two 3000 F, 2.7 V supercapacitors from China for about $4 each. I don’t actually remember why, but they arrived (unexpectedly) just before the holiday.

Supercapacitors (often called ultracapacitors) fill a niche somewhere between rechargeable lithium cells and ordinary capacitors. Ordinary capacitors have a low energy density, but a high power density: they can store and release energy very quickly. Lithium cells store a lot of energy, but charge and discharge at a comparatively low rate. By weight, supercapacitors store on the order of ten times less energy than lithium cells, and can deliver something like ten times lower power than capacitors.

Overall they’re an odd technology. Despite enthusiastic news coverage, they are a poor replacement for batteries or capacitors, but their long lifespan and moderate energy and power density make them suitable for some neat applications in their own right. Notably, they’re used in energy harvesting, regenerative braking, to extend the life of or replace automotive lead-acid batteries, and to retain data in some types of memory. You’re not likely to power your laptop with supercapacitors.

Anyway, I had a week-long holiday, and two large capacitors of dubious origin. Sometimes we live in the best of all possible worlds. Continue reading “Building A Portable Solar Powered Spot Welder: Charging Supercapacitors”

Entropy And The Arduino: When Clock Jitter Is Useful

What do you do, when you need a random number in your programming? The chances are that you reach for your environment’s function to do the job, usually something like rand() or similar. This returns the required number, and you go happily on your way.

A shift register configured as a pseudo-random number generator.
A shift register configured as a pseudo-random
number generator. [by KCAuXy4p CC0 1.0]
Except of course the reality isn’t quite that simple, and as many of you will know it all comes down to the level of randomness that you require. The simplest way to generate a random number in software is through a pseudo-random number generator, or PRNG. If you prefer to think in hardware terms, the most elementary PRNG is a shift register with a feedback loop from two of its cells through an XOR gate. While it provides a steady stream of bits it suffers from the fatal flaw that the stream is an endlessly repeating sequence rather than truly random. A PRNG is random enough to provide a level of chance in a computer game, but that predictability would make it entirely unsuitable to be used in cryptographic security for a financial transaction.

There is a handy way to deal with the PRNG predictability problem, and it lies in ensuring that its random number generation starts at a random point. Imagine the  shift register in the previous paragraph being initialised with a random number rather than a string of zeros. This random point is referred to as the seed, and if a PRNG algorithm can be started with a seed derived from a truly unpredictable source, then its output becomes no longer predictable.

Selecting Unpredictable Seeds

Computer systems that use a PRNG will therefore often have some form of seed() function alongside their rand() function. Sometimes this will take a number as an argument allowing the user to provide their own random number, at other times they will take a random number from some source of their own. The Sinclair 8-bit home computers for example took their seed from a count of the number of TV frames since switch-on.

The not-very-random result of a thousand analogRead() calls.
The not-very-random result of a thousand analogRead() calls.

The Arduino Uno has a random() function that returns a random number from a PRNG, and as you might expect it also has a randomSeed() function to ensure that the PRNG is seeded with something that will underpin its randomness. All well and good, you might think, but sadly the Atmel processor on which it depends has no hardware entropy source from which to derive that seed. The user is left to search for a random number of their own, and sadly as we were alerted by a Twitter conversation between @scanlime and @cybergibbons, this is the point at which matters start to go awry. The documentation for randomSeed() suggests reading the random noise on an unused pin via analogRead(), and using that figure does not return anything like the required level of entropy. A very quick test using the Arduino Graph example yields a stream of readings from a pin, and aggregating several thousand of them into a spreadsheet shows an extremely narrow distribution. Clearly a better source is called for.

Noisy Hardware or a Jittery Clock

As a slightly old-school electronic engineer, my thoughts turn straight to a piece of hardware. Source a nice and noisy germanium diode, give it a couple of op-amps to amplify and filter the noise before feeding it to that Arduino pin. Maybe you were thinking about radioactive decay and Geiger counters at that point, or even bouncing balls. Unfortunately though, even if they scratch the urge to make an interesting piece of engineering, these pieces of hardware run the risk of becoming overcomplex and perhaps a bit messy.

The significantly more random result of a thousand Arduino Entropy Library calls.
The significantly more random result of a thousand Arduino Entropy Library calls.

The best of the suggestions in the Twitter thread brings us to the Arduino Entropy Library, which uses jitter in the microcontroller clock to generate truly random numbers that can be used as seeds. Lifting code from the library’s random number example gave us a continuous stream of numbers, and taking a thousand of them for the same spreadsheet treatment shows a much more even distribution. The library performs as it should, though it should be noted that it’s not a particularly fast way to generate a random number.

So should you ever need a truly random number in your Arduino sketch rather than one that appears random enough for some purposes, you now know that you can safely disregard the documentation for a random seed and use the entropy library instead. Of course this comes at the expense of adding an extra library to the overhead of your sketch, but if space is at a premium you still have the option of some form of hardware noise generator. Meanwhile perhaps it is time for the Arduino folks to re-appraise their documentation.

The subject of entropy and generating random numbers is one that has appeared on these pages many times. [Voja Antonic] made a in-depth study using uninitialized RAM as an entropy source for microcontrollers. If you have an insatiable appetite for understanding Linux entropy, we point you at [Elliot Williams]’ comprehensive examination of the subject.

[Arduino image: DustyDingo Public domain]

ATtiny Chip Abused In RFID Application

One of Atmel’s smallest microcontrollers, the ATtiny, is among the most inexpensive and reliable chips around for small applications. It’s also one of the most popular. If you don’t need more than a few inputs or outputs, there’s nothing better. As a show of its ability to thrive under adverse conditions, [Trammell Hudson] was able to shoehorn an ATtiny into an RFID circuit in a way that tests the limits of the chip design.

The RFID circuit only uses two of the ATtiny’s pins and neither of which is the ground or power pin. The ATtiny is equipped with protective diodes on its input pins, and if you apply an AC waveform to the input pins, the chip is able to use the leakage current to power itself. Once that little hurdle is crossed, the ATtiny can do the rest of its job handling the RFID circuitry.

This project takes a deep dive into the internals of the ATtiny. If you’ve ever wondered what was going on inside of everyone’s favorite tiny microcontroller, or if you’re looking for an RFID circuit that keeps parts counts to an absolute minimum, this is the project for you.  The ATtiny is more than just a rugged, well-designed chip, though. It’s capable of a lot more than such a small chip should be able to.

Thanks to [adnidor] for the tip!

Roll Your Own Arduino PWM

Most projects are built on abstractions. After all, few of us can create our own wire, our own transistors, or our own integrated circuits. A few months ago, [Julian Ilett] found a problem using the Arduino library for PWM. Recently, he revisited the issue and used his own PWM code to fix the problem. You can watch the video below.

Of course, neither the Arduino library nor [Julian’s] code is actually producing PWM. The Atmel CPU’s hardware is doing the work. The Arduino library gives you a wrapper called analogWrite — especially handy if you are not using an Atmel CPU where the same abstraction will do the same work. The issue arose when [Julian] broke the abstraction to invert the PWM output.

Continue reading “Roll Your Own Arduino PWM”

Which Microcontroller Is Best Microcontroller?

Let’s say you’re working on a project, and you need a microcontroller. Which chip do you reach for? Probably the one you’re most familiar with, or at least the one whose programmer is hiding away in a corner of your desk. Choosing a microcontroller is a matter of convenience, but it doesn’t have to be this way. There are dozens of different ARM cores alone, hundreds of 8051 clones, and weirder stuff including the Cypress PSoC and TI’s MSP430. Which one is best? Which microcontroller that costs under a dollar is best? That’s the question [Jay Carlson] tried to answer, and it’s the best microcontroller shootout we’ve ever read.

[Jay] put together a monster of a review of a dozen or so microcontrollers that cost no more than a dollar. Included in this review are, from Atmel: the ATtiny1616, ATmega168PB, and the ATSAMD10. From Cypress, the PSoC 4000S. From Freescale, the KE04 and KL03. Holtek’s HT-66, and the Infineon XMC1100. From Microchip, the PIC16, PIC24, and PIC32. From Nuvoton, the N76, and M051. The NXP LPC811, Renesas RL-78, Sanyo LC87, and Silicon Labs EFM8. ST’s STM32F0 and STM8. STCMicro’s STC8, and finally TI’s MSP430. If you’re keeping score at home, most of these are either ARM or 8051-style cores, but the AVRs and PICs bump up the numbers for ‘proprietary’ core designs.

This review begins the same as all tech reviews, with a sampling of tech specs. Everything is there, including the amount of RAM to the number of PWM channels. [Jay] is going a bit further with this review and checking out the development environments, compilers, dev tools, and even the performance of different cores in three areas: blinking bits, a biquad filter, and a DMX receiver. There’s an incredible amount of work that went into this, and right now, this is the best resource we’ve seen for a throwdown of microcontrollers.

With all this data and the experience of going through a dozen different microcontroller platforms, what’s [Jay]’s takeaway? The STM32F0 is great, the Atmel/Microchip SAM D10 has great performance but you’ll be relying on some third-party libraries. The pure Microchip parts — the PIC16, PIC24, and PIC32 — have infinite product lifetimes, a wide range of packages, and a huge community but use a clunky IDE, and expensive compilers. The Cypress PSoC was just okay, and the PSoC5 or PSoC6 would be better. Surprises from this test include the Renesas RL-78 and its high performance, low cost, and the most power-efficient 5V part in the test.

With all that said, what’s the best microcontroller? That’s a dumb question, because the best microcontroller will always be the best microcontroller for that application. Or whatever you have sitting around in the parts drawer, we were never quite clear on what the answer actually is. That said, this is a new high water mark for microcontroller reviews, and we hope [Jay] will continue his research into microcontrollers that cost more than a dollar.

Mergers And Acquisitions: Broadcom, Qualcomm, And One Hundred Billion Dollars

Rumors have been circulating this last weekend of the largest semiconductor acquisition ever. Broadcom might buy Qualcomm for the princely sum of one hundred Billion dollars.

You will most likely be familiar with both Qualcomm and Broadcom for their wireless and cellphone chipsets. As far as the Maker community is concerned, Broadcom makes the chipset for the Raspberry Pi, but in the context of a two hundred Billion dollar company, a ‘maker’ focused Linux dev board is the equivalent of a rounding error on a balance sheet.

This news comes a little more than a year after the announcement that Qualcomm is snatching up NXP, and two years after the news of NXP is merging with Freescale. The industry is in a state of consolidation.

This proposed deal follows several other semiconductor mergers and acquisitions including NXP and Freescale, Intel and Altera, Avago and BroadcomOn Semiconductor and Fairchild, and the one we’re most befuddled with, Atmel and Microchip. Why are these companies merging? Because they’re sitting on mountains of cash. All of these mergers with the exception of Avago and Broadcom, have been for single-digit Billions of dollars. The merger of Broadcom and Qualcomm — if it happens — will be the largest merger of two semiconductor companies ever. That’s easy to do when both Broadcom and Qualcomm are on the top ten list of largest semiconductor companies, but it is evidence enough that the mergers and acquisitions in the industry are not slowing down.