LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

relay outputs not switching together

Solved!
Go to solution

Hi there,

 

I'm currently testing a simplified PID system before I run the whole process. The system consists of a heater pad controlled by a relay and an RTD which feeds back the temperature. All the hardware works nicely. I have a simple subVi which depending on the PID block output turns on the relay for a set amount of time every 5 seconds or so. I've tuned the system with a single relay and rtd and it worked well. Now I tried to put both relays into the system and they only seem to run alternately. For example if they turn on once every 5 seconds, now the first one turns on, then the seconds one turns on, effectively doubling the time between them turning on. I know that they can turn on at the same time as I've tested that and even switched them back and forth to make sure that's not the issue. It looks like it's something in the code I've put together to switch them. If anyone's got any ideas, that would be awesome.

 

Attached are the simplified PID loop and the subVI turning the relays on.

Download All
0 Kudos
Message 1 of 5
(2,209 Views)

Your subVI is not reentrant.

 

So what happens is one instance of it on your main VI has to wait until the other instance of it stops executing.  The subVI looks like once it starts, it could take a while to finish because it has an inner while loop that runs until the Time Elapsed function has passed out a True value.

 

You might want to make that reentrant.  You may want to revise your architecture in a way (possibly state machine?) that doesn't bury the operation in a subVI, but immediately returns to your main VI so that each instance of the subVI has a chance to run and execute.  Do you even need two separate while loops for that?  It seems like you could combine all 4 of your loops into one.

0 Kudos
Message 2 of 5
(2,197 Views)

I'm always open to ideas as to how to simplify my code. I'm not that experienced with Labview so I think I'm quite often doing it the hard way. If you would be kind enough to explain how I might combine all these loops into one that would be awesome. As for the state machine, my machine is a little more complex altogether and I'd like to keep the major architecture the same at this point.

0 Kudos
Message 3 of 5
(2,192 Views)
Solution
Accepted by topic author Chris Johnson

Start with making the SubVI re-entrant and see if that helps.  (File >> VI Properties >> Execution.)

Message 4 of 5
(2,180 Views)

That seems to have taken care of it.

 

Thanks.

0 Kudos
Message 5 of 5
(2,165 Views)