Time axis in GPIO pin measurement

Hello,

I am using MetaWear C and MetaWear android app for monitoring my sensor via a GPIO pin.
When the GPIO pin is measured more than two times, the sampling rate looks increasing and the time in x axis is no longer a collect value.
The axis is fine at the first measurement. From the second measurement, the axis gets wrong values.
Could you tell me how to solve the problem?

Comments

  • Can you quantify these issues you are seeing?  Please provide screenshots and CSV files as well.
  • Hi Eric,

    I upload screenshots and CSV file images in this site because I cannot attach the image here.
    http://firestorage.jp/photo/379c067e694bd589b101d96a31c48adcebd9ac16
     I measured 1 Hz sine wave with 0.5 V amplitude in both measurements.image
  • It looks like it's just a graphical error with the charting library.  Are the actual values recorded in the CSV file correct?
  • edited October 2017
    No, the time values in the second measurement CSV are incorrect.
    Time axis in the graph corresponds to the CSV file, so I think the graphical code is no problem.
    There would be some bug in the code regarding to sampling signals.
  • How are the time values in the 2nd CSV file incorrect?  They match the values in the first CSV file.

    Are the measured gpio values correct?
  • edited October 2017
    The time values in 2nd meas. exactly match those in 1st meas. But the actual sampling in 2nd meas. was much faster.
    The gpio values are same in both measurement, but the values are smaller than the real amplitude of sinusoidal wave (0.5 Vp-p).
    This is another mystery for me.

    I paste the real values of the measurements below.

    1st,,2nd,
    time,adc,time,adc
    0,179,0,88
    0.033,183,0.033,88
    0.066,183,0.066,106
    0.099,180,0.099,106
    0.132,170,0.132,107
    0.165,159,0.165,107
    0.198,146,0.198,124
    0.231,129,0.231,124
    0.264,111,0.264,125
    0.297,92,0.297,125
    0.33,74,0.33,140
    0.363,55,0.363,140
    0.396,39,0.396,142
    0.429,25,0.429,142
    0.462,13,0.462,155
    0.495,5,0.495,155
    0.528,1,0.528,157
    0.561,1,0.561,157
    0.594,4,0.594,167
    0.627,12,0.627,167
    0.66,23,0.66,169
    0.693,37,0.693,169
    0.726,53,0.726,176
    0.759,70,0.759,176
    0.792,89,0.792,177
    0.825,108,0.825,177
    0.858,126,0.858,181
    0.891,142,0.891,181
    0.924,156,0.924,182
    0.957,168,0.957,182
    0.99,176,0.99,182
    1.023,180,1.023,182
    1.056,181,1.056,184
    1.089,178,1.089,184
    1.122,171,1.122,180
    1.155,161,1.155,180
    1.188,147,1.188,181
    1.221,132,1.221,181
    1.254,114,1.254,174
    1.287,96,1.287,174
    1.32,77,1.32,174
    1.353,59,1.353,174
    1.386,41,1.386,164
    1.419,27,1.419,164
    1.452,15,1.452,164
    1.485,6,1.485,164
    1.518,1,1.518,152
    1.551,1,1.551,152
    1.584,3,1.584,151
    1.617,10,1.617,151
    1.65,20,1.65,136
    1.683,34,1.683,136
    1.716,50,1.716,135
    1.749,67,1.749,135
    1.782,86,1.782,118
    1.815,105,1.815,118
    1.848,123,1.848,117
    1.881,140,1.881,117
    1.914,156,1.914,98
    1.947,168,1.947,98
    1.98,177,1.98,98
    2.013,183,2.013,98
    2.046,181,2.046,80
    2.079,179,2.079,80
    2.112,173,2.112,80
    2.145,162,2.145,80
    2.178,149,2.178,61
    2.211,134,2.211,61
    2.244,117,2.244,61
    2.277,98,2.277,61
    2.31,79,2.31,44
    2.343,61,2.343,44
    2.376,44,2.376,44
    2.409,29,2.409,44
    2.442,16,2.442,29
    2.475,7,2.475,29
    2.508,2,2.508,28
    2.541,1,2.541,28
    2.574,3,2.574,16
    2.607,9,2.607,16
    2.64,19,2.64,16
    2.673,32,2.673,16
    2.706,48,2.706,7
    2.739,65,2.739,7
    2.772,83,2.772,7
    2.805,102,2.805,7
    2.838,120,2.838,2
    2.871,137,2.871,2
    2.904,152,2.904,2
    2.937,165,2.937,2
    2.97,174,2.97,1
    3.003,179,3.003,1
    3.036,181,3.036,1
    3.069,179,3.069,1
    3.102,173,3.102,3
    3.135,164,3.135,3
    3.168,152,3.168,3
    3.201,138,3.201,3
    3.234,121,3.234,9
    3.267,102,3.267,9
    3.3,82,3.3,10
    3.333,64,3.333,10
    3.366,46,3.366,19
    3.399,31,3.399,19
    3.432,18,3.432,20
    3.465,9,3.465,20
    3.498,3,3.498,32
    3.531,1,3.531,32
    3.564,2,3.564,33
    3.597,8,3.597,33
    3.63,17,3.63,48
    3.663,30,3.663,48
    3.696,45,3.696,49
    3.729,62,3.729,49
    3.762,80,3.762,65
    3.795,99,3.795,65
    3.828,119,3.828,66
    3.861,137,3.861,66
    3.894,153,3.894,84
    3.927,166,3.927,84
    3.96,173,3.96,85
    3.993,180,3.993,85
    4.026,182,4.026,104
  • Just because it visually appears to be faster the second time does not mean it actually is.  Nothing in the code looks wrong so it probably just is a bug with either the graphing API or the usage of the API.  Count the number of samples received for the same sampling duration and see if there is a discrepancy.

    You are sampling the ADC values not the input voltages.
  • edited October 2017
    I did four successive meas. for 10 sec duration.
    The numbers of samples are, 1st: 310, 2nd: 598, 3rd: 902.


    I noticed some data are duplicated in 2nd and 3rd meas.
    In 1st meas., there is no duplication.
    In 2nd meas., data are doubly duplicated and in 3rd, triply duplicated.

    1st        2nd        3rd   
    time    abs reference    time    abs reference    time    abs reference
    0    0.485    0    0.425    0    0.428
    0.033    0.467    0.033    0.425    0.033    0.428
    0.066    0.442    0.066    0.386    0.066    0.428
    0.099    0.404    0.099    0.386    0.099    0.39
    0.132    0.365    0.132    0.341    0.132    0.39
    0.165    0.316    0.165    0.341    0.165    0.39
    0.198    0.267    0.198    0.291    0.198    0.344
    0.231    0.214    0.231    0.291    0.231    0.344
    0.264    0.161    0.264    0.242    0.264    0.344
    0.297    0.116    0.297    0.242    0.297    0.295
    0.33    0.073    0.33    0.189    0.33    0.295
    0.363    0.038    0.363    0.189    0.363    0.295
    0.396    0.01    0.396    0.14    0.396    0.246
    0.429    0    0.429    0.14    0.429    0.246
    0.462    0    0.462    0.094    0.462    0.246
    0.495    0    0.495    0.094    0.495    0.193
    0.528    0.01    0.528    0.056    0.528    0.193
    0.561    0.035    0.561    0.056    0.561    0.193
    0.594    0.07    0.594    0.024    0.594    0.144
    0.627    0.108    0.627    0.024    0.627    0.144
    0.66    0.158    0.66    0.003    0.66    0.144
    0.693    0.207    0.693    0.003    0.693    0.098
    0.726    0.26    0.726    0    0.726    0.098
    0.759    0.312    0.759    0    0.759    0.098
    0.792    0.358    0.792    0    0.792    0.056
    0.825    0.4    0.825    0    0.825    0.056
    0.858    0.439    0.858    0    0.858    0.056
    0.891    0.464    0.891    0    0.891    0.024
    0.924    0.481    0.924    0.021    0.924    0.024
    0.957    0.488    0.957    0.021    0.957    0.024
    0.99    0.485    0.99    0.049    0.99    0.003
    1.023    0.471    1.023    0.049    1.023    0.003
    1.056    0.446    1.056    0.087    1.056    0.003
    1.089    0.411    1.089    0.087    1.089    0
    1.122    0.372    1.122    0.133    1.122    0
    1.155    0.323    1.155    0.133    1.155    0
    1.188    0.274    1.188    0.182    1.188    0
    1.221    0.221    1.221    0.182    1.221    0
    1.254    0.172    1.254    0.232    1.254    0
    1.287    0.123    1.287    0.232    1.287    0
    1.32    0.08    1.32    0.284    1.32    0
    1.353    0.042    1.353    0.284    1.353    0
  • In the second question, I see ADC values are the value converted from input voltage to some digitized value.
    I guess the relation between ADC and AbsoluteReference below.

    ADC=(AbsoluteReference)/(Battery voltage)*1023

    If the battery voltage is 2.8 V and the AbsoluteReference is 0.5 V, the ADC value is 183.
    I am using CR2032 cell battery and the battery voltage should be larger than 2.8 V. But this looks reasonable.
    Please tell me if something is wrong.
  • Sorry, I made three successive measurements above.
  • Interesting, it seems the code, for whatever reason, is reading the analog values multiple times?  I'll have to look over the code again and see if I can spot anything wrong.

    Yes, ADC is simply a ratiometric value as defined in your equation.
  • Thank you, Eric.
    I suspect the time axis is not defined by smartphone's internal clock, but the minimum sampling time (0.033 s in this case) and the number of sampling.
    Possibly, the number of measurements could be slipped into the calculation ?
This discussion has been closed.