From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
08-11-2017 05:10 AM
The numeric indicator changes from a number to 0 too fast for me to see. Is there a way I can store all the numbers? Thanks
Solved! Go to Solution.
08-11-2017 05:16 AM
Be more specific, what is your program doing? Do you need to see all the values or just the non-zero ones?
Did you try using a chart? This displays all data.
Or an array? Or write values to a file?
If it just needs slowing down, use a wait function in the loop? (may not be appropriate depending on your functionality.
Many other ways to do it if you have more information. Maybe upload your VI.
08-11-2017 05:23 AM
I am trying to read in serial from an arduino, but I cannot tell if it is receiving properly. Attached is my Vi.
08-11-2017 05:39 AM
I expect the "Bytes at port" needs to be moved inside the while loop (but still before the case structure)? At the moment it only gets read at the beginning and your bottom loop will forever be reading the true case and overwriting the indicators.
Did you start from some example code? What is the expected flow of execution?
If you are just quick debugging, consider wiring the string to the edge of the while loop, set the tunnel to indexing, and make an array indicator. This will show you all the strings that have come in (though only after you press stop). Or log to a file. Or maintain the array in the loop.
Another thing you can do is use NI IO Trace (separate program that should have installed). You can use this to monitor the VISA activity. Open it, press the green arrow, then run your program.
08-11-2017 07:37 AM
It is obvious that the message is terminated with a Line Feed (0xA). The serial port is already set up to use that. The VISA Read will stop its read when 1) the number of bytes you told it have been read OR 2) the termination character is read. So if you set the number of bytes to read higher than the number of bytes you expect to ever come in a message, the read will stop with the termination character. This ensures you got a complete message.
So since you are seeing if a message has even started, you need to move the Bytes At Port inside of the loop. Just do no use it to tell the VISA Read how many bytes to read.
Other notes:
You can get rid of the local variables for the stop button. You should have your producer loop (the VISA Read loop) send a message to the consumer to tell it when it has stopped. The consumer can then stop itself. You can also set the button's mechanical action back to Latch When Released.
You really should not be using the Queue Status. Just let the Dequeue Element sleep while it is waiting for data to come in.
08-11-2017 08:46 AM
Thank you IanSh and CrossRulez, a combination of your solutions has solved the problem. I needed bytes at port inside the while loop and to manually set the visaread bytes.