Reading signal from AIO with fidelity?
Posted: 05 May 2022, 00:25
I am seeking clarity from everything I've gathered in my couple weeks of working with the Revolution Pi Connect+ and AIO module. Specifically, I have knowledge gaps when it comes to reading an analog signal with fidelity.
First, my understanding is that the AIO module is capable of sampling rates much faster than what the process image can read. It is not clear to me exactly why this is, but I've taken it as a fact that whatever communication is happening between the process image and the AIO module, it limits the actual maximum sampling rate at around 125 Hz. For this reason, the sample rate must be chosen below 125 Hz for the AIO within PiCtory. I have done this.
I then want to access every single measured value on all four analog input channels. For example, if I were to select 80 Hz as my sample rate, and I acquired data for exactly one minute, I should have exactly 60 seconds * 80 samples per second * 4 channels = 19200 samples. No more and no less. Moreover, I should be able to take it as fact that all 4800 samples of a given channel were measured at 0.0125 second equally spaced intervals in time. This is what I mean by acquiring a signal with fidelity.
However, every program, library, or example I have seen acquires data by running some sort of capture code within some loop. Whether one queries a specific hex location inside /dev/piControl0 via IOCTL system calls, or one uses a higher level library such as revpimodio2, in the end, there is some programed loop running to obtain data from the AIO. This concerns me because the system is not a real-time system. Any loop running on the pi's CPU will run much faster than the maximum 125 Hz sample rate, and I will obtain many repeated values I will not be able to distinguish from their single unique values in time. Any delay I build into my loop to try and match my chosen sample rate will inevitably have jitter due to the non-real-time system's changing CPU priorities. In the end, my current understanding of the system does not lend confidence in obtaining signals with fidelity.
Can anyone point me to some resources or examples which can help increase my understanding and thereby confidence that I can perform signal processing with fidelity?
BACKGROUND: I typically use the MCC118 DAQ Hat (https://www.mccdaq.com/DAQ-HAT.aspx) on the raspberry pi. This device is capable of 100 kHz analog acquisition. It works by jamming all measured values into a real time buffer. My task as the developer is then to simply grab the data accumulated within this buffer and clear it, and to ensure I do this routinely before the buffer runs out of memory. The buffer query is then looped in my program, and it returns a list of all recorded values accumulated between the last query and the present one. Because this query loop is ran on a non-real-time system, the returned list does not have a guaranteed length. This is easy to deal with in my processing loop. However, I was looking for something a bit more industrially hardened, and decided to try the Revolution Pi. However, the revolution pi does not seem to operate in the way I am use to. My present understanding is that there is no real time buffer, and I only have access to the present value being measured at the AIO channel terminal at the time I query it. This means that the temporal spacing of my recorded values deviates as a function of the unknown CPU prioritization, rather than any type of real-time clock cycles on the A-to-D device in the AIO module itself. Do I have a misunderstanding?
First, my understanding is that the AIO module is capable of sampling rates much faster than what the process image can read. It is not clear to me exactly why this is, but I've taken it as a fact that whatever communication is happening between the process image and the AIO module, it limits the actual maximum sampling rate at around 125 Hz. For this reason, the sample rate must be chosen below 125 Hz for the AIO within PiCtory. I have done this.
I then want to access every single measured value on all four analog input channels. For example, if I were to select 80 Hz as my sample rate, and I acquired data for exactly one minute, I should have exactly 60 seconds * 80 samples per second * 4 channels = 19200 samples. No more and no less. Moreover, I should be able to take it as fact that all 4800 samples of a given channel were measured at 0.0125 second equally spaced intervals in time. This is what I mean by acquiring a signal with fidelity.
However, every program, library, or example I have seen acquires data by running some sort of capture code within some loop. Whether one queries a specific hex location inside /dev/piControl0 via IOCTL system calls, or one uses a higher level library such as revpimodio2, in the end, there is some programed loop running to obtain data from the AIO. This concerns me because the system is not a real-time system. Any loop running on the pi's CPU will run much faster than the maximum 125 Hz sample rate, and I will obtain many repeated values I will not be able to distinguish from their single unique values in time. Any delay I build into my loop to try and match my chosen sample rate will inevitably have jitter due to the non-real-time system's changing CPU priorities. In the end, my current understanding of the system does not lend confidence in obtaining signals with fidelity.
Can anyone point me to some resources or examples which can help increase my understanding and thereby confidence that I can perform signal processing with fidelity?
BACKGROUND: I typically use the MCC118 DAQ Hat (https://www.mccdaq.com/DAQ-HAT.aspx) on the raspberry pi. This device is capable of 100 kHz analog acquisition. It works by jamming all measured values into a real time buffer. My task as the developer is then to simply grab the data accumulated within this buffer and clear it, and to ensure I do this routinely before the buffer runs out of memory. The buffer query is then looped in my program, and it returns a list of all recorded values accumulated between the last query and the present one. Because this query loop is ran on a non-real-time system, the returned list does not have a guaranteed length. This is easy to deal with in my processing loop. However, I was looking for something a bit more industrially hardened, and decided to try the Revolution Pi. However, the revolution pi does not seem to operate in the way I am use to. My present understanding is that there is no real time buffer, and I only have access to the present value being measured at the AIO channel terminal at the time I query it. This means that the temporal spacing of my recorded values deviates as a function of the unknown CPU prioritization, rather than any type of real-time clock cycles on the A-to-D device in the AIO module itself. Do I have a misunderstanding?