LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Recording Serial Port Data Problems

I am trying to run a VI that allows me to retrieve data from two different serial ports.  When I do this, I use an array to compile the data from these different sources.  When the array is compiled, occasionally one of the data sources is not read correctly.  This results in the array not recording the desired data.  I have tried using waits and different sample rates in order to sync up these sources so they would record harmoniously.  I am limited to the hardware sample rates, which only has two settings.  I have attached a copy of my code (in version 8.5). I know it may not help much, as there's no hardware to read from.   Sorry for the messy VI, but its more of a reference.  Do you have any ideas on how to get around this problem?  Thank you.






Message Edited by drfunkphd on 08-07-2008 05:45 PM
0 Kudos
Message 1 of 4
(2,638 Views)
First I would recommend doing a major code cleanup.  You have a tangle of wires going in every direction and laying under objects.  It is impossible to tell what goes where.  You have stubs of code that go nowhere.  I know you admit it's messy, but doing the cleanup first before posting might help you solve the problem, or at least make it easier for others to follow your code.  Your upper right case structure has nearly indentical code, the only difference is which string indicator the results get written to.  Move all of the common stuff outside of the cases.  Likewise with the upper left case structure where the only difference is which String Control you are reading.
 
One problem I see is the millisecond wait timer in that upper right case structure.  Are you using that to provide a delay between the Serial Write and Serial Read?  That wait will occur concurrently with the Serial Read, thus you don't have any true delay between the Serial Write and the Serial Read.  This is probably the cause of why you lose synchronization between the two data streams.  You need to use a flat sequence structure with the wait timer in the middle so that the Serial Read can't occur until after the time has elapsed.
0 Kudos
Message 2 of 4
(2,618 Views)
Hi drfunkphd,
 
Ravens Fan is rihgt. you need to clean up the code. The next thing I would suggest is that for the read and write to occur sequentially, you have to put them in non-parallel structures using either a flat sequence or two loops using a producer-consumer architecture. For more reference on the producer-consumer architecture please look at this link. Hope this helps.
 
Ipshita C.
National Instruments
Applications Engineer
0 Kudos
Message 3 of 4
(2,589 Views)
Hi guys,

Thanks for the help.  The sequential structure worked very well.  And in the future I'll be sure to make the VI's a bit more legible before posting them.  Thanks again. - Dan
0 Kudos
Message 4 of 4
(2,565 Views)