broadcasting analog inputs over CAN

Discussions on CAN mapping for ECUs, sensors, PDMs, and more.
Post Reply
Mike Golden
Posts: 1
Joined: Wed May 03, 2017 2:24 am

broadcasting analog inputs over CAN

Post by Mike Golden »

I'm looking to broadcast some of the analog inputs I have plugged into my racecapture mk3 over the CAN link so my ECU (megasquirt) can use them. I don't currently see a way to do that.

Am I missing it, or is it just not possible yet?

boggie1688
Posts: 138
Joined: Fri Apr 07, 2017 3:47 pm
Location: Oakland, CA

Post by boggie1688 »

txCAN(channel, id, isExtended, data, [timeout] ) available in firmware 2.0 Transmit a CAN message.

params
channel: The CAN channel. 0 for the first channel, 1 for the 2nd, if supported on the hardware
identifier: The Identifier value of the message, either in standard (11 bit) or extended (29 bit) format.
isExtended: 0 for Standard (11 bit) Identifier or 1 for Extended (29 bit) Identifier.
data: CAN message payload; array up to 8 elements long.
timeout: (optional) specify a timeout for sending this message. if the transmit queue is full, will block for the specified milliseconds. Defaults to 100ms

returns
1 if successful, 0 if failed, nil if parameters are incorrect

Example:

channel = 0
id = 1234
ext = 0
data = {11,22,33}
res = txCAN(channel, id, ext, data)
I wonder if you can combine the getAnalog() with the above function. Store the output of getAnalog() as a variable, then use that inside the data payload.

I think the output of getAnalog() is already scaled to decimal, so you'll need to rescale it to hexa for the txCAN, and the try transmitting it back onto the bus to see if you can see it. Easy way to check is to println() and see what the getAnalog() output is.

Maybe something like this:

function getSens5()
sensor5 = (getAnalog(5)*.019608)
msg = {sensor5}
txCAN(0, 9999, 0, msg)
end

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

Post by brentp »

Good news, we have an example for that:

https://wiki.autosportlabs.com/RaceCapt ... ture_value

The value that is extracted from getAnalog() is the value after it's been scaled. So if your dashboard is reading 200 for engine temperature on the first analog input, then

getAnalog(0) will return 200.

Hope this helps!
Brent Picasso
CEO and Founder, Autosport Labs
Facebook | Twitter

Post Reply