LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Passing variables into a do while loop embedded inside a LabView dll

Solved!
Go to solution

Okay I've been tasked with interfacing a new oven over ethernet that runs a control application written in LabView.

 

I've been given and successfully run another LabView project that allows me to hook into the oven and control it remotely, but this is obviously an executable, and essentially I'd like to create a dll so that I can include it in a LabWindows project. 

 

The requirements at this stage are very simple. The UI of the remote control project has a variable temperature setting dialog item that is constantly monitored inside a do-while loop and the value then transmitted across ethernet to update the oven every 500ms. Additionally there are stop and start buttons to turn the oven on and off, both of which are monitored and state changes transmitted.

 

Ideally I'd like to be able take the executable, strip out the bits of the UI I dont actually need, then make a shared dll or better still, a .NET interop assembly.

 

I've already tried the later approach firstly checking out the concept, and creating a simple project that takes in two values, multiplies them and returns the value. That worked just fine.

 

I then tried to create a dll from the project, adding the dialog items I was interested in interacting with, to the terminal window so they are exposed outside of the resulting dll.

 

Although this built okay, and I was able to get to a point in software where I passed in the temperature value, at that point it hung - not in a nasty way as such, more like it was waiting to return from the labview dll but didnt find a way back.

 

This is the first time I've had to use LabView in anger before so it's a little alien to be coming from a conventional coding background. Any thoughts as to what I might be doing wrong.... I can post screen shots of the VI if required.

0 Kudos
Message 1 of 10
(3,214 Views)
Yes, please post the screen shots. The VI from which you created the dll should have nothing more than a multiply function with two inputs and an output. No loop, of course.
0 Kudos
Message 2 of 10
(3,208 Views)

Okay here are the screen shots... 

 

What I want to happen is that in the same way once the exe version of this starting polling data as soon as it is run, the dll version does the same.... Then when I call the functionality and pass in the two values these are are then transmitted continuously whilst it then returns back to the program that called it.

 

The other thought I had was whether instead of having the do while loops inside the LabView dll, whether I can send commands into the dll to request the appropriate ethernet activity.

Download All
0 Kudos
Message 3 of 10
(3,201 Views)
Those screen shots are obviously not from the simple VI you mentioned. That VI on the image still has the while loop that you need to remove. You certainlycan't pass new parameters to it once it starts and you certainly can't stop it unless you make the front panel visible.
0 Kudos
Message 4 of 10
(3,192 Views)

Sorry for the confusion... The VI i mentioned initially was a simple test utility to prove that I could iimport the resulting .NET object into LabWindows, and that worked just fine.

 

As you say the picture I posted are of the project I want to get operational. I'm thinking what I'll need to do is load the values I need into some form of global storage, then fire a request to run the Ethernet part of the process in order to action everything.

 

I dont actually need most of the UI as it will be implemented elsewhere with values returned from this routine - eventually!

0 Kudos
Message 5 of 10
(3,185 Views)
What I think you need to do is modify the VI so you can call it correctly. As I said, the while loops need to go. You wouldn't write an external dll with cvi like that, would you?
0 Kudos
Message 6 of 10
(3,176 Views)

No thats very true!

0 Kudos
Message 7 of 10
(3,172 Views)
The VI that you posted is poorly written, in my opinion. I would rewrite it as 4 separate VIs. One to open the connection where you pass in the tcp/ip address and a timeout. Return a reference and error code. Another VI to do a read where you pass on the reference and get the readings as return values. Another VI to do a single write, passing on the reference and values to write. Lastly, a close VI. With these, you can create a single dll with the 4 different exported functions.
0 Kudos
Message 8 of 10
(3,160 Views)

Yes I agree.... Once I get my head round LabView a little more I'll probably look at reworking whats here.... Its a little inconvenient having to pass all the parameters in one shot to a single VI. But for the time being I'll work with what I've got. Although I came from an electronics background originally which should make understanding how LabView elements are constructed more straightforward, relating them to the equivalent 'real code' I'm not finding so easy. I'm sure it will come with time however.

 

Having stripped out all the do while loops I do appear to have something that is working in some form. Tomorrow I'll have to set aside some time to see if its actually doing what I think it is doing.

 

Thanks for your help... if the tests prove successful I shut down the query.

0 Kudos
Message 9 of 10
(3,152 Views)
Solution
Accepted by umquat

Right I'm making some progress... indeed I have the functionality working.... but its incredibly slow, and I'm pretty sure I know why.

 

Still a single VI at this point which opens , writes some register info and closes the ehternet connection each time I want to do something.

 

What I've noticed is that after opening the port there seems to be a finite amount of time before the first of the commands will actually work - in this case around 15 seconds. I've actually noticed this behaviour with the original code I was supplied with, but after this time period has elapsed and because the port isnt then closed until the application shuts, the problem then goes away.

 

Ideally what I'd like to be able to do is the following in my dll

 

1)Open the port before use

 

2) Throw at regular intervals commands at the open port

 

3) Close the port after use

 

Its easy enough to visualise how you'd structure this in a C++ or C# class, but I can't visualise how you'd do this with one or more VI's. Any thoughts.

0 Kudos
Message 10 of 10
(3,111 Views)