CAN Timing

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

CAN Timing

Jump to solution
4,610 Views
fernando_barrio
Contributor III

Hi,

Is there anyway to determine the time since the last CAN message was received?

Thank you,

Fernando

1 Solution
4,406 Views
constantinrazva
NXP Employee
NXP Employee

Hello fernando.barrios@uwaterloo.ca‌,

I get where are you coming from now - for this I would suggest you use the Get bus tick block - you can find it in the Utility Blocks section. I would suggest you do like this:

  • in the CAN callback (the triggered subsystem) you get the current bus tick number (further named CAN_time)
  • in a loop (the one you decide will be responsible for watching for failure of the other system) you can get the current bus tick number (check_time); here all you have to do is convert the bus tick number to us/ms and check if the number is higher than what you want/need. By doing this, every time you get a new message, the CAN_time will update, and so when you get the difference (check_time - CAN_time), this should never be greater than a value that you decide implies the other system's failure (failure_time).

Let us know if you find this approach satisfying.

Kind regards,

Razvan.

View solution in original post

7 Replies
4,406 Views
fernando_barrio
Contributor III

That is exactly what I need, thank you for the help!

Fernando

0 Kudos
4,406 Views
gramirezv
Contributor III

Hola Fernando,

I haven't tested this yet, but from what I can see the FCAN_Isr block has the Timestamp output, this should give you the timestamp for each CAN message received depending on the Event you have selected. I assume you are using the "Rx Complete" event. If that's the case, you should be able to read each timestamp and compare with the previous message and determine if it arrived within the time you expected.

4,406 Views
constantinrazva
NXP Employee
NXP Employee

Hello fernando.barrios@uwaterloo.ca‌,

As always gramirezv‌ is right! Sorry for the delayed message. You can compare the timestamp with the previous message timestamp and get the difference. Thanks again Gustavo for the quick reply!

Kind regards,

Razvan.

4,410 Views
fernando_barrio
Contributor III

Hi constantinrazvan.chivu‌ and gramirezv‌,

I appreciate the suggestions, however I would like to determine if a system has failed by raising a flag if no message has arrived from that system after a certain amount of time. I could just compare it to the most recent CAN message received in general (from another system on the bus), but its not that accurate. Do you have any suggestions?

Thanks,

Fernando

0 Kudos
4,407 Views
constantinrazva
NXP Employee
NXP Employee

Hello fernando.barrios@uwaterloo.ca‌,

I get where are you coming from now - for this I would suggest you use the Get bus tick block - you can find it in the Utility Blocks section. I would suggest you do like this:

  • in the CAN callback (the triggered subsystem) you get the current bus tick number (further named CAN_time)
  • in a loop (the one you decide will be responsible for watching for failure of the other system) you can get the current bus tick number (check_time); here all you have to do is convert the bus tick number to us/ms and check if the number is higher than what you want/need. By doing this, every time you get a new message, the CAN_time will update, and so when you get the difference (check_time - CAN_time), this should never be greater than a value that you decide implies the other system's failure (failure_time).

Let us know if you find this approach satisfying.

Kind regards,

Razvan.

4,370 Views
ykarata1
Contributor IV

Dear All,

I need to detect whether I am getting heartbeat of other components that is connected through CAN communication. If not, I should give error after a timeout.

So while I am searching for a solution I have run into that thread. And I just wanted to implement recommended solution by @constantinrazva .

 

My block is here as it seems. I have put one Get_Bus_Tick in RX_Complete and One in Subsystem and substracted them to find timedifference. I am taking TIMEOUT as zero everytime.

 

I have also attached that part of my model lke and excel file in attachment. You should convert attached file to .slx from xlsx.

How can I solve that?

 

Thanks.

 

im_1.png

Also, I have tried another model to try your advised solution. It did not work out. What I am missing?

 

Thanks.

 

0 Kudos
4,408 Views
constantinrazva
NXP Employee
NXP Employee

fernando.barrios@uwaterloo.ca - I'd like to add a suggestion I would make if you're going with this method - you should not waste time computing the values back to us/ms at every check loop; you could just convert beforehand the failure_time to bus ticks, and save it as such in the model.

Kind regards,

Razvan.