Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

two instruments by RS-232

Dear
I am writing a code for controlling two different instruments(Samsung-Rockwell controller-COM4 and Inficon-COM5) by USB-to-RS232.
Binary transmission should be done to control the both instruments.
Each stand-alone code is good to control and get data without a loss or malfunction in real-time(under infinite loop).
But the combined code of both are interfered in the result string (there is a flowing of the buffer strings).
Therefore I obtained
COM4 : data1, NaN, data2, NaN...
COM5 : data1, NaN, data2, NaN...
 
Actually, I run two stand-alone codes for getting data at the same time.
There is no any data loss or malfunction when I don't touch computer's mouse.
But I have the same phenomenon  if I move the code program's window by mouse.
 
I guess some time delays from the computer operation.
Frankly, my code is constructed on a event-structure as you can see in my attachment
(main program : test_base_program_combined3.vi).
"Scan" event takes several seconds for each step.
But "Timeover" event set in 300 milliseconds.
Could you please advise me about this problem?
 
And tell me if you know some "buffer-flushing" methods in RS-232.
 
Thank you in advance.
 
 

메시지가 10-20-2005 07:26 AM에 labmaster에 의해 편집되었음

메시지가 10-20-2005 07:27 AM에 labmaster에 의해 편집되었음

0 Kudos
Message 1 of 5
(3,787 Views)
I found it is not related to the event structure.
I ran prog_run_main_combined2.vi (included in the attachment) on the infinite loop.
But it happened to loss the data.
Please give me your advice.
0 Kudos
Message 2 of 5
(3,779 Views)
Labmaster,

I do LabVIEW programming for more than 10 years now, but could not understand your code - itis not clear to me. It looks like you mix VISA ressources in some or the other way. What about opening and configuring a VISA ref for each of the recquired RS232 ports? Use this VISA Ref to get your data and analyze it! separately

You may as well put both uncombined versions of you code into two independent while loops. This ensures they get executed in parallel and independently. Communication between both code parts (and with any common part) must use system means like queues or locals or whatever you prefer - just to ensure the state of independence between the code parts.

To answer your Q about timeout event. This one is genereated whenever no other event got fired for the timeout period. So if another event takes several seconds to be handled, no other event is handled during that period.
BTW, it is very bad style to have longwinded code in an event handler. Use an event hendler more like an interrupt service routine. You may handle events directly whenever it takes just very small amounts of time, compared with the frequency you expect events to occure. In your case, with a timeout of 300 ms, I'd take event handling periods of about 10-30 ms as acceptable. Longer handling periods are better handled with extra code, that is started for example by a message sent via a queue or occurence or whatever you prefer. Search the examples for Producer-Consumer loops or similar. This way your event structure acts quite quick and longwinded actions can operate in parallel, maybe even with lower priority.

Just my Euro 0.02!
Greetings from Germany!<br>-- <br>Uwe
0 Kudos
Message 3 of 5
(3,772 Views)

Thanks Lul,

Yes, two indendent visa (USB to COM port) were used in my attachment.

I initialized them separately in binary mode transfer.

My purpose of this code is to acqure data (Infincon-Ecotec) just after changing the position of sensor (Rockwell).

That's why I put them in a sequence.

Can I realize your suggestion using Queue? Can you give some example code for me based on your core idea?

(please keep in mind the sequence of acquring data after moving by two instruments)

 

As for event structure, I can't understand how to modify my code.

Please give me some detail or close related example.

 

How about buffer-flushing?

 

Very thank you again.

메시지가 10-20-2005 06:13 PM에 labmaster에 의해 편집되었음

0 Kudos
Message 4 of 5
(3,764 Views)
Lab,

I took a look at your code.  It looks like all your VISA reads and writes are done asynchronously.  Try changing them to synchronous writes and see if the problem persists.

Check this site out for info:
http://digital.ni.com/public.nsf/websearch/ECCAC3C8B9A2A31186256F0B005EEEF7?OpenDocument
The bottom of the page describes how to make this change.

Good Luck!

Travis W
VISA Enthusiast

0 Kudos
Message 5 of 5
(3,737 Views)