Haltech PS1000 - PS2000: Difference between revisions
No edit summary |
No edit summary |
||
Line 79: | Line 79: | ||
end | end | ||
initCAN(CAN_chan, CAN_baud) | initCAN(CAN_chan, CAN_baud) | ||
setTickRate(tickRate) | setTickRate(tickRate) | ||
</pre> | </pre> |
Revision as of 17:07, 14 July 2015
Haltech PS2000
Under development.
The following script will map the common Haltech CAN bus channels:
--Haltech PS1000 CAN Logging tickRate = 10 --polling rate CAN_baud = 1000000 --the CAN baud rate CAN_chan = 0 --CAN channel to listen on. 0=first CAN channel, 1=second --add your virtual channels here --addChannel("Name",samplerate{1,10,25,50,100,200},precision(2),min(0),max(1000),units) rpm_Id = addChannel("RPM", 50, 0, 0, 10000, "RPM") map_Id = addChannel("MAP", 10, 0, 0, 100, 'kPa') tps_Id = addChannel("TPS", 10, 1, 0, 100, '%') fps_Id = addChannel("FuelPress", 10, 1, 0, 100, 'kPa') ops_Id = addChannel("OilPress", 10, 1, 0, 100, 'kPa') idc1_Id = addChannel("InjDutyCyc", 10, 0, 0, 100, '%') lambda_Id = addChannel("AFR", 10, 3, 0, 5, 'Lambda') cts_Id = addChannel("Coolant", 1, 1, 0, 200, 'C') ats_Id = addChannel("IAT", 1, 1, 0, 200, 'C') fts_Id = addChannel("FuelTemp", 1, 1, 0, 200, 'C') ots_Id = addChannel("OilTemp", 1, 1, 0, 200, 'C') flex_Id = addChannel("FuelComp", 1, 0, 0, 100, '%') --customize here for CAN channel mapping --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() processCAN(CAN_chan) 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 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 len = len - 1 end setChannel(cid, (value * mult) + add) end initCAN(CAN_chan, CAN_baud) setTickRate(tickRate)