That should have been:
if (A2D<32000) Voltage = 1.5+((A2D*1.5)/24000);
else Voltage = ((A2D-42000)*1.5)/24000;
PJE
--- In "PeterElliot" <> wrote:
>
>
> Hi,
>
> If you plot your data in Excel you will see that the data consists
> basically of two straight lines with a dicontinuity at 1.5V. (The
> data at 1.5V is odd as some samples were obviously above 1.5V and
> some below).
>
> The A/D reading is a line from 42000 at 0V up to 65535 at 1.5V and
> then a second line from 0 at just over 1.5V to 23350 at 3V. This
> gives a 24000 count swing over 1.5V either side of 1.5V.
>
> Therefore the A/D to (approximate) Voltage would be:
>
> if (A2D<32000) Voltage = (A2D*1.5)/24000;
> else Voltage = ((A2D-42000)*1.5)/24000;
>
> This may also be due to the resultant number being a signed value
and
> it being assigned to a non-signed integer...
>
> Also, if you're averaging, you need to average the voltage result
> from the sample and not the numeric A/D reading as this results in
a
> faulty average (in your data 1.5V has the same reading as 0.7V).
>
> Hope this is of help.
>
> Regards,
>
> PJE
>
> >
>
> --- In "hunterofcow" <hunterofcow@> wrote:
> >
> > Did you ever find out about this problem? I cannot even get
> readings
> > correct at all. I believe i am using similar code to yours. The
> > voltage i am reading from a Multimeter, the average is what
> > read_channel outputs.
> >
> >
> > voltage average
> > 3.05 23365
> > 2.78 18837
> > 2.47 14122
> > 2.24 10411
> > 2 6932
> > 1.74 3282
> > 1.5 52125
> > 1.26 61799
> > 1.06 58913
> > 0.74 53904
> > 0.48 49962
> > 0.235 46070
> > 0.001 42415
> >
>
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ts-7000/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/ts-7000/join
(Yahoo! ID required)
<*> To change settings via email:
<*> To unsubscribe from this group, send an email to:
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|