Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading stopps although....

I use VISA Read to read values from a scales. The scales sends 22 signs a time, terminated by a carriage return and a line feed after that. It is set to "send always". I work with Hardware Handshake (CTS/DTR)
Although I did the following things, I only receive 22 bytes in the read buffer of VISA Read.
The things I did (in order of data flow):
- Configuring the Port in frame 1 of a stacked sequence
- Immediately after configuration I put a property node where I set the Termination Character Enable attribute to false and the Serial End Mode for Reads to None
- Write \1BP\n to the Serial port (= send/print always)
- VISA Close
- in frame 2 of the stacked sequence I put VISA Read (in a while loop), the "bytes at port"-count is at the bytes to read port of VISA Read
If I put a probe on the bytes to read (which are the bytes at port) I can see that this number increases but the probe at the read buffer shows only 22 bytes at each loop iteration. But I need to read all bytes at the port because I need the last (latest) one for further application.

What else is to do? Is the carriage return in the signal from the scales the problem? What do I do to read without stopping?
0 Kudos
Message 1 of 10
(3,649 Views)
You attached your code in another posting and I'm confused about something. You say here that you use CTS/DTR handsahking but in your example program, the handshaking is set to none. You have nothing wired to this input of VISA Configure Serial Port so it will be set to the default of none. The other thing is, you are doing a VISA Close in the first sequence. This should be done when the sequence ends and not before doing your read. I don't think this is the cause of your problem but it would be cleaner to do it afterward. You did not include your Init_RS232 or Clear_RS232 VIs. What are these doing? Try running your VI with only the code for Com1 and see if this makes a difference.
0 Kudos
Message 2 of 10
(3,643 Views)
Hello Dennis,

thanks for your ideas. They helped a little bit, but didn't solve the problem.
The Init_RS232 or Clear_RS232 VIs have nothing to do with the VISA Read problem (on COM1), they are for a different device on COM2.
I wrote an extra programm only for COM1 and only with the VISA Read task and tried two things:
1. When I close the VISA session immediatelly after configuring the port, disableing the termination character, setting the buffer size and writing the print order the following thing happens (this is the way a had done until now): I can read only 22 byte, independent of how many bytes are at the port (bytes at port = byte count at the VISA Read vi, but this number is not equal to the read count at the VISA Read vi)
2. I closed the VISA session after the while loop with the Read vi, I mean at the end of the programm. In this case I can read as many bytes as exist at the port. (bytes at port = byte count at the VISA Read vi = return count at the VISA Read vi) But the string I read are squares and strange signs but no numbers.
I'll attache the 2. version.

Zane
0 Kudos
Message 3 of 10
(3,609 Views)
It could be that the instrument does not send numbers as characters but as hex. If you were to post the instrument manual or a link to it, someone could look at it an help you determine how the data is formatted and how you can interpret it. What happens when you connect to the instrument with Hyperterminal? Do you see the same sort of characters?
0 Kudos
Message 4 of 10
(3,595 Views)
Hy,

here are the two pages of the instrument manual that explain the data exchange. I work with 22 signs ( so forget the page about the 16 signs). Unfortunatelly the manual is in German, elt me know if there are problems.

Zane
0 Kudos
Message 5 of 10
(3,586 Views)
sorry, the attachment is empty.
0 Kudos
Message 6 of 10
(3,581 Views)
here is the second attachment - sorry, it was to big to send it together.
0 Kudos
Message 7 of 10
(3,581 Views)
Unfortunately, I don't speak or read German so I can't help with the manual. Hopefully, someone who does will see this posting and be able to help. I know there are several active German speaking members of the NI forum. You might be able to get a response by posting a new question in German to the LabVIEW general forum.
0 Kudos
Message 8 of 10
(3,570 Views)
Zane, Dennis,

let me jump in here, as I'm a German.

Zane,

using serial connections works the following way:
1. Open the serial port
2. Configure it (in your case set it to the setting that is used by the scale.
3. While not finished do
3a. Write some data to the device (if necessary)
3b. Check number of bytes at port
3c. Read that number of bytes, append the result to whatever was left over from the last reading
3d. Check your result for a complete answer. If an answer was found, it should be removed from the result string. React to this answer as necessary.
3e. Repeat with 3d until no complete answer is left in your answer string.
3f. Repeat with 3b until no more data are there on the serial port.
3g. Repeat with 3a if necessary.
While End
4. close port

One can, of course, capsulate these actions. One can, for example, read the responses until there are no new bytes for a given period. On can (and in more complex programs on even should) separate communication and data processing. So any complete answers of the device should be send via a named queue or so to an independent process that operates the data.


To come to your specific problem:
1. Do not close the VISA session until you are done. Accessing the port after you have closed it may work, as LabVIEW implicitely re-opens the port. But there are several pitfalls.
2. As the manual states, that the messages are plain text and that each message is finsihed by , you could use as termination character. This way you just have to read your 22 Bytes independently if they are there or not. You may set a timeout period of a little more than the delay between two consecutive messages of your scale.
3. Its up to you how to stop your loop reading the scale messages, but close yor port afterwards.

Using my typical signature you should be able to find my direct mail adress, in case you need some more detailled discussion, maybe in German.

Greetings from Germany!

--
Uwe
0 Kudos
Message 9 of 10
(3,566 Views)
Hello Uwe,

I can't find your e-mail-adress. I have some more questions, but think it is easier to contact you directly and speak German. Please tell me your adress or write a mail to henze@bartels-mikrotechnik.de
Christiane
0 Kudos
Message 10 of 10
(3,497 Views)