Help for the Rapid program

  • Hello friends. I need to write a basic program in Rapid, can you help me?

    Let sensor1 be Digital Input.

    Program steps are as follows;

    If sensor1 = 1

    Let the robot continue with normal steps without doing anything.

    But

    if sensor1 = 0

    "Operation failed"

    Let a text appear on the screen,

    Then

    Set the Digital Output.

    For example, set the Digital Output named "do_1" Digital Output.


    Thank you.

  • Add this in your Main Routine. The Manuals give examples of WHILE & FOR loops and IF statements. Can read up on it.

    Code
    WHILE DInput(sensor1)=0 OR DInput(sensor1)=1 DO
         IF DInput(sensor1)=1 THEN
             TPPrint "Robot Running";
         ELSE
             TPPrint "Robot Not Running";
         ENDIF
    ENDWHILE
  • I forgot to write down the problem I was having, Robot only prints on the screen in case of sensor 1, but does not proceed to the next steps. How can I solve this problem?

    In other words, when (sensor1) is 1, the Robot stays at step 17 and does not proceed to the next steps. It does not exit the while loop. I want to solve this problem. Could you help?

  • Add your commands for when the sensor is 1, between the IF DInput(sensor1) and the ELSE instructions and the commands for when the sensor is 0, between ELSE and the ENDIF instructions.

  • WaitUntil is the perfect function for this.


    WaitUntil sensor1 = 1 \Header:="Operation failed" \Message:="Operation failed" \VisualizeTime:=1\UIActiveSignal:=do_1;


    The robot will wait here until sensor1 = 1. If it waits more than 1 second the text "Operation failed" is shown to the operator and output do_1 is set. When sensor1 = 1 robot continues operation and resets do_1.

Advertising from our partners