|
|
View previous topic :: View next topic |
Author |
Message |
Erol Guest
|
LTC2400 working code... |
Posted: Tue Aug 08, 2006 6:38 pm |
|
|
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
|
|
Posted: Wed Aug 09, 2006 4:01 pm |
|
|
You have a 50ms delay in the LTC_2400_read() function. Do you really need it? It, obviously, slows things down. |
|
|
|
|
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
|