Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

ADC Calculation Help

Status
Not open for further replies.

Lighty

New Member
Hi All

I'm needing some help to work out the correct scaling of the ADC for a project I'm building.

It's a LM35 to LCD through a 16F690.

It the following correct?


Eg1
For a 0.25degC reading.

0.0025V (LM35 Output) x 1024 (10bit) = 2.56 Vref = 256 Deg Scale (exceeding the LM35 range)


Eg2[/B
For a 0.1degC Reading, I would use a 2.5x opamp between the LM35 and PIC.

0.001 (LM35 output) x 2.5 (opamp) x 1024 (10bit) = 2.56 Vref = 102.4degC reading after software math.)

Is this correct?

Is there perhaps a "calculator tool" for these sort of things?

Thanks

Justin
 
hi,
The maximum count from the adc is 1023.
I have found the easiest way is to use a simple resistive divider on the adc inpit pin, say a 100R/4k3 or 82R/3k6 [ or if you prefer a 5kpot]
Set the pot/divider so that for a 5V input to the divider, the adc pin is 4.88v, this will give 1000 adc counts for a 5V signal input, using a 5Vref
This makes the maths in the PIC simple.

Note that the LM35 is only accurate to approx 0.5Cdeg.
 
Last edited:
Thanks for your reply Eric.

Ok, so I understand how you do that, taking the 5V input and dividing it to give you 4.88, which works out at 1000 counts of the 1023 (with Vref of 5V)

But are my calculations right? other than I multiplied by 1024, where it should have been 1023?

The reason I ask is I'm needing to try understand how to do this in the future, pointless me asking someone to every time I make something.


Thx
 
Thanks for your reply Eric.

Ok, so I understand how you do that, taking the 5V input and dividing it to give you 4.88, which works out at 1000 counts of the 1023 (with Vref of 5V)

But are my calculations right? other than I multiplied by 1024, where it should have been 1023?

The reason I ask is I'm needing to try understand how to do this in the future, pointless me asking someone to every time I make something.


Thx

hi,
As its 1023 counts for a 10 bit adc Word, which with a 5Vref would mean that the adc input is +5V, would be 5.000v/1023 = 4.887mV/count.

If you used a 2.5Vref you would get 1023 adc counts for a +2.5V input voltage on the adc in, which work out to 2.50/1023 =2.443mV/count

As the LM35 is 10mV/Cdeg change this means with a 5Vref 10mV/4.88mV, which at best has a resolution of 0.5Cdeg, ie: 1 count.

BTW: you may know that the LM35 is in Kelvin, so you will have an offset voltage at 0Cdeg, which LM35 do you have, the suffix letter.?

Does this help/?

EDIT: what is the temperature range you need to work over.??
 
Last edited:
Thanks,

I understand now so I think so, I'll do some testing.

The LM35 spec sheet I have (National Semi.) says its calibrated in deg Celcius, not Kelvin? Its the LM35D Or DZ not sure.
 
Thanks,

I understand now so I think so, I'll do some testing.

The LM35 spec sheet I have (National Semi.) says its calibrated in deg Celcius, not Kelvin? Its the LM35D Or DZ not sure.

hi,
I was looking at the LM135.!!:eek:

What temperature range do you want.?
 
:) thought I had lost it.

There are 2 different projects I'm busy planning, one is 20-30 Deg C, and the other is probably 20-80 Deg C.

I tried to use the DS18B20, but I just couldn't get it to work via Flowcode, will leave it for another day
 
:) thought I had lost it.

There are 2 different projects I'm busy planning, one is 20-30 Deg C, and the other is probably 20-80 Deg C.

I tried to use the DS18B20, but I just couldn't get it to work via Flowcode, will leave it for another day

hi,
For your 20 to 30C, you will only see a 0.1V change and for the 20 to 80C a 0.6Vchange.
I would suggest a OPA for both ranges, that could give you 5V[4.88v] =1000 counts, which could be dumbed down to 0.1C resolution [NOT accuracy]
and the 0.6V to, 4.88V * [600/1000] = 2.928V
 
Ok, just not winning...

here's my next problem....

I have a PSU I'm wanting to put a LCD Voltmeter and Ammerter.

The out put is 30V and 3A. It has a load sensing resistor as part of its design as it has current limiting circuitry. The Resistor is a 0.47Ohm. Therefore the voltage across it is 1.41V (give or take) at 3Amps.

I'm wanting a resolution of 0.1V and 0.005A.

Amperage:

3A / 0.005A = 600 counts.

1.41 / 600 = 0.00235V per Step, therefore 0.00235 * 1023 = 2.404V for Vref.


The voltage:

30V / 0.1V = 300 counts

So I can use a resistor divider to drop the 30V to 0.705V to get the 300 count, but due to the way it is connected to the PSU, it will also add the Voltage from the load resistor. (but maths in the software will sort this out - I hope)

But now I'm sure I've read you can't use a Vref of less than 2.5V. Is there anyway of getting around this without having to use opamps?

Hope this all makes sense.

Thanks
 

Attachments

  • ADC.png
    ADC.png
    15 KB · Views: 292
hi,
I would not recommend using a Vref of less than 2.5Vref, with a +5Vs to the PIC.
The OPA you require are only about 20p , ~20c, you can get a dual rail to rail OPA for this price,, which would be ideal for your project.

I would say a 0.47R current sense resistor is too high for a Imax of 3A. If you use a 0.1R, that will have a 0.3V drop across at 3A.
Use an OPA to increase that to say 1.46V for the adc. Thats 5V * [300/1023] = 1.46V.

Connect the Rsense 0.1R resistor in the Low end of the external load, thats the outgoing 0V line.

OK.?
 
To work out the Voltage side, I will have to read AN0 and subtract AN1 to get the "true" voltage excluding the voltage over the sensing resistor.

I'm worried a bit about the resolution, as its will only give me a 0.1V, and due to having to work it out as stated above, I'm thinking I should maybe use something with a 12bit to get a better resolution?
 
To work out the Voltage side, I will have to read AN0 and subtract AN1 to get the "true" voltage excluding the voltage over the sensing resistor.

I'm worried a bit about the resolution, as its will only give me a 0.1V, and due to having to work it out as stated above, I'm thinking I should maybe use something with a 12bit to get a better resolution?

hi,
Question, is the PSU output going to be fixed at 30V or variable, if variable over what range of voltages.???
I know the PSU output current is going to variable from say 0A thru 3A.

IMO a 12bit ADC is an overkill for a bench PSU.

Do you have a full circuit to post, perhaps I can help with the design.?
 
Sorry, its a variable voltage, 0V - 25/30V (Just need to confirm ripple voltage and full load, but more than likely 25V or 26V), and variable current 0.002 to 3 amp.

Should have pointed that out.

I have attached the schem of the circuit. Thanks for all the help!
 

Attachments

  • 0V-30V_modified_PS_latest.GIF
    0V-30V_modified_PS_latest.GIF
    23.2 KB · Views: 313
hi,
Downloaded your schematic, will look it over.

I assume that R7 is the 0.47R current sense resistor.

Can you get rail to rail OPA's OK, say MCP6002 or equivalent.?
 
Correct, R7 is the sensing resistor.

I can get the MCP6002-I/SN.

Can you check the following, set the Vout to 15V and load it for 3A , measure the no load and 3A voltage.
Do it again also for 30v, let me know.

EDIT:
This is one option.
Note the 0.01R and the MC34071 OPA type.
If you could fit a low power +12V regulator inside the original PSU, you could use that to power the OPA. In that case you could use a LM358 or a CA3140.

The -1.3V is from the internal PSU's -V rail.
 

Attachments

  • AAesp01.gif
    AAesp01.gif
    34.8 KB · Views: 229
Last edited:
Not quite with you, should I measure the voltage across R7 (sensing resistor) while doing this? or the outputs? as the voltage will be 0V when the current limiter kicks in from being shorted?

Would it not be better to use higher quality 1% 0R1 resistor in series from the 0V/gnd?

The reason I ask is because I have 4 seperate boards, forming 2 isloaded +25V - 0V - -25V, they may have slight voltage differances over R7?
 
Last edited:
You lost me a bit on your schem.

I will have a small seperate transformer to power the LCD ammeter and voltmeter, so have a seperate +12V PSU to drive this is no problem.

Herewith voltages as requested

board 1

15.01V 3.00A = 1.456V
15.01V 0.00A = 5.3mV
30.10V 3.00A = 1.496V
30.10V 0.00A = 5.4mV

Board 2

14.99V 3.00A = 1.457V
14.99V 0.00A = 5.3mV
30.00V 3.00A = 1.457V
30.00V 0.00A = 5.4mV
 
hi,
The voltages across R7 look usable as a take off point for Isense OPA.
Use a simple divider across the Vout, by using high value resistors in the divider and the second have of a dual OPA we could avoid loading the R7 with divider resistor.

Do you need another drawing.?

EDIT:
The 0.47R is R7
The plot shows the Vout from 0v to +30V with a 10R load
 

Attachments

  • AAesp02.gif
    AAesp02.gif
    36.1 KB · Views: 277
Last edited:
Ok. Lets see if I have this right.

R3 will be another Isense resistor, for the "display unit"

U1 will be used to amplify the voltage from the Isense resistor, outout to ADC.

R1/2 acts as the voltage divider from the output, driving U2 acting as a buffer to the ADC.

bit confused about 1.3V referance that is fed into U1/2

Thanks
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top