04-15-2025 11:38 AM
Is it possible to convert attached Open Office BASIC code to native LabVIEW code? it is related to inductance of a solenoid.
A section of it was already done by Bob_Schor and Altenbach here:
https://forums.ni.com/t5/LabVIEW/Slow-speed-code-in-formula-node/m-p/4334928#M1270469
Solved! Go to Solution.
04-15-2025 12:43 PM
Of course it is possible to implement any formula or algorithm in LabVIEW.
The linked PDF lacks of a math formula and provides only some code of OpenOffive BASIC. This is not ideal. You only need to create some LabVIEW code which does the same as the Code listed in the PDF.
04-15-2025 12:57 PM
Hi,
There is not a math formula, it is a code.
Could you please share some section with LabVIEW?
04-15-2025 08:15 PM
Well, I don't know about @altenbach, but I'm pretty sure that other guy would say "Why don't you learn LabVIEW and handle this (failrly simple) task yourself? You are quoting yourself, we've done some of the work for you, so why don't you take the next step?
Bob Schor
04-16-2025 03:36 AM
Dear Bob,
You are right, I am trying.
Thanks,
Mal
04-27-2025 11:34 AM
Hi,
I am trying using attached formula node.
Self inductance works, but mutual inductance has some problem.
Could you please help me?
04-27-2025 10:45 PM
@Mal123 wrote:
Hi,
I am trying using attached formula node.
Self inductance works, but mutual inductance has some problem.
Could you please help me?
Yes, the very first problem you have is with xoffset and yoffset arrays, which are not large enough, then you reading outside of threse arrays and have NaN value as result.
You should modify your code something like that:
By the way, this will also change the Self inductance value, so, I'm unsure that this part works properly in your code.
04-30-2025 12:47 PM
Hi Andrey Dmitriev,
Now it seems to work, attached .vi with your suggestions.
I am not sure, I have to check but probably the Mutual output should be multiplied by 2.
In your opinion the code is still valid if we delete the 3 turns like in attached solenoid image?
Thank you,
Mal
04-30-2025 01:19 PM
@Mal123 wrote:
Hi Andrey Dmitriev,
Now it seems to work, attached .vi with your suggestions.
I am not sure, I have to check but probably the Mutual output should be multiplied by 2.
In your opinion the code is still valid if we delete the 3 turns like in attached solenoid image?
Thank you,
Mal
In my humble opinion your code is still not valid because of this (at least):
There should be no '-1' here; otherwise, you will obtain a negative value during the first iteration (as your BASIC code appears to use 1-based array indexing).
I recommend comparing the results with your BASIC code — given the same input data, the outputs should be nearly identical (accounting for minor discrepancies like machine epsilon).
04-30-2025 02:50 PM
The basic code appears to use 1 for array lower bounds. The default for Open Office Basic is 0 for array lower bounds. The array lower bound can be set with the Option Base 0 or Option Base 1 statement. I assume in the Basic code that calls your function it was set to Option Base 1. I do not know what happens if you run your sample function with the wrong option base, but I think it would produce an error. You might consider setting Option Base 0 and modifying your Basic example until it works, then translate that.