Discussion:
libpruio (fast and easy D/A - I/O)
(too old to reply)
TJF
2014-05-09 14:23:18 UTC
Permalink
<Loading Image...>
A new library called libpruio is availble to support digital input and
output as well as analog input on Beaglebone (black) hardware. It uses
software running on a PRUSS to configure and control the devices

- Control Module (pinmuxing)
- GPIO 0 to 3 (digital IO)
- TSC_ADC_SS (analog input)

The API is designed for easy usage, but also for fast execution speed. No
need for root privilegues or further device tree overlays (just a single
overlay to start the PRUSS).

It's compiled by the FreeBASIC compiler<http://www.freebasic-portal.de/downloads/fb-on-arm/bbb-fbc-fbc-fuer-beaglebone-black-283.html>,
but also includes a wrapper to be used with C compilers. The package
contains example code in both languages. Development and testing has been
done on a BeagleboneBlack under Ubuntu 13.10.

Find more informations at

- en: libpruio (BB D/A - I/O fast and easy)<http://www.freebasic.net/forum/viewtopic.php?f=14&t=22501>
- de: libpruio (D/A - I/O schnell und einfach)<http://www.freebasic-portal.de/downloads/fb-on-arm/libpruio-325.html>

or check out the online documentation<http://users.freebasic-portal.de/tjf/Projekte/libpruio/doc/html/index.html>
.
--
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 beagleboard+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/d/optout.
Jason Kridner
2014-05-09 15:42:50 UTC
Permalink
This looks pretty awesome from the surface. You should register at
http://beagleboard.org/project. Do you want this included the default image?
Post by TJF
<http://users.freebasic-portal.de/tjf/Projekte/libpruio/doc/html/pruio_logo.png>
A new library called libpruio is availble to support digital input and
output as well as analog input on Beaglebone (black) hardware. It uses
software running on a PRUSS to configure and control the devices
- Control Module (pinmuxing)
- GPIO 0 to 3 (digital IO)
- TSC_ADC_SS (analog input)
The API is designed for easy usage, but also for fast execution speed. No
need for root privilegues or further device tree overlays (just a single
overlay to start the PRUSS).
It's compiled by the FreeBASIC compiler<http://www.freebasic-portal.de/downloads/fb-on-arm/bbb-fbc-fbc-fuer-beaglebone-black-283.html>,
but also includes a wrapper to be used with C compilers. The package
contains example code in both languages. Development and testing has been
done on a BeagleboneBlack under Ubuntu 13.10.
Find more informations at
- en: libpruio (BB D/A - I/O fast and easy)<http://www.freebasic.net/forum/viewtopic.php?f=14&t=22501>
- de: libpruio (D/A - I/O schnell und einfach)<http://www.freebasic-portal.de/downloads/fb-on-arm/libpruio-325.html>
or check out the online documentation<http://users.freebasic-portal.de/tjf/Projekte/libpruio/doc/html/index.html>
.
--
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
.
For more options, visit https://groups.google.com/d/optout.
--
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 beagleboard+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/d/optout.
TJF
2014-05-09 17:08:26 UTC
Permalink
Thanks for the registration tip / link, done.

And thanks for your positive statement. I hope you find some time to look
under the hood. Would be nice if you can run some of the pre-compiled
examples and tell us your thoughts.

The licences are LGPLv2 / GPLv3, so it could get in to the default image.
I'd like to get some feedback and fix the major bugs, first. Is there a
deadline?
--
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 beagleboard+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/d/optout.
Jason Kridner
2014-05-09 20:25:40 UTC
Permalink
No particular deadline as we already shipped the Rev C image. We will push
a bug fix version over the next 2-3 weeks as reports come in. If we don't
squeeze in there, there's always another release coming.
Post by TJF
Thanks for the registration tip / link, done.
And thanks for your positive statement. I hope you find some time to look
under the hood. Would be nice if you can run some of the pre-compiled
examples and tell us your thoughts.
The licences are LGPLv2 / GPLv3, so it could get in to the default image.
I'd like to get some feedback and fix the major bugs, first. Is there a
deadline?
--
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
.
For more options, visit https://groups.google.com/d/optout.
--
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 beagleboard+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/d/optout.
Jason Kridner
2014-05-12 11:35:49 UTC
Permalink
No set deadline. We should be doing new releases multiple times this
summer as issue reports and feature requests start coming in on Rev C
as we get more users.
Post by TJF
Thanks for the registration tip / link, done.
And thanks for your positive statement. I hope you find some time to look
under the hood. Would be nice if you can run some of the pre-compiled
examples and tell us your thoughts.
The licences are LGPLv2 / GPLv3, so it could get in to the default image.
I'd like to get some feedback and fix the major bugs, first. Is there a
deadline?
--
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
For more options, visit https://groups.google.com/d/optout.
--
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 beagleboard+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/d/optout.
TJF
2014-05-12 20:20:14 UTC
Permalink
For the default image we need the binary libpruio.so (not sure about
libpruio.a). And we need the headers. Currently there're 4 headers, but I
think I should create an all-in-one version called pruio.h and drop the
documentation comments to save some memory.

Where to send the fine-tuned files? (Please be patient, that's my first
project here.)

Who cares about the dependencies (libprussdrv)?
--
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 beagleboard+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/d/optout.
TJF
2014-06-06 11:38:38 UTC
Permalink
Version 0.0.2 is out now:

- added: new example button.bas (.c)
- bugfix: gpio_get() returns correct value now
- cosmetic: pruio_c_wrapper.h contains headers pruio.h and pruio.hp
(all-in-one)
- cosmetic: minor changes in documentation
--
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 beagleboard+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/d/optout.
s***@public.gmane.org
2014-09-03 16:05:04 UTC
Permalink
Hi TJF,

I just managed to compile and run the libpruio example apps on beaglebone
white PRU.

I was experimenting with the button.c, trying to set the pin 8_07 as active
high, using ->

if (pruio_gpio_set(io, PIN, PRUIO_IN_0, PRUIO_LOCK_CHECK)) {
printf("failed setting PIN (%s)\n", io->Errr); break;}

But, when I compile and run it, I still see its '1'.

./analyse reveals->

P8_07, GPIO 2/02: input, pullup

Am I missing something?

Forgive me if this sounds like a stupid question. Please help.

Thanks and regards,
Shoaib Ahmed.
Post by TJF
- added: new example button.bas (.c)
- bugfix: gpio_get() returns correct value now
- cosmetic: pruio_c_wrapper.h contains headers pruio.h and pruio.hp
(all-in-one)
- cosmetic: minor changes in documentation
--
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 beagleboard+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/d/optout.
TJF
2014-09-03 18:33:09 UTC
Permalink
Hi Shoaib Ahmed,

thanks for your interrests in libpruio.
Post by s***@public.gmane.org
Am I missing something?
Forgive me if this sounds like a stupid question. Please help.
No stupid question. A stupid author of libpruio, instead. Pinmuxing doesn't
work in your version. See

http://www.freebasic.net/forum/viewtopic.php?f=14&t=22501&start=30#p198962

It'll be fixed in the next release (version 0.2). Meanwhile use external
tools, please.

Sorry for your trouble.
--
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 beagleboard+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/d/optout.
n***@public.gmane.org
2014-09-17 20:25:05 UTC
Permalink
Hey TJF,

I'm currently working on underwater ultrasonic sound and wonder if you
think that with your library can produce constant and reliant ADC input
at sample rates of 200Khz per pin. On top of that I'm interested to see
version 0.2 and the ring buffer you're been talking about.

Since it seems that you've already been able to produce results with the
ring buffer, I only need to read ADC input right now and I'm on a tight
schedule right now I would like to ask you if you want to provide a test
version of said feature. I can provide the results of the tests.

Greetings,
Nils Kohrs
--
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 beagleboard+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/d/optout.
TJF
2014-09-19 07:11:27 UTC
Permalink
Hello Nils!
Post by n***@public.gmane.org
Hey TJF,
I'm currently working on underwater ultrasonic sound and wonder if you
think that with your library can produce constant and reliant ADC input
at sample rates of 200Khz per pin
The PRUSS code is ready to work at that speed. Unfortunately the BBB
hardware (TSC_ADC_SS) is limited to a maximum total sampling rate of 160
kHz (one channel, software triggered start). If you need more than one
channel, you've to add some delay for switching (multiplexing) the input.
Post by n***@public.gmane.org
On top of that I'm interested to see version 0.2 and the ring buffer
you're been talking about.
The code is ready (95 %). I'm working on the documentation (any help is
welcome).
Post by n***@public.gmane.org
Since it seems that you've already been able to produce results with the
ring buffer, I only need to read ADC input right now and I'm on a tight
schedule right now I would like to ask you if you want to provide a test
version of said feature. I can provide the results of the tests.
Beta testing is welcome. Please tell me if you're still interested (in the
light of the hardware limitations).

BR
--
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 beagleboard+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/d/optout.
TJF
2014-10-26 17:17:02 UTC
Permalink
libpruio-0.2 is out now:


New:


- Ring buffer (RB) run mode (samples analog input continously).
- PWM output in IO and RB mode (variable frequency and duty cycles).
- CAP input in IO and RB mode (analyses frequency and duty cycles of a
pulse train).
- New examples *pwm_adc*, *pwm_cap*, *rb_oszi*.
- Subsystem control (enable or disable single subsystems at run-time).
- Device tree overlay included (universal pinmuxing at run-time).
- Tools included to create, compile and install universal or customized
device tree overlays.
- Advanced error messages from constructor.


Changes:


- Completely renewed source code (modular now, for easier expansions).
- Completely renewed documentation (interferences between C and FB
source solved).
- API adapted to modular structure (see file migration.txt.
- Version 0.0 examples adapted (*1*, *analyse*, *button*, *io_input*,
*sos*, *stepper*, *oszi*, *triggers*).
- Adaptions for new FreeBASIC compiler fbc-1.00.
- Access to all subsystem registers supported.


Bugfixes:


- Pinmuxing now available.
- GPIO output fixed (former gpio_set sometimes skipped a setting).


Download (as in first post)


http://www.freebasic-portal.de/downloads/fb-on-arm/libpruio-325.html
--
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 beagleboard+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
William Hermans
2014-10-26 21:44:09 UTC
Permalink
TJF, It would be nice if you're going to link to a site to a majority of
English speakers, that the link you give to us links to a written English
page.

At minimum you're posting in English so yeah, be nice to us.
Post by TJF
- Ring buffer (RB) run mode (samples analog input continously).
- PWM output in IO and RB mode (variable frequency and duty cycles).
- CAP input in IO and RB mode (analyses frequency and duty cycles of a
pulse train).
- New examples *pwm_adc*, *pwm_cap*, *rb_oszi*.
- Subsystem control (enable or disable single subsystems at run-time).
- Device tree overlay included (universal pinmuxing at run-time).
- Tools included to create, compile and install universal or
customized device tree overlays.
- Advanced error messages from constructor.
- Completely renewed source code (modular now, for easier expansions).
- Completely renewed documentation (interferences between C and FB
source solved).
- API adapted to modular structure (see file migration.txt.
- Version 0.0 examples adapted (*1*, *analyse*, *button*, *io_input*,
*sos*, *stepper*, *oszi*, *triggers*).
- Adaptions for new FreeBASIC compiler fbc-1.00.
- Access to all subsystem registers supported.
- Pinmuxing now available.
- GPIO output fixed (former gpio_set sometimes skipped a setting).
Download (as in first post)
http://www.freebasic-portal.de/downloads/fb-on-arm/libpruio-325.html
--
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
For more options, visit https://groups.google.com/d/optout.
--
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 beagleboard+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
TJF
2014-10-27 08:00:45 UTC
Permalink
William, sorry, my fault!

"us" can find the 'brand new' English project page at

http://beagleboard.org/project/libpruio/

Don't hesitate to ask if you need further assistance on downloading.
--
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 beagleboard+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
n***@gmail.com
2014-10-30 13:43:03 UTC
Permalink
Hey TJF,

Nice to see the update, I really happy with the new features :)

What would be the highest consistent samplerate possible with the c wrapper
with 1 channel. Using the RB would be the nicest but using MM is also an
option if the samplerate is higher with that.

I think if I know that I could figure out the rest myself, however it would
be nice to have sample code of config&start rb/mm(possibly on max
samplerate) and data retrieving in c.

Greetings,
Nils Kohrs
Post by TJF
- Ring buffer (RB) run mode (samples analog input continously).
- PWM output in IO and RB mode (variable frequency and duty cycles).
- CAP input in IO and RB mode (analyses frequency and duty cycles of a
pulse train).
- New examples *pwm_adc*, *pwm_cap*, *rb_oszi*.
- Subsystem control (enable or disable single subsystems at run-time).
- Device tree overlay included (universal pinmuxing at run-time).
- Tools included to create, compile and install universal or
customized device tree overlays.
- Advanced error messages from constructor.
- Completely renewed source code (modular now, for easier expansions).
- Completely renewed documentation (interferences between C and FB
source solved).
- API adapted to modular structure (see file migration.txt.
- Version 0.0 examples adapted (*1*, *analyse*, *button*, *io_input*,
*sos*, *stepper*, *oszi*, *triggers*).
- Adaptions for new FreeBASIC compiler fbc-1.00.
- Access to all subsystem registers supported.
- Pinmuxing now available.
- GPIO output fixed (former gpio_set sometimes skipped a setting).
Download (as in first post)
http://www.freebasic-portal.de/downloads/fb-on-arm/libpruio-325.html
--
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 beagleboard+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
TJF
2014-10-30 17:50:54 UTC
Permalink
Hello Nils,

thanks for feedback!

The maximum sample rate is limited by the ADC subsystem. It's 159 kS/s (15
cycles @ 2.4 MHz + safety buffer) for a single step (channel). It neither
matters if you operate in RB or MM mode, nor if you use FB or C compilers.

For me, writing C examples is exhausting and time consuming. For an
experianced C programmer it should be easy to translate the FB examples
*rb_oszi* and *triggers*, where you can find the code you're loocking for.
(I'd appreciate it if I can include such a translation in to the
documentation.)

For maximum sample rate you've to configure a customized step with no
delays and no avaraging. And you've to activate this step only, like

pruio_adc_setStep(Io, 9, 4, 0, 0, 0); // step 9 for AIN-4

pruio_config(Io, Samples, 1 << 9, 6285, 4); // '1 << 9' -> step 9, '6285'
ns -> 159.1 kHz

pruio_rb_start(Io);


BR
--
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 beagleboard+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
n***@gmail.com
2014-11-06 14:00:38 UTC
Permalink
I've tested that code but it produces an error for me:

MURX: 4294967285
config failed (failed executing Pru_Run instructions)
This is the code I used

#include <unistd.h>
#include "stdio.h"
#include "../c_wrapper/pruio.h"

int main(int argc, char **argv)
{
int n;
pruIo *io = pruio_new(PRUIO_DEF_ACTIVE, 0x98, 0, 1);
pruio_adc_setStep(io, 9, 4, 0, 0, 0); // step 9 for AIN-4
if (pruio_config(io, 0, 1 << 9, 6285, 0)){ // '1 << 9' -> step 9, '6285'
ns -> 159.1 kHz
printf("config failed (%s)\n", io->Errr);}
else{
pruio_rb_start(io);
for(n = 1; n <= 1000; n++){
printf("%u\n", io->DRam[0]);
sleep(1);
}
}
pruio_destroy(io);
return 0;
}


Greetings,
Nils Kohrs
--
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 beagleboard+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
n***@gmail.com
2014-11-06 16:16:43 UTC
Permalink
Hey TJF,

with 6285 ns I was only able to set the amount of samples to 1 without
getting an error. With 6290 works everything fine.

Here is some c samplecode for you, it keeps writing all the samples to a
file in burst of 1000000/4 samples per writing burst.

#include "unistd.h"
#include "stdio.h"
#include "../c_wrapper/pruio.h"


//! The main function.
int main(int argc, char **argv)
{
FILE* oFile;
uint8 bDiv = 4, bStep;
uint32 bSize = 1e6;
uint32 bsSize = bSize/bDiv;
oFile = fopen("output","wb");
pruIo *io = pruio_new(PRUIO_DEF_ACTIVE, 0x98, 0, 1); //! create new
driver structure
pruio_adc_setStep(io, 9, 4, 0, 0, 0); // step 9 for AIN-4
if (pruio_config(io, bSize, 1 << 9, 6290, 0)){ // '1 << 9' -> step 9,
'6285' ns -> 159.1 kHz
printf("config failed (%s)\n", io->Errr);}
else{
pruio_rb_start(io);
sleep(1);
while(1){
while(io->DRam[0] < (bStep+1) * bsSize && io->DRam[0] > bStep * bsSize
){
sleep(1);
}
printf("start writing %u\n",bStep*bsSize);
fwrite(io->Adc->Value, sizeof(uint16), 16000, oFile);
printf("end writing %u\n",(bStep+1)*bsSize);
bStep = bStep+1 < bDiv ? bStep+1 : 0;
}
}
pruio_destroy(io);
return 0;
}

Greetings,
Nils Kohrs
--
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 beagleboard+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
TJF
2014-11-06 18:36:04 UTC
Permalink
Hello Nils,

thanks for the code. I think about including it in the libpruio examples
folder, but your main loop is endless and the user cannot abort the
program. (Shouldn't the file get closed?) Perhaps I can adapt it a bit.

Regarding the ADC speed I made some further testing and it seems that I
mis-interpreted the TRM. The ADC subsystem can sample at least at 200 kS/s.
This speed also works for multiple channels. Find an example of four
channels at 44.1 kHz in this post
<http://beagleboard.org/Community/Forums?place=msg%2Fbeagleboard%2F3AFiCNtxGis%2FH7q76xdk8ZQJ>.
An overall sampling rate of 200 kHz was also possible (four channels).

So the limiting in the current libpruio-0.2 is too much on the safe site.
If you don't want to wait for the next version, you can adapt the code by
yourself (FreeBASIC compiler required). Replace in file pruio_adc.bas in
function PruIo.configure(...) the lines

d *= (Conf->ADC_CLKDIV + 1) * 417 '417 ≈ 1000000 / 2400 (= 1 GHz /
2.4 MHz)
d += 30 ' PRU cycles for restart [GHz]
IF Tmr <= d THEN .Errr = @"sample rate too big" : RETURN .Errr

by the following code

d = (d * (Conf->ADC_CLKDIV + 1) * 1000) \ 24
IF Tmr <= d ORELSE Tmr < 5000 THEN _
.Errr = @"sample rate too big" : RETURN .Errr

You may play a bit with the absolute value 5000. On my BBB the timing is OK
up to a frequency of 240 kHz (4165). But this may vary from board to board.
--
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 beagleboard+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
n***@gmail.com
2014-11-06 23:18:55 UTC
Permalink
Hey TJF,

I've got it compiled and working. I can't yet test if the adc keeps up
since I the function generator we've ordered got out of stock.... However I
changed my code a bit so it would close the files and the whole program has
a end statement. It's currently 1 channel at ~220 kS/s. I haven't pushed it
further because I don't know what will happen. With my understanding of the
PRU I guess the PRU can't break anything on the BBB while doing that, but I
don't know so I don't want to push my luck.

#include "unistd.h"
#include "stdio.h"
#include "../c_wrapper/pruio.h"


//! The main function.
int main(int argc, char **argv)
{
FILE* oFile;
uint8 bDiv = 4, bStep;
uint32 bSize = 1e6;
uint32 bsSize = bSize/bDiv;
uint8 cycles = 2;
char fName[12];
int i = 0;


pruIo *io = pruio_new(PRUIO_DEF_ACTIVE, 0x98, 0, 1); //! create new
driver structure
pruio_adc_setStep(io, 9, 4, 0, 0, 0); // step 9 for AIN-4
if (pruio_config(io, bSize, 1 << 9, 4545, 0)){ // '1 << 9' -> step 9,
'6285' ns -> 159.1 kHz
printf("config failed (%s)\n", io->Errr);}
else{
pruio_rb_start(io);
sleep(1);
for(i=0; i<cycles; i++){
sprintf(fName, "output.%u",i);
oFile = fopen(fName,"wb");
while(bStep<bDiv){
while(io->DRam[0] < (bStep+1) * bsSize && io->DRam[0] > bStep *
bsSize){
sleep(1);
}
printf("writing samples %u-%u\n",bStep*bsSize, (bStep+1)*bsSize);
fwrite(io->Adc->Value, sizeof(uint16), 16000, oFile);
bStep++;
}
bStep=0;
fclose(oFile);
}
}
pruio_destroy(io);
return 0;
}


Greetings,
Nils Kohrs
--
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 beagleboard+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
William Hermans
2014-11-07 09:06:19 UTC
Permalink
Whew ! If you're looking for "fast", you're not going about it the right
way.

1) Nested loops are bad.

2) A file open, and close every cycle on the outer loop ? Is that really
necessary ? Big time performance hit.

3) spintf() as I recall is a fairly slow function.

A few things you can do to fix these issues.

Remove the nested loops and replace with a, if/else control block. Make the
conditions checks that are most likely to pass more often - first. Also,
simplify your math. If the numbers are going to be consistent, and non
changing. Hard code the values. Multiplication and division on fast moving
code will slow you down. Especially if done on floating point numbers. So
unless I missed an assignment somewhere . . .



*while(io->DRam[0] < (bStep+1) * bsSize && io->DRam[0] > bStep * bsSize)
{ ...}*

if bsStep which seems to be left unassigned ( 0 ) + 1 = 1

1 * <any value> is going to be that <any value> . . . Some compilers may
optimize this out, but why ? It also makes the code less readable.

Also . . .

*fwrite(io->Adc->Value, sizeof(uint16), 16000, oFile);*


Is a potential performance hit. Quite honestly I am not sure *if*
*sizeof(uint16)
*would be checked once at compile time, or if it would be checked every
cycle at run time. But you can "fix" this simply by hard coding the value.
Make it a constant if you feel it makes the code more readable.


Open the file once before the loop, and close it after the loop is done.
That is, if at all possible. Also there is a "trap for new players", in
that if the application exits abnormally, the file may still be left
opened. So a check when the application first starts may be in order.

As an aside, you can simplify the whole application by just gathering raw
data, and shifting it out to the the general purpose processor ( ARM ).
Which then the main processor can be made to do all the heavy math
"lifting".

Anyway I hope this is useful information, and my posting is not meant to
demean, or otherwise come across as "smart-ass".
Post by n***@public.gmane.org
Hey TJF,
I've got it compiled and working. I can't yet test if the adc keeps up
since I the function generator we've ordered got out of stock.... However I
changed my code a bit so it would close the files and the whole program has
a end statement. It's currently 1 channel at ~220 kS/s. I haven't pushed it
further because I don't know what will happen. With my understanding of the
PRU I guess the PRU can't break anything on the BBB while doing that, but I
don't know so I don't want to push my luck.
#include "unistd.h"
#include "stdio.h"
#include "../c_wrapper/pruio.h"
//! The main function.
int main(int argc, char **argv)
{
FILE* oFile;
uint8 bDiv = 4, bStep;
uint32 bSize = 1e6;
uint32 bsSize = bSize/bDiv;
uint8 cycles = 2;
char fName[12];
int i = 0;
pruIo *io = pruio_new(PRUIO_DEF_ACTIVE, 0x98, 0, 1); //! create new
driver structure
pruio_adc_setStep(io, 9, 4, 0, 0, 0); // step 9 for AIN-4
if (pruio_config(io, bSize, 1 << 9, 4545, 0)){ // '1 << 9' -> step 9,
'6285' ns -> 159.1 kHz
printf("config failed (%s)\n", io->Errr);}
else{
pruio_rb_start(io);
sleep(1);
for(i=0; i<cycles; i++){
sprintf(fName, "output.%u",i);
oFile = fopen(fName,"wb");
while(bStep<bDiv){
while(io->DRam[0] < (bStep+1) * bsSize && io->DRam[0] > bStep *
bsSize){
sleep(1);
}
printf("writing samples %u-%u\n",bStep*bsSize, (bStep+1)*bsSize);
fwrite(io->Adc->Value, sizeof(uint16), 16000, oFile);
bStep++;
}
bStep=0;
fclose(oFile);
}
}
pruio_destroy(io);
return 0;
}
Greetings,
Nils Kohrs
--
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
For more options, visit https://groups.google.com/d/optout.
--
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 beagleboard+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
n***@gmail.com
2014-11-07 09:56:12 UTC
Permalink
Thanks for the feedback. I know that I'm far from a good c programmer, but
I'm not that bad.

From reading the book "The C++ Programming Language" by Bjarne Stourstrup
(the maker of c++) I know a thing or two about the compiler.
First of, all sizeof(...) are replace at compile time. Secondly, all
operators that can be calculated at compile time will be calculated at
compile time. This makes the last two optimizations you suggest just
working with the code harder.

I don't know if you've runned this code your self already, but if you would
have noticed that the limiting part is the PRU coprocessor and not actually
the ARM processor itself.
With that in mind option 1 is just the flavor of code you choose.

About point 3: If you want to concatenate a integer to a string/char[]
there are two options. First you can convert the into to a char[] with
itoa() and then use strcat(), or you use the minimal slower spintf which is
more readable

And lastly about point 2, if you want to write it to multiple files, you'll
have to close the old one and open the new one every time you go on to the
next file.

This programs was for me to test the performance, and as you see from the
one seconds sleeps I've build into it, it runs fine and a lot faster than
it needs to be. Also from any of the examples included to libpruio you can
expect the reader not to just copy the code 1:1 and live happily ever
after. Everyone will edit it to their liking and performance needs. For me
this runs fine and error handling with the file io is something you can
implement your self, if you need it. This is example code and not
production code...

And on a last note, you've made me aware of a little error in my code
though, the line:

fwrite(io->Adc->Value, sizeof(uint16), 16000, oFile);

should be

fwrite(io->Adc->Value, sizeof(uint16), bsSize, oFile);

If you want to provide better sample code you're free to go, but please
don't be that smart-ass stating facts that are only half or not at all true.

Greetings,
Nils Kohrs
--
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 beagleboard+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
William Hermans
2014-11-08 10:29:53 UTC
Permalink
*If you want to provide better sample code you're free to go, but please
don't be that smart-ass stating facts that are only half or not at all
true.*
Ok, that is just plain rude.

So, since we're being rude now. I should mention the code you pasted is C
and not C++. I figured you should know this since you think you know
everything.

I will tell you what. You keep on trucking on, and nesting while loops 100
deep if you like, and I'll refrain from reading your posts any further to
keep my eyes from bleeding.
--
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 beagleboard+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
n***@gmail.com
2014-11-10 12:48:18 UTC
Permalink
Hey TJF,

I wanted to give you a heads up on my samplecode. The performance test was
right in that is was that exact performance, but I shouldn't write a
program in c when I'm sleepy.
The program had some functional problems which should be fixed now.
However, I'll first test it with a function generator to make sure that the
code is indeed working as expected. If everything is working fine I'll post
it here and you should be able to use it as c samplecode.

Greetings,
Nils Kohrs
--
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 beagleboard+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
TJF
2014-11-10 13:05:15 UTC
Permalink
Hello Nils,

I just had a closer look at your first example. Sorry, I've new concerns.
It seems that the code requires to customize the size of the external
memory, which is a downside for beginners. And it doesn't show the ring
buffer capabilities (, you could have used MM mode as well).

From my point of view the strange of RB mode is that you can fetch any
number of samples with any size of the external memory. And the example
should demonstrate that point.

So for the FreeBASIC folder I created a new example called rb_file.bas

/'* \file rb_file.bas
\brief Example: fetch ADC samples in a ring buffer and save to file.

This file contains an example on how to use the ring buffer mode of
libpruio. A fixed step mask of AIN-0, AIN-4 and AIN-7 get sampled and
saved as raw data to some files.

Licence: GPLv3

Copyright 2014 by Thomas{ dOt ]Freiherr[ At ]gmx[ DoT }net


Compile by: `fbc -w all rb_file.bas`

\since 0.2
'/

' include libpruio
#INCLUDE ONCE "../pruio/pruio.bi"

CONST tSamp = 123401 _ '*< The number of samples in the files (per step).
, tmr = 5000 _ '*< The sampling rate in ns (5000 -> 200 kHz).
, NoStep = 3 _ '*< The number of active steps (must match setStep
calls and mask).
, NoFile = 2 _ '*< The number of files to write.
, NamFil = "output." '*< The output file names.

VAR io = NEW PruIo() '*< Create a PruIo structure, wakeup subsystems.

WITH *io
DO
IF .Errr THEN ?"NEW failed: " & *.Errr : EXIT DO

IF .Adc->setStep( 9, 0, 0, 0, 0) THEN _
?"step 9 configuration failed: " & *.Errr : EXIT DO
IF .Adc->setStep(10, 1, 0, 0, 0) THEN _
?"step 10 configuration failed: " & *.Errr : EXIT DO
IF .Adc->setStep(11, 2, 0, 0, 0) THEN _
?"step 11 configuration failed: " & *.Errr : EXIT DO

VAR mask = &b111 SHL 9 _ '*< The active steps (9 to 11).
, tInd = tSamp * NoStep _ '*< The maximum total index.
, half = ((.ESize SHR 2) \ NoStep) * NoStep '*< The maximum index of
the half ring buffer.

IF half > tInd THEN half = tInd ' adapt size for small files
VAR samp = (half SHL 1) \ NoStep '*< The number of samples (per step).

IF .config(samp, mask, tmr, 0) THEN _ ' configure driver
?"config failed: " & *.Errr : EXIT DO

IF .rb_start() THEN _ ' start ring buffer mode
?"rb_start failed: " & *.Errr : EXIT DO

VAR p0 = .Adc->Value _ '*< A pointer to the start of the ring
buffer.
, p1 = p0 + half '*< A pointer to the middle of the
ring buffer.
FOR n AS INTEGER = 0 TO NoFile - 1
VAR fnam = NamFil & n, fnr = FREEFILE
IF OPEN(fnam FOR OUTPUT AS fnr) THEN
?"Cannot open " & fnam
ELSE
?"Creating file " & fnam
VAR i = 0 '*< Start index.
WHILE i < tInd
i += half
IF i > tInd THEN ' fetch the rest (no complete chunk)
VAR rest = tInd + half - i _
, iEnd = IIF(p1 >= p0, rest, rest + half)
WHILE .DRam[0] < iEnd : SLEEP 1 : WEND
?" writing samples " & (tInd - rest) & "-" & (tInd - 1)
PUT #fnr, , *p0, rest
SWAP p0, p1 : EXIT DO
END IF

IF p1 > p0 THEN WHILE .DRam[0] < half : SLEEP 1 : WEND _
ELSE WHILE .DRam[0] > half : SLEEP 1 : WEND
?" writing samples " & (i - half) & "-" & (i - 1)
PUT #fnr, , *p0, half
SWAP p0, p1
WEND
?"Finished file " & fnam
CLOSE #fnr
END IF
NEXT
LOOP UNTIL 1
IF .Errr THEN SLEEP
END WITH

DELETE(io)

'' help Doxygen to dokument the main code
'&/** The main function. */
'&int main() {PruIo::PruIo(); AdcUddt::setStep(); PruIo::config();
PruIo::~PruIo();}

Do you like to translate that code to C to include it in the libpruio
package? If so, please add a file header with your copyright notes.

BR
--
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 beagleboard+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
TJF
2014-11-10 13:10:04 UTC
Permalink
Oups, found a buck right when I posted:

line 70
SWAP p0, p1 : EXIT DO

should be
SWAP p0, p1 : EXIT WHILE

Soory!
--
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 beagleboard+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
William Hermans
2014-11-10 20:52:18 UTC
Permalink
TJF,

I'd be willing at some point to help you port some code for your project,
Do you have a quick setup guide for your library ? I did read some of your
documents a couple months ago, but then i got busy with many other things .
. . such is life.

Other problem is that I am not exactly a hardware person so much as a
software developer, and I am semi new to embedded Linux. The new to embeded
Linux part shouldnt be too much of a problem, just means I need to read up
on the libc functions available to me. Not being an EE however slows me
down greatly however, since I do not want to fry my boards . . .

As an aside, I must have really really become accustomed to C over the last
several years, BASIC syntax hurts my eyes, lol but it was the very first
language I picked up 17+ years ago . . .
Post by TJF
line 70
SWAP p0, p1 : EXIT DO
should be
SWAP p0, p1 : EXIT WHILE
Soory!
--
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
For more options, visit https://groups.google.com/d/optout.
--
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 beagleboard+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
TJF
2014-11-11 13:06:08 UTC
Permalink
Post by William Hermans
TJF,
I'd be willing at some point to help you port some code for your project,
Hello William, welcome at the libpruio project.

I know about many tasks to improve the libpruio package. Some of them might
be fun for you.
Post by William Hermans
Do you have a quick setup guide for your library ?
Find the installation guide in the documentation at page Preparation
<http://users.freebasic-portal.de/tjf/Projekte/libpruio/doc/html/_cha_preparation.html>
.

Could you check the documentation text? It seems that you're a native
speaker with good language skills. You should be able to improve the text a
lot. (I could mail a pdf version, where you could add your comments.)
Post by William Hermans
Other problem is that I am not exactly a hardware person so much as a
software developer, and I am semi new to embedded Linux. The new to embeded
Linux part shouldnt be too much of a problem, just means I need to read up
on the libc functions available to me. Not being an EE however slows me
down greatly however, since I do not want to fry my boards . . .
I'm neither an electronics engineer, nor a programmer, nor an expert on
embedded systems, nor a native speaker. I think I realy know what you're
talking about.

I'm looking at the project from the user point of view, evaluating how
things should work and then do my best to make this happen. And, knowing
there's no perfect solution, I try to learn from my failures.
Post by William Hermans
As an aside, I must have really really become accustomed to C over the
last several years, BASIC syntax hurts my eyes, lol but it was the very
first language I picked up 17+ years ago . . .
Basic isn't the first programming language I used, but for me it's the most
productive. I'm not speaking about the m$ dialects, which I dislike as
well, and which I don't use since the middle 80's. (AFAIR QB 4.5 was the
last one I tested and droped.) But there're other dialects, which are in
some points more powerful than C, and easier to read for my old eyes.

The libpruio package contains some examples, as you can see at this
documentation page
<http://users.freebasic-portal.de/tjf/Projekte/libpruio/doc/html/_cha_examples.html>.
I think all code in folder src/c_examples could have a review. But most
important, there're some examples with grafics output

- pwm_adc.bas,
- osci.bas,
- rb_oszi.bas, and
- triggers.bas

which I didn't translate to C code jet. My idea was to use cairo grafics
library, but there might be a more common way to create short and easy C
code?

Note: libpruio examples should be easy to understand for beginners and
should have less than 200 lines of code.

Feel free to send further colaboration ideas and discuss details (here or
PM). Or just make your choice and start.

BR
--
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 beagleboard+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
William Hermans
2014-11-11 18:33:22 UTC
Permalink
Back in the early to mid 80's I was living in Kitzingen,Germany, and I was
young. If you catch my meaning.

But anyway, I am still a bit busy, but perhaps in my spare time I can read
your documentation a bit at a time to be used to it. It is something I've
been wanting to do for a while now . . .
Post by TJF
Post by William Hermans
TJF,
I'd be willing at some point to help you port some code for your project,
Hello William, welcome at the libpruio project.
I know about many tasks to improve the libpruio package. Some of them
might be fun for you.
Post by William Hermans
Do you have a quick setup guide for your library ?
Find the installation guide in the documentation at page Preparation
<http://users.freebasic-portal.de/tjf/Projekte/libpruio/doc/html/_cha_preparation.html>
.
Could you check the documentation text? It seems that you're a native
speaker with good language skills. You should be able to improve the text a
lot. (I could mail a pdf version, where you could add your comments.)
Post by William Hermans
Other problem is that I am not exactly a hardware person so much as a
software developer, and I am semi new to embedded Linux. The new to embeded
Linux part shouldnt be too much of a problem, just means I need to read up
on the libc functions available to me. Not being an EE however slows me
down greatly however, since I do not want to fry my boards . . .
I'm neither an electronics engineer, nor a programmer, nor an expert on
embedded systems, nor a native speaker. I think I realy know what you're
talking about.
I'm looking at the project from the user point of view, evaluating how
things should work and then do my best to make this happen. And, knowing
there's no perfect solution, I try to learn from my failures.
Post by William Hermans
As an aside, I must have really really become accustomed to C over the
last several years, BASIC syntax hurts my eyes, lol but it was the very
first language I picked up 17+ years ago . . .
Basic isn't the first programming language I used, but for me it's the
most productive. I'm not speaking about the m$ dialects, which I dislike as
well, and which I don't use since the middle 80's. (AFAIR QB 4.5 was the
last one I tested and droped.) But there're other dialects, which are in
some points more powerful than C, and easier to read for my old eyes.
The libpruio package contains some examples, as you can see at this
documentation page
<http://users.freebasic-portal.de/tjf/Projekte/libpruio/doc/html/_cha_examples.html>.
I think all code in folder src/c_examples could have a review. But most
important, there're some examples with grafics output
- pwm_adc.bas,
- osci.bas,
- rb_oszi.bas, and
- triggers.bas
which I didn't translate to C code jet. My idea was to use cairo grafics
library, but there might be a more common way to create short and easy C
code?
Note: libpruio examples should be easy to understand for beginners and
should have less than 200 lines of code.
Feel free to send further colaboration ideas and discuss details (here or
PM). Or just make your choice and start.
BR
--
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
For more options, visit https://groups.google.com/d/optout.
--
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 beagleboard+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
TJF
2014-11-11 19:04:00 UTC
Permalink
Post by William Hermans
Back in the early to mid 80's I was living in Kitzingen,Germany, and I was
young. If you catch my meaning.
A "Franke", I see. Most of my mess mates were coming from the WÃŒrzburg and
Aschaffenburg area.

Your surname sounds German. I'm not living in Germany any more. I moved to
the "Schluchtenscheißers".

But anyway, I am still a bit busy, but perhaps in my spare time I can read
Post by William Hermans
your documentation a bit at a time to be used to it. It is something I've
been wanting to do for a while now . . .
May I send (private mail) a pdf version of the documentation? You could
add notes to that document to improve the text.
--
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 beagleboard+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
William Hermans
2014-11-11 19:14:32 UTC
Permalink
Sure. However I am afraid my German reading skills ( translation ) are
terrible now days. I will do what I can.
Post by TJF
Post by William Hermans
Back in the early to mid 80's I was living in Kitzingen,Germany, and I
was young. If you catch my meaning.
A "Franke", I see. Most of my mess mates were coming from the WÃŒrzburg and
Aschaffenburg area.
Your surname sounds German. I'm not living in Germany any more. I moved to
the "Schluchtenscheißers".
But anyway, I am still a bit busy, but perhaps in my spare time I can read
Post by William Hermans
your documentation a bit at a time to be used to it. It is something I've
been wanting to do for a while now . . .
May I send (private mail) a pdf version of the documentation? You could
add notes to that document to improve the text.
--
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
For more options, visit https://groups.google.com/d/optout.
--
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 beagleboard+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
e***@gmail.com
2014-11-14 00:08:42 UTC
Permalink
Hey,

I'm trying to match the below modification in my version of libpruio, but
while compiling I run into the following

ld: pruio.o: relocation R_ARM_THM_MOVW_ABS_NC against `a local symbol' can
not be used when making a shared object; recompile with -fPIC

and I'm not sure how to get past it. I -think- that I have the freebasic
compiler running correctly. Any advice would be welcome.

Thanks,
Michael Todd
Post by TJF
Hello Nils,
thanks for the code. I think about including it in the libpruio examples
folder, but your main loop is endless and the user cannot abort the
program. (Shouldn't the file get closed?) Perhaps I can adapt it a bit.
Regarding the ADC speed I made some further testing and it seems that I
mis-interpreted the TRM. The ADC subsystem can sample at least at 200 kS/s.
This speed also works for multiple channels. Find an example of four
channels at 44.1 kHz in this post
<http://beagleboard.org/Community/Forums?place=msg%2Fbeagleboard%2F3AFiCNtxGis%2FH7q76xdk8ZQJ>.
An overall sampling rate of 200 kHz was also possible (four channels).
So the limiting in the current libpruio-0.2 is too much on the safe site.
If you don't want to wait for the next version, you can adapt the code by
yourself (FreeBASIC compiler required). Replace in file pruio_adc.bas in
function PruIo.configure(...) the lines
d *= (Conf->ADC_CLKDIV + 1) * 417 '417 ≈ 1000000 / 2400 (= 1 GHz /
2.4 MHz)
d += 30 ' PRU cycles for restart [GHz]
by the following code
d = (d * (Conf->ADC_CLKDIV + 1) * 1000) \ 24
IF Tmr <= d ORELSE Tmr < 5000 THEN _
You may play a bit with the absolute value 5000. On my BBB the timing is
OK up to a frequency of 240 kHz (4165). But this may vary from board to
board.
--
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 beagleboard+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
TJF
2014-11-14 14:19:01 UTC
Permalink
Hi Michael,
Post by e***@gmail.com
Hey,
I'm trying to match the below modification in my version of libpruio, but
while compiling I run into the following
ld: pruio.o: relocation R_ARM_THM_MOVW_ABS_NC against `a local symbol' can
not be used when making a shared object; recompile with -fPIC
and I'm not sure how to get past it. I -think- that I have the freebasic
compiler running correctly. Any advice would be welcome.
Thanks,
Michael Todd
if you want to compile with the old (experimental) BBB-fbc-0.90 you'll have
to use the old build scripts included in libpruio-0.0.x.

But I recommend to install the new BBB_fbc-1.00, which I also use on my
board now. Just follow the instructions in (only point 1)

http://users.freebasic-portal.de/tjf/Projekte/libpruio/doc/html/_cha_preparation.html#SecInstallation

BR
--
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 beagleboard+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
a***@gmx.de
2015-03-05 11:54:53 UTC
Permalink
Post by TJF
But I recommend to install the new BBB_fbc-1.00, which I also use on my
board now. Just follow the instructions in (only point 1)
http://users.freebasic-portal.de/tjf/Projekte/libpruio/doc/html/_cha_preparation.html#SecInstallation
Hello TJF,

thanks for librpuio and the effort you spent for this.

I followed the instructions on the side above, but still can not compile
the FB examples:

- I run a BBB with a very new Debian Linux image.
- I installed everything according the documentation on the above link.
- fbc is working:
fbc -version
FreeBASIC Compiler - Version 1.01.0 (10-14-2014), built for linux-arm
(32bit) Copyright (C) 2004-2014 The FreeBASIC development team.

However, compiling an FB example yields:
libpruio-0.2/src/examples# fbc -w all analyse.bas
/usr/local/include/freebasic/BBB/prussdrv.bi(56) error 23: File not found,
"crt/sys/types.bi" in '#INCLUDE ONCE "crt/sys/types.bi" '__HEADERS__:
sys/types.h'

- I have searched my system manually for "types.bi", but there is none.

Do you have any suggestions what might be missing to compile the libpruio
FB examples?
Btw. The C-examples can be compiled without errors.

Thanks.
--
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 beagleboard+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Jelena Freiherr
2015-03-05 19:41:18 UTC
Permalink
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hallo Herr Vogelfrei,

ich hoffe, dass eine deutschsprachige Antwort in Ihrem Sinne ist und
bedanke mich für das Interesse an libpruio.
However, compiling an FB example yields: libpruio-0.2/src/examples#
fbc -w all analyse.bas
/usr/local/include/freebasic/BBB/prussdrv.bi(56) error 23: File not
found, "crt/sys/types.bi" in '#INCLUDE ONCE "crt/sys/types.bi"
'__HEADERS__: sys/types.h'
- I have searched my system manually for "types.bi", but there is none.
Do you have any suggestions what might be missing to compile the
libpruio FB examples?
Bitte beachten Sie folgenden Satz auf der deutschen Downlaodseite:

Diese fbc Version ist nicht vollständig. Fehlende Dateien, z. B.
Header oder Beispiele, können aus dem GIT Repository bezogen und
nachinstalliert werden.

Mittlerweile habe ich auch ein Debian Paket erstellt, welches die
Installation vereinfachen soll. Dieses ist hier zu finden:

http://www.freebasic-portal.de/downloads/fb-on-arm/debian-package-fbc-1-01-357.html

Da ich bisher keine Zeit hatte das Paket zu testen, würde ich mich
über Ihre Rückmeldung sehr freuen. (Bitte beachten: das Paket
installiert in /usr, nicht in /usr/local. Ggf. vorhandene Dateien und
Ordner in /usr/local vor der Installation löschen.)

MfG


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iEYEARECAAYFAlT4sV4ACgkQiYQAalShlZ/z8QCgiHg31ijqnDngqyWimYSnX7Gm
wGoAnjgc9twRUAjqlDt0Np75dTwhzHM3
=GitI
-----END PGP SIGNATURE-----
--
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 beagleboard+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
a***@gmx.de
2015-03-06 10:38:46 UTC
Permalink
[SOLVED]

Hello TJF,

I will answer in English to give other users the possibility to use this
information as well.

Thank you for your answer. With this information I was able to compile the
supplied libpruio FreeBASIC examples.

Steps to take (on the BeagleBone, as root, otherwise use 'sudo'):

1.) wget
http://www.freebasic-portal.de/dlfiles/625/freebasic_1.01.0debian7_armhf.deb
2.) dpkg --install freebasic_1.01.0debian7_armhf.deb
(Note: On
http://www.freebasic-portal.de/downloads/fb-on-arm/debian-package-fbc-1-01-357.html

you type: freebasic_1.01.0~debian7_armhf.deb which make copy
and paste from the website resulting in an error)
3.) apt-get -f install
4.) rm /usr/local/bin/fbc
5.) reboot
6.) cp -R /usr/local/include/freebasic/BBB /usr/include/freebasic/

After this, compiling fbc -w all analyse.bas works.

Thank you.
--
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 beagleboard+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
TJF
2015-03-06 22:47:32 UTC
Permalink
Thanks for feedback!

BR
--
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 beagleboard+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...