True Random Number Generator for a True Hacker

How can you generate random bits? Some people think it’s not easy, others will tell you that it’s pretty damn hard, and then there are those who wonder if it is possible at all. Of course, it is easy to create a very long pseudorandom sequence in software, but even the best PRNG (Pseudorandom Number Generator) needs a good random seed, as we don’t want to get the same sequence each time we switch on the unit, do we? That’s why we need a TRNG (True Random Number Generator), but that requires special hardware.

Some high-end microprocessors are equipped with an internal hardware TRNG, but it is, unfortunately, not true for most low-cost microcontrollers. There are a couple of tricks hackers use to compensate. They usually start the internal free running counter and fetch its contents when some external event occurs (user presses a button, or so). This works, but not without disadvantages. First, there is the danger of “locking” those two events, as a timer period may be some derivative of input scan routine timing. Second, the free running time (between switching on and the moment the unit requests a random number) is often too short, resulting in the seed being too close to the sequence start, and thus predictable. In some cases even, there is no external input before the unit needs a random seed!

Despite what has already been discussed, microcontrollers do have a source of true randomness inside them. While it might not be good enough for crypto applications, it still generates high enough entropy for amusement games, simulations, art gadgets, etc.

Continue reading “True Random Number Generator for a True Hacker”

New Part Day: STM32F7, An ARM Cortex-M7

It was announced last year, but ST is finally rolling out the STM32F7, the first microcontroller in production that is based on the ARM Cortex-M7.

The previous go-to part from the ST catalog was the STM32F4, an extremely powerful chip based on the ARM Cortex M4 processor. This chip was incredibly powerful in its time, and is still a respectable choice for any application that needs a lot of horsepower, but not a complete Linux system. We’ve seen the ~F4 chip pump out 800×600 VGA, drive a thermal imaging camera, and put OpenCV inside a webcam. Now there’s a new, even more powerful part on the market, and the mind reels thinking what might be possible.

Right now there a few STM32F7 parts out, both with speeds up to 216MHz, Flash between 512k and 1MB, and 320kB of RAM. Peripherals include Ethernet, USB OTG, SPDIF support, and I²S. The most advanced chip in the line includes a TFT LCD controller, and a crypto processor on-chip. All of the chips in the STM32F7 line are pin compatible with the STM32F4 line, with BGA and QFP packages available.

As with the introduction of all of ST’s microcontrollers, they’re rolling out a new Discovery board with this launch. It features Ethernet, a bunch of audio peripherals, USB OTG, apparently an Arduino-style pin layout, and a 4.3 inch, 480×272 pixel LCD with capacitive touch. When this is available through the normal distributors, it will sell for around $50. The chips themselves are already available from some of the usual distributors, for $17 to $20 in quantity one. That’s a chunk of change for a microcontroller, but the possibilities for what this can do are really only limited by an engineer’s imagination.

Embed with Elliot: I2C Bus Scanning

A lot of great ICs use I2C to communicate, but debugging a non-working I2C setup can be opaque, especially if you’re just getting started with the protocol/bus. An I2C bus scanner can be a helpful first step in debugging an I2C system. Are all the devices that I think should be present actually there and responding? Do they all work at the bus speed that I’m trying to run? If you’ve got an Arduino or Bus Pirate sitting around, you’re only seconds away from scanning your I2C bus, and answering these questions.

Continue reading “Embed with Elliot: I2C Bus Scanning”

Logging Engine Temperature For RC Models

[Rui] enjoys his remote-controlled helicopter hobby and he was looking for a way to better track the temperature of the helicopter’s engine. According to [Rui], engine temperature can affect the performance of the craft, as well as the longevity and durability of the engine. He ended up building his own temperature logger from scratch.

The data logger runs from a PIC 16F88 microcontroller mounted to a circuit board. The PIC reads temperature data from a LM35 temperature sensor. This device can detect temperatures up to 140 degrees Celsius. The temperature sensor is mounted to the engine using Arctic Alumina Silver paste. The paste acts as a glue, holding the sensor in place. The circuit also contains a Microchip 24LC512 EEPROM separated into four blocks. This allows [Rui] to easily make four separate data recordings. His data logger can record up to 15 minutes of data per memory block at two samples per second.

Three buttons on the circuit allow for control over the memory. One button selects which of the four memory banks are being accessed. A second button changes modes between reading, writing, and erasing. The third button actually starts or stops the reading or writing action. The board contains an RS232 port to read the data onto a computer. The circuit is powered via two AA batteries. Combined, these batteries don’t put out the full 5V required for the circuit. [Rui] included a DC-DC converter in order to boost the voltage up high enough.

Tracking Bitcoin With The ESP8266

[Kendrick] was looking for something to do with an ESP8266 WiFi module, and since he loves Bitcoin and Arduino, the obvious solution was to make a Bitcoin price tracker.

The ESP8266 is a complete microcontroller with a WiFi chip and a few pins for a serial connection. It’s certainly possible to write some firmware for the ESP to get the current conversion rate of Bitcoin, but for simplicity’s sake, [Kendrick] chose to use an Arduino for this project. He’s using a 5V Arduino, and the ESP operates on 3.3V logic, but a few Zeners take care of the logic level conversion.

The code running on the Arduino checks the CoinDesk API minute, parses the JSON coming from the API, and prints the current Bitcoin price to the serial port. For tracking the current conversion rate of Bitcoin, it’s vastly overkill. This project could have a few interesting applications, from hooking up a few seven-segment displays, to an RGB LED mood lamp that keeps track of this magic Internet money.

Embed With Elliot: Shifting Gears With AVR Microcontrollers

Most modern computers are able to dynamically adjust their operating frequency in order to save power when they’re not heavily used and provide instantaneous-seeming response when load increases. You might be surprised to hear that the lowly 8-bit AVR microcontrollers can also switch CPU-speed gears on the fly. In this edition of Embed with Elliot, we’ll dig into the AVR’s underappreciated CPU clock prescaler.

Continue reading “Embed With Elliot: Shifting Gears With AVR Microcontrollers”

Give In To Nostalgia With a Retro Game And Watch

One of the earliest Nintendo products to gain popularity was the Game and Watch product line. Produced by Nintendo between 1980 and 1991, they are a source of nostalgia for many an 80s or 90s kid. These were those electronic handheld games that had pre-drawn monochrome images that would light up to make very basic animations. [Andrew] loved his old “Vermin” game as a kid, but eventually he sold it off. Wanting to re-live those childhood memories, he decided to build his own Game and Watch emulator.

The heart of [Andrew’s] build is a PIC18F4550 USB demo board he found on eBay. The board allows you to upload HEX files directly via USB using some simple front end software. [Andrew] wrote the code for his game in C using MPLAB. His device uses a Nokia 5110 LCD screen and is powered from a small lithium ion battery.

For the housing, [Andrew] started from another old handheld game that was about the right size. He gutted all of the old parts and stuck the new ones in their place. He also gave the housing a sort of brushed metal look using spray paint. The end result is a pretty good approximation of the original thing as evidenced by the video below. Continue reading “Give In To Nostalgia With a Retro Game And Watch”