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

Connect two board of CCS CAN Bus

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Feb 21, 2012 12:28 pm     Reply with quote

This post has a test program for two CAN bus boards connected together.
http://www.ccsinfo.com/forum/viewtopic.php?t=29627&start=7

Here are various schematics for connecting two CAN bus boards together:
http://www.microchip.com/forums/download.axd?file=0;406254

http://www.interfacebus.com/CAN-Bus-Electrical-Interface-Circuit-schematic.gif

http://www.bobandeileen.com/wp-content/uploads/2007/08/schematic.JPG
shapito



Joined: 21 Feb 2012
Posts: 9

View user's profile Send private message Send e-mail

PostPosted: Wed Feb 22, 2012 9:35 am     Reply with quote

i have use pic compiler version 4.049.
in that prototype have 4 node. The detail is like this:
- node A (PIC18F4580)
- node B (PIC16F876A and MCP2515)
- node C (MCP25050)
- node D (MCP25050)

http://www.ccsinfo.com/product_info.php?products_id=CANbuskit[/img]

http://www.ccsinfo.com/pdfs/product_PDFs/CANBus_board.pdf
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Feb 22, 2012 12:48 pm     Reply with quote

You have the CCS CAN bus board. Use their example files for that board:
Quote:

c:\program files\picc\examples\ex_can_ccs_a.c
c:\program files\picc\examples\ex_can_ccs_b.c
shapito



Joined: 21 Feb 2012
Posts: 9

View user's profile Send private message Send e-mail

PostPosted: Mon Feb 27, 2012 8:11 am     Reply with quote

i still cant do switch from node A to control led at node B.
i still not understand about can bus protocol...
RF_Developer



Joined: 07 Feb 2011
Posts: 839

View user's profile Send private message

PostPosted: Mon Feb 27, 2012 9:08 am     Reply with quote

shapito wrote:
i still cant do switch from node A to control led at node B.
i still not understand about can bus protocol...


Try to forget about node A,B etc. CAN is a message based broadcast bus. There are no addresses for nodes to use. You cannot send a message from one place to another. What you can do is send out messages for any node that wants to listen. Its up to the receiving node to act on the message if it needs to.

So, so you might send out a message from one node that has a particular message ID: a message type if you understand what I mean. All the nodes know that that message ID means "LED control". They also know that if the first data byte is zero it means LED off, and a 1 means LED on. In fact you can make all the bits in the message means a LED on or off, and so control up to 8 LEDs with each byte of the message, and there can be up to 8 bytes in any CAN message.

Now lets suppose node C and D receives this message, but they don't have any LEDs so they simply ignore that message. Node B does have LEDs so it's interested in that message, and lights its LEDs as specified by the message.

Node A cannot know whether its messages are being listened to or acted on, all it can tell is that at least one node received it. There are no message acknowledgements, If you want to do any, and it is not in the spirit of CAN, then you have to make a specific acknowledgement message.

Some people use the message ID as an address, but that's not what the ID is meant for. The ID identifies the message type not it's destination. There is not meant to be and desitination in CAN.

It takes a bit of time to get your head around all this. Once you understand it it will all be quite natural and simple, Personally I like this message passing concept.

RF Developer
shapito



Joined: 21 Feb 2012
Posts: 9

View user's profile Send private message Send e-mail

PostPosted: Mon Feb 27, 2012 9:19 am     Reply with quote

can you give me 1 simple coding?...So that can make me more understand.
dyeatman



Joined: 06 Sep 2003
Posts: 1934
Location: Norman, OK

View user's profile Send private message

PostPosted: Mon Feb 27, 2012 9:22 am     Reply with quote

As PCM said earlier, use the supplied examples. They are as simple as it gets.
I adapted them to my test environment (changed PIC numbers etc) and it worked the first time.

Have you gotten the nodes to "talk" at all?
If so, tell us what works so far...
If not, tell us what you have done so far...
_________________
Google and Forum Search are some of your best tools!!!!


Last edited by dyeatman on Mon Feb 27, 2012 9:38 am; edited 1 time in total
shapito



Joined: 21 Feb 2012
Posts: 9

View user's profile Send private message Send e-mail

PostPosted: Mon Feb 27, 2012 9:35 am     Reply with quote

really?...what function that you have done?
dyeatman



Joined: 06 Sep 2003
Posts: 1934
Location: Norman, OK

View user's profile Send private message

PostPosted: Mon Feb 27, 2012 9:41 am     Reply with quote

What I have done is much more complex than what you are working with
right now. When I started I just used the CAN bus examples to get two
working nodes and expanded from there.

In this case I think it best to focus on what you are doing and get you up
and working with the examples to better understand CAN first...

If you have the CAN board, program the examples into the chips and tell us
if it works. If it does not, you have something more serious that must be
fixed first.
_________________
Google and Forum Search are some of your best tools!!!!
shapito



Joined: 21 Feb 2012
Posts: 9

View user's profile Send private message Send e-mail

PostPosted: Mon Feb 27, 2012 9:53 am     Reply with quote

Can you explain about this?

Code:
#define WRITE_REGISTER_D_ID 0x400

and also this:
Code:

can_init();
can_putd(0x100,0,0,1,TRUE,FALSE);
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Feb 27, 2012 4:40 pm     Reply with quote

Look in the CAN bus driver file. It has explanations of the driver functions:
Quote:

c:\program files\picc\drivers\can-18xxx8.c
jgschmidt



Joined: 03 Dec 2008
Posts: 184
Location: Gresham, OR USA

View user's profile Send private message Send e-mail Visit poster's website

CAN Bus Learning and References
PostPosted: Thu Mar 22, 2012 11:31 am     Reply with quote

Shapito,

I am just starting to use CAN and also got the CCS CAN development board. I also got the CAN Bus Monitor Demo Board from Microchip so I have more boards to play with. It is inexpensive and a good tool for monitoring and inserting CAN messages. Product code is MCP2515DM-BM. I don't change ther program on it, I just use it to monitor the results as I do the exercises in the CCS book.

I have found the following references to be useful in learning about the CAN bus. Perhaps some of these will help you understand the protocol.


http://www.copperhillmedia.com/wp-content/uploads/2010/04/CAN_Book_Preview.pdf - A Comprehensible Guide to Controller Area Network

http://www.ti.com/lit/an/sloa101a/sloa101a.pdf - from Texas Instruments

http://www.ti.com/lit/an/slla270/slla270.pdf - from Texas Instruments

http://ww1.microchip.com/downloads/en/AppNotes/00713a.pdf - from Microchip

http://ww1.microchip.com/downloads/en/AppNotes/00228a.pdf - from Microchip

Cheers,

Jürgen
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
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