I am trying to use two Fluke 45's to indirectly measure the coil temperature of a solenoid valve. The idea is to place it in a thermal chamber and to then supply the highest voltage the solenoid would experience in order to see when the coil temperature stabilizes. The program I'm trying to make would be responsible for measuring the current and voltage to the solenoid in order to calculate the resistance and therefore the coil temperature. I then want to log this data to a file. I think I have the very basic functionality how I want it. I am running into one big issue though. In my DAQ loop, I am trying to configure the Fluke 45 to measure current and voltage. I would like this to only run on the initial run through of the loop. I have added a case structure but I'm not sure the best way to do a logic check so it only runs once. I can't use the loop count as the loop will be running before the logging actually occurs. What is a good way to get that initial configuration to run once? I also would appreciate any other feedback on this program. Thank you in advance.
Solved! Go to Solution.
Place the initialization of the Fluke outside the loop as then it will only execute once when the program starts. Or expand the QMH structure to the DAQ (and logging loop) and place it in an initialization case that only runs on startup.
For logging data, I always create another loop to log data (so the DAQ loop never gets behind while saving data). Place the data in a queue to the "logging loop" and then log the data when required. The DAQ loops always runs and can display data to the user at all times even if not logging. Something similar to this:
So I do have the Fluke meters intializing on startup. Then it configures them to measure resistance. Once the log button is pressed, I am trying to reconfigure them to then measure current and voltage.
The way I would do it would be to make the second loop run off a Queue that takes commands from the UI message handling loop (which receives commands from the event).
- Move the Start case of the UI loop to the DAQ loop (all DAQ should be in the DAQ loop and not in two separate loops).
- Once the "start" case has been run, re-initialize the fluke to the volts/current measurement
- When the user presses the log button send the message to the DAQ loop and collect data. You can log the data in this loop or create a log loop to handle the logging.
Wow, I never thought about sending queue messages from more than just the event loop. That's a great idea. Thank you so much for your help with this. It also really cleans things up and gets rid of the channel readers/writers. Thank you!
You can use as many Queues as you want/need. There are a couple things to be careful of if you have several queues controlling various loops:
- If you have multiple loops sending commands to one loop, you can get into race conditions depending on which command gets put into the queue first.
- The string command has to exactly match the case structure (Spaces, and upper/lower case). Helpful to use "to upper case" or "to lower case".
- Queues block by default so that is something to pay attention to when stopping/starting the program to make sure it works as intended.
- There is no way to tell which loop sent the message, which can be an issue when troubleshooting if you don't plan ahead.