Am Dienstag, 9. Dezember 2014 13:01:30 UTC+1 schrieb Luciano:The thing is that I'm only getting about 10kHz. It is normal to just get this sample rate
Hello Luciano,
the sampling rate could be higher if you activate less steps (in your code steps 1 to 8 are active). And you're using the ADC steps in the default configuration (open delay 0x98, avaraging 4). You can speed up the step(s) by removing both of them. Also keep in mind that the printf() function calls slow down your program a lot.
BR
BTW:
Why are you calling pruio_config() twice?
Why don't you use the current libpruio version 0.2?
Pardon my ignorance but about the ADC, how can I activate less steps?And how can I remove the default configuration (open delay 0x98, avaraging 4)? It is in the library "pruio_c_wrapper.h"? If so for what value should I change (#define PRUIO_DEF_AVRAGE 4)?
pruio_new(io, 0, 0, 0); pruio_config(io, 1, 1 << 2, 0, 4); // 1 << 2 = step 2 !!! libpruio-0.2 !!!
The thing about libpruio 0.2, is that I've already installed yesterday, but when I try to do the stepper example, it gives the message (setValue P1 error (no pin control)), and I don't know yet what the problem might be, and I need to use the GPIO to do the same algorithm above. So I was still trying something on libpruio0.0.2. Maybe you can help me figure it out, if possible.
sudo ./stepperIn BBB, I'm using Debian (BeagleBone Black - 2GB eMMC) 2014-05-14, available by the beagleboard.org latest images. I don't know if it might have something related with the version, because I get an error like below when I execute the command "echo libpruio > /sys/devices/bone_capemgr.slots".
But when I went to /sys/devices/ it shows bone_capemgr.9, like was in Libpruio0.0.2.
So, when I want to run the other examples like io_input.c, I use the command echo PRUSSDRV> /sys/devices/bone_capemgr.9/slots, it works, except stepper and pwm_cap, giving the same error as before (setValue P1 error (no pin control).
About the installation I did all the steps required with admin previleges (http://users.freebasic-portal.de/tjf/Projekte/libpruio/doc/html+/ChaPreparation.html).
Pardon my ignorance, but I really don't know what I'm doing wrong. So, if you could help me again, I would aprecciate very much. Already thank you for your attention.
Best regards,
Luciano.
About the installation I did all the steps required with admin previleges (http://users.freebasic-portal.de/tjf/Projekte/libpruio/doc/html+/ChaPreparation.html).Pardon my ignorance, but I really don't know what I'm doing wrong. So, if you could help me again, I would aprecciate very much. Already thank you for your attention.
!!! mind the position of the 'A' !!! in the copy command)cp src/config/libpruio-0A00.dtbo /lib/firmware/libpruio-00A0.dtbo
echo libpruio > /sys/devices/bone_capemgr.slotsall examples should work (pwm_adc, pwm_cap and stepper need admin privileges).
BR
I did this way and I would be glad of you helped me in this question. I have installed Libpruio0.0.2, and I wrote a simple code just to read the ADC value (Value[1]) from the output port P9_14 to see it commute.(I don't need all that libraries, but they are there for further algorithms). In the circuit I added a voltage divider with two 10k resistors, to get about 1,7V to not cross 1,8V.
IF .Adc->setStep(1, 0, 0, 0, 0) THEN _ ' configure fast Adc step
?"ADC setStep failed (" & *.Errr & ")" : EXIT DO
...
FOR i AS INTEGER = 0 TO c
o = IIF(.Adc->Value[1] > &h7FFF, 0, 1)
IF .Gpio->setValue(POUT, o) THEN _ ' set GPIO output
?"GPIO setValue failed (" & *.Errr & ")" : EXIT DO
NEXT
IF .Cap->Value(PIN, @f2, @d2) THEN _ ' get CAP input
?"Cap->Value failed (" & *.Errr & ")" : EXIT DO, DO
...ADC closed loop:
Minimum: 54704.59375
Avarage: 61088.24790736607
Maximum: 80321.28125
IF .Adc->setStep(1, 0, 0, 0, 0) THEN _ ' configure fast Adc step
?"ADC setStep failed (" & *.Errr & ")" : EXIT DO
IF .config(1, 1 SHL 1) THEN _
?"config failed (" & *.Errr & ")" : EXIT DO
...
FOR i AS INTEGER = 0 TO c
WHILE .Adc->Value[1] <= &h7FFF : WEND ' wait until high
IF .Gpio->setValue(POUT, 0) THEN _ ' set GPIO low
?"GPIO setValue failed (" & *.Errr & ")" : EXIT DO
WHILE .Adc->Value[1] > &h7FFF : WEND ' wait until low
IF .Gpio->setValue(POUT, 1) THEN _ ' set GPIO high
?"GPIO setValue failed (" & *.Errr & ")" : EXIT DO
NEXT
if .Cap->Value(PIN, @f2, @d2) then _ ' get CAP input
?"Cap->Value failed (" & *.Errr & ")" : EXIT DO, DO
...
ADC closed loop:
Minimum: 69589.421875
Avarage: 91196.43975694444
Maximum: 93196.6484375Then I was scrolling and he said he still had problems. He proposed a solution and then I saw the "enum pinMixung".I got the code you (TFJ) proposed next and I put it in the library pruio.h at /usr/local/include.
...
once I didn't understand welI what I've changed. Maybe you can tell me, if possible.
I didn't have the oportunity to do some tests about the sample rate, because I don't have an oscilloscope this moment. But when I have the oportunity I will report my results to you .
So, if I'm understandig it right, what I conclude is that with only one ADC working, the maximum sample rate we can get is around 93 kHz.
The ADC can definitely sample at 1.6 MHz, that is four channels could go up to 400 kHz each (sequentially). The 1.6 MHz correspond to the minimal 15 steps for one sample when setting the ADC clock to 24 MHz, that is, setting the CLKDIV register to zero, and not to 7 as it is set by default (which explains your 200kHz theoretical sampling rate). I have my own assembler code which works, but as it is a bit older, it is not in line with newer things like libpruio. If you want to have a look at my code to get it working let me know and I'll send it to you.
Hey TJF,When possible, can you tell me something about my results when I got the sample rate using the CAP pin?
#define P1 P9_14#define P2 P9_42int main(int argc, char **argv){ pruIo *Io = pruio_new(PRUIO_DEF_ACTIVE, 0, 0, 0); //! create new driver structure
if (Io->Errr) { printf("initialisation failed (%s)\n", Io->Errr);}
if (pruio_cap_config(Io, P1, 2.)) { // configure input pin printf("failed setting input @P_IN (%s)\n", Io->Errr);}...
...
if (pruio_cap_Value(Io, P1, &f1, &d1)) { // get current input printf("failed reading input @P1 (%s)\n", Io->Errr); }
printf("\r Frequency: %10f , Duty: %10f ", f1, d1); // info...
maybe libpruio can sample as fast as 1.4-1.6 MHz??
The thing is that I'm only getting about 10kHz. It is normal to just get this sample rate