Hi.
May be this help. If you cast the result to a short value (signed), you
will see that the value varies in a range from -25000 to +25000 aprox.
corresponding with the input values of:
0 v ==> -25000 (really, -24500 +/-)
1.65 V ==> 0
3.30 V ==> +25000
Then, you can convert to any range, in a linear way (more or less), and
particulary to a range from 0 to 3.3 v. Eg. convert input [0 ; 3.3] volts to
a range of values from [-4000 ; 4000], center in 0.
#define DATA_MASK 0xFFFF
#define PLC_RANGO_TORQUE 8000
#define PLC_CENTRO_TORQUE 0
#define ADC_MAX +25000
#define ADC_MIN -24500
//.....//
unsigned long aux = PEEK32(m_adc_page + DATA_OFFSET) ;
//Signed
short muestra = (short)(aux & DATA_MASK);
*torque = (muestra * PLC_RANGO_TORQUE / (ADC_MAX - ADC_MIN)) +
PLC_CENTRO_TORQUE;
Hope this helps.
Atte.
Andrés Sebastián Nagy
-----Mensaje original-----
De: ts-7000%40yahoogroups.com [mailto:
]En nombre de
PeterElliot
Enviado el: Martes, 23 de Octubre de 2007 10:34 a.m.
Para: ts-7000%40yahoogroups.com
Asunto: [ts-7000] Re: TS-7400 ADC sampling rate
That should have been:
if (A2D<32000) Voltage = 1.5+((A2D*1.5)/24000);
else Voltage = ((A2D-42000)*1.5)/24000;
PJE
--- In ts-7000%40yahoogroups.com, "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 ts-7000%40yahoogroups.com, "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
> >
>