CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Hi! need help on connecting DG406 to PIC18F2523 (ccs c)

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
khan



Joined: 12 Dec 2012
Posts: 2

View user's profile Send private message

Hi! need help on connecting DG406 to PIC18F2523 (ccs c)
PostPosted: Wed Dec 12, 2012 12:48 pm     Reply with quote

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

View user's profile Send private message AIM Address

PostPosted: Thu Dec 13, 2012 8:05 am     Reply with quote

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..... Very Happy Very Happy


[/quote]
temtronic



Joined: 01 Jul 2010
Posts: 9227
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Dec 13, 2012 8:42 am     Reply with quote

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

View user's profile Send private message

pic +DG406 prob
PostPosted: Thu Dec 13, 2012 1:40 pm     Reply with quote

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

View user's profile Send private message

Re: pic +DG406 prob
PostPosted: Thu Dec 13, 2012 3:53 pm     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group