LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Open Office BASIC code to LabVIEW

Solved!
Go to solution

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

 

 

0 Kudos
Message 1 of 17
(926 Views)

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.

 

 

0 Kudos
Message 2 of 17
(909 Views)

Hi,

There is not a math formula, it is a code.

Could you please share some section with LabVIEW?

0 Kudos
Message 3 of 17
(901 Views)

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

0 Kudos
Message 4 of 17
(841 Views)

Dear Bob,

You are right, I am trying.

 

Thanks,

Mal

0 Kudos
Message 5 of 17
(823 Views)

Hi,

I am trying using attached formula node.

Self inductance works, but mutual inductance has some problem.

 

Could you please help me?

0 Kudos
Message 6 of 17
(703 Views)
Solution
Accepted by topic author Mal123

@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:

Screenshot 2025-04-28 05.44.45.png

By the way, this will also change the Self inductance value, so, I'm unsure that this part works properly in your code.

Message 7 of 17
(689 Views)

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

 

 

 

 

 

 

 

Download All
0 Kudos
Message 8 of 17
(628 Views)

@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):

Screenshot 2025-04-30 20.09.21.png

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).

Message 9 of 17
(619 Views)

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.

Message 10 of 17
(612 Views)