LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

write multiple value in serial buffer using case structure

Solved!
Go to solution

In this VI , i am generating waves using slide bar. after that i am comparing this to some value like 0.6. if value of wave is greater than 0.6 then led blinks and case structure writes 1 value into serial buffer. if it is less than 0.6 led become off and case structure writes 0 value into serial buffer. now i want to add another condition if value of graph is between 0.2 to -0.2 then case structure writes 2 value into serial buffer. can you tell me how can i do this? 

0 Kudos
Message 1 of 17
(3,945 Views)

Tips for your VI.

 

1.  Don't reconfigure your serial port on every iteration of the while loop.

2.  Put a wait statement in that loop so you don't have a "greedy loop" eating up all your CPU clock cycles.

3.  I don't know what data you are reading on the serial port, so this next statement may not apply.  But "Bytes at Port" method of determining how many bytes to read of the serial port is the wrong way to go about 95% of the time.  Even more so when your serial port is set with the terminatioin character enabled.

 

You can create a case structure that has more than one case.  Try using Threshold 1-D array comparing your value to an array of those comparison points to get the index.  Wire the index into the case structure selector.  You will need to be sure you have all situations covered.  (What if the value is less than -0.2?)  You'll have a case to define as default for anything that may fall out of the expected ranges.

0 Kudos
Message 2 of 17
(3,931 Views)

thanks for your reply. in my project this 0,1,2 value is read  by arduino. and arduino will control device according to serial value. how to make case structure . that has more than two cases. in my case structure , i  have two  case only: true and false

0 Kudos
Message 3 of 17
(3,900 Views)

Why are you using the Compare Express VI and which Case structure do you want to have more than two cases?

 

Wire a numeric data type into the case selector and you'll be able to add cases (right-click on the selector label).  Know, though, that you can run into trouble if you wire a double to a case structure.

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 4 of 17
(3,895 Views)

sorry i can't understand your question. i am using compare VI to compare with some constant value. and  using case structure, i want to write three different values for three different conditions

0 Kudos
Message 5 of 17
(3,877 Views)
Please take the time for some of the few tutorials. If you wire an integer into a case selector, you can have as many conditions as you want. This is extremely basic.
0 Kudos
Message 6 of 17
(3,870 Views)

sorry for my misunderstanding.  i know about it. i can generate many cases. but here my problem is that i want to generate cases according to My LED output. i know i can generate two cases according to boolean value

0 Kudos
Message 7 of 17
(3,860 Views)

@rushin010 wrote:

sorry for my misunderstanding.  i know about it. i can generate many cases. but here my problem is that i want to generate cases according to My LED output. i know i can generate two cases according to boolean value


A "LED output" is a boolean value; it's not clear what you want.

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 8 of 17
(3,852 Views)
You say you know it but then you say you don't know how to do it. You've already been told one way and to get rid of the compare function. Another is to just convert the slider bar to integers and wire that directly to the case statement.
0 Kudos
Message 9 of 17
(3,843 Views)

hello  i am trying to foollow suggestion. i have made 1 D array of threshold. and i am comparing value with output of graph

0 Kudos
Message 10 of 17
(3,821 Views)