Quantcast
Channel: Forums - Recent Threads
Viewing all articles
Browse latest Browse all 262198

FDC1004: Capacitive Sensing Sample Code

$
0
0

Part Number:FDC1004

Hi,

I am trying to use FDC1004 with Arduino and downloaded "Capacitive Sensing Microcontroller Sample Code (Energia)-1.1" from www.ti.com/.../toolssoftware.

I'm not sure "(float)lb3/1048576" part.
Does this mean lb3 is shifted right 20 bits?
Is not it shifting right 19 bits (=lb3/524288)?

Below are from sample code
-----------
// Below are the calculations to take the 24-bit measurement and convert into capacitance for MEAS1
// * From datasheet: p.16 Section 8.6.1.1 shows the formula (all we need to do is shift the 24-bit value right by 19)
// ** Shifting by 19 takes a 24 bit number and makes it a 5 bit number with 19 bits after the decimal point
lbb1 = lb1*256 + lb2; // Puts 16 most significant bits into one integer for left sensor measurement
lbb2 = lbb1>>11; // Sets lbb2 to the 5 bits that exist before the decimal point
lbb3 = 0b0000011111111111 & lbb1; // Sets lbb3 to the 11 bits that exist after the decimal point
Serial.print("LEFT CAP: ");
Serial.print(lbb2 + (float)lbb3/2048 +(float)lb3/1048576, 4); // Performs an algorithm to assign bit values and add components
Serial.print(" pF ");
--------------

Thank you for your help.


Viewing all articles
Browse latest Browse all 262198

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>