Comments: AST-CAN485 Hookup Guide

Pages

Looking for answers to technical questions?

We welcome your comments and suggestions below. However, if you are looking for solutions to technical questions please see our Technical Assistance page.

  • Member #1645551 / about a year ago / 1

    ON AST-CAN485, how do I check whether there is a message already received in the buffers/MOBs? The example code's shows how to receive the message, and it waits for a message to come in. In my application I'd like to check whether there is a message, process it if there is one, and perform other tasks if there is none, then loop.

  • stephan schulz / about 6 years ago / 1

    I installed board and libraries as per the guide on macos and windows. But both give me this following error message when trying to compile.

    WARNING: Category 'Communications' in library AST_CAN is not valid. Setting to 'Uncategorized'
    WARNING: Category 'Communications' in library AST_RS485 is not valid. Setting to 'Uncategorized'
    Sketch uses 1072 bytes (0%) of program storage space. Maximum is 130048 bytes.
    Global variables use 9 bytes (0%) of dynamic memory, leaving 4087 bytes for local variables. Maximum is 4096 bytes.
    avrdude: verification error, first mismatch at byte 0x0000
    0x14 != 0x0c
    avrdude: verification error; content mismatch
    avrdude: verification error; content mismatch
    

    What am I doing wrong?

    • Member #1442119 / about 6 years ago / 1

      I was getting these same errors with two of these setup one as CAN transmitter, one as CAN receiver. On the receiver in void setup i entered pinMode(13, OUTPUT); to use the onboard LED to indicate it saw a change in a CAN packet byte. I think the problem was this is SCK, serial clock, pin also. Once I uploaded the program i wouldn't be able to load another program to it until i reburned the bootloader to the board with an Arduino. Arduino IDE would just give me content mismatch and say board is not connected.

      • Member #1001047 / about 4 years ago / 1

        Hi, I know this is an old topic but could you please leave me some information about this procedure?

  • Member #1458150 / about 6 years ago / 1

    How can I use the AST CAN as receiver and transmitter in one. I have to send messages in a CAN Network, but also have to answer.

    • Member #1442119 / about 6 years ago * / 0

      this is kind of a crude way to do it but I put this program on both can485 boards. the only difference is the message ID between the two. Each one is getting a pushbutton input to pin 2 that can turn on output pin 5 on the other board

      #include <ASTCanLib.h>  
      
      #define MESSAGE_ID        250
      #define MESSAGE_PROTOCOL  1
      #define MESSAGE_LENGTH    8 
      #define MESSAGE_RTR       0 
      
       st_cmd_t Msg;
      
       uint8_t Buffer[8] = {};
      
       void setup() {
        canInit(500000);                  // Initialise CAN port. must be before Serial.begin
        Serial.begin(1000000);             // start serial port
        Msg.pt_data = &Buffer[0];      // reference message data to transmit buffer
        pinMode(5, OUTPUT);
        Msg.ctrl.ide = MESSAGE_PROTOCOL;  // Set CAN protocol (0: CAN 2.0A, 1: CAN 2.0B)
        Msg.id.ext   = MESSAGE_ID;        // Set message ID
        Msg.dlc      = MESSAGE_LENGTH;    // Data length: 8 bytes
        Msg.ctrl.rtr = MESSAGE_RTR;       // Set rtr bit
        }
      
      void loop() {
      tx:
        int buttonState = digitalRead(2);
        if (buttonState == HIGH){
      
          Buffer[0] = 10;
        Msg.ctrl.ide = MESSAGE_PROTOCOL;  // Set CAN protocol (0: CAN 2.0A, 1: CAN 2.0B)
        Msg.id.ext   = MESSAGE_ID;        // Set message ID
        Msg.dlc      = MESSAGE_LENGTH;    // Data length: 8 bytes
        Msg.ctrl.rtr = MESSAGE_RTR;       // Set rtr bit
        Msg.cmd = CMD_TX_DATA;      
        while(can_cmd(&Msg) != CAN_CMD_ACCEPTED);
        while(can_get_status(&Msg) == CAN_STATUS_NOT_COMPLETED);
          goto tx;}
          else{Buffer[0] = 30;
                 Msg.ctrl.ide = MESSAGE_PROTOCOL;  // Set CAN protocol (0: CAN 2.0A, 1: CAN 2.0B)
        Msg.id.ext   = MESSAGE_ID;        // Set message ID
        Msg.dlc      = MESSAGE_LENGTH;    // Data length: 8 bytes
        Msg.ctrl.rtr = MESSAGE_RTR;       // Set rtr bit
              Msg.cmd = CMD_TX_DATA;      
        while(can_cmd(&Msg) != CAN_CMD_ACCEPTED);
        while(can_get_status(&Msg) == CAN_STATUS_NOT_COMPLETED);
          }
      
      Msg.cmd = CMD_RX_DATA;
      while(can_cmd(&Msg) != CAN_CMD_ACCEPTED);
      while(can_get_status(&Msg) == CAN_STATUS_NOT_COMPLETED);
      
      if (Buffer[0] == 10){
          digitalWrite(5, HIGH);}
          else if (Buffer[0] == 30) {
          digitalWrite(5, LOW);}
      }
      

  • Member #736640 / about 7 years ago / 1

    the software installation does not work,

    the board manager url does not exist:

    https://raw.githubusercontent.com/Atlantis-Specialist-Technologies/ast-arduino-boards/master/boards-manager-files/package_ast_boards_index.json

  • Member #736640 / about 7 years ago / 1

    the links you provided for schematic and datasheet are "dead": --> https://github.com/Atlantis-Specialist-Technologies-Admin/CAN485/blob/master/Documentation/Datasheet%20AT90CANXX.pdf --> https://github.com/Atlantis-Specialist-Technologies-Admin/CAN485/blob/master/Documentation/CAN485%201.0.0.pdf

    the referring github repo seems to be empty: --> https://github.com/Atlantis-Specialist-Technologies-Admin


If you've found an issue with this tutorial content, please send us your feedback!