- From: Christopher Ziel <zielchri_at_msu.edu>
- Date: Mon, 17 Apr 2006 23:22:50 -0400
Hello,
I have a program I'm writing for the lab I'm working in and I'm running into
an interesting problem. Whenever I sample / output from more than 4 ports
on the DAQ card, it apparently takes TWICE as long, to actually sample the
data. I know this is what's going on because I've spent many hours
troubleshooting the system - the user space program doesn't change the
results, and nothing in the kernel space program should really be doubling
the time as well.
Below is the bulk of my kernel space program. Since I can't change the
TICK_PERIOD after compilation, I'm using a set sampling frequency of I think
50 khz, and I'm downsampling from there (that's what the first if statement
does - for say a 100 hz sampling rate, it makes sure we take a sample only
once every 500 samples). Once we know we want to sample, we send data out
and then send sampled data to the user space program using FIFO's.
while(1)
{ //there is a structure above which relates ticks_per_sample
from the user space program to this program
if(count2 < (adr1[0]).ticks_per_sample)
{
count2 = count2 + 1;
}
else
{
//printk("count2%d\n",count2);
count2 = 0;
out_data = 2047 +
2047*sin(2*PI*((adr1[0]).freq)*rt_get_cpu_time_ns()/1E9);
check2 =
comedi_data_write(it,(adr1[0]).out_sub, (adr1[0]).out_chan,
(adr1[0]).out_range, output_aref, out_data);
rt_sleep(total_sleep_time);
//use the sleep command to include a non-busy wait - more efficient on clock
usage
check1 =
comedi_data_read(it,(adr1[0]).in_sub,(adr1[0]).in_chan,(adr1[0]).in_range,input_aref,&in_data);
current_time = rt_get_time_ns();
rtf_put(FIFO, &in_data,
sizeof(in_data)); //reading
the voltage input
rtf_put(FIFO1, ¤t_time,
sizeof(current_time));
}
rt_task_wait_period();
}
}
That code works fine, but when I add 2 more comedi_data_read's and rtf_put's
the time between each sample actually doubles. I know this because the
output file stores data as well as each time the data was sampled (so we can
compare the times). Sorry if this all sounds a little confusing, I'm
writing this a little tired.
Please let me know what I can do. I posted a message on
www.linuxquestions.org asking for some sort of solution or even algorithm
they could give me but they haven't responded yet.
Best Regards,
-Christopher Ziel
Received on 2006-04-18Z02:22:50