Most toolchains for embedded system include support for random number generation. But if you’ve read the manual you’ll know that this is really just pseudo random number generation (PRNG). When calling this function the same numbers will always return in the same order unless a different random number seed is supplied in advance. [Gardner] put together a simple and cheap solution for deriving better random number seeds. He reads a voltage from a 555 timer using the ADC on the microcontroller. At first glance it may not seem like a great source of randomness, but he performed some testing and the results look quite promising.
The project is aimed at Arduino-based circuits, but any chip with an ADC will work. The 555 timer is used as a free running oscillator. We know that this not be very stable when compared to even the worst of crystal oscillators, but that’s what makes it work so well as a random seed source. Add to this the low parts count and small size of the additional circuitry and you’ve got a winning combination. So keep this in mind when you need a random number but don’t necessarily need rock solid entropy.
[via Reddit and Freetronics]
Much to the chagrin of hardware tinkerers, the Raspberry Pi doesn’t have analog inputs on its GPIO pins. Sure, you can blink a LED with just a few console commands, but reading sensors with a bone-stock Raspi requires a little additional hardware. [Brian Dorey] just released a board that allows for 8 analog inputs on the Raspberry Pi with a 16-bit resolution that is much higher than any Arduino-based build.
[Brian]’s build is based on an earlier, similar iteration of a Raspi analog board we saw last July. Like the previous version, the new professionally made PCBs use a pair of Microchip MCP3428 analog to digital converter. These ADCs are able to sample four channels at a resolution of 16 bits; a vast improvement over the 8-bit ADCs included on every Arduino.
The boards communicate with the Raspberry Pi over an I2C serial bus using a neat stackable header. In theory, it should be possible to use several of these boards and measure dozens of analog channels, but we’ll leave a demonstration of that up to [Brian].
We think it’s a great learning experience to tear back the veil of abstraction and learn a bit more about the hardware found on an Arduino board. This project is a great example. [Scott Daniels] takes a look at the other voltage measurement options available to AVR chips used by Arduino.
If you’ve used the analogRead() function then you’ve already measured a voltage using the Arduino. But do you know what is going on behind the scenes to make this happen? The Analog to Digital converter on the AVR chip is being used to measure an incoming voltage by comparing it to a known voltage reference. That reference is by default the supply voltage line for the chip. This should be 5V but will only be as accurate as the regulator supplying it. [Scott] looks at the other voltage references that may be used. An external reference can be used by adding hardware, but that’s not the focus of his article. Instead he looks at using the 1.1V internal reference. He’s written some short example code that let’s you measure the incoming line voltage based on that internal reference. This is a very handy trick that can let you detect when the chips is running from a battery and how much juice is left in the cell.
[Chris] continues cranking out the tutorials, this time around he’s showing how to use a CPLD for simple motor control. The demo hardware is pretty basic, he built his own FPGA/CPLD demo board a few years back which used a PLCC socket for easy interfacing. You should be able to use just about any gear you have on hand.
Of course the thing about these chips is that you’re working with hardware that can be run in parallel. [Chris] mentions that this is what makes it perfect for timing-critical applications. Here he’s using a motor driver that monitors a PWM signal, using the duty cycle to actuate the direction and speed at which the motor turns. After the break you can see a demonstration of the CPLD reading from an ADC chip and converting the value to a PWM signal. [Chris] has also used the same hardware for VGA signals; something that is usually a timing nightmare if done with a microcontroller.
If this leaves you thirsting for more CPLD goodness check out our own guide on the subject.
Continue reading “CPLD motor control”
If you’ve run out of I/O pins on a project and need a way to add user input you can find a slew of port expanders that work with various communications protocols like I2C and 1-Wire. But if you just want to add in some buttons without reaching for an extra IC you’ll love this hack. [John Boxall] shows how to add four buttons using one ADC pin.
The concept is nothing new. The buttons make up an R2R resistive ladder. When one of them is pressed, it completes the circuit for a voltage divider. The results are measured by the analog-to-digital converter of an IC to tell which button was pressed. The difficult part is calculating the resistor values. [John] is using eight resistors made up of just two different values. Every button and every combination of buttons has a unique voltage result which can be discerned by the chip. He even made a truth table so you don’t have to.
The example circuit seen in the video after the break uses an Arduino. But this concept is directly applicable to any microcontroller. And it should be quite easy to use an ADC interrupt to drive all of the button-read events. Continue reading “R2R ladder connects multiple buttons to one ADC pin”
[Udo Klein] was working with some 1N4148 transistors and was interested in the specs relating to their performance at different temperatures. The forward voltage actually changes quite a bit depending on temperature and wondered if this could be reliably measured. He hacked his own LED shield for the Arduino to use as a 1×20 thermal imaging system.
The screenshot above is mapping the voltage measurements from a row of diodes (see the video after the break to get the full picture). He’s holding an ice pack over the row of diodes and observing the change. The on-screen display is facilitated by a Python script which is pulling data from the Arduino. Since there aren’t enough analog inputs to read all twenty diodes separately they have been multiplexed. Four I/O pins each enable five of the diodes, readings are taken with five analog inputs before moving on to the next set.
What can this be used for? That is precisely the wrong question… sometimes you’ve just got to go where your curiosity takes you. Continue reading “Reading diodes to create a thermal imaging system”
If you haven’t yet wrapped up your Christmas shopping, you may want to consider building [AlanFromJapan’s] implementation of the ever-classic “Clapper”. With its theme song burned into the brain of anyone old enough to remember the 80s, the clapper was a wonderful device that certainly put the “L” in laziness.
Looking for an excuse to play around with an opamp and microphone [Alan] decided to build his own version of the Clapper based off this similar circuit, which he calls the ClapClap. He built the device using an electret mic that feeds a signal through a small amplifier on the way to the ADC of an ATmega328 microcontroller. The mcu constantly polls the ADC looking for the sound of clapping hands, a solution that works, but isn’t as clean as [Alan] wanted.
He went back to the drawing board, this time building a circuit around an ATtiny2313 microcontroller. Most of the other components remained the same, though the new, smaller design sports some nice PCBs he had made at Seeedstudio. Rather than constantly polling the ADC, this version of the ClapClap looks for peaks in the signal coming from the mic to identify the clapping of hands.
He says that the newer version works great, though he still has a software bug or two that need fixing before he parks himself on the couch for all eternity.