04-27-2016 09:16 AM
1) Cylinder's flow rate (command to be passed is "b" and data returned for example is "b 32 43 76 34 12 76" )
2) Temperature (command to be passed is "t" and data returned for example is "t 35")
3) Rpm (command to be passed is "c" and data returned for example is "c 400 32.5 23.1" , first value is rpm, other two values are some average)
My requirement is to capture all these data at once and displaying it into a table and to generate report. Is it possible to pass mutiple commands at once for serial communication? If not is there any other way to get all 3 types of data one after another by passing one command after another in a loop?
04-27-2016 09:41 AM
That depends on the equipment you're using. Some hardware allows for multiple commands to be separated by some character (like a semicolon) while others do not. You'll have to check the manual or ask the company.
Performing each step is series is certainly possible and can be implemented in various ways. Each step in the sequence should occur in order by ensure proper data flow (you won't need a flat/stacked structure). multiple measurements can then be handled with a for loop OR while loop.
Another option is to use a State Machine architecture where each acquisition (rpm, temperature, flow rate) is it's own state. You can just as easily measure all 3 in sequence, OR you can change the frequency of the measurements (say you only need temperature every third acquisition). How you implement your code depends largely on your requirements.
04-27-2016 11:48 AM - edited 04-27-2016 11:48 AM
Hi madara,
why do you create double posts on the same topic? Stick with one thread per topic!
What's wrong with the answer you already got?
04-28-2016 09:04 AM
Hi.The machine accepts "btc" command and send the data for command "b" , "t" and "c" one after other. But when individual command "b" or "t" or "c" is given and after a period of time if the command is changed in write buffer the read buffer shows data of older command . How to clear the data in read buffer and to instantly get data for new command given?
Another problem is when running the vi if stop button which is inside while loop is pressed the loop does not stop instantly, sometimes we have to stop the whole vi. Is there a solution for this?
04-28-2016 09:19 AM
This is completely normal behavior. The buffer of the machine will hold the data until it is read, overwritten, or cleared. Whether or not the machine will overwrite the buffer or append to it, is machine specific. Whether or not the machine has a "clear buffer" command is machine specific.
If you are concerned of data being left in the buffer, it is up to you to ensure the buffer is cleared before you make a query.
In regards to the VI not "stopping" instantly, you must understand that NOTHING in reality happens instantly. Your code will be running a certain operation when you hit the stop button. If it is in a subvi, you must wait for the subvi to finish. if it is in a portion of the code with a time-out (lets say a read function) you either have to wait for the data to be read or the time-out to occur.
It is your responsibility as the programmer to ensure that communication functions smoothly and error free. In regards to stopping the program in a timely manner, you can reduce the time-out periods to make it seem more responsive to the user.
04-28-2016 09:57 AM
I would suggest that you change your design to something like the producer/consumer design pattern (events) template but change the consumer loop to a queued state machine. This will allow you to respond to send commands and then actively read from the port when data is available. This will also let you stop your loop like you want.
You can use a property node to check for data in the read buffer.
04-29-2016 10:19 AM
Hi. I have made a vi such that if i press a "ok" button in front panel data is collected from visa serial. But when i press "ok" button after few seconds i won't get dynamic data (real time data) instead i get data which is already stored in the buffer. Is there a way to set size of I/O buffer or read buffer so i can get real time data when i press "ok" button . Will this be solved if i keep visa serial inside while loop?