Hi I didn’t measure time for one analogRead(); I even don’t know how to do that to get some “constructive results” also I didn’t measure time for entire interrupt routine but instead I add another global double array w 128 elements and then add (right after this line: vReal[sampleCounter] = analogRead(CHANNEL); in interrupt ) this line :
vMicros[sampleCounter] = micros();
and then in main loop instead of:
memcpy(vR_copy, vReal, sizeof(double) * len);
replaced with:
memcpy(vR_copy, vMicros, sizeof(double) * len);
Then printed the entire array of micros(); results from threadFunction and I get some weird results. I modify python spectrum analyser just to read from Serial1 and print to console.The array is pretty big and I don’t wanted to subtract, one by one, the time value manually. So python function to read from Serial looks like that:
self.fftSize = 128
def get_magnitudes(self):
"""Return an array of micros."""
self.port.write('GET MAGNITUDES; ')
raw_buff = [self.port.readline() for i in range(self.fftSize)]
print "raw_buff", raw_buff
foo = re.findall("\d \.\d ", str([raw_buff for i
range(self.fftSize)]))
for i in range(self.fftSize-1):
bar = [float(foo[i +1]) - float(foo[i])]
print "read time and i ", bar , i+1
and here is some printed results:
raw_buff ['1230222384.00\r\n', '1230222425.00\r\n', '1230222448.00\r\n', '1230222471.00\r\n', '1230222494.00\r\n', '1230222517.00\r\n', '1230222540.00\r\n', '1230225588.00\r\n', '1230225611.00\r\n', '1230225634.00\r\n', '1230229342.00\r\n', '1230229367.00\r\n', '1230229388.00\r\n', '1230233405.00\r\n', '1230233428.00\r\n', '1230233451.00\r\n', '1230237478.00\r\n', '1230237501.00\r\n', '1230237527.00\r\n', '1230241545.00\r\n', '1230241568.00\r\n', '1230241591.00\r\n', '1230245617.00\r\n', '1230245640.00\r\n', '1230245663.00\r\n', '1230249684.00\r\n', '1230249704.00\r\n', '1230249727.00\r\n', '1230253753.00\r\n', '1230253774.00\r\n', '1230253797.00\r\n', '1230257821.00\r\n', '1230257847.00\r\n', '1230257867.00\r\n', '1230257890.00\r\n', '1230261917.00\r\n', '1230261938.00\r\n', '1230261961.00\r\n', '1230265981.00\r\n', '1230266006.00\r\n', '1230266017.00\r\n', '1230270042.00\r\n', '1230270068.00\r\n', '1230270088.00\r\n', '1230274111.00\r\n', '1230274134.00\r\n', '1230274160.00\r\n', '1230278180.00\r\n', '1230278203.00\r\n', '1230278229.00\r\n', '1230282249.00\r\n', '1230282272.00\r\n', '1230282295.00\r\n', '1230286321.00\r\n', '1230286341.00\r\n', '1230286364.00\r\n', '1230290390.00\r\n', '1230290410.00\r\n', '1230290433.00\r\n', '1230294456.00\r\n', '1230294480.00\r\n', '1230294502.00\r\n', '1230298525.00\r\n', '1230298551.00\r\n', '1230298571.00\r\n', '1230302594.00\r\n', '1230302617.00\r\n', '1230302643.00\r\n', '1230306663.00\r\n', '1230306686.00\r\n', '1230306712.00\r\n', '1230310732.00\r\n', '1230310755.00\r\n', '1230310778.00\r\n', '1230314803.00\r\n', '1230314824.00\r\n', '1230314847.00\r\n', '1230314870.00\r\n', '1230318891.00\r\n', '1230318914.00\r\n', '1230318937.00\r\n', '1230322964.00\r\n', '1230322984.00\r\n', '1230323007.00\r\n', '1230327045.00\r\n', '1230327065.00\r\n', '1230327088.00\r\n', '1230331111.00\r\n', '1230331136.00\r\n', '1230331157.00\r\n', '1230335177.00\r\n', '1230335202.00\r\n', '1230335223.00\r\n', '1230339246.00\r\n', '1230339269.00\r\n', '1230339295.00\r\n', '1230343316.00\r\n', '1230343339.00\r\n', '1230343364.00\r\n', '1230347386.00\r\n', '1230347409.00\r\n', '1230347432.00\r\n', '1230351455.00\r\n', '1230351476.00\r\n', '1230351499.00\r\n', '1230355525.00\r\n', '1230355546.00\r\n', '1230355569.00\r\n', '1230359592.00\r\n', '1230359617.00\r\n', '1230359638.00\r\n', '1230363642.00\r\n', '1230363667.00\r\n', '1230363688.00\r\n', '1230367732.00\r\n', '1230367755.00\r\n', '1230367778.00\r\n', '1230371798.00\r\n', '1230371821.00\r\n', '1230371847.00\r\n', '1230371868.00\r\n', '1230375871.00\r\n', '1230375894.00\r\n', '1230375920.00\r\n', '1230379960.00\r\n', '1230379983.00\r\n', '1230380008.00\r\n', '1230384017.00\r\n']
read time and i [41.0] 1
read time and i [23.0] 2
read time and i [23.0] 3
read time and i [23.0] 4
read time and i [23.0] 5
read time and i [23.0] 6
read time and i [3048.0] 7
read time and i [23.0] 8
read time and i [23.0] 9
read time and i [3708.0] 10
read time and i [25.0] 11
read time and i [21.0] 12
read time and i [4017.0] 13
read time and i [23.0] 14
read time and i [23.0] 15
read time and i [4027.0] 16
read time and i [23.0] 17
read time and i [26.0] 18
read time and i [4018.0] 19
read time and i [23.0] 20
read time and i [23.0] 21
read time and i [4026.0] 22
read time and i [23.0] 23
read time and i [23.0] 24
read time and i [4021.0] 25
read time and i [20.0] 26
read time and i [23.0] 27
read time and i [4026.0] 28
read time and i [21.0] 29
read time and i [23.0] 30
read time and i [4024.0] 31
read time and i [26.0] 32
read time and i [20.0] 33
read time and i [23.0] 34
read time and i [4027.0] 35
read time and i [21.0] 36
read time and i [23.0] 37
read time and i [4020.0] 38
read time and i [25.0] 39
read time and i [11.0] 40
read time and i [4025.0] 41
read time and i [26.0] 42
read time and i [20.0] 43
read time and i [4023.0] 44
read time and i [23.0] 45
read time and i [26.0] 46
read time and i [4020.0] 47
read time and i [23.0] 48
read time and i [26.0] 49
read time and i [4020.0] 50
read time and i [23.0] 51
read time and i [23.0] 52
read time and i [4026.0] 53
read time and i [20.0] 54
read time and i [23.0] 55
read time and i [4026.0] 56
read time and i [20.0] 57
read time and i [23.0] 58
read time and i [4023.0] 59
read time and i [24.0] 60
read time and i [22.0] 61
read time and i [4023.0] 62
read time and i [26.0] 63
read time and i [20.0] 64
read time and i [4023.0] 65
read time and i [23.0] 66
read time and i [26.0] 67
read time and i [4020.0] 68
read time and i [23.0] 69
read time and i [26.0] 70
read time and i [4020.0] 71
read time and i [23.0] 72
read time and i [23.0] 73
read time and i [4025.0] 74
read time and i [21.0] 75
read time and i [23.0] 76
read time and i [23.0] 77
read time and i [4021.0] 78
read time and i [23.0] 79
read time and i [23.0] 80
read time and i [4027.0] 81
read time and i [20.0] 82
read time and i [23.0] 83
read time and i [4038.0] 84
read time and i [20.0] 85
read time and i [23.0] 86
read time and i [4023.0] 87
read time and i [25.0] 88
read time and i [21.0] 89
read time and i [4020.0] 90
read time and i [25.0] 91
read time and i [21.0] 92
read time and i [4023.0] 93
read time and i [23.0] 94
read time and i [26.0] 95
read time and i [4021.0] 96
read time and i [23.0] 97
read time and i [25.0] 98
read time and i [4022.0] 99
read time and i [23.0] 100
read time and i [23.0] 101
read time and i [4023.0] 102
read time and i [21.0] 103
read time and i [23.0] 104
read time and i [4026.0] 105
read time and i [21.0] 106
read time and i [23.0] 107
read time and i [4023.0] 108
read time and i [25.0] 109
read time and i [21.0] 110
read time and i [4004.0] 111
read time and i [25.0] 112
read time and i [21.0] 113
read time and i [4044.0] 114
read time and i [23.0] 115
read time and i [23.0] 116
read time and i [4020.0] 117
read time and i [23.0] 118
read time and i [26.0] 119
read time and i [21.0] 120
read time and i [4003.0] 121
read time and i [23.0] 122
read time and i [26.0] 123
read time and i [4040.0] 124
read time and i [23.0] 125
read time and i [25.0] 126
read time and i [4009.0] 127
raw_buff ['1230491109.00\r\n', '1230491150.00\r\n', '1230491173.00\r\n', '1230491196.00\r\n', '1230491220.00\r\n', '1230491243.00\r\n', '1230491265.00\r\n', '1230494317.00\r\n', '1230494339.00\r\n', '1230494362.00\r\n', '1230498338.00\r\n', '1230498361.00\r\n', '1230498384.00\r\n', '1230502406.00\r\n', '1230502431.00\r\n', '1230502452.00\r\n', '1230506480.00\r\n', '1230506503.00\r\n', '1230506526.00\r\n', '1230510544.00\r\n', '1230510567.00\r\n', '1230510590.00\r\n', '1230514616.00\r\n', '1230514639.00\r\n', '1230514662.00\r\n', '1230518684.00\r\n', '1230518707.00\r\n', '1230518730.00\r\n', '1230522754.00\r\n', '1230522774.00\r\n', '1230522797.00\r\n', '1230526827.00\r\n', '1230526847.00\r\n', '1230526870.00\r\n', '1230526893.00\r\n', '1230530939.00\r\n', '1230530962.00\r\n', '1230530985.00\r\n', '1230534984.00\r\n', '1230535007.00\r\n', '1230535021.00\r\n', '1230539042.00\r\n', '1230539068.00\r\n', '1230539088.00\r\n', '1230543111.00\r\n', '1230543134.00\r\n', '1230543157.00\r\n', '1230547180.00\r\n', '1230547203.00\r\n', '1230547229.00\r\n', '1230551250.00\r\n', '1230551273.00\r\n', '1230551297.00\r\n', '1230555318.00\r\n', '1230555341.00\r\n', '1230555364.00\r\n', '1230559390.00\r\n', '1230559410.00\r\n', '1230559433.00\r\n', '1230563456.00\r\n', '1230563479.00\r\n', '1230563502.00\r\n', '1230567525.00\r\n', '1230567551.00\r\n', '1230567571.00\r\n', '1230571594.00\r\n', '1230571620.00\r\n', '1230571640.00\r\n', '1230575662.00\r\n', '1230575685.00\r\n', '1230575711.00\r\n', '1230579730.00\r\n', '1230579753.00\r\n', '1230579776.00\r\n', '1230583801.00\r\n', '1230583824.00\r\n', '1230583847.00\r\n', '1230583872.00\r\n', '1230587891.00\r\n', '1230587914.00\r\n', '1230587937.00\r\n', '1230591960.00\r\n', '1230591983.00\r\n', '1230592021.00\r\n', '1230596045.00\r\n', '1230596065.00\r\n', '1230596088.00\r\n', '1230600109.00\r\n', '1230600132.00\r\n', '1230600155.00\r\n', '1230604179.00\r\n', '1230604204.00\r\n', '1230604225.00\r\n', '1230608246.00\r\n', '1230608269.00\r\n', '1230608292.00\r\n', '1230612294.00\r\n', '1230612317.00\r\n', '1230612343.00\r\n', '1230616385.00\r\n', '1230616408.00\r\n', '1230616431.00\r\n', '1230620454.00\r\n', '1230620477.00\r\n', '1230620500.00\r\n', '1230624507.00\r\n', '1230624527.00\r\n', '1230624550.00\r\n', '1230628593.00\r\n', '1230628615.00\r\n', '1230628638.00\r\n', '1230632662.00\r\n', '1230632688.00\r\n', '1230632708.00\r\n', '1230636732.00\r\n', '1230636757.00\r\n', '1230636778.00\r\n', '1230640800.00\r\n', '1230640823.00\r\n', '1230640849.00\r\n', '1230640869.00\r\n', '1230644891.00\r\n', '1230644914.00\r\n', '1230644937.00\r\n', '1230648962.00\r\n', '1230648985.00\r\n', '1230649011.00\r\n', '1230653021.00\r\n']
read time and i [41.0] 1
read time and i [23.0] 2
read time and i [23.0] 3
read time and i [24.0] 4
read time and i [23.0] 5
read time and i [22.0] 6
read time and i [3052.0] 7
read time and i [22.0] 8
read time and i [23.0] 9
read time and i [3976.0] 10
read time and i [23.0] 11
read time and i [23.0] 12
read time and i [4022.0] 13
read time and i [25.0] 14
read time and i [21.0] 15
read time and i [4028.0] 16
read time and i [23.0] 17
read time and i [23.0] 18
read time and i [4018.0] 19
read time and i [23.0] 20
read time and i [23.0] 21
read time and i [4026.0] 22
read time and i [23.0] 23
read time and i [23.0] 24
read time and i [4022.0] 25
read time and i [23.0] 26
read time and i [23.0] 27
read time and i [4024.0] 28
read time and i [20.0] 29
read time and i [23.0] 30
read time and i [4030.0] 31
read time and i [20.0] 32
read time and i [23.0] 33
read time and i [23.0] 34
read time and i [4046.0] 35
read time and i [23.0] 36
read time and i [23.0] 37
read time and i [3999.0] 38
read time and i [23.0] 39
read time and i [14.0] 40
read time and i [4021.0] 41
read time and i [26.0] 42
read time and i [20.0] 43
read time and i [4023.0] 44
read time and i [23.0] 45
read time and i [23.0] 46
read time and i [4023.0] 47
read time and i [23.0] 48
read time and i [26.0] 49
read time and i [4021.0] 50
read time and i [23.0] 51
read time and i [24.0] 52
read time and i [4021.0] 53
read time and i [23.0] 54
read time and i [23.0] 55
read time and i [4026.0] 56
read time and i [20.0] 57
read time and i [23.0] 58
read time and i [4023.0] 59
read time and i [23.0] 60
read time and i [23.0] 61
read time and i [4023.0] 62
read time and i [26.0] 63
read time and i [20.0] 64
read time and i [4023.0] 65
read time and i [26.0] 66
read time and i [20.0] 67
read time and i [4022.0] 68
read time and i [23.0] 69
read time and i [26.0] 70
read time and i [4019.0] 71
read time and i [23.0] 72
read time and i [23.0] 73
read time and i [4025.0] 74
read time and i [23.0] 75
read time and i [23.0] 76
read time and i [25.0] 77
read time and i [4019.0] 78
read time and i [23.0] 79
read time and i [23.0] 80
read time and i [4023.0] 81
read time and i [23.0] 82
read time and i [38.0] 83
read time and i [4024.0] 84
read time and i [20.0] 85
read time and i [23.0] 86
read time and i [4021.0] 87
read time and i [23.0] 88
read time and i [23.0] 89
read time and i [4024.0] 90
read time and i [25.0] 91
read time and i [21.0] 92
read time and i [4021.0] 93
read time and i [23.0] 94
read time and i [23.0] 95
read time and i [4002.0] 96
read time and i [23.0] 97
read time and i [26.0] 98
read time and i [4042.0] 99
read time and i [23.0] 100
read time and i [23.0] 101
read time and i [4023.0] 102
read time and i [23.0] 103
read time and i [23.0] 104
read time and i [4007.0] 105
read time and i [20.0] 106
read time and i [23.0] 107
read time and i [4043.0] 108
read time and i [22.0] 109
read time and i [23.0] 110
read time and i [4024.0] 111
read time and i [26.0] 112
read time and i [20.0] 113
read time and i [4024.0] 114
read time and i [25.0] 115
read time and i [21.0] 116
read time and i [4022.0] 117
read time and i [23.0] 118
read time and i [26.0] 119
read time and i [20.0] 120
read time and i [4022.0] 121
read time and i [23.0] 122
read time and i [23.0] 123
read time and i [4025.0] 124
read time and i [23.0] 125
read time and i [26.0] 126
read time and i [4010.0] 127
As you can see almost every 3th , 4th element in vMicros array is pretty big around 4000 us and average is around 23 us and I don’t have any idea why why why ?
Maybe I shouldn’t put :
vMicros[sampleCounter] = micros();
inside interrupt routine but nothing is “bothering” interrupt routine until is done also after that I just print out copy of vMicros array so nothing at all shouldn’t block during sample reading in that interrupt routine so why this timing sample looks so weird