Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

serial data missing in multiple port operation

Solved!
Go to solution

Hello.

My unit is transferring 51 bytes of asynchronous data in frames(each frame at 80ms) on six different channels (ch1,ch2,ch3,ch4 of baud rate-19200 and other two ch5,ch6 of baud rate 115200) and these six diff serial data is received by my system and it has to be checked for any byte error...(as i'm new to labview I've programmed a lengthy vi) in which I use visa read and process the received data... But now my real issue starts... upto certain time my system 'll be receiving data without any loss but aftr some time(say around 15mins) the data loss starts from the channel having baud rate of 115200 and later other channels start acting same...But my system is expected to run for 4hours for an endurance test of an aircraft... If the data loss is very less in numbers then its OK but 3 out of 4 frames starts missing...that is like loosing 75% of data.... I 'm attaching a snap of my code..Its just for a single port(in a while loop) I've taken..Imagine I;ve done same thing to rest port in a single while loop.... Please guide me where ive gone wrong or is it anything to do with time delay....pls help me out

the thing is still my system application needs is gonna grow more so I've to rectify this in beginning itself

0 Kudos
Message 1 of 14
(3,943 Views)

There is no need to do the VISA Configure Serial Port with each iteration and doing a VISA Flush I/O Buffer makes no sense to me. You are waiting 30 msec, discarding all data and then waiting to read the 51 bytes. Try it with just a VISA Read inside the loop. 

0 Kudos
Message 2 of 14
(3,932 Views)

Thanks...yes I tried only visa read inside the loop..For 20 mins ther was no issue...but after that data started missing...even though I was receiving 51 bytes data frame header and footer had changed their positions...Then I aborted and rerun the program immediately and observed and same thing occurred after 20mins.. Y is this happening?

0 Kudos
Message 3 of 14
(3,914 Views)

You have disabled the termination character and yet you are using a fixed byte count for a read. Are you sure there aren't more than 51 bytes being sent? Have you tried using the VISA Bytes at Serial Port to tell you exactly how many bytes are available?

0 Kudos
Message 4 of 14
(3,904 Views)

Yeah I'm sure that 51 bytes of data in a frame/80ms is sent per channel..In that header is hex"55" and footer is hex"CC" ,penultimate bit is check-sum(that is XOR'ed result from 1st to 48th bit). And I admit that I have no proper idea abt the termination character function. So ,is the issue bcoz of termination character? I'm starter to this lv programming.. pls help me clear this... Can u show me an example for my requirements where out of 6 ports 2 COM ports 'll have baud rate at 115200kb/s and 4 COM ports 'll 've baud rate at 19200kb/s... Its jus simple that the unit is sending 51byte data frame at 80ms in all 6 channels... And my PC has to just receive dese data for a quite long time and display them & 've to be written to a txt file... I've given responsibility to accomplish dis..But I'm stuck up in the data receiving part and unable to proceed to next step.. I'll try out the method u suggest..Data processing part I've completed..Only long term data receiving is unsuccessful.. 

0 Kudos
Message 5 of 14
(3,889 Views)

Yeah I'm sure that 51 bytes of data in a frame/80ms is sent per channel..In that header is hex"55" and footer is hex"CC" ,penultimate bit is check-sum(that is XOR'ed result from 1st to 48th bit). And I admit that I have no proper idea abt the termination character function. So ,is the issue bcoz of termination character? I'm starter to this lv programming.. pls help me clear this... Can u show me an example for my requirements where out of 6 ports 2 COM ports 'll have baud rate at 115200kb/s and 4 COM ports 'll 've baud rate at 19200kb/s... Its jus simple that the unit is sending 51byte data frame at 80ms in all 6 channels... And my PC has to just receive dese data for a quite long time and display them & 've to be written to a txt file... I've given responsibility to accomplish dis..But I'm stuck up in the data receiving part and unable to proceed to next step.. I'll try out the method u suggest..Data processing part I've completed..Only long term data receiving is unsuccessful.. 

0 Kudos
Message 6 of 14
(3,889 Views)

Often it is better to separate the Reads from the interpretation of the data, especially when timing is critical. With all that conversion code and all the indicators in the loop things may slow down due to the OS writing to the screen.  Look at the Producer/Consumer Design Patterns which come with LV for ideas about how to separate the reads from the interpretation.

 

Termination characters are caracters sent at the end of each frame, often a line feed or carriage return.  If hex CC is guaranteed to never occur in the data, then CC may be used as the termination character.  When using a termination character you set the bytes to read to a large number (in your case I would use some thing larger than two frames, perhaps 120 or 200). The Read automacially stops when the termination character is found in the data stream.  The first time through the loop you may get a short frame or extra characters but after that it should give you one complet frame for each read.

 

If I interpretted your description properly, you are receiving less than 4000 bytes per second.  That should not be a problem.  Are your COM ports on the mother board of your computer, on PCI cards, or on USB adapters?  The problem my be with the way the OS interacts with the port drivers.

 

Lynn

Message 7 of 14
(3,886 Views)

Thanks lynn..my COM ports are on pxi card... NI PXI 1042Q.. one more thing i have to mention... along with this receiving operation i'm also sending commands to 3 channels out of 6 and also controlling lambda power supply and load thru serial communication in a single program... so will all these contribute for system slow? or have i made my code complex..? my seniors requirement is to run everything at a single click.. am i messing up the code or something?

0 Kudos
Message 8 of 14
(3,879 Views)

The PXI-1042 is a chassis.  The modules you plug into it do the work. I suppose you may have something like the PXI-8430/8 module in the chassis.

 

The data rates you are using should not be a problem. My guess is that your program architecture causes the program to slow down or one part of the program may be blocking other parts from running.

 

With multiple instruments communicating simultaneously but asynchronously, you need to be careful in the design of the program to make sure that all communications ahre handled promptly.

 

Since this is a school project, it is important for you to learn how to do these things for yourself.

 

I presumed that you are using LabVIEW for the programming, but you did not say that.  Is this correct?

 

Handling multiple instruments is not a trivial task. Prepare a design specification (if you have not already done so) which clearly indicates what communications tasks are required for each instrument. It must also specify what data (including commands) are sent to each instrument and the source of that data. Similarly specify the data received from each instrument and where it goes and what will be done with it. What inputs does the user provide? What information is displayed to the user? What information goes to files? When you have these specifications, then you can begin to select appropriate architectures for your program.

 

Anything which will be done multiple times or places in your program (such as serial port communications) should be made into subVIs.  Make sure there is no data dependency between any subVIs which may need to run in parallel.

 

Lynn

0 Kudos
Message 9 of 14
(3,868 Views)

I apologies if I have not conveyed my message properly... Yes Lynn you're right I'm performing serial operation using pxi 8432/8 module on pxi chassis... By the way this is not a school project what u presumed is right... Based on above comments and suggestion I tried serial communication using only single channel as a experiment and there was progress Upton some extent as the system was receiving data Upton 50 mins continuously, but I had used hex C as termination char., so whenever hex C appeared in any other position other than footer,I'm loosing data frame.It happens for every 200 read,can this be solved...?After 50th minute program hangs and forcibly I've to end whole labview program:(  And I'm running power supply control program and serial communication program in separate vi window simultaneously... 

0 Kudos
Message 10 of 14
(3,842 Views)