Log in

View Full Version : AC measurements using CS5460A and PIC - Help on an022a



Divya
- 13th September 2007, 10:13
Hi friends,

I am a newbie. I am desperately trying to make AC measurements using the chip CS5460A. I could successfully communicate with CS5460A and get the readings but my problem is I do not know how to convert the internal register values to the actual voltage, current, power values of the input signal. I came across the application note an220a., it is exactly the thing I am looking for..but I am unable to understand the coding specifically the following two points.

1) When internally CS5460A registers stores measurement results in 24 bit words if we remove the last 8 bits and consider only the first 16 bits how the results come alright. Can anybody kindly explain to me with a sample value.

2) Secondly how the values declared in the MAXPWRH & MAXPWRL registers are arrived at. ie., 0x98CE and 0xB3f1

I am unable to proceed further without understanding these register reading conversion. If anybody has worked on this application note or worked with CS5460A should be able to help me out.

Thankyou

SteveB
- 14th September 2007, 05:11
1) When internally CS5460A registers stores measurement results in 24 bit words if we remove the last 8 bits and consider only the first 16 bits how the results come alright. Can anybody kindly explain to me with a sample value.


Look carefully at the following sections:
- App Note-page 5 - RMS Voltage
- CS5460A Data Sheet-page 13 - 2.2 Performing Measurements
- CS5460A Data Sheet-page 47 - 5.6 and 5.7 (Output register results)

What they are saying in a nutshell is that the output registers indicate the percentage of the maximum input values. So the output (for Irms for example) would be a number between in the range 0<= N<1. Because some can be negitive, they will be in the range -1<=N<1. These are given in two's complement notation, with the MSB the sign bit for the signed values. Table 1 on page 14 may help.

As a two's complement notation to 24 bits (23 for the signed numbers), the least significant bits represent such a small percentage that they are insignificant. For example:

11111111 11111111 11111111 = 0.99999994
11111111 11111111 00000000 = 0.999984741
00000000 00000000 11111111 = 0.000015199

As you can see, the last 8 bits can easy be dropped unless the unmost of percision is required.



2) Secondly how the values declared in the MAXPWRH & MAXPWRL registers are arrived at. ie., 0x98CE and 0xB3f1

Not sure, that would take a little more looking into.

SteveB

marcomilazzo
- 28th April 2012, 19:04
Hi
what is the routine to convert the binary to floating?!!!
11111111 11111111 11111111 = 0.99999994
11111111 11111111 00000000 = 0.999984741
00000000 00000000 11111111 = 0.000015199
i tried all i know with no result
thank's for any help
marco

SteveB
- 2nd May 2012, 17:35
Hi
what is the routine to convert the binary to floating?!!!
11111111 11111111 11111111 = 0.99999994
11111111 11111111 00000000 = 0.999984741
00000000 00000000 11111111 = 0.000015199
i tried all i know with no result
thank's for any help
marco

Marco,
I don’t know if you got an answer, or are even still around. It’s been a while since I’ve had my hands dirty with this, but here is a short answer: There is no ‘routine’ to convert binary to floating directly.

The long answer is that those binary numbers represent some real value and you need to understand that to know how to manipulate the values in code.

Also, keep in mind that the magnitude of those numbers are unreasonable for use in a PIC. An unsigned 24 bit variable gives a resolution of .12 parts per million. You are unlikely to build a device that can measure accurately at that resolution, and even more so to need that resolution. A 16 bit number is more reasonable, and 12 even more so.

Now as for the values they represent:

Let’s say you are measuring voltage with an unsigned 16 bit variable. The range of measurement is 0 to 5 volts. Each bit of that variable would represent 76.2939uV. This is derived as follows:
Divide the range by number of bits: 5/65536 = 76.2939E-05 * 10^6 = 76.2939.

Now you have a value you can work with in an integer environment (sort of). If you don’t mind the rounding error, then you can just take the value of the variable and multiply it by 76.
For example:
Variable = %10100101 00100101 = $A525 = 42277
42277 * 76 = 3,213,052uV
But, this has a rounding error of 12427 due to using integers. (The value using floating point is 3225749).

We can improve the somewhat by using the value of 7629 for each bit. After that is multiplied by the variable, dividing by 100 gives us a much closer value for nV.
42277 * 7629 = 322,531,233 / 100 = 3,225,312
The rounding error is now only 167

Of course, this example would require using LONG variable types in PBP (Compiler mode PBPL).

Bottom line, you don’t need floating point if you assign those bits to mean whatever you want them to mean.

HTH,
Steve