LTC2400 SPI interface


Closed Thread
Results 1 to 27 of 27

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624


    Did you find this post helpful? Yes | No

    Default

    Hi,
    I'd say learning qualifies as a (very) valid reason ;-) By all means try using the 24bit ADC but perhaps you should start with interfacing to something "easier" like a EEPROM to begin with so you learn the basics about how the SPI interface works. I haven't looked at the datasheet for your ADC though, perhaps it's pretty straight forward.

    As for the oversampling, all you really do is take a bunch of readings and then average them. If you take 16 readings with your 10bits ADC, add them all together and divide the result by 4 you'll get a value ranging from 0-4096.

    You can read a bit more about here. Note, you can not use that code with Oshonsoft, the theory behind it obviously applies to any language/compiler though.

    Good luck!
    /Henrik.

  2. #2
    Join Date
    May 2010
    Location
    SINGAPORE
    Posts
    14


    Did you find this post helpful? Yes | No

    Thumbs up thanks for your reply

    Quote Originally Posted by HenrikOlsson View Post
    Hi,
    I'd say learning qualifies as a (very) valid reason ;-) By all means try using the 24bit ADC but perhaps you should start with interfacing to something "easier" like a EEPROM to begin with so you learn the basics about how the SPI interface works. I haven't looked at the datasheet for your ADC though, perhaps it's pretty straight forward.

    As for the oversampling, all you really do is take a bunch of readings and then average them. If you take 16 readings with your 10bits ADC, add them all together and divide the result by 4 you'll get a value ranging from 0-4096.

    You can read a bit more about here. Note, you can not use that code with Oshonsoft, the theory behind it obviously applies to any language/compiler though.

    Good luck!
    /Henrik.
    hai Henrik,

    Thanks for your suggestions.is that the communication between the eeprom and pic is very easy?what i thought is am trying to make use of the spi communication only and
    no matter whether it is ADC or EEPROM (am i right).

    when i used the internal adc for example
    i injected 1.234v where the range is 0~5v and the related 10bit adc value is 252.7232 but the pic reads only 252 i took a bunch of readings and calculated the mean value (asume the value is same 252)
    then i multiplied the value by 10000 then the value is 2520000 again divide it with 2048 and the answer is 1230.46 where the pic read only 1230
    that means we get 1.230
    as you said (252*16)/4=1008 /819.2=1.230

    what is the difference between these two.

    thanks a lot for clarifying my doubts

    PUGAL
    IF YOU BORN POOR ITS NOT BECAUSE OF YOU BUT IF YOU DIE POOR ITS BECAUSE OF YOU.

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624


    Did you find this post helpful? Yes | No

    Default

    Hi,
    It's because the reading you get from the ADC most likely won't be stable at 252 across several consecutive samples, it will probably "tip over" towards 253 a couple of times.
    Let's say you get the following values:
    252, 253, 252, 253, 253, 252, 252, 253, 251, 253, 252, 253, 253, 252, 252, 252

    The sum is 4039. Averaging them across 16 samples results in 252.4375 but you'll only "see" 252 which is ~0.29% off. Averaging them across 4 instead gives you 1009.75, you'll only "see" 1009 which is ~0.19% off.

    Had the result been 1040 instead, averaging them across 16 samples would give you the same result, ~0.29% off while the oversampling method would only be 0.009% off.

    Try it out and make sure you read thru the page I linked to, also look up the term oversampling. Here's a quote from Wikipedia:
    In practice, oversampling is implemented in order to achieve cheaper higher-resolution A/D and D/A conversion. For instance, to implement a 24-bit converter, it is sufficient to use a 20-bit converter that can run at 256 times the target sampling rate. Averaging a group of 256 consecutive 20-bit samples adds 4 bits to the resolution of the average, producing a single sample with 24-bit resolution.
    /Henrik.

  4. #4
    Join Date
    May 2010
    Location
    SINGAPORE
    Posts
    14


    Did you find this post helpful? Yes | No

    Talking Thankyou very much for your support

    Quote Originally Posted by HenrikOlsson View Post
    Hi,
    It's because the reading you get from the ADC most likely won't be stable at 252 across several consecutive samples, it will probably "tip over" towards 253 a couple of times.
    Let's say you get the following values:
    252, 253, 252, 253, 253, 252, 252, 253, 251, 253, 252, 253, 253, 252, 252, 252

    The sum is 4039. Averaging them across 16 samples results in 252.4375 but you'll only "see" 252 which is ~0.29% off. Averaging them across 4 instead gives you 1009.75, you'll only "see" 1009 which is ~0.19% off.

    Had the result been 1040 instead, averaging them across 16 samples would give you the same result, ~0.29% off while the oversampling method would only be 0.009% off.

    Try it out and make sure you read thru the page I linked to, also look up the term oversampling. Here's a quote from Wikipedia:

    /Henrik.
    HAI HENRIK,
    thanks for your support.as you said i tried the oversampling method and it gave me a better result than the previous method i used.but i have a transduser which range from 0~60000 psi on 4~20 mA,i used a 250 ohm resistor and i got 1~5v difference.

    in this case do i need to use a external ADC more than 14bit resolution or can able to use the oversampling method on internal ADC by sampling 4096 times and divide by 64 to get a 16bit resolution.is it possible? or do we have any other ways to achive it.
    THANKS FOR YOUR KIND SUPPORT,
    PUGAL.
    IF YOU BORN POOR ITS NOT BECAUSE OF YOU BUT IF YOU DIE POOR ITS BECAUSE OF YOU.

  5. #5
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624


    Did you find this post helpful? Yes | No

    Default

    Hello,
    You still haven't said what kind of resolution you actually NEED, just that you wanted to use 24bits becaue that is what you had. I also asked you earlier if you had the 4-20mA signal converted to 0-5 or 1-5V. With 1-5V it means that you are basically "wasting" 20% of the ADC range.

    Now, with a 1-5V signal I'd configure the ADC to use the external Vref inputs instead of the VDD and VSS. That way, if you feed a stable 1V signal into Vref- and a stable 5V into Vref+ you'll use all the available resolution and you'll get 0 for 1V and 1023 for 5V. That way you get a basic resolution of 0.1bar as I outlined earlier and can increase that by oversampling.

    If you try the aproach of 1024 samples remember that you need to add them into a 32bit variable as the result may not fit in a 16bit variable.

    /Henrik.

  6. #6
    Join Date
    May 2010
    Location
    SINGAPORE
    Posts
    14


    Did you find this post helpful? Yes | No

    Thumbs up hai brother

    Quote Originally Posted by HenrikOlsson View Post
    Hello,
    You still haven't said what kind of resolution you actually NEED, just that you wanted to use 24bits becaue that is what you had. I also asked you earlier if you had the 4-20mA signal converted to 0-5 or 1-5V. With 1-5V it means that you are basically "wasting" 20% of the ADC range.

    Now, with a 1-5V signal I'd configure the ADC to use the external Vref inputs instead of the VDD and VSS. That way, if you feed a stable 1V signal into Vref- and a stable 5V into Vref+ you'll use all the available resolution and you'll get 0 for 1V and 1023 for 5V. That way you get a basic resolution of 0.1bar as I outlined earlier and can increase that by oversampling.

    "If you try the aproach of 1024 samples remember that you need to add them into a 32bit variable as the result may not fit in a 16bit variable".

    /Henrik.
    hai HENRIK,

    THANKS FOR YOUR SUPPORT and sorry for delayed reply.am using "long variable" so the 32bit variable fits in it.how to feed 1v? is that any voltage regulator available for 1v.what about the -ve side.

    as you said i used the internal adc and the oversampling method and got stable reading,but for now when i seperately send the readings to the lcd and hyperterminal it works but when i used both it doesn't work .i dont know what is the problem can you help me please.

    THANKS AND REGARDS,
    PUGAL
    IF YOU BORN POOR ITS NOT BECAUSE OF YOU BUT IF YOU DIE POOR ITS BECAUSE OF YOU.

  7. #7
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624


    Did you find this post helpful? Yes | No

    Default

    how to feed 1v? is that any voltage regulator available for 1v.what about the -ve side.
    Well, anyway you like really. The simplest way is a voltage divider but then the stability and accuracy of you reading depends on the stability of the powersupply rail, which it does when you're using the Vdd/Vss for Vref anyway.

    The voltage supplied to Vref- is what will equal a returned value of 0 from the ADC, the voltage supplied to VRef+ is what will equal a returned value of 1023 from the ADC. So by feeding 1V to Vref- and 5V to Vref+ the ADC's 10 bits gets divided across 1-5V instead of 0-5V as is the case when you use Vss/Vdd as reference. (As long as you use 5V supply of course). Read up on the ADC section of the datasheet for details about the ADC.

    I can't help with your problem as I have absolutely no idea how you've coded it.

    /Henrik.

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts