DUE and sent extended CAN bus frames appearing as standard frames

This software combines with an Arduino DUE with CAN BUS Transceiver to manage a TC 3.3 KW charger for my electric vehicle.
The charger expects to receive a CAN message every second from my BMS with a CAN message ID of 0x1806E5F4 and eight data bits detailing voltage and amperage required. When I send this extended ID message from the DUE it appears on the CAN bus but appears with a standard message ID - that the charger ignores.
I have confirmed that the charger operates correctly when I send the extended CAN bus message using a Microchip CAN bus analyzer using its transmit function.
It would seem to me to be a coding problem so here is my code:

#include "variant.h"
#include <due_can.h>
#include <stdio.h>

word outputvoltage = 0x0646; //0x05A0 is max voltage of 160.6V (offset = 0.1)
word outputcurrent = 0x0078;  //0x0078 set max current to 12 amps (abs max 23A, offset = 0.1)
word volts = 0;
word amps = 0;
boolean chargerStatus = 0;  //0 is charging
unsigned long int DatafromChargerId = 0x18FF50E5;
unsigned long int BMStoChargerId = 0x1806E5F4;

CAN_FRAME ChargerCanFrame;        // BMS sending
CAN_FRAME ChargerStatusCanFrame;  // BMS receiving

void setup() {
  pinMode(62, OUTPUT);
  while (!Can0.begin(250000, 62)) {
    Serial.println("CAN0 initialization (sync) ERROR\n");
  Serial.println("Using Can0 - initialisation completed");
  ChargerCanFrame.id = BMStoChargerId;    //0x1806E5F4;
  ChargerCanFrame.length = 8;
  ChargerCanFrame.data.bytes[0] = highByte(outputvoltage);
  ChargerCanFrame.data.bytes[1] = lowByte(outputvoltage);
  ChargerCanFrame.data.bytes[2] = highByte(outputcurrent);
  ChargerCanFrame.data.bytes[3] = lowByte(outputcurrent);
  ChargerCanFrame.data.bytes[4] = 0x00;         //0 means ok to charge
  ChargerCanFrame.data.bytes[5] = 0x00;
  ChargerCanFrame.data.bytes[6] = 0x00;
  ChargerCanFrame.data.bytes[7] = 0x00;

  Can0.setRXFilter(1, 0x18FF50E5, 0x7FFFFFFF, true);
  Can0.attachCANInterrupt(1, extractData); 
void loop() {
void extractData(CAN_FRAME *frame) {

  volts = word(frame->data.bytes[0], frame->data.bytes[1]);               // frame->data.bytes[0] is highByte. RPM works for display on 4d Systems screen - same scaling 1
  amps = word(frame->data.bytes[2], frame->data.bytes[3]);
  chargerStatus = frame->data.bytes[4];

Any help gratefully received.

Since you have selected extended frames, shouldn't ChargerCanFrame.extended and ChargerStatusCanFrame.extended be initilazed with 1 in setup() ?

Thank you for your help. I have just checked the documentation I have and it seems I have misunderstood how the extended frame works. I have made the change and the compiler is still happy so I will try again and report back.

Problem solved. Thanks again.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.