08-20-2020 02:22 AM
Hey all,
I am trying to continuously sample a COM port, while also sending commands to a group of motors in labview. Currently, I am using the 'Timeout' case event to do the sampling of the COM port. When I have the steps for the motors called out as push buttons. I must click the push buttons to have the motors work in a routine. I ultimately would like to have the sequence of the motors choreographed and to do this I used a stacked sequence structure inside a case event structure. The problem is after executing the stacked sequence the time out event never occurs. Is there a way to get the sequence functionality as well as the regular sampling that I would get from a short timeout period?
08-20-2020 02:31 AM - edited 08-20-2020 02:38 AM
Hi Damian,
@damianhoward wrote:
I ultimately would like to have the sequence of the motors choreographed and to do this I used a stacked sequence structure inside a case event structure. The problem is after executing the stacked sequence the time out event never occurs. Is there a way to get the sequence functionality as well as the regular sampling that I would get from a short timeout period?
Sure there is a way: Get rid of the sequence structure! (All of them!)
Another problem is to call "long-running sequences" inside event cases: events should get handled "as fast as possible" to not block the loop from handling other events (like your timeout event)!
Implement a state machine: no need for stacked sequences of 10 frames within an event case. No need for timeout cases, which depend on "no other events occuring"…
I recommend also to separate the two devices into their own loops to handle them independently: so the USB device does not interfere with your COM port device.
08-20-2020 09:33 AM
@GerdW
Thank you for the quick response. Being that I am new to state machines. Could you provide a generic demo of what this would look like for my situation? Or could you provide a link to a topic or video where I could educate myself? So far the youtube search hasn't helped that much
08-20-2020 10:13 AM
08-20-2020 11:08 AM
@GerdW
Previously you wrote"
Sure there is a way: Get rid of the sequence structure! (All of them!)
Another problem is to call "long-running sequences" inside event cases: events should get handled "as fast as possible" to not block the loop from handling other events (like your timeout event)!
Implement a state machine: no need for stacked sequences of 10 frames within an event case. No need for timeout cases, which depend on "no other events occuring"…
I recommend also to separate the two devices into their own loops to handle them independently: so the USB device does not interfere with your COM port device."
Sorry,I don't know the proper way to include previous comments. When you say separate the two devices into their own loops. Do you mean two different state machines? and how would they be placed? left to right? or vertically stacked on one another? Also, getting back to my problem. The process that involves the USB device is used to load control a linear actuator. Is it possible to toggle this load control process on and off while the other motors perform their flat sequence?
For example, Ideally I'd like to control a stage and instruct it to go to 6 positions but I'd only like the linear actuator to apply a load between positions 2 & 3 and positions 5&6. I understand how I could do this with push buttons , but im still not understanding how to do it from the push of just one button from the front panel. Would I need a boolean switch in the various states them selves that turn on and off the external(load control) process?
08-20-2020 12:26 PM
in the tool bar. And, yes, I spent a few weeks looking for it when the quote button disappeared from the bottom by the other buttons.
08-20-2020
10:17 PM
- last edited on
05-13-2025
01:04 PM
by
Content Cleaner
Hi damianhoward,
Based on my understanding towards your described requirements, I created and attached the simple state machine VI below for you so that you might able to understand the rough idea on what a state machine could work on your motor routine (work in sequence).
Here's the link I referred when I'm about to create a state machine:
Hope it help !
08-21-2020 07:08 AM
Hello,
I think these state machines (SM) described in "Simple State Machine Architecture in NI LabVIEW" mentioned above are a bit outdated, especially when the SM has to react to user input. The same functionality is achieved with an event structure, using dynamic events plus reacting to GUI interaction. And it remains quite simple, no need to use some complicated framework.
I have made an example to illustrate the benefits.
08-21-2020 08:19 AM
And to show a way to handle a Producer- Consumer - Pattern, I extended the example to handle 2 independend producer:
08-21-2020 06:36 PM
@billko wrote:
in the tool bar. And, yes, I spent a few weeks looking for it when the quote button disappeared from the bottom by the other buttons.
Thank you Bill! I was feeling real foolish there for a second