@Fe wi John is totally right, I'd like to add that you don't have to mmap linux devices like those in /dev or via /sys but you have to map directly register,
e.g. in my case (the eqep) ... constexpr uint32_t eQEP1phAdd=0x48302180; // if you look at am335x TRM this is the base address of the eqep map_base = mmap(0, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, ( eQEP1phAdd) & ~MAP_MASK ); ... Please note that I'm continuing to use the linux drivber to the initial configuration of the device... Il giorno giovedì 28 novembre 2013 05:10:31 UTC+1, John Syne ha scritto: > > > > From: <[email protected] <javascript:>> > Reply-To: <[email protected] <javascript:>> > Date: Monday, November 25, 2013 at 3:19 AM > To: <[email protected] <javascript:>> > Subject: [beagleboard] Help: "Fast" ADC sampling on the beagleboneblack > > 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 > > 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? > > Reading the ADC values via sysfs isn’t going to be fast. Also, it doesn’t > help to have a Xenomai kernel if you don’t use it. You have to write a > Xenomai kernel driver and then create a user space app that uses the > Xenomai API to communicate with the Xenomai kernel driver. Xenomai comes > with several examples to help you get started. You could also look at > Charles Steinkuehler’s LinuxCNC work where he uses nmap to control GPIO > with the Xenomai kernel. > > Regards, > John > > > 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] <javascript:>. > For more options, visit https://groups.google.com/groups/opt_out. > > -- 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.
