Microcontroller statistics with a small SRAM footprint

statistics-library-for-microcontrollers

You may know your way around the registers of that favorite microcontroller, but at some point you’ll also need to wield some ninja-level math skills to manage arrays of data on a small device. [Scott Daniels] has some help for you in this arena. He explains how to manage statistical calculations on your collected data without eating up all the RAM. The library which he made available is targeted for the Arduino. But the concepts, which he explains quite well, should be easy to port to your preferred hardware.

The situation he outlines in the beginning his post is data collected from a sensor, but acted upon by the collection device (as opposed to a data logger where you dump the saved numbers and use a computer for the heavy lifting). This can take the form of a touch sensor, which are known for having a lot of noise when looking at individual readings. But since [Scott] is using the Mean and Standard Deviation to keep running totals of collected data over time it is also very useful for applications like building your own home heating thermostat.

On not proving the twin prime conjecture with AutoCAD

As an HVAC engineer by trade, [Carlos Paris] spends a lot of time in AutoCAD designing all those hidden pipes, tubes, and ducts hidden in a building’s rafters. One day, [Carlos] read of an open contest – the prize was over a million dollars – to generate a prime number with a billion digits. [Carlos] misheard this as, ‘a prime number greater than one billion’ and of course said this was a trivially easy task and opened up his favorite tool – AutoCAD – in an effort to discover the largest prime ever. [Carlos] never generated a remarkably large prime, but he did come up with a very, very cool visualization of prime numbers on a number line, as well as a great justification of the twin prime conjecture, a problem in mathematics that has remained unsolved for several generations.

[Carlos] started his investigations into the properties of prime numbers by drawing a series of circles on a number line in AutoCAD. These circles were of diameters of all the integers, and going down the number line, these circles started to have an interesting, chaotic pattern (see above picture). [Carlos] found that whenever two circles intersected, that position was a prime number. It’s really nothing more than a Sieve of Eratosthenes, but it’s a very cool-looking visualization nonetheless.

Looking deeper into his graph, [Carlos] discovered there were certain primes that had another prime number just two places down the number line. For example, the numbers 3 and 5, 29 and 31, and 41,and 43 are twin primes, as the difference between the primes is only 2. The idea there are infinitely many twin primes is a famous unsolved problem in mathematics – it’s obvious it must be true, but no mathematician has yet come up with a proof of this conjecture.

[Carlos] looked at his number line and simplified it to a generic prime number. By taking a generic number line and overlaying the multiples of other prime numbers on this graph, [Carlos] had a very, very clever way of understanding exactly how twin primes come into existence.

In the end, [Carlos] is no closer to proving the twin prime conjecture than anyone else. We’ve got to hand it to him, though, for nerding out with an engineer’s favorite tool – AutoCAD – and managing to derive some fairly obscure mathematics on his own.

After the break you can see [Carlos]’s videos describing the though process that went into his creation. Very, very cool work.

Continue reading “On not proving the twin prime conjecture with AutoCAD”

Hackaday Links: October 6, 2012

Upgrading a desktop with a diamond cutting wheel

[Michail] needed a new graphics card. The only problem was his motherboard didn’t have any free PCI-E x16 slots available. Unable to find a PCI-E x1 card, he did what any of us would do and broke out the Dremel. Yes, he got it working, but don’t do this unless you know what you’re doing.

It’s recycling!

[Steve] recently got a Galaxy S3 and was looking for something to do with his old phone. It’s got WiFi, it’s got a camera, and with a free app, [Steve] now has an IP Webcam. Neat way to recycle a phone.

This is now bookmarked

We’re not much for plugging other blogs, but Math ∩ Programming – that’s intersection, remember – is really cool. Apparently it has been around for a little more than a year and already there are quite a few really cool posts. How to use cellular automaton to generate caves in video games and facial recognition through Eigenvalues are amazingly in depth, and show the theory behind some really cool techniques. Very, very cool.

Troll Physics: now wireless!

Remember [Fredzislaw100], the guy who puzzled the Internet with impossible circuits? He’s back again, this time with wireless LEDs. We’re guessing something similar to an induction charging system in the battery clip, wirelessly coupled to something under the paper, and that is wirelessly coupled to the LEDs. Your guess will probably be better than ours, though.

Not shown: Captain Obvious, Major Major

Pv2 [Zachary Ricks] of the U.S. Army thought we would get a kick out of the last name of one of the guys in his company. Yes, it’s ‘Hackaday,’ and yes, it’s a real surname. Here’s the full pic [Zach] sent in. Apparently it’s a name along the lines of ‘Holiday.’ Honestly, we had no idea this was a real surname, but we’re thinking Private Hackaday could use a care package or two (dozen).

Anyone up for sending a few hacker friendly (for [Zach] and a few other guys) care packages? Even socks or books or Oreos would make for an awesome care package. Email me if you want the mailing address.

Calculating Pi to 10 Trillion Digits; the last number is 5

In August, 2010, [Alexander Yee] and [Shigeru Kondo] won a respectable amount of praise for calculating pi to more digits than anyone else. They’re back again, this time doubling the number of digits to 10 Trillion.

The previous calculation of 5 Trillion digits of Pi took 90 days to calculate on a beast of a workstation. The calculations were performed on 2x Xeon processors running at 3.33 GHz, 96 Gigabytes of RAM, and 32 Terabytes worth of hard drives. The 10 Trillion digit attempt used the same hardware, but needed 48 Terabytes of disk to store everything.

Unfortunately, the time needed to calculate 10 Trillion digits didn’t scale linearly. [Alex] and [Shigeru] waited three hundred and seventy-one days for the computer to finish the calculations. The guys used y-cruncher, a multithreaded pi benchmarking tool written by [Alex]. y-cruncher calculates hexadecimal digits of pi; conveniently, it’s fairly easy to find the nth hex digit of pi for verification.

If  you’re wondering if it would be faster to calculate pi on a top 500 supercomputer, you’d be right. Those boxes are a little busy predicting climate change, nuclear weapons yields, and curing cancer, though. Doing something nobody else has ever done is still an admirable goal, especially if it means building an awesome computer.

Tilt compensation when reading a digital compass

If you’re familiar with using a compass (the tool that points to magnetic north, not the one that makes circles) the concept of holding the device level makes sense. It must be level for the needle to balance and rotate freely. You just use your eyes to make sure you’re holding the thing right. Now think of a digital compass. They work by measuring the pull of a magnetic field, and have no visual method of showing whether they’re level or not. To ensure accurate readings you might use an accelerometer to compensate for a tilted magnetometer.

The process involves taking measurements from both an accelerometer and a magnetometer, then performing calculations with that data to get a true reading. Luckily the equations have been figured out for us and we don’t need to get too deep into trigonometry. You will, however, need to use sine, cosine, and arctangent in your calculations. These should be available in your programming language of choice. Arduino (used here) makes use of the avr-libc math library to perform the calculations.

Snow Leopard ditches real math for fake

snow_leopard_fake_math

We’ve always felt that hard drive manufacturers were dirty crooks because of their use of fake math to make drives sound bigger than they actually are. Here’s a quick refresher for those who need it: Because digital information consists of 1’s and 0’s (two possible settings), digital architecture revolves around powers of 2. Long ago, when nomenclature was setup for measuring data the term kilobyte was adopted to represent 2 to the 10th power bytes (base 2, aka real math). The problem here is that 2^10= 1024 and when laymen hear the root “kilo” they think 1000 which is 24 byes less (base 10, aka fake math). So, if you have a 500,000,000 byte drive, base 10 math would call that a 500GB drive, but base 2 math would call that 476.8GB.

We understand why hard drive manufacturers use the base 10 system; larger sounding drives sell better. Now we find out that OSX 10.6 Snow Leopard is using base 10 math to calculate storage space. While base 2 math is the standard storage measurement for operating systems it may at first be difficult to understand why Apple would change to a base 10 system. But think about it once more, doesn’t Apple have a lot to gain if all the storage-containing-hardware they sell sounds bigger than it actually is?

[via Gizmodo]

Update: Force Snow Leopard to calculate storage in base 2 [via Gizmodo]