Page 1 of 1
Time deviation use PCAN-Basic create trace files
Posted: Thu 28. Jan 2021, 04:01
by Embers
Hello everyone,
I have a puzzle that I used the PCAN-Basic API to create the message trace files, and I send one message in threads about 300ms for each time, there are two cycle to send the message , and first send it by 30min continuously ,then changed the message to another status and send it by 20min continuously, so the total cycle is 50min in program, but when I calculate the total cycle time in the trace file is 51min ,so there is about 1min time deviation between set the sending cycle time with calculate in the trace files (besides there are other threads to send and receive other messages), Why is there a time deviation ?
Any help would be appreciated !!
Best regards,
Embers
Re: Time deviation use PCAN-Basic create trace files
Posted: Thu 28. Jan 2021, 12:48
by M.Heidemann
Hello,
Thank you for your request.
Can you provide us with the mentioned trace file, so we can further assess the issue?
Also, how do you determine the individual phases (30 min, 20 min) in your code?
PLease report back to us regarding this.
Best Regards
Marvin
Re: Time deviation use PCAN-Basic create trace files
Posted: Fri 29. Jan 2021, 03:35
by Embers
Hello Marvin,
Sorry, the 50min trace files is too large, so I provide another trace file to you , this trace file record all the message that i send ,and the cycle is 97min,I send the message 0x18FF1019 00 00 00 00 00 00 00 00 expression status "OFF", 0x18FF1019 00 01 00 00 00 00 00 00 expression status "ON", In my code , I start cycle send it by "ON" ,so the start Time Offset is 40044.7ms ,then when the timer reaches 97min, the status changed to "OFF" and end of cycle in 5915770.8ms, calculate the cycle time is 5915770.8ms minus 40044.7ms equals to 5,875.73ms(97.92min) ,so there is 0.92min deviation ,code and trace file as below:
code:
Code: Select all
/*start timer*/
private void btnStartEndurance_Click(object sender, EventArgs e)
{
TimerCnt = 0;
lblHeaterStatus.Text = "ON";
tmrEndurance.Interval = 1000; /*set timer Interval to 1000ms*/
tmrEndurance.Start();
}
/*Timer tick*/
private void tmrEndurance_Tick(object sender, EventArgs e)
{
if (TimerCnt >= 5820) /*97min timer*/
{
IdleModeState = 1;
TimerCnt = 0;
lblHeaterStatus.Text = "OFF";
tmrEndurance.Stop()
}
else
{
TimerCnt++;
tmrEndurance.Start();
}
}
Trace file:
Code: Select all
;$FILEVERSION=1.1
;$STARTTIME=44210.2628356482
;
;
; Start time: 14/01/2021 06:18:29.000.0
; PCAN-Channel: PCAN_USBBUS1
; Driver version: PCAN_USB 4.2.1.16433 - (KMDF 1.9, x64, Desktop)
; Generated by PCAN-Basic API, version 4.4.0.288
;
; Message Number
; | Time Offset (ms)
; | | Type
; | | | ID (hex)
; | | | | Data Length Code
; | | | | | Data Bytes (hex) ...
; | | | | | |
;---+-- ----+---- --+-- ----+--- + -+ -- -- -- -- -- -- --
1) 0.0 Warng FFFFFFFF 4 00 00 00 08 BUSHEAVY
2) 27.5 Tx 18FF1019 8 00 00 00 00 00 00 00 00
3) 27.5 Tx 18FF1019 8 00 00 00 00 00 00 00 00
4) 45.0 Rx 18FF803A 8 FE 3A 3F FF FF FF FF FF
5) 54.9 Rx 18FF003A 8 FF FF FF FF FF FF FF FF
6) 145.0 Rx 18FF803A 8 FD 3A 3F FF FF FF FF FF
7) 405.0 Rx 18FF803A 8 FE 3A 3F FF FF FF FF FF
8) 421.8 Tx 18FF1019 8 00 00 00 00 00 00 00 00
9) 421.8 Tx 18FF1019 8 00 00 00 00 00 00 00 00
.......
967) 39617.8 Tx 18FF1019 8 00 00 00 00 00 00 00 00
968) 39617.8 Tx 18FF1019 8 00 00 00 00 00 00 00 00
969) 39673.9 Tx 18DA3AF1 8 03 19 02 09 00 00 00 00
970) 39673.9 Tx 18DA3AF1 8 03 19 02 09 00 00 00 00
971) 39678.2 Rx 18DAF13A 8 10 0B 59 02 09 FE 06 4E
972) 39679.8 Tx 18DA3AF1 8 30 0A 0A 00 00 00 00 00
973) 39679.8 Tx 18DA3AF1 8 30 0A 0A 00 00 00 00 00
974) 39707.9 Rx 18DAF13A 8 21 18 FE 1C 26 01 FF FF
975) 39814.9 Tx 18DA3AF1 8 03 22 1D 01 00 00 00 00
976) 39814.9 Tx 18DA3AF1 8 03 22 1D 01 00 00 00 00
977) 39818.0 Rx 18DAF13A 8 07 62 1D 01 41 F7 52 EA
978) 39921.9 Tx 18DA3AF1 8 03 22 1D 05 00 00 00 00
979) 39921.9 Tx 18DA3AF1 8 03 22 1D 05 00 00 00 00
980) 39927.9 Rx 18DAF13A 8 07 62 1D 05 00 00 00 03
981) 40031.9 Tx 18DA3AF1 8 03 22 1D 06 00 00 00 00
982) 40031.9 Tx 18DA3AF1 8 03 22 1D 06 00 00 00 00
983) 40037.9 Rx 18DAF13A 8 07 62 1D 06 42 9A 00 00
984) 40044.7 Tx 18FF1019 8 00 01 00 00 00 00 00 00 ---------> ON
985) 40044.7 Tx 18FF1019 8 00 01 00 00 00 00 00 00
986) 40078.3 Rx 10FECA3A 8 00 FF FE 1C 26 7F FF FF
987) 40097.9 Rx 18FF003A 8 34 10 FF FF FF FF FF FF
988) 40151.9 Tx 18DA3AF1 8 03 22 1D 07 00 00 00 00
989) 40151.9 Tx 18DA3AF1 8 03 22 1D 07 00 00 00 00
990) 40157.9 Rx 18DAF13A 8 07 62 1D 07 42 86 00 00
991) 40264.9 Tx 18DA3AF1 8 03 22 1D 0F 00 00 00 00
992) 40264.9 Tx 18DA3AF1 8 03 22 1D 0F 00 00 00 00
993) 40267.9 Rx 18DAF13A 8 07 62 1D 0F 00 00 00 B0
994) 40374.9 Tx 18DA3AF1 8 03 22 1D 10 00 00 00 00
995) 40374.9 Tx 18DA3AF1 8 03 22 1D 10 00 00 00 00
996) 40378.2 Rx 18DAF13A 8 07 62 1D 10 00 00 00 31
997) 40470.3 Tx 18FF1019 8 00 01 00 00 00 00 00 00
998) 40470.3 Tx 18FF1019 8 00 01 00 00 00 00 00 00
999) 40484.2 Tx 18DA3AF1 8 03 22 1D 11 00 00 00 00
1000) 40484.2 Tx 18DA3AF1 8 03 22 1D 11 00 00 00 00
.
.
.
.
.
214952) 5915348.6 Tx 18FF1019 8 00 01 00 00 00 00 00 00
214953) 5915348.6 Tx 18FF1019 8 00 01 00 00 00 00 00 00
214954) 5915454.4 Tx 18DA3AF1 8 03 22 1D 05 00 00 00 00
214955) 5915454.4 Tx 18DA3AF1 8 03 22 1D 05 00 00 00 00
214956) 5915462.8 Rx 18DAF13A 8 07 62 1D 05 00 00 00 10
214957) 5915503.3 Rx 10FECA3A 8 00 FF FE 1C 26 7F FF FF
214958) 5915522.8 Rx 18FF003A 8 78 55 FF FF FF FF FF FF
214959) 5915566.4 Tx 18DA3AF1 8 03 22 1D 06 00 00 00 00
214960) 5915566.4 Tx 18DA3AF1 8 03 22 1D 06 00 00 00 00
214961) 5915572.8 Rx 18DAF13A 8 07 62 1D 06 42 9A 00 00
214962) 5915681.6 Tx 18DA3AF1 8 03 22 1D 07 00 00 00 00
214963) 5915681.6 Tx 18DA3AF1 8 03 22 1D 07 00 00 00 00
214964) 5915682.8 Rx 18DAF13A 8 07 62 1D 07 42 86 00 00
214965) 5915770.8 Tx 18FF1019 8 00 00 00 00 00 00 00 00 ----------> OFF
214966) 5915770.8 Tx 18FF1019 8 00 00 00 00 00 00 00 00
Best regards
Embers
Re: Time deviation use PCAN-Basic create trace files
Posted: Fri 29. Jan 2021, 08:35
by M.Heidemann
Hello,
Do you have any ability to check the accuracy of your timer implementation?
You use a event to count up until you reach your desired number of ticks, depending on the resolution of this timer
this might lead to deviations further down the road.
Also, from what i can see, i assume you use C#.
You could use System.Threading.Timer, in this case as it allows for longer intervals.
our APIs and drivers work with high-resolution timestamps, with a precision of 1 millisecond. They use QueryPerformanceFrequency and QueryPerformanceCounter for Timestamp generation.
Please check the accuracy of the timer implementation and report back to us.
Best Regards
Marvin