10-17-2023 02:16 AM
Hi,
Attached the .vi. It works correctly, I have verified and it is what I was searching for. No need others.
Thank you very much for supporting me.
Best regards,
Mal
10-17-2023 09:48 AM
A few simple suggestions:
10-17-2023 03:20 PM
Another level of a smart mind.
Thanks Altenbach!
04-14-2025 09:04 AM
Hi,
I would like to convert attached Open Office BASIC code to LabVIEW, it is related to inductance of a solenoid.
Is it possible then to adapt it for more layers?
A section of it was already done by Bob_Schor and Altenbach.
04-14-2025 10:26 AM
@Mal123 wrote:
Hi,
I would like to convert attached Open Office BASIC code to LabVIEW, it is related to inductance of a solenoid.
Is it possible then to adapt it for more layers?
A section of it was already done by Bob_Schor and Altenbach.
The easiest way is probably to convert the given BASIC code to C using any available AI assistant (I'm serious), then wrap it in a DLL and use it in LabVIEW. I don't think there will be significant performance improvement (DLL could be a bit slower in this case), but at least it will save you time wiring such code.
This is what I've got from Microsoft Copilot:
double Mut(double r1, double r2, double x) {
double a = sqrt(pow(r1 + r2, 2) + pow(x, 2));
double b = sqrt(pow(r1 - r2, 2) + pow(x, 2));
double c = a - b;
double ci = 1;
double cs = c * c;
double ao, co;
do {
ao = (a + b) / 2;
b = sqrt(a * b);
a = ao;
co = c;
c = a - b;
ci *= 2;
cs += ci * c * c;
} while (c < co);
return 0.0005 * pow(M_PI, 2) * cs / a;
}
double LayeredCoil(double d, double r0, double kx, double ky,
int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8, int n9, int n10)
{
int Nturns[10] = {n1, n2, n3, n4, n5, n6, n7, n8, n9, n10};
double xoffset[10] = {0}, yoffset[10] = {0};
int MaxN = Nturns[0];
int N = 0;
double g = exp(-0.25) * d / 2;
double L = 0;
double M = 0;
int i, j, iLayer, jLayer;
double ix, iy, jx, jy;
// Find the layer with the maximum number of turns
for (i = 1; i < 10; i++) {
if (MaxN < Nturns[i]) {
MaxN = Nturns[i];
}
}
// Calculate the x and y offsets for each layer, total turns, and self-inductance
for (i = 0; i < 10; i++) {
N += Nturns[i];
xoffset[i] = (MaxN - Nturns[i]) / 2.0 * kx;
yoffset[i] = r0 + ky * i;
L += Nturns[i] * Mut(yoffset[i], yoffset[i], g);
}
// Change Nturns array to running total of turns
for (i = 1; i < 10; i++) {
Nturns[i] += Nturns[i - 1];
}
// Calculate mutual inductance for every pair of turns i and j
iLayer = 0;
ix = xoffset[iLayer];
iy = yoffset[iLayer];
for (i = 0; i < N - 1; i++) {
if (Nturns[iLayer] <= i) {
iLayer++;
ix = xoffset[iLayer];
iy = yoffset[iLayer];
}
jLayer = iLayer;
jx = ix + kx;
jy = yoffset[jLayer];
for (j = i + 1; j < N; j++) {
if (Nturns[jLayer] <= j) {
jLayer++;
jx = xoffset[jLayer];
jy = yoffset[jLayer];
}
M += Mut(iy, jy, ix - jx);
jx += kx;
}
ix += kx;
}
return L + 2 * M;
}
No idea if the result is correct or not (but at least Mut seems to be not so bad).
Attached code (LabVIEW 2018 + NI CVI 2020).
04-14-2025 11:03 AM
Hi Andrey Dmitriev,
You have been very fast!
Thank you, but I cannot use dll, I need LabVIEW code, or at least a formula node...
...is it possible to put your code in a formula node?
04-14-2025 11:27 AM
@Mal123 wrote:
Hi Andrey Dmitriev,
You have been very fast!
Thank you, but I cannot use dll, I need LabVIEW code, or at least a formula node...
...is it possible to put your code in a formula node?
Yes, of course, you can use provided C code as "getting started" for Formula Node (and then you will get your performance penalties back), or accurately rewrite everything in pure LabVIEW (there are trivial operations), but here you will need to invest some time for development.
04-14-2025 11:54 AM
Hi,
Thank you, my problem is not the time, but my competences, I don't know how to do it.
Best regards,
Mal