Developer Portal Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 
    SOLVED

    WaitIo, WaitBool functions

    WaitIo, WaitBool functions

    tommy3000
    Established Member

    Hello everybody

    I have a question regarding the WaitBool and WaitIo functions.

    The behaviour of this function is, after reaching the condition of the function and returning OK, in the next cycle the return value switch back to RUNNING. Using more than one function calls in one step causes the problem, that reaching on wait function condition, the other is still running, so the step stays active, the wait function does not keep the OK state.

    So I'm not able to set every function there on _tmpRetVal and collecting all tmpRetVal at the end  before returning OK for the next step.

    7 REPLIES 7

    SteffenR-
    Community Moderator
    Community Moderator

    @MarvinW's code only works if DebounceTime is T#0S. Otherwise WaitIo/WaitBool returns "OK" for only once cycle and restarts the debounce timer and probably both sensors will not reach the setpoint state at the exactly same time. That means WaitIo/WaitBool in combination with a debounce time can only be used with a direct assignment _retVal:=WaitIo(...) or _retVal:=WaitBool(). This is the "problem" of the original post by tommy3000.

    An alternative solution would be creating a BinIo flag with WaitIo:

    _retVal := WaitIo(CallIdx       := 1,
                      iBinIo        := BinIo,
                      IoIdx         := BinIo._120MB60xA, // BinIo flag with _120MB60xA := _120MB601A AND _120MB602A
                      SetpointState := TRUE,
                      DebounceTime  := T#100MS,
                      Timeout       := T#5S,
                      AutoClear     := TRUE/FALSE,
                      EventClass    := OpconEventClass.SOFTERROR);

    MarvinW
    Long-established Member

    @SteffenR- are you sure it wouldn't work with a debounce time? I specifically designed it so it can be used with a debounce time. Please have a closer look again and confirm or deny.

    The variables _signal1Ok and _signal2Ok are variables of the chain that have to be reset before the respective step. Then I check the return value of WaitIo for OK and then set the _signalXOk to TRUE, which will happen after the IO signal passed the debounce time. If the return value of WaitIo is anything other than OK then it won't affect _signalXOk. The ELSIF then checks if the IO signal does not have the desired state (I assumed it should be TRUE) and then it resets the _signalXOk. This serves as a reset in case the IO signal falls off after the debounce time was passed successfully.

    Only if both _signal1Ok and _signal2Ok are TRUE the step goes on. This requires that both signals have successfully passed the debounce time and that neither of them has reset before the other passed the debounce.

    SteffenR-
    Community Moderator
    Community Moderator

    You are right, your code example in the previous answers works because _signal1Ok and _signal2Ok are remembering the state if WaitIo has already returned OK one time.

    But you must be careful to reset these variables in all cases, for example in the previous step.

    Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist