CAN communications with PICS


Closed Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Jan 2007
    Location
    Houston, TX
    Posts
    96

    Default CAN communications with PICS

    Hello Pic Users,
    It has been a long time since my last post/ question.
    Could someone point me in the right direction.
    Are dsPIC's the only pics that can communicate with CAN communication?
    Has anyone attempted this with PBP?
    How about 16F pics with CAN tranceivers?

    Thanks,
    Padawan-78

  2. #2
    Join Date
    May 2007
    Posts
    604


    Did you find this post helpful? Yes | No

    Default

    According to here, there are 64 PIC's with CAN modules (and not just dsPICs - PIC18s and PIC24s as well):
    http://www.microchip.com/ParamChartS...g=en&pageId=75

    As for software, many choices are available - if you are not limiting yourself to PBP.

  3. #3
    Join Date
    Oct 2004
    Location
    Hangover, Germany
    Posts
    289


    Did you find this post helpful? Yes | No

    Smile

    I have solved a simple CAN-Readonly in PICBASIC on a 18F4585. You have to read a lot of datasheets and when the program is ready - it seems to be so easy...
    PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2

  4. #4
    Join Date
    Jan 2007
    Location
    Houston, TX
    Posts
    96


    Did you find this post helpful? Yes | No

    Smile thanks

    BIG WUMPUS,
    Thanks for the success story.

    I am doing the same basic thing, just need to be able to read a single can bus and decode data from it, then outputting data to LCD, leds, etc.
    Later this year I will be moving back into C programming with dsPIC's to talk to multiple CAN modules. This will take time of coarse, but for now I would really like to see If I can use PBP to just decode the data from the can.

    Can you provide any other places to begin researching, datasheets etc?
    thanks,
    Padawan-78

  5. #5
    Join Date
    Oct 2004
    Location
    Hangover, Germany
    Posts
    289


    Did you find this post helpful? Yes | No

    Thumbs up

    I have written this code:

    Get it, look inside the datasheet of the CAN-Module and try to understand it.
    There is some trouble about timing, then I configure the filters and registers.
    In the main-program I poll the flags in order to see new data.


    ---
    Code:
    ;==========================================================================
    ;CAN-Interface steuern
    ;==========================================================================
    CAN_Init:
        CANCON=%10010000:Repeat:Until (CANSTAT & %11100000)=%10000000;Configuration Mode einschalten
        ECANCON=%01000000                               ;Mode 1
        RXFCON0=%00000000:RXFCON1=%00000000             ;alle 16 Filter:deaktiviert
        MSEL0=%11111111:MSEL1=%11111111:MSEL2=%11111111:MSEL3=%11111111;alle 16 Filter:no mask
        RXFBCON0=%00110010:RXFBCON1=%01010100:RXFBCON2=%01110110;Filter 0-5 -> B0-B5
        CIOCON=%00100000
        select case CAN_Mode
            case wMode_EuroTiger:                       ;Euro-Tiger
                BRGCON1=%01000001:BRGCON2=%10110001:BRGCON3=%00000101;BRP=0TQ,Sync=1TQ,Prop=2TQ,Phase1=7TQ,Phase2=6TQ,SJW=2TQ
                ;B0: EEC1 $0CF00400 Motordrehzahl
                RXF0SIDH=%01100111:RXF0SIDL=%10001000:RXF0EIDH=%00000100:RXF0EIDL=%00000000
                ;B1: EEC2 $0CF00300 Lastquotient
                RXF1SIDH=%01100111:RXF1SIDL=%10001000:RXF1EIDH=%00000011:RXF1EIDL=%00000000
                ;B2: Eng_Temp $18FEEE00 Temperaturen
                RXF2SIDH=%11000111:RXF2SIDL=%11101010:RXF2EIDH=%11101110:RXF2EIDL=%00000000
                ;B3: Inlet Conditions $18FEF600 Ladeduck
                RXF3SIDH=%11000111:RXF3SIDL=%11101010:RXF3EIDH=%11110110:RXF3EIDL=%00000000
                RXFCON0=%00001111                       ;Filter 0-3 aktiviert
        End select
    
    CAN_ON:
        tCAN_Sleep=wInput                               ;CAN-Transmitter einschalten
        CANCON=%01110000:Repeat:Until (CANSTAT & %11100000)=%01100000;Listen Mode einschalten
        CAN_Clear=%00111111:CAN_Restart=%00111111       ;alle Buffer leeren und alle Timer neu starten
        Return
    
    CAN_OFF:
        CANCON=%00110000:Repeat:Until (CANSTAT & %11100000)=%00100000;Disable Mode einschalten
        CAN_Sleep=true:tCAN_Sleep=wOutput:Return        ;CAN-Transmitter ausschalten
    ---
    PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2

  6. #6
    Join Date
    Jan 2007
    Location
    Houston, TX
    Posts
    96


    Did you find this post helpful? Yes | No

    Default

    Thanks for the code example,
    I will begin my research today on this.
    Padawan-78

  7. #7
    Join Date
    Jan 2007
    Location
    Houston, TX
    Posts
    96


    Did you find this post helpful? Yes | No

    Talking update on CAN bus communication

    All,
    A good friend suggested that I try CCS software and compiler for pic CAN BUS communication called "PCD". Not to be an advertiser of another companies product but the software is GREAT for CAN applications, lcds, glcd. PCD is alot more work than PBP (mostly because of the pure C syntax) but other than that they have alot of built in functions (similar to PBP) you can use.....

    So far I have been able to recieved and send data between 4 nodes (uP's) at 125k baud. If you need/ want to use CAN communications I high suggest going with CCS. The software is 2-3 x PBP $ but well worth it especially because you can program all 8/16/24/dsPIC's on the list. They also have some great development boards and demo kits for all kinds of projects.

    there ya have it....
    Padawan-78

Similar Threads

  1. Multiple Pics accessing single EEPROM
    By Atom058 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 3rd February 2008, 17:22
  2. Retrieving infos from multiple PICs on a bus/chain
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 15th October 2007, 04:42
  3. Dead PICs
    By CocaColaKid in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 15th August 2007, 13:12
  4. USB Pics, ICD2, pic basic pro
    By vacpress in forum USB
    Replies: 34
    Last Post: - 20th January 2007, 20:50
  5. PIC Basic Pro <-> HP-IL communications
    By swr999 in forum Serial
    Replies: 0
    Last Post: - 6th March 2006, 18:30

Members who have read this thread : 0

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