Hi everyone,
The past few weeks have gone really well using the canbus shield v1.2 for pulling a can dump from both my pontiac and my friends FRS. I was even able to broadcast RPM back to the pontiac and have it change the tach with the engine off.
Currently, I have the electronic steering system out of the FRS on a test bench in my living room, and need to broadcast (18) Can ID’s over the network. After a few weeks of recording and translating the Id’s from the car and rebroadcasting them, I haven’t had any success getting the test rig to respond.
I have 2 questions that I havn’t been able to find answers for:
- Can I just use CAN.sendMsgBuf one after another or do I need a delay after it? If I do use a delay, does it interfere with transmitting at the right times on the 500kbps bus?
- I am structuring the message “buff” for each ID as I recorded it, example :unsigned char msg152[8] = {0xF0, 0xE4, 0x0, 0x0, 0x0, 0x2, 0x0, 0x4C};.
Should the buff be structured as I have it in HEX? or should I input decimal and the shield takes care of translating? My code is pasted below if anyone that might see something that I’m doing wrong. Thanks for the help.
[code]
// demo: CAN-BUS Shield, send data
// [email protected]
#include <mcp_can.h>
#include <SPI.h>
// the cs pin of the version after v1.1 is default to D9
// v0.9b and v1.0 is default D10
const int SPI_CS_PIN = 9;
MCP_CAN CAN(SPI_CS_PIN);
unsigned char msg144[8] = {0xC0, 0x0, 0x71, 0x8A, 0x44, 0xA4, 0xA0, 0x0};// 0x140 70mph C0 0 71 8A 44 A4 A0 0
unsigned char msg360[8] = {0x96, 0x7, 0x87, 0x80, 0x37, 0x80, 0x1, 0x0};// 0x360 70mph: 96 7 87 80 37 80 1 0
unsigned char msg282[8] = {0xB0, 0xB1, 0x8A, 0x64, 0x64, 0x0, 0x20, 0x0};//282 70MPH : B0 B1 8A 64 64 0 20 0
unsigned char msg142[8] = {0x5B, 0x26, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0};//0X142 70MPH 5B 26 8 0 0 0 0 0
unsigned char msg361[8] = {0x5, 0x29, 0x0, 0xD8, 0xD, 0xB0, 0x85, 0x79}; //5 29 0 D8 D B0 85 79
unsigned char msg152[8] = {0xF0, 0xE4, 0x0, 0x0, 0x0, 0x2, 0x0, 0x4C};
unsigned char msg372[8] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0};// 0X372 0 0 0 0 0 0 0 0
unsigned char msg4DD[8] = {0x1E, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; ///1E 0 0 0 0 0 0 0 (159661)
unsigned char msg4C1[8] = {0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0};//1 0 0 0 0 0 0 0
int dT = 0;//easy to change the delay between sending mesages
void setup() {
Serial.begin(115200);
while (CAN_OK != CAN.begin(CAN_500KBPS)) // init can bus : baudrate = 500k
{
Serial.println(“CAN BUS Shield init fail”);
Serial.println(" Init CAN BUS Shield again");
delay(100);
}
Serial.println(“CAN BUS Shield init ok!”);
// Serial.println(msg18[2]);
}
void loop() {
CAN.sendMsgBuf(0x144, 0, 8, msg144); delay(dT);
CAN.sendMsgBuf(0x360, 0, 8, msg360); delay(dT);
CAN.sendMsgBuf(0x282, 0, 8, msg282); delay(dT);
CAN.sendMsgBuf(0x142, 0, 8, msg142); delay(dT);
CAN.sendMsgBuf(0x361, 0, 8, msg361); delay(dT);
CAN.sendMsgBuf(0x152, 0, 8, msg152); delay(dT);
CAN.sendMsgBuf(0x372, 0, 8, msg372); delay(dT);
CAN.sendMsgBuf(0x4DD, 0, 8, msg4DD); delay(dT);
CAN.sendMsgBuf(0x4C1, 0, 8, msg4C1); delay(dT);
}
[/code]