|
|
View previous topic :: View next topic |
Author |
Message |
OJ Guest
|
Help AD7705 @ 1MHz with 1.225 REF |
Posted: Mon Apr 21, 2008 2:05 pm |
|
|
Can someone please help I modified the AD7705 driver with the following:
I am using a PIC18F87J60 @ 25MHz. A MIC1555 is the master clock set @ a frequency of 1MHz and a voltage reference at 1.225V.
I turned off the MCLK out by writing 0x10 as the rate, have reset tied high and DRDY is not connected.
Whats happening is I read the same value no matter what is on the input.
I checked the master clock and it is generating 1MHz. I have 5 boards and I get the same result.
Thanks in advance.
the ADC should be setup unipolar,gain=1,cal=normal rate=20hz
Code: |
#define ADC_DO PIN_D0
#define ADC_DI PIN_D1
#define ADC_CLK PIN_D2
#define ADC_CS PIN_H2
#define OSC_CS PIN_H0 //MIC1555 enable
//Calibration
//#define ADC_NORMAL 0
//#define ADC_SELF 64
//#define ADC_ZERO_SCALE 128
//#define ADC_FULL_SCALE 192
//Gain
//#define ADC_GAIN_1 0
//#define ADC_GAIN_2 8
//#define ADC_GAIN_4 16
//#define ADC_GAIN_8 24
//#define ADC_GAIN_16 32
//#define ADC_GAIN_32 40
//#define ADC_GAIN_64 48
//#define ADC_GAIN_128 56
//Polarity
//#define ADC_BIPOLAR 0
//#define ADC_UNIPOLAR 4
//Rates
//#define ADC_20 16
//#define ADC_25 17
//#define ADC_100 18
//#define ADC_200 19
/********************Convert ADC Value To Volts ********************************/
float ToVolts(long data)
{
return ((float)data*1.225/0xffff);
}
/******************** Write To ADC *********************************************/
void write_adc_byte(int data)
{
int i;
output_low(ADC_CS);
for(i=0;i<8;i++)
{
output_low(ADC_CLK);
output_bit(ADC_DI, shift_left(&data,1,0));
output_high(ADC_CLK);
}
output_high(ADC_CS);
}
/******************** Disable ADC **********************************************/
void adc_disable(void)
{
write_adc_byte(0x04);//Place in standby mode
output_low(OSC_CS);//Turn Off Oscillator
}
/******************** Enable ADC **********************************************/
void adc_enable(void)
{
output_high(OSC_CS);//Turn On Oscillator
write_adc_byte(0x00);
}
/******************** Read Value From ADC **************************************/
long read_adc_word(void)
{
int i;
long data;
output_low(ADC_CS);
for(i=0;i<16;i++)
{
output_low(ADC_CLK);
output_high(ADC_CLK);
shift_left(&data,2,input(ADC_DO));
}
output_high(ADC_CS);
return data;
}
/******************** Setup ADC **************************************/
void setup(void)
{
write_adc_byte(0x20);
write_adc_byte(0x10);
write_adc_byte(0x10);
write_adc_byte(0x04);
}
/******************** Initialize ADC *******************************************/
void init_ADC(void)
{
output_high(OSC_CS);
output_high(ADC_CLK);
output_high(ADC_CS);
setup();
delay_ms(3000);
}
/******************** Read ADC Value From Specified Channel ********************/
long read_adc_value(int1 ch)
{
long value;
if(ch){write_adc_byte(0x39);}
else{write_adc_byte(0x38);}
//value=/*ToVolts(*/read_adc_word();//);;
return value;
}
|
here is the main routine
Code: |
void main()
{
init_ADC();
while(TRUE)
{
printf("RAW=%Lu\r",read_adc_value(0));
}
}
|
|
|
|
Ttelmah Guest
|
|
Posted: Mon Apr 21, 2008 3:28 pm |
|
|
What you have posted, has the entire actual 'reading' code remarked out. 'value', will just contain a random value, dependant on what happened to be in the chip's memory when it turned on....
Best Wishes |
|
|
|
|
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
|