AC measurements using CS5460A and PIC - Help on an022a
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
Re: AC measurements using CS5460A and PIC - Help on an022a
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
Re: AC measurements using CS5460A and PIC - Help on an022a
Quote:
Originally Posted by
marcomilazzo
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