Clue Board Speed

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
ingtommy
 
Posts: 3
Joined: Sun Sep 18, 2022 5:23 am

Clue Board Speed

Post by ingtommy »

Hello
I am experimenting with the CLUE board and part of my project includes a Hall Sensor to measure RPMs of a pulley.
I am using the countio library ... can the CLUE Board measure frequencies from 150 to 300Hz? Basically I need to measure impulses less than 5 milliseconds apart and perform some operations in between ..

Is the Clue Board on Circuitpython fast enough to do this ?

Thank you

User avatar
dastels
 
Posts: 15659
Joined: Tue Oct 20, 2015 3:22 pm

Re: Clue Board Speed

Post by dastels »

The countio module is implemented in C as part of the CircuitPython runtime and is interrupt driven, so I suspect it will be fine at those low frequencies.

Dave

User avatar
ingtommy
 
Posts: 3
Joined: Sun Sep 18, 2022 5:23 am

Re: Clue Board Speed

Post by ingtommy »

Thank you Dave for your answer

I am afraid there is something I am not considering.

Usual RPM sensors works on an interrupt timer, measuring the incoming impulses in a defined time spam.
Since we're interested in the cinematic of the pulley, we have a different measurement cycle:
when pin counter increases by one, we execute some logic operations related to the timestamps available and then we get back to listening to the pin counter.
Pin counter increase with a frequency of maximum 300 Hz and it seems like the Clue Board is only supporting this cycle up until barely 40-50Hz.
Basically we need the cycle to be over in less than 4 milliseconds, and it does not seems like we're making it.

This is how we tested the board, trying to minimise code lines and optimise processing speed:
we generated a square signal with a designed frequency (we tried 10-40-50-60-100-200Hz) and we input the signal in pin D6.
Pin counter is working with pin D6, then driving the output signal (that we're listening) on Pin D8.

The output signal is pretty irregular and can't keep up with the input frequency after 40Hz.

Code right here:

Code: Select all

import board
import countio
import time
from adafruit_clue import clue
import digitalio

pin_counter = countio.Counter(board.D6, edge=countio.Edge.RISE)
led = digitalio.DigitalInOut(board.D8)
led.direction = digitalio.Direction.OUTPUT

while True:
    if pin_counter.count >= 1:
        led.value = not led.value
        pin_counter.reset()
      

User avatar
dastels
 
Posts: 15659
Joined: Tue Oct 20, 2015 3:22 pm

Re: Clue Board Speed

Post by dastels »

Hmm. To check my understanding: you not measuring the frequency of the signal on D6, you're doing something on each tick. You should probably be using C++ for this.

Dave

User avatar
ingtommy
 
Posts: 3
Joined: Sun Sep 18, 2022 5:23 am

Re: Clue Board Speed

Post by ingtommy »

Correct, I need to run some logic with every tick.
I am curious as why this simple code is already poorly performing as this could save me ton of time. Any idea?
Also, do you think trying with asyncio could be worth the time ?

User avatar
dastels
 
Posts: 15659
Joined: Tue Oct 20, 2015 3:22 pm

Re: Clue Board Speed

Post by dastels »

I haven't played with asyncio, but your code will still be in CircuitPython so I doubt it would impact the core problem (how fast the tick code runs), and it might introduce additional overhead that could slow it down even more. CircuitPython isn't IMO a great environment for writing hard realtime systems.

Dave

Locked
Please be positive and constructive with your questions and comments.

Return to “Adafruit CircuitPython”