Developer Portal Community

    We are moving! We are currently migrating our community to the new Bosch Connected Industry Online Portal. The community will be available latest in the new year again, until then it will be in read-only mode. Click here for more information.

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

    Create custom behaviour for BasMoveStandard Extension

    Create custom behaviour for BasMoveStandard Extension

    maj9bj
    Long-established Member

    In our aplication there is a valve for oil dispensing controlled by BasMoveStandard object. In manual mode I would like to avoid to leave valve opened after pressing of WrkPos button. Reason for this is the oil starts leaking out uncontrollably.

    My request is (see image):

    1. Valve (FakeOutput) opens with pressing of the WrkPos (Dispense oil) button. After timeout the valve closes again.
    2. If someone holds the WrkPos button, the valve is still open.
    3. Button BasPos closes the valve normally.

    maj9bj_1-1644486506531.png

    I solved this by overwriting manMoveWrkPos method of Extension but I am not sure if it is right way how to do that.

    Please let me know about your ideas how to solve this correctly.

    My code:

     

     

     

    METHOD ManMoveWrkPos : DINT
    VAR_INPUT
    END_VAR
    ManMoveWrkPos := RUNNING;
    
    // set timer
    _timer.PT := T#2S; {warning 'use station data here'}
    _timer();
    
    // Sequence for the manual function
    CASE _step OF
      
      0: // Start command
         _manStartTime := TIME(); 
         BinIo._FakeOutput := TRUE;
        _timer.IN := TRUE;
        _step := _step + 1;
        
      1: // Wait until finished
        ExecTimeMoveWrkPos := TIME() - _manStartTime;
        
        IF ( _timer.Q ) AND
           ( ExecMoveWrkPos = FALSE ) 
        THEN
          _timer.IN := FALSE;
          BinIo._FakeOutput := FALSE;
          _step          := 0;
          ManMoveWrkPos  := OK;
        END_IF
    END_CASE

     

     

     

    3 REPLIES 3

    SteffenR-
    Community Moderator
    Community Moderator

    I see three solutions for your use case:

    1. Use either Command Handler Template (NxCmdHandlerTemplate) or Exec Unit Template (NxExecUnitTemplate).
      Implement the device specific commands and manual functions.
      If you need it several times in your station, declare it as a subtree.
      If you need it several times in several stations, create an object with library.
      • Advantage: You can implement device specific commands and manual functions.
      • Disadvantage: You have to implement some things that are already included in the BasMove object.
    2. Use the BasMove object and add your own manual function:
      SteffenR_0-1644592384419.png
      • Advantage: Every programmer and service engineer directly sees that you have implemented something that does not use the default behaviour.
      • Disadvantage: You can't use the auto-generated HMI views and must create them manually.

    3. Use the BasMove object and overwrite the method of the manual function (= your solution):
      • Advantage: Overwriting methods is real object orientated programming.
      • Disadvantage: Maybe only object developers understand whats happening in this case.

     

     

    Regarding your source code of the manual function:

    • If BinIo._FakeOutput is connected to an BasMove parameter (OutBasePos/OutWorkPos), then you must not set this output manually in the PLC.
      Use the SetOutputs method according to documentation:

      SteffenR_1-1644593098496.png
      If you directly set the output and enable the IO stability monitoring (parameter IoStableCheck), you will get an HMI event when manipulating an output manually.

    • _manStartTime must be set in step 0 (I have fixed this in your post in case somebody copies the source code).
      Instead of your own TON timer you could then just compare
      IF( ExecTimeMoveWorkPos >= T#2S ) ...

    maj9bj
    Long-established Member

    Hello Steffen,

    thanks for the hints! I think the method overriding is easiest way in this simple case. But points 1 and 2 are also useful.

    I only change output control to SetOutput method I didn't know about event though I was checking inner methods of object 😊.

    I was also trying _manStartTime, but my mistake was setting it in step 0 to T#0s instead of TIME() 🙄.

    maj9bj
    Long-established Member

    Here is the final code using SetOutputs method and ExecTime.

    ManMoveWrkPos := RUNNING;
    
    // Sequence for the manual function
    CASE _step OF
      
      0: // Start command
        _manStartTime := TIME(); 
        _rUnit.SetOutputs(Mode := BasMoveSetOutputMode.WRK_PATTERN);
        _step := _step + 1;
        
      1: // Wait until finished
        ExecTimeMoveWrkPos := TIME() - _manStartTime;
        
        IF ( ExecTimeMoveWrkPos > T#2S ) AND {warning 'use station data here'}
           ( ExecMoveWrkPos = FALSE ) 
        THEN
          _rUnit.SetOutputs(Mode := BasMoveSetOutputMode.ALL_FALSE);
          _step          := 0;
          ManMoveWrkPos  := OK;
        END_IF
    END_CASE
    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