11-29-2018 06:53 AM - edited 11-29-2018 06:55 AM
Hello everyone,
according to Jörg's suggestion (I have an Ö on my keyboard), I implemented helper loops for automating recuring events such as DAQ.
Two issues I have been battling and am looking for input regarding those (see screenshot as well):
Any help and comments greatly appreciated !
Cheers
Niels Göran
DQMH with Helper Loop
Solved! Go to Solution.
11-29-2018 04:19 PM
11-29-2018 04:41 PM
Fabiola's suggestion offers much more robust timing.
The reusable helper loop is much better for things that are repetitive but don't have very strict timing requirements.
11-29-2018 04:43 PM
Re (1), use a calculated, rather than a fixed, timeout. Take the remainder of the current ms timer MOD your time interval and use that. So if your loop requires 213 ms, the calculated timeout will be 787.
11-29-2018 04:44 PM
That will also work.
11-29-2018 05:08 PM - edited 11-29-2018 05:08 PM
@drjdpowell wrote:
Re (1), use a calculated, rather than a fixed, timeout. Take the remainder of the current ms timer MOD your time interval and use that. So if your loop requires 213 ms, the calculated timeout will be 787.
+1 for James' suggestion. As the timeout value lives on the shift register, this is easy to accomplish. In my blog post about helper loops I wrote:
The timeout event of an event structure can be used to repetitively execute code. Timings can be controlled by setting the timeout value of the event structure, or by implementing your own timing code within the timeout case of the event structure.
There is also a small mention of the caveats when using the timeout case for critical code.
PS: Thanks for the "ö", Niels 😉
DSH Pragmatic Software Development Workshops (Fab, Steve, Brian and me)
Release Automation Tools for LabVIEW (CI/CD integration with LabVIEW)
HSE Discord Server (Discuss our free and commercial tools and services)
DQMH® (Developer Experience that makes you smile )
11-29-2018 07:10 PM
@joerg.hampel wrote:
There is also a small mention of the caveats when using the timeout case for critical code.
In case people don't want to go read the blogpost, the caveat says
"It is important to state that the timeout event is only triggered if no other events happen during the timespan that was wired to the timeout terminal of the event structure. That’s why it’s called the timeout event after all. So if you’re implementing your event structure to handle all sorts of critical events, your event structure might never actually timeout, and the code inside the timeout event case will never execute.
In our case, the timeout event case IS the critical code, and as we only enable/disable the timeout case and register for the Stop Module event, we should be good.
I also brought this up on the NI forums, please read Fabiola’s and Darren’s comments."
All great suggestions. Niels, keep us posted on your progress.
Regards,
Fab
11-29-2018 07:13 PM
Oh and this option has worked very well for us when communicating with serial devices
@ngblume wrote:... Fabiola's serial driver example here: https://delacor.com/tips-and-tricks-for-a-successful-dqmh-based-project/, Tip 5: Add Classes to DQMH Modules) might solve this problem...
Regards,
Fab
11-30-2018 01:01 AM
Hey everyone,
thank you for your replies !!
I really like Christopher's suggestions of feeding it back to the MHL (especially since the workload there is small). Furthermore, I make reuse of the same case in MHL that might also be triggered from the outside (i.e. if timed helper loop is inactive).
Extending Tip 5 of Fabiola (separate abstraction layer for serial devices) into a separate module also sounds quite reusable, since it can be kept "dumb" and unaware of the commands and handling of replies and only perform VISA write and read.
@Christopher: For the second suggestion (Tip 4 of Fabiola), I'm not sure, if I understand fully the advantages of adding a State Machine, given that I don't have an order of steps to perform, but rather just one repetitive and some event-driven ones. Wouldn't the 1s timing of the while loop "overwrite" the 10 ms time-out of the event structure (resulting in 1 s timing)?
@James: I never thought about using the run duration to calculation the remaining wait period. Simple fix !
Thanks for all the ideas!
Will keep you posted, what implementation works best for me in this case!
Cheers
Niels Göran
12-02-2018 06:03 PM
@Christopher: For the second suggestion (Tip 4 of Fabiola), I'm not sure, if I understand fully the advantages of adding a State Machine, given that I don't have an order of steps to perform, but rather just one repetitive and some event-driven ones. Wouldn't the 1s timing of the while loop "overwrite" the 10 ms time-out of the event structure (resulting in 1 s timing)?
Actually, you're right - you don't need the state enum passing around if there is only one state so this simplifies it a little! The 10ms is necessary so that the event structure will actually timeout, and you can perform your repetitive action. You could make this 1ms, or 100ms...it probably wouldn't matter because the loop structure with 1s timing will keep things in check. The event structure is there to also handle the Stop Module event, or any other events such as Start Acquiring or Stop Acquiring if you were to need those.