Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NC CAN data #461

Open
BeerMoneyMotorsports opened this issue Aug 10, 2024 · 2 comments
Open

NC CAN data #461

BeerMoneyMotorsports opened this issue Aug 10, 2024 · 2 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@BeerMoneyMotorsports
Copy link
Contributor

NC dash(and chassis) CAN broadcasts from fome to support dash, abs, prht, etc.

https://github.com/hatsunearu/nc-mx5-miata-canbus/blob/main/mazda_mx5_nc.md

@BeerMoneyMotorsports
Copy link
Contributor Author

struct nc_cluster {
//lamps
boolean Securitylamp; //
boolean DCSlamp; // 0x212, byte0, 0x08
uint8_t ABSlamp; // 0x212, byte4, 0x10 on 0x20 flashing
boolean Brakelamp; // 0x212, byte4, 0x40
uint8_t TCSlamp; // 0x212, byte4, 0x04 on 0x08 flashing
uint8_t MILlamp; // 0x420, byte5, 0x40 on 0x80 flashing
boolean Battlamp; // 0x420, byte6, 0x40 on
uint8_t Cruiselamp; // 0x4EC, byte0, 0x40 green 0x80 amber
//gauges
uint16_t Tach; // 0x201, byte0
uint8_t TachoIndex;
uint16_t Speedo; // 0x201, byte4
uint8_t OdoDist; // Distance calculated from speed.
uint8_t Odometer; // 0x420, byte 1, 0x3F (63) maximum single increase
uint16_t OdoFollow; // check for rollover
uint8_t OdoAdd; // rollover placeholder.
boolean Oilpressure; // oil is sadly a PSI switch, dedicated pin
uint8_t Coolant; // 0x420, byte 0
//transmission
uint8_t PRNDL; // 0x231, byte 0
uint8_t Gear; //0x231, byte 7 1-6, only displays if PRNDL = Drive or Manual
uint8_t LastPRNDL;
};

//packet intervals in ms
#define interval201 10
#define interval212 100
#define interval231 25
#define interval420 100
#define interval4FF 100
#define interval4F0 1000
#define interval4F1 1000
#define interval211 10;
#define interval218 25;

void send218frame() {
Frame packet;

packet.id = 0x218;
packet.eid = 0;
packet.dlc = 8;

//0F A0 7C 80 FF FF FF 00

packet.data[0] = 0x0F;
packet.data[1] = 0xA0;
packet.data[2] = 0x7C;
packet.data[3] = 0x80;
packet.data[4] = 0xFF;
packet.data[5] = 0xFF; //(0xFF & random(255));
packet.data[6] = 0xFF; //(0xFF & random(255));
packet.data[7] = 0x00; //(0xFF & random(255));

Mazda.txPacket(packet);
}

/*
PRHT Auto Observations
231#0100FFFF00000000 - Park
231#1000015700000001 - Nothing?
231#E20001320000000E - Reverse
231#0300FFFF00000000 - Neutral
231#1400015700000001 - Drive (1)

 FF 04 FF FF 00 00 00 00 PRHT operation (manual transmission)

*/

PRHT requires 231 packet (that contains gear information), 201 packet (speed), 218(?) whose function i'm not 100% sure of, 4F0(?) that appears to be a static message of
4F0#14 40 12 30 03 00 00 00, 4F1 that is 4F1#81 01 9A FF FF 00 59 59 for manual transmission, 4F1#8B 01 9A FF FF 00 58 58 for auto transmission, 4FF that is a repeating 5 element message of..
/*
0 11,00,00,00,00,00,00,00,
1 30,44,49,53,41,42,00,00,
2 31,4C,45,56,49,4E,43,00,
3 32,4F,4D,50,41,52,45,00,
4 10,14,24,12,FF,00,00,00,
*/

231 is.. a bit messy here, since this (i think) ties into the fuel anti-slosh..

void send231frame() {
Frame packet;

if (currenttime > next_fuel_slosh) {
switch (fuel_slosher) {
case 0x00:
fuel_slosher = 0x02;
next_fuel_slosh = currenttime + 30000; //0x02 for 30 seconds
break;
case 0x02:
fuel_slosher = 0x06;
next_fuel_slosh = currenttime + 5000; //0x06 for 5 seconds
break;
case 0x06:
fuel_slosher = 0x00;
next_fuel_slosh = currenttime + 60000; //0x00 for 60 seconds
break;
}
}

packet.id = 0x231;
packet.eid = 0;
packet.dlc = 8;

if (TRANS_version > tT56) {
if (cluster.PRNDL == park) {
//231#01 00 FF FF 00 00 00 00 - Park
packet.data[0] = 0x01;
packet.data[1] = fuel_slosher;
packet.data[2] = 0xFF;
packet.data[3] = 0xFF;
packet.data[4] = 0x00;
packet.data[5] = 0x00;
packet.data[6] = 0x00;
packet.data[7] = 0x00;
}
if (cluster.PRNDL == reverse) {
//231#E2 00 01 32 00 00 00 0E - Reverse
packet.data[0] = 0xE2;
packet.data[1] = fuel_slosher;
packet.data[2] = 0x01;
packet.data[3] = 0x32;
packet.data[4] = 0x00;
packet.data[5] = 0x00;
packet.data[6] = 0x00;
packet.data[7] = 0x0E;
}
if (cluster.PRNDL == neutral) {
//231#03 00 FF FF 00 00 00 00 - Neutral
packet.data[0] = 0x03;
packet.data[1] = fuel_slosher;
packet.data[2] = 0xFF;
packet.data[3] = 0xFF;
packet.data[4] = 0x00;
packet.data[5] = 0x00;
packet.data[6] = 0x00;
packet.data[7] = 0x00;
}
if (cluster.PRNDL == drive) {
//231#14 00 01 57 00 00 00 01 - Drive (1)
packet.data[0] = 0x14;
packet.data[1] = fuel_slosher;
packet.data[2] = 0x01;
packet.data[3] = 0x57;
packet.data[4] = 0x00;
packet.data[5] = 0x00;
packet.data[6] = 0x00;
packet.data[7] = 0x00; //option display gear here?
}
if (cluster.PRNDL == manual) {
packet.data[0] = 0x04;
packet.data[1] = fuel_slosher + 0x80;
packet.data[2] = 0xFF;
packet.data[3] = 0xFF;
packet.data[4] = 0x00;
packet.data[5] = 0x00;
packet.data[6] = 0x00;
packet.data[7] = cluster.Gear;
}
//shouldn't proc normally - only for menu/communication lost
if (cluster.PRNDL == ATicon) {
packet.data[0] = 0x10;
packet.data[1] = fuel_slosher + 0x40;
//packet.data[0] = 0x04;
//packet.data[1] = 0x40;
packet.data[2] = 0x01;
packet.data[3] = 0x57;
packet.data[4] = 0x00;
packet.data[5] = 0x00;
packet.data[6] = 0x00;
packet.data[7] = 0x01;
}
if (cluster.PRNDL == none) {
//10 00 01 57 00 00 00 01
packet.data[0] = 0x10;
packet.data[1] = fuel_slosher;
packet.data[2] = 0x01;
packet.data[3] = 0x57;
packet.data[4] = 0x00;
packet.data[5] = 0x00;
packet.data[6] = 0x00;
packet.data[7] = 0x01;
}
if (cluster.PRNDL != cluster.LastPRNDL) {
//inter-gear change packet - for PRHT operability, should only care about P and D, don't need to track gears
//231#10 00 01 57 00 00 00 01 - Nothing?
packet.data[0] = 0x10;
packet.data[1] = fuel_slosher;
packet.data[2] = 0x01;
packet.data[3] = 0x57;
packet.data[4] = 0x00;
packet.data[5] = 0x00;
packet.data[6] = 0x00;
packet.data[7] = 0x01;
}
} // end if trans > tt56

if (TRANS_version == tT56) {
//FF 04 FF FF 00 00 00 00 PRHT operation (manual transmission)

/*
      368 231#FF00FFFF00000000
       21 231#FF02FFFF00000000
     6726 231#FF04FFFF00000000
      113 231#FF06FFFF00000000

      0x04 = hung up on 5/8ths
      0x00 = start 9:05 1/2 9:28 3t above e 9:51
      0x02 = start 9:52 hung at 5/8
      0x06 = start 11:30 hung at 5/8
      0x00 = start 12:55 hung at 5/8 (disabled 39a)
      0x00 = start 1:35
*/
//packet.data[1] = 0x04;

packet.data[0] = 0xFF;
packet.data[1] = fuel_slosher;
packet.data[2] = 0xFF;
packet.data[3] = 0xFF;
packet.data[4] = 0x00;
packet.data[5] = 0x00;
packet.data[6] = 0x00;
packet.data[7] = 0x00;

}

cluster.LastPRNDL = cluster.PRNDL;

Mazda.txPacket(packet);
}

212 packet is produced by the ABS module. I don't have it called out explicitely in my notes, but I think it's enabled by the 4Fx packets. The ECU reads the steering angle sensor and broadcasts that to the ABS module for
traction control - I have the steering sweep saved somewhere, but not in my notes.

Security - you can short circuit (sorta) the Security lamp on the cluster - it's a challenge/hash response/ack workflow, but you can shortcut by sending the ack packet within 10ms(?) of cluster power on.

void turnoffsecurity() {
Frame packet;

//040#81 7F 00 00 00 00 00 00

packet.id = 0x040;
packet.eid = 0;
packet.dlc = 8;
packet.data[0] = 0x81;
packet.data[1] = 0x7F;
packet.data[2] = 0x00;
packet.data[3] = 0x00;
packet.data[4] = 0x00;
packet.data[5] = 0x00;
packet.data[6] = 0x00;
packet.data[7] = 0x00;

Mazda.txPacket(packet);
}

void send211frame() {
Frame packet;
//generated by cluster on auth?
//no 211 packet on automatic PRHT?
// FF,FF,80,0,40,0,0,

packet.id = 0x211;
packet.eid = 0;
packet.dlc = 8;
packet.data[0] = 0xFF;
packet.data[1] = 0xFF;
packet.data[2] = 0x80;
packet.data[3] = 0x00;
packet.data[4] = 0x40;
packet.data[5] = 0x00; //(0xFF & random(255));
packet.data[6] = 0x00; //(0xFF & random(255));
packet.data[7] = c211data; //(0xFF & random(255));

c211data++;

Mazda.txPacket(packet);
}
mostly static, but last data always increases

@BeerMoneyMotorsports BeerMoneyMotorsports added enhancement New feature or request help wanted Extra attention is needed labels Aug 10, 2024
@BeerMoneyMotorsports
Copy link
Contributor Author

rx8 preset runs the tach, oil pressure and coolant gauges. It can be copied and then delete the 0x212 portion as that will conflict with the ABS broadcast.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant