LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

SIT Connection Manager - Data acquisition

Hello there. For some time, I have been trying to solve a problem connected with the use of the SIT Connection Manager.

 

I have linked a Matlab model file with the vi successfully, no errors, etc. The thing I am trying to do is to acquire two variables: X and Y and plot them onto a XY Graph.

The problem is, however, that the data flow from the matlab file is so quick, that when I acquire a set of data (x1 y1) it is immediately overwritten by  the next set  (x2 y2) and this goes on and on. In the result, I don’t get a plot on the XY Graph, I always get a point, which is constantly moving.

 

I tried to build a buffer (with shift registers, while loops, even queue blocks) and nothing works – either I have no data at all, or  just the first pair 😕

I tried mapping the X and Y from Matlab directly to a XY Graph, but that didn’t work, so now I mapped  them to a Indicators, and from there I tried to connect them further to build that buffer. I think that the problem is connected with the way the X and Y data is made available to connect – they are in a case structure, and I can’t access them both in the same place (vide pic). When I try to remove them from the case (by a simple wire to an e.g. indicator , they don’t get updated at all).

 

So… my question and help request is connected with the problem: how to buffer data coming out of a Matlab File so that I can plot them all in a XY Graph.

 

I contacted our regional NI Tech support, they gave me some advices, but they don’t seem to work. So while I replay them (the replay takes 3-4 days to come back) I’m trying to seek help here.

 

Thank you for the discussion. 

0 Kudos
Message 1 of 7
(2,948 Views)

Hi!

 

Could you send the VI instead of screenshot? Would be easier to help.

 

Br,

Peter

0 Kudos
Message 2 of 7
(2,934 Views)
0 Kudos
Message 3 of 7
(2,924 Views)

Hi,

 

I have checked your code. Please help me with answering these questions:

- Where do you write X and Y local variables? I can't find them.

- Why did you implement queue in the block diagram, what is the purpose of that? (right below the while loop.)

- As long as I see, you draw 10 elements in the XY graph but all of them has the same coordinates. Am I right?

 

br,

Peter

0 Kudos
Message 4 of 7
(2,920 Views)

Hey

To answer your questions:

-          X and Y as local variables are written in the case loop signed as SIT_Indicator_Cases  Ther are 3 cases: -1, 0, and 1 For the -1 condition, there is nothing (except two empty arrays that I have put in, but they are unwired). For the 0 condition, the X variable is available, and for 1, the Y variable is available. The funny thing is, that even though X and Y are in separate cases, if you link an indicator to them, they  both generate results. But if you take on the indicator outside the case loop – they don’t show anything, or just one of them show something, and the other is constantly 0. In the vi I tried to acquire X2 and Y2 which should be the same as X and Y in separate cases structures, but that doesn’t work as well 😕 So, I tried to attach local variables to X and Y – they are used in to separate solutions – in the while loop, where I tried to use shift registers, and under the while loop, where I tried to use queue blocks.

-          I tried to use another solution for creating the buffer in the hope of that this one will work – the one with the shift registers doesn’t so… it was just an another plan to get this problem working – it didn’t. As I saw it didn’t even acquire X and Y values, not to mention writing them into a queue.

-          Yes. I should get 10 different X and Y values – X and Y indicators show different values each second, or so, and in the while loop I get only 10 times the same value (sometimes the last 2 values are different, like the actual second value that was shown in the X and Y, but as that happens, actual values of X and Y is not second, not third even, but it’s like the 30-eth or so, it depends.

 

Generally creating a buffer is not complicated in normal cases, but hiere the values come from the Matlab and I think that’s the main reason it can’t be done I regular ways (with e.g. shift registers)

 

Thank you for your time and attention

Peter

0 Kudos
Message 5 of 7
(2,916 Views)

Hi,

 

I am afraid there is problem with the basic structure. Let me translate your code into pseudo code, so you can identify why it gives 10 times the same value.

FOR
   X=GETX();
   Y=GETY();
   GRAPHX[]={};
   GRAPHY[]={};
   FOR i=0..10 DO
       GRAPHX[i]=X;
       GRAPHY[i]=Y;
WAIT(500); ENDFOR DRAW(GRAPHX,GRAPHY); ENDFOR

 So you set the X and Y once per FOR LOOP iteration, and write it into the graph ten times in the very same FOR LOOP iteration. X and Y will get new value only at next iteration.

Using QUEUEs is a good idea, but the way you implemented is not correct. The best way to start with it to check Example Finder in LabView help, end examine QUEUE structures like Producer/Consumer loops.

 

I hope It helped.

Peter

0 Kudos
Message 6 of 7
(2,912 Views)

We had to pause on this project for a while, I’m returning to it in a couple of days, so I’ll update this topic, if your solution helps 🙂 I’ll need to refresh my memories on queues in LabView however. Still, thanks 🙂

0 Kudos
Message 7 of 7
(2,835 Views)