Hello there,
i used this function chThdSleepUntil() instead chThdSleepMilliseconds(). my question is what is the value we use in chThdSleepUntil(). system tick or milliseconde??
and who tell the chThdSleepUntil() to begin to count ???
Thanks
chThdSleepUntil() ??
- tfAteba
- Posts: 547
- Joined: Fri Oct 16, 2015 11:03 pm
- Location: Strasbourg, France
- Has thanked: 91 times
- Been thanked: 48 times
Re: chThdSleepUntil() ??
Hello RTOSman,
The value use for this function is tick. But if you want to use milliseconds as your reférence, then you have to make a conversion from (ms) to (tick) by using for exemple MS2ST() function.
I think, that the count begin at the moment you call your function, so you don't need to do anything else.
Theo.
my question is what is the value we use in chThdSleepUntil(). system tick or milliseconde??
The value use for this function is tick. But if you want to use milliseconds as your reférence, then you have to make a conversion from (ms) to (tick) by using for exemple MS2ST() function.
and who tell the chThdSleepUntil() to begin to count ???
I think, that the count begin at the moment you call your function, so you don't need to do anything else.
Theo.
Re: chThdSleepUntil() ??
Thanks, and how about chVTGetSystemTime()) it return ticks or miliseconds ??
- tfAteba
- Posts: 547
- Joined: Fri Oct 16, 2015 11:03 pm
- Location: Strasbourg, France
- Has thanked: 91 times
- Been thanked: 48 times
Re: chThdSleepUntil() ??
Hi,
chVTGetSystemTime() return the system ticks.
The function prototype is static systime_t chVTGetSystemTime (void) and you can find all those informations on the ChibiOS/RT Manual http://chibios.sourceforge.net/docs3/rt/group__time.html#ga9abde73a5b3e779d86bdec83ca57f028
It is well documented I think, so read that and if you have any other questions you are welcome.
Theo.
chVTGetSystemTime() return the system ticks.
The function prototype is static systime_t chVTGetSystemTime (void) and you can find all those informations on the ChibiOS/RT Manual http://chibios.sourceforge.net/docs3/rt/group__time.html#ga9abde73a5b3e779d86bdec83ca57f028
It is well documented I think, so read that and if you have any other questions you are welcome.
Theo.
Re: chThdSleepUntil() ??
Hello i read all the manual, but i still learning . i have a problem with time i still can't master the time.
i have a thread i a high priority, it did this function
over time my blink does'nt blink every 1 seconde !! why ?
i have a thread i a high priority, it did this function
Code: Select all
static THD_FUNCTION(Thread1, arg) {
timeT = ST2MS(chVTGetSystemTime());
while (1)
{
ps_tel();//blink led suqar wave
chThdSleepUntil(MS2ST(timeT));
timeT += ST2MS(9);
}
}
over time my blink does'nt blink every 1 seconde !! why ?
- tfAteba
- Posts: 547
- Joined: Fri Oct 16, 2015 11:03 pm
- Location: Strasbourg, France
- Has thanked: 91 times
- Been thanked: 48 times
Re: chThdSleepUntil() ??
Hi RTOSman,
You did a little mistake.
You want to blink your led every 1 second, so why did you add ST2MS(9)?
Want your thread to run every 1000ms, so :
- Just add 1000ms to timeT variable, not ST2MS(9)
- Then call chThdSleepUntil(MS2ST(timeT));
As a result:
And I don't understand why you convert and reconvert system time to ms and so on?
Take a look at this http://www.chibios.org/dokuwiki/doku.php?id=chibios:kb:timing
I think it is much simpler .
Theo
You did a little mistake.
You want to blink your led every 1 second, so why did you add ST2MS(9)?
Want your thread to run every 1000ms, so :
- Just add 1000ms to timeT variable, not ST2MS(9)
- Then call chThdSleepUntil(MS2ST(timeT));
As a result:
Code: Select all
static THD_FUNCTION(Thread1, arg) {
timeT = ST2MS(chVTGetSystemTime());
while (1)
{
ps_tel();//blink led suqar wave
timeT += 1000;
chThdSleepUntil(MS2ST(timeT));
}
}
And I don't understand why you convert and reconvert system time to ms and so on?
Take a look at this http://www.chibios.org/dokuwiki/doku.php?id=chibios:kb:timing
I think it is much simpler .
Theo
Re: chThdSleepUntil() ??
Hello it's veery complicated to explain you my project, if you want i hava e function that i took every sample in 10 MS this is in matlab simulink. after code generation.
and i did 9 because the time between the wakup of thread and my function is 1
so to do the 10 ms calculation, i did 9 so 9+1=10 and here a did my simulink modele. and mt led blink exactely everry 1 ms just over time ihave errors. after 3 minute i have errors of 40 MS.
Du coup tu parles français ?
and i did 9 because the time between the wakup of thread and my function is 1
so to do the 10 ms calculation, i did 9 so 9+1=10 and here a did my simulink modele. and mt led blink exactely everry 1 ms just over time ihave errors. after 3 minute i have errors of 40 MS.
Du coup tu parles français ?
- tfAteba
- Posts: 547
- Joined: Fri Oct 16, 2015 11:03 pm
- Location: Strasbourg, France
- Has thanked: 91 times
- Been thanked: 48 times
Re: chThdSleepUntil() ??
Hi,
Yes has my location suggest I speack french
why? you want to discust in french?
Ok, i'm understand, wich chibios and board do you use for your project?
Yes has my location suggest I speack french
why? you want to discust in french?
Ok, i'm understand, wich chibios and board do you use for your project?
Re: chThdSleepUntil() ??
Bonjour, enfaîte j'au une arduino uno. j'ai la bibliothèque chibio 3.0.3.
je voudrais faire des test pour maîtriser le temps. donc j'ai intégré une fonction qui génère un signale carré de fréquence de 1. le problème c'est que au fil du temps la fréquence augmente un peux, quand je dépasse 3 minutes par exemple la j'ai un retarde de 40 MS. je sais pas comment faire pour éliminer ce retard ?
Vous avez des solutions a me proposer ?
vous pouvez me donnez un algo pour bien exécuter une tache chaque 10 MS !!
Merci d'avance
je voudrais faire des test pour maîtriser le temps. donc j'ai intégré une fonction qui génère un signale carré de fréquence de 1. le problème c'est que au fil du temps la fréquence augmente un peux, quand je dépasse 3 minutes par exemple la j'ai un retarde de 40 MS. je sais pas comment faire pour éliminer ce retard ?
Vous avez des solutions a me proposer ?
vous pouvez me donnez un algo pour bien exécuter une tache chaque 10 MS !!
Merci d'avance
Who is online
Users browsing this forum: No registered users and 30 guests