08-09-2026 01:21 AM
Hello,
I have set up a HAL for my power supplies and wrapped that into a clone-able DQMH module. Works pretty good, however I have two pain points with my helper loop. I use the helper loop to continuously monitor the power supply output and OVP/OCP. I personally don't like my current solutions for them so want to ask the community for guidance here, so I can continue to code better with best practices going forward.
1. Starting the helper loop.
2. Passing updates to the class from MHL to Helper Loop.
Solved! Go to Solution.
08-09-2026 01:49 AM
The thing that jumps out at me is that you are sharing state data between loops with local variables. That is a method very prone to problems, as you are finding. It can also become a performance issue, as every local variable causes a data copy. Consider two other options:
1) Don't have the helper loop actually read your power supply. Have it send "Time to read power supply" events to your main loop. Having the helper just be a timing source means there is no reason to share your HAL Object between loops.
2) Use a DVR to hold the Object and share access between loops.
08-09-2026 02:35 AM - edited 08-09-2026 03:18 AM
Thank you for the advice. I like solution 1 and I will try that out now as I still have a constant bug I am seeing. In an application I set up I have a loop that updates the voltage level by a certain increment every 2 seconds and eventually the module times out possibly due to the helper loop running trying to poll the power supply measurements every second.
I think this solution should solve my issue. Seems pretty straightforward will report in a day or 2. It's my bed time and have a long day tomorrow away from my desk, need to touch grass to clear the mind.😀
Update: Was pretty straight forward to implement ended up doing it before going to bed. I have tested it twice so far and it seems to be working now! Before my program would crash around the second or third test, but when I disabled the helper loop it worked. Now I get to go to bed in a good mood and a working helper loop in my application. Thank you so much for the suggestions!
Another Update: Was able to get through my whole range without a problem. That solution is solid! Before I was only testing a small sample of the range. Now to figure out how to start and stop the helper loop is there a better way?
08-11-2026 12:04 AM - edited 08-11-2026 12:06 AM
Found the answer to pain point one if anyone else in the future needs help with this. I did end up leaving my public events to start and stop the helper loops, but replaced the flags and property nodes inside the MHL with private events that are tied to the helper loops. Below is a link to why and how I figured out to do this.
https://documentation.dqmh.org/dqmh/7.1/PublicandPrivateRequests.html