01-12-2016 07:44 AM
Hello,
I'm writing a VI that is a state machine that is running at 30ms timing but while the state machine is in the idle loop I need to send a keep alive toggle (Boolean) to a PLC every 500ms. With the requirements of the main state machine to run at 30ms how can I setup the other time or event inside the while loop. I used the remainder / quotient function with the iteration but cant seem to find the solution there.
So the requirements:
Anyone have a suggestion?
Solved! Go to Solution.
01-12-2016 08:36 AM
Hello Bill,
Just implement a timer counter which will count the time, and when it reaches 500ms, it will reset to start again the counting, and will toggle the boolean (like time elapse). Just note that it may not be exactly 500ms. Is the accuracy of the 500ms period is important?
Thanks,
Arev
CTO | RAFA Solutions
01-12-2016 08:44 AM
Hello Bill_lewis,
As 500 isn't a multiple of 30, it seems difficult to perform it in one while loop.
You would use another loop in parallel or change one of the two timing in order to toggle your Boolean at a multiple of the while loop timing.
Regards.
01-12-2016 09:35 AM
I would go with the the parallel loop and send the data every time your timer has elapsed. You will probably want to use a time of 350-400ms, if you are going to get an error after 500ms.
If you are sending it to the device that your state machine also accesses, then it may slow it down a teeny bit if both loops are trying to send data to the same device, but I don't see any way around that.
01-12-2016 03:01 PM
Look at the Elapsed Timer express VI. It is a simple VI that will tell you if some amount of time has elapsed from the last time it was reset and that time was reached. It has an output that is true once that time has been reached so I'd put that into a case structure and when 500ms has gone by, send the keep alive.
Now as others have said this won't happen ever 500.00000000ms for several reasons, but most hardware doesn't need a keep alive to be that precise. I'd try it at 500ms, then try it at 600, then 800, until it stops working and based on that I would decide what value to use. If it some times has an issue at 500ms (because it will actually be at least 500 and might be too much) then I'd set it to 400ms. Again generally hardware doesn't mind if it sees a keep alive too often.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord