LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Action driven state machine for stepper motor

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.

0 Kudos
Message 1 of 3
(2,719 Views)

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?

0 Kudos
Message 2 of 3
(2,708 Views)

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 2015Smiley Happy)

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 3 of 3
(2,655 Views)