Ok so I tightened up the code. I kept the case statement testing in place and corrected one error. More significantly I dumped using KiTTY a fork of PuTTY as my serial terminal it was unable to keep up with the data transmission speed from the Bridge. I switched to using the arduino serial monitor which runs at 200000 nicely resulting in no more overflow errors. This allowed me to avoid having to dig deeper into and implementing the interrupt idea, perhaps later at the moment this seems to be working as is.
I have now added 2 more case tests to insert additional messages, this is working very nicely as can be seen by a sample of the start of the 1700 entry recording below. It shows each of the case tests inserting the additional messages at the right time more or less.
The tests are 50B, 1D4, and 1F2, you can see in the sample recording that the additional messages are being added successfully.
Also below is the struct statement of the messages I am adding.
The bridge now simulates the recording made of a working car and charger very closely, messages are repeated throughout the 1700 messages.
Tragically the charger still does nothing although the can sequence on the car side seems to be behaving differently (it pauses for about 500ms regularly) but I need to analyze this closely to figure out exactly what is happening, it is not obvious.
I continue to believe there is a problem with the charger or some other component from the accident it was in.
We were unable to get it to charge even when it was complete, in it's wrecked condition and I think this is causing the charger to not respond.
FYI, The inverter was damaged beyond repair. The battery and the BMS, work fine and they are being installed in a Toyota RAV4 EV.
Still looking for another wrecked leaf at a good price. This time we are looking for one with no front end damage.
Anyone else looking to buy a wreck beware !
Full code and recordings here :
http://www.evmotorworks.ca
Sample recording of bridge output on the OBC/PD side using an OLIMEX Pic32-emz64 with code from mholt999 .
Comments added to this post are not part of the recording.
,CAN ID ,DL,D0,D1,D2,D3,D4,D5,D6,D7,T Stamp,#,But 1,But 2
rx, 0x679,1;00;00;00;00;00;00;00;00,00250.38605,00;00;00
// charger plugged in
rx, 0x390,8;04;00;00;00;00;80;3C;07,00250.43612,01;00;00
rx, 0x393,8;00;10;00;00;20;00;00;02,00250.43644,02;00;00
rx, 0x50B,7;00;00;00;C0;00;00;00;00,00250.43799,03;00;00
// case 50B test
rx, 0x54A,8;DA;80;70;0E;00;00;00;54,00250.43825,04;00;00
rx, 0x481,2;4B;00;00;00;00;00;00;00,00250.43843,05;00;00
rx, 0x54B,8;10;08;80;00;04;00;00;00,00250.43878,06;00;00
rx, 0x54C,8;59;FF;00;00;00;F8;FF;00,00250.43906,07;00;00
rx, 0x54F,8;14;00;00;00;08;40;C0;14,00250.43934,08;00;00
rx, 0x1F2,8;04;64;04;A0;00;02;02;8A,00250.44229,09;00;00
//case 1DB test
rx, 0x1DB,8;FF;E0;BC;AA;2F;00;03;B0,00250.44264,10;00;00
rx, 0x55B,6;00;00;00;00;5D;C8;00;00,00250.44286,11;00;00
rx, 0x1D4,8;6E;6E;00;00;82;06;E0;C1,00250.44329,12;00;00
//case 1B4 test
rx, 0x50A,8;04;80;00;0F;00;02;04;00,00250.44357,13;00;00
rx, 0x50C,6;00;00;00;00;5D;C8;00;00,00250.44371,14;00;00
rx, 0x5A9,8;FF;FF;FC;FF;FF;F7;FE;00,00250.44413,15;00;00
rx, 0x45E,1;00;00;00;00;00;00;00;00,00250.44423,16;00;00
rx, 0x5B9,7;07;FF;07;FF;2F;FF;80;00,00250.44454,17;00;00
//vcm output
rx, 0x11A,8;00;80;00;AA;C0;00;00;67,00250.44845,18;00;00
// ...............................
List of Inserted messages:
struct can_response array_response[12] = {
{0x54A,8,{0xDA,0x80,0x70,0x0e,0x00,0x00,0x00,0x54}},
//0 CASE: 50B
{0x481,2,{0x4B,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, //1
{0x54B,8,{0x10,0x08,0x80,0x00,0x04,0x00,0x00,0x00}}, //2
{0x54C,8,{0x59,0xFF,0x00,0x00,0x00,0xF8,0xFF,0x00}}, //3
{0x54F,8,{0x14,0x00,0x00,0x00,0x08,0x40,0xC0,0x14}}, //4
{0x50A,8,{0x04,0x80,0x00,0x0F,0x00,0x02,0x04,0x00}},
//5 CASE: 1D4
{0x50C,6,{0x00,0x00,0x00,0x00,0x5D,0xC8,0x00,0x00}}, //6
{0x5A9,8,{0xFF,0xFF,0xFC,0xFF,0xFF,0xF7,0xFE,0x00}}, //7
{0x45E,1,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},
//8 extra's
{0x5B9,7,{0x07,0xFF,0x07,0xFF,0x2F,0xFF,0x80,0x00}}, //9
{0x1DB,8,{0xFF,0xE0,0xBC,0xAA,0x2F,0x00,0x03,0xB0}},
//10 CASE: 1F2
{0x55B,6,{0x00,0x00,0x00,0x00,0x5D,0xC8,0x00,0x00}}, //11
};