Showing posts with label LCD Clock. Show all posts
Showing posts with label LCD Clock. Show all posts

Friday, 19 September 2014

Simple battery powered, LCD clock / calendar

This is an old post, preserved for reference.
The products and services mentioned within are no longer available.

In a similar style to the battery powered LCD clocks I made a while ago, I have been asked to make some LCD calendars.
The desk clock used an 8x2 LCD, but I went for something different for this, the display from an Nokia 5110 phone. These are 84x48 graphical LCDs using the Philips PCD8544 controller. These is a simple interface, but it runs at 3,3V. I followed the guides on the Adafruit site to use a 4050 as a level converter and drive this from an Arduino Uno.
The plan for this is to run from 2x AA batteries, so the 4050 will not be required, and the LCD can be connected directly. As usual with these things you can't have everything, so it's 'cheap, lower power, accurate - pick two. In this case, it's cheap and low powered, so I'm running the ATmega328P with it's internal 8MHz RC oscillator, divided down to 1MHz, As with the previous clock, I'm using a 32768Hz watch crystal on a timer interrupt to count seconds.
The crystal is hidden under the chip socket, and that's all that's required for the final unit, one display, the watch crystal, 4 buttons and one 100nF decoupling capacitor on the back. The switches and display lines are wired to the nearest pin on the ATmega328P, as usual switched to ground and using the internal pullup resistors.
I've used a three pin connector for power, the centre pin is the blue backlight which isn't currently used, but could be wired up if required, obviously reducing battery life
Normally it just shows the date, but the yellow button switches into date / time mode so the time can be set. The other buttons increments day/month/year or hours/minutes/seconds, depending on mode.
I also build a portrait version, to be used on a different project.
So far testing has shown this may be out by a few seconds a day. That's not ideal for a clock, but this is to be paired with an analogue clock movement, so will mainly be used to show the date. In which case, it should be fine as long as it changes date around midnight and not at three o'clock in the afternoon.
Since there is no battery backed real time clock, it will not remember the time. I've added a function to write to the EEPROM when it changes at midnight. This is checked on power on, so the date will be correct and just the time will need to be set when the batteries are changed. The EEPROM has a limited life of 100,000 writes, so storing the time would wear it out too soon.

Sunday, 9 February 2014

Setting the time

This is an old post, preserved for reference.
The products and services mentioned within are no longer available.

I've had a query about how I have been setting the time on the LED clocks I've made. Well, it depends. When I replaced the LED driver board on my old Cascade LED clock radio, I didn't bother with any buttons etc., so the only way to set the time is to reprogram it.
So every 6 months, I plug it into the PC via an FTDI cable (as shown here) or an Arduino USB Serial Light (as in the original article). I then upload the code with the following line uncommented.

  RTC.begin();
  //RTC.adjust(DateTime(__DATE__, __TIME__));

This sets the time to the system time and date at the point of programming. I then comment the line out again and immediately reprogram it, or it would reset to that that time each time power was applied.
That's fine for me, but for the ones other people have to use, I tend to add buttons to set the time, such as on this LCD clock. Note in this case, I use the USB cable for power, there is no data connection.
So I suppose it's down to how complicated you want to make it. I'm happy to reprogram a few clocks twice a year to cope with daylight saving. But obviously the average user would prefer buttons to change the time. You could use serial (directly or via USB) to set a time from a PC, but that's probably more work that reprogramming it. You could even use an Arduino Ethernet and get the time over the internet via NTP, or connect to a rugby radio module if you wanted to.

Saturday, 15 June 2013

Battery Powered LCD Desk Clock

This is an old post, preserved for reference.
The products and services mentioned within are no longer available.

Most of the clocks I have built have been mains or USB powered, but I had a request to build some battery powered ones, so I have been researching into the options. My basic LCD design was fairly simple, using an ATMega328P with a DS1307 Real Time Clock and an HD44780 based LCD display. I've built quite a few like this, here is one of the prototypes of this arrangement with an Arduino Uno and an adafruit RTC module:
My target was a pair of AA batteries. Of those, the micro will run happily run at 3V. The LCD should work at 3V although it is a 5V model, but the RTC requires 5V and a separate backup battery. To keep cost, size and power drain down, I have removed the RTC from the equation. It's a shame to lose the battery backed clock option. To save having to fully set the date and time each time the batteries are changed, I set it to write the date to EEPROM once a day at midnight. That at least means the date doesn't need to be set. The previous versions all used an ATMega328P running from a 16MHz crystal, but firstly that uses a lot more power, and secondly, it's only rated for that speed at 5V. I looked at running the micro from a 32768Hz crystal, but that didn't work out too well as the LCD updates were very slow. I finally went for the option of using the internal 8MHz oscillator in the micro, divided down to 1MHz, but retaining the 32768Hz watch crystal for an internal counter. This has to be set by programming the fuses in the ATMega328P microcontroller. I used avrdude and a USB Tiny ISP to set these using the following command line:
avrdude -cusbtiny -pm328p -Ulfuse:w:0x22:m -Uhfuse:w:0xd2:m -Uefuse:w:0xff:m
This sets the fuses to 22:D2:FF, selecting the internal 8MHz oscillator as the clock source, and enabling divide by 8 to get 1MHz. It also enables clock out - more on that later. This can be tricky territory as you can end up setting the clock speed to the point it isn't running fast enough to re-program. See my previous article on Reviving an unprogrammable ATMega328P. However, once set, this did reduce the current draw quite a bit from the original version running at 16MHz. The next challenge was the LCD. I went though a number of options here, I started with an MC34063 as a step up switch mode regulator. The idea was to generate 5V from the 3V input. This worked fine, but required quite a few components and took up a fair amount of space. It was also running at about 10mA, which wasn't really an option on batteries.
Having ruled that out, I looked into other options. Since the micro could run at 3V, it was only the LCD that required 5V. The next step was to look at using a voltage doubler to power the LCD. The idea is to take a square wave signal and via a couple of diodes and a couple of capacitors generate a voltage twice that of the  input. In this case, I was looking at getting up to 6V from doubling 3V. There is diode drop to consider, although with the 1N5819 schottky diodes, it's only around 100mV. To get the square wave, I had ruled out the ATMega328P PWM outputs as I'd changed the internal clocks to count the seconds (or rather 16th's of a second), so the extra fuse setting I programmed was clock out. This send the 1MHz internal clock out of PB0 (pin 14, Arduino Digital Output 8). This is a bit higher than necessary, but it's effectively free. A bit of experimenting with values gave around 5V under the load of the LCD and we were in business. There were few components to fit, so I went for mounting the circuit on a pair of small pad boards, the micro and the LCD on the front board. The crystal fits under the microcontroller to protect it. The LCD connectors via a 14 way header.
The batteries and buttons went on the second board.
I used a short ribbon cable to join the two boards, and bolted it all together.
This was using a few mA and seemed to be keeping good time, and sat nicely on the desk.
One of the tasks for this was to show the day of the week. The trouble was, it was only 8 characters, so I had to be a bit creative with Wednesday and fit 'esday' into 4 user defined characters.
I used the same 'esday' characters to allow Tuesday to be fit in the centre:
I ran this for a couple of weeks and all seemed well. As I was building another couple of these, I had another look at driving the LCD. The HD44780 chip should be able to run off 3V, the only reason the display was blank was because the contrast couldn't be turned low enough, it was already down to 0V. Various data sheets show a negative voltage as being required for this, so I made a slight modification and turned the voltage doubler into a negative voltage generator. This then generated approximately -3V from the clock signal. This was a bit high, so a switched to using standard 1N4148 diodes and 100nF capactiors (in place of 10uF) to make it less good. This ended up about -2V under load. The LCD could then be driven direct from the 3V battery supply, and the only things on the charge pump was the contrast reference of the LCD. This reduced the current consumption to less than 1mA, so should double the battery life, by just shuffling around a few components.
So there it is, a neat little desk clock / calendar that should run for many months on a pair of AA batteries.
Update:
Dave Jones over at the EEVBlog has posted some videos on charge pumps and negative voltage generators: