Hi, I mention below a sample code of my project using soem I use the task function as below.
ret4 = rt_task_create(&Dc_Pll_task, "Dc_time_Pll_task", 0, 99, 0); void Dc_time_Pll_function() { struct timespec ts, tleft; static int64 integral = 0; int64 sec, nsec,delta, cycletime=1000000; clock_gettime(CLOCK_MONOTONIC, &ts); while(1) { previous1 = rt_timer_read(); //read time input_ek1818 = (Ek1818_data_inputt *) ec_slave[slave_pos_beck_digitalIO].inputs;//struct pointers to slave I/O pointers inputs// output_ek1818 = (Ek1818_data_outputt*) ec_slave[slave_pos_beck_ digitalIO].outputs; in_EL5101 = (in_EL5101t*) ec_slave[slave_pos_beck_ encoderinterface].inputs; out_EL5101 = (out_EL5101t*) ec_slave[slave_pos_beck_ encoderinterface].outputs; nsec = (cycletime + offsettime) % NSEC_PER_SEC; sec = ((cycletime + offsettime) - nsec) / NSEC_PER_SEC; ts.tv_sec += sec; ts.tv_nsec += nsec; if (ts.tv_nsec >= NSEC_PER_SEC ) { nsec = ts.tv_nsec % NSEC_PER_SEC; ts.tv_sec += (ts.tv_nsec - nsec) / NSEC_PER_SEC; ts.tv_nsec = nsec; } clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &ts, &tleft); // Loop user code here if (ec_slave[0].hasdc) { //ec_Dctime is the system time synchronised with Ethercat slave delta = (ec_DCtime -(cycletime/4)) % cycletime; if(delta > (cycletime / 2)) { delta= delta - cycletime; } if(delta>0) { integral++; } if(delta<0) { integral--; } offsettime = -(delta / 100) - (integral / 20); } } } and I am using clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &ts, &tleft); to wait for a time untill the sleep wakes up this routine works good, but when I move a mouse the clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &ts, &tleft); gets some amount of microsecond added then, and my ethercat slave loss frame but the slave is synchronised with master. can anybody solve the problem such that when I move my mouse or keyboard clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &ts, &tleft); nanosleep time should not get jumped or time get added to it so that I dont loss any ethercat frames. ret4 = rt_task_create(&Dc_Pll_task, "Dc_time_Pll_task", 0, 99, 0); and the task priority I set is high. Thank you R. Ashokkumar <https://mailtrack.io/> Sent with Mailtrack <https://chrome.google.com/webstore/detail/mailtrack-for-gmail-inbox/ndnaehgpjlnokgebbaldlmgkapkpjkkb?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality> _______________________________________________ Xenomai mailing list Xenomai@xenomai.org https://xenomai.org/mailman/listinfo/xenomai