Friday, May 01, 2009

micro controller woes


A couple of years ago I bought a little circuit(pictured top left) that had two relays controlled by a 315MHz radio and a range of 1500 feet. Luck was not on my side or maybe just misused it didn't last a week, it just up and stopped working. I just threw it in my box of electronic parts and forgot about it until I got my micro controller and started to rummage for interesting circuits to interface with it. It was a good thing I didn't throw it away as a closer inspection revealed a radio daughter board that could potentially be used with my micro controller so I swiftly soldered it off.

I had no idea if this piece of the circuit even worked but I carried my bits and bobs to work and started to plug up the breadboard. When I pushed button 1 and 2 I got the led to blink rapidly but it was continuously fluctuating when no buttons were pressed. I made the assertions that it was background noise and that the circuit outputted a +5v square wave. I went to work writing the C code to prove my hypothesis and read data from the radio. I was able quickly get some code to dump thousands of ones and zeros as it just sampled the input pin each couple of clock cycles.

It took me quite a while to figure out what to do with the 1's and 0's but eventually I massaged them into something usable with the help of gnuplot.

This first graph shows a wide view as I pressed button 1 four times. The outcome looked good like there was something usable there.
I zoomed in a bit more and got this second graph, yup a detectable cycling signal was definitely there.

The only thing left to do was determine if the other button produced a similar signal with a different detectable signature and the bottom two graphs showed the signal from the two buttons magnified to a similar point of interest and there was my different but detectable signals where clearly visible. Eureka!

The next problem is to develop C code to detect those two signals in a stream of bits. I wrote my code but it was not triggering when I pressed the buttons. I soon realized I was suffering from the observer effect in which my code to detect the patterns as I sampled the data output from the radio added delays in the detection that changed the signal signature.

I wished I could turn back the hands of time and pay just that much more attention in school, it would have made dealing with all of this a lot easier. I eventually got the circuit matching the signals and it was mostly reliable. Button two triggered all the time and from far distances but button one worked when it felt like. Mission accomplished so I packed my stuff and sent it back home. Of course I attracted quite a bit of attention from my co-workers again during those couple of days while developing the code for it. Those who thought I was working on a bomb before when I was working on the timing circuit eyes definitely popped open a bit wider this time when they saw the remote control. I pulled out the antenna a bit more just to mess with them lol.

3 comments:

Unknown said...

010110001111100000100111001011001

Man you talking some serious electrical engineering here! Good thing I have an electrical engineering background, though very shabby, else I wouldn't have clue what yuh talking bout! lol.

Mad Bull said...

Ra$$! You are an uber geek! Anyway, respeck, So can this circuit be used in anything that can get us men into women's panties more often and with less work? If the answer is yes, I will help with any funding you need. Otherwise, can this! Its obviously useless!

Cool Destiny said...

You guys rock!