05-15-2015 02:33 PM
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?
Solved! Go to Solution.
05-15-2015 03:04 PM
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.
05-16-2015 02:44 AM
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
05-16-2015 02:58 AM
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.
05-16-2015 03:45 AM
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
05-16-2015 04:19 AM
05-16-2015 04:27 AM
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
05-16-2015 04:40 AM
@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.
05-16-2015 05:03 AM
05-16-2015 07:42 AM
hello i am trying to foollow suggestion. i have made 1 D array of threshold. and i am comparing value with output of graph