[PIC] 16F887 > CAN > External voltage référence of 1,1 V or 1,2

Eric_O

Advanced Member level 4
Joined
May 31, 2020
Messages
107
Helped
0
Reputation
0
Reaction score
0
Trophy points
16
Activity points
1,024
The PIC 16F887 has a 10-bit analog / digital converter. With an LM35CZ or an LM135 or an MCP9701A I would like to measure temperatures between - 10°C and + 100ºC. For example, knowing that the LM35CZ delivers 10 mV / °C, the voltage range on its pin 2 (Vout), will vary from - 100 mV to + 1000 mV, or 1.1 V in absolute. If I use the 5 V power supply of the PIC, the accuracy will be 5 V / 1024 = 4.88 mV / bit.

From the datasheet of the 16F887, with the ADCON1 register and the b4 / b5 bits (VCFG0 / VCFG1), I understand that we can create an external reference voltage. In this case, the ideal would be to create an external reference of 1.1 V, or 1100 mV to obtain a better accuracy of 1100 mV / 1024, or 1.074 mV / bit.


Or to be more careful, an external reference of 1.2 V, i.e. an accuracy of 1200 mV / 1024 = 1.171 mV / bit. But then another question arises: How to create a reference of 1.074 V, or 1.171 V with an external circuitry? With operational amplifiers (LM324), some resistances and a 1 adjustable resistance ?
 

Hi,

"[PIC] 16F887 > CAN > External voltage référence of 1,1 V or 1,2"
What has this to do with CAN?

Some terminology:
* " from - 100 mV to + 1000 mV" is the absolute output voltage (every one will understand when you say it´s the output range)
* "1.1V" is the range, or the span
* "4.88 mV / bit." is the resolution

***
LM35 can´t output negative voltages. If you want it to operate on negative temperatures you need to externally apply a pull down resistor to a negative voltage.
--> see datasheet.

On the other hand I don´t think the PIC can handle negative voltages.

***
"If I use the 5 V power supply of the PIC, the accuracy will be 5 V / 1024 = 4.88 mV / bit".
Only true if you choose the supply voltage as REFERENCE. But you are free to use an external reference.
So you may use an external 1.25V reference for example.

I personally guess I never used VCC as referene because of accuracy and precision reasons.

***
My recommendation:
Instead of doing handstands with negative supply, amplifiers, external reference ... I´d rather use a digital sensor, like LM73 with the I2C interface.

Klaus


 

Lots of 1.024V and 2.048V precision reference ICs out there that also help with the math! The resolution will always be Vref/1024 so you can set 1mV or 2mV /bit quite easily.

The ADC cannot measure negative voltages but you can lift the ground pin of the LM35 to some higher voltage so its output can go below its own ground. Be careful doing this, it works fine but for example if the expected output was 0V (0C) to 1V (100C) and you lift it by 200mV so -20C is 0V, 0C is 0.2V and 100C is 1.2V you can use a 2.048V reference but not a 1.024V reference as the 1.2V would the be out of range. The ADC cannot return a meaningful result if the input voltage is higher than Vref.

Brian.
 

CAN, means Digital Analog converter in French. Looking at the link indicated above in my first message and looking at the datasheet of the 16F887 it seems that from the ADCON1 register we can indicate to the CAN another voltage range on which to make the conversion rather than 0 - 5V (VDD) ? - 100 mV to 1000 mV is the range in which I want to measure the temperature. So in absolute value it is 1100 mV. The converter will convert a voltage that varies between 0 and 1.1 V on 10 bits. It's understood I will use an external voltage of 1.25 V as suggested. Where can I find a diagram ? Probably with AOPs in it, or just a voltage diviser with two resistors and one trim pot ? Indeed, for the measurement of negative temperatures I must use the LM35CZ and the assembly below indicated in the datasheet.

 
Last edited:

One could always use a pin to generate a - V for OpAmp (using PWM or bit bang) , to get CM input ramge
needed, and use OpAmp to set slope and offset.

- V generation thru diode generator (relies on OpAmp PSRR to maintain accuracy) :



OpAmp should of course have precision R's to set G and offset......

Note there are processors (SOCs) out there that have 100 mV CM range below their ground
rail for A/D allowed input range, just a thought. With onboard precision Vref (+/- .1%)
and A/D to 20 bits.



Regards, Dana.
 
Last edited:

CAN, means Digital Analog converter in French.
OK.
Most of us will use "CAN" as the CAN-Bus = ControllerAreaNetwork interface.
Expect confusion. Especially when you use English and French abbreviations in one post.

Where can I find a diagram ?
For what?
The datasheet tells everything you need to know.
I bet Microchip provides additional informations/documents/example circuits/schematics.
In the end .. it´s just two or three signals at the reference connected to two signals at the microcontroller.
Also the reference device comes with a datasheet .. and additiconal documents, where you can find more detailed informations and examples.

Probably with AOPs in it, or just a voltage diviser with two resistors and one trim pot ?
Does "Probably" in this case mean that you did not try to find any information on your own?
and "AOPs" is anather French abbreviation?

**************
One could always use a pin to generate a - V for OpAmp
True. But what is it good for?
--> the ADC still will not accept negative voltages at the input.
And why need an OPAMP at all?

Klaus
 

Regarding your recommandations after these experiments with LM35CZ, LM135 and MCP9701A, I will switch to DS1820 and will try LM73. I didn’t know this last device.
--- Updated ---

OK.

Instead of using next time CAN (Convertisseur Analogique Numérique) i will use « ADC ».

No worries, i can find by my own. Just searching on Google. But i know it is bases of Electronics, and I remember them : just using a resistors devider.

AOP, on French means « Amplificateur OPerationel ».

Yes, it’s true ADC will not accept negative voltage on it’s chanel. So will use the wiring indicated in the datasheet with 2 diodes, 1 resistor, and one other ADC chanel to measure voltage on both diodes, and substracting it …
--- Updated ---

Thank’s for advices. I will switch soon to 18F4550 and 18F46K22, that have a 1.024 V, 2.048 V and also 4.096 V programmable references.
 
Last edited:

Sim of - generator Powering OpAmp :




Regards, Dana.
--- Updated ---

What accuracy of T measurement are you looking for ?


Regards, Dana.
 
Last edited:

    Eric_O

    Points: 2
    Helpful Answer Positive Rating
I didn’t know this last device.
I don´t know about a lot of devices either.

So - like you - I need to find suitable devices all the time.
Usually I use the internet site of an electronics distributor and use the search function.
Example: Farnell.com --> search "temperature sensor"

Klaus
 

Disadvantage of low reference voltage is reduced effective bit resolution and accuracy. Amplifying the analog input to e.g. 0..5V is the better solution.
 

Amplifying the analog input to e.g. 0..5V is the better solution.
Hi,

I agree - especially for higher resolution, higher performance ADCs.

Bubenefit.t for this low performance ADC, which ensures accuracy down to 2.2V VREF.
So with a 1.25V reference you gain maximum 1 LSB of benefit. There is not much room to improve performance.

On the other hand an OPAMP introduces additional noise and offset (drift).
Thus I guess the additional OPAMP - when not properly designed by a hobbyist - may result less quality.

In detail it depends on a lot of parameters. (Opamp type, gain, reference, schematic at all, PCB layout...

***
Using 5V as VRef, often means to use Vcc as VRef. This surely is the worst to do. The error introduced by Vcc is higher than any other error in the (sensor-ADC) system.


Klaus
 

Improving ADC Accuracy thru averaging (with diminishing returns),
attached.


Regards, Dana.
 

Attachments

  • AtoD averaging.rar
    1.7 MB · Views: 98

Hi,

By averaging one may improve precision, resolution and noise, but not accuracy.

In other words: an accuracy error - like DC offset - will still exist after averaging.

Klaus
 

If I have a perfect ADC, perfect no noise, no DNL, perfect reference, infinite bits.... then its reading is perfectly accurate.

If I then add noise its accuracy is now < perfect, its readings (some of them) now exhibit a std deviation, some perfectly
accurate, some not. For uncorrelated noise.

If I then average its samples over time, its readings again start approaching greater frequency of accuracy,
but not all. Its std dev from perfect accuracy shrinks. More of the readings perfectly accurate, less not so.

So in the strictest sense does accuracy have a finite probability associated with it ? My vote is yes.

Hence we cannot say that for all samples averaging does not impact accuracy, because for some it will.
The result of averaging will make the readings more frequently as viewed over time.

Knight
 

Hi,

sdev is a "pecision problem" .. and as I´ve stated in my post#13 "you can improve precision by averaging method".

I´m fully aware that many people can´t correctly differentiate between "accuracy" and "precision". You can find wrong information all over the internet.
But should we support wrong informations or teach correct informations?

Now your NEWARK link says: (your link)

"The accuracy of an ADC (Analog to Digital Converter) exhibits how close you are to represent the true signal in your measurement.
It is determined by the DC specifications for gain, offset, and linearity and is affected by parameters associated with voltage source, I/O switching,
PCB layout and analog source impedance."


It´s exactly what I´m saying: "accuracy" problem is DC parameters, like offset, gain, linearity, (and low frequency drifts)

So - instead of just posting links - please give a mathematical example how "averaging" can improve DC offset, gain errors, linearity .. and so on.
And please do not - like in the past - show special cases, exceptions or nonn related topic.
Stay at what your link says: Offset, gain, linearity...

Klaus
 

Newark link wrong link, should have been (Newark not exactly an authority) :

https://www.nxp.com/docs/en/application-note/AN5250.pdf Section 4

And please do not - like in the past - show special cases, exceptions or nonn related topic.

Please, for the future, do not exclude cases that engineering has to deal with. Un-related topics, we
are all guilty of that as we digress on many posts.

It´s exactly what I´m saying: "accuracy" problem is DC parameters, like offset, gain, linearity, (and low frequency drifts)

You are correct averaging does not correct that. It corrects noise which contributes to inaccuracy,
and thats not a "special case". If noise contributes to inaccuracy clearly its removal improves accuracy.

Hardware averaging applied to offset reduction :


Knight
--- Updated ---


 
Last edited:

Hi,

you still don´t accept the difference between "accurate" and "precise".

Noise ... has nothing to do with accuracy.
Noise ... influences precision.

Like the last time: I asked you to focus your example on accuracy errors like, offset, gain, linearity (Read the document of your own NEWARK link)
* But you provided an example for a precision error (noise. But not offset, gain, linearity).

* You post a wikipedia link that shows the difference between accuracy and precision. But refuse to acknowledge it.
* You post a NEWARK link but refuse to accept it´s informations.
Why? This way you just make a fool for yourself.

If you are not willing learn ... how can we expect forum members to learn?

Klaus
 

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…