Wednesday, May 13, 2015

Motion sensor to detect sneaking toddler

Once the kids are asleep at night, you can finally relax. Aahh. Maybe you want to stress down with a violent splatter movie with the volume at 11? In this situation you definitely do not want the kids to sneak around in the house behind you and watch the movie in secrecy. In that case you will have a lot of explanation to do. (Dad? What happened to the man's brain?). Or maybe you and your spouse are in your bedroom making new kids..? You definitely do not want the existing kids to interrupt such a beautiful moment. And difficult questions could possibly be asked.

The trick is to use a motion sensor outside the toddlers bedroom and a portable doorbell with visual and audible alarm. All possible crisis is henceforth avoided.



I bought one of these Nexa doorbells, and a...


... Nexa IR detector.

The problem with the doorbell is that is also chimes when someone are walking around in the house during daytime. It also chimes to loud for the intended purpose. Therefore, I added a volume control, that also serves the purpose as a on/off switch.


The doorbell is a simple design built around a 433MHz receiver


A 100k audio pot for the junk box does the job. I also tried with some resistors to limit the 100k pot with mixed success. It does not matter much for this purpose.


I drilled a hole in the front panel, and ...


Voila. A doorbell with a nice blue LED and fully adjustable volume with a Moog style knob. I glued some eyes to the doorbell to make it seem a bit more friendly.

Thursday, April 23, 2015

Pregnancy countdown device with Arduino

Once you or your spouse gets pregnant, thats all that matters in life. You immediately starts to count down to due date and you constantly want to know the current weight and length of the baby. And trust me; you do not wish to use a freakin iPhone app for that. You (and your baby) deserve a dedicated device for the job!

This is what you are waiting for

I hereby present my pregnancy countdown device. I built this a couple of years ago, and the baby whose due date was steadily counted down with this one is now a walking and babbling toddler. This is a simple weekend project that you can assemble with junk-box parts and an IKEA picture frame.


2 days and 22h to due date. You better pack the bag!


You are in week 40 and the baby is now 51.5 cm!


You are in week 40 and the baby is 3558 grams.



The device switches between due date countdown, baby length, baby weight and the current time (above) with 5 seconds on each.





The device is based on a Arduino UNO R3, a DS1302 real time clock and a 8-digit 7-segment display. The DS1302, and four buttons are soldered on a prototyping shield. The Arduino and the display are "glued" to the IKEA picture frame with sugru. I used an exacto knife to cut a hole in a 10x15cm picture and used an old 35mm film strip as a bezel for the 7 segment display diodes.

The buttons were initially for setting the due date, but I did not care to implement that in the software. Hardcoding is sufficient for this purpose (depending on how many kids you are planning of course).

The core of the code is basically to calculate the length and the weight of the baby given a specified due date. For any day the weight and the length can be interpolated from the tables below (showing weeks). The length (in cm) and weight (in grams) are average values for northern european babies. If all your meals are pure butter and coke during pregnancy (it can happen), you mileage may vary.

double lengthTable[] = {0,
0,
0,
0,
0,
0,
0,
0,
1.6,
2.3,
3.1,
4.1,
5.4,
7.4,
8.7,
10.1,
11.6,
13,
14.2,
15.3,
16.4,
26.7,
27.8,
28.9,
30,
34.6,
35.6,
36.6,
37.6,
39.9,
41.1,
42.4,
43.7,
45,
46.2,
47.4,
48.6,
49.8,
50.7,
51.2,
51.7,
51.5,
51.3};

int weightTable[] = {0,
0,
0,
0,
0,
0,
0,
0,
1,
2,
4,
7,
14,
23,
43,
70,
100,
140,
190,
240,
300,
360,
430,
501,
600,
660,
760,
875,
1005,
1153,
1319,
1502,
1702,
1918,
2146,
2383,
2622,
2859,
3083,
3288,
3462,
3597,
3685,
3717,
3717,
3717,
3717};

Wednesday, April 22, 2015

10 Great Audio Books for Makers and Geeks

Disclaimer: The DIYcrap blog is meant to be exclusively about crap that I am making. This post is going to be one rare exception to that rule.

I am a sucker for inspirational and geeky audio books. Although there are tons of excellent non-ficion books on paper or as e-books, not all of them are that good when transferred to audio. Some audiobooks are, however, really good and can make a boring commute become the most inspirational time of your day. This is a non-prioritized list of some of the best audio books about making, geeking, nerding (whatever) that I have heard during the last two years.  They are all positive, refreshing and inspirational, and explains why new inventions in technology make the world progress towards a better place. These books are perfect if you are fed up with all the negative news stories telling you the world is going to hell and that we are soon going to die from the melting polar ice, hunger or terrorism.

Enough said. Lets begin with the list, emphasizing again that the list is not prioritized.

1: The Second Machine Age: 

Work, Progress, and Prosperity in a Time of Brilliant Technologies




Written by: Erik BrynjolfssonAndrew McAfee
Length: 8 hrs and 49 mins
Published: 2014

The book explains how digital technology dictates changes in the economy. The authors give many examples on different technologies that contributes to this change, such as robotics, 3D-printing, artificial intelligence and autonomous vehicles. The thesis of the book is very good, but on the negative side, the book is very similar to "The race against the machine" written by the same authors. If you have read (or listened) to the previous book, you can skip this. If you have not read the first book, you should choose "The second Machine age" as it is more updated.


2: Stuff Matters: 

Exploring the Marvelous Materials That Shape Our Man-Made World




Written by: Mark Miodownik
Length: 6 hrs and 34 mins
Published: 2014

This book is all about materials science. The author goes into detail about the history behind some key materials and the impact they have in our everyday lifes. Materials such as glass, steel, plastic and chocolate are explained with lots of humour and with interesting stories. If you have forgotten absolutely everything from your chemistry classes this book can reboot your interest in that direction. 


3: The Innovators: 

How a Group of Hackers, Geniuses, and Geeks Created the Digital Revolution





Written by: Walter Isaacson
Length: 17 hrs and 28 mins
Published: 2014

This book describes the fascinating history of the computer and electronics age. Among the heroes whose lifes and work are described are Ada Lovelace, Charles Babbage, Grace Hopper, Howard Aiken, Steve Wozniak, Steve Jobs and Bill Gates. It is obvious already in the first pages that Walter Isaacson does not like the romantic illusion of a lone inventor often described in biographies. He rather advocates that collaboration between different people is the main driver behind innovation. Overall, the book is really great, it is well written, and it goes through the whole history of information technology.


4: iWoz: 

How I Invented the Personal Computer and Had Fun Along the Way




Written by: Steve Wozniak, Gina Smith
Length: 9 hrs and 12 mins
Published: 2007

The books is told by Steve Wozniak about Steve Wozniak. In fact, the whole book is about Wozniak. Wozniak, Wozniak, Wozniak. As you probably can tell, there is a lot of bragging self-centered Wozniak in there, but who cares? Wozniak is an electronic genius, and he knows it. Although the book is badly edited, there are lots of interesting stories in here.

Walter Isaacson claims in Innovators (above) that Steve Jobs and Steve Wozniak were equally important in making Apple a big success. It might be true from a business point of view, but Wozniaks romantic story of creating a working computer sitting on his own is of no doubt the more interesting story of the two (at least from a geeky point of view).


5: Abundance: 

The Future Is Better Than You Think




Length: 10 hrs and 22 mins
Published: 2012

This book advocates that mankind could not only be causing all problems we face on earth, but we can also do something about these problems. Thanks to recent developments within digital technology, material technology and so on, we can actually improve the life of all people with water purification, diagnostic apps, new means of food production, renewable energy etc. If you are tired of all negative news stories telling you the earth is going to hell, this book will bring the optimist out in you.



6: The Long Tail: 

Why the Future of Business Is Selling Less of More




Written by: Chris Anderson
Length: 8 hrs and 1 min
Published: 2006

This book is already a classic. You can read more about Chris Andersons concept on his web-page, and he explains it like this: "The theory of the Long Tail is that our culture and economy is increasingly shifting away from a focus on a relatively small number of "hits" (mainstream products and markets) at the head of the demand curve and toward a huge number of niches in the tail."

Most of Chris Andersons predictions in this book has already come true, and it might seem somewhat outdated. However, the main thesis still holds, and it is well written, and highly recommended.


7: Automate This: 

How Algorithms Came to Rule Our World



Written by: Christopher Steiner
Length: 7 hrs and 41 mins 
Published: 2012

Although the statement that algorithms "came to rule our world" is very exaggerated, the book has some interesting stories. Most of the use of algorithms described in the book is from Wall street, and there is no doubt that algorithmic trading has changed the way Wall street and that part of the economy is working (or not working). I would not use this book to teach people about algorithms. Novices might even be scared to believe that algorithms are, in fact, taking over the world. But as pure entertainment, this book is recommended.



8: Makers: 

The New Industrial Revolution



    Another book of Chris Anderson made it on my list! This book is about how 3D-printers, laser cutters, digital fabrication, Kickstarter, Arduino and the new DIY/Maker-movement is altering how businesses are created and run, and how the digital age also influences the production of physical stuff (i.e., bits and atoms). 

    Anderson believes that we face a new industrial revolution, and that the new tools and production processes can offer a way for USA and Europe to incource production of physical objects from China. He might or might not be true about this thesis. It does not matter for me. The book is full of optimism about the future and it just makes me want to make stuff right away.



    9: What If?: 
    Serious Scientific Answers to Absurd Hypothetical Questions




Written by: Randall Munroe
Length: 6 hrs and 36 mins
Published: 2014

This book is full of humor and hard facts. It provides answers to questions like "What is the farthest one human being has ever been from every other living person? Were they lonely?", and "What if you tried to hit a baseball pitched at 90 percent the speed of light?", or  "How fast can you hit a speed bump while driving and live?" and " If there was a robot apocalypse, how long would humanity last?". If you have ever read (and understood) Randall Munroe’s iconic webcomic xkcd.com, this book is for you. The book makes you proud that you enjoyed physics and chemistry classes all those years ago while the other kids hated them.


10: Bold: 

How to Go Big, Make Bank, and Better the World




Written by: Peter H. Diamandis, Steven Kotler
Length: 9 hrs and 6 mins 
Published: 2015

This book is written by the same authors that wrote Abundance in 2012. It is sort of an update of this book and sort of isn't. It is mainly a motivational book for business people wanting to understand exponential technology. For an inventor or engineer, it can be quite irritating reading a book that constantly talks about going big, bold and make a billion-dollar company.  Unfortunately, most of the stories and examples in the book are well-known and does not bring anything new to the table.

The book is narrated by one of the authors, Steven Kotler. A very bad idea. Although the book is very optimistic in its style, the narration seems very monotone, negative and depressive. It is as if he is just about to jump off a cliff. Why am I even bothering to recommend this book? Well, it is about creating businesses that changes the the world, it is optimistic, and makes me want to be an entrepreneur.


Tuesday, April 14, 2015

Script for downloading all Popular Electronics magazines

The great page http://www.americanradiohistory.com/ has got loads and loads of old radio and electronics magaizines for download. Among these are the venerable Popular Electronics magazine which was published between October 1954 and October 1982. These old magazines are really great, not only for historic reasons and for fun, but there are also lots of electronic circuits, loadspeaker designs, and more in there that you can still build directly from the articles or you can use them as inspiration for new projects.


The most famous issue is probably the January 1975 issue presenting the Altair 8800 computer kit. Now you can build your own based on the original instructions :-)

I have made a simple Python script that downloads all the 337 isssues of the Popular Electronic magazine. The script is based on a script from Peter B. Mark that downloads all 73 ham radio magazines from arxive.org (btw, a highly recommended magazine).

Using the script, I can read through all the editions on my iPad even when I am offline, for example when I am waiting for my flight on an airport with nothing else to do and no WiFi.

Disclaimer: The whole bunch of magazines will occupy about 3.5GB of disk space. Furthermore, the naming of the directories on americanradiohistory is not concise, so the script might seem a bit crappy. But it works! Feature: If you exit the script while it runs, it will not download previously downloaded magazines when you restart. Good luck.

#!/usr/bin/python
"""
Download pdfs of Popular Electronics Magazine

"""
import os
import urllib2
import urllib

START_YEAR = 1954
END_YEAR = 1982
OUTPUT_DIR = "PopularElectronics"

MISSING = ('PopularElectronics/Pop-1954-01.pdf', 'PopularElectronics/Pop-1954-02.pdf', 'PopularElectronics/Pop-1954-03.pdf', 'PopularElectronics/Pop-1954-04.pdf', 'PopularElectronics/Pop-1954-05.pdf', 'PopularElectronics/Pop-1954-06.pdf', 'PopularElectronics/Pop-1954-07.pdf', 'PopularElectronics/Pop-1954-08.pdf', 'PopularElectronics/Pop-1954-09.pdf')


def main():
    if not os.path.exists(OUTPUT_DIR):
        os.mkdir(OUTPUT_DIR)
    downloadPopMag("Pop")
    downloadPopMag("Poptronics")

def downloadPopMag(prefix):
    for year in range(START_YEAR, END_YEAR + 1):
        for month in range(1,13):
            fileName = "%s/Pop-%d-%02d.pdf" % (OUTPUT_DIR, year, month)
            if not os.path.exists(fileName) and fileName not in MISSING:
urlyear = year - 1900
tenyear = urlyear - (urlyear % 10)
strtenyear = str(tenyear) + "s"                
if(urlyear > 69):
urlyear = year

editionString = "%s-%d-%02d" % (prefix, year, month)

url = "http://www.americanradiohistory.com/Archive-Poptronics/%s/%d/%s.pdf" % (strtenyear, urlyear, editionString)
                print("Downloading: %s..." % url)
                print("To: %s" % fileName)
                try: pdfData = urllib2.urlopen(url).read()
except urllib2.HTTPError as e:
# Probably wrong prefix. Try with the other prefix later
print e.code
else:
                outFile = open(fileName, "wb")
                outFile.write(pdfData)
                outFile.close()
            else:
                print("Skipping: %s" % fileName)


if __name__ == "__main__":
    main()





Monday, March 23, 2015

Receiving JT65 with RTL-SDR

A couple of weeks ago I bought a RTL-SDR (software defined radio receiver) dongle with the 820T2 tuner chip. You just cant beat the fun/price ratio on this one. For 11$ (with free shipping) it is a bargain, and it is a great way to learn about radios (at least the reception part).

A bargain on AliExpress

Initially I used Gqrx on my Mac to communicate with the RTL-SDR, but eventually I had to resort to SDR# on Windows 7, as it has a bit more features. I have the impression that most radio (and ham-stuff) is made for Windows rather than Mac or Linux.


Apparently not much activity on 10m, but JT65 lurks there in the noise
Even with the standard antenna I had no problem receiving FM broadcast between 88-108 MHz, DAB around 200 MHz, some public transport transmitting FM on 151 MHz and some sporadic narrow FM around 140 MHz. I could also see that there was a lot of activity on 434 MHz and 868MHz bands from car keys, weather transmitters, baby calls and so on.

A few JT65 signals in the WSJT-X waterfall
However, what I really wanted to receive was amateur radio digital modes JT65 and PSK31 on the HF bands (preferably on 10m and 20m). I made a half-wave dipole for the 10m band (28MHz), and soldered the coax directly on the board. The RTL-SDR seem very noisy on HF and all I got initially was a weak RTTY signal on 10 m (which I was unable to decode), and a brief SSB-reception. I guess that one reason for the bad performance is that the strong FM broadcast signals on 88-108MHz interferes with the lower frequency bands.

Receiving JT65 in WSJT-X

However, after a bit of tweaking with the audio levels in SDR# and WSJT-X, I was able to receive some JT65 messages. It was incredibly fun to receive signals from Spain, Russia, South Africa and Brazil (among others) on this 11$ stick and my home-made dipole antenna. (Now I finally understand what the amateur radio people are so intrigued about.)

Received JT65 on 10 m from ZS6KMD in South Africa (9715km)
JT65 on 10m from PY2RED in Brazil (10550km)

Obviously, there are some improvements that can be done with the RTL-SDR to help HF reception. A FM-broadcast bandpass filter would eliminate the interference from the strong FM broadcast transmiters. As I am mainly interested in HF, and do not care about the performance above 30MHz, a simple low-pass filter at 30MHz will probably also do the trick.  Better shielding and filtering on USB can also help. Many folks are also using an upconverter, for example the Ham-it-up, which is undoubtedly the way to go to improve HF sensitivity.

Although I might try to improve HF reception on the RTL-SDR later, I will rather go building a Softrock RXTX SDR Tranceiver. The said kit is already on my workbench, and the soldering iron is hot. More to come...

Wednesday, February 25, 2015

DIYcrap audio mixer #3. FV-1 Reverb

This is part 3 of "building an audio mixer with effects". For part 1 go here, and for part 2, go here.



The mixer is working fine, and already has got two PT2399 circuits for delay. But now it is time to add some reverb. For reverb I decided to use an FV-1 based design. Experimental Noize has some nice small boards built around this chip, preprogrammed for different purposes. I decided to go for the SKRM-C8-R02 Mono-In/Stereo Out reverb and delay module.


I wanted to use a rotary switch to select between the different programs. The SKRM data sheet proposes to use a 74HC148 8 to 3 Line Priority Encoder for this purpose. Hence, there is a need for a small PCB to mount the SKRM and the 74HC148 (in addition to some additional components). Although I have used KiCad and OSH Park for PCB production previously, I wanted to test Fritzing for this small project.



I drew a quick diagram in Fritzing, swithced to PCB-view and the auto-router took care of the rest (at least most of it).


After a about ten days the card arrived in my mailbox.


The board came out quite nicely. Although I am very satisfied with the result, I do not think I will use Fritzing for my next project. OSH Park and other alternatives are way cheaper, and I think the Fritzing software is a bit limited compared to Eagle or KiCad (and even if the Fritzing-software is very simple to use, Eagle and KiCad are not that difficult to learn). The files are available at the Fritzing-site in case you are interested.


It took about 10 minutes to add the few components :-). It is only a 74HC148, a capacitor and a pull up resistor network.



Then I slammed the SKRM on top of it, soldered the connectors, and started jamming with some heavy reverb. But wait, I forgot one thing, namely to securely mount the PCB inside the mixer. A simple solution is to screw standoffs to the front panel, but the screws would interfere with the front panel design. I could also glue the standoffs to the front panel, but I just hate to glue things together when there is a slight chance that I might want to dismantle it later.



Hence, I created a plate to screw the PCB standoffs to, that is fastened with the rotary switch. It is designed in OpenSCAD and 3D-printed.


The above picture show how it looks like inside the mixer. Notice that the plate (in pink) is fastened together with the rotary switch.



The above picture show how the mixer looks like inside. The SKRM is driven by a LM7805 which is connected to the +12V rail (the blue heatsink can be seen on the bottom part of the picture). The circuit draws about 170mA, even if the data sheet states it should be less than 75mA. The reason? I do not know.



DIYcrap mixer. Now with reverb.

Monday, February 2, 2015

Building an enclosure for Mutable Instruments Shruthi-1

About a year ago I ordered a Shruthi-1 PCB and a Four Pole Mission PCB from Mutable instruments. After sourcing the components, it was a quick and enjoyable build. The synth has, however, been sitting in my drawer for a long time waiting for an enclosure.



First, I thought of buying the metal enclosure from Mutable Instruments. Besides the fact that the metal enclosure costs ¢55 (not a bad price, but still), I had, due to financial reasons, used different buttons than those recommended my Mutable Instruments. Since I had no intention to change those, I had to make my own enclosure.


Before bragging about my design I have to inform you that there is an excellent downloadable enclosure out on Thingiverse:284637. I tried it, but I just could not get it to print nice on my small RepRap Huxley.


I used OpenSCAD since it is Open Source and pretty nerdy. The box is pretty simple (and boxy), but takes only a couple of hours to print and consists of only three parts.


I created small cylinders for the LEDs. In this way they are highly visible on the front panel although the PCB is about 10mm below the panel. The cylinders also ensures that there is no light leakage from one LED opening to the next.


The final case looks ok. However, the Shruthi is not the easiest synth to use, at least when none of the buttons are labeled in any way. Therefore, I waned to create a panel with labels on.




Using the command "projection(cut=false)", the 3D drawing of the front panel can be converted to 2D. Then it is possible to export a DXF-file which can be imported in Inkscape. I learned this technique from this blog.


Once imported in Inkscape, I can create some text and stuff on the front panel. I used the same approach as I did on my mixer, and printed the front panel on some piece of colored thick paper.


Before laminating the paper, I cut out the opening for the display with an exacto knife and punched 3mm holes for the LEDs with a drill bit.



I had to extend the buttons with some Sugru to make the hight appropriate for the front panel. Looks a bit strange, but it works surprisingly good.




This is the final unit. You can download the design files on thingiverse if you like, and hack the heck out of it. The OpenSCAD-file is parametrized and it should be fairly easy to alter the design for whatever buttons you might have.


Here goes some additional pictures.

The front panel is secured with the nuts on the five potmeters.


The back plate is secured with the plastic nuts on the audio jacks.