Hello,
I am working on the prototype project of data acquisition system for that I am using the wave share high precision ad/da converter board(ad1256) with raspberry pi4 mode B, I have taken the reference code from the https://www.waveshare.com/wiki/File:AD1256-bcm2835.zip and i have done the modifications as per my requirement like i need to write the adc values into the file with time stamp, the time stamp starts with 0.000 micro seconds and ,for time stamp I am using the clock_gettime(CLOCK_REALTIME, & out_start_time); fuction from the time.h library, i am facing the issue for suppose i have select the SPS rate as 1000Hz, I am not getting the 1000 Samples for second(i.e. 1000 SPS means 1000 samples for second, for suppose if i have run the loop for 1 minute I need to get the 60K samples but I am not getting the 60K samples for minute). I need to write the adc values and time stamp in the file and the samples should match with the SPS rate , so how can i get the samples as per SPS, if you have any idea /suggestions please tell me , i have select the spi clock divider as bcm2835_spi_setClockDivider(BCM2835_SPI_CLOCK_DIVIDER_128); so for getting the required SPS rate how much the clock divider value for raspberry pi4 mode B, how can i match the SPS and adc values with in a specified time .
while(specified time)
{
clock_gettime(CLOCK_REALTIME, & out_start_time);
all_adc_read();
clock_gettime(CLOCK_REALTIME, & out_end_time);
// load the adc values and time stamp into the file using fprintf (time stamp taking from the difference between the out_start_time and out_end_time);
}
Best Regards
Raj