Friday, October 29, 2010

Arduino Floppy Drive Shield

Just when you thought it couldn't get any worse. Have you ever wanted to hook a 3.5" floppy drive up to an Arduino?


Well, I have...

Figure 1.0: Taking Something Horrible and Making It Worse

Don't worry - At the moment this is nothing more than a stupid picture and a hunk of protoboard jammed into the top of an unsuspecting Arduino. Implementing a floppy drive controller in software would be a bit of a challenge, however there is no reason it couldn't be done; though some(most) would argue it shouldn't.

For some reason floppy drives make me smile whenever I see them. I'm not sure whether it's their uselessly small data storage capacity or that satisfying "ka-chunck" sound when loading a diskette into a drive, but there's something there that you just can't get with USB flash drives.

Saturday, October 23, 2010

Up and Running (Sort of): SmartClock

Happy Saturday Everyone,

I spent this morning working on the SmartClock; however as it turns out there might be more to it than I originally thought. In case you've just tuned in, the idea was to outfit a standard clock radio with a miniature motion sensor (specifically a Panasonic NaPiOn sensor) and a PIC microcontroller to shut off the LED display whenever the room the clock was in was empty.

Figure 1: Prototype controller (center), Panasonic NaPiOn motion sensor (top left)

The four-pin connector is for the anodes of the LED display, the three-pin connector in the middle goes to the motion sensor, and the six-pin connector on the left side of the board is dual-purpose: when the board is in the radio it acts as a power supply input, and when it's on the bench it acts as a ICSP port for the PIC programmer. As I was wiring this up I was thinking to myself "There's no way in hell I can ever let anyone see this", but here it is - the worst rat's nest of wire wrap I've ever seen:

Figure 2: Ahhhh!!! (well, I guess it is October - It's a Halloween project)

The Rats' Nest
First off: Don't ever wire anything like. Ever. In the top left we have two ST Microelectronic D10F10 N-Channel MOSFETS that control the anodes of the clocks' LED display. They are driven by the Toshiba TLP191B photocoupler (beige) in the bottom-center. The PIC12F629 is on the left side of the board (on the top side), and in the top-right we have the LM1086-3.3 LDO regulator. 

The Verdict
The idea was that by switching off the LED display when the room was vacant it would be possible to save a considerable amount of power over the clocks' lifetime (ballpark figures are found in the original post). After wiring this thing up and plugging in the radio I was disappointed to find out that the radio's current draw actually increases by about 1mA when the display shuts off. As this defies logic I will have to look into this some more, however it is obvious that in it's current state we aren't achieving the goal of power savings. 

Room for Improvement
- Better firmware (slower clock speed, sleep timers, etc)
- Better hardware (more efficient power regulator, lower power PIC)
- Less wire wrap

Though the idea of starting with a working clock radio seemed like a good idea at the time; in retrospect it would have probably been a better idea to start from scratch and build an entire clock from the ground up with power conservation in mind. Since the clock I'm using probably wasn't designed to be overly power conservative there are likely unnecessary losses in the power supply and the rest of the circuity already present in the clock.

Tuesday, October 19, 2010

Arduino Isn't A Country...

A terrible thing happened today:

I was cooking up some spaghetti for dinner; nothing too special. I was pouring the pasta sauce onto the finished masterpiece when I happened to glace at the lid for the jar of pasta sauce sitting on the stove.

My first thought: "Huh - There's a map of Arduino on this stuff"


My second thought: "Wait! Arduino isn't a country! Italy is!"


My third thought: "I wonder if I can hook the Arduino up to the stove to cook spaghetti for me..."

Technology is good. Life is Wonderful. Everything is terrific.

Sunday, October 17, 2010

Bluetooth Thermometer - Update!

'Morning Everyone,

I finally invested the hour-and-a-half and threw together a version of the Bluetooth thermometer on a small (45mm x 45mm) proto-board. Believe it or not it worked first time, which is quite amazing when you consider how much wire-wrap is hidden on the bottom side of the board.

On top you can see the Sure Bluetooth module on it's adapter board. It is attached to the base board by way of a 2.54mm female header receptacle, so I can easily pop it out and use it for something else should the need arise. The TO-92 device sticking out the side is the DS1820 1-Wire thermometer. It is attached to angled header pins so it too can be removed and extended if needed.

Hiding under the Bluetooth module is the PIC, 8.000Mhz crystal, some loading caps for the crystal (22pF), and 4.7k pull-up resistors for the /MCLR and 1-Wire bus pins on the PIC12F675. I didn't include an ICSP port was included for a reason - The PIC needs +5V to be programmed, and since the Bluetooth module runs off +3.3V it would probably end up getting fried if accidentally left plugged in while the PIC was being programmed. On the bottom of the board is an LM1086-3.3V LDO regulator, rated at 1.5A it is comically over sized for this application, but it's all I had lying around in my big box of miscellaneous parts, so that's what I used.

The Future
- Adding configuration features to the firmware (boot menu / options)
- Reducing power consumption (lower clock speed / better power regulation)
- Solar power supply and super capacitor (maybe not with this Bluetooth module though)

I do have a National Semiconductor LMX9838 Bluetooth Serial Port Module kicking around that I am hoping to use in lieu of the Sure module for the next iteration of this project. This would not only save PCB space, but also allow better software control and power management.

That's all for now folks - If you're interested in the firmware or hardware send post a comment and I'll make a conscious effort to draft up some schematics and cut-and-paste the firmware into the blag.

Right now I'm off to Future Shop to pick up a clock radio...

Saturday, October 16, 2010

Every Milliwatt Counts...

While everyone else was out on the town getting hosed and having a grand old time I was hold-up in my apartment diddling around circuits - surprised? Anyway, for quite some time I've been toying with the idea of integrating a Panasonic NaPiOn PIR Motion Sensor into a radio alarm clock to blank the display when nobody is home.

Now I realize that using this particular sensor is a bit impractical at $40 a piece; I certainly wouldn't have one if I hadn't procured it in the midst of a dumpster-dive, but I do believe that the idea does have merit, as clock radios do actually suck up a fair bit of power needlessly.

Panasonic NaPiOn PIR Sensor with a PIC12F629 Microcontroller

The Circuit
The NaPiOn sensor runs off +3.3V and outputs a logical "1" whenever it senses motion. Since the output only stays high for a second or two, we need something to keep the display on for a useful amount of time, and to provide a little bit of hysteresis to prevent rapid cycling, which would be annoying. The cheapest, easiest, smallest way to do this is with a microcontroller.

Could you do this with discrete logic? Sure. Could you do this with discrete logic for $1.30 and fit it into one square centimeter of PCB space? Not a chance. The use of a microcontroller also gives us the ability to change any parameter we want (time on, time off, etc) with a few lines of code.

Some Numbers
When you consider that the sensor draws about 60uA in standby, and the PIC could probably be made to draw as little as 20uA if the firmware were optimized, it is plausible that the whole sensing circuit could end up drawing less than 200uA including the power supply.

Some rough, ball-park calculations:

13mA Per Segment * 7 Segments * 4 Digits = 364mA (13mA per diode is a rough guess)

200uA = 0.2mA (this one is right)

This would mean that you could theoretically save a fair bit of power (relatively speaking).

Take my clock radio as an example. It's a Sony Dream Machine, and it's power rating is 12W. When compared to your 4500W clothes dryer, 12W is not very much, however we have to remember that clock radios generally run twenty-four hours a day, 365.25 days a year. So in effect:

12W x 24h x 365.25 = 105.192kWh/Year

(12W = 0.012kW)

As you can see, 12W happening all the time really does add up to a substantial amount at the end of the year. When you consider that most homes have more than one clock radio, and that they are only being "looked at" maybe 2% of the time they're powered on for, the potential for savings over the lifetime of the appliance does exist.

Tomorrow morning I'm planning on hacking open a clock radio, patching this circuit and taking down some real numbers. Stay tuned...

Thursday, October 14, 2010

Proffessional Selling?

Every now and then you see something you just can't pass up; and this was such an example. While waiting for Math class today I noticed this poster tacked up on a bulletin board outside the classroom:

Now I don't know the first thing about marketing, however I do know the following:

- Professionals use spell-check
- Marketing involves getting a message across clearly
- Professionals also use grammar and punctuation

Whenever I happen to catch a gem like this one I can usually contain myself, however this time I just had to go too far. Here is a transcription of my text-message conversation with the "Proffessional" trying to sell their book:

Me: "Hello - Are you still selling the book?"

Them: "Proffessional selling?"

Me: "Oh - You're actually selling a book called "Professional Selling". Sorry, your poster was ambiguous..."

Them: "What book do you need?"

Me: "Oh I'm in electrical engineering; I just thought your poster was funny, especially because you spelled "Professional" wrong and didn't use any punctuation. Sorry..."

Them: "Lol okay. Thanks for dis'ing me anyways.? Maybe you should become an English teacher?"

Me: "Professionals use spell-check. Especially professionals that sell things..."

Them: "Jesus. Thanks for the heads up"

Me: "Oh no problem - Your poster made my day!"

Them: "Surprised you had the time of day to text me just to say that!"

Me: "Some things are worth making time for. Anyway - best of luck selling your book..."

Alright - I know I'm a bad person and a complete asshole, but sometime you just have to be!

We don't use typewriters anymore! Both my browser and my cell phone have spell-check; there is no excuse for misspelling things in this day and age. Since whoever created this poster probably didn't use a printing press to duplicate it, the lack of punctuation is absurd! You don't have to pay per character - go ahead a use a period or colon: I dare you!

Alright. I'm done now. That's my rant about spelling and punctuation. Not only does it make you look like an idiot, it's just downright "Unproffessional"...

Wednesday, October 13, 2010

Right-Angle Circuitry?

I just happened upon this site through a link on Randall Munroe's (XKCD) "blag" this morning and thought I would pass it along; it is quite fascinating:

Tuesday, October 12, 2010

DatAzul - Universal Bluetooth Datalogging Platform

Happy Thanksgiving Everyone!

After spending a fair bit of time on the Bluetooth thermometer and power meter projects it occurred to me how great it would be to have a universal Bluetooth data collection and logging platform that anyone could use quickly and with few or no modifications. Here is what I was thinking of:

- PIC or AVR-based
- 3-10 Channels of A2D with programmable scales
- Flexible power supply options (AC wall wart, battery, solar, etc.)
- Simple terminal-based "task" configuration
- Complete usability through any terminal program, NO software on the PC-side except for a terminal program and a Bluetooth stack. This means that it could be used on any OS (Windows, Mac, Linux, etc) and with smartphones that support the Bluetooth COM object.
- Onboard SD/MMC card slot to allow the caching of data should the connection to the host be lost.

Just a few thoughts that have been bouncing around inside my head for the past could weeks. Maybe this weekend I'll have a chance to piece something together and a do a bit of testing. The biggest thing is probably going to be the "boot menu" through which you set up the device; I'm not really sure exactly how I'm going to code that, so if anyone has any suggestions it would be a big help.

Wednesday, October 6, 2010

Hurray for Effective Communication!

Nothing exciting in terms of technology, but I did feel the need to share this one:

Today I came home to find a letter from Okanagan College (or "The OC" as I like to call it) sitting in my letterbox. When I went to open it, I realized that the envelope was assembled upside down. I guess they were having a rough day down at the envelope factory...

I had just finished giggling about the envelope when I examined the contents within. Inside was a cheque made out to me for $109 with the description field reading "Quick Refund" with no further explanation.

I'm still a little perplexed, but money is money, so I guess I should run off to the ATM to cash my "Quick Refund". I will have to put the cheque in an envelope; but hopefully their envelopes are put together the right way!

Tuesday, October 5, 2010

Yarrduino Power Meter

Alright - My first ever Arduino project up and running. Nothing too fancy; I just took an LCD I had lying around (HD44780 chipset) and patched it into the Freeduino board by way of a breadboard. The Arduino software is kind of neat; though it is written in Java (ughhhh), it runs like a hot damn and is well laid out.

I started off with the "Hello World" LCD example code and merged it with the "AnalogInSerial" A2D example code. The result printed out a reading in raw A2D values on the LCD, which, with just a little bit of black magic and some grade-school arithmetic was converted into a 0-5V DC voltage reading. This reading was then used to compute the current in amps (measured by the CT), which was then spit out onto the LCD.

The next step will be finding a way to measure the AC line voltage accurately and safely, and next in line comes the addition of data logging capabilities. At a glance, writing data to an SD/MMC card appears to be fairly straightforward as far as software is concerned, and from a hardware perspective it involves nothing more than a few resistors to eat up the difference between the +5V TTL on the Arduino and +2.7-3.3V the SD card operates on.

As always, comments and suggestions appreciated; source code and schematics free by request.

Also: I owe thanks to Limor and the Adafruit gang - I lifted the LCD connection schematic from her website:

Monday, October 4, 2010

We Get Signal! (from the thermometer)

I've finally managed to get the Bluetooth thermometer up and running; there are still a number of improvements to be made and features to be added but as it stands I can put power into the breadboard and get temperature readings out of RealTerm, so the basis of the system is operational.

Once it was up and running I took a few current measurements and was a little concerned; here's what I found:

Link connected but idling: ~20mA
Link connected and transmitting: ~22mA

Here's the kicker though - when power is first applied and the link is trying to connect to the PC the power consumption jumps back and forth between roughly 2mA and 50mA once a second. It seems like the "search" mode is the most power-intensive state, which could pose a bit of a problem. If the PC is waiting to accept the incoming connection the "search" routine will only take five seconds or so, after which the current draw drops down to the 20-22mA range. The danger is that if the PC is not ready to accept the connection (powered off, Bluetooth disabled, connection in use), the module will continue to "search" indefinitely, eating up the battery.

The Sure Bluetooth module doesn't have a #SHUTDOWN or similar pin, nor can it directly provide any direct link status indication, however it does have RTS and CTS pins, which we just might be able to make use of to see if the link is connected, and if it isn't, switch the power to the module off via a MOSFET for a predetermined amount of time, then try again.

Here are some of my other ideas:

Configurable "Sessions" - For the first thirty seconds after power-up, the PIC would look for any ASCII data coming in over the Bluetooth link. If anything was received, it would answer back with a "setup menu" that would allow you to change settings such as the initial sample count, sample frequency, etc. Once these values were set through the terminal, they would be saved in the EEPROM and the rig would start collection and transmitting data according to the parameters you entered.

This would be much more convenient, as right now the only way to change the behavior of the device is to modify the source code, compile it, and load it in with a PIC programmer. The "boot menu" concept lets you easily modify the settings without any hardware or software whatsoever (just your terminal program).

Some of the configurable values might include:

- Sample Frequency (currently fixed at one sample per second)
- Initial Sample Number (currently resets to "0" at power-up)
- "Search" timeout
- Temperature Scale (Centigrade or Centigrade - If you're using Fahrenheit you're not invited)
- Ideas?

That's about it in terms of news for the thermometer project; I'm going to have to work out a the details for the power supply next: I'm thinking something simple like a LP2950-3.3V should do the trick. I'm still trying to figure out how well all of this is going to run off the solar panel, the spikes at power-up can be counteracted with a supercapacitor, it's the continuous 20mA idle current that I'm wondering about...

In other news - my apologies to the folks at Neilsen-Kuljian: it is in fact my software that sucks, not their current transformers. I was having a discussion with one of my instructors at school today when it hit me: The PIC is running off of +3.3V, and therefore the A2D range will be dependent on the rail-to-rail difference of the PIC's power supply. In every project I've done in the past, I've powered the microcontroller off +5V, and had that been the case here my current measurements would have been correct, however, as the PIC's A2D in this situation tops out at +3.3V it makes perfect sense that a CT output voltage of 3.7V would give and answer of 10A!

Now that that's out of the way, I still need to find an accurate way to measure the AC line voltage and get a proportional 0-3.3V output voltage that I can cram into the PIC to compute power correctly.

I owe David (my instructor) thanks for providing feedback on my proposed measurement schemes; as things stand it seems we're still in limbo as to what would be the best way to go, I'll keep everyone posted.

Saturday, October 2, 2010

Bluetooth Power Monitor

All the recent talk of power conservation got me in the mood to adapt my power meter from a couple posts ago to be a little (just a little) more practical. With a little bit of re-working, I was able to recycle (eco-friendly) my code from the Bluetooth thermometer and use it to transmit measurements from the CT (Current Transformer) to a terminal program via the Bluetooth link.

Figure 1.0: Bluetooth Power Meter Hooked up to My Toaster Oven
With a little bit of hacking around in Proton (PICBasic Development Suite) I was able to get the thing working; at the moment it spits out a a reading every second in amps. I didn't want it to give an answer in watts since it isn't measuring the actual AC line voltage (yet), and therefore any power readings would be a sham if it used some arbitrary value like "120VAC" for the line voltage. The next step is to find a small transformer out of a clock radio or something (~6V secondary) and design a small circuit to give us a small DC voltage proportional to the AC line voltage that the PIC can then measure and use in power calculations.


-  I've run out of room in the PIC12F675 - It can only store one float variable. 

- The CT I'm using blows - The scale goes from 0-10A, but when I plug in my coffee maker that pulls 7.37A (900W/122V), the output voltage of the CT is around 4.75V, when in reality it should be about 3.7V

Figure 2.0: Terminal Output @ 9600 Baud over Bluetooth

As you can see it works as-is, if you'd like a copy of the source code give me a shout and it's all yours; just be warned that you'll need a PICBasic compiler to do anything with it. I could also send you a HEX file if you want to use it as-is. As with the thermometer, once I get something working that does more or less what I want it to do I'll draft up some schematics and maybe even a PCB. Stay tuned.