Hi there, I’ve been evaluating GHI’s SoMs’ CAN features. A few weeks ago I posted about performance on the G120, of which, after making some optimizations, got it working quite well. I believe, however, that it’s moving data as fast as it will given its CPU speed, which still isn’t fast enough.
So now, I’m looking at the G400S and also a Raspberry Pi2 with an MCP2515/2551 attached to it.
Regarding the G400S - I can’t get CAN to work at all. As soon as I call .Enable on the ControllerAreaNetwork object, I either get the exception shown below, or a steady stream of ErrorPassive events reported by ControllerAreaNetwork.ErrorReceived.
I did some searching here yesterday and found someone else reported exactly this (but they did not follow up on whether or how they resolved it). It was suggested their CAN configuration was the problem, to which they pointed out they have the same problems with NO CAN bus hooked up to the board. I found the same to be true. Also, I know my CAN bus is OK because the G120, RPI2 and a whole slew of other tools talk on it fine.
Additionally, I’m using the EXACT code that I’ve been testing with on the G120 which has been working for weeks.
What am I missing? Simon had some fairly strong words to say about the G400’s CAN implementation about a year ago. Is CAN broken on the G400?
I think it is timings mismatch. Multiple ErrorPassive errors with a final BusOff means your G400S fails to send messages and ultimately removes itself from the bus. This is a perfectly normal behaviour. Check timings and terminators.
@ Simon, sorry don’t quite understand your question?
I’m creating my CAN object this way:
new ControllerAreaNetwork(ControllerAreaNetwork.Channel.One, ControllerAreaNetwork.Speed.Kbps500)
… which, as I understand, has GHI calculate the bus timings for us. After creating the object, pulling the timings assigned out of the object reveals the timings I previously posted.
@ Nobody - Yes, but other devices on your bus also have their timing settings. If they are not close enough to those of G400, G400 will not work (as it actually does).
Use this timing for 500Kbs. these will be updated in next SDK
var can1 = new ControllerAreaNetwork(ControllerAreaNetwork.Channel.One, new ControllerAreaNetwork.Timings(1, 7, 7, 55, 3)); // 125Kbs
var can1 = new ControllerAreaNetwork(ControllerAreaNetwork.Channel.One, new ControllerAreaNetwork.Timings(1, 4, 5, 37, 3)); // 250Kbs
var can1 = new ControllerAreaNetwork(ControllerAreaNetwork.Channel.One, new ControllerAreaNetwork.Timings(1, 1, 1, 37, 1)); // 500Kkbs
var can1 = new ControllerAreaNetwork(ControllerAreaNetwork.Channel.One, new ControllerAreaNetwork.Timings(1, 7, 7, 6, 3)); // 1000Kbs
I would comment for the record that I had no problems with the default timings provided with the G120 at 500k. I only saw problems when I migrated my code to the G400.
Hello. Recently I made a custom board to work with automotive CAN messages. I’m good at Hardware, but not as good as i want at software, sadly. Could anyone show me example code how to use received CAN message data to open an output port, or something like that?
Right now I can’t get my CAN chanell to work at all, because of System.Exeption. I use GHI’s example code. Thanks for help!