G400S CAN problems

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?

P

I would add some of what I’m seeing has been reported in this thread:

https://www.ghielectronics.com/community/forum/topic?id=18783

A few more details:

CAN.Enabled does fail immediately with the generic exception if there’s no transceiver hooked up.

With the transceiver hooked up, CAN.Enabled succeeds, but as soon as I attach it to my bus, I started getting rampant ErrorPassive events

Eventually I get a BusOff event, if I set CAN.Enabled to true again to call .Reset(), I get the generic System.Exception again.

I wonder if the CAN bus timings provided by GHI aren’t quite right for my config? I’m using 500kpbs

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.

Thanks Simon. Termination is verified good. The timings (500kbps) are the ones provided by GHI:

Brp = 15
Phase1 = 5
Phase2 = 5
Prop = 2
Sync = 3
Multi = 0

and

clock = 133333200

I’ll see if I can find that bit rate calculator and see if the settings are correct

@ Nobody - What are your existing bus timings?

@ 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).

@ Nobody -

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

@ Dat - thank you, this seems to have resolved the problem!

Dat

Are there any updates to the timings on the G120? No issues to date, I’m just curious if the error only applies to the G400. Thanks.

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.

@ Diesel Engineer -

G120 should work fine with current timing.

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!

@ MVait -

Make sure that you installed latest SDK: https://www.ghielectronics.com/support/netmf/sdk/34/ghi-electronics-netmf-sdk-2015-r1-pre-release-1
if you did, don’t worry about those posted above.

What do you mean “use received CAN message data to open an output port”?

Did you try this link: Can we use Linux or a Mac for development? - GHI Electronics

If you are using G400, you can open 2 can channel and send/receive between them.