News:

PROTON pic BASIC Compilers for PIC, PIC24, dsPIC33

Main Menu

High speed A/D on 33FJ12GP202

Started by Wimax, Aug 28, 2022, 04:05 PM

Previous topic - Next topic

Wimax

Hello everyone !

I need to sample a signal at a rate greater than or equal to 128 Ksps using the 33FJ12GP202's internal converter operating with a clock of 39.62 MHz. The resolution can be 10 or 12 bits, and the sampling rate should be sufficiently stable for a time of about 1 second. From the data-sheet it appears that the internal ADC can operate up to 500 Ksps at 12 bits and 1.1 Msps at 10 bits.
I have performed a few tests using a simple for-next loop, but I do not exceed 90 Ksps. I use the the compiler instruction ADin with the following settings for the converter

Declare Adin_Tad = cFRC
Declare Adin_Stime = 1


I suppose that to get good sample rate accuracy I should use a Timer and handle the adc with an interrupt, but the conversion should still happen faster.
Is there any way to get better results ?


top204

For fast or specialised sampling do not use the ADin command.

It is a general purpose command for just getting ADC samples.

You will need to setup the ADC using its SFRs for what you require, then create a procedure that starts the ADC and waits of it to finish.

Wimax

Thank you Les for the info. I found "ADin.inc", maybe suitable for this ?

top204

#3
The ADin procedure can be adapted to give more control of the ADC, but you will need to remove the beginning bits and pieces of it, because they are for general purpose use, using FRC and channel etc...

But the procedures show the principle of starting an ADC sample, then waiting for it to finish. The mechanism that tailors the ADC is in its initial setup and the clock it uses etc...

If you check out the "DSP" folder within the "samples24" directory you will see the FIR and FFT programs use a higher speed ADC, and an interrupt to capture it so the program does not have to wait for it to finish.

Wimax

Yes, very very interesting  ;) ! I have to study these nights  :o

Wimax

#5
After long sleepless nights, I may have managed to "squeeze" the ADC, but...I had to face another bottleneck trying to send the data to an external SRAM via SPI.
I used a procedure already verified some time ago (provided by Les), but this time the goal was to push the SPI to higher speeds.
Using the file "SPI_33.inc" and spending some time...I reached interesting results also with a clock of 39.6 MHz (128000 samples acquired and transferred to the RAM in 250 ms).
I don't know if it's possible to get best results with the same clock speed, but I'm very happy now  ;D !