Announcement

Collapse
No announcement yet.

Issue with CAN Bus

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Issue with CAN Bus

    Hello,

    I have an issue with my program. I receive well the CAN frames if they are send at 1hz frequency. If I send it at 10hz the program freeze

    I don't find where is the problem.
    Attached Files

  • #2
    Hello mavrik,

    I do not have any Can Bus module so I cannot possibly replicate the
    issue that you are experiencing. Did you perhaps misplace this line of code on line 767?

    Code:
      if (Rbuf[0] != 49 || RId != 1157)  {
    I hope this helps.
    Best Regards,
    Kevin
    Last edited by John Kevin; 26th February 2019, 06:06 PM.

    Comment


    • #3
      Hello,

      The line 767 is OK. I think my problem come from when the Buffer is full. How I can verify it ?

      Comment


      • #4
        Hi mavrik,

        I presume that the buffer you are saying is processed by your CANBUS library. You can use the display to print the buffer in a fixed
        position using the command:

        Code:
        Display.gfx_MoveTo(10,10);
        Also, for debugging purposes you use the terminal available on WS4, or the Serial Monitor on Arduino IDE.

        Is it possible that while the display is still syncing, you are continuously receiving the incoming data from CANBUS?
        You can try to unhook the jumper wire on the CLK and let the display sync first (5-8 seconds) to see if it makes a difference.


        Best Regards,
        Kevin

        Comment


        • #5
          Hi,

          I have deleted all the delay() and now I use millis() for manage the time.

          I send the time since the last loop each time on the serial. The time is always between 30 and 40 ms.

          The screen freeze again but not the program because he continue to send me value by serial port but nothing change on on the screen...
          Attached Files

          Comment


          • #6
            Could you place my post in "4Duino Modules (ATMega32U4 + Picaso)" because I use a 4duino display. Thanks

            Comment


          • #7
            Hello mavrik,

            You can try to unhook the jumper wire on the CLK and let the display sync first (5-8 seconds) to see if it makes a difference.
            Have you tried this?


            I send the time since the last loop each time on the serial. The time is always between 30 and 40 ms.

            The screen freeze again but not the program because he continue to send me value by serial port but nothing change on on the screen....
            Can I ask how frequently does the screen freeze? And when it occurs, does the process of receiving data resume after some time?

            Best Regards,
            Kevin

            Comment


            • #8
              Hi John,

              Originally posted by John Kevin View Post
              You can try to unhook the jumper wire on the CLK and let the display sync first (5-8 seconds) to see if it makes a difference.
              Where is this Jumper ?

              Comment


              • John Kevin
                John Kevin commented
                Editing a comment
                I assume that you are using SPI communication, connecting the CLK of your CANBus to the CLK pin of the 4Duino.

            • #9
              I can't disconnect only the CLK pin ...

              Click image for larger version

Name:	2019-03-06 14.04.14.jpg
Views:	38
Size:	1.79 MB
ID:	67345

              Comment


              • #10
                Originally posted by John Kevin View Post
                Can I ask how frequently does the screen freeze? And when it occurs, does the process of receiving data resume after some time?
                When the screen freeze he never come back. I need to restart the screen.
                I think the problem is in my loop CAN_stockV(). The screen freeze when the table is full _CirculeV after 21 message received.



                Comment


                • #11
                  Hello mavrik,

                  I am trying to simulate your program using the 4Duino and a host controller (Arduino). The messages sent will have the same
                  format as the CANBus.

                  I will get back to you as soon as I have simulated your program entirely.

                  Best Regards,
                  Kevin

                  Comment


                  • #12
                    Hello,

                    I solved the problem.

                    The issue come from I use unsigned int _CirculeV[256] . The sizeof(_CirculeV) when you use Int type don't give 256 but 512....

                    I have divided the value of the sizeof in my program and I have solved the issue.


                    while (_NcanV > 2) { // chaque message dans _Circule occupe au moins 3 octets
                    _NcanV--;
                    RIdV = _CirculeV[_indexRV]; // recup Id
                    _indexRV++;
                    if (_indexRV == sizeof(_CirculeV) / 2) {_indexRV = 0;}
                    _NcanV--;
                    RlenV = _CirculeV[_indexRV]; // recup longueur
                    _indexRV++;
                    if (_indexRV == sizeof(_CirculeV) / 2) {_indexRV = 0;}

                    for (int k = 0; k < RlenV; k++) {
                    _NcanV--;
                    RbufV[k] = _CirculeV[_indexRV]; // recup octets message
                    _indexRV++;
                    if (_indexRV == sizeof(_CirculeV) / 2) {_indexRV = 0;}

                    }

                    }

                    Comment


                    • #13
                      Hi mavrik,

                      Thank you for letting us know! I am glad that you have solved your problem.
                      The sample code that you give can be beneficial to others.
                      Thank you for sharing your project with us.

                      Best regards,
                      Kevin

                      Comment

                      Working...
                      X