CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

CAN problems
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
sjbaxter



Joined: 26 Jan 2006
Posts: 141
Location: Cheshire, UK

View user's profile Send private message Visit poster's website

PostPosted: Wed Aug 23, 2006 8:29 am     Reply with quote

Code:
if(can_putd(rx_id out_data, tx_len,tx_pri,tx_ext,tx_rtr));


what do you do if this returns zero. Do you just try again or wait for a while ? if it fails, say, more than 20 times do you give up or reset the node.

What you are trying to achive is similar to J1939 Address Claiming. That assumes a 'preferred address' in its negotiations. In your case that would have to be a random number at power up. The trouble is if two nodes really want the same address only one can take it. So J1939 added an extra 64bits (name) into the negotiation to futher resolve the conflict.

There is a bit of information in a Microchip App Note that my be of use:

App Note 930

Just as a sidenote, what version of CCS are you using ?
Which PIC/CAN Controller and CAN tranceiver ?
_________________
Regards,
Simon.
newguy



Joined: 24 Jun 2004
Posts: 1909

View user's profile Send private message

PostPosted: Wed Aug 23, 2006 9:38 am     Reply with quote

Another thing.....

You mention that you don't change the CAN bus speed from the "default". How do you know what the default is? What if it is 10 bits per second?

Definitely look into setting each node to a definite value such as 125 kpbs or something like that. Go look over PCM's post on the subject (it helped me):

http://www.ccsinfo.com/forum/viewtopic.php?t=22138&highlight=bit+timing
iso
Guest







PostPosted: Wed Aug 23, 2006 10:54 am     Reply with quote

The vehicle systems I've used (not J1939) have not had addresses for each node. Rather there are unique address for each function.

In that way if one car gets a module for the fuel pump lets say id 0x500 is the fuel level and status message it sends. Which the cluster reads and displays to the user. Now say a car doesn't get a fuel pump module, rather its a hardwired to the engine controller. The engine controller still sends out message 0x500 to the bus, the cluster does not need any new programming. Most nodes don't need to know WHERE a message is coming from, just rather the what the data IS.

If you have a complex system where many nodes are sending information to other nodes on a cyclic basis it doesn't make sense to give one busy node 20 addresses that other nodes send to. Rather just make it listen for data its interested in.

In my experience I've found this to be the more flexible system. Mainly since its easy to upgrade, you don't have modules getting upset when they request data to a non-existant module. etc

Also, termination is not always 120 for the bus. CAN physical states 40-80 ohm total for the differential pair, but a lot of automotive networks also use 2.6k at all non-end nodes for emi. This does limit the number of nodes on the bus to somthing like 24-32, varies with bus speed. Also, automotive networks never (that I've seen) go much above 30% load. But these are all saftey systems so I but they are just being careful
Gordon



Joined: 14 Jun 2006
Posts: 3

View user's profile Send private message

PostPosted: Tue Aug 29, 2006 1:28 am     Reply with quote

Quote:
if it fails, say, more than 20 times do you give up or reset the node.
Do you mean reset_cpu, or just resetting the CAN buffers?


Quote:
J1939 Address Claiming.
The algorithm i have created works well, and has been substantially tested (or so i would like to think). If two nodes fight over an address, the one which claimed it first interms of time wins, if this is equal, they both try and pick another one. I generate random numbers using the timers, as it took me a while to realise there is no such thing as a real random number!! I will look in to J1939 for future applications, but i am 95% there with this one.

Quote:
Just as a sidenote, what version of CCS are you using ?
Which PIC/CAN Controller and CAN tranceiver ?
1.14 CCS suite (is that right?). 18F4580 and a A82C250 can controller.

Quote:
How do you know what the default is?
I don't, I guess I'm being lazy. I will certainly look at setting it properly.

Thanks for all help, it's good to try and understand what is going on, rather than using the CAN commands blindly!!!!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
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 vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group