Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PLC: If Then Else inside Function Block

Tags:

plc

I'm trying to learn by programming for a Bosch/Rexroth MLC. I wrote this sequence, but I'm not sure if there's a better way to do things.

Pseudo-code would look something like this:

wRunningCount=300
wStandstillCount=150
wCount
zeroSpeed
IF zeroSpeed THEN
    wCount=wStandstillCount
ELSE
    wCount=wRunningCount
FI

But I want to move this functionality into function blocks. (Already have a TON that will receive the wCount)

Right now I have:

                  __MOVE____
       zeroSpeed-|EN    ENO|-
wStandStillCount-|_________|-wCount


                  __MOVE___
      zeroSpeed-o|EN    ENO|-
   wRunningCount-|_________|-wCount

Is there some better way to do this?

like image 211
Niclas Avatar asked Apr 20 '26 01:04

Niclas


2 Answers

depending on how you want to initialize your variables you can do this

enter image description here

Otherwise there is not better way to do it then you are right now.

like image 90
mrsargent Avatar answered Apr 21 '26 14:04

mrsargent


Most 61131 implementations will have a "SEL" block that should do this fairly nicely...

            __SEL__
zerospeed  |G     Q|wCount
           |       |
wrunning   |IN0    |
           |       |
wstandstill|IN1    |
           |_______|
like image 23
Squanchy Avatar answered Apr 21 '26 14:04

Squanchy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!