Diccionari.cat
Optimot, consultes lingüístiques

Contingut: vista del tacòmetre digital. Source: Momex.cat

Digital Tachometer for Harley Davidson Sportster (Part 1 - Introduction)

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.

Contingut: HD Sportster speedometer. Source: Momex.cat
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, ...

Part 1 - Introduction
Part 2 - Communication Bus and sensors
Part 3 - Harley Davidson and SAE J1850 VPW
Part 4 - Bus Messages
Part 5 - Tachometer Benchmarking
Part 6 - Design and functions
Part 7 - Components
Part 8 - Schematics and BOM
Part 9 - PCB design
Part 10 - Prototypes evolution
Part 11 - Source code and libraries
Part 12 - Housing design and brackets
Part 13 - Wiring harness and installation
Part 14 - Final result and videos
Part 15 - Issues during development and improvements

(1) Have you ever been riding in 5th gear and tried to upshift when there is no 6th?

Digital Tachometer for Harley Davidson Sportster (Part 2 - Communication Bus and sensors)

Part1 / Part2 / Part3 / Part4 / Part5 / Part6 / Part7 / Part8 / Part9 / Part10 / Part11 / Part12 / Part13 / Part14 / Part15

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.

...Read more

Digital Tachometer for Harley Davidson Sportster (Part 3 - Harley Davidson and SAE J1850 VPW)

Part1 / Part2 / Part3 / Part4 / Part5 / Part6 / Part7 / Part8 / Part9 / Part10 / Part11 / Part12 / Part13 / Part14 / Part15

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.
...Read more

Digital Tachometer for Harley Davidson Sportster (Part 4 - Bus Messages)

Part1 / Part2 / Part3 / Part4 / Part5 / Part6 / Part7 / Part8 / Part9 / Part10 / Part11 / Part12 / Part13 / Part14 / Part15

Messages and Headers:

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:

Remark1: "???" Messages are those not identified.
Remark2: last byte from these messatges will always be the CRC, but it is not represented on the tables.


ECU Information R/S byte# Formula
#0 #1 #2 #3 #4 #5
E
N
G
I
N
E
RPM S 28 1B 10 02 XX YY rpm = (hex2dec(xx)*256+hex2dec(yy)) / 4
Speed S 48 29 10 02 XX YY kph= (hex2dec(xx)*256+hex2dec(yy)) / 128
MIL S 68 88 10 03 - - Active Failure tell-tale
83 - - Inactive Failure tell-tale
Gear S A8 3B 10 03 XX - 0xXX = 0x00, 0x02, 0x04, 0x08, 0x0A, 0x14
(decimal: 0,2,4,8,10,20) for 1st-5th gears
Eng Temp S A8 49 10 10 XX - ºC = hex2dec(XX) - 40
Odometer S A8 69 10 06 XX XX Resolution bit=0,4 meters
Odometer2 S A8 69 10 86 XX XX Same as before
Resolution de bit=0,4 meters
Fuel Consump S A8 83 10 0A XX XX Resolution bit=0,00005 liters
Fuel Consump 2 S A8 83 10 8A XX XX Same as before
Resolution bit=0,00005 liters
Low Voltage tell-tale R C8 88 10 0E - - Request to METER.
Answer:C8 88 61
#6 ??? - Network Control R 8C FE 10 60 - - Unknown Secondary ID (60)
#7 ??? - Network Control S 28 FF 10 01 XX - XX:0x07 o 0x06 (Unknown)
ECU Engine Status - Network Control S 68 FF 10 XX - - XX:0x03 (Node awaken) o 0x04 (Sleep Node)
#11 ??? - Vehicle Security S 28 93 10 02 XX - XX:0x00 (Unknown)
#12 ??? - Vehicle Security S 68 93 10 20 XX - XX:0x01 (Unknown)
#13 ??? - Vehicle Speed Control S 68 63 10 26 XX - XX:0x00 i 0x01 (Unknown)
Vehicle Speed Control R 68 62 10 XX - - XX:0x01 (Speed Control System ON/OFF)
XX:0x21 (Switch ON/OFF active)
#15 ??? - Vehicle Speed Control S 09 63 10 XX - - XX:0x20 (Unknown)
...Read more

Digital Tachometer for Harley Davidson Sportster (Part 5 - Tachometer Benchmarking)

Part1 / Part2 / Part3 / Part4 / Part5 / Part6 / Part7 / Part8 / Part9 / Part10 / Part11 / Part12 / Part13 / Part14 / Part15

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 €):

  • Installation Dificulty: ★★☆☆☆
    HD Sportster Tachometer. Source: Harley Davidson Speedometer and Tachometer bracket Ref#: 67182-07. Source: Harley Davidson Harness Ref# 68811-07. Source: Harley Davidson

    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).

    ...Read more

    Digital Tachometer for Harley Davidson Sportster (Part 6 - Design and functions)

    Part1 / Part2 / Part3 / Part4 / Part5 / Part6 / Part7 / Part8 / Part9 / Part11 / Part12 / Part13 / Part14 / Part15

    This part will be divided into two sections and for each one I will summarize the most important ideas I have come up with.

    Conceptual design

    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:

    HD Sportster Tachometer. Source: Momex.cat Draft. Source: Momex.cat

    ...Read more

    Digital Tachometer for Harley Davidson Sportster (Part 7 - Components)

    Part1 / Part2 / Part3 / Part4 / Part5 / Part6 / Part7 / Part8 / Part9 / Part10 / Part11 / Part12 / Part13 / Part14 / Part15

    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).

    Basic circuit diagram. Source: Momex.cat
    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.

    Microchip PIC18F2553

    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.

    ...Read more

    Digital Tachometer for Harley Davidson Sportster (Part 8 - Schematic and BOM)

    Part1 / Part2 / Part3 / Part4 / Part5 / Part6 / Part7 / Part8 / Part9 / Part10 / Part11 / Part12 / Part13 / Part14 / Part15

    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 ):

    Content: Harley tachometer schematic. Source: Momex.cat

    And the list of components or BOM (Bill Of Materials):

    ...Read more

    Digital Tachometer for Harley Davidson Sportster (Part 9 - PCB Design)

    Part1 / Part2 / Part3 / Part4 / Part5 / Part6 / Part7 / Part8 / Part9 / Part10 / Part11 / Part12 / Part13 / Part14 / Part15

    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).

    7 SEGMENTS

    Content: 7-segments schematic. Source: Momex.cat Content: Pinout 7-segments. Source: Momex.cat Content: footprint 7-segments. Source: Momex.cat Content: STEP vista 3D 7-Segments. Source: Momex.cat

    PIC18F2553

    Content: PIC schematic. Source: Momex.cat Content: Pinout PIC. Source: Momex.cat Content: footprint PIC. Source: Momex.cat Content: STEP veiw 3D PIC. Source: Momex.cat

    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.

    Content: Component footprints on the PCB layout, Altium Designer. Source: Momex.cat
    ...Read more

    Digital Tachometer for Harley Davidson Sportster (Part 10 - Prototypes evolution)

    Part1 / Part2 / Part3 / Part4 / Part5 / Part6 / Part7 / Part8 / Part9 / Part10 / Part11 / Part12 / Part13 / Part14 / Part15

    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.

    Protoboard

    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.

    Images

    Content: Initial Protoboard. Source: Momex.cat Content: Protoboard with power supply and oscilloscope. Source: Momex.cat Content: wire mess on protoboard. Source: Momex.cat
    ...Read more

    Digital Tachometer for Harley Davidson Sportster (Part 11 - Source code and libraries)

    Part1 / Part2 / Part3 / Part4 / Part5 / Part6 / Part7 / Part8 / Part9 / Part10 / Part11 / Part12 / Part13 / Part14 / Part15

    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:

    Generic libraries

    • cdefs.h
    • 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

    • j1850.c
    • j1850.h

    MM5450 driver related functions

    • MM5450.c
    • MM5450.h

    Main

    • macros.h
    • main.c

    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.

    // define J1850 VPW timing requirements in accordance with SAE J1850 standard
    // all pulse width times in us 
    // receiving pulse width
    #define RX_SHORT_MIN	us2cntT0CON8(34)      // minimum short pulse time
    #define RX_SHORT_MAX	us2cntT0CON8(96)      // maximum short pulse time
    #define RX_LONG_MIN	us2cntT0CON8(96)      // minimum long pulse time
    #define RX_LONG_MAX	us2cntT0CON8(163)     // maximum long pulse time
    #define RX_SOF_MIN	us2cntT0CON8(123)     // l'he posat a 153 (abans 163) minimum start of frame time
    #define RX_SOF_MAX	us2cntT0CON8(279)     // l'he posat a 249 (abans 239) maximum start of frame time
    #define RX_EOD_MIN	us2cntT0CON8(163)     // minimum end of data time
    #define RX_EOD_MAX	us2cntT0CON8(239)     // maximum end of data time
    #define RX_EOF_MIN	us2cntT0CON8(239)     // minimum end of frame time, ends at minimum IFS
    #define RX_BRK_MIN	us2cntT0CON8(239)     // minimum break time
    #define RX_IFS_MIN	us2cntT0CON8(280)     // minimum inter frame separation time, ends at next SOF
    ...Read more

    Digital Tachometer for Harley Davidson Sportster (Part 12 - Housing design and brackets)

    Part1 / Part2 / Part3 / Part4 / Part5 / Part6 / Part7 / Part8 / Part9 / Part10 / Part11 / Part12 / Part13 / Part14 / Part15

    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)

    Content: HD bracket 67338-97. Source: eBay Content: HD bracket 67338-97. Source: eBay Content: HD bracket 67338-97. Source: Momex.cat
    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.

    Content: Gauge cover from an old analog speedo. Source: Momex.cat

    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:

    sudo apt-get install freecad

    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.

    Content: Creation of the 3D model tachometer housing. Source: Momex.cat Content: Creation of the 3D model tachometer housing. Source: Momex.cat
    ...Read more

    Digital Tachometer for Harley Davidson Sportster (Part 13 - Wiring harness and installation)

    Part1 / Part2 / Part3 / Part4 / Part5 / Part6 / Part7 / Part8 / Part9 / Part10 / Part11 / Part12 / Part13 / Part14 / Part15

    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:

    Content: HD Sportster schematic. Source: google

    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.

    ...Read more

    Digital Tachometer for Harley Davidson Sportster (Part 14 - Final result and videos)

    Part1 / Part2 / Part3 / Part4 / Part5 / Part6 / Part7 / Part8 / Part9 / Part10 / Part11 / Part12 / Part13 / Part14 / Part15

    Finally!! here you have some images and videos of the project.

    Content: Digital DIY Tachometer for Harley Davidson Sportster. Source: Momex.cat
    ...Read more

    Digital Tachometer for Harley Davidson Sportster (Part 15 - Issues during development and improvements)

    Part1 / Part2 / Part3 / Part4 / Part5 / Part6 / Part7 / Part8 / Part9 / Part10 / Part11 / Part12 / Part13 / Part14 / Part15

    Issues:

    • 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, ….


    Improvements:

    • 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. Salut

    Content: Homemade Digital Tahcometer for Sportster. Source: Momex.cat

    Project index:
    Part1 / Part2 / Part3 / Part4 / Part5 / Part6 / Part7 / Part8 / Part9 / Part10 / Part11 / Part12 / Part13 / Part14 / Part15