Searching \ for '[pic]: how to convert 0-2,5v to 0-1023' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/devices.htm?key=pic
Search entire site for: 'how to convert 0-2,5v to 0-1023'.

Exact match. Not showing close matches.
PICList Thread
'[pic]: how to convert 0-2,5v to 0-1023'
2007\01\07@130530 by Andre Abelian

flavicon
face
Hi to all,

I need to convert ADC 0-2,5v  result to  0-1023 output to uart.
I am kind of lost how to do this should I add result x 2?
any help will appreciate.

thanks

Andre

2007\01\07@134518 by Rolf

face picon face
Andre Abelian wrote:
> Hi to all,
>
> I need to convert ADC 0-2,5v  result to  0-1023 output to uart.
> I am kind of lost how to do this should I add result x 2?
> any help will appreciate.
>
> thanks
>
> Andre
>  
You need to get 2.5V on the Vref+ pin, and use that for the 10bit
conversion. The challenge is then to get a 2.5V reference.... ;-)

On PIC18 devices see the ADCON1 register bits VCFG0 and VCFG1

on PIC16's see the ADCON1 register's PCFG bits.

Rolf

2007\01\07@155609 by Jinx

face picon face
> The challenge is then to get a 2.5V reference.... ;-)

Fortunately 2.5V is a standard reference. Microchip do the
MCP1525 (I use occassionally), and there's AD, LM, MAX,
REF-, TL, ZRC etc. Those are from the RS catalogue, I'm
sure Mouser or Digikey will have similar

2007\01\07@161249 by Andre Abelian

flavicon
face
Rolf,

thanks for your replay. Using Vref is very good idea but in my case the
situation is lot more
complicated. This is how it should be:

0-2,4v  output 0-1023 with 2's complement format and enable a bit
2.6-5.0v  output 0-1023 disable the bit. While it is in between 2,5v
should output 0

any idea?

thanks for your help

Andre

{Quote hidden}

2007\01\07@165121 by Tom Sefranek

face picon face
Your looking for a 12 bit (11bits actually) A-D.
Then some bit manipulation. (Math).

Andre Abelian wrote:

{Quote hidden}

--
 *
 |  __O    Thomas C. Sefranek   spam_OUTWA1RHPTakeThisOuTspamARRL.net
 |_-\<,_   Amateur Radio Operator: WA1RHP  
 (*)/ (*)  Bicycle mobile on 145.41, 448.625 MHz

hamradio.cmcorp.com/inventory/Inventory.html
http://www.harvardrepeater.org

2007\01\07@175341 by Andre Abelian

flavicon
face
Tom,

Previews guy did it by using pic internal ADC. Another problem is
that the design is already done and I can't change it.
Can you explain more detail ?

thanks

Andre


Tom Sefranek wrote:

{Quote hidden}

2007\01\07@180529 by Steve Smith

flavicon
face
This is an idea (untested)
If a 10 bit resolution is required to 2.5v and a 10 bit converter is
available
Then
Fix Vref = 2v5 to the vref input pin

Select VCC as Vref and test to see if >512 if yes then set bit over range

If no then set Vref to Vref and read result

Hey presto 11 bits from a 10 bit a-d    Ok 10 and 1/2 bits...

It may work

Rgds Steve

{Original Message removed}

2007\01\07@180949 by Jinx

face picon face
> situation is lot more complicated

More like a completely different problem

> 0-2,4v  output 0-1023 with 2's complement format and enable a bit
> 2.6-5.0v  output 0-1023 disable the bit. While it is in between 2,5v
> should output 0
>
> any idea?

2 x 16F88 **. One with a Vref+ =2.4V, Vref- = 0V, the other
with Vref = Vcc, Vref- = 2.5V. A combination of an ADC and
window comparator -> a high-resolution ADC either side of a
deadband

** any PICs with Vref-

2007\01\07@181219 by Jinx

face picon face
I wrote

> the other with Vref = Vcc, Vref- = 2.5V

Vref- = 2.6V

2007\01\07@181611 by Steve Smith

flavicon
face
Jinx:
just switch the vref between Vcc and Vref in
Only need 1 chip then
Steve

-----Original Message-----
From: .....piclist-bouncesKILLspamspam@spam@mit.edu [piclist-bouncesspamKILLspammit.edu] On Behalf Of
Jinx
Sent: 07 January 2007 23:09
To: Microcontroller discussion list - Public.
Subject: Re: [pic]: how to convert 0-2,5v to 0-1023

> situation is lot more complicated

More like a completely different problem

> 0-2,4v  output 0-1023 with 2's complement format and enable a bit
> 2.6-5.0v  output 0-1023 disable the bit. While it is in between 2,5v
> should output 0
>
> any idea?

2 x 16F88 **. One with a Vref+ =2.4V, Vref- = 0V, the other
with Vref = Vcc, Vref- = 2.5V. A combination of an ADC and
window comparator -> a high-resolution ADC either side of a
deadband

** any PICs with Vref-

2007\01\07@182403 by Rolf

face picon face
With 1 2.5V reference (again), you could hypothetically do a divide and
conquer approach.
Set the VRef+ to 2.5V, do the conversion. If the result is < 1023, it is
< 2.5V, and you have your number.
If it is >= 1-23, then set VRef- to 2.5V, and do another ADC, If the
result is exactly 0, then the input is exactly 2.5V....

This assumes that the input does not change between the first and second
ADC. In essence, you add a bit to the ADC to get an 11bit conversion.

There are bound to be other small errors that creep in though, and your
conversion quality may not be increased to a reliable 11 bit process
(ADC performance may in fact decrease).

It would probably be equally accurate to just ignore the 2.5V reference,
and do a full range ADC (0-5V), and then multiply by 2 to get the ADC
scaled to the 2048 bit output resolution.

Rolf


Andre Abelian wrote:
{Quote hidden}

2007\01\07@185714 by Jinx

face picon face
:
> just switch the vref between Vcc and Vref in
> Only need 1 chip then

Yes, that would work, although you'd lose resolution with a wider
Vref. Andre hasn't specified what resolution is acceptable, maybe
512 on one half is OK

2007\01\07@200917 by Andre Abelian

flavicon
face
Jinx,

definitely 512 res is enough but at this moment the hardware is
already made and Vref is not used so what ever solution we can
do without Vref is acceptable.

thanks

Andre


Jinx wrote:

{Quote hidden}

2007\01\07@205632 by Jinx

face picon face
> definitely 512 res is enough but at this moment the hardware is
> already made and Vref is not used so what ever solution we can
> do without Vref is acceptable.

Without knowing what the hardware consists of (can you help ?)
it's hard to say. What PIC is being used ? What interconnections
are there ? Any external switches like FETs or resistive dividers ?

and so on .....

2007\01\08@004124 by Mohit M. (Lists)

picon face
Tom Sefranek:
>>Your looking for a 12 bit (11bits actually) A-D.

Andre Abelian:
> Previews guy did it by using pic internal ADC.

If you need 11 bits using PIC's ADC, maybe you can do that by
oversampling.

This document explains how for an AVR with 10bit ADC:
http://www.atmel.com/dyn/resources/prod_documents/doc8003.pdf

Mohit Mahajan.

---- Original Message -----
From: "Andre Abelian" <.....andreKILLspamspam.....ditechnology.com>
To: "Microcontroller discussion list - Public." <EraseMEpiclistspam_OUTspamTakeThisOuTmit.edu>
Sent: Monday, January 08, 2007 4:23 AM
Subject: Re: [pic]: how to convert 0-2,5v to 0-1023


{Quote hidden}

2007\01\08@045313 by Michael Rigby-Jones

picon face


{Quote hidden}

So this sounds like you really want to output (via the UART) a range of -1023 to +1023 for an input voltage range of 0-5 volts, with 2.5 volts giving an output of zero?  Is that correct?  Ignore the following if not.

You mentioned in a later post that a resolution of 512 counts for full scale was acceptable. If so this is a trivial problem to solve.

With Vcc=5v, the PICs ADC converter gives an output of 0-1023 for your input range.  You simply need to double the output, then subtract 1023 to give the result you require e.g. in C this would be something like this:

 int16_t result; /* 16 bit signed value to hold final result */
 int16_t adc;    /* 16 bit signed value to hold ADC result */

 adc = GetAdc();                    /* Get ADC result */

 result= (adc * 2) - 1023;          /* convert range -1023 to +1023 */

 putch( (uint8_t)(result >> 8) );   /* Send MSB of result to UART */
 putch( (uint8_t)(result & 0xFF) ); /* Send LSB of result to UART */


It would be just as easy if you are using assembler, just remember to use a signed 16 bit subtract function in the calculation.

Regards

Mike

=======================================================================
This e-mail is intended for the person it is addressed to only. The
information contained in it may be confidential and/or protected by
law. If you are not the intended recipient of this message, you must
not make any use of this information, or copy or show it to any
person. Please contact us immediately to tell us that you have
received this e-mail, and return the original to us. Any use,
forwarding, printing or copying of this message is strictly prohibited.
No part of this message can be considered a request for goods or
services.
=======================================================================

2007\01\08@143609 by Andre Abelian

flavicon
face
Jinx,

I convinced them to use 511 instead of 1023 because of we
never going to get 1023 quality anyway unless hardware is going to
be changed.
Hardware info:
PIC16F876A
output to UART 19200 10 byte long.
Analog pins are connected to transducer that produces 0-5 output x and y
and 3 buttons are connected to other pic pins.

thanks

Andre






{Original Message removed}

2007\01\08@163202 by James Newtons Massmind

face picon face
www.piclist.com/techref/A2DCodeGenerator.asp

> -----Original Message-----
> From: KILLspampiclist-bouncesKILLspamspammit.edu
> [RemoveMEpiclist-bouncesTakeThisOuTspammit.edu] On Behalf Of Andre Abelian
> Sent: 2007 Jan 07, Sun 10:06
> To: Microcontroller discussion list - Public.
> Subject: [pic]: how to convert 0-2,5v to 0-1023
>
> Hi to all,
>
> I need to convert ADC 0-2,5v  result to  0-1023 output to uart.
> I am kind of lost how to do this should I add result x 2?
> any help will appreciate.
>
> thanks
>
> Andre
> -

More... (looser matching)
- Last day of these posts
- In 2007 , 2008 only
- Today
- New search...