Reputation: 146
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?
Upvotes: 3
Views: 3963
Reputation: 87
Most 61131 implementations will have a "SEL" block that should do this fairly nicely...
__SEL__
zerospeed |G Q|wCount
| |
wrunning |IN0 |
| |
wstandstill|IN1 |
|_______|
Upvotes: 1
Reputation: 162
Why can't you use the ton block in ST? The rest of your code looks pretty good.
TON_0(enable:=TRUE, PT:=T#1s);
IF TON_0.Q THEN //if timer done
//do stuff
TON_0(enable:=FALSE); //reset timer
END_IF
Upvotes: 0
Reputation: 2442
depending on how you want to initialize your variables you can do this
Otherwise there is not better way to do it then you are right now.
Upvotes: 1