Announcement

Collapse
No announcement yet.

Issue with CAN Bus

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

  • mavrik
    started a topic Issue with CAN Bus

    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

  • John Kevin
    replied
    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

    Leave a comment:


  • mavrik
    replied
    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;}

    }

    }

    Leave a comment:


  • John Kevin
    replied
    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

    Leave a comment:


  • mavrik
    replied
    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.



    Leave a comment:


  • mavrik
    replied
    I can't disconnect only the CLK pin ...

    Click image for larger version

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

    Leave a comment:


  • John Kevin
    commented on 's reply
    I assume that you are using SPI communication, connecting the CLK of your CANBus to the CLK pin of the 4Duino.

  • mavrik
    replied
    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 ?

    Leave a comment:


  • John Kevin
    replied
    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

    Leave a comment:


  • James_4DSystems
    commented on 's reply
    No Problem - Done

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

    Leave a comment:


  • mavrik
    replied
    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

    Leave a comment:


  • John Kevin
    replied
    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

    Leave a comment:


  • mavrik
    replied
    Hello,

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

    Leave a comment:


  • John Kevin
    replied
    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.

    Leave a comment:

Working...
X