Impedance Analyzer
GROUP MEMBERS: Neil Hardy, Luke Schussler, Madeleyne Vaca
The Analog Devices Inc. AD5933 Impedance Analyzer chip is able to measure impedance over a range of frequencies. This notebook page describes a setup that calibrates the AD5933 by performing a frequency sweep for a known resistance value, and then measures impedance at a user inputted frequency, sending the results to a bluetooth app for display. The code is located in this repository:
Import programImpedanceMeasurement
using AD5933 to measure impedances
/media/uploads/mvaca3/video-1481555804.mp4
Calibration
On startup, the mbed calibrates the AD5933 chip by performing a frequency sweep from 100kHz to 1MHz in increments of 100kHz, and computing the gain and phase correction values for each frequency.
//store reference resistance _ref = ref; //perform frequency sweep sweep(); _pc->printf("Exited sweep.\n\r"); for(int i = 0; i <=_n; i++) { _pc->printf("_real[%i]: %i, _imag[%i]: %i\n\r", i, _real[i], i, _imag[i]); } //for each step, calculate gain factor and phase for(int i=0; i < 9; i+=1) { _pc->printf("_n: %i", _n); _pc->printf("gain and phase calculation loop %i\n\r", i); _gain[i] = (float)(1.0/ref)/sqrt((pow((double)_real[i],2)+pow((double)_imag[i],2))); _phase[i] = (float)atan((double)(_imag[i]/_real[i])); } //take temperature _pc->printf("Getting temperature.n\r"); _temp[0] = getTemp(); _pc->printf("Exiting calibrate.n\r");
Inputting a Frequency
The user inputs what frequency they want to measure impedance at using a potentiometer. The led's on the mbed display in binary a value between 1 and 10, representing the input frequency in hundreds of kHz. The frequency entered on the potentiometer and displayed on the led's will only be entered into the AD5933 when a pushbutton is pressed.
//Insert frequency select/led code here _pc->printf("Entering sweep\n\r"); _freq = 100000; _inc = 100000; _n = 9; int i = 0; char buff; configure(); read(i); _i2c->read(STATUS, &buff, 1); while(!(buff & 0x4)) { i++; buff = (0x3 << 4) | (_range << 1) | _pga; _i2c->write(CTRL_HIGH, &buff, 1); read(i); _i2c->read(STATUS, &buff, 1); }
Measuring Impedance
Once a frequency has been entered by the user, the AD5933 will begin measuring impedance values, and transmitting the results to the app via bluetooth.
_pc->printf("Entering findZ.n\r"); //set frequency for sweep _freq = f*100000; //sweep sweep1(); //get temperature _temp[1] = getTemp(); //perform gain/phase correction _z = (float)(1.0/(_gain[f-1]*sqrt((double)(_r^2+_i^2)))); _phs = _phs - _phase[f-1]; //perform temperature correction _z = _z + (_temp[1]-_temp[0])*0.00003*_z;
Wiring
AD5933 Wiring
mbed | AD5933 |
---|---|
P27 | SCL |
P28 | SDA |
GND | 12,13,14 |
VOUT (3.3V) | 9,10,11 |
HC05 Wiring
mbed | HC05 |
---|---|
P13 | RX |
P14 | TX |
GND | GND |
VU (5V) | 5V |
Other Components
mbed | other |
---|---|
P7 | push button |
P19 | potentiometer |
Bluetooth with HC05 Chip
blue.baud(9600); while(1) { //len is the length of the character array, buff for (int i = 0; i < len; i++) { blue.putc(buff[i]); } }
Android App Programming with App Inventor
MIT's App Inventor is a quick way to prototype an android app. The interface abstracts the main components of an app into a drag-and-drop language. Generating a bluetooth connection, which would usually require a few Java threads, can be managed easily.
The User Interface consists of a listpicker, a button, and two canvases for the graphs.
This is how the Bluetooth is set up.
The data is constantly sent to the phone from the mbed. Each data string is delimited with a ;. The block that reads "-1" bytes is actually just reading the entire buffer of received bytes since the last time the timer went off up until the first delimiter. After reading the data in, a custom graph function gets called that will update both graphs in real time.
1 comment on Impedance Analyzer:
Please log in to post comments.
Hi, there is no full code of app inventor? openGraph is not canvas?