CANbus


Closed Thread
Results 1 to 24 of 24

Thread: CANbus

Hybrid View

  1. #1
    Join Date
    Jul 2009
    Posts
    10

    Default CANbus

    Hi Folks,
    Anyone got experience using CAN interface on the 18F4580 or similar microchip device ? Lots of resources available using 16F876 etc with 2510 external interface but had no success converting code to suit a device with built in CAN interface. Have spent a couple of weeks now poring over Datasheets and experimenting with code. Very nearly out of ideas - help!

  2. #2
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818

    Default

    Try these links:
    1. from microchip: http://ww1.microchip.com/downloads/e...Doc/00876A.pdf
    2. A Special google link made to search this forum or the entire internet, your choice: http://www.google.com/custom?hl=en&c...picbasic.co.uk
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  3. #3
    Join Date
    Jul 2007
    Location
    Bavaria
    Posts
    28

    Default

    Hi Tim,

    I made a CAN interface using a PIC 18F248.
    What exactly is your problem?

    Regards,

    Ingo

  4. #4
    Join Date
    Jul 2009
    Posts
    10

    Default

    Hi Ingo,

    Thank you for coming forward. I am not having any success in achieving a Can transmission in Normal mode. I have two 18f4580s connected together on 400mm of twisted pair and 120 ohm terminating resistors. The master is set to transmit only, the 'slave' to reply with received data byte values plus decimal one.

    I have both configured to 125Khz data rate based on 16 Mhz xtals.
    Using an oscilloscope monitoring the Can bus I can see activity. Both units output the same stream. A dominant 30uS pulse, followed by fifteen 10uS wide dominant pulses at 200uS intervals, this does not correspond to the data rate or the standard frame. I have checked my BRGCON settings against the microchip BRG calculator and everything is correct. After a restart, the respective 'transmissions' may appear synchronized, but can often overlap. Because of this I do not think either is properly responding to the prescence of the other. Runnning the receiving node in ICD The rx buffers are not accepting any data and rx buffer flags are never set. Equally the master -(tx only) never clears TXReq bit , Tx errors are flagged (PIE3 etc) . In short I am a little lost. Plenty indications of things going wrong, but no real indications as to the cause.

    I have a nominal bit time of 8Tq, I read somewhere that increasing this to around 13 may help. Did not try this yet as I had more pressing things to attend to.

    Hope this is not too confusing - trying to be concise.

  5. #5
    Join Date
    Jul 2009
    Posts
    10

    Default

    Thanks Joe S for the links, I already looked at most of Microchip data sheets and Application notes. Lots on M2510 but not much on ECAN.

    Just checked the 18F4580 Errata, but there is nothing in there wrt CAN.

    INSE, I just had a look at the 18F248 data sheet and the CAN module has the same basic register set as the 4580 ECAN module. The CAN module is more appropriate to my requirements and my code should not require any major changes to run on 18F248. I have ordered a few of them today - did you have any problems or did you find everything pretty straightforward ?

  6. #6
    Join Date
    Jul 2007
    Location
    Bavaria
    Posts
    28

    Default

    Hi Tim,

    I suggest you start setting up communication in one direction first and add the reply function in the next step.
    Make your receiver blink a LED or put out something on a terminal when it has successfully received data.
    I have been debugging my CAN settings with a Microchip MCP2515 eval board that I won on a exhibition years ago.
    CAN is not that easy if you start from zero, so it was very helpful to have something at hand that HAD to be working...

    My CAN node sends data to a unit and only acknowledges incoming messages.

    while (RXB0CON.7 = 1) or (RXB1CON.7 = 1) 'check receive flag and wait for silence on CAN-Bus
    RXB0CON.7 = 0
    RXB1CON.7 = 0
    pause 100
    @ clrwdt
    wend
    After that the PIC shuts down, maybe you can implement a check of the receive flag to blink a LED...

    How does your CAN setup look like?
    My init sequence:

    CANCON = 128 'Config Mode
    brgcon1 = $01
    brgcon2 = $BF
    brgcon3 = $07
    ciocon = 32 'CANTX recessive high

    TXB0SIDH = $AE 'Identifier für Klemmenstatus =$575
    TXB0SIDL = $A0 'Identifier für Klemmenstatus
    TXB0DLC = 1 ' Länge 1 Byte

    CANCON = 0 ' Normal Mode
    I got the BRGCON values from the Microchip calculator for 100 kBaud and 10MHz clock.

    I see from your post, that you more or less already tried out the tips I could give you.

    I also noticed that the terminator resistor disturbed transmission, so I skipped it.
    Which CAN transceiver are you using?
    Can you post some snippets of your code?
    If your PIC has internal PLL, did you configure it correctly?

    Regards,

    Ingo

Similar Threads

  1. canbus
    By nono2002 in forum mel PIC BASIC
    Replies: 2
    Last Post: - 1st January 2014, 20:35
  2. Canbus
    By Tobias in forum Off Topic
    Replies: 0
    Last Post: - 22nd September 2008, 23:54
  3. Using the 18F2480 CAN CANBUS
    By bwarb in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 15th August 2005, 13:45
  4. CANbus
    By Ioannis in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 17th March 2005, 15:43

Members who have read this thread : 2

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts