Method to turn off engine

Testing and development of Megasquirt 3

Moderators: jsmcortina, muythaibxr

makro
MS/Extra Newbie
Posts: 25
Joined: Fri Aug 08, 2014 5:30 am

Method to turn off engine

Post by makro »

Hi guys,

I am wanting to implement a type of safety system that will turn off the engine in case of a situation where oil pressure or fuel pressure reaches a critically low level.
These levels would be pre-defined in a table of upper and lower limits in a micro controller program. I currently have an Arduino (It's a micro-controller for those of you who haven't heard of it) interfaced to the MS3 via CANBus, and I would plan to have these oil pressure sensor and fuel pressure sensors wired to the Arduino. The exact reason for me using my own micro-controller is it's performing a whole bunch of other stuff for my twin-charging project.

I was wondering if these was a memory address I can target in the MS3 through the CANBus that would allow me to turn off the engine? Either that, or use one of the input pins on the MS3 and then somehow get the MS3 to turn off the engine based on the input?
If such thing doesn't exist, would it be hard to implement?

The only downside I can see to doing this is the risk that the engine will turn off whilst doing a significant speed, and that might suddenly lock the drive-line up. I'm also thinking if the throttle body is open enough then the car would decelerate at an acceptable rate rather than lock the drive-line. I'm willing to test these theories off road :)

I know I could put in a secondary relay on the fuel or ignition circuit and then control that with my micro controller, but I figure the cleaner solution is to let Megasquirt kill the engine for me.

Any ideas would be welcomed!

Cheers,
Matt
makro
MS/Extra Newbie
Posts: 25
Joined: Fri Aug 08, 2014 5:30 am

Re: Method to turn off engine

Post by makro »

By the way, I can also see something like this being used for anyone who wants to implement their own car security system where the engine won't turn on until it gets a specific HIGH/LOW/CANBus signal/message from your own electronics.
jsmcortina
Site Admin
Posts: 39617
Joined: Mon May 03, 2004 1:34 am
Location: Birmingham, UK
Contact:

Re: Method to turn off engine

Post by jsmcortina »

Oil pressure control is already a feature in MS3.

Yes, you can send an "Al-CAN" message to shut the engine down.

Send 0x8502 to table 7 offset 683 for spark cut. 0x8503 for fuel and spark cut.

James
I can repair or upgrade Megasquirts in UK. http://www.jamesmurrayengineering.co.uk

My Success story: http://www.msextra.com/forums/viewtopic ... 04&t=34277
MSEXTRA documentation at: http://www.msextra.com/doc/index.html
New users, please read the "Forum Help Page".
makro
MS/Extra Newbie
Posts: 25
Joined: Fri Aug 08, 2014 5:30 am

Re: Method to turn off engine

Post by makro »

jsmcortina wrote:Oil pressure control is already a feature in MS3.

Yes, you can send an "Al-CAN" message to shut the engine down.

Send 0x8502 to table 7 offset 683 for spark cut. 0x8503 for fuel and spark cut.

James
Thanks James! Exactly what I was looking for. Once I am done with the spark/fuel cut, how do I clear the flags so I can start the engine again? Or does that happen automatically??

In regards to the oil pressure control, how do I access the setup of it in TunerStudio? I had a look over the menus today and couldn't really find much on it.
I was actually just looking over the ms3-1.3.2 source code about 30 minutes ago and I did in fact see the method for the oil pressure control.

Cheers.
Reverant
Super MS/Extra'er
Posts: 1233
Joined: Sat Apr 15, 2006 12:39 am
Location: Athens, Greece

Re: Method to turn off engine

Post by Reverant »

jsmcortina wrote:Oil pressure control is already a feature in MS3.

Yes, you can send an "Al-CAN" message to shut the engine down.

Send 0x8502 to table 7 offset 683 for spark cut. 0x8503 for fuel and spark cut.

James
Bug report: Works great, but only above cranking RPM.

Below cranking RPM, I get fuel, no spark, even though the both Fuel Cut and Spark Cut indicators are on.

So basically, I get fuel when below cranking RPM even though the Fuel Cut indicator is on.

This is on 1.3.2 release.

MSQ needed?
The man behind MS Labs
2005 Audi A3 2.0L TFSI DSG AWD - Extreme MS3
2002 Mazda Miata 1.8 6sp - Enhanced MS3 1.4.0, sequential injection, sequential ignition, big turbo, lots of boost
jsmcortina
Site Admin
Posts: 39617
Joined: Mon May 03, 2004 1:34 am
Location: Birmingham, UK
Contact:

Re: Method to turn off engine

Post by jsmcortina »

MSQ and datalog. I've tested and it works for me.

James
I can repair or upgrade Megasquirts in UK. http://www.jamesmurrayengineering.co.uk

My Success story: http://www.msextra.com/forums/viewtopic ... 04&t=34277
MSEXTRA documentation at: http://www.msextra.com/doc/index.html
New users, please read the "Forum Help Page".
makro
MS/Extra Newbie
Posts: 25
Joined: Fri Aug 08, 2014 5:30 am

Re: Method to turn off engine

Post by makro »

James, I can't find where in TunerStudio the oil pressure control stuff is. Forgive me, however how do I get to it?
JAM
Master MS/Extra'er
Posts: 626
Joined: Sun Jan 22, 2006 7:58 pm
Location: Cincinatti,OH

Re: Method to turn off engine

Post by JAM »

makro wrote:James, I can't find where in TunerStudio the oil pressure control stuff is. Forgive me, however how do I get to it?
you can always type into the search field in the upper right corner of tunerstudio, i often do that when i cant remember a screen location that i do not use often- it comes up and will take you to the menu. they did a good job with that feature
makro
MS/Extra Newbie
Posts: 25
Joined: Fri Aug 08, 2014 5:30 am

Re: Method to turn off engine

Post by makro »

JAM wrote:
makro wrote:James, I can't find where in TunerStudio the oil pressure control stuff is. Forgive me, however how do I get to it?
you can always type into the search field in the upper right corner of tunerstudio, i often do that when i cant remember a screen location that i do not use often- it comes up and will take you to the menu. they did a good job with that feature
I have used the search terms "oil", "pressure", and "safety" and can't seem to find anything. Is it possible that I'm missing menus or something??
jsmcortina wrote:Oil pressure control is already a feature in MS3.

Yes, you can send an "Al-CAN" message to shut the engine down.

Send 0x8502 to table 7 offset 683 for spark cut. 0x8503 for fuel and spark cut.

James
What type of CAN message type do I have to use? I have just tried with MSG_CMD and the indicators did not show in TunerStudio with either types of cut. I have confirmed the data is good with logging through my own C++ class for the CAN board for the Arduino. I can see the message being sent on the CAN board as well. So far all other CAN interfacing with the Megasquirt has been successful. Any ideas?

Arduino output:
TYPE : 0
FROM ID : 1
TO ID : 0
VAR_BLK : 7
VAR_OFFSET : 683
DLC : 2
DATA 0 : 133
DATA 1 : 3
DATA 2 : 0
DATA 3 : 0
DATA 4 : 0
DATA 5 : 0
DATA 6 : 0
DATA 7 : 0

C++ CAN control output:
--- HEADER ---
1010101
1101000
1000
111000
10
^--- DATA ---
10000101
11
0
0
0
0
0
0
Reverant
Super MS/Extra'er
Posts: 1233
Joined: Sat Apr 15, 2006 12:39 am
Location: Athens, Greece

Re: Method to turn off engine

Post by Reverant »

Any chance you are on older firmware? I think the above only works in 1.3+.
The man behind MS Labs
2005 Audi A3 2.0L TFSI DSG AWD - Extreme MS3
2002 Mazda Miata 1.8 6sp - Enhanced MS3 1.4.0, sequential injection, sequential ignition, big turbo, lots of boost
makro
MS/Extra Newbie
Posts: 25
Joined: Fri Aug 08, 2014 5:30 am

Re: Method to turn off engine

Post by makro »

Reverant wrote:Any chance you are on older firmware? I think the above only works in 1.3+.
Good pickup!! I'm on 1.2.3... so I dare say that will be the cause of it. Will update firmware tomorrow and post back results. Thanks!
Reverant
Super MS/Extra'er
Posts: 1233
Joined: Sat Apr 15, 2006 12:39 am
Location: Athens, Greece

Re: Method to turn off engine

Post by Reverant »

Attached .msq and datalog. Cranking RPM is set to 300, RPM is ~250, and while the Fuel Cut indicator is active, the pulsewidth > 0.
The man behind MS Labs
2005 Audi A3 2.0L TFSI DSG AWD - Extreme MS3
2002 Mazda Miata 1.8 6sp - Enhanced MS3 1.4.0, sequential injection, sequential ignition, big turbo, lots of boost
makro
MS/Extra Newbie
Posts: 25
Joined: Fri Aug 08, 2014 5:30 am

Re: Method to turn off engine

Post by makro »

Just to add a bit of info, I successfully tested both types of engine cut via CANBus today. My MS3 is still on my desk so RPM was definitely @ 0.

Of course - upgrading to 1.3.2 allowed me to do the above and unlocked my "hidden" menus. :)

The only thing I'm not sure about now.... is writing 0x0000 via CANBus the correct way to disengage both types of cut?? It certainly turns the indicators off in TS however I want to know I'm not inadvertently also turning something else off.

James - Is there a way to setup fuel and oil pressure control to shutdown the engine when the pressure is out of range? I didn't see the option for the fuel pressure, but I'm assuming if oil pressure goes out of range (after setting the two lines on the graph) then it will automatically cut the engine??

Cheers,
Matt
jsmcortina
Site Admin
Posts: 39617
Joined: Mon May 03, 2004 1:34 am
Location: Birmingham, UK
Contact:

Re: Method to turn off engine

Post by jsmcortina »

Yes, writing 0x0000 turns off the cut. Anything other than the three values locks it out as a safety measure against rogue data.

Out of range oil pressure will trigger a CEL, you can use the CEL / limp mode system to take action.

There aren't any similar controls for fuel pressure at this time.

James
I can repair or upgrade Megasquirts in UK. http://www.jamesmurrayengineering.co.uk

My Success story: http://www.msextra.com/forums/viewtopic ... 04&t=34277
MSEXTRA documentation at: http://www.msextra.com/doc/index.html
New users, please read the "Forum Help Page".
makro
MS/Extra Newbie
Posts: 25
Joined: Fri Aug 08, 2014 5:30 am

Re: Method to turn off engine

Post by makro »

Okay great.

I spent a bit of time looking at the source code earlier today. I was trying to find where I could set the flagbyte22 on startup, so when the MS3 is first powered on, the fuel cut and spark cut are active by default.

My idea is to have a car security system where by default, the car won't start until it get's it "magic" wake up signal over the CANBus. I will design something with the Arduino to send the 0x0000 to the MS3... maybe a RFID reader, or a finger printer scanner or something. Anything is possible.

What do you think would be the best place to set flagbyte22? (If my thoughts are correct so far)

Also, could you please clarify the difference between FLAGBYTE22_SHUTDOWNACTIVE and FLAGBYTE22_SHUTDOWNSPKACTIVE? If I bitwise OR these, does that cut both??
jsmcortina
Site Admin
Posts: 39617
Joined: Mon May 03, 2004 1:34 am
Location: Birmingham, UK
Contact:

Re: Method to turn off engine

Post by jsmcortina »

makro wrote:Also, could you please clarify the difference between FLAGBYTE22_SHUTDOWNACTIVE and FLAGBYTE22_SHUTDOWNSPKACTIVE? If I bitwise OR these, does that cut both??
One cuts fuel, the other spark. Yes it will.
Set that right at the end of init.

Beware of what happens if you stall in a junction.

James
I can repair or upgrade Megasquirts in UK. http://www.jamesmurrayengineering.co.uk

My Success story: http://www.msextra.com/forums/viewtopic ... 04&t=34277
MSEXTRA documentation at: http://www.msextra.com/doc/index.html
New users, please read the "Forum Help Page".
makro
MS/Extra Newbie
Posts: 25
Joined: Fri Aug 08, 2014 5:30 am

Re: Method to turn off engine

Post by makro »

jsmcortina wrote:
makro wrote:Also, could you please clarify the difference between FLAGBYTE22_SHUTDOWNACTIVE and FLAGBYTE22_SHUTDOWNSPKACTIVE? If I bitwise OR these, does that cut both??
One cuts fuel, the other spark. Yes it will.
Set that right at the end of init.

Beware of what happens if you stall in a junction.

James
Excellent. Yeah I have considered the implications of doing this. My thinking:

If I'm only setting 'flagbyte22 = FLAGBYTE22_SHUTDOWNACTIVE | FLAGBYTE22_SHUTDOWNSPKACTIVE;' at the end of main_init(), this is only going to affect first power on? Once the flag has been cleared, if my car stalls I'm not going to switch the power off, I'm just going to try crank it again. That should mean the engine cut bits won't be set again right?!?
Or does the whole main_init() procedure get called every time the engine stops??

Cheers.
Reverant
Super MS/Extra'er
Posts: 1233
Joined: Sat Apr 15, 2006 12:39 am
Location: Athens, Greece

Re: Method to turn off engine

Post by Reverant »

makro wrote: Excellent. Yeah I have considered the implications of doing this. My thinking:

If I'm only setting 'flagbyte22 = FLAGBYTE22_SHUTDOWNACTIVE | FLAGBYTE22_SHUTDOWNSPKACTIVE;' at the end of main_init(), this is only going to affect first power on? Once the flag has been cleared, if my car stalls I'm not going to switch the power off, I'm just going to try crank it again. That should mean the engine cut bits won't be set again right?!?
Or does the whole main_init() procedure get called every time the engine stops??

Cheers.
Yeah, isn't it great that not all cars have the dreaded starter interlock?
Reverant wrote:Attached .msq and datalog. Cranking RPM is set to 300, RPM is ~250, and while the Fuel Cut indicator is active, the pulsewidth > 0.
James, have you had a chance to take a look?
The man behind MS Labs
2005 Audi A3 2.0L TFSI DSG AWD - Extreme MS3
2002 Mazda Miata 1.8 6sp - Enhanced MS3 1.4.0, sequential injection, sequential ignition, big turbo, lots of boost
jsmcortina
Site Admin
Posts: 39617
Joined: Mon May 03, 2004 1:34 am
Location: Birmingham, UK
Contact:

Re: Method to turn off engine

Post by jsmcortina »

makro wrote:Or does the whole main_init() procedure get called every time the engine stops??
It gets called once at power-on only.

James
I can repair or upgrade Megasquirts in UK. http://www.jamesmurrayengineering.co.uk

My Success story: http://www.msextra.com/forums/viewtopic ... 04&t=34277
MSEXTRA documentation at: http://www.msextra.com/doc/index.html
New users, please read the "Forum Help Page".
makro
MS/Extra Newbie
Posts: 25
Joined: Fri Aug 08, 2014 5:30 am

Re: Method to turn off engine

Post by makro »

Reverant wrote: Yeah, isn't it great that not all cars have the dreaded starter interlock?
Tell me more about this interlock?!?! I'm assuming some cars you have to turn the power off to restart the engine??
jsmcortina wrote:
makro wrote:Or does the whole main_init() procedure get called every time the engine stops??
It gets called once at power-on only.

James
James, I've managed to compile and flash the modified source with those bits set at startup, however the dash doesn't show that the fuel and spark cut is active. Are these indicators something that get's updated separately under normal operation when it's activated through the CANBus code or through another area of the code?
It doesn't really bother me, more so just so I know it's working as expected. As long as I can disable it and start the car, that's the main thing.
Post Reply