FlexCAN_T4 - FlexCAN for Teensy 4

I 've posted my CAN board on Tindie for anyone interested.

2021-04-18T20%3A39%3A23.000Z-3%401500x-100.jpg


https://www.tindie.com/products/fusion/dual-can-bus-adapter-for-teensy-40-41/
 
Hi,
please, tell me, what am I doing wrong?
when the temperature of the external device rises, the power supply R4850 must reduce the output voltage,
the code works, but when switching the voltage there is a delay of 60-70 seconds, this is a lot!
how to remove this delay? I will be very grateful for your help!
Code:
#include <FlexCAN_T4.h>

FlexCAN_T4<CAN1, RX_SIZE_256, TX_SIZE_16> can1;
CAN_message_t msg;

uint8_t Temperature = 0;
uint8_t temp = 0;

void setup()
{
  can1.begin();
  can1.setBaudRate(125000);
}

void loop()
{
  if (Temperature > 50 && temp == 0)
  {
    msg.mb = 1;
    msg.id = 0x108180fe;
    msg.len = 8;
    msg.buf[0] = 0x01;
    msg.buf[1] = 0x01;
    msg.buf[2] = 0x00;
    msg.buf[3] = 0x00;
    msg.buf[4] = 0x00;
    msg.buf[5] = 0x00;
    msg.buf[6] = 0xa6; // Voltage 41.5
    msg.buf[7] = 0x00;
    can1.write(msg);
    temp = 1;
  } else if (Temperature < 45 && temp == 1)
  {
    msg.mb = 1;
    msg.id = 0x108180fe;
    msg.len = 8;
    msg.buf[0] = 0x01;
    msg.buf[1] = 0x01;
    msg.buf[2] = 0x00;
    msg.buf[3] = 0x00;
    msg.buf[4] = 0x00;
    msg.buf[5] = 0x00;
    msg.buf[6] = 0xd6; // Voltage 53.5
    msg.buf[7] = 0x00;
    can1.write(msg);
    temp = 0;
  }
}
 
it looks like you are flooding the bus with writes, are you sure the device can process the data that fast? usually on cars we need to space the transmissions to a device at like 10ms, but your loop is constantly flooding the bus so.....

that is an extended ID, you should be using:
Code:
msg.flags.extended = 1;

Maybe its just the extended flag, I relooked your code and see it's doing only a single transmission on a heat change, but because you are not using the flag, the CANID is truncated to 11bit instead of being 29bit..
 
it looks like you are flooding the bus with writes, are you sure the device can process the data that fast? usually on cars we need to space the transmissions to a device at like 10ms, but your loop is constantly flooding the bus so.....

that is an extended ID, you should be using:
Code:
msg.flags.extended = 1;

Maybe its just the extended flag, I relooked your code and see it's doing only a single transmission on a heat change, but because you are not using the flag, the CANID is truncated to 11bit instead of being 29bit..
I am very grateful to you for your answer!
but, I am very bad at programming (((
can't figure out what i need to do?
 
Code:
msg.flags.extended = 1;

this must be set BEFORE writing, or else your extended ID will truncate to a standard ID and it will not be the one you wanted for your device

also try adding in setup:
Code:
can1.setClock(CLK_60MHz);

the default 24MHz clock didnt work on my civic's BCAN bus at 125000, but 60MHz worked
 
please tell me where to install this code ?
Code:
msg.flags.extended = 1;
I use Teensy 3.2, this code throws an error
Code:
can1.setClock(CLK_60MHz);
 
ahh okay sorry Teensy 3.x doesn't use setClock, 4.x only.

you need to put that msg.flags.extended with your message you wanna send. put it under your msg.id = 0x108180fe;
 
ahh okay sorry Teensy 3.x doesn't use setClock, 4.x only.
you need to put that msg.flags.extended with your message you wanna send. put it under your msg.id = 0x108180fe;
unfortunately there are no changes, the delay remains the same 60 seconds (((
 
tonton81, can I somehow disable data reception?
I only need to transfer data,
maybe then the transmission speed will increase?

i made simple code, but the effect is the same, the delay when switching is 65 seconds :(
Code:
#include <IFCT.h>

CAN_message_t msg;

void setup() {
  Can0.setBaudRate(125000);
  Can0.enableFIFO();

  msg.ext = 1;
  msg.id = 0x108180fe;
  msg.len = 8;
  msg.buf[0] = 0x01;
  msg.buf[1] = 0x01;
  msg.buf[2] = 0x00;
  msg.buf[3] = 0x00;
  msg.buf[4] = 0x00;
  msg.buf[5] = 0x00;
  msg.buf[6] = 0xd6; //Voltage
  msg.buf[7] = 0x00;

  Can0.write(msg);
}

void loop() {
}
 
if you dont read them they will stay full. reception and transmission have different mailboxes and dont depend on each other. You should try printing mailboxStatus() every couple seconds then, if it shows all TX mailboxes full, it means you have physical connection issues (transceiver not enabled via gpio? CAN termination resistance?)
 
if you dont read them they will stay full. reception and transmission have different mailboxes and dont depend on each other. You should try printing mailboxStatus() every couple seconds then, if it shows all TX mailboxes full, it means you have physical connection issues (transceiver not enabled via gpio? CAN termination resistance?)
unfortunately I don't understand a lot, I have no experience with these devices,
I use this wiring diagram ..
schematic.png
 
MCP2551 is a 5V transceiver, you need to make sure the communication is done at 3.3V or you risk damaging the pin on teensy. Or look for a 3.3V transceiver
 
MCP2551 is a 5V transceiver, you need to make sure the communication is done at 3.3V or you risk damaging the pin on teensy. Or look for a 3.3V transceiver
2.0-2.5 volts, these levels correspond to Teensy,
I think it is possible that additional commands are needed for the block R4850...
 
No thats the way it sends, something wrong in your setup. if IFCT and FlexCAN_T4 both don't work it'd definately not the code :)
 
No thats the way it sends, something wrong in your setup. if IFCT and FlexCAN_T4 both don't work it'd definately not the code :)
I've been fighting this for two weeks now, I broke my whole head,
I can't imagine which way to dig ...

I tried to connect through such a module, there is a delay ..
2021-04-21_223003.png
there is clearly something wrong with the commands ...
 
have you checked with a can bus analyzer to see if data is going out? or try another can-equipped bus just to see if you can read the bus (using FIFO example). If you can't read the bus don't expect transmissions to work, if you can read the bus, best to check if your frame layout is correct for the device your talking to
 
have you checked with a can bus analyzer to see if data is going out? or try another can-equipped bus just to see if you can read the bus (using FIFO example). If you can't read the bus don't expect transmissions to work, if you can read the bus, best to check if your frame layout is correct for the device your talking to
tonton81, I am very grateful to you for participating in my problem!
this is the data I accept using IFCTsimpleFIFOPolling.ino
2021-04-22_071311.png
and wto such with the help IFCTsniffer.ino
2021-04-22_071158.jpg
but I don't understand what they mean :(
 
thats a different id and doesnt correlate to your sends, is the device sending you that? what is the device?
 
well you need the manual for it then, i tried googling and came up with this:
https://github.com/craigpeacock/Huawei_R4850G2_CAN/blob/main/Protocol.xlsx

the IDs dont match what your sending or receiving, but since your receiving something it means your sending the wrong/right data to the wrong canid thats why it's not responding
yes, this is the document I use,
but it turns out that nothing works, I am sure that I am doing something wrong,
but I can't understand what am I doing wrong? if the error is in the team, how should it be correct?

maybe I'm not forming the team correctly ?
 
wow .... found a bug !!!

I had it like that:
msg.buf[0] = 0x01;
msg.buf[1] = 0x01;

did so:
msg.buf[0] = 0x01;
msg.buf[1] = 0x00;

now the voltage switches very quickly,
but another problem appeared, this voltage changes for 1 minute,
then reverts to the previous value!
now you need to figure out how to remember it ?

it looks like now I need to send two commands in a row,
switch and remember, do I understand correctly ?
 
did you read last line of the xlsx? :)




The rectifier can operate in two states:
Off-line is when there is no CAN communication (i.e. standalone operation). This occurs on power-up or if CAN communication has timed-out (Orange LED slowly blinking).
On-line values are only valid when CAN communication is present (Orange LED not blinking). These values are volatile and reset to default on loss of CAN comms.
CAN communication time-out is approximately 60 seconds. i.e. if you stop sending valid CAN messages to the rectifier, the rectifier will switch to Off-line/Default values in approximately 60 seconds.






You basically need to keep transmitting whatever within 60 seconds for it to remain active, if you stop transmitting for 60 seconds thats it. so send every 30 seconds if you want
 
Back
Top