Jump to content

10mS Timer Counter problem


Recommended Posts

I have a simple project (see attachment).

I do not understand why variable "int var 1" is always equal to 1.

Please explain to me.

P.S. Win7 64bit, Vision ver 9.3.1.build 0, V570-57-T20 (Hardvare rev: E, OS ver: 3.4 (16)) with lasts updates

P.S.2: а по русски тут говорят?

Link to comment
Share on other sites

The first condition in your rung is DW1 = 0. If this is true, than you add 100 to it. If in this moment MI1 = 0, you will increase it and it will be equal to 1.

The next scan DW1 will not be equal to 0 anymore (it will be equal to 100!) and the condition ot increase MI1 will be false.

About Russian - you can send me mail to support@unitronics.com in Russian, but the answer anyway will be in English.

Link to comment
Share on other sites

This example finished, more isn't present other program items.

I think that the variable "int var 1" should increase on 1 every second. But it does not happen. Why?

If to change procedure RUN (net 1) so that the condition (MI1 > 0) was processed parallely with (DW1 = SDW 43 + 100) all works.

I can't load more pictures (or projects) on a forum to show it.

Link to comment
Share on other sites

Andrey,

It does not work because you changed DW 1, and logic say that if you want to compare MI 1 to Zero if DW 1 is Zero - it is not Zero already.

Attached is other example which works in accordance to your logic rules.

I agree that the series connection isn't working because DW1 gets modified while the network is being processed.

I completely DISAGREE that it should be evaluating the ladder like this.

Each instruction in a rung should only be executed ONCE.

This means that once the comparator is evaluated, it should retain the state of that decision until the rung has been completely finished executing.

What is really happening is the rung is going back and re-evaluating the comparator for subsequent conditions.

Looking at the STL generated for the rung, you can see that Visilogic is not properly translating the ladder as written.

It is clearly evaluating the first comparator instruction TWICE.

It should not be.

This is not in line with any other translator that I have ever seen. It is completely unintutitive, and breaks from the "left to right" execution convention that everyone expects.

Link to comment
Share on other sites

AlexUT

I think that for procedure "run" net 1 (from ex1.jpg, post #8) the equivalent C code is:

if (DW1 == 0)

{

DW1 = 100 + SDW43;

if (MI1 > 0)

{

MI1 ++;

}

}

You say that the equivalent C code is

if (DW1 == 0)

{

DW1 = 100 + SDW43;

}

if (DW1 == 0)

{

if (MI1 > 0)

{

MI1 ++;

}

}

But this code is equivalent to two nets.

I am in confusion...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
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...