LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Trouble with state machine

Solved!
Go to solution

Dear colegues,

Three days ago I faced with the unundestanding of state machine working. I will breathly describe what I mean below.

 

In attached files you can find screen shots of two programs. CCD1-CCD4 are screenshots of standart thorlabs VI for CCD camera, which I just rebuild with state machine structure. This VI works perfect - interface doesn't stuck, all buttons works.

 

The next group of pictures from PLE measurement VI. I try to maximise detalisation, thus the quantity is too high.

 

This is also state machine, but in this program I use not only CCD, also thorlabs motors, shutters, powermeter, QEPro spectrometer, motorised mirror. All this stuff Initialise in first case. After that VI read position for motors from txt file and they move to ones.  PLE-CCD cycle1 is the case which is cycled for camera alignment and setting.

 

So, the issue is that I can't move window sliders, control any buttons on front pannel after pushing button which starts initialisation. But I see that maximum noise value from CCD changes (I have indicator on front pannel), thus I think that It is not realy stuck, but maybe problem in some settings of labview in my case? 

 

 

Could you help me with that?

0 Kudos
Message 1 of 6
(2,518 Views)

Hi Raskol,

 

In attached files you can find screen shots…

Two problems in one sentence:

1. You really want us to load 10 files instead of just on ZIP file?

2. How should we debug images using LabVIEW? Please attach the VI(s)!

 

the issue is that I can't move window sliders, control any buttons on front pannel after pushing button which starts initialisation.

Is there an event structure in your code, hidden in some case or (much worse) stacked sequence frame?

 

maybe problem in some settings of labview in my case? 

One problem for sure is the heavy overuse of local variables!

Use wires instead to avoid all those race conditions!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 6
(2,516 Views)

Sorry guys,

 

I attach to this message main VIs and zip with screenshots of my program. But the number of SubVIs is to big and their work needs to special software from manufacturer, thus I don't attach them.

 

I don't use event structure in this program (I remember, that it can locks the front panel).

But I usually use stacked sequence besides flat one, for better space economy.

 

I can try to rewrite program with wires instead of local variables, but are you shure about this? Becouse I saw the much heavier VIs with bigger number of local variables and they works ok.

 

Is there something like "rule of thumb" what I can use for local variables quantity reducing?

0 Kudos
Message 3 of 6
(2,502 Views)
Solution
Accepted by topic author Raskol

Hi Raskol,

 

for better space economy.

Use subVIs for "space economy"!

 

Becouse I saw the much heavier VIs with bigger number of local variables and they works ok.

They might work (seemingly) "ok".

But employing bad coding style because you saw other people doing so isn't the best excuse…

 

Is there something like "rule of thumb" what I can use for local variables quantity reducing?

Rule of thumb: replace locals by wires.

In LabVIEW the wire is the variable! (THINK DATAFLOW!)

 

(There is one reason to use locals: when you need to set the value of a control. In your images this reason is not the main use case for locals…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 6
(2,491 Views)

@GerdW wrote:

Hi Raskol,

 

for better space economy.

Use subVIs for "space economy"!

 

Becouse I saw the much heavier VIs with bigger number of local variables and they works ok.

They might work (seemingly) "ok".

But employing bad coding style because you saw other people doing so isn't the best excuse…

 

Is there something like "rule of thumb" what I can use for local variables quantity reducing?

Rule of thumb: replace locals by wires.

In LabVIEW the wire is the variable! (THINK DATAFLOW!)

 

(There is one reason to use locals: when you need to set the value of a control. In your images this reason is not the main use case for locals…)


To be a little more explicit re: Gerd's response (and your question) highlighted above:

If a local variable was read before it was written to, you would be reading stale data and actually be missing data points.  Most likely, you wouldn't even know this occurred because adjacent data points are generally similar to each other (except when they aren't, and that is where you could be getting into big trouble reading stale data).

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 5 of 6
(2,445 Views)

Thanks GerdW!

 

I changed all local variables to wires, and now it works normaly. I think, that the most part of trouble was in the 2 local variables which I used for writting array from camera matrix (1280x1024 elements).

0 Kudos
Message 6 of 6
(2,438 Views)