Out of the box, Raspbian is configured to provide a decent experience while conserving energy. However, responding instantly to incoming measurements tends to be so deviating, that we need to do some extra work to get a system working well.
A typical sign is that there is much noise in the data readings from the flywheel, lots of small deviations. This is typically the case when the signals are handled too late.
Open Rowing Monitor does not exist in isolation, so the first step is to make sure the Operating System (OS) is cut out for the job.
Normally, a Linux kernel is configured to do non-real-time work, and focusses on doing one task well for a prolonged period of time, reducing overhead. This is great for normal applications that process a lot of data. However, Open Rowing Monitor does not process much data, but does has to respond quickly to incoming signals (especially the impulses from the flywheel). The time it takes to respond to an incoming interrupt is called latency. For reducing noise in the readings, it is important that the latency does not vary too much.
When installing Open Rowing Monitor, please use a low latency or real time kernel. Currently, the Raspbian 64Bit Lite kernel is a Preempt kernel, which aims at low latency. So using this is a great choice for the Operating System.
Aside from selecting the right OS and kernel, there are some settings that can be set at startup that reduce the latency of the kernel.
One of these options is to turn off CPU exploit protection. This is a huge security risk as it removes security mitigations in the kernel, but it reduces latency. Given your specific network layout, this could be worth the effort. Add to /boot/cmdline.txt
the following option, if you consider it responsible in your situation (this introduces a security risk):
mitigations=off
Another option is to dedicate a CPU to Open Rowing Monitor and run the CPU's in isolation. This avenue isn't explored fully, and the effects on Open Rowing Monitor are unknown, but this text explains how it should work.
Typically, Raspbian is configured to reduce energy consumption, using the ondemand CPU governor. For low latency applications, this isn't sufficient. To get the most out of the CPU, we need to use the performance governor.
First, Raspbian will interfere with settings, so we need to kill that functionality:
sudo systemctl disable raspi-config
Next, we need to istall cpufrequtils to allow control over the CPU governor:
sudo apt-get install cpufrequtils
Now, you can set the default governor by editing /etc/default/cpufrequtils
so that it reads:
GOVERNOR="performance"
After a reboot, you can check the governor by executing:
sudo cpufreq-info
If all went well, your CPU is now in "Performance" mode. Please note that a Raspberry Pi will run hot and consume a lot more energy.
There are some services running that can be disabled safely.
To disable triggerhappy, do the following:
sudo systemctl disable triggerhappy.service
There are some other services that can be stopped, but where the effects on Open Rowing Monitor are untested, which can be found here.
One thing you can do to improve CPU performance is to reduce flanklength, which will reduce CPU-load. So running with unneccessary long flanklength isn't advised.