From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
08-13-2014 03:47 PM
Hello,
I have a linear stage that I am controlling with an open loop system using a stepper motor. I want to run some tests to measure how far and how consistently the motor can move the stage. The way my software works is that I give the motor a position (number of steps), then it runs until it reaches that position.
The motor homes itself, and then I want to implement an event structure so that I can give different commands without having to rerun the program each time. The three cases I would like to implement are:
1) Giving the motor a new position to run to
2) Telling the motor to home itself again
3) Stopping the program at any time
I have watched tutorials on the event structure, and can't for the life of me figure out why it won't work. The motor runs, homes itself, enters the while loop, and just stays there. When I change the values, nothing happens. Can anyone help me figure this out?
Solved! Go to Solution.
08-13-2014 04:07 PM
Is highlight execution on the whole time? Turn it on, then run the VI. I'm saying this because it is possible it never finishes the Home subVI and never enters the while loop. If it does keep highlight execution on and change the value of the Position control, see what happens.
What you are describing just can't be happening. The event structure works as you expect. When the Position value changes then the case is entered. If it is in a case and you change the value again, depending on the settings it will either pile up events like a queue, or will not allow more UI events to be queued up.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
16 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
08-13-2014 05:03 PM
You need to show us your code (incl. subVIs). We cannot debug pictures.
08-14-2014 07:41 AM
Thank you for the replies.
I have kept the highlight execution on the whole time, and it shows that home completes and the while loop is entered. When I change the position, nothing happens; the event structure is never entered, for any of the cases I try. I am as baffled as you are.
I've included my code, and all the relevant subVIs should be there. The piece of code I am having trouble with is testDistances.vi.
altenbach:
This wouldn't have to do with the fact that I'm running my software on a myRIO, and not my PC, would it?
Thanks again,
E
08-14-2014 07:49 AM
@Riche29 wrote:
Thank you for the replies.
This wouldn't have to do with the fact that I'm running my software on a myRIO, and not my PC, would it?
Yes, yes it would.
The myRIO is an embedded device and has no video output, and therefore doesn't have a concept of events based on user input. I've never used a myRIO but I assumed it wouldn't even allow you to put the code on the myRIO if an event structure was being used, but I guess you can have user events so maybe that is why no error was thrown.
The code runs as expect on Windows where I tested it. I had to disable parts of the Home, and Run routine because I don't have the myDAQ or myRIO software installed but the event structure worked as expected.
Also for the Position Value change the control should be in the event structure, not just in the while loop. If it isn't then you'll be reading the last value not the new one. You were probably just making changes to test things because in the images you posted it was in the event structure.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
16 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
08-14-2014 07:55 AM
Hooovahh wrote:
The myRIO is an embedded device and has no video output, and therefore doesn't have a concept of events based on user input. I've never used a myRIO but I assumed it wouldn't even allow you to put the code on the myRIO if an event structure was being used, but I guess you can have user events so maybe that is why no error was thrown.
Actually LabVIEW RT will allow you to use the Event Structure. But since there is no actual front panel, events coming from the UI just won't happen. I'll have to test it, but I'm pretty sure User Events will work.
08-14-2014 08:02 AM
Okay, this is good to know. So is it the case that I can't input new values into the front panel during run time and have them interact with the program? It only uses the values I give it before I press run?
Emma
08-14-2014 08:14 AM
If you are running through the LabVIEW IDE, then you can still change the values. It just won't generate the event.
08-14-2014 08:52 AM
Does this mean I would need to nix the event structure and poll for new data?
08-14-2014 09:01 AM
Yep