LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Running matlab program via switch in labview

Hi,

 

I had a basic question on integrating a matlab m file into labview. What I pretty much want is the ability to run a certain m file at a flip of a switch.

 

I essentially created a reset button and that reset button will reset my device. 

 

I attached my block diagram to my best guess to how it would work but when I tried to run it, it does not run the m file.

 

Any reason why? I tried while(y==1) and if(y==1) to run it but doesn't seem to work.

 

Thanks! Looking forward to hearing from you!

 

Justin

0 Kudos
Message 1 of 10
(3,455 Views)

Do you have a while loop wrapped around this?  Otherwise it only runs once.

 

It would make more sense to have the mathscript node in the True case of a case structure.

 

I don't know enough about mathscript to know whether a boolean can be compared to 1 for equality, or if it would be -1, or must be a True, False constant.  Why not do a While (y) ?

 

Also, assuming things do work, your Mathscript node would never end.  Because you have a while y==1 loop.  Once it is true, it will always be true.  Y can only change if you ever exit the mathscript node and allow the boolean control to be read again.

0 Kudos
Message 2 of 10
(3,450 Views)

Did you put MathScript inside of a loop?

The example attached seems to work pretty well.

Andy Chang
National Instruments
0 Kudos
Message 3 of 10
(3,447 Views)

I can take the while statement out. I just want to figure out how to literally run the program at a flip of a switch on labview because I like the GUI of labview and finding it difficult to do so.

 

like [Press Button] => [Run Script] => [End]

 

It works just fine on matlab.

 

Justin

0 Kudos
Message 4 of 10
(3,445 Views)
I'm sorry andy, I'm using Labview 8.2 so I cannot open your VI. Could you possibly take a screen shot?
0 Kudos
Message 5 of 10
(3,442 Views)

Just remember to put Wait statements in the loops so they don't run the CPU at top speed.

 

Message Edited by Ravens Fan on 03-28-2010 05:19 PM
0 Kudos
Message 6 of 10
(3,437 Views)

thanks for the help.

 

the code you gave me seems to work in a sense in activating the switch but now I have another problem. This code is suppose to output a voltage out of the DAQ-6009 but its not.

 

When I run the program via matlab it works just fine. But when I run it in labview it doesn't work. I notice that most examples on thelabview websites arefor basic calculations. In terms of putting things in like analoginput, analogoutput, putsample and all that to call the USB-6009 daq device from matlab. Is that possible to do all of that in mathscript in labview? Or would I need to make a virtual channel and call it from there?

 

I'm sorry if it seems like a confusing question.

 

Thanks

Justin

0 Kudos
Message 7 of 10
(3,430 Views)
What would make sense to me is to use the DAQmx functions that are built into LabVIEW. The DAQ Assistant would work just fine. Why would you even purchase LabVIEW if you aren't going to use it's native functions?
0 Kudos
Message 8 of 10
(3,397 Views)

I never really had formal teaching in labview, I"m trying to learn labview but it has a pretty steep learning curve. Since i'm a student I only learned how to program in standard C and java so the logic in matlab makes sense to me.

 

but the thing is I really like the GUI that labview and thought it might be useful in my application so I thought I'd integrate the two but its proving more difficult then I originally thought

0 Kudos
Message 9 of 10
(3,386 Views)
Review the information at Getting Started with DAQmx. What you are attempting to do is pretty basic and the DAQ Assistant is easy to use.
0 Kudos
Message 10 of 10
(3,382 Views)