RTAI-3.1 as pwm - performance question

Jakub Mikolaj Lamik jml at cfsi.dk
Fri Oct 22 10:05:13 CEST 2004


Hi, 

I'm new to the list. I'm evaluating RTAI and coming with probably
trivial problem.

I'm using rtai-3.1 with default configuration (Uni-Processor scheduler,
IPC support 
as modules etc) with kernel 2.4.27 patched with hal16-2.4.27.patch.
I tried simple example with parallel pwm generator with 100 us period.
The timer is 
setup to periodic mode and the only RTAI task which is running in kernel
space is 
highest priority and basically does something like: 

static void pwm_thread_0(int n)
{
        while(1) {
                outb(0x00, LPT1);
                rt_task_wait_period();
                outb(0x01, LPT1);
                rt_task_wait_period();
        }
}
int init_module(void)
{
        RTIME now;
        outb(0, LPT1 + 2); //set port to output mode
        rt_set_periodic_mode();
        rt_task_init(&task_0, pwm_thread_0, 0, STACK_SIZE, 0, 0, 0);
        total_period = start_rt_timer(nano2count(PERIOD));
        rt_task_make_periodic(&task_0, rt_get_time() + total_period,
total_period);
        return 0;
}

Here is my /proc/rtai/scheduler

RTAI Uniprocessor Real Time Task Scheduler.

    Calibrated CPU Frequency: 2525240000 Hz
    Calibrated timer interrupt to scheduler latency: 2688 ns
    Calibrated one shot setup time: 2010 ns

Number of RT CPUs in system: 1

Priority  Period(ns)  FPU  Sig  State  Task  RT_TASK *  TIME
-------------------------------------------------------------
0         99733       No   No   0x5    1     e01d6200   17
TIMED
> e01d6200 
READY

Using oscilloscope I can observe 100 us pulse width periods with quite
well precision. 
Problems are appearing when I'm heavily overloading my system  (i.e.
building kernel 
with "make -j" option, using VNC etc.). I can observe jitter which is up
to 20 us. 

Am I doing something wrong or misunderstanding RTAI concept?

Regards,
Jakub




More information about the Rtai mailing list