sparkfun / sparkfun_can-bus_arduino_library Goto Github PK
View Code? Open in Web Editor NEWLicense: Other
License: Other
Hello, i was searching if i can communicate with Can speed 1Mbps,
it's supported with this library ?
I know this library is written for the SparkFun shield, but will it work on an ESP32 (which uses Arduino IDE/code) and be able to address it's built-in native CAN bus interface?
I am working on a project so I bought a sparkfun redboard Plus and a sparkfun can-bus shield. I went to program it with OBD-II to DB9 Cable that I bought from you with the library (CAN-Bus_Shield-master) that you have as an example and at first I used the SparkFun_CAN_Demo library, I ran it with the arduino ide but it not working(can't init can). After various tests I have done, I have come to the conclusion that some library has a problem, but I can't find which library it is or the problem where are finding. The test was done on an audi a4 b6 quattro 2002 1.8T. Maybe have you updated the code and forgot to upload the corrected one?? I believe some library has a problem but I don't know which one is not a topic from the program that has the selection table for rpm or throttle or maf sensor but some library. As I tell I working into an project so any help is good.I am waiting for feedback
Anyone who knows how to implement 115200 baud instead of the standard baud rates?
This library uses some outdated concepts / AVR-specific code. It CAN (haha) be updated to work on many more Arduino platforms. See this forum post for more details:
https://forum.sparkfun.com/viewtopic.php?f=169&t=53206&p=216453#p216408
Does this library support CAN protocol Flow Control?
In message definition tCAN, I cannot find flow control byte. I guess this library doesn't flow control, is it? When we receive multi frames, for example, some PID response has multi frames:
7C8 8 10 0A 61 12 01 00 00 07
7C8 8 21 10 00 80 00 00 00 00
how to handle this situation?
This lib works fine for PID codes. But there are useful bits of info (voltage, version) that don't use PID codes, they use ELM327 commands. In another Arduino OBD library, I found the relevant calls (below). Can they be adapted and merged into the lib? I don't think I can adapt them myself.
float COBD::getVoltage()
{
char buf[32];
if (sendCommand("ATRV\r", buf, sizeof(buf)) > 0) {
char* p = getResultValue(buf);
if (p) return (float)atof(p);
}
return 0;
}
byte COBD::getVersion()
{
byte version = 0;
for (byte n = 0; n < 3; n++) {
char buffer[32];
if (sendCommand("ATI\r", buffer, sizeof(buffer), 200)) {
char *p = strchr(buffer, ' ');
if (p) {
p += 2;
version = (*p - '0') * 10 + (*(p + 2) - '0');
break;
}
}
}
return version;
}
Is the CAN shield supposed to work with the Leonardo? It doesn't work for me, and there are various forum threads that say the SPI pins aren't in the right place.
The ECU Demo sketch logs all zeros for GPS data to the SD card. Tried doing a serial debug of the same data and it's zeros as well.
The lat and lon values returned seems to be 10 times too large.
I am based in Stockholm/Sweden and my correct lat/lon is 59.317 / 18.054.
However using:
f_get_position(&flat, &flon, &fix_age)
I get: 593.17 / flon: 180.54
And using:
get_position(&lat, &lon, &fix_age)
I get: 59317041 / 18054290
I use:
CAN-BUS Shield (DEV-13262) and GPS Receiver
EM-506 (GPS-12751) ordered bis SK Pang
Arduino Uno R3
I imagine this is highly unlikely, but any chance someone can port this to SAMD architecture? Eg, to be used with an Adafruit M0 device or similar.
I am trying to load n number of CAN messages(datatype tCAN) to the CAN transmission buffer (load it 3 messages at a time), and send them at a go to the CAN bus. I am not able to figure out the required methods from the sparkfun datasheets and online forums. Can anyone please suggest how to do that or any document for the same ?
Just to keep project boards clean it would be useful to have a 2 pin through-hole jumper (for flea-clip short) and a surface mount resistor in series between the CANH and CANL lines.
|---- o o --- 120ohm ----| CANH CANL
I was not able to get any GPS readings. I am using:
CAN-BUS Shield (DEV-13262) and GPS Receiver
EM-506 (GPS-12751) ordered bis SK Pang
Arduino Uno R3
Looking at the hookup guide, it actually seems that the author was also not able to get a GPS fix, The author suggested the reason was poor GPS connection, but perhaps it's actually the code. Looking through the code it seems to me that it will not work on Arduino Uno with software serial, because it does too many other things including delays to be able to read the incoming data from the serial GPS module.
https://learn.sparkfun.com/tutorials/can-bus-shield-hookup-guide
Hi,
I need to have support for 29 bit identifiers in a project I'm working on.
I have working code for it that I would like to contribute, but I'm unsure what the best way of handling the 11 vs 29 bit difference.
I have added a bool for keeping track of if it's a 29 or 11 bit identifier
typedef struct
{
uint32_t id;
struct {
int8_t rtr : 1;
uint8_t length : 4;
} header;
uint8_t data[8];
bool extended;
} tCAN;
I would like to keep all old code working though, and I have two suggestions. Either change the mcp2515.c to .cpp which would allow constructors that set default extended=false or add a new struct for extended messages. Do you have any other suggestion?
We are using Sparkfun CAN shield and Arduino Uno to build a CAN network. We are observing the data in CAN network using KVaser Canking. When we send a data to the CAN bus, we can see the data in KVaser window. But, when we try to read something from the CAN bus, it is showing garbage values. Note that 120 ohm is also there. Here is the code:
`
#include <Canbus.h>
#include <defaults.h>
#include <global.h>
#include <mcp2515.h>
#include <mcp2515_defs.h>
//********************************Setup Loop*********************************//
void setup() {
Serial.begin(115200);
Serial.println("CAN Write - Testing transmission of CAN Bus messages");
delay(1000);
if(Canbus.init(CANSPEED_250)) //Initialise MCP2515 CAN controller at the specified speed
Serial.println("CAN Init ok");
else
Serial.println("Can't init CAN");
delay(1000);
}
unsigned long now=0, prev=0;
void loop() {
mcp2515_bit_modify(CANCTRL, (1<<REQOP2)|(1<<REQOP1)|(1<<REQOP0), 0);
tCAN message; // message read from the bus
tCAN amessage;
// Attack message details
amessage.id = 0x631; //formatted in HEX
amessage.header.rtr = 0;
amessage.header.length = 8; //formatted in DEC
amessage.data[0] = 0x00;
amessage.data[1] = 0x00;
amessage.data[2] = 0x00;
amessage.data[3] = 0x00; //formatted in HEX
amessage.data[4] = 0x00;
amessage.data[5] = 0x00;
amessage.data[6] = 0x00;
amessage.data[7] = 0x00;
while(! mcp2515_check_message()){
}
if(mcp2515_get_message(&message) and message.id==0x630){ //wait for target message on the bus
amessage.id = 0x630;
mcp2515_send_message(&amessage);//this is not working
Serial.println("Sending attack message");//this is not working
}
auto error_tec = mcp2515_read_register(TEC);
Serial.print("TEC Count of adversary : "); //this is working
Serial.println(error_tec); //this is working
}
`Can some one help how to resolve this?
I'm wondering how we can add the 1000kbps setting to the library? I edited Canbus.h to add CANSPEED_1000, however it does not seem to work trying to obtain the rpm from a vehicle. I'm not sure if the numbers 1 3 and 7 are just there to set the "priority" like in networking to set connection priority or if it means something else?
I only have one set of the chips so can't test with a second set to tell if it is in fact initializing the controller at the higher speed or not.
#define CANSPEED_125 7 // CAN speed at 125 kbps
#define CANSPEED_250 3 // CAN speed at 250 kbps
#define CANSPEED_500 1 // CAN speed at 500 kbps
#define CANSPEED_1000 0 // CAN speed at 1000 kbps
I have the Sparkfun can bus shield and I'm tryng to connect to an ecu that works at 1 mbps. Unfortunately this library only supports baud rates up to 500 kbps. I'm sure that is easy to edit the library but I don't know how to do this.
Can you please have a look at this?
thank's
Davide
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.