Jump to content
  • 0

Equal time intervals between samples for measurement data from an Mcc118


Sai Mouli

Question

Hello everyone, 

Good Day,

I am facing a huge problem in my project where I am bulding a GUI interface using MCC 118 voltage measurement instrument. My objective is to log everysingle data point measured from each voltage channel and store this data and export it in an excel file. The most cruicial task here is to achieve equal time intervals between consecutive sample points read. Say for example, sample 1 is read at 33ms, sample 2 is read at 33.2ms sample 3 is read at 33.4 ms. For this to be possible I don't know if the MCC 118 provides samples with equal interval. As we may know by using a_in_scan_read() function doesnt deliver samples one at a time but a set of samples for each iteration. Say for example, if i keep a_in_scan_read() function in a loop i read with a scan rate of 1000samples/sec for 10 second expecting 10,000 samples in total per channel. The working mechanism is such that in the first iteration 30 samples/channel are read then in second iteration 55 samples , in 3rd iteration 40samples and so on till the limit of 10,000 samples are achieved.My approach was that eventhough a set of samples are read for each iteration, calculating the time difference between begin and end of each iteration in a loop and dividing it with the number of samples read for that iteration would form an equal time gap between each sample point. However, this method only works to some extent. It goes this way, say for

IT(Iteration) 1 -- 30 samples --- time interval --- 1.5 ms

IT 2 ----------- 40 samples ---- time interval -- 1.7 ms

IT 3 ------------- 56 samples --- time interval -- 1.85 ms

.........

As you can see for each batch size the time interval is varying. I could take the time difference between the beginning and end of the entire Loop instead of just recording the time taken for each iteration in a loop. However, I am not sure if I could do that since in between , I  am also storing and concatenating the data received from the channels at the end of each iteration before moving on to the next iteration in the Loop. I believe some computational time is also lost in this part of the process .Previously followed by storing data I also used to Log real time data in a canvas figures for real time plotting .  However as the results have shown non uniform time interval between sample points I decided to disect that part from the process. Now I am just reading and storing data however the results are still the same. Could someone give me the best possible solution to achieve equal time interval between sample points? This feature is quite crucial in signal processing applications.  What needs to be known is,

Is there any way to accurately log the time for each sample read from MCC118 ? or

is there any computational method feasible enough to manually develop the time interval between samples as accurately as possible? 

I have attached the Loop function which I am using in my program please open it in notepad.

some key notes:

->stime- refers to time the scan begins

->click_stop - just stops the process

->all other variables related to data are data storage parameters

->D0-D7 are global variable conditions for respective channels to be enabled by user(0->selected and 1->not selected)

I would really like to know if I am making any mistake here. I hope I was clear enough and  Please let me know.

                                      Thank You,

 

 

LOOP

Edited by Sai Mouli
Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

Hello @Sai Mouli.

The acquired samples of each channel are at equal time intervals during a scan.  Below is a scan representation for three channels.

image.png

 

If your sampling rate is 10,000 Hz, then the data interval of a given channel will be 0.1 msec throughout the scan.  Since there is no timestamp option in the MCC DAQ HAT Library, you will need add a timestamp to each data point after the acquisition has completed.  Use your system's clock as the start time and then add the time interval of each scan.

Note: Minimize the amount of background processing during a scan, especially at fast sampling rates.

MCC 118 hardware:  https://mccdaq.github.io/daqhats/overview.html#board-components

MCC 118 datasheet:  https://www.mccdaq.com/PDFs/specs/DS-MCC-118.pdf

Python Library Reference:  https://mccdaq.github.io/daqhats/python.html

 

Regards,

Fausto

Link to comment
Share on other sites

  • 0
17 hours ago, Fausto said:

Hello @Sai Mouli.

The acquired samples of each channel are at equal time intervals during a scan.  Below is a scan representation for three channels.

image.png

 

If your sampling rate is 10,000 Hz, then the data interval of a given channel will be 0.1 msec throughout the scan.  Since there is no timestamp option in the MCC DAQ HAT Library, you will need add a timestamp to each data point after the acquisition has completed.  Use your system's clock as the start time and then add the time interval of each scan.

Note: Minimize the amount of background processing during a scan, especially at fast sampling rates.

MCC 118 hardware:  https://mccdaq.github.io/daqhats/overview.html#board-components

MCC 118 datasheet:  https://www.mccdaq.com/PDFs/specs/DS-MCC-118.pdf

Python Library Reference:  https://mccdaq.github.io/daqhats/python.html

 

Regards,

Fausto

Hello Sir,

Thank you for the response. It clears many things for me. Just to make sure I have understood correctly and get some more insight.

-->Say for example I insert a_in_scan_read() function and run it at a scan rate of 1000 samples/sec inside a while loop. I will apply time.time() function to record the starting time of the scan and as soon as the very first sample is read I can simply increment the time stamp for every successive sample with an interval of 1ms. More clearly,

  Channel 0:   Sample 1 --> 33ms(Since start of scan)

                       Sample 2 --> 34ms

                      Sample 3 --> 35ms

                ..... 

-->It is my understanding, but as given in the Hardware specifications, the Scan Clock description says the internal clock has a capacity of upto 100KS/s and a conversion of 8micro seconds per channel, does it  imply by default MCC118 scans samples at equal time intervals for upto 100KHz frequency?

 

-->And as per high sample rates , I have one more doubt, for every interation in a loop,  after reading the scanned data in the same loop I am  storing data in arrays as well as plotting data in an animated canvas figure for visual display of the user. The whole program is capsuled with in a GUI window.Do they cause interference to the progrm as well? Do I have to remove them as well to store accurate data in a sheet? 

 My apologies for any errors in details. Looking forward to your response.

                                            Thank You,

Yours Sincerely,

Sai Mouli 

Link to comment
Share on other sites

  • 0

Hello @Sai Mouli.

7 hours ago, Sai Mouli said:

-->Say for example I insert a_in_scan_read() function and run it at a scan rate of 1000 samples/sec inside a while loop. I will apply time.time() function to record the starting time of the scan and as soon as the very first sample is read I can simply increment the time stamp for every successive sample with an interval of 1ms. More clearly,

  Channel 0:   Sample 1 --> 33ms(Since start of scan)

                       Sample 2 --> 34ms

                      Sample 3 --> 35ms

That is correct.  You will need to add the increment to each sample.

 

7 hours ago, Sai Mouli said:

-->It is my understanding, but as given in the Hardware specifications, the Scan Clock description says the internal clock has a capacity of upto 100KS/s and a conversion of 8micro seconds per channel, does it  imply by default MCC118 scans samples at equal time intervals for upto 100KHz frequency?

The channel-to-channel conversion time is fixed at 8 microseconds, regardless of the user specified sample rate.

 

7 hours ago, Sai Mouli said:

-->And as per high sample rates , I have one more doubt, for every interation in a loop,  after reading the scanned data in the same loop I am  storing data in arrays as well as plotting data in an animated canvas figure for visual display of the user. The whole program is capsuled with in a GUI window.Do they cause interference to the progrm as well? Do I have to remove them as well to store accurate data in a sheet? 

Which Raspberry Pi module are you using and how much RAM onboard?  You definitely want to move the acquired data to a user buffer during an acquisition.  However, processing, displaying the data, and the Python language (does not support multithreading) may slow your application.  You will need to run some performance tests.

Regards,

Fausto

Link to comment
Share on other sites

  • 0
On 8/4/2023 at 8:16 PM, Fausto said:

Hello @Sai Mouli.

That is correct.  You will need to add the increment to each sample.

 

The channel-to-channel conversion time is fixed at 8 microseconds, regardless of the user specified sample rate.

 

Which Raspberry Pi module are you using and how much RAM onboard?  You definitely want to move the acquired data to a user buffer during an acquisition.  However, processing, displaying the data, and the Python language (does not support multithreading) may slow your application.  You will need to run some performance tests.

Regards,

Fausto

Thank You for the clarification. I am using Raspberry Pi 4 computer model B with 2 GB ram. Also how do I select a specific number of channels? Like say I only want to run measurement on Channel 0-2 while deactivating all other channels? a_in_scan_read() function doesn't seem have any input parameters referring to channel numbers. a_in_read() does but it only does a single read returning just a single value from scan buffer. None of the option flags consist of any scan options that allows us to select our desired channels. Do I just have to store data the from my desired  channels? or is there any existing method or any specific detail which I overlooked? kindly please let me know 

regards,

Sai Mouli

Edited by Sai Mouli
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...