How to achieve a higher Sample Rate from RedPitayas slow Analog Inputs?
Posted: Mon Nov 11, 2019 5:26 pm
Hello RedPitaya-Community,
I am trying to read the analog inputs of my RedPitaya (Stemlab 125-14).
According to the datasheet the slow analog inputs should be capable of around 100kS/s.
The maximum I can achieve with the following C-code is around 10-16kS/s. The code is executed & running directly on the Linux OS of the RedPitaya.
Does anyone have an idea on how to maximize the sample rate? Or any ideas for alternate approaches?
For my project I need around 50kS/s.
Thanks in advance!
I am trying to read the analog inputs of my RedPitaya (Stemlab 125-14).
According to the datasheet the slow analog inputs should be capable of around 100kS/s.
The maximum I can achieve with the following C-code is around 10-16kS/s. The code is executed & running directly on the Linux OS of the RedPitaya.
Does anyone have an idea on how to maximize the sample rate? Or any ideas for alternate approaches?
For my project I need around 50kS/s.
Thanks in advance!
Code: Select all
// Test für maximale Sample Rate (minimalstes Programm)
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <sys/time.h> //Header for timestamp
#include "/RedPitaya/api/include/redpitaya/rp.h" //Header for RP API
int main()
{
float voltage; //Measured Voltage
struct timeval currentTime; //Timestamp
// Initialization of RP-API
if (rp_Init() != RP_OK)
{
fprintf(stderr, "Red Pitaya API init failed!\n");
return EXIT_FAILURE;
}
int counter = 0;
while(counter<=100000) //counter ist Anzahl der Pakete - spaeter while(1)
{
//Get AI-Values
rp_AIpinGetValue(1, &voltage); //Read Voltage of Pin1
// Timestamp in microseconds
gettimeofday(¤tTime, NULL);
unsigned long long microsecondsSinceEpoch =
(unsigned long long)(currentTime.tv_sec) * (int)1e6 +
(unsigned long long)(currentTime.tv_usec);
printf("%.4f // %llu \n", voltage, microsecondsSinceEpoch);
counter++;
}
return 0;
}