Quantcast
Channel: Hacker News 50
Viewing all articles
Browse latest Browse all 9433

The whistled: how to remake a dozen years old project the right way - Limpkin's blog

$
0
0

Comments:"The whistled: how to remake a dozen years old project the right way - Limpkin's blog"

URL:http://www.limpkin.fr/index.php?post/2013/04/26/The-whistled%3A-how-to-remake-a-dozen-years-old-project-the-right-way


Hey guys
As the slightly changed adage goes: a video is worth a thousand words:

Interested? Have a look at my tindie page or click below to get more technical details...

So, why this project and why now?


I generally get project ideas before looking for components. For the whistled, things were the other way around.
A few months ago, when finding a new 32pins Cortex M4, I got plenty of ideas and the whistled was one of them.
As mentioned in the video, this tiny Kinetis K10 can perform around 80 [q15 2048 points] Fast Fourrier Transforms (FFTs) per second and still give me time to run my own algos.
This is explained by the fact that a Cortex M4 has a Digital Signal Processing (DSP) instruction set which is particularly useful for processing operations, and also because the ARM CMSIS library provides us with already optimized code to perform more complex functions such as FFTs.
As all the ground work was already done, I could actually focus on filter design and whistle recognition algorithms.
This took a lot of time and a lot of testing.

The specs and schematics

Let's start from the ground up:

As you see, the schematics are fairly simple and I find it quite beautiful.
You'll notice:
- a few ferrites (L1/L2/L3) to filter the parasites that may be introduced in the system or made by Q2 switching
- a P-Mosfet (Q1) to prevent reversed polarity connections (I know you guys ).
- a standard 3.3V LDO (U1)
- our main Cortex M4 microcontroller (U3)
- a mosfet driver (U4) with its N-Mosfet (Q2) to allow proper dimming for big loads
- a microphone amplifier with Automatic Gain Control (AGC) (U2), which parameters were quite tricky to set

All the PCB traces you may touch are ESD protected: namely the power supply and the N-Mosfet drain, as all the rest of the PCB is covered by a transparent heat shrinkable tube. I really wanted to idiot proof my design (no offense intended).
Something worth noticing is that the Kinetis K10 has a 16bits timer with PWM outputs, resuling in a wide dimming range.
The platform will allow you to apply from 4.5V to 18V, with a max current of 5A at its input.
You could actually drive up to a 90 Watts load with this tiny 55x13mm board!
And of course, SWD pads are present on the board for you to flash your own program.

The Bill of Materials

Only click if you have a wide screen...

The BoM is not very cheap because of a few design choices:
- wanting to be flexible on the input voltage, leading me to choose more expensive components
- adding extra filtering (the ferrites)
- choosing terminal block connections
- choosing to protect the board from reversed polarity
- choosing low Rds mosfets to prevent the board from heating
I'd like to think that it is the cost of 'perfection', so the boards will work in every possible situation .

The PCB


As you can see, everything is pretty much packed in there.
First prototypes were actually quite a pain to solder, the MAX9814's pins having a 0.4mm pitch.
For ESD protection I had to leave some clearing around the microphone, as the heat shrinkable tubing may not perfectly surround it. On the bottom layer, I also had to split the ground returns between the microcontroller/analog and power parts of the circuit, so the sound amplification may not be disturbed by the switching induced noise.


Final copper thickness is 60um which leads to a 7 degrees temperature rise at 5A for the high current trace.

Hacker-friendliness

As already mentioned, the board is open hardware and has 4 pads for SWD connections (3.3V / 0V / clock / data):


So if you have some funky ideas for this platform, please knock yourself out.
This powerful cortex M4's processing capabilities will enable you to do more than just whistle recognition, and I am pretty sure a lot of these applications could involve party lighting .
You could also implement a "secret sound sequence" to open doors / safes.

The files


Here is everything you'll need to reproduce this work.
This project is open hardware, and I also provide you with all the code except my algorithms as I'm a bit worried of bad quality copies that may appear later on dx-like websites.
The schematics are fairly simple so you may want to make the PCB in the CAD software of your own choice.
When you'll work on the code, all you'll need to do is run your algorithms on the working_buffer variable in the run_recognition_algo function at the end of main.c
Whistle schematicsWhistle gerbersCode templateDatasheetsUser Manual

The algorithm

Due to the number of comments I received, let me explain myself a bit more and also give you the general structure of the current implemented algorithm.
I managed to create a working algorithm but I do believe that some people may be able to make a better one. The algo I made is tied to this platform and more importantly tied to current implementation (two consecutive whistles to switch on/off) so I'm not sure it'd be of any use to those who want to tinker with the platform.
But if you really want to make the algorithm the same way I did, here is what it should do:
- detect two consecutive peaks in the FFT at different frequencies
- check the width of these peaks
- depending how you whistle, control the freq. deviation of the one peak
- check the isolation between the height of the peak and the nearby peaks
- tolerate one or two FFTs without peaks as your whistle seems continuous but actually isn't.
- only allow a whistling frequency range (8 to 46 in the current algo)
The algorithm I made prefers false positives (false detection) to false negatives (no detection when you whistle) as people whistle differently.
So it will actually be easier for you to tailor your code for your whistle rather than be as tolerant as me .

The final word

I really do believe in this project and that is why I took a shot and funded it myself .
This decision was pushed by lots of friends and colleagues that found the whistledeasy to use and very convenient for their home automation setups. If this project is successful, I actually plan to make new families of product based on this principle.
So if you are as motivated as me by this project, I'd really appreciate if you could have a look at my tindie page:
- link for one assembled PCB
- link for one assembled PCB + US AC/DC
- link for one assembled PCB + EU AC/DC
- link for one PCB + US AC/DC + led strip
- link for one PCB + EU AC/DC + led strip

Cheers!


Viewing all articles
Browse latest Browse all 9433

Trending Articles