LabVIEW MathScript RT Module

cancel
Showing results for 
Search instead for 
Did you mean: 

Changing input value through coding in mathscript.

Hi, 

Can I change value of input (control) through code in mathscript? 

Like I have this kinda thing to do. 

 

if x >5

led = 1

x = 0

end 

like I want to check if x is greater than 5? if yes then turn led ON and then make x = 0. 

Can I do this in labview mathscript coding? 

0 Kudos
Message 1 of 9
(6,898 Views)

Yes this can be achieved through the use of property nodes. You can create a property node by right-clicking on the control you want to update, and then write a boolean true or false to that property node from your mathscript node based on the value of x.  Here is an example of modifying a boolean control using property nodes.

 

CC
Applications Engineering
National Instruments
http://www.ni.com/support
0 Kudos
Message 2 of 9
(6,865 Views)

The "input value" only has meaning the next time the mathscript node is called and it will get whatever value is wired to it from the outside. Assuming that your mathscript node is in a loop, easiest would be to feed the new value as new x is via a shift register.

 

If you want more specific help, please attach a simplified example of your code.

 

(Also, please ignore everything that has been said earlier about value property nodes. It is completely irrelevant here and makes no sense. If you want to programatically update a control, you would use a local variable anyway)

0 Kudos
Message 3 of 9
(6,853 Views)

Thanks for the guidance. Actually I want to control my load through a timer as shown in the picture attached like as far as the timer reaches value greater than 5, it should gets reset to 0 and start running again from the start. Is it possible?  

0 Kudos
Message 4 of 9
(6,792 Views)

We typically don't debug truncated images, but a shift register is probably what you want. Initialize it with zero, increment with each iteration, and reset back to zero as needed.

 

Of course your entire code would be much easier to implement in plain graphical code. No script node needed at all! Try it!

 

Next time, simply attach the VI instead of pictures. Thanks!

0 Kudos
Message 5 of 9
(6,787 Views)

Thank you. I did so. I made a user defined timer using shift registers. Attached is my VI for reference. What I want to do is, that I want to press this Reset button through coding in mathscript. Like the user does not need to press the reset button, the timer automatically gets reset after meeting certain conditions. Is it possible? 

Thank You. 

 

0 Kudos
Message 6 of 9
(6,779 Views)

There is no shift register, just a missing subVI. Please attach the subVI!

 

(Have you looked at the elapsed time express VI?)

0 Kudos
Message 7 of 9
(6,775 Views)

Here is that missing subVI.  

I did check the Elapsed Time Express VI, but I want to reset my time according to my algorithm many times. That is why I am searching for a solution in which I write something in mathscript like "reset =1" and the reset button gets pressed. I hope you understand my point. 

Thank you. 

0 Kudos
Message 8 of 9
(6,765 Views)

Your code really makes no sense at all.

 

The elapsed time express VI can be set to auto-reset and start over every time it elapses.

 

Here's something that could give you some ideas....

 

 

 

 

0 Kudos
Message 9 of 9
(6,757 Views)