DC motor control under Linux

M

Thread Starter

mc99044

Hello folks!

I am trying to perform digital control, in order to control the position of a dc motor. How can I program a timer subroutine, in order it to help me in the sampling process? I want to set the sampling rate of the control, for instance at 0.01sec, so i want the timer program 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.

Thanks.
 
Hello,

Take a look at and/or contact the Orocos and/or LinuxCNC projects - they both had to do this kind of thing, so they should be able to help you. Orocos in particular has split off a generic "Realtime Control Services" sub-project
that may be exactly what you need.
http://www.orocos.org/
http://www.linuxcnc.org/

As others have written, accurate 10ms is beyond a stock kernel (though I think 2.6 is better in this regard than 2.4 was); the solution depends on how much jitter is acceptable.

Jiri
--
Jiri Baum <[email protected]> http://www.csse.monash.edu.au/~jirib
MAT LinuxPLC project --- http://mat.sf.net --- Machine Automation Tools
 
R

Rokicki, Andrew

As far as the slice time. There is a HZ variable on my system /usr/src/linux-2.4/include/param.h
by increasing it you can decrease slice time. Once you do that you need to recompile the kernel. On our system we have it set at 4096 this gives us slice of 0.25 ms slice.
this allows us to drive a stepper motor at reasonable speed. One thing to remember is that Linux is not real time so if some task is running with higher priority than your DC motor task, your motor will not run smoothly. To fix that you need real time extension (see links in Jiri's
email) or write some sort of a driver.
 
Top