06-27-2017 05:50 AM - edited 06-27-2017 06:17 AM
Hello everyone,
as part of the build up of an solarthermal system I need to control devices and take measurments. I already programmed the VI for taking the measurments and saving the data. But my problem that I don't know how to combine the control and measure part.
I thought about to use the classical "Producer/ Consumer-Loop" for taking the measurments and saving them. That works fine.
But, in addition to that, I need to control valves and a Pumpe by using the measured values. So shoud I run a second Producer/Consumer Loop in parallel or is there a other and better possibility to handel that?
I know, it's a realy basic question, but unfortunately this topic was not included in the NI Core 1 or 2 Cours. So I would be glade, if someone could give me a hint 🙂
Solved! Go to Solution.
06-27-2017 06:24 AM
It depends ...
Are measurements fast in comparison to the regulation speed? How fast must the system react?
Depending on such factors you could control the system in a timeout on the consumer, or have a small loop queue up control signals at a steady rate (like 20Hz) (or in the producer loop), or have a free running control loop that simply uses the latest read data.
I often find the regulator need the measured values and need to react to the latest data. It's often easy enough to just queue up a Regulate after the measure, and possibly a timeout on the consumer.
Do that make sense?
/Y
06-27-2017 06:26 AM
What update rate do you need? Is there anything safety critical (pumps typically fall into that category)?
Control systems typically do not use a Producer/Consumer setup since you need to react to the latest data, not all of the data. Depending on a few factors, I would usually put the measurement and the control code in the same loop. Use shift registers to keep any system state needed for the control.
06-27-2017 07:20 AM
So here are a little bit more information about the requirements:
The measurement rate is about 3 s an I have about 30 voltage Signals to measure by using a multiplexing card.
With two of the measured values I have to switch a pump on or off. The other values should be displayed in diagramms on the Front Panel and saved to a file.
For the change of the operating state of the pumpe, I'm just using tow of the Temperature values. If the build temperature difference is greater or equal than 10 Kelvin, the pumpe should switch on. If the temperature difference is less than 2 Kelvin, the Pumpe should switch off (VI already existing). So we are tallking about a very slow process and a maximum of the temperatur changings about 1 Kelvin per minute. In addition there is a over temperature protection using the same type of hysteresis.
The on/off switching is done by using a relay card.
So yeas, the measurement is fast in comparison to the regulation speed.
The reaction time should be in the worst case one second after taking the mesaurement values.
06-27-2017 07:34 AM
So you recommand to put the measurement and the control in on loop, and the process of saving data in a nother loop by using a Que to conect both loops? Did I get this right so fare?
06-27-2017 07:35 AM
If it's that slow (basically anything <100Hz) it'd handle it in the consumer loop in the timeout case, queue up a control command after each sample-command. If for some reason the rate drifts due to slow states you can have an external loop queue up sample+control-commands.
/Y
06-27-2017 08:36 AM
@Laudst wrote:
So you recommend to put the measurement and the control in one loop, and the process of saving data in another loop by using a Queue to connect both loops?
That is exactly what I would do.
06-27-2017 10:29 AM
Thank a lot for your help!