View previous topic :: View next topic |
Author |
Message |
noral
Joined: 09 May 2014 Posts: 4
|
Sigma-Delta ADC in PIC24FJ128GC010 |
Posted: Fri May 09, 2014 8:51 am |
|
|
Hi guys,
I'm doing a project with a PIC24FJ128GC010 and an analog accelerometer. I must to confess that I'm new in this world.
My question is how can I read the information from the accelerometer in the sigma-delta adc channel. I've been searching in the web unsuccesfully.
Could anybody help me?
Thanks in advance. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19499
|
|
Posted: Fri May 09, 2014 2:09 pm |
|
|
Look in the compiler manual, under setup_sd_adc, setup_sd_adc_channel, read_sd_adc, and set_sd_adc_calibration.
Reason the web is quiet, is it is a pretty new feature, and few people have played with it. |
|
|
mikedann
Joined: 16 Jul 2014 Posts: 6 Location: South Africa
|
Re: Sigma-Delta ADC in PIC24FJ128GC010 |
Posted: Wed Jul 16, 2014 1:37 am |
|
|
Hi there, am also just starting to use the PIC24FJ128GC006 (similar to PIC24FJ128GC010) and battling to use both the Pipeline ADC and the Sigma-Delta ADC. Has anyone else had any success with these peripherals using CCS?
Thanks, Mike.
noral wrote: | Hi guys,
I'm doing a project with a PIC24FJ128GC010 and an analog accelerometer. I must to confess that I'm new in this world.
My question is how can I read the information from the accelerometer in the sigma-delta adc channel. I've been searching in the web unsuccesfully.
Could anybody help me?
Thanks in advance. |
|
|
|
NWilson
Joined: 30 Jun 2011 Posts: 21 Location: King's Lynn. England
|
|
Posted: Mon Sep 01, 2014 8:28 am |
|
|
Welcome to the club. I've been battling with it's peripherals for the last couple of weeks. So far I've managed to setup the internal op-amps, bandgap references and Pipeline ADC.
To get the Pipeline ADC working reliably I had to do the following:
Code: |
#bit ADIF=getenv("BIT:AD1IF")
unsigned int16 nADC_Val;
unsigned int16 nADC_Timeout = 0;
ADIF=FALSE; // Reset interrupt flag
setup_adc_ports(sAN3, VSS_VDD); // RB3 = input to read
setup_adc(ADC_CLOCK | ADC_TAD_MUL_8); // Setup clock and aquisition time
set_adc_channel(3); // Set Mux to Channel 3
//Then at each reading
read_adc(ADC_START_ONLY);
while (!ADIF){ // Wait here for ADC to complete or timeout
restart_wdt();
nADC_Timeout++;
if (nADC_Timeout > 1000) break;
}
if (g_nADC_Timeout < 1000) // ADC completed
nADC_Val = read_adc(ADC_READ_ONLY);
|
I've temporarily given up on getting the USB working. Now struggling with the Sigma-Delta ADC.
Regards
Neil |
|
|
juliogtd
Joined: 01 Jan 2009 Posts: 6
|
Sigma Delta ADC Solved |
Posted: Tue Nov 01, 2016 2:53 pm |
|
|
In my experience, the read_sd_adc () command does not work properly. So I had to write a new read_SDadc () function... and it works.
Code: | #include <24FJ128GC006.h>
#word IFS6 = 0x0090
#word SD1RESH = 0x04D6
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int16 SDvalor, SDerrOffset, SDmaxValue, SDvalorCorrected;
int32 tmp;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int16 read_SDadc(void){
for(unsigned int8 i= 0; i<6; i++){
bit_clear(IFS6,9);
while(!bit_test(IFS6,9));
}
return SD1RESH;
} // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void main(){
set_sd_adc_channel(0);
setup_SD_adc(SDADC_ENABLED|SDADC_BW_NORMAL|SDADC_SVDD_SVSS|SDADC_DITHER_HIGH|SDADC_GAIN_1,SDADC_ROUND_16_BITS |
SDADC_CHOPPING_ENABLED|SDADC_RES_UPDATED_EVERY_INT |SDADC_INT_EVERY_SAMPLE,SDADC_CLK_FRC|SDADC_OSR_1024|SDADC_CLOCK_DIV_2);
set_sd_adc_calibration(SDADC_START_CALIBRATION_MODE);
SDerrOffset = read_SDadc();
set_sd_adc_calibration(SDADC_END_CALIBRATION_MODE);
set_sd_adc_channel(SDADC_REFERENCE);
SDmaxValue = read_SDadc()-SDerrOffset;
set_sd_adc_channel(0);
SDvalor = read_SDadc();
tmp = (int32)(SDvalor-DerrOffset)*0x00007FFF/(int32)SDmaxValue;
if(tmp > 32767) tmp= 32767;
else if(tmp < -32768) tmp= -32768;
SDvalorCorrected = (int16)tmp;
for(;;);
} // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
|