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

[CANbus] communication between two nodes with PIC18F2580
Goto page Previous  1, 2, 3  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Martinez_pt



Joined: 26 Sep 2008
Posts: 11

View user's profile Send private message

PostPosted: Mon Sep 29, 2008 11:06 am     Reply with quote

Hi ambrojohn, thank you for your quick response.


My PCWDH version is the following:




I'll try your suggestion.


Thank you again.


Martinez_pt
Martinez_pt



Joined: 26 Sep 2008
Posts: 11

View user's profile Send private message

PostPosted: Mon Sep 29, 2008 11:18 am     Reply with quote

ambrojohn wrote:


Here is the output I get on the PC via rs232:

Code:
===========================================
  Comunication Test with a CAN message
  from NODE_1 to NODE_2 and back to NODE_1
===========================================

Operating Mode.........0 (0 normal, 1 disable, 2 loopback, 3 listen, 4 config)
Messages Received......3 (0 valid, 1 standard, 2 extended, 3 all)
Bit rate...............125.00 kb/s

Specify ID and data of the message
ID: 0xaa
data: hello
PUT 1: ID=AA LEN=5 PRI=3 EXT=1 RTR=0
   DATA = 68 65 6C 6C 6F

PUT 1: ID=AA LEN=5 PRI=3 EXT=1 RTR=0
   DATA = 68 65 6C 6C 6F

PUT 1: ID=AA LEN=5 PRI=3 EXT=1 RTR=0
   DATA = 68 65 6C 6C 6F


Now, you have all the elements to evaluate where I'm wrong.


Hoping in some help. Thank you.
Ambrogio



You dont have any problem with your system, since you send data to node 1 from PC the data is coded in ASCII, so you recive the ASCII code for h, e , l, l, o.

As you can see if you visit this link:

http://www.asciitable.com/


char ASCII code (in hex)
h----------------------68
e----------------------65
l----------------------6C
l--------------------- 6C
o--------------------- 6F


hope this help.


Martinez_PT
Martinez_pt



Joined: 26 Sep 2008
Posts: 11

View user's profile Send private message

PostPosted: Mon Sep 29, 2008 5:33 pm     Reply with quote

Thank you ambrojohn!!

Now I can compile the examples.

I'll try the example on loopback mode, then I'll try something like you, connect two boards with PIC 18F4580 + MCP2551.

Two more days and I should be trying those.


Thank you again

Martinez_pt
ambrojohn



Joined: 27 Apr 2008
Posts: 18

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

PostPosted: Wed Oct 01, 2008 2:07 am     Reply with quote

Hi Martinez_pt

Yes, I know about the correspondence about the chars of the word "hello" and their corresponding ASCI codes in hexadecimal value ;-)

My problem is that, although the software seems to have sent the message, when I connect an oscilloscope to the MCP2551 CANH and CANL I cannot see any signs of the message!!!!

And that should be the reason I cannot receive anything with a connected receiving node.

Hope we can help each other and work it out.
Martinez_pt



Joined: 26 Sep 2008
Posts: 11

View user's profile Send private message

PostPosted: Wed Oct 01, 2008 2:11 pm     Reply with quote

Hi ambrojohn.


Do you have a bootloader for your PIC?


I tried the microchip AP the bootloader they provide it's for older models.



Thank you.
ambrojohn



Joined: 27 Apr 2008
Posts: 18

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

PostPosted: Thu Oct 02, 2008 1:27 am     Reply with quote

Are you talking about AN247?

They have disabled the link....
What the bootloader was used for? Can you explain it to me?
Martinez_pt



Joined: 26 Sep 2008
Posts: 11

View user's profile Send private message

PostPosted: Thu Oct 02, 2008 9:31 pm     Reply with quote

The bootloader was to program the PIC over the board, so I don't have to take it off and use a PIC flash.

Anyway I already got it to work with Tiny PIC Bootloader.

Make some changes on *asm file and it works fine.


Thank you anyway.


I'm waiting for the transceiver's from Microchip to test the bus.


Then I'll say anything about it.

regards

Martinez_pt
ambrojohn



Joined: 27 Apr 2008
Posts: 18

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

PostPosted: Fri Oct 03, 2008 1:55 am     Reply with quote

Martinez_pt wrote:



I'm waiting for the transceiver's from Microchip to test the bus.



Ok, I'm waiting for your results.

Bye
Martinez_pt



Joined: 26 Sep 2008
Posts: 11

View user's profile Send private message

PostPosted: Sun Oct 26, 2008 11:46 pm     Reply with quote

Ok, I got it work.

I used the CCS EX_CAN.C example and it works fine for me.

I can communicate between two boards (18F4580 or 18F4480 + MCP 2551) over the CAN Bus.

I think your problem is on Bit rate, but I can not say any thing for now because I just start with this.

But anyway try something like LOOPBACK.
On this mode the CAN controller do not send anything to the bus, but you can test if you received any thing on the rx_buffer.

If you look on MCP 2551 datasheet you'll see that the value for Rs resistor is 0 ohm for max speed and have a range from 10Kohm to 100Kohm to select slope-control, I'm my case I used a 10k resistor.

If you want I can send you my HW schema and the modifications on the EX_CAN.C.


For me the rate of 125 Kbps is enough, so I don't think I will change any thing that way, I'll have to configure some filters and masks so I'll keep in touch.

Regards

Martinez_pt
ambrojohn



Joined: 27 Apr 2008
Posts: 18

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

PostPosted: Mon Oct 27, 2008 2:43 am     Reply with quote

Hello Martinez_pt. I'm happy to listen to you again.

Martinez_pt wrote:
Ok, I got it work.

I used the CCS EX_CAN.C example.


Me too.

Quote:

I think your problem is on Bit rate, but I can not say any thing for now because I just start with this.


I tried many different bit rate setting (the same on both board), but it never works, till now.

Quote:

But anyway try something like LOOPBACK.


I tried with it, long time ago. And it worked fine.

Quote:

If you look on MCP 2551 datasheet you'll see that the value for Rs resistor is 0 ohm for max speed and have a range from 10Kohm to 100Kohm to select slope-control, I'm my case I used a 10k resistor.


Yes I had used 4700 ohm resistor.

Quote:

If you want I can send you my HW schema and the modifications on the EX_CAN.C.


Yes. I'm very curious to see it. Just to compare it with mine.
http://ambrojohn.altervista.org/CAN_nodes.PNG


Thank you martinez_pt. And I hope to make my circuit work thanks to your results.

Regards
Ambrogio
Martinez_pt



Joined: 26 Sep 2008
Posts: 11

View user's profile Send private message

PostPosted: Mon Oct 27, 2008 1:13 pm     Reply with quote

Hi, Ambrogio.


I think you should not use the led on RX CAN that way, because MCP 2551 RX pin or RX CAN pin from PIC will absorb the current from the led. I know that is only 1 mA by the resistor of 470 ohm but it can interfere on logical signal that PIC receives from MCP, so I put an external circuit for the led so that way the base of transistor only collects the state of the pin that is the reason of the 2,2 Kohm resistor.

Here is my schema :

http://www.ave.dee.isep.ipp.pt/~1010792/esquema.JPG

I just made one schema because both boards have the same HW setup, unless node B that do not have RS232 interface.

Image from the board's:

http://www.ave.dee.isep.ipp.pt/~1010792/DSC00393.JPG

With the bus:

http://www.ave.dee.isep.ipp.pt/~1010792/DSC00400.JPG

Here is the SW for the two nodes:

http://www.ave.dee.isep.ipp.pt/~1010792/EX_CAN_node_A.C
http://www.ave.dee.isep.ipp.pt/~1010792/EX_CAN_node_B.C


The node B sent data over the bus to node A and them the data is sent over RS232 for serial port on PC. As you can see in my configuration only node A has a RS232 interface.

I hope this may help you on your CAN communication.

Regards

Martinez_pt
ambrojohn



Joined: 27 Apr 2008
Posts: 18

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

PostPosted: Mon Oct 27, 2008 5:56 pm     Reply with quote

Many thanks for those informations!

I will try them during next weekend (unfortunately, I have not the board with me).

Now you can transmit via CAN. You could try to send a message from node A to node B and then resend the same message back to node A and see it via RS232. In this way you can see, and let me know, if you can also receive correctly messages.

I hope to return with good news.
Ambrogio
ambrojohn



Joined: 27 Apr 2008
Posts: 18

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

PostPosted: Mon Oct 27, 2008 6:04 pm     Reply with quote

Have you tried to make it work with the PICs internal oscillator?
Martinez_pt



Joined: 26 Sep 2008
Posts: 11

View user's profile Send private message

PostPosted: Mon Oct 27, 2008 8:30 pm     Reply with quote

Hi, Ambrogio.


ambrojohn wrote:
Have you tried to make it work with the PICs internal oscillator?


No, I didn't. I have used an external oscillator 20 MHz.

I'll try to make your SW objective work.

If I was able to do it I let you know.

Best regards

Martinez_pt
ambrojohn



Joined: 27 Apr 2008
Posts: 18

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

PostPosted: Tue Oct 28, 2008 7:33 am     Reply with quote

Do you think I could use the same 20 MHz oscillator for both PICs?

A
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, 3  Next
Page 2 of 3

 
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