Help with Mercedes w211 E55

Discussions on CAN mapping for ECUs, sensors, PDMs, and more.
Bewbzout
Posts: 24
Joined: Fri Jan 20, 2017 4:00 pm
Location: Oregon

Post by Bewbzout »

I cleared everything hit write and then read. After it read the configuration nothing showed up so I then added this script

-- Log messages from CAN bus -- be sure to set the correct baud rate in the CAN settings -------------------------------------------------- -- change this to 0 for CAN bus 1, or 1 for CAN bus 2 canBus = 0 -------------------------------------------------- --this function drains all pending CAN messages --and outputs messages to the log function outputCAN() repeat id, ext, data = rxCAN(canBus, 1000) if id ~= nil then print('[' ..id ..']: ') for i = 1,#data do print(data ..', ') end println('') end until id == nil println('Timeout: no CAN data') end function onTick() outputCAN() end setTickRate(30)

It said the exact same thing as above. No numbers.

brentp
Site Admin
Posts: 6282
Joined: Wed Jan 24, 2007 6:36 am

Post by brentp »

Hi, really odd that you're not seeing output after that script. Can you save your current configuration and attach it to a reply here? I'd like to see if it's getting munged somehow, preventing it from running and you seeing any output.

Sorry for the hassle, we'll figure it out!
Brent Picasso
CEO and Founder, Autosport Labs
Facebook | Twitter

Mitch Detailed
Posts: 5
Joined: Tue Feb 07, 2017 4:29 am
Location: Murfreesboro TN
Contact:

Post by Mitch Detailed »

yeah, i convinced him to go RCP, knowing it's featureset and limited understanding of the scripting process (and complications of scripting) involved, i'm used to a can config similar to link g4+ for setup.

i'm sending him a new cable tomorrow, i Remember that I hooked up both Can 1 and 2 to both H and L can on the oem hub, so I'm anticipating the 120ohm terminating resistor possibly being a reason behind the issues.

as for the reverse engineering part, all the variables are straight forward for the most part, but they're using bitmasks on nearly every one aside from TPS that makes things difficult. I also don't currently own a RCP system so it definitely makes it difficult to help identify exact problems.

growing pains make us taller. we will persevere

Mitch Detailed
Posts: 5
Joined: Tue Feb 07, 2017 4:29 am
Location: Murfreesboro TN
Contact:

Post by Mitch Detailed »

Can Id= 0x236 (566)
Information is in the first 2 bytes, So:
Length=2 and,
Offset=0
The Variable inside the 2 bytes is xxx##### ######xx, So:
Bitmask= 0x1FFC

Steering Wheel Centerline value =1024,
Locked Left value= 776
Locked Right value = 1272

run the variable through the formula x*1/8+-128,

you get a min/max of -31 and 31

If anyone is interested in explaining how this variable script would be initiated, i'm all ears

brentp
Site Admin
Posts: 6282
Joined: Wed Jan 24, 2007 6:36 am

Post by brentp »

Hi Mitch, are you also helping out Bewbzout?

Bewbzout, if you can save and attach your config here, I can double check to make sure there's nothing amiss with the script. Thanks!
Brent Picasso
CEO and Founder, Autosport Labs
Facebook | Twitter

Bewbzout
Posts: 24
Joined: Fri Jan 20, 2017 4:00 pm
Location: Oregon

Post by Bewbzout »

Sorry I haven't replied for awhile. Work has been crazy. I will try and get that to you soon Brent. Thank you again guys for the help.

Mitch Detailed
Posts: 5
Joined: Tue Feb 07, 2017 4:29 am
Location: Murfreesboro TN
Contact:

Post by Mitch Detailed »

brentp wrote:Hi Mitch, are you also helping out Bewbzout?
Yessir, everything has been referenced for me to help him out.

MikeD
Posts: 39
Joined: Sun May 29, 2016 11:55 am
Location: Austria
Contact:

Post by MikeD »

Hi Bewbzout and Mitch,

Mitch? we've been in contact via FB messenger some days ago or am I wrong?

Do you have a CAN script up and running which is mapping some parameters as it should, and just need to extract the steering angle, which you are asking for in the thread above?

With the data you provided here is what I would add when using just the scripting area (and not the direct CAN mapping, where I have not played around much at all and there seems to be a bug in Version 2.11.0 too)
SteerAngleId = addChannel("SteerAngle", 25, 3, -31, 31, 'unit') --unknown units

CAN_map = {
[566] = function(data) processSteering(data)
end}

function processSteering(data)
local loByte = bit.band(data[2], 0xFC)
local hiByte = bit.band(data[1], 0x1F)
local value = ((hiByte * 64) + (loByte / 4)) * 0.125 - 128
setChannel(SteerAngleId, value)
end
I did not tested this on the bench but you may try it out and come back with your findings.
Otherwise if you have no CAN script running at all then come back here too.

-Mike

Bewbzout
Posts: 24
Joined: Fri Jan 20, 2017 4:00 pm
Location: Oregon

Post by Bewbzout »

Ok finally I got CAN data. I have some questions on how I got it though. First Mitch sent me another cable with only one channel which could be it but I don't think so. Second I'm wondering if this whole time using my tablet was the problem instead of hooked up to the laptop with the cable? Third which I believe is the the problem was when I would copy that script using my tablet it would put the script into a sentence format.

Anyway I'm totally stoked that I can finally start using this thing.

Next is to see if I can get some data

brentp
Site Admin
Posts: 6282
Joined: Wed Jan 24, 2007 6:36 am

Post by brentp »

Glad you're getting further!

Connecting via laptop or via wireless won't change the CAN operation, once it is setup correctly.
Brent Picasso
CEO and Founder, Autosport Labs
Facebook | Twitter

Bewbzout
Posts: 24
Joined: Fri Jan 20, 2017 4:00 pm
Location: Oregon

Post by Bewbzout »

So Mitch had me load this script for steering angle

--Testing for Josh Chapin
--Steering angle test

--how frequently we poll for CAN messages
tickRate = 30
--the CAN baud rate
CAN_baud = 500000
--CAN channel to listen on. 0=first CAN channel, 1=second
CAN_chan = 0

--add your virtual channels here
--format addChannel(<name>, <sample rate>, <precision>, <min>, <max>, [units])
--muxId = addChannel("Mux", 10, 0, -30, 130, "C")
--coolantId = addChannel("tCoolant", 10, 0, -30, 130, "C")
--rpmId = addChannel("RPM", 10, 0, 0, 20000)
--rpm2Id = addChannel("RPM2", 10, 0, 0, 20000)
--tpsvId = addChannel("vTPS", 10, 2, 0, 5)
--tpsId = addChannel("rTPS", 10, 2, 0, 16, "#")
--batId = addChannel("vBatt", 10, 1, 0, 20, "#")
--airtId = addChannel("tAir", 10, 0, -30, 130,"C")
--gearId = addChannel("Gear", 10, 0, 0, 6,"#")
--oilpId = addChannel("pOil", 10, 1, -30, 130,"C")
--oiltId = addChannel("tOil", 10, 0, 0, 8,"bar")
--ignId = addChannel("iOut", 10, 1, -20, 60,"deg")
--injId = addChannel("zInjection", 10, 0, 0, 720,"deg")
--lamId = addChannel("lMeasured", 10, 3, 0, 2,"#")
--manId = addChannel("pManifold", 10, 1, 0, 300,"kPaA")
--lamsId = addChannel("lSetpoint", 10, 3, 0, 2,"#")
--lauId = addChannel("Launch", 10, 3, 0, 2,"#")
SteerAngleId = addChannel("SteerAngle", 25, 3, -31, 31, 'Degrees')

----------------------------------------
--customize here for CAN channel mapping
--format is:
--[CAN Id] = function(data) map_chan(<chan_id>, <data>, <CAN offset>, <CAN length>, <multiplier>, <adder>, [filter])
----------------------------------------
[566] = function(data) processSteering(data)
end}

function processSteering(data)
local loByte = bit.band(data[2], 0xFC)
local hiByte = bit.band(data[1], 0x1F)
local value = ((hiByte * 64) + (loByte / 4)) * 0.125 - 128
setChannel(SteerAngleId, value)
--CAN_map = {
--[814] = function(data)
--if map_chan(muxId, data, 0, 1, 1, 0) == 1 then
--map_chan(coolantId, data, 1, 1, 0.62745, -30)
--map_chan(rpmId, data, 2, 2, 1, 0)
--map_chan(tpsvId, data, 4, 1, 0.019608, 0)
--map_chan(tpsId, data, 5, 1 , 1, 1)
--map_chan(batId, data, 6, 1, 0.078, 0)
--map_chan(airtId, data, 7, 1, 0.62745, -30)
--elseif map_chan(muxId, data, 0, 1, 1, 0) == 2 then
--map_chan(oilpId, data, 2, 1, 1, 0)
--map_chan(oiltId, data, 3, 1, 0.62745, -30)
--map_chan(mapsId, data, 4, 1, 1, 0)
--end
end
}

function onTick()
processCAN(CAN_chan)
end
--===========do not edit below===========
function processCAN(chan)
local msg = 0
repeat
local id, e, data = rxCAN(chan, 0)
if id ~= nil then
local map = CAN_map[id]
if map ~= nil then
map(data)
end
end
msg = msg + 1
until id == nil or msg > 100
end


--Map CAN channel, little endian format
function map_chan(cid, data, offset, len, mult, add, filter)
if offset + len > #data then return end
offset = offset + 1
local value = 0
local shift = 1
while len > 0 do
value = value + (data[offset] * shift)
shift = shift * 256
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)

I am getting a startup error that states

([string "--testing for josh chapin..."] :37.0: unexpected symbol error


Anyone know what it's referring to and what we need to do to change the script? Thank you

dewittpayne
Posts: 67
Joined: Sun Dec 11, 2016 1:07 am

Post by dewittpayne »

The obvious conclusion is that '--' is not the 'ignore comment line' character. Try removing all the comments and see what happens.

brentp
Site Admin
Posts: 6282
Joined: Wed Jan 24, 2007 6:36 am

Post by brentp »

The -- is actually valid syntax in Lua, denoting a comment.

The error is likely further down, and the point it referenced is where it thinks the start of the error exists.
Brent Picasso
CEO and Founder, Autosport Labs
Facebook | Twitter

brentp
Site Admin
Posts: 6282
Joined: Wed Jan 24, 2007 6:36 am

Post by brentp »

Looks like the error is around the use of the } symbols, it appears to be unbalanced.

[566] = function(data) processSteering(data)
end}

Recommend asking the person that supplied it to you to test it again and possibly fix the error; it's hard to tell from here how it should work. They can possibly provide a quick fix for you!
Brent Picasso
CEO and Founder, Autosport Labs
Facebook | Twitter

MikeD
Posts: 39
Joined: Sun May 29, 2016 11:55 am
Location: Austria
Contact:

Post by MikeD »

Although I did not wrote the script but just suggested how the steering angle could be calculated some posts above and given some information from before, here is the slightly modified script you posted lately... give it a try and come back with your findings please!
--Steering angle test

--how frequently we poll for CAN messages
tickRate = 30
--the CAN baud rate
CAN_baud = 500000
--CAN channel to listen on. 0=first CAN channel, 1=second
CAN_chan = 0

--add your virtual channels here
--format addChannel(<name>, <sample rate>, <precision>, <min>, <max>, [units])
--muxId = addChannel("Mux", 10, 0, -30, 130, "C")
--coolantId = addChannel("tCoolant", 10, 0, -30, 130, "C")
--rpmId = addChannel("RPM", 10, 0, 0, 20000)
--rpm2Id = addChannel("RPM2", 10, 0, 0, 20000)
--tpsvId = addChannel("vTPS", 10, 2, 0, 5)
--tpsId = addChannel("rTPS", 10, 2, 0, 16, "#")
--batId = addChannel("vBatt", 10, 1, 0, 20, "#")
--airtId = addChannel("tAir", 10, 0, -30, 130,"C")
--gearId = addChannel("Gear", 10, 0, 0, 6,"#")
--oilpId = addChannel("pOil", 10, 1, -30, 130,"C")
--oiltId = addChannel("tOil", 10, 0, 0, 8,"bar")
--ignId = addChannel("iOut", 10, 1, -20, 60,"deg")
--injId = addChannel("zInjection", 10, 0, 0, 720,"deg")
--lamId = addChannel("lMeasured", 10, 3, 0, 2,"#")
--manId = addChannel("pManifold", 10, 1, 0, 300,"kPaA")
--lamsId = addChannel("lSetpoint", 10, 3, 0, 2,"#")
--lauId = addChannel("Launch", 10, 3, 0, 2,"#")
SteerAngleId = addChannel("SteerAngle", 25, 3, -31, 31, 'Degrees')

----------------------------------------
--customize here for CAN channel mapping
--format is:
--[CAN Id] = function(data) map_chan(<chan_id>, <data>, <CAN offset>, <CAN length>, <multiplier>, <adder>, [filter])
----------------------------------------

function processSteering(data)
local loByte = bit.band(data[2], 0xFC)
local hiByte = bit.band(data[1], 0x1F)
local value = ((hiByte * 64) + (loByte / 4)) * 0.125 - 128
setChannel(SteerAngleId, value)
end

CAN_map = {
[566] = function(data) processSteering(data)
--[814] = function(data)
--if map_chan(muxId, data, 0, 1, 1, 0) == 1 then
--map_chan(coolantId, data, 1, 1, 0.62745, -30)
--map_chan(rpmId, data, 2, 2, 1, 0)
--map_chan(tpsvId, data, 4, 1, 0.019608, 0)
--map_chan(tpsId, data, 5, 1 , 1, 1)
--map_chan(batId, data, 6, 1, 0.078, 0)
--map_chan(airtId, data, 7, 1, 0.62745, -30)
--elseif map_chan(muxId, data, 0, 1, 1, 0) == 2 then
--map_chan(oilpId, data, 2, 1, 1, 0)
--map_chan(oiltId, data, 3, 1, 0.62745, -30)
--map_chan(mapsId, data, 4, 1, 1, 0)
--end
end
}

function onTick()
processCAN(CAN_chan)
end
--===========do not edit below===========
function processCAN(chan)
local msg = 0
repeat
local id, e, data = rxCAN(chan, 0)
if id ~= nil then
local map = CAN_map[id]
if map ~= nil then
map(data)
end
end
msg = msg + 1
until id == nil or msg > 100
end


--Map CAN channel, little endian format
function map_chan(cid, data, offset, len, mult, add, filter)
if offset + len > #data then return end
offset = offset + 1
local value = 0
local shift = 1
while len > 0 do
value = value + (data[offset] * shift)
shift = shift * 256
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)

Post Reply