Megasquirt CAN: Difference between revisions

No edit summary
 
(16 intermediate revisions by the same user not shown)
Line 1: Line 1:
=Megasquirt Dashboard CAN broadcast=
=Megasquirt Integration=
 
This CAN script enables integration with the simplified dashboard mode CAN stream. Refer to the Megasquirt documentation for enabling Dashboard mode CAN broadcast.


Channels enabled:
Channels enabled:
Line 9: Line 7:
* Manifold Absolute Pressure (MAP)
* Manifold Absolute Pressure (MAP)
* Air/Fuel Ratio (AFR)
* Air/Fuel Ratio (AFR)
* And more


Additional channels can be enabled by expanding the script.
==Megasquirt Wiring==


===RaceCapture/Pro MK4, RaceCapture/Track MK3, PodiumConnect MK2===


All of these system use our standard Power+CAN connection. [[Harness_specifications|See Harness Specifications]]


==Megasquirt Wiring==
[[file:M8_4P_male_pinout.jpg|200px]]
 
{| class="wikitable"
|-
! Pin !! Connection !! Notes
|-
| 1 || CAN low || White
|-
| 2 || Power || Red, 9-24v / 1A (~12W)
|-
| 3 || CAN high || Green
|-
| 4 || Ground || Black
|}
 
Connect power and ground to your vehicle power, and then connect:
 
* CAN High to the Megasquirt CAN high wire
* CAN Low to the Megasquirt CAN Low wire


===Megasquirt 2 V3===
===RaceCapture/Apex===
Wire up the CANH / CANL internal jumpers according to the instructions in the [http://www.msextra.com/doc/pdf/MS2V30_Hardware-3.4.pdf Megasquirt Manual]
Use the CAN High and Low connections from either CAN1 or CAN2.  Typically CAN1 is used, so you would use '''CAN 1 High''' and '''CAN 1 Low''.
[[Image:RaceCaptureApex_can_bus_pinout.png|500px]]


If connected per the guide, you CAN connections will be on the following port on the DB37
===RaceCapture/Pro MK3===
Use the CAN High and Low connections from either CAN1 or CAN2 on the 24 pin Molex harness. Typically CAN1 is used, so you would use '''CAN 1 High''' and '''CAN 1 Low'''.


* CAN High - DB37 Pin 3 (SPR1)
[[Image:RaceCapture_Pro_MK3_Molex_CAN_pinout.png|500px]]
* CAN Low - DB37 Pin 4 (SPR2)


Connect CAN High and CAN Low to the corresponding CAN High and CAN Low channel connections on RaceCapture/Pro
===RaceCapture/Pro MK2  MK3 RJ45 and RaceCapture/Track (MK1 / MK2)===
You can use a standard CAT-5 ethernet cable with RJ45 connectors to integrate with RaceCapture/Pro MK2/MK3 and RaceCapture/Track MK2


You can use a standard CAT-5 ethernet cable with RJ45 connectors to integrate with RaceCapture/Pro.
* Note, RaceCapture/Track MK1 can be used, but you must wire it to CAN1


{| class="wikitable" style="text-align:center; width:700px; height:200px;"
{| class="wikitable" style="text-align:center; width:700px; height:200px;"
Line 52: Line 73:
[[File:Canrj45.png]]
[[File:Canrj45.png]]


===MS3 Pro===
===Microsquirt===
[http://www.diyautotune.com/downloads/ms3-pro/ms3pro_wiring.pdf MS3-Pro MS3-Pro wiring]
Connect RaceCapture CAN High / CAN Low to pins 2 and 3 of the Microsquirt wiring harness, according to the instructions in the [http://www.microsquirt.info/uswiring.htm Microsquirt Manual]


CAN bus connections available on MS3-Pro white connector:
===Megasquirt 2 V3===
* CAN High: Pin 34
Wire up the CANH / CANL internal jumpers according to the instructions in the [http://www.msextra.com/doc/pdf/MS2V30_Hardware-3.4.pdf Megasquirt Manual]
* CAN Low : Pin 33


==Photos==
If connected per the guide, you CAN connections will be on the following port on the DB37
[[Image:megasquirt_CAN_RCP.jpg|500px]]


==Enable Megasquirt Dashboard Mode==
* CAN High - DB37 Pin 3 (SPR1)
In TunerStudio, enable CAN dashboard mode and burn it to the controller. Once this is done, RaceCapture/Pro will be receiving CAN bus data from the Megasquirt.
* CAN Low - DB37 Pin 4 (SPR2)


==Integration Script==
Connect CAN High and CAN Low to the corresponding CAN High and CAN Low channel connections on RaceCapture/Pro
Paste this entire script into the Scripting window of RaceCapture/Pro. Ensure any existing script is completely overwritten - do not append to an existing script.


<pre>
'''Note''' Ensure the Megasquirt has the correct internal modifications to allow CAN bus operation; usually requiring the addition of jumpers. Please refer to the Megasquirt documentation for more information.
--This example configured for Megasquirt Dashboard Mode


--how frequently we poll for CAN messages
===MS3 Pro===
tickRate = 30
Refer to the [http://www.diyautotune.com/downloads/ms3-pro/ms3pro_wiring.pdf MS3-Pro MS3-Pro wiring] manual for wiring instructions.
--the CAN baud rate
CAN_baud = 500000
--CAN channel to listen on. 0=first CAN channel, 1=second
CAN_chan = 0
--1 for Big Endian (MSB) mode; 0 for Little Endian mode (LSB)
be_mode = 1


--add your virtual channels here
CAN bus connections available on MS3-Pro white connector:
--addChannel(<name>, <sample rate>, [logging precision], [min], [max], [units label])
* CAN High: Pin 34
rpmId = addChannel("RPM", 10, 0, 0, 8000)
* CAN Low : Pin 33
tpsId = addChannel("TPS", 10, 0, 0, 100, "%")
mapId = addChannel("MAP", 10, 0, 0, 105, "kPa")
cltId = addChannel("Coolant", 1, 0, 0, 250, "F")
afrId = addChannel("AFR", 10, 1, 0, 20)
 
--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 = {
[1512] = function(data) map_chan(mapId, data, 0, 2, 0.1, 0) map_chan(rpmId, data, 2, 2, 1, 0) map_chan(cltId, data, 4, 2, 0.1, 0) map_chan(tpsId, data, 6, 2, 0.1, 0, filter_tps) end,
[1514] = function(data) map_chan(afrId, data, 1, 1, 0.1, 0) end
}


function onTick()
==Enable Megasquirt CAN broadcast==
    processCAN(CAN_chan)
In TunerStudio, enable CAN mode and burn it to the controller. Once this is done, RaceCapture/Pro will be receiving CAN bus data from the Megasquirt.
end


function filter_tps(value)
* '''Note''': Enable CAN broadcast at 1520 in Tuner Studio, and set CAN baud rate to 500K.
  --filter out overflow
  if value > 100 then value = 0 end
  return value


end
==Megasquirt Preset==


--===========do not edit below===========
Once wiring and connections are complete, select the Megasquirt preset under Setup / CAN Channels, and then '''write''' the changes to your RaceCapture system.
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, big endian format
[[image:RaceCapture_Megasquirt_CAN_mapping.png|600px]]
function map_chan(cid, data, offset, len, mult, add, filter)
    offset = offset + 1
    local value = 0
    while len > 0 do
        value = (value * 256) + data[offset]
        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)
==Verifying==
setTickRate(tickRate)
Once connected and with the preset loaded, navigate to the Dashboard screen in the RaceCapture app to verify data  connectivity.
</pre>


==References==
==References==
* [http://www.msextra.com/doc/pdf/Megasquirt_CAN_Broadcast.pdf Full CAN bus mapping]
* [http://www.msextra.com/doc/pdf/Megasquirt_CAN_Broadcast.pdf Full CAN bus mapping]

Latest revision as of 22:13, 23 February 2025

Megasquirt Integration

Channels enabled:

  • Engine RPM (RPM)
  • Throttle Position (TPS)
  • Coolant Temperature (Coolant)
  • Manifold Absolute Pressure (MAP)
  • Air/Fuel Ratio (AFR)
  • And more

Megasquirt Wiring

RaceCapture/Pro MK4, RaceCapture/Track MK3, PodiumConnect MK2

All of these system use our standard Power+CAN connection. See Harness Specifications

M8 4P male pinout.jpg

Pin Connection Notes
1 CAN low White
2 Power Red, 9-24v / 1A (~12W)
3 CAN high Green
4 Ground Black

Connect power and ground to your vehicle power, and then connect:

  • CAN High to the Megasquirt CAN high wire
  • CAN Low to the Megasquirt CAN Low wire

RaceCapture/Apex

Use the CAN High and Low connections from either CAN1 or CAN2. Typically CAN1 is used, so you would use CAN 1 High' and CAN 1 Low. RaceCaptureApex can bus pinout.png

RaceCapture/Pro MK3

Use the CAN High and Low connections from either CAN1 or CAN2 on the 24 pin Molex harness. Typically CAN1 is used, so you would use CAN 1 High and CAN 1 Low.

RaceCapture Pro MK3 Molex CAN pinout.png

RaceCapture/Pro MK2 MK3 RJ45 and RaceCapture/Track (MK1 / MK2)

You can use a standard CAT-5 ethernet cable with RJ45 connectors to integrate with RaceCapture/Pro MK2/MK3 and RaceCapture/Track MK2

  • Note, RaceCapture/Track MK1 can be used, but you must wire it to CAN1
Power, ground and CAN bus connections to RaceCapture/Pro
Connection RaceCapture/Pro (RJ45 cable)
+12v Brown
Ground Orange/White
CAN 1 High Orange
CAN 1 Low Green/White

These color codes assume EIA-T568B RJ45 cable (check printing on the cable to confirm)

  • Note: If you have RaceCapture/Pro powered through the terminal block and grounded at the same location, all you need to wire are the two CAN ligh/CAN low connections. You do not need to separately connect ground and power via the RJ45 port.

Canrj45.png

Microsquirt

Connect RaceCapture CAN High / CAN Low to pins 2 and 3 of the Microsquirt wiring harness, according to the instructions in the Microsquirt Manual

Megasquirt 2 V3

Wire up the CANH / CANL internal jumpers according to the instructions in the Megasquirt Manual

If connected per the guide, you CAN connections will be on the following port on the DB37

  • CAN High - DB37 Pin 3 (SPR1)
  • CAN Low - DB37 Pin 4 (SPR2)

Connect CAN High and CAN Low to the corresponding CAN High and CAN Low channel connections on RaceCapture/Pro

Note Ensure the Megasquirt has the correct internal modifications to allow CAN bus operation; usually requiring the addition of jumpers. Please refer to the Megasquirt documentation for more information.

MS3 Pro

Refer to the MS3-Pro MS3-Pro wiring manual for wiring instructions.

CAN bus connections available on MS3-Pro white connector:

  • CAN High: Pin 34
  • CAN Low : Pin 33

Enable Megasquirt CAN broadcast

In TunerStudio, enable CAN mode and burn it to the controller. Once this is done, RaceCapture/Pro will be receiving CAN bus data from the Megasquirt.

  • Note: Enable CAN broadcast at 1520 in Tuner Studio, and set CAN baud rate to 500K.

Megasquirt Preset

Once wiring and connections are complete, select the Megasquirt preset under Setup / CAN Channels, and then write the changes to your RaceCapture system.

RaceCapture Megasquirt CAN mapping.png

Verifying

Once connected and with the preset loaded, navigate to the Dashboard screen in the RaceCapture app to verify data connectivity.

References