Car clock, temperature and voltmeter

 

 

 

 

1.             Introduction

 

 

This device was designed to replace the original digital clock in a Fiat Ducato 1992-1994, mounted just above the inside rearview mirror. The original clock is not very accurate, only displays time and is sensitive to interference (e.g. from Xenon headlights). The replacement device described here does not have these disadvantages, and on top of that also displays the temperature and the car’s battery voltage. It works on the car battery and uses the Microchip MCP9800 as a temperature sensor.

 

This circuit is based around the PIC16F1937 microcontroller. This chip is actually a small computer contained in a single chip, including RAM memory,  EEPROM, I/O ports, CPU and so on. When you buy this chip, it comes empty with no program on it. You have to compile the source code and download the resulting  machine code into it, using a PC and a small programmer attached to the PC and the chip. To get yourself familiar with this stuff, I suggest you first read this link: Getting started with microcontrollers.

 

Back to top

 

2.             Description

 

The LCD display used in this design is the Varitronix VIM-404 (Digikey ordernbr: 153-1047-ND), which is a 0.5” multiplexed 4 digits 7-segment transflective display. It is driven by the PIC16F1937 microcontroller which has a built-in LCD driver.

The LCD is lit by a LED backlight unit (4.1V): Digikey ordernbr. 153-1026-ND.

 

The design is based on Microchip’s F1 evaluation board. The original PIC16LF1937 was replaced by the PIC16F1937 to be able to operate at 5 volts (in stead of 3.3 volts) to have a better contrast on the used LCD display.

 

Back to top

 

 

3.             Usage

 

 

The device is operated with a single pushbutton.

 

When powered, time is displayed. Press the button to change the display to temperature, press again to switch to voltage.

 

Setting the time is done using a unique one-button user interface:

 

-       First set the hours. Press and hold the button, the units of the minutes will increase until reached 0, then the tens of minutes will increase until reached 0, then the hours will increase. Release the button when the hours are correct.

-       Then set the tens of minutes. Press and hold the button, the units of the minutes will increase until reached 0, then the tens of minutes will increase. Release the button when the tens of minutes are correct.

-       Then set the units of minutes. Press and hold the button, the units of the minutes will increase. Release the button when the units of minutes are correct.

 

 

Back to top

 

 

4.             Connection

 

It is advised to use two 4-pin connector to connect the device to the car. I made them myself from standard headers:

 

 

 

Back to top

 

 

5.             Schematic diagram

 

 

 

List of components

 

Link to Eagle circuit

 

 

Back to top

 

6.             Explanation of the schematic diagram

 

(Refer to the schematic diagram).

 

12V power coming from contact or light switch must be connected to PAD8. This is for the backlight, it will be on when the engine is running or when the light is on, by means of IC4 (LM317) which is configured for 4.1V (R3-R5).

12V continuous power must be connected to PAD6. This is converted down to 5V by means of IC2, a very efficient power regulator by Microchip (the MCP1790) which provides the power for the PIC, the LCD and the temp sensor.

 

Three common lines and a lot of segment lines are connected between the LCD display and the PIC’s LCD driver.

 

The digital temperature sensor is connected to the clock and data lines of the PIC’s I2C bus.

A common 32768 Hz crystal is connected to the PIC’s oscillator pins, this is used as the time base for the clock.

 

R1 and R2 are a voltage divider to measure the battery voltage. It is connected to an analog input of the PIC.

 

Back to top

 

 

7.             The printed circuit board

 

The pcb is designed for smd components.

It is double sided and designed with Eagle (from Cadsoft).

The LCD display, the only non-SMD component, has long pins and therefore can be mounted on top of the microcontroller, thus saving space.

The LED backlight unit fits between the LCD display and the PCB/PIC.

 

 

 

 

 

 

 

PDF file (top, mirrored) to print on a transparent: Print-layout

PDF file (bottom) to print on a transparent: Print-layout

 

Link to Eagle file brd file containing the PCB..

 

 

 

 

 

Back to top

 

 

8.             The final device

 

 

Below some pictures of the final device.

 

The original device compared with the new one:

 

 

 

 

Device showing time, notice the special “font” showing 6 and 9 like in professional displays:

 

 

 

The device built in the mirror console of the Fiat Ducato:

 

 

 

Back to top

 

 

9.             Tips and tricks

 

-       The backlight unit can get a little bit warm and this may mislead the temperature sensor. It is better to mount the sensor off the PCB and connect it with 4 wires.

-       In my motorhome the backlight goes on when either the contact is on or the light is on. This is achieved with two diodes on both lines from contact and from light to PAD8.

-       Clock accuracy: the time keeping is done using timer1, operated by a 32768 Hz quartz crystal. Normally, the timer causes an interrupt every 2 seconds, but since we set the TMR1 value to about 8000h, this is reduced to once a second. You can play with the 8000h value: increasing it to e.g. 8001h will make the clock run a bit faster, decreasing it will make it run slower. You can even use non integer values, e.g. 8000.5h by incrementing every x interrupts. Using long observation times for the accuracy, you can get the right value for TMR1, resulting in a very high accuracy clock.

 

 

Back to top

 

 

10.          Programming

 

 

The software is written in C (Hi-tech C supporting Microchip). It uses power saving techniques such as Sleep() and wake up from sleep after timer1 overflow.

 

For programming you need the Microchip MPLAB IDE (free to download) and a PICkit3 compatible programmer. You also need the Hi-tech C compiler (the lite version, free to download, will do).

 

Zip file containing all source code, header files and project files: Link to MPLAB project. The project file to open is called CarClockTempVoltMeter_5V.mcp, the workspace file is LCD_CarClockTempVoltMeter_5V.mcw.

 

Connection to a PIC programmer.

The connector marked “M+-DC” should be connected (during programming) to the PICkit3 programmer (M corresponds to the white arrow on the PICkit3).

 

Back to top

 

 

 

 

Home                         Back to Electronic Projects