I am using the 2010 to control 3 BDC motors speed set by separate unit with pic16f688 digitising pots and sending via RS232 to 2010 timers RS232 and PWM all ok but I don't understand the ADC in the dspic30 tried many times but never works, I want to read 3 tachos and another analogue signal simultaneously for the PID loops here is my init ADC
can anyone help dick l
Rich (BB code):
void setup_ADC(void)
{
ADCON1bits.ADON = 0; //15 ADC off
ADCON1bits.ADSIDL = 0; //13 continuous was
ADCON1bits.FORM = 0; //9-8 output data in raw format
ADCON1bits.SSRC = 7; //7-5 auto convert
ADCON1bits.SIMSAM = 1; //3 enable simultaneous sampling
ADCON1bits.ASAM = 0; //2 no auto start
ADCON1bits.SAMP = 0; //1 holding
ADCON1bits.DONE= 0; //0 not done
ADCON2bits.VCFG = 0; //15-13 AVDD and AVSS reference
ADCON2bits.CSCNA = 0; //10 do not scan inputs
ADCON2bits.CHPS = 2; //9-8 convert ch0,1,2,3 channels
ADCON2bits.BUFS = 0; //7 lower buff
// ADCON2bits.SMPI = 0; //5-2 interrupt after sample sequence
ADCON2bits.BUFM = 0; //1 single buffer
ADCON2bits.ALTS = 0; //0 use MUXA
ADCON3bits.SAMC = 31; //12-8 Total time = (15 + 15) * Tad = 12us
ADCON3bits.ADRC = 0; //7 system clock
ADCON3bits.ADCS = 63; //5-0 ADC clock Tad = Tcy(ADCS + 1) / 2
ADCHSbits.CH123SA = 0; // AN0 = CH1,AN1 = CH2, AN2 = CH3
ADCHSbits.CH0SA = 3; // CH0 = AN3
ADPCFG = 0xFFF0; // AN0-3 analogue inputs
ADCSSL = 0x0000;
ADCON1bits.ADON = 1; // start
}
Last edited by a moderator: