Realtime Clock With 18F2550

by snorlaxprime in Circuits > Clocks

184 Views, 1 Favorites, 0 Comments

Realtime Clock With 18F2550

ClockBuildCoverImage1.png
All soldered.jpg

There are probably significant numbers of Clock already out there. I have some spare component to make the clock that had been sitting collecting dust, so here goes another clock that is not using Arduino but 18F2550. The idea is to build a clock that is accurate, and didn't lost the time when the power went out, so that when you plug it back in it remembers the last time and continue to display the right time.

Then you can expand the clock with additional features.

Supplies

pic18f2550.png

The microprocessors behind this is PIC 18F2550. This will be the brain of the compute module, it have the capability to display clock on it's own, but because we want a feature that will allow us to hold the time when the power is off, then we use the DS3231 RTC to keep track of time as this have a battery backup that will hold the time.

I am actually using the BEEPIC development board this will allow much faster uploading of the code.

The programming interface for this is using the MPLAB IDE to generate the .HEX file.

Gather All the Components

Components.jpg
20250824_194811.jpg
LCD1602 module.png
Potentiometer01.png
RTC-DS3231.png

Here are the list of the components used:

  1. 1x BEEPIC development board by Microgenia (The company no longer making this), alternative can be sourced from BOLT, but modification will be necessary for the library to work or you can download their source code directly
  2. LCD Display LCD1602 module
  3. 2x tactile push button
  4. Bread board
  5. 10K Potentiometer
  6. RTC DS-3231
  7. 2x 10K resistors
  8. 220 ohm resistor
  9. CR2025 battery for the RTC

Consumables:

  1. wires
  2. solder
  3. Female headers (optional)
  4. Male headers

Tools:

  1. Soldering iron
  2. Multimeter
  3. Pliers
  4. Cable cutters
  5. Prototype board
  6. 3D printer (optional)

Circuit Diagram

BeepicRTCClock.png

We are connecting the DS-3231

  1. SCL to PIN RB1 of PIC18F2550
  2. SDA to PIN RB0 of PIC18F2550

Connection of the LCD Display:

  1. RS to PIN RC6 of PIC18F2550
  2. E to PIN RC7 of PIC18F2550
  3. R/W connected to GND
  4. Vo connected to the Potentiometer (middle leg)
  5. VDD connected to + 5V
  6. VSS connected to GND
  7. LCD1 to PIN RA0 of PIC18F2550
  8. DB5 to PIN RA1 of PIC18F2550
  9. DB6 to PIN RA2 of PIC18F2550
  10. DB7 to PIN RA3 of PIC18F2550
  11. LED+ connected to 220 ohm resistor to 5V
  12. LED- connected to GND

Switches connection

  1. Adjustment switch connected to RC1 of PIC 18F2550
  2. Mode switch connected to RC0 of PIC 18F2550
  3. Pull up resistors 10K is connected to RC1 and RC0 to 5V

Prototyping

Prototype.jpg

It is always a good idea to prototype the the build so that you can check and test that everything is working. Connect everything through the prototype board if you have one so that you can tested out before soldering it to your breadboard.


Build or Upload the Hex File

MPLAB.png
Uploading the HEX file to 18F2550

Open the MPLAB Ide and load the source file from the following Github repository

Once compiled, the will be a .HEX file in the folder and you can upload them using the MiEUSBHIDLoader in the same repository as above.

If you want a quick and easy way, there is a precompiled .HEX file already in the above repository named BeepicClock.hex

If all goes well you should have a working clock, and you can make adjustment to the brightness of the backlight using the 10K potentiometer.

The first button will cycle through the hour, minute, day, date, month and year

The second button will allow you to increment the numbers

Once you are happy with the way it looks, now it is time to build the real thing using the bread board.

The 18F2550 prototype board that I have can switch into the boot loader mode by pressing the button, and it will allow the HEX file to be uploaded as shown in the youtube video.

Solder Each Component to the Breadboard

Microprocessor.jpg
AttachButton.jpg
Wiring01.jpg
RealtimeClock.jpg
Potentiometer.jpg

Start with the PIC, then design your way through and make sure each component is soldered and positioned well. Here are the orders of the component that soldered through.

Starting with the male headers for the PIC development board. Then the female header for the LCD display. Then slowing connecting all the LCD connection from female headers to the development board. Then positioning the switch on the opposite side, starting with the pull up resistors and then connecting the Realtime clock on the other side. The final component is the Potentiometer which connected to V0 (contrast adjustment).

Finishing the Build

Soldered.jpg

Repeat the same steps again to upload the boot loader if you haven't load it up and then make adjustment to the clock as necessary. Then adjust the contrast so that LCD is not too bright. Don't forget to attach a button cell. Now you have a fully working clock that you can brag about. And when the power reset, it will still remember the time until the next time it is plugged in.

Printing the Case

Print the case using the attached STL file to host the clock. You will need 3mm screws to attached the Printed circuit boards to the case.

After Thoughts

There are a couple of features that are missing from the clock, so you can add things like:

  1. Beeper for alarm
  2. Temperature sensors
  3. Pomodoro timer mode
  4. Update the Display to show bigger fonts
  5. Metronome functions