CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Help with LTC2480/81 (16-bit ADC)
Goto page Previous  1, 2, 3, 4
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
carl



Joined: 06 Feb 2008
Posts: 240
Location: Chester

View user's profile Send private message

PostPosted: Fri Aug 19, 2011 8:55 am     Reply with quote

Hi Ttelmah
Quote:


What is In- connected to?.
The input range, is -0.5*Vref to *0.5*Vref, between in+, and in- (with unity gain selected).
To get the full 5v range on In+, you need to connect In- to 2.5v.

Best Wishes


I think its working correctly, but I think I have to do something with the code (2's complement maybe?).

IN- = 2.5V FIXED

IN+ from 0 to 2.499V it counts up from zero to 65535
IN+ from 2.5V to 5V it counts down from 65535 to zero.

DOES THIS SEEM CORRECT?

And if it is correct, what would be the best way to manipulate it to give a whole posiitve number from zero to 65535 over the 0V to 5V range on the IN+?

Thanks for any help
Carl
Ttelmah



Joined: 11 Mar 2010
Posts: 20159

View user's profile Send private message

PostPosted: Fri Aug 19, 2011 2:58 pm     Reply with quote

If you are not handling the value as signed, then of course you have problems.
The value is 16bit +sign, so needs to be handled using 32bit signed values on CCS. The formula is simple. Put the 16bit value into the low 16bits of a 32bit signed number. If the sign bit is set on the arriving data, subtract this from zero. Otherwise do nothing.
You then have +/-65536 available.

Best Wishes
carl



Joined: 06 Feb 2008
Posts: 240
Location: Chester

View user's profile Send private message

PostPosted: Mon Aug 22, 2011 2:34 am     Reply with quote

Hi Ttelmah,

Ok I understand your last point. So If I was just using this with large voltages as discussed then I could get the full swing over the full 5V. And it would be nicely digitised and stable.

However the actual application is in relation to the load cell as previously stated.
Quote:
Hi Ttelmah,

That answers it, i understand. I will try it and see.
How will this effect a differential signal though from the load cell?

The load cell is powered from 5V giving a common mode for the load cell of 2.5V for In+ and In- . At no load the voltage difference is '0' at max load the FS is 7.5mV or +/- 3.75mV.

So In- = 2.49625V
In+ = 2.50375V

Now looking again at the datasheetQuote:

Table 2a. The LTC2480 Performance vs GAIN in Normal Speed Mode (VCC = 5V, VREF = 5V)
GAIN 1 4 8 16 32 64 128 256 Input Span ±2.5 ±0.625 ±0.312 ±0.156 ±78m ±39m ±19.5m ±9.76m V


with a gain of 256, I should be able to get an input range of 2.5V±9.76mV = 65535 output . But I am nearly 52295 with a ±3.75mV input (which is a bit high but you get he idea - the load cell is damaged so the results are not exact). In other words it is like it is only reading half the scale

What do you think?

Thanks
Carl


So, for a differential input - the input swing is only going to be 2.5V pk/pk - is this true?? Or can I get a full 5V swing??

What effect will this have on the resolution of the load cell reading?? I presume it will still be 16 bit??

Also do you have any thoughts on if I should include a pre-amplifer first or other associated circuitry for a load cell application (because of the very small voltages involved) to minimise any noise interference? BUt this IC says it can be used on its own.

When I connect the load cell up with no load, the 'zero balance' is stated at -0.0382 mv/V. so about 0.2mv at 5V excitation. But the ouput at x256 is jumping round quite a bit. I need to ensure th is method is stable and accurate.

Thanks for all your help
Carl[/b]
temtronic



Joined: 01 Jul 2010
Posts: 9658
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Aug 22, 2011 7:21 am     Reply with quote

CArl..If I read it right the load cell's max output is +-3.75 mV. I sure hope you have real good shielded wiring between it and the opamp, as well as GREAT grounding ! ANY kind of airborn 'noise',emi,etc. could easily make your number go wild.
Perhaps you can test this by stting up a 'battery-pot-- load cell' simulator,this might also help with 'getting the math right "?
Ttelmah



Joined: 11 Mar 2010
Posts: 20159

View user's profile Send private message

PostPosted: Mon Aug 22, 2011 7:25 am     Reply with quote

You always need to build your code to handle the full range of the ADC. In this case 17bits including sign. Though you may intend only to use part of the range, it only takes a little bit of noise, and a signal outside your expected range, for garbage to result otherwise....
The chip effectively has an internal pre-amplifier, with a programmable 1 to 256 gain. You would need to study the noise specifications of this chip, versus those of an external input amplifier to see which approach gives the best performance. At the highest gain, the full scale is 19.5mV (+/-9.76mV), while the noise floor of the chip is 0.5uV, giving about 19000 resolvable levels (they claim 16384). So 14bit useable.

Best Wishes
carl



Joined: 06 Feb 2008
Posts: 240
Location: Chester

View user's profile Send private message

PostPosted: Mon Aug 22, 2011 8:30 am     Reply with quote

Thankyou both for your replies.
At the moment, the PCB uses smd, very short traces, no external osc, not the best earth plane - but this can be changed, 0.1uF on the supply lines, the cable coming directly off the load cell is wired directly into the PCB, only a few other components away from the ADC.

So I agree, I will have to look at improving this to the very best and compare if another IA is needed.

My main question is though is why am I only getting half the range again when using the signal as differential - so at +-3.75 mV it nearly gives the full range - but this should be LESS THAN HALF.

How is it possible to get at the highest gain, the full scale is 19.5mV (+/-9.76mV), with differential inputs???


So hyperthetically If I had a load cell that gave out 19.5mV (+/-9.76mV), how would I set this up to = FS at 19.5mV?? Because at the moment it would give FS = 9.76mV (+/-4.78mV),
Ttelmah



Joined: 11 Mar 2010
Posts: 20159

View user's profile Send private message

PostPosted: Mon Aug 22, 2011 8:44 am     Reply with quote

Have you made your code signed?.
Step back, and get the code giving the full range swing, with one input at 2.5v, unity gain, and 0 to 5v on the other input. Once you have this giving +65535 counts to -65536, you are using the data from the chip properly, and can start turning up the gain.

Best Wishes
carl



Joined: 06 Feb 2008
Posts: 240
Location: Chester

View user's profile Send private message

PostPosted: Mon Aug 22, 2011 8:59 am     Reply with quote

I only connected it up as you stated, but did not change the code - just needed to see that I could get the swing when -IN was at 2.5V, and +IN is varied from 0 to 5V. And it worked well.

I will change the code first as you said and make it signed to give +65535 counts to -65536.

And only then look at the gain.

Thanks
Carl
carl



Joined: 06 Feb 2008
Posts: 240
Location: Chester

View user's profile Send private message

PostPosted: Wed Aug 24, 2011 7:53 am     Reply with quote

Hi Ttelmah,

OK I think that I have cracked it - although I don't fully understand how the code relates to the datasheet on page17, table4.

My code
Code:
void main(){

signed int32 x =0; 
signed int32 y =0;
signed int32 z =0;   
signed int32 a =0; 
                     
while(1) {
x = read_LTC2480(LTC2480_READ_TEMP);    // Read ADC
y = ((x >> 4) & 0xFFFF);               // Shift Right to remove the first 4 control bits and mask to only output the 16bit number.            
z = ((x >> 20) & 0x1);               // shift the 'sign bit' and mask, so that only the sign bit will be available to read.

if (z!=0){               // If the sign bit is positive (meaning that -in is greater than +in) then carry on, otherwise skip.      
a = (0 - (y^0xFFFF));       // invert the count and turn into a negative number
printf("%ld \n\r", a);
delay_ms(500);
}
else if (z==0){             // If the sign bit is negative (meaning that -in is less than +in) then just output the actual count 'y' without any manipulation
printf("%ld \n\r", y);
delay_ms(500);
}
}
}


The above code gives me a +/- 65535 swing. the format is below:

IN+ = Fixed 2.5V.
IN- is varied between 0V and 5V

And the output code (approx) goes as follows:
but because I am only using pots to adjust/set the IN- and In+, a slight adustment on pot, and the meter still displays 1.25V, because it could actually be 1.251V or 1.259V. So the figures below are averaged the best I can get.


IN- = 0 IN- = 1.25 IN- = 2.5V IN- = 3.75V IN- = 5V
65535 32771 0V -32760 -65536

DOES THIS LOOK CORRECT?

I think it works as it should - although there are some defenite concerns before continuing. The main issue is the code fluctuating - how steady would you expect the ouput to be with a test PCB? (which is connected to a scope, external RS232 converter, power is from a 'boost regulator' with a 5V ouput (AS1321) and a few jumper wires on the PCB.

Below is a snapshot of the hyperterminal at 1.25V
Quote:

32783
32777
32818
32771
32766
32782
32791
32786
32784
32781
32780
32769
32779
32774
32770
32777
32796
32786
32773
32791
32784
32797


what would you suggest my next step would be??

Best Regards
Carl
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2, 3, 4
Page 4 of 4

 
Jump to:  
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