I didn't think I was spoiling the precision.. Instead of "1 latency == 1us" now "1 latency == 0.25us" ... So there is more precision?
I admit the naming in the patch/code is not great, I didn't know what to call it.
Vida CEM swapping
-
vtl
- Posts: 4934
- Joined: 16 Aug 2012, 13:35
- Year and Model: 2005 XC70
- Location: Boston
- Has thanked: 130 times
- Been thanked: 686 times
In your patch - yes. In my patch I just collect the total CPU cycles, so the precision is even greater than in your patch. This is what makes me a bit nervous: cracks with precision improved only slightly, does not with a full possible precision.sirloins wrote: 17 Feb 2022, 10:36 I didn't think I was spoiling the precision.. Instead of "1 latency == 1us" now "1 latency == 0.25us" ... So there is more precision?
May I ask you to collect the 720 logs w/ your patch and my patch, with DUMP_BUCKETS defined?
Cheapest 8690720 is $150 on ebay
-
sirloins
- Posts: 43
- Joined: 05 Nov 2020, 18:54
- Year and Model: 2010 V50 T5 AWD M66
- Location: Ottawa, Canada
- Been thanked: 3 times
Okay, sorry, yes I see what you are saying.
I am assuming the weighted product being used makes the difference, but let me get the logs and we can see for ourselves what is going on exactly.
I am assuming the weighted product being used makes the difference, but let me get the logs and we can see for ourselves what is going on exactly.
-
vtl
- Posts: 4934
- Joined: 16 Aug 2012, 13:35
- Year and Model: 2005 XC70
- Location: Boston
- Has thanked: 130 times
- Been thanked: 686 times
Thinking about precision.
MCU runs at 8 MHz, each clock cycle is 0.125 us. It looks like egress CAN frame starts at arbitrary time, aligned to MCU clock rate, not CAN clock rate. In this case the other side (Teensy) will see a clock-accurate latency.
Of course, every signal has some noise. By switching the histogram resolution from 1 us to 0.25 us you make it functioning like a primitive filter that recovers a real clock cycles. In that case, using 0.125 us buckets would make it even better?
MCU runs at 8 MHz, each clock cycle is 0.125 us. It looks like egress CAN frame starts at arbitrary time, aligned to MCU clock rate, not CAN clock rate. In this case the other side (Teensy) will see a clock-accurate latency.
Of course, every signal has some noise. By switching the histogram resolution from 1 us to 0.25 us you make it functioning like a primitive filter that recovers a real clock cycles. In that case, using 0.125 us buckets would make it even better?
-
sirloins
- Posts: 43
- Joined: 05 Nov 2020, 18:54
- Year and Model: 2010 V50 T5 AWD M66
- Location: Ottawa, Canada
- Been thanked: 3 times
Attached are two logs from the first round of the first byte and part of the second round.
The correct byte is 13 for the first position.
I can run them longer or to completion as well, let me know if you think that would be useful.
The correct byte is 13 for the first position.
I can run them longer or to completion as well, let me know if you think that would be useful.
- Attachments
-
P1-720-sirloin_patch.txt- (137.8 KiB) Downloaded 87 times
-
P1-720-vtl_patch.txt- (51.94 KiB) Downloaded 104 times
- RickHaleParker
- Posts: 7203
- Joined: 25 May 2015, 14:30
- Year and Model: See Signature below.
- Location: Kansas
- Has thanked: 8 times
- Been thanked: 979 times
Spoils the precision or the accuracy?vtl wrote: 17 Feb 2022, 10:31 Didn't work... Interesting. And yet rounding the result up to a quarter of microsecond, or, in other words spoiling the precision in a terrible way, makes it work?
Accuracy is how close the measured value is to the true value.
Precision is the smallest unit of measurement. ( how many decimal places ).
Active
1998 C70, B5234T3, 16T, AW50-42, Bosch Motronic 4.4, Special Edition package.
2017 Ford PIU. 3.5l, Twin Turbo, 365 Hp.
............................
Past
2003 S40, B4204T3, 14T twin scroll AW55-50/51SN, Siemens EMS 2000. ( Killed by a plastic radiator. )
2004 S60R, B8444S TF80 AWD. Yamaha V8 conversion ( I moved, the project did not )
2005 XC90 T6 Executive, B6294T, 4T65 AWD, Bosch Motronic 7.0. ( Transmission dead after sitting for a winter )
1998 C70, B5234T3, 16T, AW50-42, Bosch Motronic 4.4, Special Edition package.
2017 Ford PIU. 3.5l, Twin Turbo, 365 Hp.
............................
Past
2003 S40, B4204T3, 14T twin scroll AW55-50/51SN, Siemens EMS 2000. ( Killed by a plastic radiator. )
2004 S60R, B8444S TF80 AWD. Yamaha V8 conversion ( I moved, the project did not )
2005 XC90 T6 Executive, B6294T, 4T65 AWD, Bosch Motronic 7.0. ( Transmission dead after sitting for a winter )
-
sirloins
- Posts: 43
- Joined: 05 Nov 2020, 18:54
- Year and Model: 2010 V50 T5 AWD M66
- Location: Ottawa, Canada
- Been thanked: 3 times
Good points, let me try with 0.125us and the dump_buckets set. I will update the logs.vtl wrote: 17 Feb 2022, 11:02 Thinking about precision.
MCU runs at 8 MHz, each clock cycle is 0.125 us. It looks like egress CAN frame starts at arbitrary time, aligned to MCU clock rate, not CAN clock rate. In this case the other side (Teensy) will see a clock-accurate latency.
Of course, every signal has some noise. By switching the histogram resolution from 1 us to 0.25 us you make it functioning like a primitive filter that recovers a real clock cycles. In that case, using 0.125 us buckets would make it even better?
-
sirloins
- Posts: 43
- Joined: 05 Nov 2020, 18:54
- Year and Model: 2010 V50 T5 AWD M66
- Location: Ottawa, Canada
- Been thanked: 3 times
Ok, first of all, thanks for questioning why my change works... turns out I don't even know why it works lol. Lets get to the bottom of it.
When attempting to do the 0.125us change (ie set my LATENCY_RESOLUTION to 8 ) I found a bug in the change I submitted.
Specifically here (my change):
Recall this function returns clockCyclesPerMicrosecond / LATENCY_RESOLUTION... So by setting the LATENCY_RESOLUTION to 4 I was limiting the maximum time that we would wait for a sample.
Instead of the timeout being 2ms, it was now 0.5ms.
I should have left this alone since it is just a timeout.
So I fixed this, and set it back to:
Interesting, now everything doesn't work again, even with the histogram in 0.25us.
So I tried your patch again vtl, this time with the following:
It works now. *edit: I also checked with this single change from the master branch and it also works
So this means the only thing making this work was limiting the timeout (limit) in the cem_unlock function. Now, obviously, we don't need the change I submitted, and I can log a bit more so we can create a more effective algorithm.
When attempting to do the 0.125us change (ie set my LATENCY_RESOLUTION to 8 ) I found a bug in the change I submitted.
Specifically here (my change):
Code: Select all
/* maximum time to collect our samples */
limit = TSC + 2 * 1000 * clockCyclesPerLatencyUnit();Instead of the timeout being 2ms, it was now 0.5ms.
I should have left this alone since it is just a timeout.
So I fixed this, and set it back to:
Code: Select all
/* maximum time to collect our samples */
limit = TSC + 2 * 1000 * clockCyclesPerMicrosecond();
So I tried your patch again vtl, this time with the following:
Code: Select all
/* maximum time to collect our samples */
limit = TSC + 2 * 1000 * clockCyclesPerMicrosecond()/4;
So this means the only thing making this work was limiting the timeout (limit) in the cem_unlock function. Now, obviously, we don't need the change I submitted, and I can log a bit more so we can create a more effective algorithm.
-
sirloins
- Posts: 43
- Joined: 05 Nov 2020, 18:54
- Year and Model: 2010 V50 T5 AWD M66
- Location: Ottawa, Canada
- Been thanked: 3 times
Attached are four log files.
p1_master_div4.txt - Master branch with: limit = TSC + 2 * 1000 * clockCyclesPerMicrosecond()/4;
p1_master_div4_full.txt - full log to completion of the above file.
p1_31254749_div4_full.txt - full log on my 31254749 (in car)
p2_master_nodiv.txt - Master branch, no changes.
p1_master_div4.txt - Master branch with: limit = TSC + 2 * 1000 * clockCyclesPerMicrosecond()/4;
p1_master_div4_full.txt - full log to completion of the above file.
p1_31254749_div4_full.txt - full log on my 31254749 (in car)
p2_master_nodiv.txt - Master branch, no changes.
- Attachments
-
p1_master_div4.txt- (69.63 KiB) Downloaded 114 times
-
p1_master_nodiv.txt- (42.78 KiB) Downloaded 90 times
-
p1_master_div4_full.txt- (398.33 KiB) Downloaded 97 times
-
P1_31254749_div4_full.txt- (122.01 KiB) Downloaded 86 times
-
- Similar Topics
- Replies
- Views
- Last post
-
- 1 Replies
- 9049 Views
-
Last post by RickHaleParker
-
- 6 Replies
- 8886 Views
-
Last post by abscate
-
- 27 Replies
- 27803 Views
-
Last post by cn90
-
- 10 Replies
- 10329 Views
-
Last post by jonesg
-
- 7 Replies
- 5504 Views
-
Last post by RickHaleParker






