Simple universal digital speedometer based on PIC16F628A. Diagrams and materials Speedometer odometer clock on pic16f628a


The speedometer is designed to measure the speed of a car (motorcycle), a feature of the device is a very wide calibration range, which allows it to work in almost any car with any speed sensor. Initially, the calibration was made for a speed sensor with 6 pulses per 1 revolution and when the ratio of mileage to sensor revolution is 1 mileage = 1 revolution. Speed ​​measurement range 0 ... 255 km per hour. Measurement step - 1 km per hour. The program has a measurement hysteresis, which eliminates the "jitter" of the least significant bit of the indication.

After turning on the power - the speedometer briefly turns on all segments (self-diagnosis) and proceeds to measure the speed. The zero speed flag is set (transistor turns on) when the speed is zero, and cleared when the speed is not zero. This flag can be used for anything, such as illuminating door handles so that they glow green when the car stops. This part of the circuit may not be used at all.

The speedometer is assembled on 2 printed circuit boards connected at an angle of 90 degrees. An indicator is located on the first board, everything else on the second. This solution allows you to very compactly place the speedometer in the housing of the standard panel, or in a separate housing.

Calibration is performed as follows: you need to short-circuit (you can also use a screwdriver) any of the jumpers. The display will show a calibration constant, in the first case it is equal to 150. This is a certain conventional value that does not have any units of measurement. Further, by closing one of the jumpers, you can decrease or increase this constant in the range of 0 ... 255. If you do not touch the jumpers for a few seconds, the device will exit the calibration mode back to the speed measurement mode. The calibration constant will be stored in the non-volatile EEPROM. The exact value of the calibration constant is selected experimentally.

The self-diagnosis indication time is stored in the 1st cell of the EEPROM, by changing this value you can change the screen saver time. To completely turn off the screen saver, you need to write zero in the EEPROM. All this concerns only the 1st EEPROM cell, not zero. The zero cell stores the speedometer calibration constant and changes it with the jump buttons.



File:
The size:
Content:

speed_universal.rar
32.9 KB
PCB drawing (LAY) and firmware files (HEX)

Speedometer-odometer, the idea is not new, but the implementation of such a device has different options, I bring to your attention, a simple circuit on the common ATmega8 MK, there are two types of firmware for the indicators for the circuit; 16x2 and 16x4. , as well as the design of the circuit in the proteus.
The diagram of this speedometer-odometer,

The coefficients for the speed sensor can be adjusted directly from the user menu, for any speed sensor with any (with the number of pulses from 1 to 9999 ……), and also set and adjusted from the user menu, the number of pulses per kilometer.

Circuit characteristics

:

Display of current speed, (display on LCD, for 16x2 from 0.1 km / h, for 16x4 from 0.001 km / h)
total mileage, (display on LCD, for 16x2 from 0.1 km / h, for 16x4 from 0.001 km)
daily mileage (keep .... 20 !!! daily counters, choice No. from the menu),
displaying the activity time of each counter (general and for daily allowances), in other words, travel time.
Ability to customize the overspeed alarm.
the user menu allows you to set all the coefficients (speed and kilometer count) directly from the instrument keyboard.
All data is stored in the controller's memory.


Here I give a description of the operation of the menu and the output of readings for a 16x2 display (for a 16x4 display, this description of work is also completely suitable, only the information is displayed on a 16x4 screen more complete without abbreviations).


Description of the menu.
1) Selection of the number of the personal daily counter km, taking into account the time of the period of cell activity
2) View the personal daily km counter (the one that is displayed in the first line, when you press the enter buttons to the right, it is reset to zero.)
3) Resetting the total (total) km, (does not affect the daily counters)
4) Reset the current account km, (not saved in EEPROM)
5) SETTINGS
5.1) Quartz frequency setting of the ATmega8 quartz resonator clock correction for 1 second (only affects the calculation of the km / h speed)
5.2) Number of pulses from the speed sensor (default 6 pulses)
5.3) Impulse per km, this is the number of impulses from the meter per kilometer (default 600 imp.)
5.4) Clock per second - the internal variable of the internal clock at the PB1 pin, it gives out a short pulse of 0.5Hz, if the clock is in a hurry, the number must be increased, if it lags behind, the number must be decreased.
5.4) maximum speed, - setting the threshold for max. speed (buzzer).
5.5) East defaults - restore default settings.
5.6) Save settings - until you clicked this item - everything is valid only until shutdown.

Such data is stored in the EEPROM;
a) general settings,
b) total readings (the total sum of all counters) with fixation and display of hours, the period of operation of the active state of the speedometer - odometer.
c) 20 personal cells of km readings, with fixation and display of hours, the period of operation of the active state of the displayed cell.
For total and personal data, the INT 0 pin is responsible for storing in memory when the circuit is de-energized, it is connected through a resistor divider, which is connected with 2kOhm to ground and 4.7kOhm to + 12 V power supply of the roll.

Added a description, a diagram, a seal, a screen of fuses for poniprog, corrected the inscriptions for displaying information and menus in the source code, for the direct purpose of the speedometer-odometer device, but in principle the program is quite universal and can be a speedometer, and a frequency counter, and a tachometer, and in general that only your heart desires ... the point is that it counts, very accurately, multiplying the frequency by a coefficient, and calculates the total number of impulses dividing it by a coefficient, in principle, having selected the coefficients, it can work with anything ...

Proteus circuit.

The car suggested below digital speedometer designed for installation in cars with standard analog speedometers controlled by electrical impulses from installed speed sensors. It is also possible to use such a device in case self installation on the car of similar sensors.

The speedometer is based on an inexpensive and affordable microcontroller PIC16F628A... LED indicators are used as information display devices SC10-21YWA(sign height 25.4 mm, yellow light, common cathode) "Kingbrihgt".

The device is connected to the signal contact of the standard analog speedometer. By pressing the button (duplicated by sound), you can change the brightness of the indicators "in a circle". If desired, you can additionally install a latching button to turn off the speedometer power (not shown in the diagram).

With a loosely closed car door (signal low level relative to the body) and a speed of more than 9 km per hour, an intermittent signal is heard, and the speed reading on the indicator is replaced by the abbreviation 'dor' (abbreviated from the English "door" - door) turned on at full brightness.

Power to the speedometer is taken from the ignition switch (contact - "ignition"). Each time you turn it on, the brightness of the indicators is set to what it was previously set by the user. All insignificant zeros on the indicator except for the least significant digit are disabled. When using other similar indicators, it may be necessary to select a selection of current-limiting resistors in the anode circuit of their segments. The sound emitter with a built-in HA1 generator can be replaced with any home-made sound generator with a frequency of 1000-1500 Hz, capable of operating from a 5-volt power source.

The program, which must be entered into the MK using the programmer, will allow the user to choose one of five options for the speedometer, depending on the number of pulses received from the vehicle speed sensor. The proposed digital speedometer "understands" the sensors that produce: 2500 imp / km, 4000 imp / km, 6000 imp / km, 8000 imp / km and 10,000 imp / km. The list can be expanded by making appropriate changes to the program. To date, the author of these lines has come across only the above sensors.

To select the desired option, you must enter service mode, for which you need to install the S1 jumper and then apply power to the device. Now, by pressing the SB1 "Brightness" button (for 1-2 s, with a pause between presses 1-2 s), the desired option is selected:

1 press - 2500 imp / km;
2 clicks - 4000 imp / km;
3 clicks - 6000 imp / km;
4 clicks - 8000 imp / km;
5 clicks - 10,000 imp / km.

3 seconds after the last press, the corresponding number of short sound signals HA1, confirming the entry in the EEPROM of the microcontroller of the desired option. If the service mode is not selected at the first start-up, the speed sensor mode will be automatically set to 2500 imp / km. If the number of taps is more than 5, the Japanese standard (2500) will also be set. To select another operating mode, it is enough to repeat the service procedure from the beginning.

After selecting the desired operating mode, the S1 jumper must be removed. The device is now ready for use.

The reading error is for:

1 option (2500) +0.2 km;
2 options (4000) less than 0.1 km;
3 options (6000) +0.2 km;
4 options (8000) - 0.4 km;
5 options (10,000) less than 0.1 km;

If the number of pulses from the speed sensor is unknown, the following procedure must be performed. Measure 10 meters from the car wheel on a flat section of the road. Connect the dial voltmeter (tester) to the signal contact of the analog speedometer and slowly moving, count the number of "jerking" of the voltmeter needle. Multiply your result by 100.

CONTEST

This article presents a device that is installed in the dashboard of a car and partly replaces the on-board computer.

I'll start with the background.
Once I put a torpedo from a foreign car in the car and realized that the speedometer terribly did not coincide with the real speed indicators. It was decided to install an on-board computer. No sooner said than done. Many functions, etc., over time he refused, and had to do it myself.

From all the functions, I realized that I really only need a few basic ones, so I did.

On the Internet, I spied something separately and brought it all into the finished device presented below.
From the required readings, I chose: an on-board network voltmeter, a speedometer and an odometer (total mileage is not resettable, and daily, resettable).
Also, in my panel I did not show the standard indicator of the fuel level in the tank, I put a switch for the voltmeter readings, it shows either the voltage of the on-board network, or the voltage drop across the tank sensor. The readings, of course, are not in liters, but in some numbers, so I remembered the readings of an empty tank, a quarter, a half, 0.75 tank, and a full one. And according to the readings, I can be guided by the amount of fuel in the tank.

Now about the scheme.

The voltmeter is assembled on a pic16f676 microcontroller, I used PNP transistors
Indicator with a common anode, with dynamic indication for three digits.
The speedometer-odometer uses a pic16f873a microprocessor, transistors operating on anodes, reverse conduction, an indicator for a three-digit speedometer with dynamic indication with a common anode, I took two indicators with OA with dynamics for the odometer.

Sensor Description :

The work algorithm is as follows:
The voltage of 12 volts from the battery is always supplied to the circuit, but from the leg of the ignition lock 15/1 it is supplied to the circuit as power, and to the leg 21 MK, and when the ignition is turned off, the circuit does not immediately de-energize, but data on the mileage is recorded in EEPROM of the controller, when the recording was successful, the microcontroller gives a command to the keys that remove the supply voltage of the entire circuit. During recording, the odometer indicator lights up the inscription "record"
V printed circuit board there is a switch that either supplies power to the anodes of the speedometer directly, or runs through a resistor, which in turn, at night, "mutes" the brightness of the glow, so as not to dazzle, but who does not need it, you can put a jumper on the board. (which I did at home)
When you turn the ignition key, the voltmeter, speedometer and total mileage readings light up, to switch to the daily mileage, you must briefly press the reset button, And to reset the daily mileage, you must hold the same button for a long time, and the word "reset" will appear on the indicator
The circuit works on my machine, and already on a friend's machine. So the circuit is fully operational and tested in the field.
And yet, in the voltmeter, instead of a trimming resistor, I put a constant 13 kOhm (in my case) so that the readings do not get lost under the influence of vibration.
And yet, the photo shows a board from the first experiment, the tracks are not completed there, but you are presented with a completely finished board, with all the changes.

Photo of the finished device

REFERENCE! This speedometer-odometer has nothing in common, except for the principle of operation and some functions, with the speedometer-odometer of Dear MAMEDA. The device was created in 2004 and went around the Internet a little with a tachometer, and did not find support at that time, apparently due to the shortage and price of the microcontroller. Draw your own conclusions!

The device measures the speed in the range of 0-999 km per hour, and also has 2 mileage counters - this is the total and daily mileage. The daily odometer counts not only hundreds, but also tens of meters, as well as thousands of kilometers, which can be called a feature of the device. All functions are controlled by one single button. The indication is made on 7-segment LED indicators: 3-digit without a dot for the speed, and two 3-digit (or 6-digit) with a dot for the mileage counters. The device is calibrated for a 6-pulse speed sensor and a mileage ratio of 6 pulses per 1 meter.

More about the operation of the device: When the ignition is off, the indicators are off and the current consumption is negligible. If you turn on the ignition, the device turns on all segments of the indicators for self-diagnosis (it will be immediately visible if which segment is faulty). Then, after a couple of seconds, the device starts displaying the speed and the previously selected mileage, by briefly pressing the button, the display mode of the daily or total mileage is switched. When the display shows the daily mileage, a long press (more than 2 sec) will reset the daily mileage counter. After turning off the ignition, the device displays the word "RECORD" for a few seconds and all odometer values ​​are recorded in the non-volatile EEPROM memory, so even disconnecting the battery will not reset the odometer.

Each counter has its own format:
General odometer XXXXXX (least significant digit 1 kilometer) 6 digits, no dot.
Daily odometer XXXX.XX (least significant digit 10 meters), 6 digits, 4th point is lit

This device is calibrated for a sensor that has 6 pulses per meter, or 1 meter per revolution. This formula is suitable for most vehicles. (For example! The speedometer is made for a Japanese car, in which 0.62 revolutions is equal to 1 meter (or 1 revolution of 1 mile), and in order not to violate the formula there is a sensor of 10 pulses per 1 meter (0.62 revolutions = 1 meter = 6 pulses, or 1 revolution = 1 mile = 10 pulses).
The instrument can also be calibrated to work with virtually any sensor and travel-to-pulse ratio. This can be done by editing the source text.
Copy the source code into the "MPLAB IDE" program, edit and compile the new corrected HEX file.

IMPORTANT!!!
It is better to put quartz, KX-3HT 10.0 MHz. This is a thermostable resonator operating temperature: from -40 to 85 ° C, it is several times more expensive.
On LEDs for uniform illumination of inscriptions, cut off the lenses and mat the surface in any way available to you.