Counters

Topics about the Software of Revolution Pi
Post Reply
RudyVerheyen
Posts: 2
Joined: 11 Oct 2024, 17:18

Counters

Post by RudyVerheyen »

Hi,

I recently have purchased a RevPi connect 4 and the MIO, AIO, DI and DO modules.
I want to count a squire wave, comming from a DC motor.
The signal from the motor has a ampitude of 24V, 60 pulses/ revolution.
At 1000 rpm I've got 60000 pulses a minuut or 1KHz.
The motor runs between 250rpm and 8000rpm, 250Hz to 10KHz output signal.

How can I measure this?
Counter function is limeted to 2000 counts, I belive.

Thanks,
Rudy
User avatar
dirk
KUNBUS
Posts: 2174
Joined: 15 Dec 2016, 13:19

Re: Counters

Post by dirk »

Hello Ruby, the first port of call is to consult the data sheet(s) of the relevant RevPi modules that implement counters. The RevPi DI module is therefore suitable for your application.
https://revolutionpi.com/en/tutorials/d ... enblaetter
Thus the maximum frequency for counter inputs on the RevPi DI Module is specified as 2 kHz.

However, the analog signal must still be debounced. This reduces the maximum frequency for sampling. The RevPi Di module makes this possible in a simple and variable way through a configurable parameter in PiCtory. Take a look at the video tutorial - Counter and Encoder:
https://revolutionpi.com/en/tutorials/video-tutorials

However, this measured data is transferred asynchronously to the process image cyclically via the PiBridge. It is therefore necessary to measure this cycle time on your system. This will tell you the frequency with which the measured values are transmitted. Take a look at this helpful article from our knowledge database:
Measuring analog data with the RevPi AIO module

So to sum it up the measured value "RevPiIOCycle" indicates how many MS (not rounded) a PiBridge cycle takes on your system. You can use this value to calculate the frequency with which an overflow of the counters is prevented during sampling.
RudyVerheyen
Posts: 2
Joined: 11 Oct 2024, 17:18

Re: Counters

Post by RudyVerheyen »

Hi Dirk,

Still not completly clear for a newby as me.
The max count is 2000 but in what time frame, a PiBridgeCycle (safe time 8ms)?

If the motor is running at 8000rpm (60 pulses/revolution), I will have 8000 pulse a second. Measuered after 8ms the counter will be at 1000, right? Or is this limeted by the 2KHz and can the counter only count to 266 in 8ms?

Can you start and stop the counter in a loop every 8ms?

Greetings,
Rudy
User avatar
dirk
KUNBUS
Posts: 2174
Joined: 15 Dec 2016, 13:19

Re: Counters

Post by dirk »

Hi Rudy,
sure, it's a somewhat complex matter when it comes to sampling and measurement. But first things first:

Well, physically with the RevPi DI Module it is possible to count 2000 pulses per second - 2 kHz.
In case that exceeds your needs, then you have to switch to another hardware, unfortunately. If you want to give it a try, then I have these thoughts for you:

You can count a maximum of 16-bit values. This corresponds to 0xFF or decimal 65535. See here: https://revolutionpi.com/en/tutorials/o ... io-modules

Then you have two asynchronous processes that together (not added together) result in a group runtime.
a) RevPi DI counter frequency - 2 kHz
b) PiBridge cycle time approx. 8 ms

Since the PiBridge cycle time is not rounded, but is saved as a whole MS, we should rather assume 9 MS in reality.
So 9 MS corresponds to 1/0,009 Hz → approx. 112 Hz

So to sum it up, if you lose one PiBridge cycle in your application, you'll expect to get the "oldest" values with 18 MS or 56 Hz sampling rate.
In reality, those values will vary because of asynchronously.

So, back to the DC engine - what do you expect to measure 56 Hz to 112 Hz?
User avatar
dirk
KUNBUS
Posts: 2174
Joined: 15 Dec 2016, 13:19

Re: Counters

Post by dirk »

Hello Rudy, how are you? Do you have any questions?
Post Reply