100%
retro-gauge pcb-main view
Description

Imported from GitHub: h4ctar/retro-gauge · commit a7ec970 · license GPL-3.0

Description

Open Source Motorcycle Tachometer

README

Retro Gauge

Introduction

This is an open source motorcycle tacho project with the following features:

  • Analog tachometer
  • Digital speedometer
  • Odometer
  • Trip meter
  • Battery voltage
  • Standard indicators (turn signals, oil pressure, neutral and high beam)
  • Clock

It is housed in a classic round casing, with a retro looking 8 digit starburst LCD.

The toolchain is all open source; the PCB's are designed with KiCad and the case is designed in FreeCAD.

Assembly

System Design

The system design is simple, the only interesting decision is that the indicators all go via the microcontroller, this lets us do fun things with the indicators (test them when powered on or reuse the oil pressure indicator for other warnings).

System Design

Microcontroller

An ATmega328P-PU microcontroller will be used to process all the inputs, and drive the outputs.

Here are all the required inputs and outputs:

FunctionTypeNumber of pins
TachoDigital input1
SpeedoDigital input1
Oil pressureDigital input1
Turn signalsDigital input1
NeutralDigital input1
High beamDigital input1
Mode buttonDigital input1
Battery voltageAnalog input1
Stepper motorDigital output4 (could be 3)
RBG LEDsDigital output1
LCDDigital output3
ISPDigital IO3 (can be shared)
Real time clockDigital IO2

For a total of 18 digital IOs and one analog input, the ATmega328P-PU has more than enough at 23 programmable IO lines.

The ATmega328P-PU also has 1024 bytes of EEPROM which can be used to store the configuration, trip and odometer values.

An external 16 MHz crystal will be used to run the ATmega328P-PU at it's fastest clock speed.

The microcontroller will be programmed with an in-circuit serial programmer (ICSP). A bootloader doesnt need to be burned when using ICSP.

ATmega328P

The low byte fuses configure the clock:

BitNameDescriptionValue
7CKDIV8When set, divides the clock speed by 81
6CKOUTWhen set, the clock pulse is output on PB01
5SUT1Sets start up delay time1
4SUT01
3CKSEL3Sets the clock source1
2CKSEL21
1CKSEL11
0CKSEL01

The high byte fuses:

BitNameDescriptionValue
7RSTDISBLExternal reset disable1
6DWENDebug wire enable1
5SPIENEnable serial programming0
4WDTONWatchdog timer always on1
3EESAVEPreserve EEPROM memory through chip erase0
2EBOOTSZ1Sets the bootloder size memory1
1EBOOTSZ01
0BOOTRSTSelect the reset vector0

The extended fuses:

BitNameDescriptionValue
7Not used1
61
51
41
31
2BODLEVEL2Sets the brown-out detector level1
1BODLEVEL10
0BODLEVEL01

There is a simple Makefile that compiles and links the code and has targets to burn the fuses and the code.

Power Supply

A linear voltage regulator will be used to convert the bikes rough 14V down to a smooth 5V for the rest of the system. A smoothing capacitor is added on the bikes side to help smooth out the input before it gets to the regulator.

Power Supply

Indicator Lights

There are indicator lights for low oil pressure, neutral, high beam and turn signals.

The oil pressure and neutral sensors are simple switches to ground. So these will be directly connected to digital input pins. I'm not sure if the internal pull ups will be good enough so there will be provision on the PCB for external pull up resistors. There will be a diode to protect against connecting this pin to 12V on the bike.

Neutral

The highbeam and turn signals indicators should light up when they see 12V. We'll use an optocoupler to give some extra protection. The left and right turn signals need to go through diodes to stop them turning each other on.

Turn Signals

Diode forward voltage: 0.715V
Photodiode forward voltage: 1.3V
Photodiode forward current: 10mA
R1 = (14V - 0.715V - 1.3V) / 10mA = 1200 ohm ~= 1k ohm
CTR: 50%
Output current: 50% of 10mA = 5mA
Output voltage: 4V
R2 = (5V - 4V) / 5mA = 200 ohm

Tachometer

There are a few choices for the tachometer pickup, an inductive or capacitive pickup on one of the spark plug wires, or a hall effect sensor on a rotating part of the engine. The most robust solution is to go with the hall effect sensor, and the most universal location for it is in replacement of the mechanical drive off the camshaft of the original tachometer.

Tachometer

Speedometer

The speedometer will also be a hall effect pickup, but will be a simpler design with a few magnets on the wheel and an NPN hall effect sensor mounted on an axel spacer.

Speed Pickup

Real Time Clock

A PCF8563T RTC module will be used to keep the time for the clock. It will have a coin cell to keep the clock ticking when the key is off.

RTC

LCD

The VIM-878-DP-FC-S-LV LCD display will be used. It is a transflective LCD so works well in both bright sunlight and at night with a backlight. It is an 8 character 14 (plus 2) segment "starburst" display. It has a total of (14 + 2) * 8 = 128 segments and uses 4 backplanes.

LCD Segment Names

The HT1621B will be used to drive the LCD. There are some existing Arduino libraries to interface with it. It can drive 32 segments by 4 commons which is exactly what is required to drive the selected LCD.

The schematic of the driver to the display follows the application notes in the datasheet and is optimised for the PCB layout. It is controlled with 3 pins that are also used by the ICSP.

LCD Schematic

LCD PCB

This table has the LCD segments from the datasheet and what memory address they are according to the PCB layout:

LCD PinCOM0COM1COM2COM3Memory address
11D1E1FCA131
21L1K1J1I30
32D2E2FCA229
42L2K2J2I27
53D3E3FCA328
63L3K3J3I26
74D4E4FCA425
84L4K4J4I24
95D5E5FCA523
105L5K5J5I22
116D6E6FCA621
126L6K6J6I20
137D7E7FCA719
147L7K7J7I18
158D8E8FCA817
168L8K8J8I16
17COM0
18COM1
19COM2
20COM3
21DP88C8B8A15
228M8N8G8H14
23DP77C7B7A13
247M7N7G7H12
25DP66C6B6A11
266M6N6G6H10
27DP55C5B5A9
285M5N5G5H8
29DP44C4B4A7
304M4N4G4H6
31DP33C3B3A5
323M3N3G3H4
33DP22C2B2A3
342M2N2G2H2
35DP11C1B1A1
361M1N1G1H0

From this table we can see that each digit is powered by 4 LCD pins that map to 4 memory addresses. For example digit 1 is LCD pins 35, 1, 2 and 36, which map to memory address' 1, 31, 30 and 0.

The font maps ASCII characters to the segments in order CA,F,E,D,I,J,K,L,A,B,C,DP,H,G,N,M. The segments are in this order so the nibbles match the memory layout of the driver.

The address mapping maps digits to the 4 memory addresses that the font nibbles should be written to.

DigitAddress'
11,31,30, 0
23,29,27, 2
35,28,26, 4
47,25,24, 6
59,23,22, 8
611,21,20,10
713,19,18,12
815,17,16,14

This font table and address mapping should be enough to display text on the LCD.

Stepper motor

The X27.168 stepper motor will be used, it is designed for gauges and can be directly driven from a microcontroller.

People on the internet say that clamping diodes are required, so they will be added.

Motor

The X25 datasheet shows the required pattern to step the motor.

Step Pattern

Indicators

Neopixels

PCB Design

There are three PCBs: the main board, the sensor board and the face board. The boards are stacked using standoffs and are connected together with 2.54mm stacking header pins.

The main board has the microcontroller, stepper motor, LCD, real time clock and indicators. The sensor board has the power supply and the signal conditioning. The face board is the dial face and has transparent icons for the indicators.

Main PCB

Case Design

The case is 3D printed out of ASA.

Case

EEPROM

The ODO, trip and configuration will be stored in EEPROM.

EEPROM has like 100,000 writes before it wears out, so in order to be able to store the ODO and trip we will need to be able to rotate to new address'. To do this we will have a table at the start of the EEPROM that stores the address of each value and if the EEPROM gets corrupt we will find a new place to store it and update the table.

AddressSizeDescription
08ODO Address
18Trip Address
28Wheel diameter
158Next available address
1632ODO value
2032Trip value

Firmware

The source code is in the firmware/src directory.

There is a makefile with a default target to compile and link the source into a hex file; a burn target to burn this hex to the micro and a fuses target to write the fuses. It is configured to use avrdude and a usbtiny programmer to talk to the microcontroller, but it should be possible to modify it to use other methods. The code is compiled with clang. There is a compile_flags.txt file that is used to configure a language server so that Vim or Visual Studio Code can give nice completion and code navigation.

On Arch linux I install the following tools and dependencies:

  • llvm
  • clang
  • avrdude
  • avr-libc
  • lib32-glibc

Datasheets

Comments
Sign in to comment

No comments yet. Be the first to ask about this board.