ni.com is currently experiencing unexpected issues.
Some services may be unavailable at this time.
03-30-2021 10:40 AM
Hi,
I'm completely new to Labview but I'm trying to learn something.
I get this error, while trying to connect to Mega 2560 --> VISA: (Hex 0xBFFF00A6) The connection for the given session has been lost, but one hour ago it worked...I did not change anything...
Could someone help me?
Thank you in advance!
03-30-2021 10:44 AM
03-30-2021 10:46 AM
How are you connected to your device? What VISA session are you using?
03-30-2021 10:47 AM
This is what I did...It did not properly do what I expected, but anyway it compiled...
03-30-2021 10:51 AM - edited 03-30-2021 10:52 AM
Your use of a Loop here is a little strange - what do you want to do?
Are you trying to make a single write/read pair, or to poll something repeatedly?
In either case, a For loop is probably the wrong tool (for the first, no loop, for the second, a While loop).
You also want to call VISA Close at the end of your VI, and some sort of Initialization at the beginning (depending on device, perhaps VISA Configure Serial Port or VISA Open).
03-30-2021 10:55 AM
I wanted to append to an array each letter composing a word I give at the input, that's why I use a for loop with that N... I'm trying to learn something regarding LabView since 2/3 days...I'm sorry if I did something terrible..
Should I do this in different and easier way? I guess yes...
Thank you!
03-30-2021 11:00 AM
03-30-2021 11:05 AM
I previously send all the letters, such as: Hi!
Then, for the serial reading I read 1 letter at a time and would like to put each one into an array, in different indices.
For example: write "Hi!"
Read a row array with 3 elements containing H i !
I don't know if I am clear enough in the explanation, but the aim should be this
Thank you for your help up to now
03-30-2021 11:11 AM
Ok, so you want a program which sends a string with multiple characters to your Arduino, and then the Arduino code will echo the letters one by one back?
Are they echoed with a line termination character? Are they written separately (by the Arduino) or is the string just directly echoed and you only want to read it a single letter at a time?
If you want to read a single character, set the "bytes to read" input to VISA Read to 1.
Note that you'll get a warning (not an error) telling you that there might be more bytes available to read.
You can then index them out of the loop into an array.
If they're echoed slowly and you want to update the array between Reads, you'll need to put it inside the loop and use a Shift Register or Feedback Node to store the "history".