While driving a vehicle we all have in mind at least a couple of basic indicators that will give us an idea of the speed and the engine RPMs. In trucks or passenger cars it is common to have more information but in a motorcycle, due to the available space, there is a limitation of info. We can find some models that have 2 gauges with the speedo and a tachometer and other models with one gauge and a LCD to show the speed.
If we look at cheaper bikes or engines that don’t rev up too much, everything gets much simpler. The indicators of a Harley Davidson Sportster are very basic, you can find a speedo gauge, some tell tales (fuel, engine check, …) and a small LCD display to show the odometer, two partials and the current time.
For a person obsessed with control like me, this ammount of information was obviously not enough, so I decided to start a long term project (almost took me 4 years) in order to design some kind of display to give me some extra information like engine RPMs and gear engaged.(1).
Learning a bit of electronics and develope my own PCBs was a pending item in my checklist, so I decided to go for it. As everything I've learned comes from the open source / free software I decided to create this blog in order to return my learnings to the community.
I will divide this project in 14 parts where I will explain the different steps I followed, schematics, designs, code, ...
In this second part we will focus in the motorcycle electronics and in knowing what we can/cannot use.
Nowadays, all vehicles with a minimum of technology have a communication bus that connects all different control units. The main advantadge is pretty clear, if each control unit had its own sensors, the weight and cost of the vehicle would be higher due to some sensors and harnesses would be redundant. With a communication bus, each control unit can have a mínimum of sensors attached and then broadcast the information through the bus to the other control units and in case it needs other information, find it there.
The best and shortest way to understand this protocol is to read this document. The longest way is to read directly the SAE J1850 documentation. Nevertheless, in this post I will try to summarize the most relevant concepts of this protocol in order to be able to write the proper code to receive and interpret the ECM messages.
According to the standard SAE J1850 VPW, in our bike we will have 1-wire data bus where the information will be broadcasted based on different voltage levels and tranmission timings. These levels are:
Passive: 0 - 3,5V (natural state of the data bus)
Active: 4,25V - 20V (control units can activate the bus through transistors)
Main bus properties are:
Serial bus: information is sent bit by bit.
Asynchronous: broadcasted information between nodes is managed by the same emitter instead of beeing synchronized by another clock signal.
Master-less: there is no node with superiority over the others.
Peer to peer: All nodes have same capability to transmit.
One important property of the nodes is that when one is transmitting to the data bus, it listens to itself to check if what it says is the same that is in the data bus. In following lines we will understand why.
Following tables gather some of the messages that are being broadcasted through a 2011 Sportster Iron (XL883N) J1850 VPW bus for each one of the present control units (Engine, Display and Body Controller). Information has been obtained from:
Easiest way to start a project is always doing a benchmarking or market analysis. Doing this, we will be able to know what do we want, how do we want it and if we can reduce the complexity of the project by using already existing components.
Harley Davidson - Analog tachometer Kit 67182-07 (Price April'16: HD USA 337 USD / HD UE 524 €):
This is the solution that HD gives to all of you wanting to incorporate a second gauge with an analog tachometer into your Sportster. According the installation manual, this kit has, as interesting part for our project, a double gauge bracket (ref#: 67338-97) and a specific harness (ref#: 68811-07).
This part will be divided into two sections and for each one I will summarize the most important ideas I have come up with.
After doing a little bit of research and benchmarking, knowing the ideas that I liked the most, understanding what ideas are available and knowing which are my theoretical & manufacturing limitations, these are my conclusions:
2 gauges: This will allow me to keep the stock speedometer with its information (odometer).
Simplification: I will use the bracket 67338-97 for the 2 gauges that comes with the Tachometer kit 67182-07. On ebay you can find them from time to time. With this, PCB shape and size (∅85mm) and housing (∅90mm) are already set.
The Harness could also be purchased on ebay (68811-07) but, it will be cheaper if I make it by myself. It is only needed 3 wires (+12V, GND and bus J1850) and no specific connector.
Tell-tales and displays:: 7-Segments and LEDs.
Gauge face: vinyl, stiker or similar.
A draft idea would be something similar like the following images:
In this part I will list the components and integrated circuits (IC) I have used. Below, there is a basic circuit diagram (full schematic will be detailed in the next part).
Remark: Digit3 driver will be used alternatively with the RPM bar. In RPM mode we will see all 4 digits but in the rest of modes, Digit3 will remain OFF and the RPM bar will show the RPMs. This is done because the rest of modes can work perfectly with only 3 of the 4 digits.
The PIC18F2553 is the project brain. I would lie to you if I say that I chose this particular brand and model because it was the best of the best (best performance, best price, …). Frankly speaking, I chose it because it was the MCU family I started to work with when I decided to learn electronics. That and because it had enough pins to carry out this project.
So far, everything we have done has been to investigate about the SAE J1850 protocol, check on the Internet about which components are available and think how we are going to build this tachometer. Now it is time to start the practical part, this means, start to define the schematic to allow us, afterwards, design the PCB (Printed Circuit Board).
In order to do it we will use specific electronic design software that we can find on the following list. In my case, I have used Altium Designer.
Here, you have the schematic (PDF / Altium ):
And the list of components or BOM (Bill Of Materials):
In this 9th part I will show you some of the steps I followed up to do this PCB design.
1) To be able to do the schematic or the PCB layout, Altium Designer requires some libraries where it can find the components information we will use. It will be necessary to have 2 libraries, one for the schematic with, for example, the number of IC pins, and antoher library for the PCB with the footprins and the position of the terminals. Additionally, if you want to be able to see a 3D version of your PCB, it is in this second library where you have to include the 3D files (STEP format). Following figures show a couple of examples where we can see from left to right (schematic, terminal list, footprint and a 3D model using STEP files).
2) Once the schematic is done (part8), we can proceed to build the PCB. To do so, we will need to transfer all the component footprints to the PCB shape we choose.
On this section, I will show the different parts of this project and the evolution on each step. As you will see, on every step I used different prototype platforms and I will explain its pros and cons.
All and each one of you have had a protoboard in your hands when you started to built simple electronic circuits. I did the same and the first prototype was built with a protoboard I had on my drawer. So, I started by lighting a LED with a PIC, then multiplexing a LED matrix, creating a data bus, interruptions, etc… Pros: Immediate availability when trying to test new circuits. Cons: You can suffer from bad connections (intermitent connections, disconnections, shorts,…) that can lead you astray and kill your desire of building something bigger. You can easily waste hours or days just because a simple cable was having a bad connection. I would not recommend it for complex circuits.
Once the code is uploaded to the new Github repository (DIGTACHO), in this post I will try to summarize all the important parts of this project. As seen below, 4 subgroups have been defined in order to categorize each one of the programming files:
inttypes.h Note: Other libraries needed to compile this project such as p18f2553.h, timers.h, string.h, usart.h, stdio.h, pwm.h are already included in MPLAB software and that's why they are not included in this subgroup.
SAE J1850 related functions
MM5450 driver related functions
In theory, all the files should have english comments to explain what is the code doing. Nevertheless, I will try to write a short explanation of what I think are the most interesting / important parts:
Interesting code in j1850.h
Timming definition and the function used for configuring PIC Timer0 according to SAE J1850 protocol.
Following list will summarize the parts included on the housing and bracket assembly for the speedometer and tachometer:
1-Dual gauge bracket (ref#: 67338-97) (seen on Part5)
Note: It is important to take care of the gauge "rear horns" that are used to center and fix the position of the speedo and tachometer. The housing used for the tachometer will need to have a specific space to fit correctly.
2-Gauge cover and glass from an old analog speedometer:
In order to avoid humidity issues I will reuse the gauge cover from an old analog speedometer bought some time ago to get some ideas for this project.
3-3D printed housing:
Following design has been done with FreeCAD v0.15. According wiquipedia, FreeCAD is a parametric CAD 3D design tool. It is opensource (GPL and LGPL license) and focused in mechanical engineering, industrial engineering and architecture. It is available for Ubuntu by typing the following command:
It can not be compared with other professional CAD tools, but FreeCAD offers enough resources to allow the design of complex models. The housing, as you will see, is quite simple and as beeing my first 3D printed design I feel quite satisfied. The design can be summarized in 5 steps:
3.1- Exterior part: In workbench “Part Design”, we will create a sketch on the X-Z and will draw the shape of the housing. Afterwards, with the option revolve, we will be able to revolve 360º in order to have the basic housing shape.
Once we have the PCB, the housing and the bracket, now we “only” need the harness. There are a thousand ways to connect the PCB to the 3 wires that will allow it to operate (12V, Ground and J1850 data bus). We can choose the cheap option (3 wires from the PCB to some part of the harness) or the expensive one (ref# 68811-07 HD harness that comes with the tachometer ref#67182-07).
Let’s go first to take a look on the schematic (spedometer side) to understand what do we have there:
As you see, there is a harness that goes from the speedometer through the 39A/B connector to a subharness and from there to the HD main harness through the 20A connector. This connector is located just under the fuel tank, as seen in the following pictures.
First and main issue was.. how the hell do I make this project?! It was my first electronic project and I had to think & plan basically all the steps (quite stressful).
The J1850 VPN trasnceivers were discontinued and not available in the main online electronic stores. Luckily, I was able to find 3 IC on eBay and I was able to build my first dummy control unit that was broadcasting messages all the time on the data bus. For the final design I manage to replace the IC by a couple of transistors and resistors.
The lack of experience when soldering electronic parts and in particular SMD components. I lost 2 PCB on the way but I learnt the lesson to start always by soldering the most difficult components first.
I suffered many times problems on the PCB, usually due to my poor soldering skills that created micro joint cracks. I spent sometimes weeks trying to find the rootcause and that caused many times to loose hope.
Poor test & lab equipment, for example a computer 12V fixed power supply to simulate the battery of the bike. Anyway, I have to say that even with some basic equipment if you want to do something you can do it. With time I manage to buy a decent soldering station, a decent multimeter, scope, ….
The software still has some minor glitches that I don’t care to solve. For example, from time to time some number that should not be there appears on the gear indicator, but as fast as it comes, it goes away.
Need to implement the fuel consumption function on the tachometer.
Brightness can be increased or decreased by user request, except for the gear indicator that is fixed and it could disturb at night.
All the LEDs used on the RPM bar or on the mode indicator can not be seen when driving at daylight.
When the sun shines from the rear of the bike, it is not possible to read the 7 segments (even with full brightness).
Rear switch does not perform as expected sometimes. The connector should be improved.
3D printed housing could be improved in many ways. It does not have a PCB fixing tab, only a position tab. Also it could be improved the hole on the back of the housing to avoid/reduce humidity entrance.
Design and print a vinyl for the tachometer cover. Currently, it has a printed paper that is now deteriorated due to the humidity and the sun.
Any other question or request, please leave a comment below or send me an email.