Other Parts Discussed in Thread: DDC112
Dear fellows,
I am recently working on a Chemical analyser project which involves the DDC112 interfacing with a photodiode. But due to its complexity and contrariness in every data sheet i cant figure how to make it work.
Connections:
I have connected photodiode to IN1 and IN2 has been grounded by me. DIN has also been grounded.
When i retrieve the data on polling DVALID then if i get 40 bit data then it gives me 00000h first and then random values of last 20 bits. I am unable to distinguish which data is for IN1 and which data is for IN2 because the datasheet says that first we get IN1a and IN2a data then we get IN2b and IN1b data,
Can anyone give me a simple algorithm or C language code to make it work?
Here is my code.
#include <16F873A.h>
#use delay(clock=20M)
#fuses HS, NOWDT, BROWNOUT, NOLVP
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
void main()
{
int b;
int data[40];
output_bit(PIN_B1,0); // CONV LOW
output_bit(PIN_B2,0); // DCLK LOW
output_bit(PIN_B3,1); // DXMIT HIGH
/* Range 111 */
output_bit(PIN_B4,1);
output_bit(PIN_B5,1);
output_bit(PIN_B6,1);
output_bit(PIN_C2,0);
while(1)
{
output_toggle(PIN_B1); // CONV HIGH
delay_us(500);
output_toggle(PIN_B1); // CONV LOW
delay_us(500);
output_toggle(PIN_B1);
while(input_state(PIN_A0)); // Wait untill DVALID LOW
while(!input_state(PIN_A0)); // Wait untill DVALID LOW
output_bit(PIN_B3,0); // DXMIT LOW
// output_toggle(PIN_C2);
for(b=0;b<40;b++)
{
output_bit(PIN_B2,1); // DCLK HIGH
data[b]=input_state(PIN_A1);
putc(data[b]+48);
output_bit(PIN_B2,0); // DCLK LOW
}
putc('a');
output_bit(PIN_B3,1); // DXMIT HIGH
while(input_state(PIN_A0)); // Wait untill DVALID LOW
while(!input_state(PIN_A0)); // Wait untill DVALID HIGH
output_bit(PIN_B3,0); // DXMIT LOW
// output_toggle(PIN_C2);
for(b=0;b<40;b++)
{
output_bit(PIN_B2,1); // DCLK HIGH
data[b]=input_state(PIN_A1);
putc(data[b]+48);
output_bit(PIN_B2,0); // DCLK LOW
}
putc('b');
output_bit(PIN_B3,1); // DXMIT HIGH
output_bit(PIN_C3,0);
}
}


