I have a first DRAFT version for the Pico PIO implementation of the PicoCapturePIO capturing class for my Arduino Logic Analyzer Library ready and started to run some tests.

The Test Sketch is part of the project and can be found in the examples forlder.

I was using a PWM signal with a duty cycle of 60% in order to be able verify the measuring.

Here are my results:

Capturing in a loop with micros() delays

In my standard implementation I was doing the capturing in a simple loop and used some delays to measure at different frequencies:

testing 50000 -> 52339.48 using delay microsec 19 duty cycle: 59.91 => OK 
testing 100000 -> 104471.05 using delay microsec 9 duty cycle: 59.89 => OK 
testing 200000 -> 247247.77 using delay microsec 4 duty cycle: 59.92 => OK 
testing 300000 -> 494488.09 using delay microsec 2 duty cycle: 59.86 => OK 
testing 400000 -> 630186.63 using delay microsec 1 duty cycle: 60.02 => OK 
testing 500000 -> 630277.56 using delay microsec 1 duty cycle: 59.88 => OK 
testing 600000 -> 654316.19 using delay microsec 0 duty cycle: 59.97 => OK 
testing 700000 -> 654512.25 using delay microsec 0 duty cycle: 59.98 => OK 

We can measure up to 654’316 Hz.

Capturing in a loop w/o delays

A simple loop w/o delays will run much faster:

testing max speed 
time us:26126.00
sample count:65535
max speed: 2508420.75

We can measure up to 2’508’420 Hz !

Capturing with the PIO

Here are the results using the new PicoCapturePIO class:

testing 50000 -> 50109.30 hz / divider: 2494.69 duty cycle: 59.91 => OK 
testing 100000 -> 100218.22 hz / divider: 1247.34 duty cycle: 59.89 => OK 
testing 200000 -> 200434.30 hz / divider: 623.67 duty cycle: 59.97 => OK 
testing 300000 -> 300652.38 hz / divider: 415.78 duty cycle: 59.99 => OK 
testing 400000 -> 400869.81 hz / divider: 311.84 duty cycle: 59.87 => OK 
testing 500000 -> 501085.75 hz / divider: 249.47 duty cycle: 59.97 => OK 
testing 600000 -> 601293.69 hz / divider: 207.89 duty cycle: 59.89 => OK 
testing 700000 -> 701516.81 hz / divider: 178.19 duty cycle: 59.71 => OK 
testing 800000 -> 801749.44 hz / divider: 155.92 duty cycle: 59.87 => OK 
testing 900000 -> 901940.56 hz / divider: 138.59 duty cycle: 60.38 => OK 
testing 1000000 -> 1002171.50 hz / divider: 124.73 duty cycle: 59.96 => OK 
testing 10000000 -> 10020642.00 hz / divider: 12.47 duty cycle: 57.39 => OK 
testing 20000000 -> 20041284.00 hz / divider: 6.24 duty cycle: 65.35 => ERROR
testing 30000000 -> 30048144.00 hz / divider: 4.16 duty cycle: 62.45 => OK 
testing 40000000 -> 40082568.00 hz / divider: 3.12 duty cycle: 60.45 => OK 
testing 50000000 -> 50064936.00 hz / divider: 2.49 duty cycle: 83.66 => ERROR
testing 60000000 -> 60123852.00 hz / divider: 2.08 duty cycle: 99.98 => ERROR
testing 100000000 -> 100206424.00 hz / divider: 1.25 duty cycle: 99.98 => ERROR

The effective frequencies are much closer to the requested measuring frequencies – which is a good thing! We can also achieve quite some high frequencies – but the measuring results seem to be getting very wrong at very high speeds.

I think that the test PWM signal has just a frequency which is too low: So if we measure at full speed we are not able to capture and store a full cycle because we run out of memory too quick.

So to test this properly I will need to adjust the frequency of the test signal dependent on the measuring frequency. Unfortunately there is standard Arduino API for this…


0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published.