Scheduling a component faster than 1Hz #988
-
Hello, I'm trying to trigger a passive component at a frequency higher than 1Hz (let's say at 60 Hertz for example) but I'm having a lot of difficulties to do it. ContextTo do this I am inspired by the RPI demonstration available in the F´ project, but in the I understood that it is done through the two instances: RateGroupDriver: and ActiveRateGroup:
The instantiation of this class is done in the following manner in RPI for 10Hz and 1Hz: // Rate Group Dividers for 10Hz and 1Hz
static NATIVE_INT_TYPE rgDivs[] = {1,10,0};
Svc::RateGroupDriverImpl rateGroupDriverComp("RGDRV",rgDivs,FW_NUM_ARRAY_ELEMENTS(rgDivs)); If I refer to @timcanham words about the RateGroupDriver instance in the
So I understand that if we want to add a frequency of 60 Hz we have at least two possibilities: 1- Either enter a value so that 1Hz/x = 60Hz or x=1/60. 2- Or modify the input frequency to 60Hz and put the value 1 in the first slot of RateGroupDriver. As the RPI tutorial would trigger a component at 1Hz or 10Hz, I think I have misunderstood something or I have missed some information. I noticed that the RPI tutorial makes more use of ActiveRateGroup: // Context array variables are passed to rate group members if needed to distinguish one call from another
// These context must match the rate group members connected in RPITopologyAi.xml
static NATIVE_UINT_TYPE rg10HzContext[] = {Rpi::CONTEXT_RPI_DEMO_10Hz,0,0,0,0,0,0,0,0};
Svc::ActiveRateGroupImpl rateGroup10HzComp("RG10Hz",rg10HzContext,FW_NUM_ARRAY_ELEMENTS(rg10HzContext));
static NATIVE_UINT_TYPE rg1HzContext[] = {0,0,Rpi::CONTEXT_RPI_DEMO_1Hz,0,0,0,0,0,0};
Svc::ActiveRateGroupImpl rateGroup1HzComp("RG1Hz",rg1HzContext,FW_NUM_ARRAY_ELEMENTS(rg1HzContext)); In fact it has been defined two enumerated types for rate group contexts in RPI/Top/RpiSchedContext: enum {
CONTEXT_RPI_DEMO_1Hz = 10, // 10Hz cycle
CONTEXT_RPI_DEMO_10Hz = 11 // 1 Hz cycle
}; At the moment I'm still struggling to realize the potential of contexts by reading the RPI code but I don't have the impression that this is what makes 10Hz possible. QuestionCould you detail the process to program the triggering of a specific component at a frequency higher than 1Hz please? Maybe the explanations could be used to feed the Rate Groups and Timeliness presentation in the F´ documentation which has been in TODO for a while. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Hi! You are right about #2 "Or modify the input frequency to 60Hz and put the value 1 in the first slot of RateGroupDriver." - i think that would be the easiest way. The Rate Group Driver's CycleIn is triggered via the LinuxTimer. To set the frequency that the LinuxTimer invokes a port call to the RateGroupDriver, adjust this argument in the linuxTimer.startTimer() in main.cpp see here I believe the argument is an integer that represents the number of miiliseconds between invoking a call to the RateGroupDriver. After you set this to the desired value, you could keep the first index of the rgDivs at 1. Ebenezer Arunkumar |
Beta Was this translation helpful? Give feedback.
-
If you look here: https://github.com/nasa/fprime/blob/devel/RPI/Top/Main.cpp#L57 The Linux timer will drive the linuxTimer.startTimer(100); i.e. every 100ms. If you want to drive the |
Beta Was this translation helpful? Give feedback.
If you look here:
https://github.com/nasa/fprime/blob/devel/RPI/Top/Main.cpp#L57
The Linux timer will drive the
RateGroupDriver
at 10 Hz with this line:linuxTimer.startTimer(100);
i.e. every 100ms.
If you want to drive the
RateGroupDriver
's fundamental tick at higher rate, lower this parameter. Then use the table to divide that frequency down to slower ones for other rate groups. Granted, 60Hz isn't an even number of milliseconds, but I don't know how important 60Hz exactly is.