Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: ad5933.h
- Revision:
- 6:6b9fc31d51b0
- Parent:
- 5:2dc8c3f02788
--- a/ad5933.h Wed May 13 14:07:40 2015 +0000
+++ b/ad5933.h Wed May 20 09:17:24 2015 +0000
@@ -12,6 +12,7 @@
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
+
--------------------------------------------------------------------------------- */
#ifndef MBED_AD5933_H
@@ -21,6 +22,31 @@
/** AD5933 class.
* Library to communicate with the AD5933 impedance meter chip.
+ *
+ * Example:
+ * @code
+ * #include "mbed.h"
+ * #include "ad5933.h"
+ *
+ * AD5933 Zmeter(p28, p27, false);
+ *
+ * int main() {
+ * float temp = Zmeter.getTemperature();
+ *
+ * Zmeter.initFrequencySweepParam(100000, 10, 2, 50, true, 1);
+ *
+ * while(true) {
+ * if(!Zmeter.Measure(true))
+ * printf("error occured");
+ *
+ * int real = Zmeter.real;
+ * int imag = Zmeter.imaginary;
+ *
+ * wait(1);
+ * }
+ *
+ * }
+ * @endcode
*/
class AD5933
{
@@ -31,50 +57,64 @@
@param extClk source of the Clock signal: true = external; false = internal
*/
AD5933(PinName sda, PinName scl, bool extClk);
-
- /** Set all parameters concerning a frequency sweep.
- @param startFreq initial frequency (max 100000Hz)
- @param stepFreq stepsize of increment in frequency
- @param nrOfSteps number of increments
- */
- bool setFrequencySweepParam(unsigned int startFreq, unsigned int stepFreq, unsigned int nrOfSteps);
-
+
/** Time to wait before the ADC starts to sample
@param nrOfCycles Number of cycles (outputfrequency) to wait for sampling can start (max 2044)
- */
+ @return true on succes, false on failure
+ */
bool setSettlingTime(unsigned int nrOfCycles);
-
+
/** Set the gain of the pre-amplification and the output voltage range
@param PGA Gain of the pre-amplifier (true = x1; false = x5)
@param RangeNr Set the output voltage (1 = 2V; 2 = 1V; 3 = 400mV; 4 = 200mV)
- */
+ @return true on succes, false on failure
+ */
bool setAnalogCircuit(bool PGA, int RangeNr);
-
+
/** Measure Impedance
@param increment (true = goto next frequency in sweep; false = remeasure at current frequency)
- */
+ @return true on succes, false on failure
+ */
bool Measure(bool increment);
-
+
/// Resets Device
+ ///@return true on succes, false on failure
bool reset();
-
+
/// Get temperature of chip
+ ///@return temperature in degrees Celcius
float getTemperature();
-
+
+ /// Puts the Device in Standby Mode
+ ///@return true on succes, false on failure
bool standby();
-
+
+ /// Puts the Device in PowerDown Mode
+ ///@return true on succes, false on failure
+ bool powerdown();
+
+ /** Initialises a frequency sweep.
+ @param startFreq initial frequency (max 100000Hz)
+ @param stepFreq stepsize of increment in frequency
+ @param nrOfSteps number of increments
+ @param nrOfCycles Number of cycles (outputfrequency) to wait for sampling can start (max 2044)
+ @param PGA Gain of the pre-amplifier (true = x1; false = x5)
+ @param RangeNr Set the output voltage (1 = 2V; 2 = 1V; 3 = 400mV; 4 = 200mV)
+ @return true on succes, false on failure
+ */
+ bool initFrequencySweepParam(unsigned int startFreq, unsigned int stepFreq, unsigned int nrOfSteps, unsigned int nrOfCycles, bool PGA, int RangeNr);
+
/// real part of impedance (uncalibrated)
unsigned int real;
-
+
/// imaginary part of impedance (uncalibrated)
unsigned int imaginary;
-
-
+
private:
I2C sCom;
uint8_t PGAandVoltout;
- bool firstMeasurement;
+ bool setFrequencySweepParam(unsigned int startFreq, unsigned int stepFreq, unsigned int nrOfSteps);
bool gotoAdressPointer(uint8_t Adress);
bool setRegister(uint8_t RegisterAdress, uint8_t RegisterValue);
bool writeBlock(uint8_t ByteArray[], uint8_t sizeArray);