eCAP reading a PWM signal, someone has made this functionality works?

184 views
Skip to first unread message

Fabio Luis Girardi

unread,
Mar 29, 2021, 4:14:59 PM3/29/21
to BeagleBoard
Hi all!

After spending a lot of days trying to make eCAP modules to read (not generate as everyone does) a PWM signal (period+duty cycle), I have to ask:

Someone has made this functionality works? Can be via sysfs, via PRU program handling the register, via CPU program handling the registers, or any other method?

If yes, can give me an example or the environment details? 

PS: eCAP module is the most undocumented function of Beaglebone...

Best regards,

Fabio

TJF

unread,
Mar 30, 2021, 11:14:23 PM3/30/21
to BeagleBoard
Hi Fabio!

You're correct, eCAP is pretty much undocumented and unsupported.

Find examples in the libpruio project at


and


The first example measures a pulse train generated by a PWM subsystem output (31 kHz), and the second measures a pulse train generated by PRU firmware (20 MHz).

Regards

set_

unread,
Mar 31, 2021, 2:29:16 AM3/31/21
to BeagleBoard
Hello,

Adafruit_BBIO has some type of example plus the library has its source: https://github.com/adafruit/adafruit-beaglebone-io-python/tree/master/Adafruit_BBIO#usage

Seth

Drew Fustini

unread,
Mar 31, 2021, 2:37:17 AM3/31/21
to Beagle Board, Darren Schachter, Robert Nelson
We had an awesome university student Darren Schachter participating in
Major League Hacking [1] last summer write a eCAP kernel driver for
the iio subsystem [2]. It has progressed beyond the initial review
but you should find it to be useful.

Robert - are you building that driver in our beaglebone kernel?

Thanks,
Drew

[1] https://mlh.io/
[2] https://lore.kernel.org/linux-iio/2020081815361...@cornell.edu/

Drew Fustini

unread,
Mar 31, 2021, 2:38:29 AM3/31/21
to Beagle Board, Darren Schachter, Robert Nelson
On Tue, Mar 30, 2021 at 11:36 PM Drew Fustini <pdp7...@gmail.com> wrote:
>
> On Mon, Mar 29, 2021 at 1:15 PM Fabio Luis Girardi
> <papelhi...@gmail.com> wrote:
> >
> > Hi all!
> >
> > After spending a lot of days trying to make eCAP modules to read (not generate as everyone does) a PWM signal (period+duty cycle), I have to ask:
> >
> > Someone has made this functionality works? Can be via sysfs, via PRU program handling the register, via CPU program handling the registers, or any other method?
> >
> > If yes, can give me an example or the environment details?
> >
> > PS: eCAP module is the most undocumented function of Beaglebone...
> >
> > Best regards,
> >
> > Fabio
>
> We had an awesome university student Darren Schachter participating in
> Major League Hacking [1] last summer write a eCAP kernel driver for
> the iio subsystem [2]. It has progressed beyond the initial review
> but you should find it to be useful.

*It has _not_ progressed beyond the initial review [..]

sorry for the typo,
drew

Darren Schachter

unread,
Mar 31, 2021, 10:55:56 AM3/31/21
to Drew Fustini, Beagle Board, Robert Nelson
Hi there,

As Drew mentioned, I worked on a driver for eCAP support last summer.
I submitted a preliminary patch to mainline Linux for this driver and
received some feedback. Unfortunately, around that time, my classes
started again and things got very busy so I have not yet had a chance
to implement the requested changes. However, the driver itself is
fully functional -- the feedback mostly centered around formatting /
adopting newer Linux IIO standards. I hope that the driver code is
still useful. Please feel free to reach out to me if you have any
questions about it.

Best,
Darren

Dennis Lee Bieber

unread,
Mar 31, 2021, 11:51:36 AM3/31/21
to Beagleboard
On Tue, 30 Mar 2021 23:29:16 -0700 (PDT), in
gmane.comp.hardware.beagleboard.user set_
<functt-Re5JQEe...@public.gmane.org> wrote:

>Hello,
>
>Adafruit_BBIO has some type of example plus the library has its
>source: https://github.com/adafruit/adafruit-beaglebone-io-python/tree/master/Adafruit_BBIO#usage
>

The eQEP is a different creature from eCAP.

eQEP is to read quadrature encoded inputs (rotary knobs producing two
step waveforms in which the changes between the two identifies which
direction the knob is rotating, and how far it has been turned). From the
BBB TRM (SPRUH73P)
"""
15.4.1 Introduction
A single track of slots patterns the periphery of an incremental encoder
disk, as shown in Figure 15-130. These slots create an alternating pattern
of dark and light lines. The disk count is defined as the number of
dark/light line pairs that occur per revolution (lines per revolution). As
a rule, a second track is added to generate a signal that occurs once per
revolution (index signal: QEPI), which can be used to indicate an absolute
position. Encoder manufacturers identify the index pulse using different
terms such as index, marker, home position, and zero reference.
"""

eCAP is, as the TRM describes it
"""
15.3.1.1 Purpose of the Peripheral
Uses for eCAP include:
• Sample rate measurements of audio inputs
• Speed measurements of rotating machinery (for example, toothed sprockets
sensed via Hall sensors)
• Elapsed time measurements between position sensor pulses
• Period and duty cycle measurements of pulse train signals
• Decoding current or voltage amplitude derived from duty cycle encoded
current/voltage sensors
"""

>On Monday, March 29, 2021 at 3:14:59 PM UTC-5 papelhi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:
>
>> Someone has made this functionality works? Can be via sysfs, via PRU
>> program handling the register, via CPU program handling the registers, or
>> any other method?
>>
>> If yes, can give me an example or the environment details?
>>
So far the best I've located is some 7 years old:
https://linux-arm-kernel.infradead.narkive.com/zeEA4MIa/patch-v3-0-6-iio-pulse-capture-support-for-ti-ecap

It appears your question was asked some two years ago at:
https://github.com/adafruit/adafruit-beaglebone-io-python/issues/306

{which sort of implies the previous effort was never really completed}


--
Dennis L Bieber

Drew Fustini

unread,
Mar 31, 2021, 4:29:35 PM3/31/21
to Beagle Board
To clarify for anyone finding this thread in the future.

eQEP (encoder input) driver is in mainline Linux kernel thanks to David Lechner:
https://elixir.bootlin.com/linux/latest/source/drivers/counter/ti-eqep.c

eCAP (pulse input) driver is available as patch posted by Darren
Schachter that is known to work:
https://lore.kernel.org/linux-iio/2020081815361...@cornell.edu/

-Drew

TJF

unread,
Apr 1, 2021, 5:15:32 AM4/1/21
to BeagleBoard
... and - to be complete - that proven eCAP + eQEP features - well documented (including example code) and with similar programming interfaces (not changing in new kernels) - are available in libpruio since years at
https://github.com/DTJF/libpruio
Reply all
Reply to author
Forward
0 new messages