zondag 18 december 2011

Mystery LED in a box: part 6

see also: Mystery LED in a box: part 0
see also: Mystery LED in a box: part 1
see also: Mystery LED in a box: part 2 
see also: Mystery LED in a box: part 3
see also: Mystery LED in a box: part 4
see also: Mystery LED in a box: part 5

How do you respond to a sentence like the following:

U'2F'UBMU'SI'G'5HY'W'KGZ'W'V'UI'H'B'VCNR'LBW'9UBMV'LI'G'1LDC'B'QDW'XSAW'U'
GBMF'TZ'W'4GZ'W'4GDH'J'VDX'DKY'X'R'1BS'4GQ'MV'3AW'PZI'H'Z'PY'S'B'IBG'9NL'I4UT


Anyone? Nobody? ANYthing? The last clue kept us busy for a few weeks. 
Shortly after presenting the world our latest progress we found a rather scary letter in our mailbox:
 

"All your base are belong to us". Not only one of the most famous internet memes ever but as from now also a big hint to solve our mysterious sentence that should lead us to our wedding gift. Googling it didn't result in a lot of usefull stuff other then a huge amount of odes and also parodies to the subject. After a week of puzzling, googling and trying to tear some usefull information from my friends a little birdy (Thank you!) remerbered my of a mental note that I took during part 2 of the queste. The clue of part 2 ended with the number 64 ("VIERENZESTIG"), which was not intended for that assignment. It seemed a bit lost standing there, but I kept it in mind. Maybe it is usefull here.
Adding '64' to the Google search string 'All your base are belong to us' didn't actually give me something new (except some way too nerdy Microsoft stuff). But hurray, my luck changed when I shortened the string to 'All your base 64'. It showed me various leads to the term 'Base64'. Base64 is an encoding/decoding method that uses a base of 64 characters to encode 8 bit ASCII data. It has various applications and it makes a normal sentence look like it is heavily encrypted. For that it is also used to obfuscate passwords. The Wikipedia site showed with a small example how to decode Base64 encoded data, and manually decoding the first part showed my the first letters of my own name, so I knew I was going the right way. Base64 is not very difficult to encode/decode so there has to be somebody that already made a script for the world wide web. Lucky me!
There was only one thing. Base64 encoding makes a distinction between small and capital letters while Morse code doesn't make this distinction. That was an easy one. It immediately explained the apostrophe ( ' ) characters in the mysterious sentence. A letter followed by an apostrophe means a capital letter, otherwise it is used as a small letter.


"SANNE, NAAI EEN PORTEMONNEE MET JULLIE 
NAMEN EN TROUWDATUM. BEWIJS VIA BLOG..." 

(Sanne (That's my nickname), sew a wallet with your names 
and wedding date. Show the proof via the blog...) 

The assignment is a wink to my wife's hobby: Sewing and other sorts of crafting. In part 2 she had to do some soldering on the mystery box, so now it was my turn. And here is the result... And yes, it is geeky and nerdy!



What's next? 

zaterdag 26 november 2011

Mystery LED in a box: part 5

see also: Mystery LED in a box: part 0
see also: Mystery LED in a box: part 1
see also: Mystery LED in a box: part 2 
see also: Mystery LED in a box: part 3
see also: Mystery LED in a box: part 4

I promised in the previous item to provide an update after my vacation. That was in August! Unfortunately my vacation doesn't take more then 3 months (I wish!). 

It took me quite some time to make the mystery box actually listen to me. I was able to tell it stuff with the IR transmitter that I had to build, but it looked pretty deaf. The last hint I got was a little assigment to tell the box 'something':

"JIPPIE NU KAN IK OOK LUISTEREN. ZEG EENS IETS..."

 I figured out that this 'something' had to be the word 'IETS', which is the dutch word for 'something'. 'IETS' has also the advantage to be fairly easy in morse code. Three dots, one dash and again three dots is all it takes (** *- ***).

Just two weeks ago I found out why me and the box were not on the same level. I made a little mistake with one of the resistors.... 3K3 IS NOT THE SAME AS 33K, IDIOT!
The 2K and 3K3 resistors serve as a voltage reference for the incoming photo transistor signal, and using a 33K resistor resulted in a 4.7V reference instead of the intended 3V.

 

Having that fixed the box and I renewed our vows and we were finally on speaking terms again. Telling 'IETS' to it with IR remote control waked it up and gave me a new sequence of morse pulses. I quickly hooked up my datalogger to log the sequence and let Matlab crunch the data:


"WIE ZIJN JE BESTE VRIENDEN? (IN ALFABETISCHE VOLGORDE)"

Translated: "Who are your best friends? (in alphabetical order)"

Damn, that looks like a tricky question. This really could cost (or gain) me friends... I took the safe road and picked the names of the people that actually contributed to the wedding present.


But some use their real name and others jotted down their nickname in the card. Some of the guys have actually nicknames that are used so often, their real names are already long forgotten (Bart? And who's Frank?). So multiple options here:


Regardless the right answer it promised to be a challenge to send this huge morse code sequence manually, although I realized that is exactly what they did back in the days in WW2. But then they didn't had microcontrollers like we have now so I followed Deddies Labs slogan ("Because anything deserves a microcontroller") and start putting together a morse code generator.



That worked! A little bird had told me in the meantime what the most likely answer was to the friends question, and finally the mystery box gave me the next morse sequence. Again twice as fast as the previous clue which was also double as fast as the one before that....
Inevitably the datalogger needed some more tuning since the last upgrade which boosted up the sampling frequency to a whopping 40Hz (!!!) proved not to be fast enough (C'mon guys, cut me some slack here). I actually compressed the data before storing it to the USB stick and decompressed it with Matlab (I will explain this later on in a different topic). It is now so freakin' fast that I myself don't even now how fast it is. I probably can expect some phonecalls from the CERN...

This clue is probably also the last clue the mystery box will give me, a running led sequence after the hint gives me the impression that its job is finished. I am shedding no tears, it is still electronics and it can't withstand salty water very well:


U'2F'UBMU'SI'G'5HY'W'KGZ'W'V'UI'H'B'VCNR'LBW'9UBMV'LI'G'1LDC'B'QDW'XSAW'U'
GBMF'TZ'W'4GZ'W'4GDH'J'VDX'DKY'X'R'1BS'4GQ'MV'3AW'PZI'H'Z'PY'S'B'IBG'9NL'I4UT


What the hell? Is this my final hint? This is not human readable. No easy "Congratulations, the present can be picked up at the trainstation in locker 1306"? Did I read the morse code right? Yes, I think I did! Did something went wrong with compressing the data or did Matlab had a bad day? Not likely.

Chuckles of recognition of some of my friends gave me definitely the idea that I got the clue right. As you all can understand, more to follow...

see also: Mystery LED in a box: part 6
see also: Mystery LED in a box: part 7 

maandag 8 augustus 2011

Mystery LED in a box: part 4

see also: Mystery LED in a box: part 0
see also: Mystery LED in a box: part 1
see also: Mystery LED in a box: part 2 
see also: Mystery LED in a box: part 3

Days passed by since we fulfilled our last assignment considering the mystery LED box without any news. Did we do it right? Were we missing something? Last week the uncertainties suddenly vanished with a envelop that we found on our doormat.


In the envelop we found some interesting parts: a micro switch, an IR led, and a BP103 phototransistor. I rushed to the website we found in the previous clue and there we found a new briefing. The 'Grande Finale' was about to take of...

Again I had to add stuff to the already pretty stuffed up board and upload a new hexfile to the Attiny. I was asked to build an simple IR transmitter and giving the Attiny the capability to receive IR signals. Instead of one led the board now needed three leds.


The next evening I did my magic and a couple of hours later the mystery box was blinking again...


It started with a running light, followed by 1 minute of sequential blinking of the middle led, finished by the 3rd led turning on and off only once. Nothing after that, you could almost hear the Atmel sleeping :) In the video you can find the BP103 photo transistor in the box on the left.


Diligently I hooked up my ever so useful datalogger! Just before I started recording the new sequence like I did with the previous clues, my attention was caught by the middle led..... Damn! Rat bastards...... the sample rate of the led sequence was definitely faster then 4Hz this time and my datalogger is not capable of recording any faster. And reading the morse code with the naked eye is definitey out of question at those speeds. I knew I should have kept my mouth shut about this bug (or blog about it). Me and my big mouth!


My friends' goal was definitely to slow down the progress solving the mystery box, apparently I was going to fast for them. Now I had to (quick) fix the datalogger first. And we were about to leave for vacation in a couple of days, were I was forbidden to even think of electronics or dream of Atmels. I agreed with myself to speed up the datalogger and get at least the next clue out of the mystery box before packing my bags.

From the datalogger's sourcecode I removed everything unnecessary that could slow down the recording. Wow, I did some realy awful programming two years ago. 4 hours and a lot of deleting and rewriting later I managed to get the datalogger to record with an astonishing speed of at least 40Hz. I didn't try to make it faster, a tenfold increase seemed fine by me. I figured my friends not to be that big of assholes... Luckily I was right. After recording and some minor changes to the Matlab script the next sentence popped up:


"JIPPIE NU KAN IK OOK LUISTEREN. ZEG EENS IETS..."

Like I already suspected with the IR led and phototransistor the box was now capable of also 'listening'. It 'asked' me to say 'something' to him/it. This 'something' I still have to find out. I really have to pack my suitcases now...

As you probably already have noticed, a project like this kind of grows on you. Like my 1 year old son it finally starts to listen and I start to understand its babbling. I hope I won't mix up the two, and find myself poking a soldering iron in my son's eye while the mystery box is getting a bath.

More after my vacation...

see also: Mystery LED in a box: part 5  
see also: Mystery LED in a box: part 6
see also: Mystery LED in a box: part 7

zaterdag 16 juli 2011

Mystery LED in a box: part 3

see also: Mystery LED in a box: part 0
see also: Mystery LED in a box: part 1
see also: Mystery LED in a box: part 2

Still we don't have the contents of the wedding present that was given to us on our wedding party. Along the way we found clues telling us to exentend the electronics board with a pushbutton and most recently to fill all 128 bytes of the EEPROM with the hex value '0x03'.

To get to the EEPROM I added a 10 pins ISP header to the board to be able to connect it to my programmer. This gave me also the nice opportunity to read the fuse and lock bits to anticipate for any other surprises. Hmm, no surprises here (was I thinking too difficult again? Was I disappointed?), the fuse and lock bits were left alone and still had their default value. I also made a backup of the EEPROM and Flash memory to fix any possible screw-ups.


I used Codevision to read the EEPROM and changed it as requested. Yeehaa, a new Morse sequence!

"PROFICIAT MET JULLIE SKILZZ. CHECK HTTP://**.***.**.***/DEZONDEVOORBIJ/ OM DE VOLGENDE HINT TE VINDEN. MYMICROCONTROLLERCANBEATTHEHELLOUTOF..."

(the '*' were actually filled in but are not really relevant here)

After congratulating us with the achieved result so far we were presented a website for the next clue. Here the clue ended with a seemingly harmless reference to the coolest bumper sticker ever that hangs on the wall of Deddies Lab. Note taken!


So, a website. The tips&tricks section on the website gave us a link to the wikipedia site of morse code. We could have used that some time ago! Funny...

We were told to make a picture of the mystery box with today's newspaper to prove that the cube was still intact. Okay, I maybe broke it a week ago... but it is fixed now. The picture below will lead us further on our quest as promised on the website.



It is obviously that somebody is watching our moves. I suppose we have to be carefull with what we say the weeks to come. Hang on...

see also: Mystery LED in a box: part 4 
see also: Mystery LED in a box: part 5  
see also: Mystery LED in a box: part 6
see also: Mystery LED in a box: part 7

Mystery LED in a box: part 2

see also: Mystery LED in a box: part 0
see also: Mystery LED in a box: part 1 

Nothing more sexy then a beautiful woman with a 360 degrees celcius piece of metal in her hands. And I recently married her too. Lucky me!


In our continuing quest to find our wedding present we (and with 'we' I mean Rianne) got the task to add a pushbutton to the mystery box. This was easy, even for my soldering virgin.

The pushbutton revealed a new sequence of Morse code. The Matlab script I wrote for the first clue proved itself robust enough to also give us the next clue:

"ALLRIGHT. JULLIE DACHTEN TOCH NIET DAT DIT HET AL WAS HE? ZET HET EEPROM VOL MET 0X03 OM NAAR DE VOLGENDE RONDE TE GAAN. VIERENZESTIG"

The next task is to fill the EEPROM of the Attiny with '0x03'. This would bring us to the next round. The sentence strangely ends with the number 64. I don't know if this means anything for now or later on but I will keep the number in mind.

Stay tuned....

see also: Mystery LED in a box: part 3 
see also: Mystery LED in a box: part 4 
see also: Mystery LED in a box: part 5  
see also: Mystery LED in a box: part 6
see also: Mystery LED in a box: part 7

maandag 11 juli 2011

Mystery LED in a box: part 1

see also: Mystery LED in a box: part 0

So the puzzling started. After receiving the small transparent mystery box on our wedding party, already the next day I diligently started deciphering the led's ON/OFF sequence.

As a leftover from a energy monitoring project (that I never finished) I still had a USB datalogger (build around the VDIP1 module) which can log 4 channels of analogue values as a 10 bits value with a maximal sample rate of about 4Hz. It is unfortunately not faster (the software contains some bugs that I still have to fix), but for the mystery led it seemed appropriate. I plugged in an optical sensor (type unknown) to log when and how long the led is ON and OFF. Not knowing how long a unique data sequence was, I logged the optical sensor for 30 minutes.


With the analogue values of the optical sensor stored in a CSV file, I can write some signal processing scripts to analyse the data. In a spreadsheet program the data showed up nicely. A high analogue value (around 700) means the led is ON, the lower values indicate the led is turned OFF. The total sequence was around 7500 samples long. Not a very pleasant job to decipher that by just looking at the led. I definitely needed some software aids for this.


I have some experience with MATLAB, a widely used mathematical software environment. With MATLAB this shouldn't be difficult to decipher, I figured. A 'small' difficulty was that I had no clue what to look for. It can be a highly encrypted telephone number for which I needed a key, or a 800x600 black&white picture giving us a new clue or even a QR code leading us to a website. I stared at the data for a small week and played around with it viewing it from different angles. But nothing that looked useful.

To make sure I didn't miss any data, I watched the Attiny's led output on an oscilloscoop. Maybe a signal with a frequency higher then a visible sequence of 20Hz would show up. Some of my friends know their way pretty well in in the GHz working areas, so I was aware of some very high frequency clue. Luckily, the Attiny2313 has an internal clock of only 1MHz, and my 15MHz scoop showed no hidden suprise. The data that I had from the datalogger still looked as the only useful data.


I definitely was thinking too difficult. It was time to get help from my wife (no offense, honey). Maybe she can look at it from a different (non-technical) perpective which I didn't see with my biassed technical view.
Funny thing was that from the beginning I told everybody that a Morse-code would be out of the question, since this should be way to easy to solve for me and would be kind of an insult to me. I must say, I did look at this option, interpreting the '1' as a dash '-' and the '0' as a dot '.'. The spreadsheet sample from the picture above would then be deciphered as '----.-.-.-.'. But it didn't gave me information when a certain letter started or ended, so the data stream could mean a enormous amount of letter combinations. Very hard to go through all that options. I quickly put aside the Morse-code option.

Eventually it was my brilliant wife that came up with the idea that not the '1''s are dashes and the '0''s are dots but that the lengths of the sequential '1''s were the way to go. So a long stream of '1''s means a dash and a short stream of '1''s means a dot. The length of the '0' streams would then indicate the ending and starting of letters and complete words. The beginning of the data is then deciphered as '-... . ... - .' which means 'BESTE', the dutch word for 'DEAR'.

Victory was ours! A few hours of additional MATLAB programming eventually gave us the information that we needed.

"BESTE SANNE EN RIANNE, GEFELICITEERD MET JULLIE HUWELIJK. OM DE VOLGENDE AANWIJZING TE VERKRIJGEN MOET RIANNE EEN DRUKKNOP NAAR AARDE AAN PIN7 SOLDEREN."

The text basically says that my wife Rianne needs to solder a push button between ground and PIN7 on the Atmel.

That is our first clue, we are going to search for the next one! More to follow....

see also: Mystery LED in a box: part 2
see also: Mystery LED in a box: part 3
see also: Mystery LED in a box: part 4 
see also: Mystery LED in a box: part 5  
see also: Mystery LED in a box: part 6 
see also: Mystery LED in a box: part 7

zondag 10 juli 2011

Mystery LED in a box: part 0

I could have expected it!

 Last year we build this huge wooden dice for a good friend's wedding stuffed with electronics to prevent the newlyweds from getting their hands on their present too quickly. Two weeks ago it was my turn to tie the knot and guess what: The same guys that stood by my side last year putting the dice together now stood right in front of me all together to give me and the misses an interesting transparant box with some electronic parts in it.



Besides a lot of air the little box was filled with a 9V battery, some voltage regulation with an 7805, an ON/OFF switch, an Atmel's Attiny2313 and a single yellow 3mm led. Although the beers tasted good that evening it didn't take me too long to come up with the idea of flipping the switch. What could such a tiny Atmel do, not considering the fact that the battery could be half filled with explosives ending the party a bit sooner as expected? Luckily for us our friends indeed had only good intentions (so far), and the yellow led started blinking quite decently.


That was it. No big speech afterwards, hints, tips or tricks. The music started playing again, everybody grabbed their beers and we stood their holding a little transparent box with a small blinking yellow led like it was our first born baby. Luckily at the end of the party we got a little hint. Despite the kind of nerdy content of the present we were told that Rianne (my wife) will play a big part in finding the solution...

My (our) task is to figure out if this box leads us to any clues concerning our wedding gift. Supposing their is indeed a wedding gift besides this small box worth approximately 10 euros.

More is following soon....

see also: Mystery LED in a box: part 1
see also: Mystery LED in a box: part 2
see also: Mystery LED in a box: part 3
see also: Mystery LED in a box: part 4 
see also: Mystery LED in a box: part 5 
see also: Mystery LED in a box: part 6
see also: Mystery LED in a box: part 7

zaterdag 5 februari 2011

Electronic watering can



 To get the necesarry carbon dioxide to oxygen conversion Deddies lab is accommodated with a young Ficus Lyrata. To not interrupt its attempt to become the biggest Ficus on earth it needs a weekly dosis of water. That combined with the lab's motto that everything deserves a microcontroller gave inspiration for a little project on a rainy sunday: An automated electronic watering can!

 No, it is not an R2D2 alike robot holding a watering can. Basically it is a 10 liter reservoir filled with water and a little pump that waters the plant once a week.

 
 To count the days and make the device extremely low on power consumption it uses a simple (mechanical) wall outlet timer that turns on the electronics once a day for only 15 minutes.* In this 15 minutes the day counter is incremented and on the 7th day the pump starts pumping up the water. That is unless their is enough water in the tank (guarded by mr. Duck) and some other preconditions have been met. If mr. Duck notices the water level is getting low, he pulls the rope indicating that no pumping is allowed anymore unless the tank is filled again.

* I could have used a more modern timer that will only turn on the watering can once a week. But as it was still a sunday I made it a kind of scrapheap challenge and used parts I had lying around instead of buying a new timer the next day.


An Atmega8 is used running on its own internal 1 MHz clock. A pushbutton is available to set the day that is most convenient for watering. Besides the timer mode their is also the possibility to give the plant an extra shot of water with the single shot pushbutton. This button is also useful when adjusting the voltage regulator that determines how long the pumps needs to be turned on. The single shot mode can test the amount of water that is pumped up. With the Aux In feature a external trigger signal can start the pump. That is unless the Timer Mode is disabled with the jumper. There is also an additional Aux Out that turns high when the pump is activated. 
Especially the Aux In and Out features can become useful when this watering can is part of a larger home automated system. Maybe we get plenty of 'rainy sunday afternoons' for Deddies lab to roll out this home automation plan.

When the hole thing was put together and ran the first tests I realized that an important feature was missing. Although mr. Duck indicates the water level is getting low and pumping is not allowed anymore there is still no (auditive/visual) signal to the outside world that the tank needs refilling. So, mr. Duck guards the pump but not the plant. So an addition to the electronics will be needed to fix this.


My Ficus Lyrata needs approximately half a liter per week. With a water reservoir that can contain 10 liters and has a minimum water level of 2 I have to fill the tank every 4 months. Not bad with the water tap at the other side of the house.

Schematics can be found below and C source code for Codevision AVR can also be downloaded.


woensdag 19 januari 2011

Microcontroller from hell

Isn't this the coolest bumper sticker ever? Okay, that is just a matter of opinion, but I think it is pretty awesome... And it is actually not on my bumper, but a wall decoration of Deddies lab for some time.

maandag 17 januari 2011

Auto powerdown

A little detail from the Secret d'Icey project: I am actually not very familiar with Atmel's own power saving capabilities, so I made a little circuit with FET's. I set it up so that the Atmega328 cuts off its own power when there is no activity for 30 seconds.


Default the gate of the P-FET (IRF9530) is pulled up to V+, which is connected to the batteries. This turns off the P-FET and Vs stays 0V. The pulse switch S2 connects the gate to ground and lets the P-FET conduct so Vs become equal to V+. This will power up the circuit that also contains the Atmega328. When the Atmega is turned on the output B2 (pin 5) turns high. This makes also the N-FET IRF540 conduct and makes sure the gate of the P-FET keeps grounded. This takes over the role of the pulse switch.

When there is no change in the dice state for 30 seconds the output B2 becomes low, which turns off the N-FET and the gate of the P-FET is again pulled up high to V+. Now the circuit (Vs) is cut off from the batteries.

(The IRF540 and IRF9530 are maybe a bit overkill (with a maximum drain current of 22 respectively 12A) but these I had lying around.)

I tend to learn how to use Atmel's power saving functions in the near future, but until then this hardware solution will serve its purpose nicely and maybe it can be useful for other applications.