Problem to create 3 Alternative reset Switch

asifdip
2012-10-11
2024-10-29
  • asifdip - 2012-10-11

    Hello All,
    I am try to create 3 switch with visualization. I have there global variables (switch) x1, x2, x3.
    I am trying to write a program if X1=1, then X2=0 and X3=0. It same for if x2=0, then X1=0 and x3=0. If X3=1 then x2=0, x1=0.
    I have tried with (If_else) condition but it not works. Then I also use "RS or toggle " funtion block but it is not working.

    MY intention is X1 is "true " condition untill X2 or X3 is "False" but when press X2 then X2 is "True" and X3 and X1 is off "false".
    X2 is "true" but after pressing x3, X3 should be" true" and other x2 and x1 is "false".
    I have written following two function but it is not working.

    1st trying:
    If X1 =true then ( X1, X2 and X3 are global variable)
    X1:=true; X2:=false; X3:=false ;

    ELSIF X2=true then
    x2:=true; X1:=False; X3:=false;

    ElSIF x3=true then
    X3:=true; X1:=false; X2:=false;

    END_IF ;

    Trying another way:

    I have also tried with RS or toggle function block:

    var
    Reset_ablauf_Coil_Auto:RS;
    Reset_ablauf_Stange_Auto:RS;
    Reset_ablauf_Stange_Munual:RS;
    END_var

    Reset_ablauf_Coil_Auto(
    SET:=X1 ,
    RESET1:= X2 OR X2,
    Q1=> X1);

    Reset_ablauf_Stange_Auto(
    SET:=X2 ,
    RESET1:= X1 OR X3,
    Q1=> X2);

    Reset_ablauf_Stange_Munual(
    SET:=X3 ,
    RESET1:= X1 OR X2,
    Q1=>X3);

    In my first trying i have some priority problem but second one is also not working.
    Pls give me suggestion or idea.

    Best Regards,
    Asif

     
  • shooter - 2012-10-14

    Your problem is not in the code, but you have three switches used as inputs, it is impossible to change the inputs itself.
    You will have to use another strategy.

    example:
    if R_TRIG X1 then status :=1;
    if R_TRIG X2 then status :=2;
    etc.
    now you can see which button is pressed last.

    CASE status
    1:
    do here what you want in status 1
    2:
    etc.
    END_CASE

     
  • sarathbabu - 2012-10-19

    Hi,
    With the help of a friend I got it.pls find the attached program this works for u r requirement

    test3switch.pro [36.25 KiB]

     

Log in to post a comment.