It is currently 23 Feb 2019 14:32

All times are UTC + 1 hour




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: 16 Jan 2019 16:17 
Offline

Joined: 07 Sep 2013 16:08
Posts: 25
I appreciate this is probably a bit of a daft question, but just learning the CAN routines in MikroC and have a strange issue - can an incorrect CAN initialisation have an impact on other nodes communicating with each other?

Reason I say this is I have designed a small board with a pic to integrate to an existing canbus network, at the minute it is purely for the purpose of reception so I have it set up in listening mode - however whilst having the device physically connected to the bus does not influence the behaviour of any nodes, tweaking the BRP values prevents the other two pre-existing nodes from communicating with each other.

Basically, setting BRP incorrectly on node 3 prevents node 1 and 2 from communicating, even though it's in listening mode and not transmitting.

Reverting BRP back to *'ideal' values resolves the issue, though I do not receive any CAN messages,


*ideal values are what the mikroc supplied can baud calculator suggests for a 16mhz crystal, i.e:

SJW = 1
BRP = 2
PHSEG1 = 1
PHSEG2 = 2
PROPSEG = 4

I either have something wrong with my software (quite likely), or something with my hardware, (hopefully not)


Top
 Profile  
 
PostPosted: 17 Jan 2019 16:27 
Offline
User avatar

Joined: 05 Mar 2018 09:44
Posts: 564
Location: Belgrade
Hi,

Let me know more about how did you connected the nodes and how did you program it, so we could see what's behind it.


Kind regards,
Petar


Top
 Profile  
 
PostPosted: 18 Jan 2019 20:12 
Offline

Joined: 07 Sep 2013 16:08
Posts: 25
Hi Petar, thanks for your reply!

I am using a homebrew PCB and the intention is to plug into an automotive CAN network.

The CAN specific circuitry is based on that found at the bottom of the CANBUS library help document, using a pic 18F4580 with the CAN RX/TX connected to MCP2551 RX/TX which in turn connected to the CAN_Hi/CAN_Lo pins an automotive OBD plug

The code I have written is quite complex so I omitted it to avoid confusion, but the purpose of the code is to allow access to the canbus functions through an FTDI usb serial converter and configure the canbus and send/receive dynamically via the computer.

There is no onboard termination because this should be provided for on the vehicle itself. Though - I am tempted to try adding some to see what occurs here.

I don't want to overcomplicate by posting a massive code listing (though i will if neccessary) as I think my problem is more fundamental/an idiots mistake or hardware in nature.

To re-cap on the issue: I am at the stage of just setting up the canbus configuration and initialising the bus, I am not yet attempting to transmit a message. If I don't initialise the canbus, or if I use a correct baud rate then I don't receive any messages but other devices can communicate with each other on the bus. If I initialise the CANBUS with wrong or different baud rate then all communication is blocked even when other nodes try and communicate with each other and you get 'error code city'

It's not an easy problem to describe, do be patient with me :s I will provide as much information as i can but I don't want to post too much irrelevent stuff here because it's a sizeable project (by my standards anyway).


Top
 Profile  
 
PostPosted: 18 Jan 2019 22:19 
Offline

Joined: 07 Sep 2013 16:08
Posts: 25
Doing more homework on this subject (forgive my lack of experience - this project is supposed to be my initiation in this field!) it suggests that if I do in fact mismatch the baud then errors on the bus should be expected.

This is derived from what I read here:

https://community.nxp.com/thread/447898

In particular:

"If the node with the 250k baud rate is NOT in listen-only mode, it will detect an error within each message and will send Error Flag, destroying the bus traffic. Because the other nodes (500k) detect the error caused by the Error Flag, they discard the current message and increase their error counters."

So my observation at the minute is that in all likelihood my device is not being configured properly because this does describe the issues being found. Yet I do send requests from my PC that should set it to listen mode, so maybe there is a mistake with how I am initialising or setting the mode.

So might be a code issue after all. it's food for thought.


Top
 Profile  
 
PostPosted: 19 Jan 2019 16:50 
Offline

Joined: 07 Sep 2013 16:08
Posts: 25
I've modified my soft to give feedback to it's operating mode, and during canbus disturbance i can confirm that it is in listen only mode at that time

so the incorrect baud shouldn't influence the bus. hmm.


Top
 Profile  
 
PostPosted: 21 Jan 2019 10:46 
Offline

Joined: 07 Sep 2013 16:08
Posts: 25
I think the problem has been resolved, I basically rewrote the code (not really changed anything in particular) and it's giving me plausible results.

I am still having an issue with transmit of packets but I will make a new thread appropriate to that issue.


Top
 Profile  
 
PostPosted: 21 Jan 2019 12:31 
Offline
User avatar

Joined: 05 Mar 2018 09:44
Posts: 564
Location: Belgrade
Hi,
Thank you for letting us know.
Kind regards,
Petar


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: