ashfsk said:
Also adding these many 10-bit values doesnt seem possible without overflow.
If you use a higher language such as PIC Basic, it does the work for you, I was interested at the sample rate, so I ran a few tests. It was comparing a 16F877 and a 18F452.
Both were running at maximum speed, i.e. the 16F877 was 20Mhz, and the 18F452 was 40Mhz (PLL enabled). Both programs were very similar,
16F877 Code;
Code:
Device = 16F877
XTAL = 20
Dim Result As Word
Dim X As Byte
Dim myarray1[100] As Byte
Declare ADIN_RES 8 ' 8-bit result required
Declare ADIN_TAD 8_FOSC '
Declare ADIN_STIME 0 ' Allow 10us sample time
Low PORTB.0
Main:
X = 0
Repeat
Inc X
myarray1[X] = ADIn 0
Until X = 100
PORTB.0 = 1
PORTB.0 = 0
GoTo Main
18F452 Code;
Code:
Device = 18F452
XTAL = 10
Declare PLL_REQ = On '40Mhz
Dim Result As Word
Dim X As Byte
Dim myarray1[100] As Byte
Declare ADIN_RES 8 ' 8-bit result required
Declare ADIN_TAD 8_FOSC '
Declare ADIN_STIME 0 ' Allow 10us sample time
Low PORTB.0
Main:
X = 0 ' start A/D run
Repeat
Inc X
myarray1[X] = ADIn 0
Until X = 100
PORTB.0 = 1
PORTB.0 = 0
GoTo Main
As you can see, the program acquires 100 samples from ADC Channel 0 (PORTA.0). PORTB.0 is toggled so I can clock each time 100 samples has been taken, and see it on an external frequency counter
I experimented with both 10 Bit and 8 Bit resolution, here’s the 8 Bit results;
16F877 = 44600 Samples/Second
18F452 = 175300 Samples/Second
Now with a couple of changes for 10 Bit resolution;
Code:
Device = 18F452
XTAL = 10
Declare PLL_REQ = On '40Mhz
Dim Result As Word
Dim X As Byte
Dim myarray1[100] As [COLOR="Red"][B]Word[/B][/COLOR]
Declare ADIN_RES [COLOR="Red"][B]10[/B][/COLOR] ' 10-bit result required
Declare ADIN_TAD 8_FOSC '
Declare ADIN_STIME 0 ' Allow 10us sample time
And the sample rate afterwards;
16F877 = 30100 Samples/Second
18F452 = 153800 Samples/Second
Its clear that the 18F452 is by far the superior from these results, it would be a combination of a few things, but mainly because of its PLL ability, so that it can function at 40Mhz, and extended instruction set that all 18F's have
This is not specifically directed as an answer for your post, but could provide a quick guide on how to make efficient samples in PIC Basic.
After you have sampled, you can do what you please with the data