Author Topic: PIC24: VREF > VDD?  (Read 1589 times)

0 Members and 1 Guest are viewing this topic.

Offline Pack34Topic starter

  • Frequent Contributor
  • **
  • Posts: 753
PIC24: VREF > VDD?
« on: September 14, 2018, 10:41:17 pm »
I was looking at being able to measure the rail feeding the PIC using a space analog pin, however, if it's powered by that one rail it would just respond with 0xFF when sampling since the pin you're measuring is at the reference.

I know that if I were to attach a 3.3V reference to the analog reference pin on the PIC it would allow me to capture the value if the power supply of the PIC is greater than the reference, but what about when the PIC's power supply is something like 3.1V or 2.9V? Would the ADC inside of the PIC behave and give me a correct value? or would it behave strangely since the voltage reference is greater than the power supply of the chip?
 

Offline cv007

  • Frequent Contributor
  • **
  • Posts: 822
Re: PIC24: VREF > VDD?
« Reply #1 on: September 15, 2018, 01:59:14 am »
Quote
I was looking at being able to measure the rail
I would assume the pic24 has a channel input from some fixed voltage, like a band gap voltage. You don't even need a pin. Measure the adc value of the bandgap and simply work out the Vdd voltage (or whatever is used for Vref).

adcval  / Vbg = 255 / Vref
Vbg * 255 = adcval * Vref
Vbg * 255 / adcval = Vref
if Vbg is 1.2v
Vref * 100 = 1.2*100 * 255 / adcval
if adcval = 127
Vref * 100 = 120 * 255 / 127
Vref * 100 = 240 (2.40V)

edit-
255 is assuming 8bit adc, change accordingly and double check that some of these multiplications stay inside the var type used
the *100 is just to get some fractional values using integers (first fraction digit probably usable, the rest probably not so much)
« Last Edit: September 15, 2018, 02:11:59 am by cv007 »
 

Online JPortici

  • Super Contributor
  • ***
  • Posts: 3452
  • Country: it
Re: PIC24: VREF > VDD?
« Reply #2 on: September 15, 2018, 05:27:24 am »
You didn't say which PIC24 so i have no idea of what solutions can be possible.
Anyway, if there is the AVDD/AVSS, AVDD mustn't differ more than 0.3V from VDD.
if you want to use an external VREF, VREF+ musn't exceed AVDD, VREF- mustnt go lower than VSS and VREF+ > VREF-

the PIC24 probably have a bandgap voltage reference available as an analog input so you can use it to measure Vdd as cv007 said, but you'll have to calibrate it because initial accuracy and temperature drift are not that good

otherwise, if you also have a different regulated rail or you are willining to put a reference voltage of any kind you can measure that one. i.e, a 2.5V one, measure it. a 5V one, use a resistor divider and measure it et cetera
 

Online iMo

  • Super Contributor
  • ***
  • Posts: 4671
  • Country: nr
  • It's important to try new things..
Re: PIC24: VREF > VDD?
« Reply #3 on: September 15, 2018, 07:35:30 am »
With pic24 you may set the Vref to Avdd or you may use an external Vref. I used to use an LM385-1.2 or -2.5 in past (with a 10k resistor).

You may also use a voltage divider from Avdd to ground, say 10k-10k, and do measure the voltage in the middle.
Pic24 has got a 12bit ADC, so your reading shall be something like (3.3 / 2) / (2.5 / 4096) = 2703 with 2.5V Vref.

PS: a TL431 is also an option (2.5V).
« Last Edit: September 15, 2018, 08:00:38 am by imo »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf