1.一个设备【吊架控制】

1、功能需求:

  1、点位分布,如下图所示,先选择点位,选中后执行左边的上下停功能来执行所选中的点位,

  2、取消选中的点位后,再执行上下停功能,未选中的不会执行动作

 2、逻辑分析

  1、选择按钮后,要标记当前选按钮的状态,只要被选中的按钮才会被执行动作

  代码如下:

 #SYMBOL_NAME "Diaojia_Control"

  DIGITAL_INPUT UP,STOP,down;
  DIGITAL_INPUT Btn_Tog[30]; 

  DIGITAL_OUTPUT Btn_fb[30],btn_fb2[30];
  DIGITAL_OUTPUT up_code[30],stop_code[30],down_code[30];

integer i;

PUSH Btn_Tog
{
   i = GetLastModifiedArrayIndex ();     //选中被标记
   Btn_fb[i] = !Btn_fb[i];                     //取反
   Btn_fb2[i] = !Btn_fb[i];
}

push up
{
    for(i = 1 to 30)
   {
       delay(10);
      if(Btn_fb[i] = 1)
      {
         pulse(50,up_code[i]);
      }
   }
}

push stop
{
    for(i = 1 to 30)
   {
       delay(10);
      if(Btn_fb[i] = 1)
      {
         pulse(50,stop_code[i]);
      }
   }
}

push down
{
    for(i = 1 to 30)
   {
      delay(10);
      if(Btn_fb[i] = 1)
      {
         pulse(50,down_code[i]);
      }

   }
}

Function Main()
{  
 integer i;
 delay(300);
 for(i = 1 to 30)
  {
    Btn_fb2[i] = 0;  //初始化
  }
}

 

posted @ 2023-11-24 20:21  zhang0513  阅读(1)  评论(0编辑  收藏  举报