Comments (4)
bool AD5933::calibrate(double gain[], int phase[], int ref, int n) {
// We need arrays to hold the real and imaginary values temporarily
int *real = new int[n];
int *imag = new int[n];
// Perform the frequency sweep
if (!frequencySweep(real, imag, n)) {
delete [] real;
delete [] imag;
return false;
}
// For each point in the sweep, calculate the gain factor and phase
for (int i = 0; i < n; i++) {
gain[i] = (double)(1.0/ref)/sqrt(pow(real[i], 2) + pow(imag[i], 2));
// TODO: phase
///////////////////////mie 20230305
//Serial.print("real[i] = ");
//Serial.println(real[i]);
//Serial.print("imag[i] = ");
//Serial.println(imag[i]);
phase[i] = atan2(imag[i], real[i])*180/PI;
//Serial.print("phase[i] = ");
//Serial.println(phase[i]);
////////////////////////////////////
}
delete [] real;
delete [] imag;
return true;
}
from arduino-ad5933.
The problem has been solved, just modify the library file as above, but int will cause errors, you need to further modify the int phase in the library to float phase type
from arduino-ad5933.
Dear all,
If someone is interested I wrote an example of using the AD5933 with a kind of command line using my own library (called Generic_MEAS) so you can easily add new command with int, float or long parameters. My example has a command called "FREQ, frequency (float)" so you can select the initial frequency and do the calibration (using some #define statement in the header file. After this FREQ command you can enter a ACQ command (without parameters) and got the results with phase correction based on calibration. The original has been modified an use a float as a frequency parameter and use mainly one frequency with a null frequency increment so the gain[I] is the mean gain and only valid for i=0. You can easily change the behavior of the software, for example the command FREQ can handle the start frequency, the increment frequency and the number of increments.
Let me know if you want to get the code.
Raymond
from arduino-ad5933.
To get around the problem with the phase being defined as an int, I added two new floats and converted the phase to degrees.
Also, why delete the arrays once you have them? We want to use the phase when measuring unknown impedances.
code:
bool AD5933::calibrate(double gain[], int phase[], int ref, int n) {
// We need arrays to hold the real and imaginary values temporarily
int *real = new int[n];
int *imag = new int[n];
float faze, R;
// Perform the frequency sweep
if (!frequencySweep(real, imag, n)) {
delete [] real;
delete [] imag;
return false;
}
// For each point in the sweep, calculate the gain factor and phase
for (int i = 0; i < n; i++) {
gain[i] = (double)(1.0/ref)/sqrt(pow(real[i], 2) + pow(imag[i], 2));
R = float(imag[i])/real[i];
faze = atan(R); // page 19 of datasheet
phase[i] = degrees(faze);
// TODO: phase
}
// delete [] real;
// delete [] imag;
return true;
from arduino-ad5933.
Related Issues (19)
- TODO: excitation voltage range, settling time cycles HOT 4
- Possible to program entire control register in one go? HOT 2
- How to connect ad5933 with arduino HOT 1
- AD5933 to measure change in impedance HOT 1
- FAILED initialization HOT 4
- Any chance of an open-source license? HOT 2
- The sweep frequency is not correct HOT 2
- cant run the code
- Can not find Math.h
- SWEEP_DELAY
- "getComplexData" needs a time-out safety HOT 1
- Calibrate function Problem
- Excitation Voltage Output HOT 9
- impedance measurement is not accurate HOT 2
- start of the frequency the impedance value drops HOT 1
- Connecting external clock
- Power Standby failed
- Arduino Due Compatability
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arduino-ad5933.