Library to work with the LDC1000 from Texas Instruments

Dependencies:   FastPWM

Dependents:   LDC1000_test

LDC1000

This library was written to interface to Texas Instruments' LDC1000 in order to perform inductance measurement. This libary needs a SPI peripheral on your mbed device to talk to the LDC1000.

Clock

The LDC1000 needs a high speed clock for its internal frequency counter. In order to provide this clock, the FastPWM library is used. This may change the behaviour of other PWM channels, please be aware of that, and read the FastPWM documentation to understand the implications.

Unsupported

Not supported (yet):

  1. Setting the RpMAX and RpMIN values
  2. Setting the interrupt pin functionality
Revision:
2:44b76f6f19d5
Parent:
1:a88df80e7664
Child:
4:62ebb87678f8
--- a/LDC1000.cpp	Wed Apr 29 14:57:22 2015 +0000
+++ b/LDC1000.cpp	Tue May 19 13:26:40 2015 +0000
@@ -22,6 +22,7 @@
     wait_us(10);
     setFrequency(f_external);
     setResponseTime(LDC_RESPONSE_384);
+    setWatchdog(5000);
 }
 
 void LDC1000::setOutputPower(LDC_AMPLITUDE amplitude)
@@ -35,7 +36,13 @@
 
 }
 
+void LDC1000::setWatchdog(float frequency)
+{
+    uint8_t buffer;
+    buffer = 68.94*log(frequency/2500);
+    writeSPI(&buffer,0x03);
 
+}
 
 void LDC1000::setResponseTime(LDC_RESPONSE responsetime)
 {
@@ -59,7 +66,7 @@
     uint16_t resp[] = {192, 384, 768, 1536, 3072, 6144};
     _raw_l = readRawCounts();
     _fsensor = (_frequency/(_raw_l*3.0))*resp[(uint8_t)(_responsetime)];
-    return 1/(cap*pow(2*PI*_fsensor,2));
+    return 1./(cap*pow(2*PI*_fsensor,2));
 };
 
 uint32_t LDC1000::readRawCounts(void)