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 support@ccsinfo.com

LTC2400 working code...

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







LTC2400 working code...
PostPosted: Tue Aug 08, 2006 6:38 pm     Reply with quote

This Code is working with LTC2400 (24 bit, 8 pin ADC)
if you need maybe will can optimize for Conversion time....
Working circuit at :

hxxp://img102.imageshack.us/img102/8969/img1619nr7.jpg

Code:
#include "C:\PROGRA~1\PICC\DEVICES\16F628a.H"
#fuses HS,NOWDT,PUT,BROWNOUT,NOPROTECT,noMCLR,NOLVP
#use delay(clock=8000000,restart_wdt)

#define LTC_CS       PIN_A0      // LTC de 5
#define LTC_SCK      PIN_A2      // LTC de 7
#define LTC_SDA      PIN_A3      // LTC de 6

#byte CMCON0  = 0x19

#define use_portb_lcd TRUE
#include "LCD.C"

int32 degisken=0;
unsigned int ADCBuffer[3];
float gerilim = 0;
float Vref = 4.0962;          // Ölçülen Vref
float Ratio = 45.5934;        // 100K ve 2K2 nin ölçülen oranı

#define FULLSCALE 16777216    // 2^24

int1 ltc_clock()
{
   int1 in=0;
   
   output_high(LTC_SCK);    in=input(LTC_SDA);   delay_ms(5);
   output_low(LTC_SCK);     delay_ms(5);
   
   return(in);
}


void LTC_2400_read()
{
   unsigned int i=0;

   output_low(LTC_SCK);       // clock 0 da olmalı
   output_low(LTC_CS);        // CS ile IC yi seçtik.
   delay_ms(70);

   ltc_clock();   // bit 31   BOŞ
   ltc_clock();   // bit 30   BOŞ
   ltc_clock();   // bit 29   SIG
   ltc_clock();   // bit 28   EXR

   ADCbuffer[0]=0;
   ADCbuffer[1]=0;
   ADCbuffer[2]=0;

   for (i = 1; i <= 24; i++)  shift_left(ADCbuffer,3,ltc_clock());

   output_high(LTC_CS);
   delay_ms(50);

   degisken = make32(ADCBuffer[2],ADCBuffer[1],ADCBuffer[0]);

}

void main()
{
   disable_interrupts(GLOBAL);
   CMCON0=7;
   setup_ccp1(CCP_OFF);
   setup_timer_2(T2_DISABLED,0,1);
   delay_ms(10);
   lcd_init();

   printf(lcd_putc,"\f    LTC2400     ");
   printf(lcd_putc,"\nGELISTIRME KITI ");

   output_high(LTC_CS);
   delay_ms(2000);


while(TRUE)
{
   LTC_2400_read();

   gerilim = (float) degisken / FULLSCALE;
   gerilim *= Vref;
   gerilim *= Ratio;
   
   printf(lcd_putc,"\f ADC : %.3f V",gerilim);
   delay_ms(250);
}
}
kender



Joined: 09 Aug 2004
Posts: 768
Location: Silicon Valley

View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger

PostPosted: Wed Aug 09, 2006 4:01 pm     Reply with quote

You have a 50ms delay in the LTC_2400_read() function. Do you really need it? It, obviously, slows things down.
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