Arduino Megasquirt Library

This driver provides access to the MegaSquirt ECU with a level of abstraction above the MegaSquirt serial interface, enabling users with no knowledge of the MegaSquirt commands to access the register data easily without caring about the underlying communication required.

The MegaSquirt is a low cost engine control unit with support for fueling, ignition and idle control.

Wiring

The MegaSquirt is connected to the Arduino using the RS232 output on the MegaSquirt, a MAX232 chip, and the Serial interface on the arduino board.

Synopsis

 
#include >MegaSquirt.h<
void setup(){
 MegaSquirt::begin();
 
 byte status;
 String signature;
 status=MegaSquirt::signature(&signature);
 switch (status){
  case MS_COMM_SUCCESS:
   Serial.print("MegaSquirt Signature: ");
   Serial.println(signature);
   break;
  case MS_ERR_COMM_TIMEOUT:
   Serial.println(" FAILURE: Communication Timeout");
   break;
  case MS_ERR_COMM_OVERFLOW:
   Serial.println(" FAILURE: Communication Overflow");
   break;
  default:
   Serial.println(" FAILURE: Unknown Error"); 
 }

String revision;
 status=MegaSquirt::revision(&revision);

 uint16_t uptime;
 status=MegaSquirt::seconds(&uptime);

 MegaSquirtData registers;
 byte regTable[MS_TABLE_LENGTH];
 status=MegaSquirt::getData(regTable);

 registers.loadDAta(regTable);

 Serial.println(registers.lambda1()/10,DEC )
}

Download

You can download the ZIP file to import into the IDE here, or you can fork your own.

Trip to Zeeland

It was sunny so I went for a drive in the seven with tuner studio running to see if I could improve things, I couldn’t but the drive was lovely.

SDC10193

Basically, there is not enough variation in MAP pressure, and the rate of change is very steep off idle with no change at higher rpm. This means that the VE table is pretty flat.

Subsequently, I changed over to TPS based fueling, the result is a much more responsive drive, throttle response is like lightning in comparison, and it feels and sounds like its set up properly. The AFR is much closer to the AFR target. I’ve only ran auto tune for about an hour or so on what was a relatively quiet drive, so the edges are not tuned yet, but for the most part its pretty close. Its certainly very drivable

Whilst I was trying to get Alpha-N working I hit a few idiosyncrasies in the tuning software. There are three fueling options for mega squirt: Speed Density; (MAP Based) Pure Alpha-N; (TPS Based) and Blended.

For now I’m using Pure Alpha-N, however when I set the fueling algorithm to Alpha-N in either tuner studio, or mega tune it was still using MAP for fueling. For whatever reason it was using the blended algorithm. This seems to be not a bug, but slightly misleading name, Pure Alpha-N is essentially blended, but starting with Alpha-N rather than MAP. Therefore I set the Threshold to 9k in the Alpha-N blending dialog.

In addition, I had ego correction active at idle, this results in an idle which falls and rises all the time, setting EGO correction to be active above 1200 worked a treat.

LC-1 Permenant Install

I decided to install my innovate LC-1 permanently in the car, whilst this wont give me offline data-logging, it will save some effort when I go for a data-logging run.  In the future, I will be running megasquirt, and will use the LC-1 to provide and AFR readout.

I got my LC-1 from an innovate reseller called Telematica last year, their price was good, and it arrived almost immediately (They are based in greece, and it arrived in 2 days.)  So I ordered a digital gauge, the XD-16, which I will mount in the dash.  The reason being that whilst offline logging is nice with the laptop, it can be a real pain trying to work out what you were doing at any given time, as correlating RPM, Load, and AFR requires some data mangling.  I’m hoping i’ll get a good visual indication of what’s going on with this as I drive.

I used to keep it all in a little plastic box with a serial connector on one end, a 12v adaptor on the other, and long wire going out to the Lambda Sensor, I just removed it all and right now, it looks a bit like this:

I shall mount the LC-1 onto the bulkhead with the rest of the electronics, and the gauge I shall wire into the dash with a connector for the Serial cable so that things can still be disconnected. The sensor cable has a nice plastic bit which can go into a grommet, if its long enough, I’d like to get it into the scuttle, or engine bay rather than the passengers foot well as its likely to get broken if its there.