Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

problem in interfacing LTC2410 with 18LF2520

Status
Not open for further replies.

hemnath

Advanced Member level 3
Advanced Member level 3
Joined
Jun 24, 2012
Messages
702
Helped
61
Reputation
120
Reaction score
57
Trophy points
1,308
Location
Chennai
Activity points
6,589
Hardware Connections:
18LF2520 --------- LTC2410
PIN C4 ---------- SDO
PIN C3 --------- SCK
PIN C1 --------- CS

test code:
Code:
#include "18F2520.h"
#fuses INTRC, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP      // Internal oscillator
#use delay(clock=1000000)      // 1Mhz

#define A2D_CSI       PIN_C1     
#define A2D_SCLK      PIN_C3     
#define A2D_SDO      PIN_C4   

int32 Read_A2D(void)
{
   int32 A2D_COUNTS;
   int i;

   output_high(A2D_SCLK);
   delay_us(100);
   output_high(A2D_CSI);
   output_low(A2D_SCLK);
   output_low(A2D_CSI);

   while((input(A2D_SDO))==1); //wait for /EOC to go low...

   for(i=4;i>0;i--) //I don't need to use these first 4 bits
   {
      output_high(A2D_SCLK);
      delay_us(5);
      output_low(A2D_SCLK);
      delay_us(5);
   }

   for(i=20;i>0;i--)      //Set i = number of bits to read
   {                     
      output_high(A2D_SCLK);
      delay_us(5);
      shift_left(&A2D_COUNTS,4,input(A2D_SDO));
      output_low(A2D_SCLK);
      delay_us(5);
   }
   output_high(A2D_CSI);

   return A2D_COUNTS;
}

void main()
{
   int32 A2D_value;
   setup_adc_ports(NO_ANALOGS|VSS_VDD);         // No analogs
   setup_adc(ADC_OFF|ADC_TAD_MUL_0);
   
   setup_comparator (NC_NC_NC_NC);      // Disable comparator

   while(1)
   {
          A2D_value = Read_A2D();
          delay_ms(200);
          // display the adc value on lcd
    }
}

When i run this code, I get the output of 709931 in the display. When the change the input voltage at LTC2410, the display value is not changing.

Please help
 

Hi,

why you use bit bang mode instead of built in SPI hardware?

Klasu
 

sorry. There was a problem on the hardware. SCK and SDO lines are wrong connected.

I want to receive 32 bit data from LTC2410. I modified the routine. But it's not working.
Code:
int32 Read_A2D(void)
{
   int32 A2D_COUNTS;
   int i;

   output_high(A2D_SCLK);
   delay_us(100);
   output_high(A2D_CSI);
   output_low(A2D_SCLK);
   output_low(A2D_CSI);

   while((input(A2D_SDO))==1); //wait for /EOC to go low...
   for(i=32; i>0; i--)      //Set i = number of bits to read
	{                     
      output_high(A2D_SCLK);
      delay_us(5);
      shift_left(&A2D_COUNTS, 4, input(A2D_SDO));
      output_low(A2D_SCLK);
      delay_us(5);		
   }
   output_high(A2D_CSI);

   return A2D_COUNTS;
}

How to use SPI hardware?

Also LTC2410 has internal oscillator. Im using the internal serial clock.
 

hello

where do you configure I/O
A2D_SDO must be configured as input for reading the bit value.

try this


Code:
int dummy;
   for(i=20;i>0;i--)      //Set i = number of bits to read
   {                     
      output_high(A2D_SCLK);
      delay_us(5);
     dummy=input(A2D_SDO);
      shift_left(A2D_COUNTS,4,dummy);        // A2D_COUNT insrtead of &A2D_COUNT
      output_low(A2D_SCLK);
      delay_us(5);
   }
 

Hi,

sorry. There was a problem on the hardware. SCK and SDO lines are wrong connected.

your config seems to be with SCK and SDO like PIC datasheet.
Is it really a hardware problem?

Hardware Connections:
18LF2520 --------- LTC2410
PIN C4 ---------- SDO
PIN C3 --------- SCK
PIN C1 --------- CS

Klaus
 

I wrongly connected in the hardware as
18LF2520 --------- LTC2410
PIN C3 ---------- SDO
PIN C4 --------- SCK
PIN C1 --------- CS

- - - Updated - - -

Hi paulfjujo,
I want to read 32 bit data. In the datasheet, it says LTC2410 produces 32 bit output code. Below is the code. But still there is an error.
Code:
int32 Read_A2D(void)
{
   int32 A2D_COUNTS;
   int i;

   output_high(A2D_SCLK);
   delay_us(100);
   output_high(A2D_CSI);
   output_low(A2D_SCLK);
   output_low(A2D_CSI);

   while((input(A2D_SDO))==1); //wait for /EOC to go low...
   for(i=32; i>0; i--)      //Set i = number of bits to read
	{                     
      output_high(A2D_SCLK);
      delay_us(5);
      shift_left(A2D_COUNTS, 4, input(A2D_SDO));
      output_low(A2D_SCLK);
      delay_us(5);		
   }
   output_high(A2D_CSI);

   return A2D_COUNTS;
}

Then i shall parse it to 24 bit data.
 

I have designed a PCB and components are soldered and testing on it. (Not testing on breadboard).

Measured Vref: 3.2938V

Measured Input signal, Vin = IN+ - IN- => 0.00048V.

Maximum change in input signal is 4uV. For these change in input signal, there could be change of 20 bits.
1uV = 5 bits.

Code:
int32 Read_A2D(void)
{
   int i;
   signed int32 data = 0;

   output_high(A2D_SCLK);
   delay_us(100);
   output_high(A2D_CSI);
   output_low(A2D_SCLK);
   output_low(A2D_CSI);

   data = 0;

   for (i = 32; i!=0; i--)
   {
      output_high(A2D_SCLK); //clock hi
      delay_us(5);
      if (input(A2D_SDO))
      bit_set(Data, i - 1);
      output_low(A2D_SCLK); //clock low
      delay_us(5);
   }

   output_high(A2D_CSI);

   return data;
}

But the output code changes in values of 1000.. Please help me to correct the above routine.
 

Hi,

How to use SPI hardware?
--> read PIC datasheet.


What about debugging?

Instead of looking only at the END values on the LCDisplay you should go step by step.

First measure VCC, FO, REF+, REF- IN+, IN- all with respect to ground.
Show us the values.

you have a 32 bit result from ADC,
* Bits 31...30 are status bits. What do they show?
* Bits 29 is the sign bit. What does it show?
* Bits 28..5 is the conversion result. What does it show? (unchanged. without any correction, just the raw bits)
* bits 4..0 don´t have a meaning.

for calculation you need bits 29 ... 5.
Use a "32 bit signed int" result value.
* put ADC bit 29 into result bit 31
* put ADC bits 28..5 into result bits 30.. 7
* put "0" in result bits 6...0
* invert result bit 31

the 32 bit signed result value range equals the ADC input range.

Klaus
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top