Haltech PS1000 - PS2000: Difference between revisions

No edit summary
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
=Haltech PS2000=
[[Image:Haltech_PS2000.png]]


Under development.
The following script will map the common Haltech CAN bus channels to RaceCapture/Pro:


The following script will map the common Haltech CAN bus channels:
<pre>
--Designed for Haltech PS1000/PS2000 CAN Logging
--HALTECH CAN V2 Broadcast Protocol
 
--============================== Set Variables =================================


<pre>
setTickRate(30)
--Haltech PS1000 CAN Logging
initCAN(0, 1000000)
CAN_chan = 0 -- 0=first CAN channel, 1=second


tickRate = 10 --polling rate
--comment out channels if reqd
CAN_baud = 1000000 --the CAN baud rate
--note Haltech quotes IDs in HEX and must be converted to Decimal
CAN_chan = 0 --CAN channel to listen on. 0=first CAN channel, 1=second
--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 ==========================


--add your virtual channels here
--usage: addChannel("Name",samplerate{1,10,25,50,100,200},precision(2),min(0),max(1000),units)
--addChannel("Name",samplerate{1,10,25,50,100,200},precision(2),min(0),max(1000),units)
rpmId = addChannel("RPM", 25, 0, 0, 10000, 'RPM')
rpm_Id = addChannel("RPM", 50, 0, 0, 10000, "RPM")
mapId = addChannel("MAP", 10, 1, 0, 100, 'kPa')
map_Id = addChannel("MAP", 10, 0, 0, 100, 'kPa')
tpsId = addChannel("TPS", 10, 1, 0, 100, '%')
tps_Id = addChannel("TPS", 10, 1, 0, 100, '%')
fpsId = addChannel("FPS", 10, 1, 0, 100, 'kPa')
fps_Id = addChannel("FuelPress", 10, 1, 0, 100, 'kPa')
opsId = addChannel("OPS", 10, 1, 0, 100, 'kPa')
ops_Id = addChannel("OilPress", 10, 1, 0, 100, 'kPa')
idcId = addChannel("IDC", 10, 0, 0, 100, '%')
idc1_Id = addChannel("InjDutyCyc", 10, 0, 0, 100, '%')
afrId = addChannel("AFR", 10, 2, 0, 5, 'Lambda')
lambda_Id = addChannel("AFR", 10, 3, 0, 5, 'Lambda')
ctsId = addChannel("CTS", 10, 1, 0, 200, 'C')
cts_Id = addChannel("Coolant", 1, 1, 0, 200, 'C')
atsId = addChannel("IAT", 10, 1, 0, 200, 'C')
ats_Id = addChannel("IAT", 1, 1, 0, 200, 'C')
ftsId = addChannel("FTS", 10, 1, 0, 200, 'C')
fts_Id = addChannel("FuelTemp", 1, 1, 0, 200, 'C')
otsId = addChannel("OTS", 10, 1, 0, 200, 'C')
ots_Id = addChannel("OilTemp", 1, 1, 0, 200, 'C')
flxId = addChannel("FLX", 10, 0, 0, 100, '%')
flex_Id = addChannel("FuelComp", 1, 0, 0, 100, '%')


--customize here for CAN channel mapping
--========================== Init ===================================
--format is: [CAN Id] = function(data) map_chan(<channel id>, data, <CAN offset>, <CAN length>, <multiplier>, <adder>)
CAN_map = {
[360] = function(data) map_chan(rpm_Id, data, 0, 2, 1, 0) end,
[360] = function(data) map_chan(map_Id, data, 2, 2, 10, -1013) end,
[360] = function(data) map_chan(tps_Id, data, 4, 2, 10, 0) end,
--[360] = function(data) map_chan(cps_Id, data, 6, 2, 10, 0) end,
[361] = function(data) map_chan(fps_Id, data, 0, 2, 10, -1013) end,
[361] = function(data) map_chan(ops_Id, data, 2, 2, 10, -1013) end,
--[361] = function(data) map_chan(accel_pos_Id, data, 4, 2, 10, 0) end,
--[361] = function(data) map_chan(waste_gate_pres_Id, data, 6, 2, 10, -1013) end,
[362] = function(data) map_chan(idc1_Id, data, 0, 2, 10, -1013) end,
--[362] = function(data) map_chan(idc2_Id, data, 2, 2, 10, -1013) end,
--[362] = function(data) map_chan(ignL_Id, data, 4, 2, 10, 0) end,
--[362] = function(data) map_chan(ignT_Id, data, 6, 2, 10, 0) end,
[368] = function(data) map_chan(lambda_Id, data, 0, 2, 1000, 0) end,
[3E0] = function(data) map_chan(cts_Id, data, 0, 2, 10, 2731) end,
[3E0] = function(data) map_chan(ats_Id, data, 2, 2, 10, 2731) end,
[3E0] = function(data) map_chan(fts_Id, data, 4, 2, 10, 2731) end,
[3E0] = function(data) map_chan(ots_Id, data, 6, 2, 10, 2731) end,
[3E1] = function(data) map_chan(flex_Id, data, 4, 2, 10, 0) end
}


function onTick()
function onTick()
    processCAN(CAN_chan)
  processCAN()
end
end


--===========do not edit below===========
--========================== CAN =============================
function processCAN(chan)
 
    repeat
function processCAN() --finds an id that exists then passes it to
        local id, e, data = rxCAN(chan)
  repeat
        if id ~= nil then
    local id, e, data = rxCAN(0)
            local map = CAN_map[id]
    if id ~= nil then -- step through CAN data until you get a value
            if map ~= nil then
      local map = CAN_map[id]
                map(data)        
      if map ~= nil then
            end
        map(data) --this runs map_chan function with the CAN 'data'
        end
end
    until id == nil
    end
  until id == nil
end
end


--Map CAN channel
function map_chan(cid, data, offset, len, mult, add) --eg (rpmId, data, 0, 2, 1, 0)
function map_chan(cid, data, offset, len, mult, add)
  offset = offset + 1
  local value = 0
  while len > 0 do
    value = (value * 256) + data[offset]
     offset = offset + 1
     offset = offset + 1
     local value = 0
     len = len - 1
    while len > 0 do
  end
        value = (value * 256) + data[offset]
  setChannel(cid, (value * mult) + add)
        offset = offset + 1
        len = len - 1
    end
    setChannel(cid, (value * mult) + add)
end
end
initCAN(CAN_chan, CAN_baud)
setTickRate(tickRate)
</pre>
</pre>

Latest revision as of 01:47, 31 July 2015

Haltech PS2000.png

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