搜索
bottom↓
回复: 2

关于MODBUS制作MPG手轮的疑问。

[复制链接]

出0入0汤圆

发表于 2016-11-16 14:13:06 | 显示全部楼层 |阅读模式
本帖最后由 王涛 于 2016-11-16 23:15 编辑

关于Mach3 modbus有两种方式一种是通过Plug-in方式,这种方式要开发插件读取Modbus设备的数据,这种方式可以掌控整个Mach3的所有变量。这里不做说明。现在要说的是另外的一种方式——即非插件方式的自动查询方式(Autopoller)。这种方式会定时发送数据请求报文。Modbus设备把数据准备好给mach3读取。下图就是mach3 modbus 非插件方式的设设置。这种设置下地址进行了从映射


上图就是这种映射只要和modbus设备通信正常后就能轻松的通过TEST MODBUS得到modbus设备的数据。或是用vb来调试
列如:A=GetInput(64) MsgBox"A="&A就能得到数据。
这里是一个modbus手轮的宏程序。
' Macropump developed for Peach Hill MPG Set
' Based on Hofmann MODIO Panel
' Objective to give Remote Pendant based, Axis, Step, Feed Over ride, Via Analogue inputs 1,2 &3
' Step and Direction from Mechanical MPG Using I/P 6 &7
' In addition Digital I/Ps for E-Stop,Digital Dig 0 normally closed push button
' Digital 1 & 2 via center off 3 pos switch  Jog On/Off, and Shuttle Off/On
' Jog mode thru Analog In 1
' Jog step val thru Analog In 2
' Jog speed over ride thru Analog In 3
' E-Stop via Port 0 Pin 0 no Software required

                MPGAxis = Getinput ( 64 ) 'analog input 1 on ModIO
Select Case MPGAxis
Case <85
        'do nothing
        State = 0
Case < 277        
        If GetOEMLED ( 14 ) = 0 Then 'If not set to continuous Jog Mode
                DoOEMButton ( 276 ) 'Set jog to Continuous
        End If
        State = 1
Case <490
        If GetOEMLED ( 15 ) = 0 Then 'If not set to Step Jog Mode
                DoOEMButton ( 275 ) 'Set jog to Continuous
        End If
        State = 2        
Case <707
        If GetOEMLED ( 57 ) = 0 Then 'If not set to MPG Jog Mode
                DoOEMButton ( 306 ) 'Set jog to MPG
        End If
        If GetOEMLED ( 59 ) = 0 Then
                DoOEMButton ( 185 ) 'Set MPG to Jog X
        End If
        State = 3        
Case <919
        If GetOEMLED ( 57 ) = 0 Then 'If not set to MPG Jog Mode
                DoOEMButton ( 306 ) 'Set jog to MPG
        End If
        If GetOEMLED ( 60 ) = 0 Then
                DoOEMButton ( 186 ) 'Set MPG to Jog Y
        End If
        State = 4
Case >919
        If GetOEMLED ( 57 ) = 0 Then 'If not set to MPG Jog Mode
                DoOEMButton ( 306 ) 'Set jog to MPG
        End If
        If GetOEMLED ( 61 ) = 0 Then
                DoOEMButton ( 187 ) 'Set MPG to Jog Z
        End If
        State = 5
End Select  

' Logic for setting Jog Ammounts thru Analog In 2
JOGInc = Getinput ( 65 ) 'analog input 2 on ModIO
Select Case JOGInc
Case <256
        If GetOEMLED ( 57 ) <> 0 Then 'If is set Jog Step
                DoOEMButton ( 265 ) 'Set Step to 1mm
        End If
Case <714
        If GetOEMLED ( 57 ) <> 0 Then 'If is set Jog Step
                DoOEMButton ( 266 ) 'Set Step to 0.1mm
        End If
Case >714
        If GetOEMLED ( 57 ) <> 0 Then 'If is set Jog Step
                DoOEMButton ( 267 ) 'Set Step to 0.01mm
        End If
End Select  
' Setting Feedrate Over rate from Analogue 3
Option Explicit
Dim fro As Integer

Const Input3Sig = 18

fro = GetInput ( 66 )
fro = (fro * 195.0)/1024.0
SetDRO 21, FRO+5
'
Rem DRO display On ModIO
'
Option Explicit
Dim Display As String
Dim SVal As String
Dim iCount As Integer
Dim iBase As Integer
Dim strMode (6) As String
'
Const slave = 6 ' Default config
Const NoAxesToDisplay = 4
If GetLED (1) Then strMode (0) = " inch" Else strMode (0) = "    mm"'Added extra space              
If getOEMLED (16) Then strMode (1) ="<m/c>" Else strMode (1)  ="      "'coord sys Extra Space
If GetOEMLED (83) Then strMode (2) ="      " Else strMode (2) = " NoJog"
If GetLED (0) Then strMode (3) = " EStop" Else strMode (3) = "      "
strMode (4) = "     "
strMode (5) = "     "
Display =""
For iCount = 0 To NoAxesToDisplay - 1
        SVal = Right ("     " & Format (GetDro (iCount), "+0.0000;-0.0000"), 11)
        If iCount < 3 Then 'X, Y, Z
                iBase = Asc ("X")
        Else 'A, B, C
                iBase = Asc ("A") - 3
        End If
        Display = Display & " " & Chr (iBase + iCount) & SVal & " " & StrMode (iCount)
Next iCount
SetModIOString (slave, 0, 0, Display)

这个程序接收来自MODBUS的三个寄存器的输入用来改变(Jog mode thru Analog In 1
' Jog step val thru Analog In 2  ' Jog speed over ride thru Analog In 3)。和DRO的输出给MODBUS手轮显示坐标值。


那么问题来了这个宏并没有对手轮的脉冲计算和处理。MPG电子手轮的脉冲从哪里输入,映射的是Encoder 1 Encoder 2(67、68 )中的那一个????
这个值是如何传到mach3 里的MPG1count计算器的???


在C:\Mach3\Brains目录下有一个文件是ModIOMPG.brn这个文件里面有过对MPG1count++进行过处理可是它所对应的Modbus地址不对。它的是零地址,而且在brian里激活这个ModIOMPG.brn好像也没有什么反应。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x

阿莫论坛20周年了!感谢大家的支持与爱护!!

月入3000的是反美的。收入3万是亲美的。收入30万是移民美国的。收入300万是取得绿卡后回国,教唆那些3000来反美的!

出0入0汤圆

发表于 2016-11-16 16:02:52 | 显示全部楼层
我个人认为,modbus不适合高速设备,比如编码器,手轮,伺服。

出0入0汤圆

 楼主| 发表于 2016-11-17 22:50:34 | 显示全部楼层
这里上传一个mach3空白的插件给大家,有了这个插件可以做二次开发。开发自己的控制板自己的modbus控制卡总之mach3的所以变量都可以引用,然后通过串口,usb等输出给控制卡。在控制卡上可以做自己的控制算法。把产生的.dll文件放在MACH3的plugs文件夹里激活它。就可以了。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-4-25 20:57

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

快速回复 返回顶部 返回列表