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.

[SOLVED] LTC2440 How to Read and How to Configure ?

Status
Not open for further replies.

Okada

Banned
Joined
Jun 16, 2016
Messages
1,159
Helped
129
Reputation
252
Reaction score
128
Trophy points
63
Activity points
0
I am designing a Weighing Scale and want to use LTC2440. I want to know how to Configure the resolution of the LTC2440 to 24 bit.

In device datasheet page no. 14 table 3 provides the OSRx values to be written to the device using its SDI pin. Should I write 0x08 serially to configure the device to output 24 bit adc result ?

If yes, When should I write this value ? While reading the device ?
 

This is the code I have written but I am getting 0.


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
void LTC2440_Init() {
    LTC2440_SCK_Direction  = OUTPUT;
    LTC2440_SDO_Direction  = INPUT;
    LTC2440_CS_Direction   = OUTPUT;
    LTC2440_SDI_Direction  = OUTPUT;
    
    LTC2440_CS = HIGH;
    LTC2440_SDI = LOW;
}
 
unsigned long int Read_LTC2440(unsigned char input_data) {
    unsigned char i = 0, mask = 0x10;
    unsigned long int result = 0;
    
    LTC2440_SCK = LOW;
    Delay_ms(1);
    LTC2440_CS = LOW;
    Delay_ms(1);
    
    if(!LTC2440_SDO) {
        Delay_ms(1);
        
        for(i = 0; i < 32; i++) {
            if(input_data & mask) {
                LTC2440_SDI = HIGH;
            }
            else {
                LTC2440_SDI = LOW;
            }
 
            Delay_ms(1);
 
            input_data <<= 1;
 
            LTC2440_SCK = HIGH;
            Delay_ms(1);
 
            if(LTC2440_SDO) {
               result |= 1;
            }
            
            result <<= 1;
 
            LTC2440_SCK = LOW;
            Delay_ms(1);
        }
    }    Delay_ms(5);
     
    LTC2440_CS = HIGH;
 
    return (result & 0x3FFFFFFF) >> 6;
}
 
raw_adc_value = Read_LTC2440(0x18);
Delay_ms(1);



- - - Updated - - -

Edit: I got the output but it is not correct. I am getting x2 value ? Why ? Circuit is same as in previous post. For 2.5V input I am getting 5.0V.

Code:
weight = (double)raw_adc_value * 5.0 / 16777216.0;

This i sonly a test code.

- - - Updated - - -

Edit:

Got the required output. See attached simulation video. I have set max weight to be measured as 1000 Kg in code and I am getting precise result.
 

Attachments

  • Weighing Scale - Proteus Simulation Result.pdf
    164.4 KB · Views: 109
  • Weighing Scale.png
    Weighing Scale.png
    48.4 KB · Views: 74
  • Proteus Simulation Video #4.rar
    355.2 KB · Views: 93

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top