Jump to content
Sign in to follow this  
vectrex

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

Share this post


Link to post
Share on other sites

the easy way is

|---[sB1]------(R mb4) SB1 = system bit 1 = ALWAYS 1

|

|---[mb1]--|--[mb3]------(S mb4)

|---[mb2]--|

first net : reset coil MB4

next net : mb1 or mb2 and mb3 = set mb4

kind regards, pascal

Share this post


Link to post
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 ?????????????????

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites

hello and HELP ...

But what when MB1 or 2 or 3 isnt 1 anymore ... MB4 doesnt get Reset ...

i need

IF MB1 = 1 , MB2 = 1, MB 3 = 1 THEN MB4 = 1

ELSE MB4 = 0

so if e.g. MB1 turns from 1 to 0 MB4 needs to be reset to 0 !!!

how can i achive thise funktion ???

please help ;)

Share this post


Link to post
Share on other sites

HELLO ! ... yes DIRECT COIL does the TRICK ... thank you for the help ;)

about power up options ... when i set a MB to Powerup option RESET ... isnt it supposed to RESET = 0 whenever i power off/on the PLC ????

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

hello again !

why please why is the ladder net width so limited ???

i mean the graphical editor ... why cant the vertical slider be expanded to the right ??? (to create longer functions IN ONE ROW !)

thank you again !

Share this post


Link to post
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!

Share this post


Link to post
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 ?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Right, Damian!

Just idea - you can make DT with Address of... and then a subroutine. This way with one DT and few nets in one sub you will perfomrm all requested logic.

Share this post


Link to post
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

Share this post


Link to post
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.

Sign in to follow this  

×
×
  • Create New...