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 problem (beginner)
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
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Jan 15, 2008 1:03 pm     Reply with quote

Try this program. It blinks an LED on Pin B0. Does this program
compile with no errors ?
Code:

#include <18F448.h>
#fuses HS, NOPROTECT, PUT, BROWNOUT, NOWDT, NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

//======================================
void main()
{

while(1)
  {
   output_high(PIN_B0);
   delay_ms(500);
   output_low(PIN_B0);
   delay_ms(500);
  }

}
Stephane
Guest







LEDS
PostPosted: Fri Jan 18, 2008 10:31 am     Reply with quote

Sorry I didn't see your answer (i didn't see there was a second page)

Same error message with this little program...

Yet i have tried another simple program with leds for a 18f448 just before yours (CAN BUS) and it was OK.

...
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jan 18, 2008 11:37 am     Reply with quote

I was able to duplicate your problem. I commented out the #device
statement in the 18F448.h file, and I got the error message that you get.
Example:
Quote:
// Standard Header file for the PIC18F448 device
//#device PIC18F448
#nolist

Question:
Did you do this ? Did you comment out the #device statement ?
If so, please put it back the way it was. Never edit the .H files.
Stephane
Guest







pic18f448
PostPosted: Sun Jan 20, 2008 12:15 pm     Reply with quote

First Thank you to help me

I didn't modify the 18f448.h :
I know this is a already made file and i don't touch this kind of file

I cannot find these lines in 18f448.h :

// Standard Header file for the PIC18F448 device
#device PIC18F448
#nolist

Maybe i've got a bad 18f448.h file ?

Another possible reason :
When i create a new PIC WIZARD PROJECT i choose the 18f448 PIC, 8 000 000 Mhz, High Speed Oscillator and i choose BUS CAN > USE CAN BUS

Do i have to choose other options ?

thank you again
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Jan 20, 2008 1:57 pm     Reply with quote

I don't use the IDE version of the CCS compiler (such as PCWH).
I use the "command line" version, and I use MPLAB as the IDE.

In the command line version, all .H files have a #device statement for
the PIC at the start of the file.

I don't know what CCS is doing in the IDE version.
Stephane
Guest







News...
PostPosted: Tue Jan 22, 2008 11:23 am     Reply with quote

i reinstalled my PIC C Compiler and i didn't update it

my current version in PCWH 3.212

And the program is compiled correctly ....

So for the moment it's OK !

I'll try it with 2 easypic flash modules soon and i'll say to you if it works fine.

Thank you for the time you gave to me

Feedback soon
(Next tuesday i think)

Stephane
vinh
Guest







new question
PostPosted: Mon Mar 03, 2008 10:10 pm     Reply with quote

hi

I work in forklift truck field and I have 1 question to ask:

I have 6 controllers and two resistors 120 ohm and using CAN bus to

communicate. How can controllers communicate in this situation or they

have a CANchip interface that can communicate 6 controllers.

Hoping who know, reply soon.

thanks
newguy



Joined: 24 Jun 2004
Posts: 1907

View user's profile Send private message

PostPosted: Mon Mar 03, 2008 10:37 pm     Reply with quote

A very large number of controllers can be connected to one CAN bus. The 120 ohm resistors are placed at the two ends of the bus to prevent/minimize reflections. Controllers in the middle of the bus don't need termination resistors.
vinh
Guest







reply
PostPosted: Tue Mar 04, 2008 8:00 pm     Reply with quote

sorry NewGuy

I don't understand what you mean controller in the middle, for my example, I have 6 controllers so you mean I need only 1 CANchip interface and two 120 ohm resistor placed in the start and end of the canbus. So you can show me more details about this problem. Why we only need two resistors and what kind of CANchip can we use in this case?(I saw you said that two resistors play a important role in preventing reflection, how important they are? If I don't have two resistors what happened? and what happened if I place another resistor in the middle of the CANbus)

see you soon

thanks
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Mar 04, 2008 8:33 pm     Reply with quote

Quote:
I have 6 controllers

Tell us what a "controller" is. Describe it, or give the part number.
vinh
Guest







reply
PostPosted: Tue Mar 04, 2008 9:12 pm     Reply with quote

PCM programmer wrote:
Quote:
I have 6 controllers

Tell us what a "controller" is. Describe it, or give the part number.


thanks for replying me soon PCM programmer

I said that I worked in forklift truck and they're modern truck, they have controller such as

traction controller

steering controller

hydraulic controller

display controller...

I just said like this and I saw in circuit they draw only two resistors 120 ohm

can you suggest me what kind of CANchip can they use?

thanks
newguy



Joined: 24 Jun 2004
Posts: 1907

View user's profile Send private message

PostPosted: Tue Mar 04, 2008 11:20 pm     Reply with quote

Regarding the general layout of a CAN bus, consult this thread: http://www.ccsinfo.com/forum/viewtopic.php?t=27504&highlight=bus+termination

There are quite a number of CAN transceivers available. Some are 'dumb' devices that just take care of driving/sensing the bus. Examples would be the LT1796 or MCP2551. Others, like the MCP2510 or MCP2515 also include the 'smarts' built into the chip that take care of the actual communication.

Any CAN compliant transceiver or transceiver with built-in controller will work as long as you're able to match the bus's bit rate.
sresam89



Joined: 15 Mar 2012
Posts: 20
Location: India

View user's profile Send private message

PostPosted: Mon Apr 02, 2012 8:45 pm     Reply with quote

PCM programmer wrote:
Here is a simple test program which allows you to prove that two CAN


1. Can I use the same program for 18f4550/4585 ECAN controllers?
2. Will there be any other major changes in the program except for the headers?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Apr 03, 2012 5:06 pm     Reply with quote

18F4550 doesn't have a CAN bus module. It has a USB module.

For the 18F4585, it should work, because the 18F4585 data sheet says:
Quote:

The ECAN module is fully backward compatible with the
CAN module available in PIC18CXX8 and PIC18FXX8 devices.
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