回复:工艺部要我实现在PLC内执行一个计算公式,并把数值在WINCC画面上显示。

已锁定

渔明锅红

  • 帖子

    2064
  • 精华

    83
  • 被关注

    471

论坛等级:至圣

注册时间:2009-04-02

白金 白金 如何晋级?

发布于 2020-09-09 11:42:57

16楼

进一步完美程序,要在WINCC上显示5个激光测距的位置。

FUNCTION FC28 : VOID

VAR_TEMP

    x2_tan:REAL;

    x2_cos:REAL;

   y2_tan:REAL;

   y2_cos:REAL; 

   AA:REAL;

   BB:REAL;

   CC:REAL;

   sin_a:REAL;

   cos_a:REAL;

   a_into:REAL;

   kk1:REAL;

   kk2:REAL;

   kk3:REAL;

   mm1:REAL;

   mm2:REAL;

   mm3:REAL;

    Mandrel_Z0:REAL;

   Mandrel_Z1:REAL;

    Mandrel_R:REAL;

     Mandrel_a:REAL;

     x0:REAL;

x1:REAL;

    END_VAR


    // Statement Section

    

  

// Block Parameters

VAR_INPUT

  

  // Input Parameters

Mandrel_D:REAL;

Mandrel_P:REAL;

runningbeam_Pos:REAL;

lase1_value:REAL;

lase2_value:REAL;

END_VAR


 

VAR_OUTPUT

Mandrel_E:REAL; // Output Parameters

Mandrel_x2:REAL;

Mandrel_y2:REAL;

E_1:REAL;

E_2:REAL;

E_3:REAL;

E_4:REAL;

E_5:REAL;

END_VAR

  BEGIN 

  IF  runningbeam_Pos>500.0 AND runningbeam_Pos<505.0  THEN x0:=lase1_value;x1:=lase2_value;E_1:=Mandrel_E; END_IF;

   IF runningbeam_Pos>1000.0  AND runningbeam_Pos<1005.0  THEN x0:=lase1_value;x1:=lase2_value;E_2:=Mandrel_E; END_IF;

    IF runningbeam_Pos>1500.0  AND runningbeam_Pos<1505.0    THEN x0:=lase1_value;x1:=lase2_value;E_3:=Mandrel_E; END_IF;

     IF runningbeam_Pos>2000.0  AND runningbeam_Pos<2005.0    THEN x0:=lase1_value;x1:=lase2_value;E_4:=Mandrel_E; END_IF;

      IF runningbeam_Pos>3000.0   AND runningbeam_Pos<3005.0   THEN x0:=lase1_value;x1:=lase2_value; E_5:=Mandrel_E;  END_IF; 



   Mandrel_a:=53.0;

  Mandrel_R:=(Mandrel_D-Mandrel_P)/2;

    a_into:=Mandrel_a*3.1415926/180;

   sin_a:=SIN(a_into);

   cos_a:=COS(a_into);

   mm1:=(Mandrel_R+Mandrel_Z1)*cos_a-(Mandrel_R+Mandrel_Z0);

   mm2:=(Mandrel_R+Mandrel_Z1)*sin_a;

   mm3:=mm1/mm2;

   x2_tan:=ATAN(mm3);

   //x2_tan:=ATAN(((Mandrel_R+Mandrel_Z1)*(Mandrel_R+Mandrel_Z0)*cos_a)/((Mandrel_R+Mandrel_Z1)*sin_a)); 

   

   kk1:=(Mandrel_R+Mandrel_Z0)*(Mandrel_R+Mandrel_Z0);

   kk2:=(Mandrel_R+Mandrel_Z1)*(Mandrel_R+Mandrel_Z1);

   kk3:=2*(Mandrel_R+Mandrel_Z0)*(Mandrel_R+Mandrel_Z1)*cos_a;

   AA:=kk1+kk2-kk3;

   BB:=SQRT(AA);

   CC:=BB/(2*Mandrel_R);

   x2_cos:=ACOS(CC);

  Mandrel_x2:=Mandrel_R*COS(x2_tan-x2_cos);

  Mandrel_y2:=Mandrel_R+Mandrel_Z0+Mandrel_R*SIN(x2_tan-x2_cos);

  Mandrel_E:=SQRT(Mandrel_x2*Mandrel_x2+Mandrel_y2*Mandrel_y2);

  

      

 IF Mandrel_D=270.0  THEN

        Mandrel_Z0:=1278-x0;

        Mandrel_Z1:=1493.7-x1;// Statement Section

           END_IF;

 IF Mandrel_D=300.0 THEN

        Mandrel_Z0:=1263-x0;

        Mandrel_Z1:=1478.7-x1;// Statement Section

           END_IF;

 IF Mandrel_D=330.0 THEN

        Mandrel_Z0:=1248-x0;

        Mandrel_Z1:=1463.7-x1;// Statement Section

           END_IF;

 IF Mandrel_D=350.0 THEN

        Mandrel_Z0:=1238-x0;

        Mandrel_Z1:=1453.7-x1;// Statement Section

           END_IF;

 IF Mandrel_D=375.0 THEN

        Mandrel_Z0:=1225.5-x0;

        Mandrel_Z1:=1441.2-x1;// Statement Section

           END_IF;

 IF Mandrel_D=400.0 THEN

        Mandrel_Z0:=1213-x0;

        Mandrel_Z1:=1428.7-x1;// Statement Section

           END_IF;

 IF Mandrel_D=420.0 THEN

        Mandrel_Z0:=1203-x0;

        Mandrel_Z1:=1418.7-x1;// Statement Section

           END_IF;

 IF Mandrel_D=450.0 THEN

        Mandrel_Z0:=1188-x0;

        Mandrel_Z1:=1403.7-x1;// Statement Section

           END_IF;

 IF Mandrel_D=480.0 THEN

        Mandrel_Z0:=1173-x0;

        Mandrel_Z1:=1388.7-x1;// Statement Section

           END_IF;

 IF Mandrel_D=510.0 THEN

        Mandrel_Z0:=1158-x0;

        Mandrel_Z1:=1373.7-x1;// Statement Section

           END_IF;

 IF Mandrel_D=550.0 THEN

        Mandrel_Z0:=1138-x0;

        Mandrel_Z1:=1353.7-x1;// Statement Section

           END_IF;

 IF Mandrel_D=575.0 THEN

        Mandrel_Z0:=1125.5-x0;

        Mandrel_Z1:=1341.2-x1;// Statement Section

           END_IF;

 IF Mandrel_D=600.0 THEN

        Mandrel_Z0:=1113-x0;

        Mandrel_Z1:=1328.7-x1;// Statement Section

           END_IF;

 IF Mandrel_D=620.0 THEN

        Mandrel_Z0:=1103-x0;

        Mandrel_Z1:=1318.7-x1;// Statement Section

           END_IF;

 if Mandrel_D=650 then

        Mandrel_Z0:=1088-x0;

        Mandrel_Z1:=1303.7-x1;// Statement Section

           END_IF;

             

END_FUNCTION





网鱼能够改善伙食,还能释放工作中的压力。
评论
编辑推荐: 关闭

请填写推广理由:

本版热门话题

SIMATIC S7-300/400

共有54778条技术帖

相关推荐

热门标签

相关帖子推荐

guzhang

恭喜,你发布的帖子

评为精华帖!

快扫描右侧二维码晒一晒吧!

再发帖或跟帖交流2条,就能晋升VIP啦!开启更多专属权限!

  • 分享

  • 只看
    楼主

top
X 图片
您收到0封站内信:
×
×
信息提示
很抱歉!您所访问的页面不存在,或网址发生了变化,请稍后再试。