Hello! i'm new here, i have been reading many topics for info time ago but now i'm stucked with a problem..i hope you can help me.
My "project" will consist on sending custom data to a CAN-Bus line, for automotive purposals, i'm still starting it (wirings, making cable obd2-serial,etc).
Well, here comes my problem, on my first example test, "VehicleSpeed" from the libraries for canBus, it's sending wrong data.. you can check in attachment, with the vehicle stationary it reads 255km/h, always same value... the bad thing is that when i disconnect it from the car, and i disconnect the can bus shield, it also keep sending data... i have test reading simple data from the can bus "basic example" and it receives data with "id 7FF" and "FFFFFFFF" packet... it's very annoying!! who is sending this data?? i have tested on 3 different computers, changed usb-firewire cable, reinstalled the IDE, libraries, etc... Someone can give me a clue? Thanks
Dropbox imgs:
https://dl.dropboxusercontent.com/u/47864432/arduino/BASIC_EXAMPLE_WEIRD_DATA.jpg
https://dl.dropboxusercontent.com/u/47864432/arduino/No_CANBUSSHIELD_SendingData.jpg
I attach source code i used:
Basic example
// Include always these libraries before using the CAN BUS functions
#include <CAN.h>
#include <SPI.h>
// ID numbers
#define IDWAITED 200
#define OWNID 100
// Create an instance of the object
CAN myCAN = CAN();
// Setting up our devices and I/Os
void setup() {
// Inits the UART
Serial.begin(115200);
delay(100);
// Let's open the bus. Remember the input parameter:
// 1: 1Mbps
// 500: 500Kbps <--- Most frecuently used
// 250: 250Kbp
// 125: 125Kbps
myCAN.begin(125);
}
void loop() {
//****************************************
// 1. Receive data
//****************************************
if (myCAN.messageAvailable() == 1) {
// Read the last message received.
myCAN.getMessage(&myCAN.messageRx);
// Print in the serial monitor the received message
myCAN.printMessage(&myCAN.messageRx);
}
//****************************************
// 2. Send data
//****************************************
// Insert the ID in the data structure
myCAN.messageTx.id = OWNID;
// These fields include the data to send
myCAN.messageTx.data[0] = 0;
myCAN.messageTx.data[1] += 1;
myCAN.messageTx.data[2] = 2;
myCAN.messageTx.data[3] = 3;
myCAN.messageTx.data[4] = 4;
myCAN.messageTx.data[5] = 5;
myCAN.messageTx.data[6] = 6;
myCAN.messageTx.data[7] = 7;
// The length of the data structure
myCAN.messageTx.header.length = 8;
// Send data
myCAN.sendMessage(&myCAN.messageTx);
// A time delay
delay(1000);
}
This second refers CAN.h library where vehicleSpeed function is, but it's a standart, not modified.
// Include always these libraries before using the CAN Bus functions
#include <CAN.h>
#include <SPI.h>
// Create an instance of the object
CAN myCAN = CAN();
void setup()
{
// Initializes the Serial
Serial.begin(115200);
delay(100);
// Print initial message
Serial.println("Initializing CAN Bus...");
// Configuring the Bus at 500 Kbit/s
myCAN.begin(500);
Serial.println("CAN Bus initialized at 500 KBits/s");
}
void loop()
{
// Read the value of vehicle speed
int vehicleSpeed = myCAN.getVehicleSpeed();
// Print received data in the serial monitor
Serial.print("Vehicle Speed : ");
Serial.print(vehicleSpeed);
Serial.println(" Km/h");
delay(1000);
}
Any help will be welcome, thanks in advance!!