您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

位移传感器界面化角度

2024/3/8 16:42:37发布12次查看
最近在研究一台磨床,上磨盘需要有一定的倾斜角,本文阐述了利用三个位移传感器通过测量位移转换成角度并界面化,分享给大家。
正向两个位移传感器,侧面方向一个位移传感器。主要的思路为:正向两个位移传感器取平均值作为正向位移,与侧向位移传感器组成三角函数关系,通过arctan算出夹角,内部红色光标设置成x/y偏移变量,如图大圆半径为100,对应x偏移量为sina*100,对应y偏移量为cosa*100。这样不但可以直观的观察角度,而且更能直观的观察红色光标的位置。附代码如下:
/////////位移传感器数值整定
call fc 105
in :=db41.dbw232
hi_lim :=2.000000e+000
lo_lim :=0.000000e+000
bipolar:=false
ret_val:=#_retval
out :=#_dist_s_kipp_p2
call fc 105
in :=db41.dbw234
hi_lim :=2.000000e+000
lo_lim :=0.000000e+000
bipolar:=false
ret_val:=#_retval
out :=#_dist_s_dkipp_p3
call fc 105
in :=db41.dbw230
hi_lim :=2.000000e+000
lo_lim :=0.000000e+000
bipolar:=false
ret_val:=#_retval
out :=#_dist_s_dreh_p1
///////////////////////////////////
////////数值校正
l #_dist_s_dreh_p1
l #_zero_val_s_dreh_p1
-r
l db34.dbd 274
*r
negr
t #_skal_dist_sensor_dreh
l #_dist_s_kipp_p2
l #_zero_val_s_kipp_p2
-r
l db34.dbd 278
*r
negr
t #_skal_dist_sensor_kipp
l #_dist_s_dkipp_p3
l #_zero_val_s_dkipp_p3
-r
l db34.dbd 278
*r
negr
t #_skal_dist_sensor_dkipp
l #_skal_dist_sensor_kipp
l #_skal_dist_sensor_dkipp
+r
l 2.000000e+000
/r
t #_skal_mwert_kipp_dkipp
//////////////////////////////////////////////////////
////////清零操作
a db34.dbx 268.0
a db41.dbx 23.7
jcn n4_1
l #_dist_s_dreh_p1
t #_zero_val_s_dreh_p1
l #_dist_s_kipp_p2
t #_zero_val_s_kipp_p2
l #_dist_s_dkipp_p3
t #_zero_val_s_dkipp_p3
r db34.dbx 268.0
n4_1: nop 0
l #_skal_mwert_kipp_dkipp
l 0.000000e+000
>=r
s #iv_jump1 //positiv
l #_skal_mwert_kipp_dkipp
l 0.000000e+000
r #iv_jump1 //neg.
l #_skal_dist_sensor_dreh
l 0.000000e+000
>=r
s #iv_jump2 //pos.
l #_skal_dist_sensor_dreh
l 0.000000e+000
r #iv_jump2 //neg.
l #_skal_dist_sensor_dreh
l 0.000000e+000
==r
jcn n5e
l 1.000000e-006
t #_skal_dist_sensor_dreh
n5e: nop 0
//////////////////////////////////////////////////////
///////四个象限,第一象限0-90°
a #iv_jump1
a #iv_jump2
jcn e51
l #_skal_mwert_kipp_dkipp
l #_skal_dist_sensor_dreh
/r
atan
t #_temp_winkel_verh_y_x //pos winkel (rad)
l 3.140000e+000
/r
l 1.800000e+002
*r
t #_vi_winkel_a
l #_temp_winkel_verh_y_x
cos
l 1.000000e+002 //hmi画的半径
*r
rnd
t #_vi_engstestelle_x
l #_temp_winkel_verh_y_x
sin
l 1.000000e+002
*r
rnd
t #_vi_engstestelle_y
e51: nop 0
/////////位移传感器数值整定
call fc 105
in :=db41.dbw232
hi_lim :=2.000000e+000
lo_lim :=0.000000e+000
bipolar:=false
ret_val:=#_retval
out :=#_dist_s_kipp_p2
call fc 105
in :=db41.dbw234
hi_lim :=2.000000e+000
lo_lim :=0.000000e+000
bipolar:=false
ret_val:=#_retval
out :=#_dist_s_dkipp_p3
call fc 105
in :=db41.dbw230
hi_lim :=2.000000e+000
lo_lim :=0.000000e+000
bipolar:=false
ret_val:=#_retval
out :=#_dist_s_dreh_p1
///////////////////////////////////
////////数值校正
l #_dist_s_dreh_p1
l #_zero_val_s_dreh_p1
-r
l db34.dbd 274
*r
negr
t #_skal_dist_sensor_dreh
l #_dist_s_kipp_p2
l #_zero_val_s_kipp_p2
-r
l db34.dbd 278
*r
negr
t #_skal_dist_sensor_kipp
l #_dist_s_dkipp_p3
l #_zero_val_s_dkipp_p3
-r
l db34.dbd 278
*r
negr
t #_skal_dist_sensor_dkipp
l #_skal_dist_sensor_kipp
l #_skal_dist_sensor_dkipp
+r
l 2.000000e+000
/r
t #_skal_mwert_kipp_dkipp
//////////////////////////////////////////////////////
////////清零操作
a db34.dbx 268.0
a db41.dbx 23.7
jcn n4_1
l #_dist_s_dreh_p1
t #_zero_val_s_dreh_p1
l #_dist_s_kipp_p2
t #_zero_val_s_kipp_p2
l #_dist_s_dkipp_p3
t #_zero_val_s_dkipp_p3
r db34.dbx 268.0
n4_1: nop 0
l #_skal_mwert_kipp_dkipp
l 0.000000e+000
>=r
s #iv_jump1 //positiv
l #_skal_mwert_kipp_dkipp
l 0.000000e+000
r #iv_jump1 //neg.
l #_skal_dist_sensor_dreh
l 0.000000e+000
>=r
s #iv_jump2 //pos.
l #_skal_dist_sensor_dreh
l 0.000000e+000
r #iv_jump2 //neg.
l #_skal_dist_sensor_dreh
l 0.000000e+000
==r
jcn n5e
l 1.000000e-006
t #_skal_dist_sensor_dreh
n5e: nop 0
//////////////////////////////////////////////////////
///////四个象限,第一象限0-90°
a #iv_jump1
a #iv_jump2
jcn e51
l #_skal_mwert_kipp_dkipp
l #_skal_dist_sensor_dreh
/r
atan
t #_temp_winkel_verh_y_x //pos winkel (rad)
l 3.140000e+000
/r
l 1.800000e+002
*r
t #_vi_winkel_a
l #_temp_winkel_verh_y_x
cos
l 1.000000e+002 //hmi画的半径
*r
rnd
t #_vi_engstestelle_x
l #_temp_winkel_verh_y_x
sin
l 1.000000e+002
*r
rnd
t #_vi_engstestelle_y
e51: nop 0
////////////////////////////////////////////////
////////其他三个象限同理。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product