运动平台:日脉的二维运动平台(一个旋转平台和一个滑动平台)

开发环境:VS2010 + .NET Framework + VB.NET

使用文件:pci_8158.vb

motion_8158_2D.vb

2D平台运动类

Public Class motion_8158_2D

    Public CardId As Integer
'move parameter here
'AxisNo is 0 or 1
Public AxisNo As Short
'Dist : mm
Public Dist As Double
'StrVel : mm/s
Public StrVel As Double
'MaxVel : mm/s
Public MaxVel As Double
'Tacc : s
Public Tacc As Double
'Tdec : s
Public Tdec As Double Public Sub New(ByVal cardId1 As Integer)
CardId = cardId1
End Sub Public Sub New(ByVal axisNo1 As Short, ByVal dist1 As Double, ByVal strVel1 As Double, ByVal maxVel1 As Double, ByVal tacc1 As Double, ByVal tdec1 As Double)
AxisNo = axisNo1
Dist = dist1
StrVel = strVel1
MaxVel = maxVel1
Tacc = tacc1
Tdec = tdec1
End Sub Public Sub CardRegedit_8158_2d() Dim code As Integer
code = B_8158_initial(CardId, )
'set axis num 0
B_8158_set_move_ratio(, )
B_8158_set_pls_outmode(, )
B_8158_set_servo(, ) 'set axis num 1
B_8158_set_alm(, , )
B_8158_set_inp(, , )
B_8158_set_move_ratio(, )
B_8158_set_pls_outmode(, )
B_8158_set_move_ratio(, ) 'code = B_8158_config_from_file()
'the axis num of x axis linear motion is 0
'the axis num of Ry axis ratary motion is 1 'Is has 8158 card 's drive
If (code <> ) Then
MsgBox("No 8158 Card exit!")
B_8158_close()
End If 'configure the input mode of external feedback pulse
B_8158_set_pls_iptmode(, , )
'set counter input source
B_8158_set_feedback_src(, )
End Sub Public Sub LinearMotion()
Dim pulse_dist As Double = Dist *
Dim pulse_strVel As Double = StrVel *
Dim pulse_maxVel As Double = MaxVel *
B_8158_start_tr_move(AxisNo, pulse_dist, pulse_strVel, pulse_maxVel, Tacc, Tdec)
End Sub Public Sub RotateMotion()
'rotation stage dec radio 1/5
Dim pulse_dist As Double = Dist * /
Dim pulse_strVel As Double = StrVel * /
Dim pulse_maxVel As Double = MaxVel * /
B_8158_start_tr_move(AxisNo, pulse_dist, pulse_strVel, pulse_maxVel, Tacc, Tdec)
End Sub Public Function GetLinearSpeed() As Double
Dim s As Double
B_8158_get_current_speed(, s)
GetLinearSpeed = s /
End Function Public Function GetRotSpeed() As Double
Dim s As Double
B_8158_get_current_speed(, s)
GetRotSpeed = s * /
End Function
End Class

新开辟一个线程,用While循环控制连续运动主窗体程序:

用事件委托的方法,向TextBox中写入数据

''' <summary>
''' aging motion control test software at 20130819
''' mail:bin___03@163.com
''' </summary>
''' <remarks></remarks>
''' Public Class Form1
'Control motion manually
Delegate Sub UpdateLogCallback(ByVal [text] As String)
Private manualMotion As Boolean = False
Dim MotionThread As System.Threading.Thread
Dim objMotion As motion_8158_2D = New motion_8158_2D()
Dim timeBegin As Date
Dim timeEnd As Date
Dim boolDuration As Boolean = False
Dim log As IO.StreamWriter
Dim logFileName As String Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.MaximumSize = Me.Size
Me.MinimumSize = Me.Size objMotion.CardRegedit_8158_2d() End Sub Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
timeBegin = DateTime.Now
boolDuration = True
'MsgBox(timeBegin.ToString("yyyyMMddHHmmss"))
logFileName = timeBegin.ToString("yyMMddHHmmss") & ".txt"
log = New IO.StreamWriter(logFileName, True) manualMotion = True
btnStop.Enabled = True
btnStart.Enabled = False
tsslMovingStatus.Text = "moving..."
txtLog.Clear() MotionThread = New System.Threading.Thread(AddressOf ContinuuousMotion)
MotionThread.Start() End Sub Private Function isStopMotion() As Boolean
isStopMotion = True
For i = To
Dim temp As Short = B_8158_motion_done(i)
If B_8158_motion_done(i) <> Then
isStopMotion = False
Exit For
End If
Next
Return isStopMotion
End Function Sub ContinuuousMotion()
Dim objRandom As Random = New Random()
Dim tilt_old As Double =
Dim tilt_new As Double
'MsgBox(manualMotion)
While True If manualMotion Then
Exit While
End If End While While manualMotion
Dim rdn As Double = objRandom.NextDouble
If rdn <= 0.5 Then
tilt_new = - * rdn
Else
tilt_new = * rdn
End If Dim strLog As String =
">> " & DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss ") & "TILT:" & tilt_new.ToString & vbCrLf
UpdateLog(strLog)
log.Write(strLog) Threading.Thread.Sleep()
' rotate
objMotion = New motion_8158_2D(, tilt_new - tilt_old, , , 0.05, 0.05)
objMotion.RotateMotion() 'waiting for the motion stopped
While True
If isStopMotion() Then
Exit While
End If
End While Threading.Thread.Sleep()
'acc = 0.18g for 100mm for linear stage
objMotion = New motion_8158_2D(, , , , 0.05, 0.05)
objMotion.LinearMotion() 'waiting for the motion stopped
While True
If isStopMotion() Then
Exit While
End If
End While Threading.Thread.Sleep()
'acc = -0.18g for 100mm for linear stage
objMotion = New motion_8158_2D(, -, , , 0.05, 0.05)
objMotion.LinearMotion() 'waiting for the motion stopped
While True
If isStopMotion() Then
Exit While
End If
End While tilt_old = tilt_new
End While
End Sub Private Sub btnStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStop.Click
boolDuration = False
manualMotion = False
btnStop.Enabled = False
btnStart.Enabled = True
tsslMovingStatus.Text = "stoped..."
UpdateLog(Application.StartupPath & "\" & logFileName)
log.Dispose()
log.Close()
MotionThread.Abort() B_8158_stop_move_all()
For i = To
B_8158_emg_stop(i)
B_8158_set_motion_int_factor(i, )
Next
B_8158_int_control(, )
End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
txtLinearSpeed.Text = objMotion.GetLinearSpeed.ToString
txtRotSpeed.Text = objMotion.GetRotSpeed.ToString If boolDuration Then
'start button and stop button control boolDuration parameter
timeEnd = DateTime.Now
'timespan format write to duration time text
txtDurationTime.Text = (timeEnd - timeBegin).ToString("hh\:mm\:ss\.ff")
End If End Sub Private Sub Form1_FormClosed(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles MyBase.FormClosed
Try
B_8158_stop_move_all()
B_8158_close()
MotionThread.Abort()
log.Dispose()
log.Close()
Catch ex As Exception End Try End Sub Private Sub UpdateLog(ByVal [text] As String)
If InvokeRequired Then
Dim d As New UpdateLogCallback(AddressOf UpdateLog)
Me.Invoke(d, New Object() {[text]})
Else If txtLog.Lines.Count > Then
txtLog.Clear()
End If
txtLog.AppendText([text])
End If
End Sub End Class

工程文件下载页:http://download.csdn.net/detail/asan2006/5993907

ADLINK 8158控制程序-连续运动(VB.NET)的更多相关文章

  1. 第三期 第三期 搜索——1.运动规划(motion_planing)

    运动规划的根本问题在于机器人可能存在于一个这样的世界中, 它可能想找到一条到达这个目标的路径,那么就需要指定一个到达那里的计划, 自动驾驶汽车也会遇到这个问题.他可能处于高速公路的附近的街道网络中,他 ...

  2. [ios学习笔记之视图、绘制和手势识别]

    一 视图 二 绘制 三 手势 00:31 UIGestureRecognizer 抽象类 两步 1添加识别器(控制器或者视图来完成) 2手势识别后要做的事情 UIPanGestureRecognize ...

  3. A simple test

        博士生课程报告       视觉信息检索技术                 博 士 生:施 智 平 指导老师:史忠植 研究员       中国科学院计算技术研究所   2005年1月   目 ...

  4. 标准C函数库的使用方法

    本篇介绍若干经常使用的标准C函数的使用方法,主要介绍stdio(标准输入输出).math(数字函数库).time(时间函数库).stdlib(标准函数库)string(标准字符串函数)等. 最后更新  ...

  5. WEB烟花效果——Canvas实现

    摘要        本文主要介绍一种WEB形式的烟花(fireworks)效果(图1所示),该效果基于Canvas实现,巧妙地运用了canvas绘图的特性,并加入了物理力作用的模拟,使整体效果非常绚丽 ...

  6. search

    |—search()—|—添加一个列表变量Expend,存储每个小格扩展时为第几步,可打印出 |                    |—打印运动表 |—A*—|— heuristic() |—Dy ...

  7. 闵可夫斯基和(Mincowsky sum)

    一.概述 官方定义:两个图形A,B的闵可夫斯基和C={a+b|a∈A,b∈B}通俗一点:从原点向图形A内部的每一个点做向量,将图形B沿每个向量移动,所有的最终位置的并便是闵可夫斯基和(具有交换律) 例 ...

  8. 3.定时器的使用(以通俗易懂的语言解释JavaScript)

    1.定时器的作用: 开启定时器:setInterval -->间隔型 setTimeout -->延时型 区别:setInterval会一直执行,应用如微博间隔一段时间不断请求后台数据,看 ...

  9. CSS3帧动画

    在前面的文章中也有介绍过css3动画的内容,可见<关于transition和animation>和<webkitAnimationEnd动画事件>,今天又要唠叨一下这个东西了, ...

随机推荐

  1. assert sys.modules[modname] is old_mod

    使用了pypiwin32 包中的pythoncom的时候,当跑在apache下,日志报错: [Thu Aug 27 17:06:44 2015] [error] [client 127.0.0.1] ...

  2. .net 实例化对象

    定义TestClass,在调用的地方 TestClass a; 如果下面有引用 a.Property,VS会报错,而如果 TestClass a = null; 再次调用的话则不会报错. TestCl ...

  3. JavaScript生成器+随机数的使用

    function* getIndex(indexList){ var len = indexList.length; var m; while(indexList.length > 0){ m ...

  4. java项目导出jar文件时指定main方法的类

    需要先运行一下main函数,eclipse的Export-->Runnable JAR File ---> 下的Launch configuration下拉列表才会有记录.如果想要删除下拉 ...

  5. 酷炫地给py代码标上行数

    Python IDLE是没有显示行号的功能的,今天学了一个方式可以酷炫地给自己的代码加上行号,该方法直接修改代码,慎用哦!代码如下: import fileinput for line in file ...

  6. 轻松解决Win8.1连接受限或无法连接WiFi问题

    在无线网络连接设置窗口中,找到当前连接的无线网络“WLAN状态”,右击查看“状态”. 在“WLAN状态”窗口中找到“无线属性”. 进入“无线网络属性”窗口,切换到“安全”页面,点击“高级设置”.最重要 ...

  7. CSS也可以改变图片幅面尺寸

    一般情况下,只有<img />标签中的图片,可以根据宽高设定来改变大小. 比如1024x768的图,我们设width="640",height="480&qu ...

  8. unity3d 幻灯片效果实现

    上一篇使用的是静态方式进行的加载,采用的数据结构为 数组 该篇文章则是使用动态加载的方式实现: this.objsOfRouses = Resources.LoadAll("images&q ...

  9. BAT等互联网公司薪资分享

  10. c# 哈希表集合;函数

    * 哈希表集合 1.先进去的后出来,最后进去的先出来 2.利用枚举类型打印出集合中的Key值和Value值 ** 函数 1.函数:能够独立完成某项功能的模块. 函数四要素:输入.输出.函数体.函数名 ...