05-25-2012 07:07 AM
"termination char calls for termination of the read operation. The read operation terminates when the termination char is read from the serial device. 0xA is the hex equivalent of a linefeed character (\n). Change the termination char to 0xD for message strings that terminate with a carriage return (\r)."
Above is the context help for termchar.i don't understand it clearly....In our case what will be the Termchar to signal the EndOfString??It should be an integer value.Is the term char will be the last value of our array?? can you please explain it for me?
05-25-2012 07:23 AM - edited 05-25-2012 07:25 AM
Term char is only important for the receiving side of the communication link.
Basically you have two possibilities to transmit data over a serial link, either fixed size (including variable sized messages that contain some sort of length indication in a header) or termination character defined. These are the only two options to signal to the receiving side that a message has been completely received. In the case of termination character you specify the character byte that will tell the receiving side that the last byte has been transmitted.
Now VISA does allow to append automatically a termination character to any send message but I would not recommend to do that ever. For one there have been VISA versions in the past where that did not work reliable and for two I'm a proponent of implementing a protocol properly and not relying on underlaying transmission mechanismes to do such things automagically. So if your external device expects a carriage return then add that explicitedly in the string you send out.
For receiving messages this is another thing. VISA needs to be able to determine when to stop waiting for incoming data. It has really three mechanismes for that.
1) if an error occures, either in the underlaying transport layers or due to the timeout having elapsed before one of the next two mechanismes has occurred
2) if a specific configurable character has been received (only if the terminate on termination character receive is enabled)
3) if the specified amount of bytes has been received
Which termination character to configure VISA for, if any, will depend on your device.
05-25-2012 07:30 AM
Thanks...Thanks a lot for Gerd and rolfk.This helped me to understand more about VISA read and write.
05-28-2012 12:28 AM
In the below attached VI.How can we see each array element in the particular array index as the input array??Now all the elements appears on the first column of the output array.
05-28-2012 01:27 AM - edited 05-28-2012 01:29 AM
Setting the string in the write VI to "\ Code Display" by right clicking on it and appending to each "\n"!
Alternatively you can do that in the diagram by using Concatenate String and adding the "\n" character to each string before you send it off. There is a line feed constant in the string palette or you can use an ordinary string constant right click on it and set it to above mentioned option. Then add the "\n" in it.
05-28-2012 01:50 AM
The index array function outputs each array element one by one and they will be the input to the VISAwrite,so
"Setting the string in the write VI to "\ Code Display" by right clicking on it and appending to each "\n"! "
You mean the output of the index array function??And where to append "\n".Can you please explain in detail.
one more question:-
Is there any changes that we have to make in read.vi??
05-28-2012 02:05 AM
@danil33 wrote:
The index array function outputs each array element one by one and they will be the input to the VISAwrite,so
"Setting the string in the write VI to "\ Code Display" by right clicking on it and appending to each "\n"! "
You mean the output of the index array function??And where to append "\n".Can you please explain in detail.
one more question:-
Is there any changes that we have to make in read.vi??
No! You have an array of strings you send. You also have configured the termination character in the write.vi which makes BTW no sense as is. That termination character configuration only has influence on the receiving side. So no, you do not need to change anything in your read.vi as you configured it to terminate on the termination character. But you need to make sure that every string you send of in the write.vi is actually terminated by this termination character.
So you can either right click on the string inside the array control on your write.vi, selecte "\ Code Display" and then add "\n" (without quotes of course!) to each string. Or you can add a Concatenate String function inside the loop, after you retrieve the string from the array and add this character explicitetly in the diagram. Or you can read through the many VISA documentation pages to see which other property you need to set too on the VISA session to cause VISA to append that character itself. Something I would not recommend to do, unless you have a very specific reason to do so. IMHO you should always send out explicitedly what the device expects and not rely on such features. The automatic appending of termination character on send in VISA has in the past more than once shown weird behaviour. This was always promptly fixed by NI, but why risk such issues if you can avoid them entirely with a little change in your software. Besides I'm to lazy to go and find the right combination of properties each time I write a serial port instrument driver.
05-28-2012 02:21 AM - edited 05-28-2012 02:24 AM
Hi,
I made the following changes.By default the termchar appers to be 10.If we change the termchar again it automatically becomes 10.Also \n added to every string,but while running only 1st element of the array can be seen.
05-28-2012 02:35 AM
Where do you add the termchar in the write.vi?
And if you want to read more than one string in the read.vi, you should of course change the constant on the for loop that determines how many times the loop is executed!
05-28-2012 02:56 AM - edited 05-28-2012 02:59 AM
I did like this.