Hondata KPro4: Difference between revisions
(enhanced instructions) |
(→Script) |
||
Line 30: | Line 30: | ||
--This example adopted to Hondata KPro4 CAN output | --This example adopted to Hondata KPro4 CAN output | ||
tickRate = 30 | tickRate = 30 | ||
--the CAN baud rate | --the CAN baud rate |
Revision as of 16:12, 20 July 2016
Introduction
The following script adapts the Hondata KPro4 CAN to RaceCapture/Pro
Supported Channels
This integration supports the following channels:
- RPM
- EcuVolts
- IAT
- EngineTemp
- TPS
- MAP
- InjectorPW
- Ignition
- Knock
- CamTiming
Wiring
Use the supplied Hondata harness and connect the CAN High / CAN Low to the corresponding CAN High / CAN Low on the RaceCapture/Pro CAN 1 channel. See the [CAN_Bus_Integration|CAN integration guide]] for wiring details.
CAN termination
The KPro4 does not have built-in CAN termination. You will need to also connect a 120 ohm resistor across the CAN High / CAN Low connections at the connections to the KPro4.
Script
Copy and paste this script into the scripting window of RaceCapture/Pro. Ensure any existing script is removed.
--This example adopted to Hondata KPro4 CAN output tickRate = 30 --the CAN baud rate CAN_baud = 250000 --CAN channel to listen on. 0=first CAN channel, 1=second CAN_chan = 0 --add your virtual channels here rpmId = addChannel("RPM", 25, 0, 0, 9000, "RPM") vltId = addChannel("EcuVolts", 10, 1, 0, 20, "volts") iatId = addChannel("IAT", 1, 0, 0, 100, "F") ectId = addChannel("EngineTemp", 1, 0, 0, 150, "F") tpsId = addChannel("TPS", 10, 0, 0, 100, "%") mapId = addChannel("MAP", 10, 2, -15, 25, "PSI") injId = addChannel("InjectorPW", 10, 3, 0, 100, "ms") ignId = addChannel("Ignition", 10, 0, -20, 20, "D") lmdId = addChannel("AFR", 10, 3, 0, 2, "lambda") knkId = addChannel("Knock", 1, 0, 0, 15, "count") camId = addChannel("CamTiming", 10, 0, -20, 20, "D") function toF(value) return value * 1.8 + 32 end function toAFR(value) return value * 14.7 end --customize here for CAN channel mapping --offset/length in bytes? --format is: [CAN Id] = function(data) map_chan(<channel id>, data, <CAN offset>, <CAN length>, <multiplier>, <adder>) CAN_map = { --did not bother logging gear speed and target cam angle [1632] = function(data) map_chan(rpmId, data, 0, 2, 1, 0) map_chan(vltId, data, 5, 1, 0.1, 0) end, [1633] = function(data) map_chan(iatId, data, 0, 2, 1, 0, toF) map_chan(ectId, data, 2, 2, 1, 0, toF) end, [1634] = function(data) map_chan(tpsId, data, 0, 2, 1, 0) map_chan(mapId, data, 2, 2, 0.0145037738, -14.7) end, [1635] = function(data) map_chan(injId, data, 0, 2, 0.001, 0) map_chan(ignId, data, 2, 2, 1, 0) end, [1636] = function(data) map_chan(lmdId, data, 0, 2, 0.00003051757, 0, toAFR) end, [1637] = function(data) map_chan(knkId, data, 0, 2, 1, 0) end, [1638] = function(data) map_chan(camId, data, 2, 2, 1, 0) end } function onTick() processCAN(CAN_chan) processLogging() end function processLogging() if getGpio(1) < 1 then startLogging() else stopLogging() end end --===========do not edit below=========== function processCAN(chan) repeat local id, e, data = rxCAN(chan) if id ~= nil then local map = CAN_map[id] if map ~= nil then map(data) end end until id == nil end --Map CAN channel, big endian format function map_chan(cid, data, offset, len, mult, add, filter) offset = offset + 1 local value = 0 while len > 0 do value = (value * 256) + data[offset] offset = offset + 1 len = len - 1 end local cv = value * mult + add if filter ~= nil then cv = filter(cv) end setChannel(cid, cv) end initCAN(CAN_chan, CAN_baud) setTickRate(tickRate)