LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

While Loops, chain of events and Value updating

Solved!
Go to solution

Hello you people much smarter than me, 

I am currently working on a project where a system is controlled by receiving strings via RS232. The system is going to control some stepper motors, with a varying angle of movement. 

 

I made myself a little GUI with LabVIEW for ease of use, but I am now presented with a minor issue (not even a bug). I have a dial to set the step angle and then a button to select the direction. The buttons trigger an event change within a while loop, the step angle is "coming in from the outside". The issue is now that whenever I change the angle, the new value is not transmitted on the next move, but the one after that. While this is supposed to happen as the loop runs only if I have an event change, it is still annoying because you always have to think one step ahead. 

 

Is there a way to change this, or am I maybe missing a simple thing how this is to be mended?

I am a relative beginner/ occasional user of LabVIEW btw. 

I attached my VI (LabVIEW '18) if you want to have a look yourselves. 

 

Thanks, 

Ivo

0 Kudos
Message 1 of 10
(3,193 Views)

Hi Perl,

 

the step angle is "coming in from the outside". … the new value is not transmitted on the next move, but the one after that.

A clear THINK DATAFLOW! problem combined with a race condition…

 

When you need the current value IN THE EVENT CASE you need to read that value IN THE EVENT CASE. THINK DATAFLOW!

Best regards,
GerdW


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

Wouldn't I need 4 front panel items for the different directions then?

I would like only one single readout, that is used by the 4 different events. 

The issue is to minimize user error, and in this case, the bigger issue is that the angle for all 4 directions is the same. 

 

If I could "join" the 4 elements in the block diagram in one readout on the front panel, that would be fantastic. 

0 Kudos
Message 3 of 10
(3,177 Views)
Solution
Accepted by Perlmarmelade

Hi Perl,

 

I would like only one single readout, that is used by the 4 different events. 

You could:

- read from a local inside those event cases

- read the dial control in it's own event and store it's value in a shift register…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 10
(3,175 Views)

Thanks, I will try that. 

 

On another note, is it possible to tell a numeric control wheter to use a point or comma as decimal point?

It currently does a comma, and a point would definitely be better to treat in C++ i my system. 

0 Kudos
Message 5 of 10
(3,172 Views)

Hi Perl,

 

you can:

1. Set your OS to use the point instead of the comma as decimal separator.

2. Tell LabVIEW not to use the system setting, but the point by default.

3. When communicating with your "C++ system" you can format your numeric value into string using FormatIntoString with proper format codes…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 10
(3,168 Views)

@GerdW

 

you can:

2. Tell LabVIEW not to use the system setting, but the point by default.


How would one do that?

0 Kudos
Message 7 of 10
(3,165 Views)
Solution
Accepted by Perlmarmelade

Hi Perl,

 

open the LabVIEW options and see all those "Front panel" options

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 8 of 10
(3,151 Views)

Alright, got it. 

 

Thanks, Mate

0 Kudos
Message 9 of 10
(3,144 Views)

@Perlmarmelade wrote:

Wouldn't I need 4 front panel items for the different directions then? 


The correct way would be to eliminate all this duplicate code!!!

 

Once you combine all four direction events into one, they all can read the same value from the same terminal inside the same event. Here's how that could look like.

 

altenbach_1-1616348883952.png

 

 

Now you have less code which is also much easier to maintain. For example if you later decide that you actually want two decimal digits, you only need to make one simple change instead modifying in four different places!

 

Many of your other events only differ e.g. by a single string (stop, end, origin, reset) and they could be combined in a similar way (not shown).

0 Kudos
Message 10 of 10
(2,096 Views)