DSPRelated.com
Forums

Re: doubts in 2181...

Started by Steve Conner May 5, 2005
> i am swaminathan from chennai, india.
> i have planned to do a project of power measurement in 2181

We use the 2181 here. It should do what you want no problem. > as the processor is 16bit i am not able to get the product of the
> fractional nos exactly.
> for example, when i tried with the sample values for the registers mx0
> and mx1
>as 0.5255 and 0.0125 i get a value greater than 16 bit so the values are
>getting
>written in two separate registers.....
> how to work on this... how to increase the accuracy......

For a start, the multiplier can only multiply a mx register by a my
register. So to multiply two numbers, you should put them in mx0 and my0-
NOT mx0 and mx1.

Now in fractional mode, the result gets scaled. So if you set mx0=1.0 and
my0=1.0 and then do mr=mx0*my0, you should find that the mr1 register
contains the answer of 1.0 as a 16 bit fractional number. The full answer is
actually 32 bits- the 16 LSBs can be found in mr0. (mr2 is 8 extra bits to
contain any overflow from multiply-accumulate operations)

If fractional mode confuses you, you can switch the multiplier into integer
mode. I always use integer mode for this reason. But it doesn't really make
much difference in the end. In integer mode, you get mr1=(mx0*my0/(2^16))
and again mr0 contains the 16 least significant bits. If you took mr1 and
mr0 together as a 32-bit integer then it would be exactly equal to mx0*my0.

For more accuracy: The calculations for average real power are basically
multiply-accumulates (MACs). The sum of squares calculation for RMS
voltage/current is a series of MACs too. So you can do it at 32-bit
(actually 40-bit) precision using the mr=mr+mx0*my0 type of instruction. At
the end of a block of samples you will have a 40-bit integer in mr2:mr1:mr0.
You can convert it to floating point, or scale it to a 16-bit integer as I
described above, or store/display it as a 32-bit integer using two memory
locations. > i also don't know how to use the 1847 codec for my work ,
> where i need the samples of two inputs simultaneously......
> can anybody explain how to proceed with this.

It's stereo so it already samples two channels simultaneously. Put the
voltage signal into the left channel and current into the right. A similar
device (but using a PC with LabVIEW instead of a DSP chip) is explained in
an appendix of my PhD thesis. It shows the circuit to interface voltage and
current transformers to the mini jack input.

http://www.scopeboy.com/elec/RE/index.html Steve Conner