Jump to content

Programming an ON-OFF relay


Cedric

Recommended Posts

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!

Link to comment

In your VI, the loop time is irrelevant; the reason that your LabVIEW results don't match your Simulink results is because the dt input to H(s) is too large. You are supplying the dt input to H(s) so you'll always get the same results regardless of how fast the loop runs. If your loop time matches your dt, then your code executes in "real time" - at the same rate as an equivalent physical system. However, you probably want to simulate faster than that (as Simulink does), so if you were to make your loop time 1ms, but leave your dt input at 10ms, you'd get your results 10 times as fast as real life.

A better approach, though, might be to put your processing into a for loop inside your while loop, as shown in this diagram:

post-3989-1163691735.gif?width=400

Link to comment

Your solution is just perfect!

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 with my looptime! When I increased my precision, I also decreased my looptime so everything had to run fast. In your 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%

Thank you very much for your help!

Greetings,

Cedric.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.