cancel
Showing results for 
Search instead for 
Did you mean: 

Any ideas with regard to spurious ADC values

Lorne Vaasjo
Associate II
Posted on February 27, 2017 at 20:05

I am using the ADC+DMA to collect samples for AC power calculations.  The voltage and current are well buffered (low impedance sources) sampled at about 7kHz.

The data acquisition will work properly for many seconds (between 10 and 40) but then I will get a series of ADC readings in the raw data that are completely incorrect.

To try to figure this out I am collecting the raw ADC values in a buffer that collects one second of data and gets re-written until a spurious value arrives.

The following is a part of the raw ADC buffer showing spurious data in samples 58 through 70.

I have experimented with different sample rates, buffer sizes and adc settling times but haven't found anything that gets rid of the problem.

The processor used is an STM32F030CCT6 using a 28MHz external crystal.

The 'raw values' below are relative to the prevous 1 second average value for each reading (thus the negative values) and the sample rate is lowered from the 7kHz.

sample#, rawVolts, rawCurrent, v*i/100

26,78,-1,0

27,171,-1,-1

28,269,-1,-2

29,358,0,0

30,544,2,10

31,537,-1,-5

32,494,-2,-9

33,429,-1,-4

34,353,-1,-3

35,277,0,0

36,180,-1,-1

37,68,0,0

38,-35,0,0

39,-125,0,0

40,-223,-1,2

41,-317,-2,6

42,-396,-2,7

43,-453,-2,9

44,-500,-1,5

45,-529,-1,5

46,-541,-2,10

47,-541,0,0

48,-521,-1,5

49,-463,-1,4

50,-391,-1,3

51,-316,-2,6

52,-231,-1,2

53,-123,-1,1

54,-14,0,0

55,80,0,0

56,174,1,1

57,272,-1,-2

58,360,1990,7164

59,-1488,1991,-29626

60,-1991,1939,-38605

61,-1991,1991,-39640

62,-455,-960,4368

63,-1133,-1986,22501

64,-1987,637,-12657

65,461,1931,8901

66,-1931,11,-212

67,859,-1990,-17094

68,-1991,295,-5873

69,-545,5,-27

70,-1931,-1,19

71,-33,-1,0

72,-124,0,0

73,-222,-1,2

74,-317,0,0

75,-396,-2,7

76,-451,-1,4

77,-499,-1,4

78,-529,-1,5

79,-541,-1,5

80,-542,-1,5

81,-519,0,0

82,-464,-1,4

83,-392,-1,3

84,-316,-1,3

85,-232,-2,4

86,-124,-1,1

87,-15,0,0

88,80,-1,0

89,173,0,0

90,270,-1,-2

91,360,-1,-3

92,439,2,8

93,477,-1,-4

94,518,-2,-10

95,536,-1,-5

96,544,-1,-5

97,536,0,0

98,498,0,0

99,430,0,0

100,355,-1,-3

101,278,0,0

102,179,-1,-1

103,67,-1,0

104,-31,-1,0

105,-124,-1,1

106,-222,-1,2

107,-316,0,0

108,-396,-1,3

109,-451,0,0

110,-499,-2,9

111,-529,-1,5

112,-542,-1,5

113,-541,0,0

114,-521,-1,5

115,-464,-1,4

116,-392,-1,3

117,-318,0,0

118,-232,-1,2

119,-124,-1,1

120,-16,-1,0

121,79,0,0

122,171,0,0

123,270,-1,-2

124,359,-1,-3

125,427,-1,-4

126,475,-1,-4

127,517,-1,-5

128,536,-1,-5

129,544,0,0

130,536,-1,-5

131,498,0,0

132,432,0,0

133,354,0,0

134,280,-2,-5

135,181,-1,-1

136,69,-1,0

137,-33,-1,0

138,-124,-1,1

139,-220,-1,2

140,-315,0,0

141,-395,-1,3

142,-451,-1,4

143,-498,-1,4

144,-528,-1,5

145,-541,-1,5

146,-541,-1,5

147,-524,-1,5

148,-466,0,0

149,-391,0,0

150,-318,1,-3

151,-232,-1,2

152,-125,-1,1

153,-16,-1,0

154,78,-1,0

155,171,-1,-1
6 REPLIES 6
Posted on February 27, 2017 at 21:55

Are you managing the buffer in a ping-pong fashion, with HT and TC interrupts, so that you are not doing analysis of live data that might be changing via DMA action on the buffer in the background?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
S.Ma
Principal
Posted on February 27, 2017 at 22:09

What happen if you scan only one channel?

Activate the analog watchdog to see and even stop as soon as the weird values are detected.

By toggling a GPIO to make a pulse when the weird values are detected, analog check can be done using an oscilloscope.

Posted on February 28, 2017 at 01:11

I'm using a circular buffer and processing the oldest half of the data buffer on both complete and half-complete dma interrupts. I am using the correct half of the buffers as well.  I put a port line high during the processing and the processing time is about 1/20 of the collection time so I'm not ever accessing data that's changing. I also keep track of the worst case number of clock ticks that occur during the processing and that indicates the processing never takes extra time.

Posted on February 28, 2017 at 01:56

I haven't tried using a single channel but have jumpered one input to an extra channel to see if the values track. They do track except when strange data occurs which indicates the issue is likely and internal one and not an issue with the voltage on the pin(s). I need to do some further testing to be sure that is always the case.

Posted on February 28, 2017 at 07:19

By using the analog watchdog, it will tell if the problem is on the ADC side or it is a memory bus bandwidth or wrong free SRAM area. 

AvaTar
Lead
Posted on February 28, 2017 at 09:07

The data acquisition will work properly for many seconds (between 10 and 40) but then I will get a series of ADC readings in the raw data that are completely incorrect.

Excluding a DMA vs. core access issue (as Clive One suggested), that sounds like some race condition.

Perhaps this 10 .. 40 seconds is about the time for two events (interrupts ?) to overlap statistically.

Either another handler takes too long, or there is some kind of bus contention that keep the DMA from picking up the ADC value.

Have you checked the errata ?