Jump to content

V350 IF/THEN / ELSE ?


Recommended Posts

Hello ! I am kinda new to programming the V350 and programming in general. I have following situation and cannot find a workaround ;(

i have 3 MBs indicating a status and i want to have another MB set if e.g. BIT1,2 is Set and BIT0 is UnSet ....

so IF MB1 + MB2 = 1 and MB3 = 0 THEN MB4 = Set

ELSE MB4 = Unset

how can i implement such a function ??

Thank you for your help in advance ...

best regards .. Thomas

Link to comment
Share on other sites

hello ! thanks for the reply but thats not exactly what i want to do i think

@pascal: your version allways resets MB4 each cyle and then sets it again so MB4 is allways changine ?! i need MB4 be allways stable on or off

@fantasia83: your version ... conditional sub routine ? call a subroutine ? so when MB4 is set it calls the subroutine and then resets MB4 ... also not what i want to do !?

i have 3 Bits ... if they are 1 i want to set Bit4= 1 ELSE Bit4 allways is 0

please help again ;) thanks !

and another question: when i set Power Options for MB ... e.g. to RESET ... on my V350 the MB only gets set to REST when doing two power off/on cycles .... how comes ?????????????????

Link to comment
Share on other sites

  • External Moderators

Hey!

So you want to set MB4 to 1 if MB1 and MB2 and MB3 are 1, otherwise MB4 always is 0?

<Net #1>

MB1 MB2 MB3 MB4

--| |--| |--| |--()

Very simple! ;) If one of the MB's is 0, then MB4 will become 0 automatically.

With the Power Up Options - the whole point of it is to RESET an MB when the PLC is restarted or Powered On/Off. If you are trying to keep, for example MB5 reset (0) all the time, just put this in a Net:

MB5

--(/)--

Hope that helps you!

Link to comment
Share on other sites

Hi Vectrex,

I want to start a step earlier - how the controller works?

When powered, it:

1. First check the status of inputs. Update hte memory, related to each input.

2. Execute the program - from left to right, from top to bottom. If it finds contact of an input, it checks the status of the memory, related to this input. If there is a digital output as result of a rung, it updates the relevatn to this output memory.

3. When finish executing the program, PLC updates the status of the outputs according to the relevant memory.

4. After finishing the update of the outputs, it starts a new scan.

Based on this information - having Normal contacts as conditions and normal coil as result, each time the controller will come to this rung in the program, it will check the status of condition contacts and acording to this status - true or false - will update the condition. This condition will remain unchanged until the next scan (in case there is only one coil in the program, which is highly recommended!!!).

The question you posted has very simple soluiton in Ladder language and Ash already gave it.

About Power Up value:

Think, at the beginning of your program, you write a rung, like N.O. contact of SB2 (active only the first scan after power up) = Set or Reset coil of the MB you want to give a Power Up value. As result this bit will have requested value. Then, in your program, you can change its state.

If I'll take your example - if you give to MB4 power up value Reset, at the beginning of the scan its value will be 0. Then, comming to the rung Ash shown to you, according to the values of MB1, 2 and 3 it will be updated with a new value.

I hope this makes sense to you.

Link to comment
Share on other sites

  • External Moderators

Hi Again.

You can use a Vector Fill (Under the Vector Menu).

A (Fill Value) = SB0

B (Fill Vector: Start Address) = MB1

C (Number of Operands to Fill) = 100

We use SB0 as the value of SB0 is always False (Reset).

This Utility will fill MB1 to MB100 with the value '0' - meaning they will all be Reset.

Remember if you just want to do this on startup, put a SB2 contact before it --|SB2|--

Link to comment
Share on other sites

  • 2 weeks later...

Hello ! I am kinda new to programming the V350 and programming in general. I have following situation and cannot find a workaround ;(

i have 3 MBs indicating a status and i want to have another MB set if e.g. BIT1,2 is Set and BIT0 is UnSet ....

so IF MB1 + MB2 = 1 and MB3 = 0 THEN MB4 = Set

ELSE MB4 = Unset

how can i implement such a function ??

Thank you for your help in advance ...

best regards .. Thomas

The ans at the first question:

--|MB1|--+--|/MB3|--(MB4)--

--|MB1|--+

(MB1 or MB2) and (not MB3) then MB4 =1

else

MB4 = 0

Link to comment
Share on other sites

  • 2 weeks later...

Definitelly NO! And, as I explained in my previous post, this is not the right way of writing programs and we will not "sponsor" it.

In other hand, VisiLogic has a lot of advanced tools to ease programming. Please describe better your needs. I'm pretty sure we can find some other solution.

Small tip - take a look at FB Events...

Link to comment
Share on other sites

In fact - it's too big!

We always recommend:

Write one rung per net!

Write simple, short nets!

Following these roles, you will understand why in fact the nets are too big!

Hi Emil,

I disagree with you on this one. I like short simple nets as well, but I often find myself constantly creating the dreaded "S-loop" to be able to be able to finish one simple train of logic.

If Writing one rung per network is good practice (as most of us probably agree), it would seem that Visilogic has too much vertical network area in proportion to the horizontal area.

Even with the smallest function blocks, I can only have three in series and still have enough room at the right to place a coil without having to make a loop.

Yet, Visilogic leaves room to create up to six parallel rungs in one network all tall enough to contain function blocks.

As a side note. Most software dynamically modify the wires for you as you build code. RSLogix as an example. Once your net gets too wide it automatically does the S-curve for you. This tends to be much more efficient to program from a "development time" standpoint. I feel like I waste a lot of time in Visilogic drawing wires as if I were using Autocad, instead of just entering logic. Maybe something R&D can chew on for the "next generation". In this day and age, if something that can be automated has to be performed manually, we're just wasting time and money.

Link to comment
Share on other sites

well i have the situation comparing about 100 thermocouples status judged by the temperature in status of wrong wired, wrong polarity .... so function gets big ...

so no way to expand to the right instead of using lines lines lines lines ?

Sounds like you should consider creating a loop and using indirect addressing. If you have to do virtually the same thing 100 times over than it is to your benefit to organize it such that you can just re-use the same block of code as if it were a function.

Link to comment
Share on other sites

yes i definitly have to look at indirect adressing ...

i started with programming (beside some basic with c64 ;) ) from zero when picking the v350 for our projects and just wanted to get it to work myself so i just did it with direct adressing .... which means much S line drawing in the nets ;) anyway the product is finished

this will take time time time :P:P:P

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