Searching \ for '[pic]: how to convert 0-2,5v to 0-1023' in subject line. ()
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.
'[pic]: how to convert 0-2,5v to 0-1023'
2007\01\07@130530 by

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
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
> 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

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?

Andre

{Quote hidden}

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

Andre Abelian wrote:

{Quote hidden}

--
*
|  __O    Thomas C. Sefranek   WA1RHPARRL.net
(*)/ (*)  Bicycle mobile on 145.41, 448.625 MHz

http://www.harvardrepeater.org

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}

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}
> 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

** any PICs with Vref-

I wrote

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

Vref- = 2.6V

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

-----Original Message-----
From: piclist-bouncesmit.edu [piclist-bouncesmit.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

** any PICs with Vref-

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

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}

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

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}

> 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 .....

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" <andreditechnology.com>
To: "Microcontroller discussion list - Public." <piclistmit.edu>
Sent: Monday, January 08, 2007 4:23 AM
Subject: Re: [pic]: how to convert 0-2,5v to 0-1023

{Quote hidden}

{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 */

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
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.
=======================================================================

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}
www.piclist.com/techref/A2DCodeGenerator.asp

> -----Original Message-----
> From: piclist-bouncesmit.edu
> [piclist-bouncesmit.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...