Custom CAN message

Discussion and Support for MoTeC's M1 series ECUs

Re: Custom CAN message

Postby rntechnologies on Tue Aug 28, 2018 3:30 pm

Also wheel speed is generally an easy one if you have access to a dyno.
You can hold the vehicle at a set known speed and get the raw integer off the CANbus, then you can apply scaling to achieve the number you are seeing.
Regards,
Ryan
Powertune Australia
rntechnologies
Pro User
 
Posts: 91
Joined: Tue Aug 07, 2018 9:45 am
Location: Sydney, Australia

Re: Custom CAN message

Postby gtihk on Thu Aug 30, 2018 1:21 pm

I am not too worried about scaling at this stage.
I will try to make a start by adding a Built in Group under ECU and name it CUSTOM RECEIVE.
Within this group I will add Scheduled Functions at different rates.
Do I need to set up a diagnostic channel within this Group?
I shall try to do some switches to see how it goes. May be brake switch or clutch switch.
gtihk
 
Posts: 76
Joined: Thu Jul 19, 2018 1:37 pm

Re: Custom CAN message

Postby rntechnologies on Thu Aug 30, 2018 4:40 pm

There is no need for a diagnostic channel in there, however its advisable to put some code in your function to cater for timeouts.
This can be done using the Delay.Falling method.
Regards,
Ryan
Powertune Australia
rntechnologies
Pro User
 
Posts: 91
Joined: Tue Aug 07, 2018 9:45 am
Location: Sydney, Australia

Re: Custom CAN message

Postby gtihk on Fri Aug 31, 2018 4:58 pm

Please comment.
the Project currently validated with no errors.

Scheduled Function :
local rx = false;

local rxtimeout = false;

local anytimeout = false;

local <Unsigned Integer> h = 0;

/*

* Message 0x43F

*/

h = CanComms.RxOpenStandard(0, 0x43F, 0x000, true);

rx = CanComms.RxMessage(h);

rx = CanComms.RxMessage(h) or rx;

rxtimeout = Delay.Rising(not rx, 0.5);

anytimeout = anytimeout or rxtimeout;



if (rx)

{
if (CanComms.GetBit(h,0))
{
Gear.Neutral Switch State = Gear.Neutral Switch State.Off;
}
else
{
Gear.Neutral Switch State = Gear.Neutral Switch State.On;
}
}
gtihk
 
Posts: 76
Joined: Thu Jul 19, 2018 1:37 pm

Re: Custom CAN message

Postby gtihk on Sat Sep 01, 2018 4:50 pm

To turn on and then off the CEL as the engine starts to run,I use the following :
cancomms.SetBit(h, X, engine.state.AsInteger()<2;//engine not running.

There must be a better way to control the CEL. Anybody please?
gtihk
 
Posts: 76
Joined: Thu Jul 19, 2018 1:37 pm

Re: Custom CAN message

Postby rntechnologies on Wed Sep 05, 2018 9:35 am

Hi gtihk,
At this point, you are best off trialing this with a development ecu and a test car.
You will then be able to iron out everything on the car.

There are countless ways to write the same thing, and every programmer has there own reasons for the way they write things.

If the code works, and it doesn't contain any unnecessary executions, there should be no issues with it.
Regards,
Ryan
Powertune Australia
rntechnologies
Pro User
 
Posts: 91
Joined: Tue Aug 07, 2018 9:45 am
Location: Sydney, Australia

Previous

Return to M1 ECUs

Who is online

Users browsing this forum: No registered users and 7 guests