02-26-2013 02:15 AM
I had a serial write which have to take different commands at different cases. The same serial read should read both. How can I do it. Means if I have a string 500\r\nZ. I one case it should be -500\r\n Zand other case +500\r\n Z. But boyh of these cases have to be read with one serail write . How can I do iit . Please help
Solved! Go to Solution.
02-26-2013 02:24 AM
02-26-2013 04:35 AM
not like this I need when -500 or +500 . These are two conditions applies to a serial port. The condition for these two commands is different. So using this code If condition is wrong the other case will be considered I don't need like that. I need the help such that when the input is - values It shold take -500 and when the input is not equal to comparing value then no command should sent. When the input is positive but the number is comparable to the comparing value, then the command should be +500. So what I have to do
02-26-2013 04:37 AM - edited 02-26-2013 04:39 AM
Hi perumpadapu,
use a comparison function and a case structure. All your "IF-THEN-ELSE" is just realized with compare-and-case-structure.
When you're not comfortable with designing logic you should draw your thoughts on a sheet of paper first!
02-26-2013 05:16 AM
comparison will not work I will sent the required thing in this reply
02-26-2013 05:41 AM
02-26-2013 05:45 AM
Hi GerdW
My first question to you is how you are creating such images ? Is there any shortcut method for this?
2nd question. Instead of using two VISA write if at a time only 1 condition is true then we can combine the strings. Because after VISA initialization this 2 VISA write condition is then this connection will pose problem ?
02-26-2013 05:50 AM - edited 02-26-2013 05:50 AM
Hi Ranjeet,
those pictures are snippets...
2nd question:
The OP has to provide a VISA resource wire. By doing so he can execute one case after the other. He also wanted to have the VISA-Write in the cases as he wrote "don't write anything if case is not true": easiest is to put VISA-Write in the TRUE-case...
02-26-2013 05:56 AM
Why cant like this ?
I think this is also OK
02-26-2013 06:18 AM
You can't gaurantee that both conditions won't hit at the same time. You will need to send a separate command for each condition.
Plus, using EQUALS on floating points is dangerous. You might never get the condition because a really low bit could be off.