Timer in Linux
I am trying to perform digital control, in order to control the position of a dc motor. How can I programm a timer subroutine, in order it to help me in the sampling process? I want thus to set the sampling rate of the control, for instance at 0.01sec, so i want the timer programm to trigger the system to take a sample every 0.01 secs. My operating system is Linux, and I use a digital I/O card without a hardware timer.
Read the man page on setitimer.
This sets up a timer that when it expires sends a SIGALARM to the process. So you need to learn about signal processing, too.
Read the man page on the singal family of functions, also.
On a multiuser (busy) system, even Windows, timers are not guaranteed to get the process going exactly on time, every time.
The scheduler might decide that some other process is more important.