LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Programming an ON-OFF relay

I created a theoretical transfer function 5/(s³+7s³+11s+5) and want to control it using an on-off relay which sends out 15V when on and 0V when off. When I do a Simulink simulation with the hysteresis set to 0 and input set to 6V, I get the result as seen in "simulink.jpg"

As LabVIEW has no build in on-off relay, I had to program it myself. After doing that I tested the system with a very simple application and the results were competely different than in Simulink. The number of oscilation in the same time-interval is different and the ampitude of the signal in the LabVIEW program varies while it does not in Simulink. The results of my program can be seen in "labview.jpg"

I include the source code of the simple test program "onofftest.vi" and the source code of my self-made on-off relay "onoff.vi" bundled in the library "onofftest.llb"


When I debug onoff.vi, I get the values I expect: it only outputs 0V and 15V. I do not know what I have done wrong and I hope there is a more experienced devellopper who can help me out.

Thanks in advance!
Cedric.
Download All
0 Kudos
Message 1 of 5
(3,424 Views)
I tested my program again and found that the problem is a timing issue. When I change the loop delay to 10ms and the dt of H(s) to 10ms (instead of 100ms), the results are very close to those of Simulink. The problem is that these values are impossible to work with on a PIII 900MHz as everything goes in slow motion.

Are there solutions to improve speed or a more effective way to make my program behave correctly without having to decrease the loop time?

Thanks in advance!
0 Kudos
Message 2 of 5
(3,363 Views)

Sorry, I can't look at the LV code from my network PC so I can only offer some generic comments / guesses.

Assumption 1: Simulink graph is based purely on a theoretical simulation model allowing an arbitrarily small timeslice for integration, not on an actual hardware implementation.  LabVIEW graph is based on an actual hardware implementation, generating and monitoring real-world electrons.

General comment: you can't rely on a real-world control algorithm with a fairly coarse timeslice running non-deterministically under Windows to perfectly match a theoretical model.  Sometimes you can get a really good match almost all the time, but ultimately there are limits.

Offhand, I would guess there are some ways to increase your typical LabVIEW loop rate *and* keep it pretty consistent without sending everything into "slow motion."  I wouldn't normally consider a 10 msec loop time to be very fast for bang-bang (ON/OFF) control.  I'll try to look at the code when I get a chance.  A first wild guess is that you might be reconfiguring your DAQ tasks on every loop iteration?   If so, that isn't necessary and is definitely a bad idea for a control loop. 

Of course, this is just guessing until I see the code so I'll shut up now...

-Kevin P.

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 3 of 5
(3,348 Views)
Thanks for your answer!

My application is meant to be purely theoretical and there is no Data Aquisition involved. It just consist of an ON-OFF relay and a 3rd order Transfer-Function. I want to use it as a didactic simulation without the need of real world components.
0 Kudos
Message 4 of 5
(3,337 Views)
A member of the LAVA forum has been able to solve my question, thank you for your help! The solution can be seen here:
http://forums.lavag.org/Programming-an-ON-OFF-relay-t4852.html

A screenshot of the solution can be found in "testonoff.gif"

The system has to run in "real-time" as it is meant to be a didactic simulation. The problem was that I coupled my precision (dt of H(s)) with my looptime! When I increased my precision, I also decreased my looptime so everything had to run fast. In this solution, only the relay has to run fast while the drawing can run at the standard 100ms rate.

Now I can view the system in real-time with a CPU load of 50%

Message Edited by CedricVH on 11-16-2006 10:22 AM

0 Kudos
Message 5 of 5
(3,333 Views)