Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Number of byte at serial port

Dear all,
 
I write serial communication of a commercial instrument with Labview 6i.
The communication is operated in binary mode in RS-232.
 
In my attachment, I use the property of "Number of byte at serial port".
it detects the correct number of byte (23bytes) to read.
but the size of real data(6bytes) (from VISA READ) is less than the number of property(23bytes)
Therefore I can read the data correctly.
 
In case of deleteing "close VISA" in the end of the routine, the number of property is going higher(e.g. 3000bytes) while running the routine.
 
Please guide me to write correct code wih labview 6i.
 
Thank you in advance.
 
 
0 Kudos
Message 1 of 7
(4,502 Views)
Labmaster,

some remarks:
1. When opening the serial port (or something else) _outside_ a loop, one should close it as well _outside_.
    Otherwise you close it with every iteration of the loop.
2. IMHO, your code can work just in debug mode (single step or execution highlighting), as the serial transfer as well as the devoice itself. need some time to operate. Your code  asks the number of bytes too quick.

What I would change is:
a) put opening & close outside of the loop.
b) flush the serial buffer of the port (simply  get number of bytes and read 'em) before entering the loop.
c) with each iteration of the loop, do just one write and read and a wait of -say- 5ms.
   Your write might be OK, the read should be done in a second inner while that  checks the number of bytes and compares it with the recquired answer length of your instrument. In case of enough bytes are availabel,
    you could finish the inner loop. In the other case, wait some 5 ms and continue looping.
    It might be usefull to include some timeout break in the inner loop (just in case the device is not responding).
d) add some stop mechanism into the outer loop.

Greetings from Germany!<br>-- <br>Uwe
0 Kudos
Message 2 of 7
(4,494 Views)
Very thank you.
 
b) Do you mean I should use the two while loops to read the data?
How to compare the number of bytes?
Please give me your example code for this work.
 
Best Regards,
 
 
0 Kudos
Message 3 of 7
(4,489 Views)
I would like to start off by apologizing that this is very confusing. The problem that you are running into is that when you program starts off it uses the Configure Serial Port.VI which has an input to enable termination. You later set the termination enable property to false. The problem is that this alone does not disable the termination. You also need to set the End Mode for Reads to None to disable termination.

The quick solution is set the Enable Termination to False on the actual VISA Configure Serial Port.VI.

Here is a KB if you would like to read about this more.

How do I configure VISA to NOT terminate a serial transfer on a character?

-Josh
0 Kudos
Message 4 of 7
(4,476 Views)
attached is a Q&D example...

Greetings from Germany!<br>-- <br>Uwe

0 Kudos
Message 5 of 7
(4,473 Views)
Dear LuI, JoshuaP, and all
 
Thank you for the comments.
Lul, I understand what you mean!. Very thnak you!
 
In binary operation, should I disable the input/output termination character?
JoshuaP, I wanted to disable the terminal character before VISA writing.
(It's my mistake.)
How to disable the option in labview 6i in configuration stage?
I know there is a connector in labview 7 or later.
 
I have much experience in writing RS-232 text operation, not binary.
Please understand this is not a simple problem for me.
In my recent work, I found I couldn't get the correct data in the specific command (I explained it my first question).
(In other commands, it is likely to be an expected result.)
Therefore I asked my problem to the instrument's technician and he pointed out the termination character without his testing.
(I have to disable termination character in binary operation.)
but he didn't explain why I met the problem in the command. (other command is Okay, as I told you.)
 
Please focuse on my real problem again.
 
Thank you in advance.

메시지가 08-11-2005 10:46 AM에 labmaster에 의해 편집되었음

0 Kudos
Message 6 of 7
(4,468 Views)
Hi LabMaster,
 
You should be able to configure the Serial Port using the "Visa Configure Serial Port.vi" located in the Serial pallet within LabVIEW 6.1. There is an input that allows you to enable or disable the termination character for the Read/Write.
 
This should allow you to get all of the characters that you see with the Bytes at Serial Port.vi.
 
Regards,
Matthew S.

LabVIEW Integration Engineer with experience in LabVIEW Real-Time, LabVIEW FPGA, DAQ, Machine Vision, as well as C/C++. CLAD, working on CLD and CLA.
0 Kudos
Message 7 of 7
(4,434 Views)