PWM generation using libpruio

I want to use for PWM generation to control servo motor. The problem i m facing is :

To enable libpruio i m using this dts file
https://github.com/jadonk/cape-firmware/blob/master/arch/arm/boot/dts/BB-BONE-PRU-01-00A0.dts

To enable the pwm pin i m using cape-universaln
https://github.com/cdsteinkuehler/beaglebone-universal-io/blob/master/cape-universaln-00A0.dts

These both files are kind of conflicting with each other as if one is loaded to slots then other is not loading.

If i do not load the cape-universaln i m not able to export the pwm pins.

Any help appreciated.

Are you using a recent Beagleboard image? Beaglebone?

I haven’t used libpruio, but I assume it uses the UIO kernel driver.
First, you will need to activate that driver.

This utility will help get it done:

https://github.com/RobertCNelson/dtb-rebuilder

You will need to clone the above to your board and make 2 very easy changes to text files.
Then you have to run the script in the above and re-boot.
Can perhaps guide you but need to know which kernel and which board you are using.
I didn’t have to do anything to the Device tree for Remoteproc and PWM. Hopefully the same
will be true for UIO.

Regarding the PWM, once again, have to assume you are using a recent Debian image.
The version 4 kernels require some steps to get the PWM exported.
I did this just a few days ago, and got it to work. You need to look for:

/sys/class/pwm/pwmchip0

You need to export by something like:

echo 0 > export

Or it could be other numbers depending on which PWM.

I haven’t found a concise reference for the above process, and how the export number maps to the particular PWM.
Perhaps someone else can point us to a good reference guide for this process.

Greg

Hi!

I want to use for PWM generation to control servo motor. The problem i m facing is :

To enable libpruio i m using this dts file
https://github.com/jadonk/cape-firmware/blob/master/arch/arm/boot/dts/BB-BONE-PRU-01-00A0.dts

To enable the pwm pin i m using cape-universaln
https://github.com/cdsteinkuehler/beaglebone-universal-io/blob/master/cape-universaln-00A0.dts

These both files are kind of conflicting with each other as if one is loaded to slots then other is not loading.

AFAIR cape-universal enables all subsystems, including the PRUSS. So you don’t need BB-BONE-PRU-01.

If i do not load the cape-universaln i m not able to export the pwm pins.

You need not export any pins when using libpruio. Just disable cape-universaln and load libpruio overlay instead. This has the same pinmuxing capabilities and will enable the PRUSS (just PRUSS, not all the other subsystems, in order to save power). For testing and in the development phase, you run your application with sudo (for pinmuxing). When finished, separate the configuration part from your source, add a line ‘io->Init = io->Conf’ after configuration and before deleting the libpruio instance, and compile it, in order to execute it in system init (for fixed pinmuxing). Then your app can run without root privileges. (Or use dts_custom.bas to create your customized device tree.)

Regards

PS:
Recent images don’t support libpruio at all.
libpruio-0.2.2 is designed for kernel 3.8. It needs adaption for newer kernel versions. In kernel 4.x, PWMSS->ehrPWM generated PWM signals don’t work. So it’s best to stay with the latest 3.8 for now.

Break out your PWM on to a PIC16Fx (using it crystal-controlled with software-based PWM by counting the clock cycles per instruction) and then use UART to control it.

An alternative fix, but it does give you nice isolation in the process.

Depending on how powerful your servos are, you might have to 2 or 3 stage it with SSR’s (solid state relay chips) or direct to MOSFET (Irfz24N is a nice cheap one, and use some beefy fast rectifiers going backward to null out the inductive blowback from the coils on stop).

Hobby servos can be controlled direct from a standard TTL level output btw.