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.
ad5933.h@0:6a71184e6f66, 2015-05-11 (annotated)
- Committer:
- dipi
- Date:
- Mon May 11 13:17:10 2015 +0000
- Revision:
- 0:6a71184e6f66
- Child:
- 1:b6eb241a5fa3
First Untested Version
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| dipi | 0:6a71184e6f66 | 1 | #ifndef MBED_AD5933_H |
| dipi | 0:6a71184e6f66 | 2 | #include "mbed.h" |
| dipi | 0:6a71184e6f66 | 3 | #define MBED_AD5933_H |
| dipi | 0:6a71184e6f66 | 4 | |
| dipi | 0:6a71184e6f66 | 5 | |
| dipi | 0:6a71184e6f66 | 6 | /** AD5933 class. |
| dipi | 0:6a71184e6f66 | 7 | * Library to communicate with the AD5933 impedance meter chip. |
| dipi | 0:6a71184e6f66 | 8 | */ |
| dipi | 0:6a71184e6f66 | 9 | class AD5933 |
| dipi | 0:6a71184e6f66 | 10 | { |
| dipi | 0:6a71184e6f66 | 11 | public: |
| dipi | 0:6a71184e6f66 | 12 | /** Create AD5933 instance |
| dipi | 0:6a71184e6f66 | 13 | @param sda I2C data line pin |
| dipi | 0:6a71184e6f66 | 14 | @param scl I2C clock line pin |
| dipi | 0:6a71184e6f66 | 15 | @param extClk source of the Clock signal: true = external; false = internal |
| dipi | 0:6a71184e6f66 | 16 | */ |
| dipi | 0:6a71184e6f66 | 17 | AD5933(PinName sda, PinName scl, bool extClk); |
| dipi | 0:6a71184e6f66 | 18 | |
| dipi | 0:6a71184e6f66 | 19 | /** Set all parameters concerning a frequency sweep. |
| dipi | 0:6a71184e6f66 | 20 | @param startFreq initial frequency (max 100000Hz) |
| dipi | 0:6a71184e6f66 | 21 | @param stepFreq stepsize of increment in frequency |
| dipi | 0:6a71184e6f66 | 22 | @param nrOfSteps number of increments |
| dipi | 0:6a71184e6f66 | 23 | */ |
| dipi | 0:6a71184e6f66 | 24 | bool setFrequencySweepParam(unsigned int startFreq, unsigned int stepFreq, unsigned int nrOfSteps); |
| dipi | 0:6a71184e6f66 | 25 | |
| dipi | 0:6a71184e6f66 | 26 | /** Time to wait before the ADC starts to sample |
| dipi | 0:6a71184e6f66 | 27 | @param nrOfCycles Number of cycles (outputfrequency) to wait for sampling can start (max 2044) |
| dipi | 0:6a71184e6f66 | 28 | */ |
| dipi | 0:6a71184e6f66 | 29 | bool setSettlingTime(unsigned int nrOfCycles); |
| dipi | 0:6a71184e6f66 | 30 | |
| dipi | 0:6a71184e6f66 | 31 | /** Set the gain of the pre-amplification and the output voltage range |
| dipi | 0:6a71184e6f66 | 32 | @param PGA Gain of the pre-amplifier (true = x1; false = x5) |
| dipi | 0:6a71184e6f66 | 33 | @param RangeNr Set the output voltage (1 = 2V; 2 = 1V; 3 = 400mV; 4 = 200mV) |
| dipi | 0:6a71184e6f66 | 34 | */ |
| dipi | 0:6a71184e6f66 | 35 | bool setAnalogCircuit(bool PGA, int RangeNr); |
| dipi | 0:6a71184e6f66 | 36 | |
| dipi | 0:6a71184e6f66 | 37 | /** Measure Impedance |
| dipi | 0:6a71184e6f66 | 38 | @param increment (true = goto next frequency in sweep; false = remeasure at current frequency) |
| dipi | 0:6a71184e6f66 | 39 | */ |
| dipi | 0:6a71184e6f66 | 40 | bool Measure(bool increment); |
| dipi | 0:6a71184e6f66 | 41 | |
| dipi | 0:6a71184e6f66 | 42 | /// Resets Device |
| dipi | 0:6a71184e6f66 | 43 | bool reset(); |
| dipi | 0:6a71184e6f66 | 44 | |
| dipi | 0:6a71184e6f66 | 45 | /// real part of impedance (uncalibrated) |
| dipi | 0:6a71184e6f66 | 46 | int real; |
| dipi | 0:6a71184e6f66 | 47 | |
| dipi | 0:6a71184e6f66 | 48 | /// imaginary part of impedance (uncalibrated) |
| dipi | 0:6a71184e6f66 | 49 | int imaginary; |
| dipi | 0:6a71184e6f66 | 50 | |
| dipi | 0:6a71184e6f66 | 51 | |
| dipi | 0:6a71184e6f66 | 52 | private: |
| dipi | 0:6a71184e6f66 | 53 | I2C sCom; |
| dipi | 0:6a71184e6f66 | 54 | uint8_t PGAandVoltout; |
| dipi | 0:6a71184e6f66 | 55 | bool firstMeasurement; |
| dipi | 0:6a71184e6f66 | 56 | |
| dipi | 0:6a71184e6f66 | 57 | bool gotoAdressPointer(uint8_t Adress); |
| dipi | 0:6a71184e6f66 | 58 | bool setRegister(uint8_t RegisterAdress, uint8_t RegisterValue); |
| dipi | 0:6a71184e6f66 | 59 | bool writeBlock(uint8_t ByteArray[], uint8_t sizeArray); |
| dipi | 0:6a71184e6f66 | 60 | uint8_t getRegister(uint8_t RegisterAdress); |
| dipi | 0:6a71184e6f66 | 61 | bool readBlock(uint8_t* ByteArray, uint8_t sizeArray); |
| dipi | 0:6a71184e6f66 | 62 | bool setControlReg(uint8_t Command); |
| dipi | 0:6a71184e6f66 | 63 | bool getData(); |
| dipi | 0:6a71184e6f66 | 64 | bool _extClk; |
| dipi | 0:6a71184e6f66 | 65 | |
| dipi | 0:6a71184e6f66 | 66 | }; |
| dipi | 0:6a71184e6f66 | 67 | #endif |