“Any one who considers arithmetical methods of producing random digits is, of course, in a state of sin.” – John Von Neumann, 1951
Here is the finished device, turned on and displaying the number 4.
I’ve blogged previously about the development process for my latest project, an artificial die designed for die-based Role Playing Games. When I started this project, I had several design goals in mind: I wanted it to be extremely small and easy to carry, yet have 6 buttons to “roll” each of the standard sizes of die (D4, D6, D8, D10, D12, and D20). I also wanted it to based on a Random Number Generator (RNG) implemented in hardware instead of using the built in pseudo-random number generator. As those who have been watching the Show And Tell will know, I’m proud to say that I’ve succeeded. If you’d like to see it in action, a short demo video is available here..
My first step was to learn as much as I could about the Random Generation process, so I could design my own generator. As described previously, I found an open source design that I was able to implement. In this design, the Zener Effect of a 1.22V Zener Diode is used to generate Avalanche noise, which is then amplified through a 2n3904 NPN transistor and a pair of high-speed Op Amps, then delivered to the Microprocessor as a digital input. The microprocessor implements a debiasing algorithm known as the Von Neumann corrector to take the input noise distribution, which could have an uneven balance of 0s and 1s, and turn it into an even distribution of 0s and 1s. When the conditions of the corrector are met, the new random bit is mixed into a 32 bit number. Since this is implemented within a timer interrupt that triggers every 32 microseconds, the random number is updated extremely quickly. If you want to learn more about the RNG support circuitry or the software, check out the source files for this project. The Hardware process is described on the Schematic, and the software process is documented within the source code.
This is the rear side of the Electronic Die, with all of the circuitry shown.
To check that this device worked properly, I sampled the D20 option 250 times, and performed a Pearson’s Chi-Squared test based on the null hypothesis that the source data is uniformly distributed. Suffice it to say, it passed, and I could not reject the null hypothesis. I also borrowed the method of testing from the original designer of the RNG hardware, so if you’d like to look at the precise statistical methods, feel free to check them out here.
This is the output Frequency Histogram for 250 rolls of the electronic 20-sided die.
Because I wanted the device to be easy to use, I selected a two-digit seven-segment display, and found small tactile momentary switches to use for the UI. Since I wanted this project to be as small as possible, I decided to use Surface Mount devices for the RNG components and microprocessor and put them beneath the seven-segment display, on the underside of the board. I selected the Atmega8 to keep the LED driving simple (it has enough pins to drive both digits simultaneously, to keep the input switches on as few pins as possible (I’m using a resistor ladder, and an ADC to read the result), and to have a small package to fit within the .6” spaced rows of pins on the seven-segment display. Because I was able to place all of the components (besides the switches and display) on the underside of the board, the top of the device is clean and simple and the PCB is kept to 1.1” x 1.25”, small enough to easily attach it to a 2xAA battery pack. Since the batteries would run out in under 10 days due to the high (~10mA) quiescent current use of the ADC and RNG circuitry, a simple power switch is included to turn power to the whole device on and off. At one-off prices, all of the components can be bought for about $10. The PCB is small, so if you buy from Laen over at DorkbotPDX (Who, by the way, awesomely accepted several last-minute design file changes, on a weekend no less) it’s about $7 for 3 boards.
In short, this is a simple, easy to use artificial die. When a button is pressed, the machine generates a random number in the appropriate range, displays it on the screen for several seconds, and then turns off the display. If you use this device, you don’t have to worry about carrying around a bag of dice, finding an even rolling surface, or losing a die. And in the process, I learned about Hardware RNGs, and designed my first mostly surface-mount PCB. And again, thank you to Leon Maurer for laying a lot of the groundwork for the design of the RNG. This project is released under the CC BY/SA License, and the design files are available at my github page.
Is there a clean way for an Arduino to cut its own power?
I’m hacking into an existing circuit that is battery-powered, and I would like to be able to, say, reset the microcontroller, which then waits for some kind of input from the hacked device, and then when it’s done processing, it turns itself off (to save batteries on the host circuit).
Absolutely! And its quite easy to do when you use some of the lower level functionally of the Arduino’s AVR. Most micro controllers contain a piece of hardware called a Watchdog Timer which, when enabled, will perform either a hard or soft reset of the device. The cool thing about utilizing the watchdog on the newer Arduinos (ATMEGA168/328) is that you can actually execute a function after each reset (ATMEGA8s can only perform a hard reset). There are two things you need to do to properly utilize the watchdog. First, when you initialize it, you set the quantity of time the micro controller waits before performing the reset, set in “setup_watchdog(X);.” You can set X to 0=16ms, 1=32ms, 2=64ms, 3=128ms, 4=250ms, 5=500ms, 6=1024m, 7=2048ms, 8=4096ms or 9=8192ms. The second thing you need to do is “pet” the watchdog in order to prevent unwanted resets. By periodically adding “wdt_reset()” to your code, you reset the watchdog’s timer and preventing the reset. This is also a good way of adding stability to your code. If you software hangs, the watchdog with reset the device.
With regards to power consumption, you are in luck. If properly utilized, the Arduino can draw mere micro-amps when put to sleep. This sleep function, when paired with the watchdog, can result in a very low power and stable device. There are approximately 5 sleep modes that dictate which functions are put to sleep and are detailed in the AVR doc. When I set my Arduino to POWER_DOWN mode, I measured only 20.7uA at 3.3V .
There is a good page on Arduino’s site that demos the sleep functions.
The service is the backbone of a mailing and shipping industry that employs more than 8.5 million people and supports almost $1 trillion in economic activity every year. The service itself employs 574,000 people.
Nearly every business relies on the post office to deliver packages, advertise services and send out bills. This postal supply chain supports millions of American jobs in fields as diverse as banking, agriculture, media and manufacturing.
Backyard Brains offers a series of exciting and affordable entry‐level Brain Recording Kitsthat provide the ability for students of all ages to learn about neurons.
For the first time ever, school children and amateur scientists will have access to similar tools used by neuroscientists worldwide to study Electrophysiology: the electrical activity of neurons. By following a few simple steps, everyone can experience how the brain is able to communicate our senses, memories, hopes, and desires!
NEW PRODUCT – Optical Fingerprint Sensor, works with Arduino. Secure your project with biometrics – this all-in-one optical fingerprint sensor will make adding fingerprint detection and verification super simple. These modules are typically used in safes – there’s a high powered DSP chip that does the image rendering, calculation, feature-finding and searching. Connect to any microcontroller or system with TTL serial, and send packets of data to take photos, detect prints, hash and search. You can also enroll new fingers directly – up to 162 finger prints can be stored in the onboard FLASH memory. There’s a red LED in the lens that lights up during a photo so you know its working.
Sometimes the full breadth of the conversation around Science, Technology, Engineering, and Math (STEM) education is hard to take in all at once. For this reason, Teach.com has put together an infographic highlighting the beginnings of the STEM focus in America, the decline in STEM interest, and it’s recent resurgence as we strive for global competitive advantage through mastery of STEM research and education. Share this infographic with others to help us highlight the continued need for a serious focus on STEM teachers and STEM education.
Following an International Visiting Artist Fellowship, Jessica was awarded an Arts Council Wales and Wales Arts International grant to undertake a research and development project at Urban Glass, New York. Collaborating with internationally renowed glass artists and neon specialists she produced new sculptural anatomical neon artwork inspired by biological electricity, the prescence of natural electrical activity in the human body.
Blown glass human organs encapsulate inert gases displaying different colours under the influence of an electric current. The human anatomy is a complex, biological system in which energy plays a vital role. Brain Wave conveys neurological processing activity as a kinetic and sensory, physical phenomena through its display of moving electric plasma. Optic Nerve shows a similar effect, more akin to the blood vessels of the eye and with a front ‘lens’ magnifiying the movement and the intensity of light. Heart is a representation of the human heart illuminated by still red neon gas.Electric Lungs is a more technically intricate structure with xenon gas spreading through its passage ways, communicating our human unawareness of the trace gases we inhale in our breathable atmosphere.
Keeping with our recent all-multirotor all-the-time theme, it’s time for another how-to post! Plans are afoot, and scheming has been schemed. The flying robot skeletons have been piling up in a corner of the workshop, and after several revisions we’ve narrowed down the design to something worth sharing.
A QR code, or Quick Response code is a somewhat new technology that, when scanned by a smart phone or iPad app, takes you to a website or texts you with more information about a product. You see them everywhere now, from cereal boxes to bus stops. From the moment Jake got his new phone, he was obsessed with them. I remember he used to talk about how production at Spoonflower could be more efficient if we could just walk around scanning QR codes to look up orders and find out information about rolls of fabric. As for me, I just liked how they resembled little patchwork quilts. So when the staff challenge was announced, the idea of making a QR code quilt seemed perfect.
Our first step was to pick our QR code. Every web page has a corresponding code, so we had a lot of silly ideas about what site to choose. For loyalty’s sake we chose Spoonflower and with a simple free online code generator, Jake was able to print out an image of the QR code for the Spoonflower site. We used this as a guide for our quilt.
We added it to our QR section, which is growing at a steady clip. Got a QR project we haven’t seen? Post a link in the comments.
When I started this, as can be seen in the image below, the case was two parts that fit together in a semi-complex manner (Actually, the very first version just had a little plastic square that covered the AVR, but nothing else). It was hard to print with any quality and, frankly, the front looked awful. So I simplified it such that the IR LED could stick out a small hole, as seen in the middle. But then it dawned on my that the translucent plastics might just be transparent enough to IR that no hole was needed at all. And sure enough, it just worked! Thus, the design is now even simpler (assuming you have translucent filament).
For the construction of the prototype, I cut long strips out of the bars and installed plastic tubing on the inside of the bars to help keep them rigid. I then installed approximately 40 high-efficiency LED bulbs in the inner plastic tubing, and installed a momentary actuator button on the back of the bars. The whole system runs off of a watch battery.
After the test of the prototype GLO-BARS, I realized that the installation of the lights significantly weakened the structural integrity of the handlebars. I am currently attempting to create a solution that would restore the rigidity of the bars.
Although the bars were weak, they were extremely bright. I had no doubts about how visible I was to drivers and felt very comfortable while riding my bicycle at night.