09-26-2017 03:58 PM
I had previously written a code to accelerate, run at constant frequency, and decelerate a stepper motor using LabVIEW and NI my DAQ. The code worked and ran as expected. I am trying to improve this code by adding a "sleep" function - where the motor is still on after it finishes running for a certain amount of time, then if not action happens for that amount of time, it enters a "Sleep" mode where no current runs through it. This "sleep" mode is a digital output. I would also like this motor, at any point, to be able to run again when told, restart the timer before "sleep" if told, or stop altogether. To do this, I created a state machine dependent on those actions. However, I am noticing that the motor returns to the run state even when the run command isn't changed, among other unexpected results. I have attached my code, and would appreciate suggestions on how to fix these problems or how to streamline it and simplify it in general.
Thanks in advance.
09-26-2017 04:25 PM
Looking at an example, I see that "If a user interface event occurs while a state other than "Wait for Event" is running, the event will be queued and its event frame will run the next time this Event Structure executes." This explains why my code was running again even though I wasn't telling it to in that event structure - it had that value changed queued from when the user pressed run initially. I have fixed my code so "Run" no longer needs to be pressed to start the motor. However, on that note, is there a way for the code to not queue the commands when they happen earlier in the code?
09-27-2017 01:49 AM
Hope All user may not use the latest LabVIEW Version, Its better to Save your LabVIEW Files to Previous Version when sharing ( Its easy for me to view your code if its saved in LV 2015)