Developer Portal Community

    Showing results for 
    Search instead for 
    Did you mean: 

    24 tips (Advent calendar) for Control plus programmers

    24 tips (Advent calendar) for Control plus programmers

    Community Moderator
    Community Moderator

    Hey, it’s december. The time when the day starts with opening a door of an Advent calendar.

    Check out the official BCI Advent calendar on LinkedIn with some interesting piece of information every day.

    But just these days I noticed in a discussion that there are so many small improvements from Control plus bundle V1.0 to V2.3 that some of you maybe missed. What would be more obvious than showing you a tip every day ...

    #01  #02  #03  #04  #05  #06
    #07  #08  #09  #10  #11  #12
    #13  #14  #15  #16  #17  #18
    #19  #20  #21  #22  #23  #24

    24 REPLIES 24

    Community Moderator
    Community Moderator

    Do you know that the Object Browser can not only update your Std, but also clean up your Std?

    The clean up function deletes all unused objects/peripherals.



    Community Moderator
    Community Moderator

    You can add external tools or batch files to the Control plus Studio menu bar:


    1. Tools > External tools > Add
    2. Insert title
    3. Choose EXE or BAT file via […]
    4. Close everything with OK
    5. Tools > Customize
    6. Add new toolbar and add your EXE/BAT from commands via drag & drop


    In the attachment you can find an example batch file to clean up the station folder (batch file must be placed in station folder).

    Community Moderator
    Community Moderator

    By default objects and add-ons do not have an output for any active error number, but they provide an array with all active events. By checking for an specific event you can program a specific behaviour.

    This is how to realize it in an application:




    Implementation in an waiting step after command execution:



    PS: If the object or add-on do not provide a special functionality it is not possible to "mute" specific events or acknowledge them automatically.



    Source code for copying:

      /// temporary FB instance with list of currently active events
      _eventQuery : OpconEventQuery;
      /// flag if a special event is currently active (found in query)
      _eventFound : BOOL;
      /// temporary counter of FOR loop
      _i : DINT;
      /// compared OOIDs are equal
      _equalOoids : BOOL;


    IF( Station.PcdAccess.ExecState = OpconExecState.DONE )
      Station.PcdAccess.Execute := FALSE;
      _retVal := OK;
    ELSIF( Station.PcdAccess.ExecState = OpconExecState.ERROR )
      Station.PcdAccess.Execute := FALSE;
      // get currently active errors
      Station.PcdAccess.GetPendingEvents(OpconEventQueryType.ERROR, _eventQuery);
      // search for error "unkown identifier"
      _eventFound := FALSE;
      FOR _i := 1 TO _eventQuery.UsedEntries
        IF( _eventQuery.Entry[_i].Number = PcdAccessServerEvents.ERR_UNKOWN_ID )
          // OOID must also be compared because event numbers are not unique
          _equalOoids := OpconObjectIdIsEqual(_eventQuery.Entry[_i].ObjectId, PcdAccessConstants.OOID);
          IF( _equalOoids )
            _eventFound := TRUE;
      IF( _eventFound )
        // create new part if it doesn't exist on PCD server
        _retVal := JUMP1;
        // any other error -> stop automatic chain
        _env.ChainControl := OpconChainControl.ERROR;


    Community Moderator
    Community Moderator

    The BasMove object is a really powerful object. "BasMove" is the abbreviation for basic movement. It can be used for any use case with digital in-/outputs, for example belt motor, fan motor, hydraulic power pack, electrical cylinders and of course pneumatic cylinders.

    The parameters for the object are maybe as complicated as powerful the object is. Therefore a short guide for the parameters for the default case of a pneumatic cylinder:

    1. Set the parameter ValvePreset if you have a pneumatic cylinder without special requirements.
      This parameter hides all parameters that need not to be parametrized for the selected valve (e.g. 5/3 directional valve).
    2. Set the parameter OutputResetOnCancel to choose the behaviour in case of a cancel (operation mode change, emergency stop, control off, opening/closing doors). If the cylinder can stop its movement YES_IF_NOT_IN_POS is recommended. If it is a gripper or can't stop its movement (for example 5/2 directional valve) the value NO is recommended.
    3. If the supply power (= compressed air for pneumatic cylinders) is switched off in some cases you should set the parameter SupplyState.
      By setting this parameter the outputs will be reset if the SupplyState input has a falling edge and the outputs will be initialized according to the inputs (InBasePos, InWorkPos) everytime the SupplyState input has a rising edge.
    4. In the PLC code use the object output OutImm.IsInBasPos / IsInWrkPos for calculating the home position etc. This output is only TRUE if both the output and the input are TRUE.
    5. In the chains always set the command parameters PreStartCheck and OutputPulsing.



    Community Moderator
    Community Moderator

    Once again a topic about the BasMove object for pneumatic cylinders:

    The BasMove object has two commands, one for each end position. But there is also a method to set the outputs without any command. This can be used for special purposes, special initialization/cancel behaviour, etc.

    The method needs to be called only once, not cyclically, for example:

    // fill both sides with compressed air



    To prevent hard hitting of the end in case of empty compressed air lines there is also another solution for the homing:

    With the parameter ParCmd.OutputPulsing:=TRUE the valve output(s) will be pulsed if the cylinder is not in any end position. This is helpful for 5/3 or 2x 3/2 directional valves, for 5/2 directional valves it is useless. With the pulses the compressed air lines will be filled with compressed air slowly. It prevents that the cylinder hits the end hard because of missing counterpressure.

    It should work for almost all cylinder sizes without changing the pulse parameters in ParCmd structure.