Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Development
  3. CAN bus transport implementation

CAN bus transport implementation

Scheduled Pinned Locked Moved Development
54 Posts 5 Posters 487 Views 8 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    JeeLet
    wrote on last edited by JeeLet
    #16

    a topo of the day

    on the hardware side, I got screwed with an arduino pin that became too soft, too dilated, look for an hour before understanding why no dialog.

    Otherwise, on the Gateway side, no problem, MyController recognized well.

    and CAN_Switch.ino is good too, my Widget on MyC switches well on the switch change.

    listing of the dialog pour le Node 51 (set up in a fixed place )

    coter log from MyC:

    2022-06-11T18:49:35.167+0200	recd	0;255;3;0;9;1482640 TSF:MSG:READ,51-51-0,s=4,c=1,t=16,pt=1,l=1,sg=0:1
    2022-06-11T18:49:35.170+0200	recd	51;4;1;0;16;1
    2022-06-11T18:49:35.179+0200	recd	0;255;3;0;9;1482653 TSF:MSG:READ,51-51-0,s=255,c=3,t=21,pt=1,l=1,sg=0:0
    2022-06-11T18:49:35.182+0200	recd	51;255;3;0;21;0
    

    coter IDE from MyS:

    67889 TSF:MSG:BC
    68197 TSF:MSG:SEND,51-51-0-0,s=255,c=3,t=21,pt=1,l=1,sg=0,ft=0,st=OK:0
    68203 TSF:MSG:READ,0-0-255,s=255,c=3,t=20,pt=0,l=0,sg=0:
    
    68208 TSF:MSG:BC
    68836 TSF:MSG:SEND,51-51-0-0,s=255,c=3,t=21,pt=1,l=1,sg=0,ft=0,st=OK:0
    
    68843 MCO:SLP:MS=5,SMS=0,I1=255,M1=255,I2=255,M2=255
    68848 TSF:TDI:TSL
    68849 MCO:SLP:WUP=-1 ........ it is incomplete 
    

    well now we have to calm down the CAN bus dialog, the Rx/Tx Led of the gateway looks like a Christmas tree :)

    tomorrow I'll test a CAN_Switch version2 sketch

    1 Reply Last reply
    0
    • J Offline
      J Offline
      JeeLet
      wrote on last edited by JeeLet
      #17

      test with the digital output inputs of 2 Arduino on CAN Bus.

      • status of a button and control of a led with MyC

      a proof in video that it is functional :)

      video

      all is not functional, on the end of the video, the reset or reboot does not work, (but functional with the RS485 bus)
      .... to follow ;)
      (now the Analog values, decimal to test )

      I would like to test the Node to Node with the filtering.
      a question : is it difficult to put the filters on the MySensors sketch ???

      there are still MySensors on the forum ???
      if yes, a help for Adam Slowik would be a great thing.
      implement it in MyS Yes Yes

      Thanks

      1 Reply Last reply
      0
      • Adam SlowikA Offline
        Adam SlowikA Offline
        Adam Slowik
        wrote on last edited by
        #18

        @JeeLet as I can see You had bussy weekend. I was AFK so I was unable to respond. Within working days I should be able to respond quicker.

        @JeeLet said in CAN bus transport implementation:

        lines 163 and 228 modify and error resolved

        Can you push Your fix to My repo?

        @JeeLet said in CAN bus transport implementation:

        a proof in video that it is functional

        Great job! I never was at this stage.

        @JeeLet said in CAN bus transport implementation:

        all is not functional, on the end of the video, the reset or reboot does not work, (but functional with the RS485 bus)
        .... to follow

        Can You provide (gateway/node) logs from reset scenario. It would be great to have those logs either for RS485 and CAN so I can compare them.

        @JeeLet said in CAN bus transport implementation:

        I would like to test the Node to Node with the filtering.
        a question : is it difficult to put the filters on the MySensors sketch ???

        Could You describe what kind of test You would like to perform? Right now there is no way to set filters from the sketch. I think it should stay this way.

        Perhaps We have different things in mind when We think about filters. I'll try to describe how I see this.

        When it comes to CAN frame there is header and body. Header contains metadata and body contains data. mcp2515 can filter frames based on header content. Header contains id of destination node. Based on this id filters are set to drop any messages not intended for current node. This way if gateway want to send message to node with id=51 only node with this id receives this message.

        There is exception for this rule. Messages with destination id set to BROADCAST_ADDRESS reaches all nodes.

        With this in mind I see no reason to set filters differently. Of course I can be wrong.

        Composition of header is described in MyTransportCAN.cpp in method _buildHeader()

        As of now my all can modules and arduinos are burried in some box at My attic so I am unable to test anything

        1 Reply Last reply
        0
        • J Offline
          J Offline
          JeeLet
          wrote on last edited by JeeLet
          #19

          "Can you provide logs (gateway/node) from the reset scenario. It would be great to have these logs for RS485 and CAN so I can compare them."

          listing

          Released today 2 gateways connect to MyController

          • UNO_usb - Gateway and RS485 bus
          • UNO_usb - Gateway and CAN Bus

          with connect, a UNO with the basic sketch "RelayWithButtonActuator_base.ino" (slightly modified)
          with ... a Led and a Switch, for each bus.

          The Listing split in several parts

          "Log of the IDE and MyC for the two types of bus (node34 and node 54), CAN and RS485.

          - Listing Action RESET with MyController 
          	2 parts for CAN
          	and 
          	2 parts for RS485
          	
          
          and 
          
          - Listing Action On/Off on the node switch or with MyController 
          	4 parts for CAN
          	and 
          	4 parts for RS485
          

          No error on the Reset, it works fine, an error from me.

          Oh yes, I even found an error :)
          the sendSketchInfo("test xxxxx", "1.0"); is not up

          see the end of the video
          video

          ....I will answer the other question tomorrow.

          1 Reply Last reply
          0
          • J Offline
            J Offline
            JeeLet
            wrote on last edited by JeeLet
            #20

            @Adam-Slowik "Can you push your patch to my repository? " .... I don't know how

            On the CAN principle

            @Adam-Slowik "Based on this id, the filters are configured to remove all messages not intended for the current node. This way, if the gateway wants to send a message to the node with id = 51, only the node with that id receives that message." ... yes, that's how I see it.

            another way to say/explain it.

            "The philosophy of CAN is to constitute a messaging system.
            The messages (the letter) send on the CAN Bus (the post office), distributed by the CAN Bus (the letter carrier).

            Each (letter) have each an identifier (stamp of the post ☺ ) that ... identifies it.
            And put in the right mailbox (the MCP2515) according to the choice of filter/mask ( color, scent? ☺ ) of the letter."

            So there are two "stratum" of dialogue / work.

            • one on the Can Bus, and another on the Nodes.

            The idea is to relieve the Nodes of unnecessary work/effort with the risks that this brings. Less letter to open :)

            @Adam-Slowik "... my modules and arduinos are buried in a box in my attic..." ? Arduino 8bit and MySensors is over for you?
            ( if it's a personal / family reason don't say anything )

            1 Reply Last reply
            0
            • J Offline
              J Offline
              JeeLet
              wrote on last edited by JeeLet
              #21

              I tested my sketch with clock and OLED to see :)

              bah No the time is not up :(

              I give this information for an overview, it can help for the continuation (but not to give you work :) )

              The listing of the messages of mySensors

              test with "void receiveTime" function (without RTC clock)
              https://forum.mysensors.org/topic/4809/real-time-clock-module-lcd-display-and-controller-time/8?_=1655208396048

              ..........Log MyC - terminal ssh  .........
              2022-06-14T14:01:45.115+0200	recd	0;255;3;0;9;65310350 TSF:MSG:READ,55-55-0,s=255,c=3,t=1,pt=0,l=0,sg=0:
              2022-06-14T14:01:45.119+0200	recd	0;255;3;0;9;65310356 TSF:MSG:ECHO REQ
              2022-06-14T14:01:45.127+0200	recd	0;255;3;0;9;65310360 TSF:MSG:SEND,0-0-55-55,s=255,c=3,t=1,pt=0,l=0,sg=0,ft=0,st=OK:
              2022-06-14T14:01:45.127+0200	recd	55;255;3;0;1;
              2022-06-14T14:01:45.146+0200	sent	55;255;3;0;1;1655215305
              2022-06-14T14:01:45.160+0200	recd	0;255;3;0;9;65310394 TSF:MSG:SEND,0-0-55-55,s=255,c=3,t=1,pt=0,l=10,sg=0,ft=0,st=OK:1655215305
              
              
              ..........Log MyS - terminal IDE .........
                   time current:0   -------------------------------------------  
              58007 TSF:MSG:SEND,55-55-0-0,s=255,c=3,t=1,pt=0,l=0,sg=0,ft=0,st=OK:
              58017 TSF:MSG:READ,0-0-55,s=255,c=3,t=1,pt=0,l=0,sg=0:
              58022 TSF:MSG:ECHO
              

              avec Bus RS485

              
              ..........Log MyC - terminal ssh  .........
              2022-06-14T14:22:41.265+0200	recd	0;255;3;0;9;72000090 TSF:SAN:OK
              2022-06-14T14:22:41.274+0200	recd	0;255;3;0;9;72000096 TSM:READY:NWD REQ
              2022-06-14T14:22:41.298+0200	recd	0;255;3;0;9;72000115 ?TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=20,pt=0,l=0,sg=0,ft=0,st=OK:
              2022-06-14T14:22:41.917+0200	recd	0;255;3;0;9;72000736 TSF:MSG:READ,22-22-0,s=255,c=3,t=21,pt=1,l=1,sg=0:0
              2022-06-14T14:22:41.920+0200	recd	22;255;3;0;21;0
              
              
              .........Log MyS - terminal IDE .........
                 time current:1422   -------------------------------------------  
              423956 TSF:MSG:READ,0-0-255,s=255,c=3,t=20,pt=1,l=1,sg=0:0
              423962 TSF:MSG:BC
              424008 TSF:MSG:SEND,22-22-0-0,s=255,c=3,t=21,pt=1,l=1,sg=0,ft=0,st=OK:0
                 requestOn----------------------------------------- 
              
              1 Reply Last reply
              0
              • Adam SlowikA Offline
                Adam SlowikA Offline
                Adam Slowik
                wrote on last edited by
                #22

                @JeeLet said in CAN bus transport implementation:

                Arduino 8bit and MySensors is over for you?

                No it is not over. Right now I don't have enough time. Now I am able to work for let's say 1 hour per week. Probably I will become more active at the end of 2023 :D

                @JeeLet said in CAN bus transport implementation:

                bah No the time is not up

                Here You posted RS485 version:
                https://forum.mysensors.org/topic/4809/real-time-clock-module-lcd-display-and-controller-time/8?_=1655208396048

                Could You post here CAN version?

                1 Reply Last reply
                0
                • J Offline
                  J Offline
                  JeeLet
                  wrote on last edited by JeeLet
                  #23

                  @Adam-Slowik "Could you post the CAN version here?"

                  it's the same, except that the bus is not rs485 but CAN :)

                  ......
                  ........
                  #define MY_NODE_ID 55          /*Node en ID static*/
                  
                    #define MY_CAN
                    
                    #include "SSD1306Ascii.h"
                  ........
                  .....
                  

                  but I'll go back to PaulStoffregen's Lib <TimeLib.h> to see if I can simplify the basic sketch of MySensors

                  1 Reply Last reply
                  0
                  • Adam SlowikA Offline
                    Adam SlowikA Offline
                    Adam Slowik
                    wrote on last edited by
                    #24

                    In previous example (with diodes) did You set CAN_CLOCK to MCP_16MHZ?

                    1 Reply Last reply
                    0
                    • J Offline
                      J Offline
                      JeeLet
                      wrote on last edited by JeeLet
                      #25

                      no it stayed on 8Mhz ?

                      I didn't modify anything (the other sketches work)

                      But I just looked at the quartz and it's 16M!! (SW-65-16M)

                      I am lost :(

                      https://www.gotronic.fr/art-module-bus-can-sbc-can01-28405.htm

                      but on the doc there is :
                      The 8000000 stands that the MCP2515 operates with a clock of 8 MHz. This
                      depends on the quartz used and may need to be adjusted.

                      error
                      on the official doc it's a 16Mhz like mine.

                      • https://www.joy-it.net/en/products/SBC-CAN01
                        OSCILLATOR 16 MHz Crystal Oscillator

                      so 8Mhz or 16Mhz?
                      and why does it work with the previous sketches?

                      1 Reply Last reply
                      0
                      • J Offline
                        J Offline
                        JeeLet
                        wrote on last edited by JeeLet
                        #26

                        I think the dialogue is good
                        but the problem is the length of the storyline

                        a part of the dialog on the IDE terminal for both types
                        CAN and RS485

                           - IDE terminal sur RS485 :
                        
                        4066 TSF:MSG:ECHO
                        4132 TSF:MSG:READ,0-0-22,s=255,c=3,t=1,pt=0,l=10,sg=0:1655285320
                        8018 TSF:MSG:SEND,22-22-0-0,s=255,c=3,t=1,pt=0,l=0,sg=0,ft=0,st=OK:
                        8054 TSF:MSG:READ,0-0-22,s=255,c=3,t=1,pt=0,l=0,sg=0:
                        8058 TSF:MSG:ECHO
                        8111 TSF:MSG:READ,0-0-22,s=255,c=3,t=1,pt=0,l=10,sg=0:1655285324
                          newTime:1655285324   -------------------------------------------  
                        
                        
                          - IDE terminal sur CAN :
                        
                        22224 MCO:REG:REQ
                        22226 TSF:MSG:SEND,55-55-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2
                        22233 !MCO:PRO:RC=1
                        22235 TSF:MSG:READ,0-0-55,s=255,c=3,t=27,pt=1,l=1,sg=0:1
                        22240 MCO:PIM:NODE REG=1
                        28004 TSF:MSG:SEND,55-55-0-0,s=255,c=3,t=1,pt=0,l=0,sg=0,ft=0,st=OK:
                        28014 TSF:MSG:READ,0-0-55,s=255,c=3,t=1,pt=0,l=0,sg=0:
                        28019 TSF:MSG:ECHO
                          newTime:0   -------------------------------------------  
                        

                        sketch

                        void receiveTime(unsigned long controllerTime)   {   
                            if (receiveTime) stateCom = true ; else stateCom = false;
                              newTime = controllerTime;
                        " " ....
                        Serial.print("  newTime:"); Serial.print(newTime);
                        
                        1 Reply Last reply
                        0
                        • J Offline
                          J Offline
                          JeeLet
                          wrote on last edited by JeeLet
                          #27

                          frequency change

                          with 16Mhz I have a NACK

                          // #define CAN_CLOCK MCP_16MHZ
                          105 TSM:FPAR
                          18107 ?TSF:MSG:SEND,55-55-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=4,st=NACK:
                            newTime:0   -------------------------------------------  
                               time current:0   -------------------------------------------  
                          20115 !TSM:FPAR:NO REPLY
                          20117 TSM:FPAR
                          20119 ?TSF:MSG:SEND,55-55-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=5,st=NACK:
                          
                          // #define CAN_CLOCK MCP_8MHZ
                          8004 TSF:MSG:SEND,55-55-0-0,s=255,c=3,t=1,pt=0,l=0,sg=0,ft=0,st=OK:
                          28014 TSF:MSG:READ,0-0-55,s=255,c=3,t=1,pt=0,l=0,sg=0:
                          28019 TSF:MSG:ECHO
                            newTime:0   -------------------------------------------  
                               time current:0   -------------------------------------------  
                          38005 TSF:MSG:SEND,55-55-0-0,s=255,c=3,t=1,pt=0,l=0,sg=0,ft=0,st=OK:
                          38016 TSF:MSG:READ,0-0-55,s=255,c=3,t=1,pt=0,l=0,sg=0:
                          

                          https://forum.arduino.cc/t/how-to-set-the-mhz-in-mcp2515-library-file-based-on-crystal-oscillator/628822

                          1 Reply Last reply
                          0
                          • J Offline
                            J Offline
                            JeeLet
                            wrote on last edited by
                            #28

                            in the sketch I added lines to visualize the buffer data

                            a part of I recopied

                            log IDE :

                            newTime:0   -------------------------------------------  
                               Extended ID: 0x0410FF00  DLC: 8  Data: 0x00 0x00 0xFF 0x0A 0x23 0x14 0xFF 0x00
                            88010 TSF:MSG:SEND,55-55-0-0,s=255,c=3,t=1,pt=0,l=0,sg=0,ft=0,st=OK:
                            Extended ID: 0x05103700  DLC: 7  Data: 0x00 0x00 0x37 0x02 0x13 0x01 0xFF
                            Extended ID: 0x06303700  DLC: 8  Data: 0x00 0x00 0x37 0x52 0x03 0x01 0xFF 0x31
                              newTime:0   ------------------------------------------- 
                            

                            I stop for me, I pause for 1 day or 2 :)

                            1 Reply Last reply
                            0
                            • Adam SlowikA Offline
                              Adam SlowikA Offline
                              Adam Slowik
                              wrote on last edited by
                              #29

                              I found a bug in my code. Please re-download new version.

                              If something won't work please enable CAN debug by adding:
                              #define MY_DEBUG_VERBOSE_CAN

                              add this to gateway and to node sketch

                              1 Reply Last reply
                              1
                              • J Offline
                                J Offline
                                JeeLet
                                wrote on last edited by JeeLet
                                #30

                                #define MY_DEBUG_VERBOSE_CAN .....yes yes I already tested it, it's very good.
                                (a very useful function)

                                ..go to

                                • Reloading the CAN-MyS update
                                • ClearEeprom of the GW and Nodes
                                • Reloading of Sketches on GW and Nodes

                                Bravo :woman-lifting-weights:

                                • sendSketchInfo(" text ...."); and well up

                                • requestTime(receiveTime); and functional

                                Ahhhhhh Lovely this is great :rainbow:
                                I offer the coffee crossing :croissant: :coffee:

                                (what was the problem ??? )

                                After the test on the Digital I/O of the Nodes ,
                                now I test the Analog I/O

                                a Super Thank You @Adam-Slowik
                                :+1:

                                1 Reply Last reply
                                0
                                • J Offline
                                  J Offline
                                  JeeLet
                                  wrote on last edited by JeeLet
                                  #31

                                  a test with DHT22 probes.

                                  the values go up well on MyC
                                  real decimal values :)

                                  here is a screen shot

                                  big vue

                                  I have to find another type of probes, the DHT22 give me losses, or my sketch is to review

                                  ReEdit
                                  error :angry:
                                  I got excited too fast
                                  the values are not refreshed.
                                  I look better :eyeglasses:

                                  ReRe-edition
                                  I made a mistake, as I play a little too much with MyController, I add and remove gateways from nodes and other salads.
                                  and well in the end it makes no sense ;)

                                  I cleaned up the Yaml files of MyC and it's better :)

                                  1 Reply Last reply
                                  0
                                  • Adam SlowikA Offline
                                    Adam SlowikA Offline
                                    Adam Slowik
                                    wrote on last edited by
                                    #32

                                    @JeeLet said in CAN bus transport implementation:

                                    what was the problem ???

                                    Previous messages used 7 bytes long payload. Single CAN frame is able to transfer 8 bytes. So all messages was contained in single frame. Example with time, used 17 (!) bytes long payload. In order to transfer 17 bytes there is need to split data to 3 messages (8+8+1). Next in the other side of wire You have to concat it. This mechanism of splitting and concating had a bug. For details check last 3 commits (at the bottom)
                                    https://github.com/mysensors/MySensors/compare/development...AdamSlowik:development

                                    1 Reply Last reply
                                    0
                                    • J Offline
                                      J Offline
                                      JeeLet
                                      wrote on last edited by JeeLet
                                      #33

                                      Gateway Logs on MyController
                                      (CAN Bus and RS485 Bus)

                                      two separate files
                                      CAN log
                                      RS485 log

                                      files split in parts :
                                      A : gateways startup
                                      B : reboot of the gateways
                                      C : launch of MyClock Nodes (id23 and id55)
                                      D ; periodic refresh requestTime(receiveTime)
                                      E ; send value (1700 and 2100)

                                      (I have prepared the work for you to read)

                                      a 1st analysis

                                      • (at the bottom of the listing, the sending of values "1700 or 2100" with MyC)
                                        The RS485 bus dialogues much more, the CAN bus is more timid :)

                                      Adam Slowik bravo

                                      I test what now???
                                      the ACK ??

                                      Oh yes, I have to check the disconnection of the nodes.
                                      The Gateway gives me the impression that the information does not go back to MyC if a Node is off ???

                                      1 Reply Last reply
                                      0
                                      • Adam SlowikA Offline
                                        Adam SlowikA Offline
                                        Adam Slowik
                                        wrote on last edited by
                                        #34

                                        @JeeLet said in CAN bus transport implementation:

                                        I test what now???

                                        I was at similar position some time ago:

                                        @Adam-Slowik said in CAN bus transport implementation:

                                        Any suggestion what to test next?

                                        I have no idea what to test next. I do not use MySensors. I hope this will change in the future, but as of now I'm a newbie.

                                        If You won't get any advice from more experienced users I would suggest to do some long running test to see if it's stable. If it's stable try to use it in some real use cases.

                                        If You find any bugs in transmission layer post logs here. I will do My best to support CAN, because I will need it in a future.

                                        1 Reply Last reply
                                        0
                                        • J Offline
                                          J Offline
                                          JeeLet
                                          wrote on last edited by
                                          #35

                                          " I would suggest doing a long term test to see if it is stable." yes I will stress it to see the weakness

                                          ".. If it is stable, try to use it in real use cases." yes that's the point

                                          One last question

                                          I'm going from 8Mhz to 16Mhz (in development/MyConfig.h on line 306)

                                          question: can you explain how I can bring up in the sketch the parameters that are related to the MCP_CAN_lib library

                                          it should not be complicated for me :) it is only text to insert ???

                                          an example with the #define CAN_CLOCK MCP_8MHZ

                                          Thanks Adam Slowik

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          9

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.0k

                                          Posts


                                          Copyright 2019 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • MySensors
                                          • OpenHardware.io
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular