View previous topic :: View next topic |
Author |
Message |
khan
Joined: 12 Dec 2012 Posts: 2
|
Hi! need help on connecting DG406 to PIC18F2523 (ccs c) |
Posted: Wed Dec 12, 2012 12:48 pm |
|
|
I want to measure DC voltages(0-40v) and currents(0-200v).
Voltage isolated and reduced to 0-5V and current sensed by Hall effect and conditioned to 0-5V signals (coming from the outputs of ISO122 and AD620) to the 16 inputs of DG406.
Voltage & current precision required are 0.1V/A (12-bit resolution).
Signals are connected to the DG406 through passive low pass 50R (series) and 4.7uf at DG406 inputs to ground.
Output of mux is connected to controller analog in (0.05uf at this pin.)
Crystal = 20MHz,
ADC clock= 0.8uS
Acq time= 3.2uS
ccs code is given below. Accuracy acheived is 9-bit and also ADC counts are fluctuating:
Code: | setup_adc_ports(AN0|VSS_VREF);
setup_adc(ADC_CLOCK_DIV_4|ADC_TAD_MUL_16); //0.8uS
{ // Acquire_Data (void)
for(ch=0;ch<16;ch++) //DG406 channels
{
output_b (ch);
delay_us(70);
set_adc_channel(0);
delay_us(4);// 4Tad
for(sample=0;sample<8;sample++)
{
read_adc(1); //starts
delay_us(11); //required for conversion
value = read_adc(6);
sum[ch]=sum[ch]+value;
delay_us(4); //2Tad
}
output_b (15);
//set_adc_channel(0X0F);
delay_us(70);
}
//calculate average
for(i=0;i<12;i++)
AN[i]= sum[i]>>3;
} |
|
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Thu Dec 13, 2012 8:05 am |
|
|
there is an awful lot of code MISSING CODE here,
not to mention that pesky SCHEMATIC of what you are up to.
this bit gave me a nice laugh as is...
//calculate average
for(i=0;i<12;i++)
AN[i]= sum[i]>>3;
GIGO rules.....
[/quote] |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9221 Location: Greensville,Ontario
|
|
Posted: Thu Dec 13, 2012 8:42 am |
|
|
You need to go back to the basics.
Create a SIMPLE program to select and read ONE channel of the mux and display onto either local LCD or send to PC. Confirm that the 'numbers' agree.That the displayed voltage is close to the actual input.
When this works, expand the code to select the inputs you need,process the data and carry on....
Without seeing a schematic,complete code, picture of the setup it's impossible to diagnose where your problems are.The more information you supply the faster you'll get some replies.
hth
jay |
|
|
khan
Joined: 12 Dec 2012 Posts: 2
|
pic +DG406 prob |
Posted: Thu Dec 13, 2012 1:40 pm |
|
|
Thanks for your response.
I have already done single channel and its ok.
Then I selected single channel through DG406, its also ok
but when I add 16 channels the digital read is noisy. I'm giving schematics below. |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
Re: pic +DG406 prob |
Posted: Thu Dec 13, 2012 3:53 pm |
|
|
khan wrote: |
but when I add 16 channels the digital read is noisy. |
I sense un-buffered high-impedance voltage dividers directly coupled to the ADC channels coming. _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
|