Hi,

I'm using the same kernel (with xenomai) as you, and I'm facing a similar 
issue with the encoder interface

If you use xenomai and then access via sysfs to the driver you0re causing a 
domain switch to linux OS over xenomai. 
Moreover this way in any cycle you're issuing to many syscalls to reach 
high frequencies.

Just this morning I've tried to sample the encoder not using the sysfs 
interface but mmaping the device counter to the xenomai task and i 
experienced a big performance bump.


BR
Giuseppe

Il giorno lunedì 25 novembre 2013 12:19:19 UTC+1, fe wi ha scritto:
>
> Hi!
>
> I am currently using my Beaglebone Black with the following KERNEL: 
> 3.8.13xenomai-bone28.1 (including the ti_am335_adc driver).
>
> Part of my Project is reading signals from an ADC and then processing 
> them. I would love to use the onboard ADC for that, but I require to sample 
> 5 channels @ 2 kHz each. (I have installed the Xenomai Kernel mainly for 
> processing purposes but it might be useful for sampling as well ;) )
>
> My first simplistic try was to just read the voltage values from the files 
> provided in "/sys/bus/iio/devices/iio:device0/in_voltage0_raw" . 
> This works fine so far, but is just not fast enough. ( I get about 500 sps 
> on ONE channel)
>
> Here is that part of my CODE: 
> for(;;) {
>
> rt_task_wait_period(NULL); // Xenomai
>
> now=rt_timer_read(); // Xenomai 
>
> // Work for the current period //
>
>        FILE *read = fopen ( 
> "/sys/bus/iio/devices/iio:device0/in_voltage0_raw", "r");
>      
>
>         fscanf (read, "%f", &value);
>         float voltage = value * (1800.0/4095.0);   
>         fprintf (write, "Value: %f    Voltage: %f\n", value, voltage);
>
>              printf("Time since last turn: %ld,%06ld ms    Value:%f   
> Voltage: 
> %f\n",
>                        (long)(now - previous) / 1000000,
>                        (long)(now - previous) % 1000000, value, voltage);
>                        previous = now;
>
>     fclose ( read );
>     fclose ( write );
>
>   }  
> (I know that leaving out the printf part and the voltage calculation 
> increases performance, but still not enough)
>
> Is there any other way reading the values, directly from the memory 
> location or a register? Perhaps using mmap? 
> Or is there a Xenomai function for reading from an iio device? (I couldn't 
> find any...)
>
> I have seen two interesting links about continuous sampling:
> - 
> http://beagleboard-gsoc13.blogspot.de/2013/07/sampling-analogue-signals-using-adc-on.html
> - 
> http://processors.wiki.ti.com/index.php/AM335x_ADC_Driver%27s_Guide<http://www.google.com/url?q=http%3A%2F%2Fprocessors.wiki.ti.com%2Findex.php%2FAM335x_ADC_Driver%2527s_Guide&sa=D&sntz=1&usg=AFQjCNHs3cOTJepHxoPVPsMXnwNffHYyoQ>
>
> But i can't get the generic_buffer.c from those sites to work correctly 
> (as the trigger handling seems to be outdated), plus i might need to know a 
> kind of "oneshot" read function anyway to mux the 5 channels i want to 
> sample. Or is it possible to continuous sample multiple channels? The 
> Driver guide says 'no', but the Author from the other link seems to have 
> worked a lot on the adc Driver since.
>
> I am currently trying to figure out the code in generic_buffer.c and the 
> used iio_utils.h and the adc driver, but it is a lot of code and drivers 
> are not my strong suit.
> So far I think I need to setup the ADC to my needs (somewhat similar to 
> generic_buffer.c) and then read from it somehow, but I am really struggling 
> with that!
>
>
> So now you know the state of my project :) but to *sum it up*:
>
> Are my demands (5 channels @ 2 kHz) even possible using only the on-board 
> ADC?
> And if yes how do i read the values fast enough? Any tips?
>
> Thank you in advance!!
>
>
>

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to