linnemann Posted February 1 Report Share Posted February 1 Hello I'm building a reusable state machine using an UDFB. I want to detect a rising edge when the statemachine should run to transition from the idle state to the next state. I create the input tags but in the UDFB i cannot use the tag when using Positive and Negative transition contact. I can select it if I use the Direct or Inverted Contact. What is the reason for this and how do you propose i do it otherwise? Attached is a very minimal example. StateMachine.ulpr Quote Link to comment Share on other sites More sharing options...
ORSO2001 Posted February 1 Report Share Posted February 1 hi linnemann I think that this happens because also the "function in" variables are consider as "local" so are inizialized at every loop of the program...so the -|P|- will be as a normal -| |- . if you want/need just a "one shot" command you have to reset the used variable at the end of what you need to do. consider that a single variable is passed by value...so you have also use a "function out" to reset it...otherwise array and struct are passed as reference...so what you do with the relative "function in" variable will have a direct effect to the global variables. hope that is clear but mostly that is right. Quote Link to comment Share on other sites More sharing options...
linnemann Posted February 1 Author Report Share Posted February 1 Hi This is also what support said, but if I need to use global variables or structs then the udfb is not really reusable. Any example of how to make a reusable udfb with a state machine and a way to oneshot it from function in tags? Quote Link to comment Share on other sites More sharing options...
ORSO2001 Posted February 2 Report Share Posted February 2 hi at the moment i can't write something new...maybe later...for the moment take a look at the following discussion that I have had in thi sforum: LINK Quote Link to comment Share on other sites More sharing options...
linnemann Posted February 3 Author Report Share Posted February 3 Thank you for the link. It does not solve the rising edge ,but it has workarounds. I've added the rising edge in a struct to be a feature request as there should be no limitations as it is passed as reference when input is a Struct, Array or buffer. Regards Quote Link to comment Share on other sites More sharing options...
linnemann Posted February 6 Author Report Share Posted February 6 I have attached a sample project that shows how this can be implemented until UT gets this in as a basic feature. Two input structs are used, one for keeping track og the rising/falling bits and one for the statemachine. StateMachine.ulpr Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.