LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

MATLAB + LabView Error

Hello everyone.

I am using LabView + Matlab to control a system, the issue is that everytime I try to do an else if statement, I get an error from the software.

 

"LabVIEW:  LabVIEW failed to send variable to the script server."

 

If I use just If + else, it runs ok, but when I try to do if + if else + else, the error comes back. Someone have the solution? May I am comitting some type of error?

 

Thank you!

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

I cannot comment on this particular error you get, but I give two advices:

  1. If you want to get proper help in this forum, you need to attach your VI (or project zipped up), so people can examine your code.
  2. You have a nice bowl of spagetti based on the screenshot, it makes even worse to see what your code is supposed to do. I really recommend to take some tutorials and read on LabVIEW programming style guide, etc. You should program in a cleaner way, and use subVIs to encapsulate certain code parts and to have a clean block diagram.

Here is some more reading: http://www.ni.com/newsletter/51735/en/

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

I appreciate your advices.

But the doubt is just about the if statements, I don't see why other parts of the code matters here.

 

When I am using if + else, it works, when using if + if else + else, it fails.

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

Other parts of the code does not affect this matlab script, right. But in overall, your programming style is dangerous, almost impossible to debug such code. I see many strange things and lots of Rube Goldberg constructs. Besides, why do you need that MATLAB script, that simple logic can be easily programmed using LabVIEW functions...?

0 Kudos
Message 4 of 10
(3,516 Views)

The code is this way because my Teacher of Nonlinear Control give us this task to be made in 1 week and I don't have time to do it the right way 😄

 

The Matlab script is just because he demands that the control algorithm must be made in Matlab.

 

Yeah, this is nonsense, but I have to do it.

0 Kudos
Message 5 of 10
(3,512 Views)

Right now i do not have access to LabVIEW to test this script. Could you put together a very simple vi, where you can reproduce this error? Just a simple vi only with this matlab script. Also double check whether you are using the correct syntax in the script. If you can recreate this error, attach this simple vi, so people can test it and figure out what is wrong.

0 Kudos
Message 6 of 10
(3,508 Views)

I do not use Matlab, but are you sure that syntax is correct Matlab syntax? Should it maybe be "if + elseif + else"?

0 Kudos
Message 7 of 10
(3,495 Views)
0 Kudos
Message 8 of 10
(3,491 Views)

The highlighted MATLAB code looks OK. 

 

You could try the actions suggested in the below post.

 

https://forums.ni.com/t5/LabVIEW/help-Error-1047-occurred-at-LabVIEW-LabVIEW-failed-to-send/m-p/3259...

BR
0 Kudos
Message 9 of 10
(3,462 Views)

Thanks to everybody.

I am working in this code for hours and I had perceived that everytime I use a float in the code, the error returns.

 

For example, I have an expression:

(4/pi)*(27/100)

if I change 27 per 27.5, I got the same error. I have no idea why, but I adapted the code to bypass this problems in another way.

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