halum Posted May 5, 2018 Report Share Posted May 5, 2018 Some one can helps me please I'm new in LabVIEW deveolopment and I need to solve this expression with VI in LabVIEW 2015 Im tried many solution I cant add mathScript to labview2015..some one helps me to design the VI. thanks alot 1) z = (3>>x)+(5<<y) 2) z = (x² ^ 2) | (y & 1) Link to comment
ShaunR Posted May 5, 2018 Report Share Posted May 5, 2018 Post your solution and we will take a look. Link to comment
willsan Posted May 7, 2018 Report Share Posted May 7, 2018 On 5/6/2018 at 6:39 AM, ShaunR said: Post your solution and we will take a look. same viewpoint with you. Link to comment
ShaunR Posted May 7, 2018 Report Share Posted May 7, 2018 2 hours ago, willsan said: same viewpoint with you. If you don't post any code to show that you have at least tried, then it looks like you are trying to get us to write some school homework for you. Show us what you have tried and we will help. 1 Link to comment
halum Posted May 7, 2018 Author Report Share Posted May 7, 2018 the third question i m all ready doing it the response is in attach file but the first and second expression i m really not understand how can i resolve it thanks sir for your reply Link to comment
Tim_S Posted May 7, 2018 Report Share Posted May 7, 2018 If you are using a formula node then it's just a matter of setting up the inputs and outputs of the node and typing in the formula. LabVIEW has very good help that installs with it, but there is a little tutorial here. The first formula has one gotcha but the error message tells you what the issue is. The second formula is a little wonky in that it looks like x-squared is being squared. Make sure you read the help on the formula node. 1 Link to comment
Popular Post GregSands Posted May 7, 2018 Popular Post Report Share Posted May 7, 2018 Firstly, you are using a Formula Node, not a MathScript Node. But that will do what you need just fine. Secondly, look at the built-in help to explain the operators. Right click on the Formula Node, then Help, and then look for the allowed operators. You'll see the ones you need, including >> (right shift), << (left shift), & (and), ^ (exclusive or), and | (or). Note that ^ is not "to the power of". That should make completing this fairly straight-forward. 3 Link to comment
halum Posted May 8, 2018 Author Report Share Posted May 8, 2018 is my work until now correct? Link to comment
LogMAN Posted May 8, 2018 Report Share Posted May 8, 2018 (edited) 5 hours ago, halum said: is my work until now correct? You are the one who wrote the program, you should know better than anyone if it produces the right results or not. If you don't, maybe you should start by understanding the expression before writing any code. Let's take your first example: if ((a + b) >= 4) c = (a - 2) + (b * 3) else c = (a + 5) * (b - 2) What do you expect for a = 2 and b = 3? Your program returns c = 9. Is this correct? Before writing any code I suggest calculating a few results by hand. That way you can compare your results to what the program returns. This is how you make sure your program works correctly. Edit: On 5/7/2018 at 5:56 PM, halum said: but the first and second expression i m really not understand how can i resolve it Can you explain more detailed where you have trouble? The third expression seems to be working, so what is the problem with the other two? Edited May 8, 2018 by LogMAN Link to comment
halum Posted May 8, 2018 Author Report Share Posted May 8, 2018 Yes sir, I cant resolve the first and second expressiion Link to comment
halum Posted May 8, 2018 Author Report Share Posted May 8, 2018 I mean i cant design a Virtual instrument for this expression Link to comment
halum Posted May 8, 2018 Author Report Share Posted May 8, 2018 im using Labview 2015 64 bit Link to comment
LogMAN Posted May 8, 2018 Report Share Posted May 8, 2018 (edited) 8 minutes ago, halum said: I mean i cant design a Virtual instrument for this expression You did it for the other expression, so which part do you have trouble with? Is there maybe an error message when you create the VI? Edited May 8, 2018 by LogMAN Link to comment
halum Posted May 8, 2018 Author Report Share Posted May 8, 2018 1) z = (3>>x)+(5<<y) what does it mean << and >> its an array? and by any tools can i design it in block diagram 2) z = (x² ^ 2) | (y & 1) when i put the boolean oppeartion and try to connect input and out put variable, message show demande mathscrpt Link to comment
Tim_S Posted May 8, 2018 Report Share Posted May 8, 2018 It appears you need help with the math expression. The LabVIEW help topics of "Formula Node" and "Precedence of Operators in Formula Nodes and Expression Nodes" should help. Have you read these? 2 Link to comment
LogMAN Posted May 8, 2018 Report Share Posted May 8, 2018 (edited) 31 minutes ago, halum said: 1) z = (3>>x)+(5<<y) what does it mean << and >> its an array? and by any tools can i design it in block diagram To answer your question: No, its not an array. I think GregSands already provided good help to this particular question: 22 hours ago, GregSands said: Secondly, look at the built-in help to explain the operators. Right click on the Formula Node, then Help, and then look for the allowed operators. You'll see the ones you need, including >> (right shift), << (left shift), & (and), ^ (exclusive or), and | (or). Note that ^ is not "to the power of". That should make completing this fairly straight-forward. Of course this is only useful if you work with the Formula Node, just like you did with the other solution. That being said, before you continue writing anything in LabVIEW please take your time to understand what your expressions are doing. Try to make it simpler to understand. For example, instead of trying to get this entire expression to work, start with one portion of it, like the first part: z = 3 >> x You have to answer the same questions as before: What do you expect this expression to return for z? There are a lot of resources on the internet that also explain very well what these expressions do. You just need to know what to search for, so here is a translation table for you: >> Arithmetic Shift Right << Arithmetic Shift Left ^ Bit Exclusive Or & Bit And | Bit Or I suggest you try and understand what each of these expression does before combining them into longer expressions. Here is a full list of operations with their names for the Formula Node: http://zone.ni.com/reference/en-XX/help/371361P-01/lvhowto/precedence_of_operators_in/ 31 minutes ago, halum said: 2) z = (x² ^ 2) | (y & 1) when i put the boolean oppeartion and try to connect input and out put variable, message show demande mathscrpt I'm not an expert with Formula Nodes, but this should be possible to do without MathScript. From what I can tell the "x²" probably isn't allowed in the Formula Node, so maybe use "pow(x,2)" instead? If you get an error message please post the entire message here, maybe someone knows why this error happens. Edited May 8, 2018 by LogMAN 2 Link to comment
halum Posted May 8, 2018 Author Report Share Posted May 8, 2018 (edited) LogMAN thanks sir Edited May 9, 2018 by halum Link to comment
halum Posted May 22, 2018 Author Report Share Posted May 22, 2018 On 5/7/2018 at 8:03 AM, willsan said: same viewpoint with you. hi sir look at my work its is correct or no plz expression: 1) z = (3>>x)+(5<<y) 2) z = (x² ^ 2) | (y & 1) task2-1.vi task2-2.vi Link to comment
Tim_S Posted May 22, 2018 Report Share Posted May 22, 2018 You can easily check the work by calculating what the value by hand and then comparing the output of the VIs. If you had done this then you would have answered your question. You do have errors in your code. Things you need to watch for is the data types matter and how the logical shift primitive works. As for style, making code neat and organized is important with any language. LabVIEW is a 'visual' language rather than a text language so what constitutes neat and organized means something a little different; there is a code cleanup feature up in the button bar area that can help with this. Link to comment
LogMAN Posted May 22, 2018 Report Share Posted May 22, 2018 1 hour ago, halum said: look at my work its is correct or no plz expression: 1) z = (3>>x)+(5<<y) 2) z = (x² ^ 2) | (y & 1) I understand you are eager to learn programming in LabVIEW, but you should really start by learning the concepts first. The learning curve you try to take is way to high in my opinion. That being said, these are your current solutions as far as I can tell: 1) z = (x << 3) + (5 << y) 2) z = (x² ^ 2) | (y & 1) Again, you should manually calculate some results and see if your code returns the correct results. 1 Link to comment
halum Posted May 24, 2018 Author Report Share Posted May 24, 2018 (edited) On 5/22/2018 at 7:00 PM, LogMAN said: I understand you are eager to learn programming in LabVIEW, but you should really start by learning the concepts first. The learning curve you try to take is way to high in my opinion. That being said, these are your current solutions as far as I can tell: 1) z = (x << 3) + (5 << y) 2) z = (x² ^ 2) | (y & 1) Again, you should manually calculate some results and see if your code returns the correct results. task2-1.vi Edited May 29, 2018 by halum Link to comment
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now