LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Hi!!I have some problems with the synchronization of my system, and I don´t know how I can solve this!

My system consists of differents vi´s.Some of them are used to read analogic inputs and digital inputs, using the serial port.
The values that I read, go through differents vi to be proccesed, and at the end, these values are written in a file, all the values in the same file.
My problems of synchronization are:

1. I have one vi per input, and all of them use the same serial port. How can I synchronize them to avoid serial port conflicts? (using queues??) And how can I do, to get differents number of samples/sg with every vi? I have to introduce them in differents loops?

2. The other problem is that, for example, I want to read 8 samples/ s but I only want
to write two samples every second. How can I do to avoid stoping the data flow?

Maybe, my problem is that I want to see the system like
one block, and I am ignoring that, although all the system works like a block, every part works using a different "speed". I don´t know how tools can I use to combine two ideas, working like an only system( data dependence, some vis need the data of others vi to be able to work) and working getting differents numbers of samples/s.
I have seen that there are synchronization vis. I am going to glance at them, maybe I find something interesting but I amsure that your help will be very useful?
Thanks in advanced!!

Graci
0 Kudos
Message 1 of 5
(2,313 Views)
I think you are pretty much on the right track with Queues. I have implemented a very similar system myself using queues. I have even different systems connected to the serial interface, but I can synchronise them all easily using the following method:

1) Make a VI for opening the serial port and reading the data. The data (parsed to extract the numbers required) are then stored in an array (Shift register). If the pre-determined time delay is reached (say 5 seconds) the values are averaged and written to a Queue with a defined data type. Save the VI as a VI template.

2) Make a VI which starts an instance of this template VI for every channel you require. You can use VI Server to set values on the new front panel before you set it's property to "running". Setting a timer value for all can help ensure that the X-Axis of your timing values (if you require) are synchronised. The clue here is to define and initiate a QUEUE per channel. (RS-232_1, RS-232_2 and so on). The QUEUE name needs to be passed to the VI Template before running so that each VI running in the background has an individual link to the main program.
The second part of this VI simply uses an array of QUEUES, polling them one after another with a timeout of, say 5 ms. If data is found, append accordingly to an XY-Graph.

I also add in some "Auto termination" in the VI template (MAx number of values allowed in the QUEUE for example) to allow for the background processes to find out if the front-VI is still running or not. There are many different ways to do this, shoose the best for your application.

With this approach, it's not even important what instrument is connected as long as data is written in a specified format into a known QUEUE. I have also developed systems where I can transparently (almost) drop in VI Templates for instruments with similar functionality (output data) from different suppliers.

I would post an example, but the time it would take me to clean it up is too large. Sorry. If you have any further questions, don't hesitate to ask further questions.

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
0 Kudos
Message 2 of 5
(2,312 Views)
Hello Graci,

my first idea here would be to make use of Locks (Synchronization Palette) with the serial vis to be able to synchronize parallel loops and try to achieve those rates.

Also, another idea is to reconsider how the communications are being carried out, I mean, instead of complicating the program's structure with parallel loops, queues, locks, etc..., just read/write all points at the same time at the fastest rate you need. Then you can get rid of unwanted data discarding it later. I'm sure in some circumstances, this could achieve better rates (the other approach introduces a lot of overhead), and the programming would be a lot simpler (I don't know if this is possible on your application, it's just an idea).

Regards,
JorgeM.
0 Kudos
Message 3 of 5
(2,312 Views)
Ah, I missed the part about all using the same port. The locks are indeed the best way to achieve this.

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
0 Kudos
Message 4 of 5
(2,312 Views)
Hi again,

just to make my comments more clear, locks can be implemented with the VISA Lock Async and VISA Unlock vis .... not in the synchronization palette : )

Regards,

JorgeM.
0 Kudos
Message 5 of 5
(2,312 Views)