Can I use libpruio in both PRUss?

As the title says:
can libpruio run in both PRUss at the same time? The documentation says that the default configuration allow libpruio to run on PRU-0 OR PRU-1, so I guess this is a no?
I want to sample two three phase sinusoidal signal and I’m wondering if I can control the AIN pins of each sequence with a ‘dedicated’ PRU.
Thanks

Hi!

Control input pins? You can control output pins. Do you mean configure?

Even if you use dedicated PRUSS for the two pin sets, it’d be the same subsystem to sample the data (TSC_ADC_SS).

The way to go is:

  • use PRU1 for the input part (running libpruio)
  • use PRU0 for your customized controller, getting input from libpruio

BR

Thanks for your answer TJF!
I’m working C language directly on the bbb from PuTTy, so
I did my first attempt with rb mode but (after including both pruio.h and pruio_c_wrapper.h ) i got an error in:

`

pruIo *io = pruio_new(PRUIO_DEF_ACTIVE, 1, 0x98, 0); // average, open delay and sampe delay 0

`

rb.c: In function ‘main’:
rb.c:19:25: error: ‘PRUIO_DEF_ACTIVE’ undeclared (first use in this function)

And I’ve no idea why, since PRUIO_DEF_ACTIVE is defined in pruio.h.
Do you know what could be my mistake?!
Thanks in advance
BR

rb.c: In function ‘main’:
rb.c:19:25: error: ‘PRUIO_DEF_ACTIVE’ undeclared (first use in this function)

And I’ve no idea why, since PRUIO_DEF_ACTIVE is defined in pruio.h.
Do you know what could be my mistake?!
Thanks in advance

This means that PRUIO_DEF_ACTIVE is undefined or is not in the same scope as the c file using it.

Ah, this seems to be a libpruio-ism . . . others have had similar issues

http://stackoverflow.com/questions/27517043/undefined-reference-to-pruio-new-and-pruio-config-on-beaglebone-black

But nothing there specific to your error.

I can’t belive it, I just realize I downloaded the 0.0.2 version of libpruio and not the 0.2 (i followed rvega instructions in the freebasic forum and and here in this google group post) to compile I was using:
gcc -Wall -o rb rb.c /usr/local/lib/freebasic/fbrt0.o -lpruio -L"/usr/local/lib/freebasic/" -lfb -lpthread -lprussdrv -ltermcap -lsupc++
wheter TJC in the link you posted suggested using only -lpruio.
Let’s hope this will solve my problem! I still can’t belive it.
Thanks for the head up, and it’s not even the first time I read that stackoverflow post.

Both the headers are in the local include folder of the bbb, and the c file in the src/c_wrapper folder (with pruio.h and pruio_c_wrapper.h)

Both the headers are in the local include folder of the bbb, and the c file in the src/c_wrapper folder (with pruio.h and pruio_c_wrapper.h)

Yeah after reading that stackoverflow post it did occur to me it could be a shared library linker option “issue”. Which I find kind of odd, but I do not typically use other peoples code as such. Usually I write my own code from “scratch”, and try to avoid as much third party code as possible. Third party abstraction layers bother me even more . . .

I’m new to embedded system and programmation in general, I wouldn’t be able to start from ‘scratch’ for sure!
I’m still trying to understand why the constructor PruIo::PruIo() is defined differently in pruio.h
pruIo* pruio_new(uint16 Act, uint8 Av, uint32 OpD, uint8 SaD);
and in pruio_c_wrapper.h
PruIo* pruio_new(uint8 Av, uint32 OpD, uint8 SaD, uint8 Pru);
and which one should I use. I get that pruIo and PruIo are two different struct, but that’s it.
R

Hi Valeria!

I’m working C language directly on the bbb from PuTTy, …

That’s a big step in the right direction … (consider a replacement for C language?)

I’m new to embedded system and programmation in general, I wouldn’t be able to start from ‘scratch’ for sure!
I’m still trying to understand why the constructor PruIo::PruIo() is defined differently in pruio.h
pruIo* pruio_new(uint16 Act, uint8 Av, uint32 OpD, uint8 SaD);
and in pruio_c_wrapper.h
PruIo* pruio_new(uint8 Av, uint32 OpD, uint8 SaD, uint8 Pru);
and which one should I use. I get that pruIo and PruIo are two different struct, but that’s it.
R

You still mixed up versions:

  • pruio_c_wrapper.h is from version 0.0.2, it’s removed in version 0.2 (which you should use)
  • you must use #include “…/c_wrapper/pruio.h” (as in all the examples)
  • there’s just one constructor: pruIo* pruio_new()
  • you may optional also #include “…/c_wrapper/pruio_pins.h” (predefined macros for convenience)

Note: In version 0.2 PruIo (capital P) isn’t a struct, It’s a pointer to a FreeBASIC UDT (= User Defined Type) – a class that cannot be used directly from C source due to missing features in that language.

BR

Hi Valeria!

I’m working C language directly on the bbb from PuTTy, …

That’s a big step in the right direction … (consider a replacement for C language?)

You mean, FreeBasic? :D:D

I’m new to embedded system and programmation in general, I wouldn’t be able to start from ‘scratch’ for sure!
I’m still trying to understand why the constructor PruIo::PruIo() is defined differently in pruio.h
pruIo* pruio_new(uint16 Act, uint8 Av, uint32 OpD, uint8 SaD);
and in pruio_c_wrapper.h
PruIo* pruio_new(uint8 Av, uint32 OpD, uint8 SaD, uint8 Pru);
and which one should I use. I get that pruIo and PruIo are two different struct, but that’s it.
R

You still mixed up versions:

  • pruio_c_wrapper.h is from version 0.0.2, it’s removed in version 0.2 (which you should use)
  • you must use #include “…/c_wrapper/pruio.h” (as in all the examples)
  • there’s just one constructor: pruIo* pruio_new()
  • you may optional also #include “…/c_wrapper/pruio_pins.h” (predefined macros for convenience)

Note: In version 0.2 PruIo (capital P) isn’t a struct, It’s a pointer to a FreeBASIC UDT (= User Defined Type) – a class that cannot be used directly from C source due to missing features in that language.

BR

Thank’s for the clarification, the ‘funny’ thing was that in my pc I dawnloaded the new version of libpruio for reference, but in the bbb I installed the old one.
Can I ask something else about a function of the library? I’ve troubles understand how pruio_config(io, Samp, Mask,Tmr, Mds) work in rb mode, in particular the mask parameter.
Let's say that I want to sample 2 channel, AIN-1 and AIN-2 (Mask =0b110), Samp is the buffer size in term of sampling set so 2(channel)x(sample per channel that I want to 'collect' in the buffer, say 50), Tmr =1e6 ns and Mds= 4.

The Value array will be something like:

Value[0] | 1. sample AIN-1

Value[1] | 1. sample AIN-2

Value[2] | 2. sample AIN-1

Value[3] | 2. sample AIN-2

Value[98] | 50. sample AIN-1

Value[99] | 50. sample AIN-2

What’s the difference between this and Single mode? or which I have:

Value[1] | sample AIN-1

Value[2] | sample AIN-2

In this case Samp=1 as the comments in pruio.bas says or 50 (samples per channel that I want to 'collect' in the buffer) and then I'll have 25 samples per channel?

You mean, FreeBasic? :D:D

Some languages are beginners friendly, other are not. You wasted a lot of time before you dropped cross compiling. You’ll find further optimization potential in replacing PuTTy by an SSH client with X-server emulation, which makes it possible to get grafics output (ie. from example Oszi) from BBB on your PC screen. Or replacing wodniws by LINUX on your PC will skip all this installation issues, you can focus on your custom targets.

Anyway, it’s up to you to manage you progress speed.

Thank’s for the clarification, the ‘funny’ thing was that in my pc I dawnloaded the new version of libpruio for reference, but in the bbb I installed the old one.
Can I ask something else about a function of the library? I’ve troubles understand how pruio_config(io, Samp, Mask,Tmr, Mds) work in rb mode, in particular the mask parameter.
Let's say that I want to sample 2 channel, AIN-1 and AIN-2 (Mask =0b110), Samp is the buffer size in term of sampling set so 2(channel)x(sample per channel that I want to 'collect' in the buffer, say 50), Tmr =1e6 ns and Mds= 4.

The Value array will be something like:

Value[0] | 1. sample AIN-1

Value[1] | 1. sample AIN-2

Value[2] | 2. sample AIN-1

Value[3] | 2. sample AIN-2

Value[98] | 50. sample AIN-1

Value[99] | 50. sample AIN-2

What’s the difference between this and Single mode? or which I have:

Value[1] | sample AIN-1

Value[2] | sample AIN-2

In this case Samp=1 as the comments in pruio.bas says or 50 (samples per channel that I want to 'collect' in the buffer) and then I'll have 25 samples per channel?


|
|

  • | - |

    |
    |

    |
    |

    |
    |

    |
    |

The documentation is your friend.

  • Mask is not a channel mask, it’s a step mask.
  • Bit-0 enables the charge step
  • Bit-1 enables step 1, …, bit-16 enables step 16
  • Setting bit 1 in mask does not mean measuring AIN-1. It means enabling step 1, which is measuring AIN-0 by default in libpruio.
  • You can either use default configuration and mask step 2 (AIN-1) and step 3 (AIN-2) as
    Mask = 1 << 3 | 1 << 2
    or define new steps (range 9 to 16) or override default steps (range 1 to 8) with your custom configuration by calling pruio_adc_setStep() and then mask those customized steps with pruio_config().

In single mode you have one value per active step. This value gets updated continously. All IO (GPIO, ADC, CAP, PWM) is controlled at the same priority. This means you may see some latency in the ADC samples (a few ns).

In contrast the ADC has priority in MM and RB mode. The starts of the ADC measurements are performed with accurate timing. No further IO (GPIO, CAP and PWM) in version 0.2 (and further IO with lower priority in next versions).

BR