Haltech PS1000 - PS2000
Haltech PS2000 and PS1000
The following script will map the common Haltech CAN bus channels to RaceCapture/Pro:
--Designed for Haltech PS1000/PS2000 CAN Logging --HALTECH CAN V2 Broadcast Protocol --============================== Set Variables ================================= setTickRate(30) initCAN(0, 1000000) CAN_chan = 0 -- 0=first CAN channel, 1=second --comment out channels if reqd --note Haltech quotes IDs in HEX and must be converted to Decimal --usage: map_chan(var, data, starting byte, byte length, Unit, Offset) CAN_map = { [864] = function(data) map_chan(rpmId, data, 0, 2, 1, 0) map_chan(mapId, data, 2, 2, 0.1, -101.3) map_chan(tpsId, data, 4, 2, 0.1, 0) end, [865] = function(data) map_chan(fpsId, data, 0, 2, 0.1, 0) map_chan(opsId, data, 2, 2, 0.1, 0) end, [866] = function(data) map_chan(idcId, data, 0, 2, 0.1, 0) end, [872] = function(data) map_chan(afrId, data, 0, 2, 0.001, 0) end, [992] = function(data) map_chan(ctsId, data, 0, 2, 0.1, -273.1) map_chan(atsId, data, 2, 2, 0.1, -273.1) map_chan(ftsId, data, 4, 2, 0.1, -273.1) map_chan(otsId, data, 6, 2, 0.1, -273.1) end, [993] = function(data) map_chan(flxId, data, 4, 2, 0.1, 0) end } --=============================== Add Virtual Channels ========================== --usage: addChannel("Name",samplerate{1,10,25,50,100,200},precision(2),min(0),max(1000),units) rpmId = addChannel("RPM", 25, 0, 0, 10000, 'RPM') mapId = addChannel("MAP", 10, 1, 0, 100, 'kPa') tpsId = addChannel("TPS", 10, 1, 0, 100, '%') fpsId = addChannel("FPS", 10, 1, 0, 100, 'kPa') opsId = addChannel("OPS", 10, 1, 0, 100, 'kPa') idcId = addChannel("IDC", 10, 0, 0, 100, '%') afrId = addChannel("AFR", 10, 2, 0, 5, 'Lambda') ctsId = addChannel("CTS", 10, 1, 0, 200, 'C') atsId = addChannel("IAT", 10, 1, 0, 200, 'C') ftsId = addChannel("FTS", 10, 1, 0, 200, 'C') otsId = addChannel("OTS", 10, 1, 0, 200, 'C') flxId = addChannel("FLX", 10, 0, 0, 100, '%') --========================== Init =================================== function onTick() processCAN() end --========================== CAN ============================= function processCAN() --finds an id that exists then passes it to repeat local id, e, data = rxCAN(0) if id ~= nil then -- step through CAN data until you get a value local map = CAN_map[id] if map ~= nil then map(data) --this runs map_chan function with the CAN 'data' end end until id == nil end function map_chan(cid, data, offset, len, mult, add) --eg (rpmId, data, 0, 2, 1, 0) offset = offset + 1 local value = 0 while len > 0 do value = (value * 256) + data[offset] offset = offset + 1 len = len - 1 end setChannel(cid, (value * mult) + add) end