Shop OBEX P1 Docs P2 Docs Learn Events
ADC Sampling Breakthrough - Page 9 — Parallax Forums

ADC Sampling Breakthrough

1679111252

Comments

  • evanhevanh Posts: 15,915
    edited 2018-11-23 08:16
    cgracey wrote: »
    What does that graph mean? I need to look at his code.

    Nothing complicated. The graph is just a direct plot of filtered readings. I render it to a huge bitmap just to eyeball for ripples.

    It's all my code, btw.

    EDIT: Here's an example of the ramping bitstream: https://forums.parallax.com/discussion/download/124347/rampbitstream.bin
  • cgraceycgracey Posts: 14,152
    evanh wrote: »
    cgracey wrote: »
    What does that graph mean? I need to look at his code.

    Nothing complicated. The graph is just a direct plot of filtered readings. I render it to a huge bitmap just to eyeball for ripples.

    It's all my code, btw.

    EDIT: Here's an example of the ramping bitstream: https://forums.parallax.com/discussion/download/124347/rampbitstream.bin

    Ok. I'm not at my computer, so I can't look at the file, but does the duty cycle range from about 1/7th to 6/7th?
  • evanhevanh Posts: 15,915
    edited 2018-11-23 08:35
    Full sweep of 50,000.

    I probably should have tried a slower ramp with a smaller NCO. Tighter spread that way.
  • cgraceycgracey Posts: 14,152
    evanh wrote: »
    1/50,000th

    1 bit high in 50k bits?
  • cgraceycgracey Posts: 14,152
    By 1/7th, i mean 000000100000010000001...
  • cgraceycgracey Posts: 14,152
    I was supposing that over 50k bits, you went from 0000001-repeat to 0111111-repeat.
  • evanhevanh Posts: 15,915
    edited 2018-11-23 08:56
    You're right. The sweep is 50k bits. The NCO is also 50k though. So, first 1-bit occurs at clock 315 ... second 1-bit occurs at clock 446.

  • cgraceycgracey Posts: 14,152
    evanh wrote: »
    You're right. The sweep is 50k bits. The NCO is also 50k though. So, first 1-bit occurs at clock 315 ... second 1-bit occurs at clock 446.

    Okay. Our ADC puts out 0000001 to 0111111, as duty over a 7-bit span. To model that, ramp the NCO from 1/7th of 100% to 6/7th of 100%.

    I believe freq settings would range from 1/7 * $1_0000_0000 to 6/7 * $1_0000_0000.
  • cgraceycgracey Posts: 14,152
    Modeling the ADC may be superfluous, actually, Evanh.

    What I am really curious about is how many clocks does it take to get a sample of N-bit quality, and then how many past samples influence the current sample.

    I really want to understand this concept.
  • cgraceycgracey Posts: 14,152
    TonyB_, I got home late and I'm tired, so I'll try the latest Tukey's in the morning.
  • evanhevanh Posts: 15,915
    edited 2018-11-23 09:36
    The differing parameters means each graph scales according to whatever readings are produced. I'm not rescaling anything yet. Note: Discontinuous sampling doesn't get close to the same bit depth as full blown continuous Sinc2.

    That latest discontinuous Sinc2 method is producing peak values of just over 8k. So 13-bit depth from 256 clocks per reading. Fully continuous is 16-bit depth from 256 clocks.

  • evanhevanh Posts: 15,915
    cgracey wrote: »
    and then how many past samples influence the current sample.

    My chosen method for doing single discontinuous sampling is to subdivide the 256 clocks into 4 chunks of 64 clocks. Run them as 4 continuous chunks. Discard the first two results then, finally, add the remaining two together.

  • Chip had too much Turkey to do a Tukey.
  • evanhevanh Posts: 15,915
    :)
  • ErNaErNa Posts: 1,752
    evanh wrote: »
    By leaving the smartpin disabled, Chip is able to use a Streamer to capture every clocked bit into a buffer in hubram, packed as 32 bits per longword, and then apply different effects.

    That's just what I'm asking for, having original data. I could try to do the job on P1, but in this case I do not know for sure, if it can be tranfered to the P2.
    So it would be very helpfull to have the data stream, so I can make experiments here. If I understand right, Chip can not transfer data to a file on the pc.
  • We can do this stream, Erna. OzProp showed the ADC data streams for VIO and GIO using his logic analyzer. I think at the time the focus was on the variable staggered start, rather than the ADC data stream itself. It may take a few days...

  • ErNaErNa Posts: 1,752
    it's ok, as soon as I see a data stream I can try to figure out, if there is certain character of the noise. We will see, hopefully it is. And it is a very basic experiment I never did...
  • The same expectation here; sounds very interesting having many data streams available, in order to try some thoughtful analysis at their contents.

    If possible, it'll be good to include at least some grouped samples, showing simultaneous captured twits and nibbles data, of two and four closely-coupled ADCs (pertaining to the same GIO/VIO group).

    Despite some (not so) minute differences that could exist between their internal components and the several ways they can be affected by incident noise sources, many interesting patterns could emerge from those analysis, beyound the ones already noticed by Chip and others.

    The solely concern will be related to the assembly order of samples, when creating any resulting files; some previous agreement between the ones intending to collect them could someway ease any post-proccessing, in order to split them appart.

  • The actual ADC hardware is modulating the bitstream. This bitstream appears as a digital pin IN data bit every sysclock. By leaving the smartpin disabled, Chip is able to use a Streamer to capture every clocked bit into a buffer in hubram, packed as 32 bits per longword, and then apply different effects.

    I missed that. Plz ignore my bitstream comment.

  • cgraceycgracey Posts: 14,152
    evanh wrote: »
    The differing parameters means each graph scales according to whatever readings are produced. I'm not rescaling anything yet. Note: Discontinuous sampling doesn't get close to the same bit depth as full blown continuous Sinc2.

    That latest discontinuous Sinc2 method is producing peak values of just over 8k. So 13-bit depth from 256 clocks per reading. Fully continuous is 16-bit depth from 256 clocks.

    Okay, sounds great, but when you say 13-bit or 16-bit depth from 256 samples, are you able to resolve every single possible 13-bit or 16-bit value from 256 samples? This seems, to me, the true criteria for being able to claim we've doubled the bit depth. That's what I'm totally not clear on.
  • TonyB_TonyB_ Posts: 2,178
    edited 2018-11-23 21:38
    How much Tukey can you swallow?
    #Tukey Samples/Max, Values
     2/32, 5,27
     3/32, 0,16,32
     4/32, 1,10,22,31
     5/32, 0, 5,16,27,32
     6/32, 1, 5,12,20,27,31
     7/32, 0, 2, 8,16,24,30,32
     8/32, 0, 3, 7,13,19,25,29,32
     9/32, 0, 1, 5,10,16,22,27,31,32
    10/32, 0, 2, 5, 9,13,19,23,27,30,32
    11/32, 0, 1, 3, 7,11,16,21,25,29,31,32
    12/32, 0, 1, 3, 6,10,14,18,22,26,29,31,32
    13/32, 0, 1, 2, 5, 8,12,16,20,24,27,30,31,32
    14/32, 0, 1, 2, 5, 7,11,14,18,21,25,27,30,31,32
    15/32, 0, 0, 2, 3, 6, 9,12,16,20,23,26,29,30,32,32
    16/32, 0, 1, 2, 4, 6, 8,11,14,18,21,24,26,28,30,31,32
    17/32, 0, 0, 1, 3, 5, 7,10,13,16,19,22,25,27,29,31,32,32
    18/32, 0, 1, 1, 3, 5, 7, 9,12,15,17,20,23,25,27,29,31,31,32
    19/32, 0, 0, 1, 2, 4, 6, 8,11,13,16,19,21,24,26,28,30,31,32,32
    20/32, 0, 0, 1, 2, 4, 6, 8,10,12,15,17,20,22,24,26,28,30,31,32,32
    21/32, 0, 0, 1, 2, 3, 5, 7, 9,11,13,16,19,21,23,25,27,29,30,31,32,32
    22/32, 0, 0, 1, 2, 3, 5, 6, 8,10,13,15,17,19,22,24,26,27,29,30,31,32,32
    23/32, 0, 0, 1, 1, 3, 4, 6, 7, 9,11,14,16,18,21,23,25,26,28,29,31,31,32,32
    24/32, 0, 0, 1, 2, 3, 4, 5, 7, 9,11,13,15,17,19,21,23,25,27,28,29,30,31,32,32
    25/32, 0, 0, 1, 1, 2, 3, 5, 6, 8,10,12,14,16,18,20,22,24,26,27,29,30,31,31,32,32
    26/32, 0, 0, 1, 1, 2, 3, 5, 6, 8, 9,11,13,15,17,19,21,23,24,26,27,29,30,31,31,32,32
    27/32, 0, 0, 0, 1, 2, 3, 4, 5, 7, 9,10,12,14,16,18,20,22,23,25,27,28,29,30,31,32,32,32
    28/32, 0, 0, 1, 1, 2, 3, 4, 5, 7, 8,10,12,13,15,17,19,20,22,24,25,27,28,29,30,31,31,32,32
    29/32, 0, 0, 0, 1, 2, 2, 3, 5, 6, 7, 9,11,12,14,16,18,20,21,23,25,26,27,29,30,30,31,32,32,32
    30/32, 0, 0, 1, 1, 2, 3, 4, 5, 6, 7, 9,10,12,13,15,17,19,20,22,23,25,26,27,28,29,30,31,31,32,32
    31/32, 0, 0, 0, 1, 1, 2, 3, 4, 5, 7, 8, 9,11,13,14,16,18,19,21,23,24,25,27,28,29,30,31,31,32,32,32
    32/32, 0, 0, 0, 1, 2, 2, 3, 4, 5, 6, 8, 9,11,12,14,15,17,18,20,21,23,24,26,27,28,29,30,30,31,32,32,32
    
    All the Tukey7/32 values are even and five of them are exact (others are 2.14 and 29.86), therefore excellent logic-wise but probably too short to be useful.

    #Tukey Samples/Max, Chi-Square, Increments
    #Rounded values ignored for Chi-Square if < 2
     2/32, 0.0246,22
     3/32, 0.0003,16,16
     4/32, 0.0037, 9,12, 9
     5/32, 0.0246, 5,11,11, 5
     6/32, 0.0338, 4, 7, 8, 7, 4
     7/32, 0.0103, 2, 6, 8, 8, 6, 2
     8/32, 0.0444, 3, 4, 6, 6, 6, 4, 3
     9/32, 0.0283, 1, 4, 5, 6, 6, 5, 4, 1
    10/32, 0.1082, 2, 3, 4, 4, 6, 4, 4, 3, 2
    11/32, 0.0343, 1, 2, 4, 4, 5, 5, 4, 4, 2, 1
    12/32, 0.0503, 1, 2, 3, 4, 4, 4, 4, 4, 3, 2, 1
    13/32, 0.0441, 1, 1, 3, 3, 4, 4, 4, 4, 3, 3, 1, 1
    14/32, 0.1739, 1, 1, 3, 2, 4, 3, 4, 3, 4, 2, 3, 1, 1
    15/32, 0.2232, 0, 2, 1, 3, 3, 3, 4, 4, 3, 3, 3, 1, 2, 0
    16/32, 0.1314, 1, 1, 2, 2, 2, 3, 3, 4, 3, 3, 2, 2, 2, 1, 1
    17/32, 0.0727, 0, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 2, 2, 2, 1, 0
    18/32, 0.0805, 1, 0, 2, 2, 2, 2, 3, 3, 2, 3, 3, 2, 2, 2, 2, 0, 1
    19/32, 0.0873, 0, 1, 1, 2, 2, 2, 3, 2, 3, 3, 2, 3, 2, 2, 2, 1, 1, 0
    20/32, 0.1496, 0, 1, 1, 2, 2, 2, 2, 2, 3, 2, 3, 2, 2, 2, 2, 2, 1, 1, 0
    21/32, 0.1425, 0, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 0
    22/32, 0.1408, 0, 1, 1, 1, 2, 1, 2, 2, 3, 2, 2, 2, 3, 2, 2, 1, 2, 1, 1, 1, 0
    23/32, 0.2373, 0, 1, 0, 2, 1, 2, 1, 2, 2, 3, 2, 2, 3, 2, 2, 1, 2, 1, 2, 0, 1, 0
    24/32, 0.1726, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 0
    25/32, 0.0945, 0, 1, 0, 1, 1, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 1, 1, 0, 1, 0
    26/32, 0.1874, 0, 1, 0, 1, 1, 2, 1, 2, 1, 2, 2, 2, 2, 2, 2, 2, 1, 2, 1, 2, 1, 1, 0, 1, 0
    27/32, 0.1199, 0, 0, 1, 1, 1, 1, 1, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 1, 1, 1, 1, 1, 0, 0
    28/32, 0.1009, 0, 1, 0, 1, 1, 1, 1, 2, 1, 2, 2, 1, 2, 2, 2, 1, 2, 2, 1, 2, 1, 1, 1, 1, 0, 1, 0
    29/32, 0.3971, 0, 0, 1, 1, 0, 1, 2, 1, 1, 2, 2, 1, 2, 2, 2, 2, 1, 2, 2, 1, 1, 2, 1, 0, 1, 1, 0, 0
    30/32, 0.2800, 0, 1, 0, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 2, 2, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 0, 1, 0
    31/32, 0.1402, 0, 0, 1, 0, 1, 1, 1, 1, 2, 1, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 1, 2, 1, 1, 1, 1, 0, 1, 0, 0
    32/32, 0.3195, 0, 0, 1, 1, 0, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 1, 1, 1, 0, 1, 1, 0, 0
    
    A Chi-Square goodness of fit total was calculated, the sum of (Rounded-Exact)^2/Exact. As the largest error possible is 0.5, this sum is completely distorted by errors in very low values which have no effect in practice and any errors for rounded values of 0 and 1 have been ignored.
  • Tukey17/32 is linear in the mid-range and the middle 15 values would be a good alternative to 16/32:
    17/32, 0, 0, 1, 3, 5, 7,10,13,16,19,22,25,27,29,31,32,32
    
  • cgraceycgracey Posts: 14,152
    Great, TonyB_!

    I am thinking that for general purposes, this windowing can be accomplished IN SERIES with the bitstream.

    In any of these windowing schemes, the end number of possible whole-bit contributions is around length/2 for either tapered end. This could be computed on the fly for summing ADC operations, since bit order is not important. For Goertzel, you can't toy with the positions of bits. This would mean that no final right-shift would be needed. Rounding could be handled in series, too.
  • TonyB_TonyB_ Posts: 2,178
    edited 2018-11-23 19:36
    cgracey wrote: »
    Great, TonyB_!

    I am thinking that for general purposes, this windowing can be accomplished IN SERIES with the bitstream.

    In any of these windowing schemes, the end number of possible whole-bit contributions is around length/2 for either tapered end. This could be computed on the fly for summing ADC operations, since bit order is not important. For Goertzel, you can't toy with the positions of bits. This would mean that no final right-shift would be needed. Rounding could be handled in series, too.

    So no Tukey window in hardware? I don't mind, if so. If the window is sliding by one sample at a time, then only one bit has to be removed in one ramp and one added in the other. A table of increments between the adjacent ramp values, not the actually values, is what would be needed.

    EDIT:
    On second thoughts last sentence is probably wrong.
  • cgraceycgracey Posts: 14,152
    TonyB_ wrote: »
    cgracey wrote: »
    Great, TonyB_!

    I am thinking that for general purposes, this windowing can be accomplished IN SERIES with the bitstream.

    In any of these windowing schemes, the end number of possible whole-bit contributions is around length/2 for either tapered end. This could be computed on the fly for summing ADC operations, since bit order is not important. For Goertzel, you can't toy with the positions of bits. This would mean that no final right-shift would be needed. Rounding could be handled in series, too.

    So no Tukey window in hardware? I don't mind, if so. If the window is sliding by one sample at a time, then only one bit has to be removed in one ramp and one added in the other. A table of increments between the adjacent ramp values, not the actually values, is what would be needed.

    Tukey or trapezoid could be used.
  • cgraceycgracey Posts: 14,152
    Before we can know which way is best to proceed, we need to understand what Evanh is working on. It might be that we have an additional 8-bit bus from each smart pin conveying eight bits of ADC sample per clock.
  • jmgjmg Posts: 15,173
    TonyB_ wrote: »
    How much Tukey can you swallow?
    #Tukey Samples/Max, Values
     2/32, 5,27
     3/32, 0,16,32
     4/32, 1,10,22,31
     5/32, 0, 5,16,27,32
     6/32, 1, 5,12,20,27,31
     7/32, 0, 2, 8,16,24,30,32
     8/32, 0, 3, 7,13,19,25,29,32
     9/32, 0, 1, 5,10,16,22,27,31,32
    10/32, 0, 2, 5, 9,13,19,23,27,30,32
    11/32, 0, 1, 3, 7,11,16,21,25,29,31,32
    12/32, 0, 1, 3, 6,10,14,18,22,26,29,31,32
    13/32, 0, 1, 2, 5, 8,12,16,20,24,27,30,31,32
    14/32, 0, 1, 2, 5, 7,11,14,18,21,25,27,30,31,32
    15/32, 0, 0, 2, 3, 6, 9,12,16,20,23,26,29,30,32,32
    16/32, 0, 1, 2, 4, 6, 8,11,14,18,21,24,26,28,30,31,32
    17/32, 0, 0, 1, 3, 5, 7,10,13,16,19,22,25,27,29,31,32,32
    18/32, 0, 1, 1, 3, 5, 7, 9,12,15,17,20,23,25,27,29,31,31,32
    19/32, 0, 0, 1, 2, 4, 6, 8,11,13,16,19,21,24,26,28,30,31,32,32
    20/32, 0, 0, 1, 2, 4, 6, 8,10,12,15,17,20,22,24,26,28,30,31,32,32
    21/32, 0, 0, 1, 2, 3, 5, 7, 9,11,13,16,19,21,23,25,27,29,30,31,32,32
    22/32, 0, 0, 1, 2, 3, 5, 6, 8,10,13,15,17,19,22,24,26,27,29,30,31,32,32
    23/32, 0, 0, 1, 1, 3, 4, 6, 7, 9,11,14,16,18,21,23,25,26,28,29,31,31,32,32
    24/32, 0, 0, 1, 2, 3, 4, 5, 7, 9,11,13,15,17,19,21,23,25,27,28,29,30,31,32,32
    25/32, 0, 0, 1, 1, 2, 3, 5, 6, 8,10,12,14,16,18,20,22,24,26,27,29,30,31,31,32,32
    26/32, 0, 0, 1, 1, 2, 3, 5, 6, 8, 9,11,13,15,17,19,21,23,24,26,27,29,30,31,31,32,32
    27/32, 0, 0, 0, 1, 2, 3, 4, 5, 7, 9,10,12,14,16,18,20,22,23,25,27,28,29,30,31,32,32,32
    28/32, 0, 0, 1, 1, 2, 3, 4, 5, 7, 8,10,12,13,15,17,19,20,22,24,25,27,28,29,30,31,31,32,32
    29/32, 0, 0, 0, 1, 2, 2, 3, 5, 6, 7, 9,11,12,14,16,18,20,21,23,25,26,27,29,30,30,31,32,32,32
    30/32, 0, 0, 1, 1, 2, 3, 4, 5, 6, 7, 9,10,12,13,15,17,19,20,22,23,25,26,27,28,29,30,31,31,32,32
    31/32, 0, 0, 0, 1, 1, 2, 3, 4, 5, 7, 8, 9,11,13,14,16,18,19,21,23,24,25,27,28,29,30,31,31,32,32,32
    32/32, 0, 0, 0, 1, 2, 2, 3, 4, 5, 6, 8, 9,11,12,14,15,17,18,20,21,23,24,26,27,28,29,30,30,31,32,32,32
    
    All the Tukey7/32 values are even and five of them are exact (others are 2.14 and 29.86), therefore excellent logic-wise but probably too short to be useful.
    These smaller ones need to be tested and quantified, to get a sense of where the best Logic/gain trade off it.

    I was wondering about the simpler ones, like 7/32, if they can be be applied at a lower clock, if more coverage is needed ?
    eg a 7/32 may be compact enough to have tolerable logic cost, and /2 or /3 could tune the X coverage to what is needed, at low cost.
  • jmgjmg Posts: 15,173
    edited 2018-11-23 20:19
    evanh wrote: »
    cgracey wrote: »
    and then how many past samples influence the current sample.

    My chosen method for doing single discontinuous sampling is to subdivide the 256 clocks into 4 chunks of 64 clocks. Run them as 4 continuous chunks. Discard the first two results then, finally, add the remaining two together.
    That discard decision can be done downstream - the hardware does not have to apply it.
    eg In Chip's MUX Auto-zero-scale-fit mode, he would set for a sample count of 3 for each GND/VIO, but someone may want better AC performance and not worry about DC, so they would prefer nothing discarded & they would skip the Auto stuff..

    What is the actual logic cost of the Sinc2 you are testing here ? - how many wide-adders etc per smart pin ?

    Should smart pins be paired for cases where someone wants highest ADC specs, to save logic ?
    eg Smart Pins are paired by users now for Precise Duty Cycle & Reciprocal Counting.

  • cgracey wrote: »
    Before we can know which way is best to proceed, we need to understand what Evanh is working on. It might be that we have an additional 8-bit bus from each smart pin conveying eight bits of ADC sample per clock.

    Kind of a sample history shift register, with new samples being added to one end, while the older ones are being discarded at the other?
  • jmgjmg Posts: 15,173
    cgracey wrote: »
    Okay. Our ADC puts out 0000001 to 0111111, as duty over a 7-bit span. To model that, ramp the NCO from 1/7th of 100% to 6/7th of 100%.

    I believe freq settings would range from 1/7 * $1_0000_0000 to 6/7 * $1_0000_0000.

    Pondering this clumping effect more, it sounds similar to the SysCLK outpacing the ADC engine, not surprising, as you cannot expect the ADC sense amp to be flat out to 250MHz with 4mV swings.
    Ringing and bounce above 30MHz would appear as clumping.

    If you cannot reduce the ADC sample clock, perhaps a simple bitstream majority voter can be applied to lower the effective sample rate, and (hopefully) scrub that HF noise effect ?
    Logic cost of that is 2 small counters.
Sign In or Register to comment.