pigpio icon indicating copy to clipboard operation
pigpio copied to clipboard

feature request: increase number of allowed loops in gpioWaveChain

Open kektobiologist opened this issue 4 years ago • 6 comments

Right now there is a hard limit of 20 loop counters (as per documentation) in a wave chain I am trying to create a ramp pulse input with ~100 square waves of 10 ms duration each of increasing frequencies (5000us pulse width to 10us pulse width), however the library only allows 20 loop counters (so 20 waves) at most. Is this a hardware limitation or can it be changed? In the code I can see the limit is defined as

#define WCB_COUNTERS (WCB_CNT_PER_PAGE * PI_WAVE_COUNT_PAGES)

where WCB_CNT_PER_PAGE is 2 and PI_WAVE_COUNT_PAGES is 10 Any help would be appreciated. EDIT: changed wording to make it clearer

kektobiologist avatar Sep 09 '20 17:09 kektobiologist

Where are you seeing this limitation? The documentation, as I read it, shows a loop count of

loop x + y*256 times

is possible. Both x, y are 8-bit integers.

guymcswain avatar Sep 10 '20 00:09 guymcswain

sorry i meant loop counters, not loop count

The code is currently dimensioned to support a chain with roughly 600 entries and 20 loop counters.

i.e. i can have only 20 loop blocks in the chain, having more throws PI_CHAIN_COUNTER

kektobiologist avatar Sep 10 '20 00:09 kektobiologist

Ok, thanks for clarifying. The limitation may be due to the allocated dma control blocks in memory which may have been arbitrary when @joan2937 implemented the code. Even if it is, to change it could require a fairly involved effort.

Also, you may want to check if sending waves synchronously, each with 20 loop counters, is workable for your application. You would only need to monitor the wave status and send another wave every 200ms (if I'm understanding your requirement).

guymcswain avatar Sep 10 '20 01:09 guymcswain

Thank you. I'm up for contributing if @joan2937 thinks this is worthwhile, or I'd like to know if there's another way around this.

kektobiologist avatar Sep 10 '20 01:09 kektobiologist

I couldn't find any documentation related to sending synchronous wave chains. Do you mean using wave_send_using_mode(PIN, pigpio.WAVE_MODE_ONE_SHOT_SYNC) to send individual waves?

kektobiologist avatar Sep 15 '20 14:09 kektobiologist

Yes. But now that I think about it, you would have to send each individual wave. If they are 10ms long and your network isn't slow, you should be able to keep up using gpiowavetxat to know when the next wave is playing.

guymcswain avatar Sep 15 '20 16:09 guymcswain