Project SC300 Road Racer: Part 17 – Get out there! Or not…

Figuring out how to map the CAN channels can be a little tricky. Here’s a few points to take note of, some of which is in the protocol documentation:

  • The Haltech CAN documentation specifies the channel IDs in hexadecimal. The RCP wants them in decimal. Most operating systems’ built in calculators will happily translate hexadecimal (eg: 36C) to decimal (876)
  • Haltech sends pressures as kilopascals (kPa) and “and it is necessary to subtract 101.3 kPa from the final result if gauge pressure is desired”.
  • Haltech’s CAN protocol deals with integers that are then converted at the other end. This means that you will be working with interesting units.
  • Each CAN channel has 8 bytes and Haltech divides them up into different values.
  • Values are signed integers using two’s complement and Big Endian (this has to do with the order of the bits in the bytes)

We configured the Haltech to measure oil pressure, so here’s an example mapping for oil pressure read via CAN:

  • Haltech says oil pressure is on channel 0x361 (Hex 361 -> decimal 865)
  • Oil pressure is on bytes 2-3
  • Oil pressure is measured in 0.1 kPa

So, in the RaceCapture app, we would configure:

  • Channel named OilPress
  • CAN Bus 1
  • CAN ID 865
  • Offset 2 (starts at 2nd byte)
  • Length 2 (2 bytes long — #2 and #3)
  • Signed
  • Big Endian

The last thing to do is set the formula for the channel. If you did nothing, you would see a number like 2750, which would be very confusing.

  • The unit for the channel is actually 0.1 kPa, so 2750 is actually 2750 * 0.1 or 275 kPa
  • 1 PSI is 0.1450377 kPa

To convert the CAN value to PSI, your formula in the RaceCapture app would be:

  • Times 0.0145
  • Divided by 1.0
  • Plus 0

2750 * 0.0145 / 1 + 0 = 39.875

We would expect ECU Manager to show a value of ~40PSI for the oil pressure, assuming we had told it to use imperial units.

Similarly, temperatures are measured in 0.1 Kelvins, which is slightly more annoying to convert. If you’re an imperial guy (I am), you can find a formula for Kelvin to Fahrenheit conversion that looks like:

T(°F) = T(K) × 9/5 – 459.67

Since you can’t enter “9/5” in the formula box, you would use 1.8. However, the Haltech is outputting 0.1Kelvin, so you actually want to use 0.18.

  • Times 0.18
  • Divided by 1.0
  • Plus -459.67

Take some time to figure out which channels you want to log or pay attention to, and go through and map them all. In the ECU manager software, be sure to configure which CAN output you’re using (in our case we ended up using the top / auxillary CAN port instead of the original hardwired port).

 


Power everything up and switch the RaceCapture app to the data overview page.

The overview page will show all of the values that the RaceCapture knows about and in real-time. It’s similar to ECU Manager’s diagnostic page. A great way to figure out if you have the initial CAN wiring and programming figured out is to simply manipulate the gas pedal and watch the TPS value change. If it works, you’ve got the CAN settings all correct. If it doesn’t, you either forgot to set the CAN baud rate correctly, you didn’t fully power cycle the RaceCapture, or you have your CAN Hi/Lo wires backwards. The RaceCapture has an internal termination resistor, so make sure that it is the last device on your Haltech CAN hub and that you’ve wired it as a “black” connector (with the termination loop on the HUB side).

Now things really start to get tricky. You have to write a script.

 


The scripting interface in the RaceCapture app.

The RaceCapture uses a scripting language called Lua which is actually a very common one. If you have zero experience programming in any language at all, this is all going to be way over your head, and I don’t intend to give you a primer in this article series. Autosport Labs has an active forum, which includes a Lua scripting subsection, where you can ask questions and find example scripts. There’s also a wiki with a Lua scripting guide as well as a page full of Lua script examples, too.

While the syntax of Lua is very simple and writing basic things is not hard, it took me a while to figure out exactly what I needed to do with respect to the script. It needed to do a few different things:

  • It needed to retransmit (mirror) all of the Haltech information to the CD-7 dash CAN bus
  • It needed to transmit the GPS information to the CD-7 dash CAN bus

That’s it. While this seems trivial on the surface, it proved to be rather complicated. This link is the final version of the script I ended up with. I used all of the aforementioned resources to come to this. Here’s some details on what’s inside:

  • Some copied and pasted functions that generate CAN messages for the GPS (speed, lat, lon, altitude) and IMU (yaw, pitch roll) which will be read by the AEM CD-7 dashboard
  • Some copied and pasted functions (from the same place) that properly break down 16- and 32-bit values into multiple bytes
  • A special loop that will read data off the #1 CAN bus for 10 milliseconds and retransmit it on the #2 bus
  • Optional settings to print information to the RaceCapture App script log

The reality is that it took us quite some time to figure this all out, with quite a bit of trial and error, and a number of forum posts back and forth between myself and the Autosport Labs folks. And, as stated before, we decided not to bother with the retransmit in the end, and are going to wire one of the AEM CD-7’s two CAN channels directly into the Haltech bus. We still need to send GPS data to the dash, though, so that the dash can do predictive timing for us.

But, if we wanted, we could also use the RaceCapture/Pro MK2’s predictive lap time information and send that to the dash. Either way.

5 comments

  1. Small world indeed. I have been keeping up with your build for a while. Very envious of the wiring job. The CD-7 is a great product but it is so new that there isn’t much guidance on how to customize. We may be swapping to an AIM product.

    1. If you need any help with your CD-7 just let me know. Happy to dig into it. AEM tech support is also super helpful. Let me know next time you come through Atlanta!

Leave a Reply

Your email address will not be published. Required fields are marked *

*
*