Hello Mr. TJF

First of All, thank you so much for providing support on real-time tasks 
using a low cost plataform.
I'm trying to apply the libary "libpruio" to make a system for energy 
meansurement using the beaglebone black. To do this,  I need to enable 2 
ADC channels, set a sample time, fil a buffer with the samples and make 
some calculation that includes the FFT. I'm really newbie on 
microprocessors, but i wrote a simple C code. The idea of this code is just 
to make 128 samples os the two channels and print the values. Just it:

#include "unistd.h"
#include "../c_wrapper/pruio.h" // include header
#include "time.h"


//! The main function.
int main(/*int argc, char **argv*/)
{
 float n[256];
 int a[256];
 int i=0;


  pruIo *io = pruio_new(PRUIO_DEF_ACTIVE, 0x98, 0, 1); //! create new 
driver structure
  pruio_adc_setStep(io, 9, 1, 0, 0, 0);                                     
                             // step 9, AIN-0
  pruio_adc_setStep(io, 10, 2, 0, 0, 0);


  if (pruio_config(io, 128, 9<<10 , 156250, 4)){ // upload (default) 
settings, start IO mode
                              printf("config failed (%s)\n", io->Errr);}
  else {


  if (pruio_rb_start(io)) printf("rb_start failed (%s)\n", io->Errr); // 
start measurement


  else{
        sleep(1);


        i=io->DRam[0];
        a[i] = i;
        n[i] = io->Adc->Value[i];
        do{
                if(i != io->DRam[0]){
                        i=io->DRam[0];
                        a[i] = i;
                        n[i] = io->Adc->Value[i];
                }
        }while(io->DRam[0] < 126);
        a[io->DRam[0]] = io->DRam[0];
        n[io->DRam[0]] = io->Adc->Value[io->DRam[0]];

        for(i = 0; i<=127; i++ ){
            printf("amostra %d            -----               %f \n", a[i], 
 (n[i]/65536)*1.8);
        }

}
/* we're done */
}
  pruio_destroy(io);        /* destroy driver structure */
        return 0;
}

 as result, I receive this:

amostra 1            -----               0.000000 
amostra 0            -----               -0.000012 
amostra 2            -----               1.799561 
amostra 3            -----               1.799561 
amostra -1092378024            -----               -0.000012 
amostra 5            -----               1.799561 
amostra 6            -----               1.799561 
amostra 7            -----               1.799561 
amostra -1092377860            -----               0.000000 
amostra 9            -----               1.799561 
amostra 10            -----               1.799561 
amostra 11            -----               1.799561 
amostra 12            -----               1.799561 
amostra 466005475            -----               0.000000 
amostra 14            -----               1.799561 
amostra 15            -----               1.799561 
amostra 1            -----               0.000000 
amostra -1225151312            -----               -0.000012 
amostra 18            -----               1.799561 
amostra 19            -----               1.799561 
amostra 3            -----               -0.000000 
amostra 21            -----               1.799561 
amostra 22            -----               1.799561 
amostra 23            -----               1.799561 
amostra -1225186212            -----               0.000000 
amostra 25            -----               1.799561 
amostra 26            -----               1.799561 
amostra 27            -----               1.799561 
amostra 1            -----               0.000000 
amostra 29            -----               1.799561 
amostra 30            -----               1.799561 
amostra 31            -----               1.799561 
amostra 0            -----               -0.000012 
amostra 33            -----               1.799561 
amostra 34            -----               1.799561 
amostra 35            -----               1.799561 
amostra -1092377728            -----               0.000000 
amostra 37            -----               1.799561 
amostra 38            -----               1.799561 
amostra 39            -----               1.799561 
amostra 0            -----               -0.000000 
amostra 41            -----               1.799561 
amostra 42            -----               1.799561 
amostra 43            -----               1.799561 
amostra 0            -----               0.000000 
amostra 45            -----               1.799561 
amostra 46            -----               1.799561 
amostra 47            -----               1.799561 
amostra 0            -----               0.000000 
amostra 49            -----               1.799561 
amostra 50            -----               1.799561 
amostra 51            -----               1.799561 
amostra 0            -----               0.000000 
amostra 53            -----               1.799561 
amostra 54            -----               1.799561 
amostra 55            -----               1.799561 
amostra -1225159968            -----               0.000000 
amostra 57            -----               1.799561 
amostra 58            -----               1.799561 
amostra 59            -----               1.799561 
amostra -1092376444            -----               0.000000 
amostra 61            -----               1.799561 
amostra 62            -----               1.799561 
amostra 63            -----               1.799561 
amostra 0            -----               0.000000 
amostra 65            -----               1.799561 
amostra 66            -----               1.799561 
amostra 67            -----               1.799561 
amostra 6            -----               0.000000 
amostra 69            -----               1.799561 
amostra 70            -----               1.799561 
amostra 71            -----               1.799561 
amostra 0            -----               0.000000 
amostra 73            -----               1.799561 
amostra 74            -----               1.799561 
amostra 75            -----               1.799561 
amostra 0            -----               0.000000 
amostra 77            -----               1.799561 
amostra 78            -----               1.799561 
amostra 79            -----               1.799561 
amostra 0            -----               0.000000 
amostra 81            -----               1.799561 
amostra 82            -----               1.799561 
amostra 83            -----               1.799561 
amostra 0            -----               -0.000000 
amostra 85            -----               1.799561 
amostra 86            -----               1.799561 
amostra 87            -----               1.799561 
amostra 0            -----               0.000000 
amostra 89            -----               1.799561 
amostra 90            -----               1.799561 
amostra 91            -----               1.799561 
amostra -1225160672            -----               -0.000000 
amostra 93            -----               1.799561 
amostra 94            -----               1.799561 
amostra 95            -----               1.799561 
amostra 96            -----               1.799561 
amostra 0            -----               -0.000000 
amostra 98            -----               1.799561 
amostra 99            -----               1.799561 
amostra 0            -----               0.000000 
amostra 101            -----               1.799561 
amostra 102            -----               1.799561 
amostra 103            -----               1.799561 
amostra -1225162752            -----               0.000000 
amostra 105            -----               1.799561 
amostra 106            -----               1.799561 
amostra 107            -----               1.799561 
amostra -1092377440            -----               0.000000 
amostra 109            -----               1.799561 
amostra 110            -----               1.799561 
amostra 111            -----               1.799561 
amostra 0            -----               -0.000000 
amostra 113            -----               1.799561 
amostra 114            -----               1.799561 
amostra 115            -----               1.799561 
amostra 0            -----               -0.000012 
amostra 0            -----               0.000000 
amostra 118            -----               1.799561 
amostra 119            -----               1.799561 
amostra 0            -----               -0.000012 
amostra 121            -----               1.799561 
amostra 122            -----               1.799561 
amostra 123            -----               1.799561 
amostra 0            -----               0.000000 
amostra 125            -----               1.799561 
amostra 126            -----               1.799561 
amostra -1092376512            -----               0.000000 

As you can see, the index does not obey the right sequency... do you have 
any idea why doe it happen??

-- 
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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beagleboard/b04c57b8-9256-4d3a-8ed4-3b330ee3d046%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to