dikidera
Full Member
![*](http://nefariousmotorsports.com/forum/Themes/nefmoto/images/star.gif) ![*](http://nefariousmotorsports.com/forum/Themes/nefmoto/images/star.gif)
Karma: +8/-8
Offline
Posts: 139
|
![](http://nefariousmotorsports.com/forum/Themes/nefmoto/images/post/xx.gif) |
« on: January 01, 2024, 08:55:19 AM »
|
|
|
I wanted to ask when logging an engine what is the minimum latency per sample that is required for good enough data? Additionally what about time coherence of data?
In my ECU when I log via the CAN protocol, after about 9or 10 params I am getting error frames from my ECU for network congestion and a pause between 30 and 100ms between the data especially with 15 parameters, I cannot be sure that the AFR for instance really corresponds for the RPM if for instance I received the RPM data 50 or 100ms ago depending on when the pause occurred. I usually try to dump stale frames, but this still gives me sometimes sample granularity of 100ms.
|
|
« Last Edit: January 01, 2024, 08:57:12 AM by dikidera »
|
Logged
|
|
|
|
jcsbanks
Full Member
![*](http://nefariousmotorsports.com/forum/Themes/nefmoto/images/star.gif) ![*](http://nefariousmotorsports.com/forum/Themes/nefmoto/images/star.gif)
Karma: +19/-3
Offline
Posts: 140
|
![](http://nefariousmotorsports.com/forum/Themes/nefmoto/images/post/xx.gif) |
« Reply #1 on: January 01, 2024, 11:47:00 AM »
|
|
|
Might be helpful to state the ECU, hardware and software used. For example I can get 15 items over CAN every millisecond with no CAN errors.
|
|
|
Logged
|
|
|
|
dikidera
Full Member
![*](http://nefariousmotorsports.com/forum/Themes/nefmoto/images/star.gif) ![*](http://nefariousmotorsports.com/forum/Themes/nefmoto/images/star.gif)
Karma: +8/-8
Offline
Posts: 139
|
![](http://nefariousmotorsports.com/forum/Themes/nefmoto/images/post/xx.gif) |
« Reply #2 on: January 02, 2024, 05:25:27 AM »
|
|
|
I definitely cannot get 15 items per ms.
The ECU is Denso LE.2 hardware is an RPI with custom software, using the VOLCANO protocol for Volvo. I am using a specific functionality called Dynamic Records whereby I request the parameters I want by their specific diagnostic ID along with how fast it should send the data, which plugs all the values I want into a frame several CAN messages long. Basically the ECU determines how and when to send the data and I just listen passively. But after a specific number of parameters, the ECU returns error frames indicating that the CAN bus is busy/overloaded. Which increases my latency to 30-100ms.
So yes, looking at the many logs I have, the avg sample rate is 100ms. So i get 10 samples per second.
|
|
« Last Edit: January 02, 2024, 05:34:07 AM by dikidera »
|
Logged
|
|
|
|
prj
|
![](http://nefariousmotorsports.com/forum/Themes/nefmoto/images/post/xx.gif) |
« Reply #3 on: January 02, 2024, 06:54:28 AM »
|
|
|
Use polling instead of scheduling, so you smoothly roll off the sample rate.
The issue is not the CAN being overloaded but most likely the ECU scheduler.
Maybe Denso is different but no such issues on ME7 or ME9 when defining then polling.
|
|
|
Logged
|
|
|
|
dikidera
Full Member
![*](http://nefariousmotorsports.com/forum/Themes/nefmoto/images/star.gif) ![*](http://nefariousmotorsports.com/forum/Themes/nefmoto/images/star.gif)
Karma: +8/-8
Offline
Posts: 139
|
![](http://nefariousmotorsports.com/forum/Themes/nefmoto/images/post/xx.gif) |
« Reply #4 on: January 13, 2024, 05:24:34 AM »
|
|
|
Either there is a problem with my CAN shield maybe triggering some state or the ECU simply cannot deliver the data this fast.
I tried polling but a single param was returned in 15ms and no sooner. And unless I wait for each reply to succeed, sending a request for a different param will block returning of the other parameter for quite a few seconds.
I wonder if it is simply a limitation of the ECU or socketcan or something along those lines. So 10 samples per second is about the best I can achieve currently.
|
|
« Last Edit: January 13, 2024, 05:28:43 AM by dikidera »
|
Logged
|
|
|
|
prj
|
![](http://nefariousmotorsports.com/forum/Themes/nefmoto/images/post/xx.gif) |
« Reply #5 on: January 13, 2024, 05:41:49 AM »
|
|
|
You seem to be doing this wrong... Use 0xAA to define the record dynamically with as many variables as you like. Then use 0xA6 in a loop to read the dynamic record. 15ms will give you 66hz speed, more than enough!
Look at VolvoLogger source code, it's all there in the open how to log.
|
|
|
Logged
|
|
|
|
dikidera
Full Member
![*](http://nefariousmotorsports.com/forum/Themes/nefmoto/images/star.gif) ![*](http://nefariousmotorsports.com/forum/Themes/nefmoto/images/star.gif)
Karma: +8/-8
Offline
Posts: 139
|
![](http://nefariousmotorsports.com/forum/Themes/nefmoto/images/post/xx.gif) |
« Reply #6 on: January 14, 2024, 09:12:59 AM »
|
|
|
Amazing and this change didnt need much refactoring if at all. Just some changes to the frame format. With this I not only got much more stable frame times but no error frames and sub 100ms logging.
|
|
|
Logged
|
|
|
|
prj
|
![](http://nefariousmotorsports.com/forum/Themes/nefmoto/images/post/xx.gif) |
« Reply #7 on: January 15, 2024, 01:06:24 AM »
|
|
|
You can add a closed loop P controller to set an exact sample rate regardless of variable count. I do that for my rate limiter.
Have a target sample rate, e.g. 20hz, that means 50ms between samples. Then every time you receive a sample check how much time has elapsed from last sample. Subtract that from 50ms and introduce a delay.
|
|
|
Logged
|
|
|
|
|