LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Declaring variables in LabVIEW

Hello everyone, 

 

Could someone please help me with this LabVIEW program? I admit that I am new to the program, but I have been seeking for help online also. I don't think there is a direct answer to my problem, and I'm not here for answers. Any advice and tips would be greatly appreciated. 

 

About the program: 

 

My sub panel is an x-y platform where a mouse cursor navigates about. I have three different cases:

0: Do nothing 

1: Update mouse coordinates (x & y coordinates are displayed in boxes titled "Local Mouse Coord")

2: Display absolute position (x & y coordinates are displayed in boxes titled "Encoder counts")

 

My program currently works so that the mouse coordinates (in pixels) are updated and displayed when the cursor is within and beyond the sub panel's bounds. My goal is to only have everything be updated ONLY when the cursor is within the sub panel's bounds. 

 

Below are screenshots of my current sub panel and block diagram.

 

Sub Panel

 

Screen Shot 2012-08-30 at 8.48.20 PM.png

 

 

Furthermore, my solution to my goal is to use a not function connected prior to the three different cases. The following are the four coordinates to my sub panel's corners (bounds): 

 

(20,20) - Top left

(342,20) - Top right

(20,342) - Bottom left

(342,342) - Bottom right

 

Given these coordinates, I came up with piecewise definitions of when the coordinates need to be displayed and updated: 

20 < x < 342 && 20<y<342

 

Below is a screenshot of a diagram of what I would need to do in LabVIEW. However, in order to do so, I realize that I need to: 

1) Declare variables x & y

2) Tie both x & y together (i.e. a case is executed if and only if x and y are true) 

 

Not Function.jpeg

 

 

Will someone kindly please help me? Smiley Wink

 

 

 

0 Kudos
Message 1 of 18
(4,191 Views)

Use the mouse move event for subpanel

Message 2 of 18
(4,186 Views)

I'm so sorry I'm still a newb. How do I do that? 

0 Kudos
Message 3 of 18
(4,182 Views)

Hi qpt,

 

    When you right click the event structure, select add events, it will open  a popup menu .The rightmost column will have the events and the column adjacent left to it will list the controls available.In that you have to select the subpanel( If available)

  I dont have acess to  LabVIEW  to show you the image or share code

Message 4 of 18
(4,177 Views)

Hi qpt,

 

"I'm so sorry I'm still a newb. How do I do that?"

Two points:

- Have you gone through the basics courses offered by NI? They are for free!

 

- When you ask for "declaring variables" you didn't understand the LabVIEW programming paradigm: There are no variables. You don't need to declare them. Use DATAFLOW! The wire is the variable! Back to first point...

 

To help for your question:

- Ever looked at the InRangeAndCoerce function?

- Ever looked into the boolean functions palette? There's an AND function. No need for additional NOTs...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 5 of 18
(4,167 Views)

Hi

 

There is not direct event that you can use with a sub panel control.

 

You can calculate the corordinates of the sub panel from its properties -> Position and Bounds. this you seem to have done already.

 

You can then use the mouse coordinates obtained in the Panel mouse move event and compare with the sub panel start and end coordinates.

 

you can use the in range? function available in the comparison function palette.

 

As you only wanted tip and not the solution, i am not posting the code.

 

 

 

Regards
Freelance_LV
TestAutomation Consultant
Message 6 of 18
(4,163 Views)

Thank you so much everyone for the replies! Smiley Happy

I read about the in range and coerce function. This seems to be the most suitable for my task. 

 

However, in repy to FreeLance LV 's post... 

You said "You can then use the mouse coordinates obtained in the Panel mouse move event and compare with the sub panel start and end coordinates."

I'm still kind of lost here. How would I obtain the sub panel's start and end coordinates? 

I know what their values are, but how would I get those values to connect to the in range function as upper limit and lower limit? 

Also, I connected "Coords" to x of the inrange function. This is correct right? 

 

One more question to all, 

How would I connect an event to a case structure... and have that function pertain to ONLY one event? 

Every time I connect something to a case structure, it gets connected to all events =/ 

0 Kudos
Message 7 of 18
(4,137 Views)

Thank you for the suggestion on free basic courses GerdW! 

I'll check them asap! Much appreciation 

0 Kudos
Message 8 of 18
(4,135 Views)

Alright

 

Read the tutorial anyways....

 

its easier for me to post the vi than explain it to you in words.. so ..here you go with what you should do.

 

and for thesecond half of your question.. need more clarity... not understood what you meant by connecting event to a case structure

Regards
Freelance_LV
TestAutomation Consultant
0 Kudos
Message 9 of 18
(4,129 Views)

Sorry, I forgot to attach the following. Here is a screenshot of what I currently have. I created a constant from the "Local Mouse Coord" and changed the values to my desired limits (is this right?). Then I connected them to the function. 

 

Screen Shot 2012-08-31 at 12.31.22 AM.png

 

And also attached is a copy of the file I'm currently working with. 

0 Kudos
Message 10 of 18
(4,122 Views)