Thursday, July 31, 2014

Battery voltage measurement

I have been thinking about the battery voltage measurement. There are many trade offs in the different methods to accomplish this. The voltage divider I have now works fine. In a voltage divider, the lower the resistance values, the better resolution you have, but the more current you draw. I use 100k ohm resistors so the total current draw (continuous draw) is 20 micro amps. This doesn't feel really good as the Atmel mega1284 can power down to about 1 microamp. The alternative is to add a switching circuit like a FET to switch on the power to the voltage divider. This would make the current draw almost zero when not in use, but adds to the complexity of the board layout. I think for the current version I am going to go with the simple voltage divider and suck up the current draw. After all, the lcd is drawing about 250 microamps anyway and my goal is really to stay below half a milliamp in idle mode. For later models I will consider some of the new battery monitors/manager chips out there. They are good at not only reporting voltage but tracking battery capacity to give you a better idea of remaining battery life. Parts arrived from mouser (particularly the small switches I need) so I will be finalizing the design of the next version. As much as I hate it, I will probably leave out the Bluetooth at this point because I really want this to fit in a good looking case. Stay tuned for updates.

Monday, July 28, 2014

Using the Watchdog Timer for Periodic Tasks

The more I read the datasheet on the mega1284p the more I am amazed at what I learn about chips I have been using for a long time. Forget about using timer 2 for your periodic tasks. It is nice because it can continue to run in sleep mode but it is only an 8 bit counter. Even with the max prescaling (1024) with my 8 Mhz clock you roll over about every 0.03 seconds. This forced me to keep a counter running to only update my clock every 1 second or so because the overhead of doing it every 0.03 seconds crashed the processor. Then I read the section on the Watchdog Timer. I have used it before to reset the processor when my code hung up, but I learned that the WDT can be used in interrupt mode only. This means I can use it for the periodic functions. And the great part is it has it's own clock source which will allow it to roll over from 16ms to 8 seconds. And this leaves Timer 2 for other Arduino functions or I can bring the chip down to lower shutdown levels to conserve battery power. You have to use a timing sequence to enable the WDT, so after some searching and tweaking, I found the following to work:

// Setup the watchdog timer to overflow every 8 seconds.
  MCUSR &= ~(1<<WDRF);
  WDTCSR |= (1<<WDCE) | (1<<WDE);
  WDTCSR = 1<<WDP0 | 1<<WDP3; // Set Watchdog Timer to interupt on 8 second overflow
  WDTCSR |= _BV(WDIE); // Enable Interupt but not Reset

That was it. I then used the Interrupt service routine to set my update flag ( the interrupt caused the chip to wake up from sleep)

SIGNAL(WDT_vect){
  //Add periodic operations
  if (mSelect == -1) clockUp = true; // The current mode is the clock, otherwise, don't update
}

I am currently optimizing the code to minimize battery power. I have it down to about 0.6 ma in sleep mode. The lcd should be about 0.25 ma. Unfortunately, the rest is mostly the stock IMU board. Even placing the individual components in low power mode, it is still a big draw. I am going to fix that in my next design by replacing the board with a BMP180 and a LSM9DS0 IMU. These should virtually disappear in low power mode and the 0.25 ma for the display should be just about all I see. That will give about 16 days of standby time for the 100mah battery I have. I have ordered the final parts from Mouser and will finish the PC board layout after they arrive. The new design will have the improved IMU, barometer, bluetooth, an installed speaker, and I hope, will all fit in the LunaTik ipod nano 6th gen watch case to make this project truly wearable and good looking. Stay tuned.

Saturday, July 12, 2014

Board Layout:
Board Layout (*.brd)

Schematic:
Schematic (*.sch)

Arduino Sketch (zip):
Arduino Sketch (*.zip of all tabs)

These files will give you a good idea of how I constructed the watch. Note: these are still all in their early development stages and do not have a lot of polish or annotation.

Friday, July 11, 2014

First 2 Prototypes Completed

I made a couple of design changes to the protoype watch in my YouTube video. I now use an EADOG-102 lcd and this prototype will not have Bluetooth. I also switched to the ATmega1284p. It is Arduino compatible and has 16k RAM!!!!!!!!!   Here is the new system laid out on a breadboard:



I got my circuit boards from SeeedStudio's Fusion service the other day. They look really good (the boards not my terrible silk screening skills). It was a great deal. I paid $10 for 5 boards and $7 for shipping. They were cool enough to send me 6 boards (probably because my boards were so small they couldn't utilize the space for anyone else - but that is way cool they did that) and it took about 3 weeks from submission to arrival.


I was going to use a work light and low temp solder to assemble the boards, but based on the good job on the spacing in the layout, I decided to hand solder the first prototype.

I soldered the components up to the sensor assembly and the lcd.


At this point, I want to power up the ATmega1284p and see if it will receive the Arduino bootloader.

Here is where I learned a lot of things I already knew. I initially tried to bootload using an Arduino as the ISP. When I tried to load the 1284p 8Mhz bootloader, It started to go and then hung up. If you notice in my schematic, I decided to use the internal RC oscillator to save component count on the board. The first thing that the Bootloader does is set the fuses to predetermined values. That caused the 1284 to switch to external 8Mhz crystal. I don't have one so the chip became unresponsive. When I realized what I did, I simply soldered two leads to the 1284p pins for the crystal, attached an external 8Mhz crystal and was able to use AVRStudio to reset the chip to use internal oscillator. I used it to load the bootloader too. At this point, I put 3.3V to the board and held a FTDI programmer to the programming port and uploaded the firmware from the Arduino IDE. I was both happy and amazed it worked.

Now that that was verified, I soldered the sensor board and the lcd. The result was the completed prototype.


I specifically designed the size to be able to fit perfectly into the numerous rubber watch cases available for the ipod nano. This one was $3 from Amazon. 

And the final assembled watch.

Right now, the watch has modes to display weather data (temp/press/altitude), Accelerometer data, Magnetic field data, I have a mode to set the time. I can view the status page and check remaining RAM (which I have over 14k - thanks 1284p!) and the status of the RTC and sensors, I can set the contrast and 12/24 hour time mode and check the battery voltage too. I have not implemented the Gyro data yet (the gyro is the biggest power hog) and I did not add a speaker to this yet (I have pads for it on the pcboard) and there is no Bluetooth although the FTDI connector has all the connections I need to implement a small transceiver. 

I finished a second prootype using the special backlight available for the EADOG-120 display. It adds significant width (backlit watch is twice as wide as non) but it is a pretty cool feature. Since the display uses two different sets of lights, I tied one to the 1284p and the second I hardwired to the battery. This lets me use the backlight without having to wake up the microcontroller, but still gives me software control of the the backlight if I want it constantly on or want to use it as an alarm mechanism. The lcd without the backlight is the one that has a special back that can't be used with a backlight but is really readable in ambient light.



With the massive RAM I have I intend to make the displays more attractive, add animations, and track trends in pressure to forecast weather. I will also add some specialty apps to uttilize the accelerometer as a movement alarm and a golf rangefinder (hold watch at eye length, point your finger at the bottom of flag, then at top, use the orientation data to calculate distance to pin). I will also use the clock display to show more data like battery status and pressure trend.

I would encourage Makers to have at my designs, modify them, improve them, and build your own smart watch. I am working on another version using the 1.3" oLed display. It will not use the sensor board but will be constructed with discrete sensor components. It will also have a USB port for recharging.

Thanks for reading. Hope this has motivated you to try a project like this.

Here is the schematic.







Wednesday, July 2, 2014

Arduino Smart Watch

This blog will catalog the work I am doing to create an Arduino-based Smart Watch. See the below video for an introduction on the concept.

 
 
I submitted the project to the Atmel Simply AVR Contest. See Below:
 
I have modified the project to use the EA DOG 120 LCD display instead of the oLed for now. For one, it is super easy to use, very thin, and has pins that fit a breadboard. It is very low power and always on as opposed to the oLed that I want to leave off. I am working on an oLed watch too because I happen to love the look of the 1.3" oLed display.
 
For the project, in order to make this so the average hobbyist could construct it, I have decided to use the GY-80 IMU as the sensor platform. It has the BMP085 Pressure/Temperature sensor, and accelerometer, gyro, and magnetometer in a very small form factor. It also has an on board 3.3V regulator. By using this board, I will cut out having to solder a bunch of very small components and save a lot of board space in the process. I had the pc boards made and they are on their way. I will update when I have assembled the first prototype.