|
发表于 2019-9-16 19:00:35
来自手机
|
显示全部楼层
laomaotao 发表于 2019-01-28 09:45- k* K! O J5 d7 Z4 F
本帖最后由 laomaotao 于 2019-1-28 10:27 编辑
& ^4 v8 P/ Y( ` n' j5 a$ v, f
' U j/ h$ v/ z9 Q& l' `" I {; \! L( Z' W
这是一个mach3的空白插件工程。有了这个你可以自己开发自己的mach3 接口板。其实并口是最稳定的。操作系统可以把并口当做GPIO来操作。现在淘宝上卖的卡都是大部分通过开发插件来实现USB接口的。大部分都是ARM+FPGA架构的或是你这种板架构的。这个贴在别的站发过现在搬来这里给你研究。
! {) G w. _+ f7 X- ^6 X有了这个插件可以做二次开发。开发自己的控制板自己的modbus控制卡总之mach3的所以变量都可以引用,然后通过串口,usb等输出给控制卡。在控制卡上可以做自己的控制算法。或是把mach3电脑端运算的数据给下位机,下位机只负责输出脉冲。把产生的.dll文件放在MACH3的plugs文件夹里激活它。就可以了。
3 k1 p* u! U9 A' j下面是mach3手轮的设计思想,给你研究。我去年研究后还做了个手轮的usb接口板手轮的编码器用最便宜点的2块钱的都没问题。你如果掌握了控制这个技术可以给你节约很多成本。而且可以灵活开发,也可以买板子优惠大家。现在本人主要是做脱机控制器现在精力都在这里。本来可以上传所以制作资料无奈老电脑打不开。更多资料到MACH3官网下载和参考。6 n: Z6 }0 j/ v3 D1 }3 M
7 h& G( q. X1 Y& R H q( ^
1 R% G7 r9 B; [ R C" O
关于Mach3 modbus有两种方式一种是通过Plug-in方式,这种方式要开发插件读取Modbus设备的数据,这种方式可以掌控整个Mach3的所有变量。这里不做说明。现在要说的是另外的一种方式——即非插件方式的自动查询方式(Autopoller)。这种方式会定时发送数据请求报文。Modbus设备把数据准备好给mach3读取。下图就是mach3 modbus 非插件方式的设设置。这种设置下地址进行了从映射+ d) j* T7 L) p# g9 K' r
6 H3 ~% h. `! u
. P6 y8 y. U- y+ @上图就是这种映射只要和modbus设备通信正常后就能轻松的通过TEST MODBUS得到modbus设备的数据。或是用vb来调试
, M; l! g. `7 m列如:A=GetInput(64) MsgBox"A="&A就能得到数据。- Y; ^6 ?# @+ }& A
这里是一个modbus手轮的宏程序。
& v2 k2 u2 x8 n' Macropump developed for Peach Hill MPG Set
- n, t. t" E) S v p% b7 @' Based on Hofmann MODIO Panel4 A5 j& k v( ]
' Objective to give Remote Pendant based, Axis, Step, Feed Over ride, Via Analogue inputs 1,2 &38 \- K: S" m) a S- v+ }* S2 s
' Step and Direction from Mechanical MPG Using I/P 6 &7
, h2 F. y" _- d& L' In addition Digital I/Ps for E-Stop,Digital Dig 0 normally closed push button
. X/ g! {2 ^/ p: n! l) i# X# q' Digital 1 & 2 via center off 3 pos switch Jog On/Off, and Shuttle Off/On A# n$ Z! O, _: y6 z- `- P2 y3 G: ]
' Jog mode thru Analog In 1
0 W% `1 [9 W$ m, z, m9 Q0 H) {' Jog step val thru Analog In 2, C1 |* d+ U$ r$ ^
' Jog speed over ride thru Analog In 3
4 ~5 \# j/ Q* @2 G' [$ I* x' E-Stop via Port 0 Pin 0 no Software required2 B" F. f5 T! T# s9 f+ |/ @ R
5 b7 M! b; r8 c: B- Z9 ~ MPGAxis = Getinput ( 64 ) 'analog input 1 on ModIO* z0 C$ f' V/ U+ _
Select Case MPGAxis
# T3 ?& i" y. \( l: xCase <85
; U$ [; ^: g F; h7 P" k 'do nothing0 n' s/ g, f* B4 p7 B1 I- j
State = 0
% z0 h5 O* J4 h+ A2 R SCase < 277 ' B5 D- }" a. l6 [
If GetOEMLED ( 14 ) = 0 Then 'If not set to continuous Jog Mode
& z7 p* A: j! [2 p7 c0 z% g( J DoOEMButton ( 276 ) 'Set jog to Continuous
* s# I& {$ N P) c1 v End If- g2 Z. A! H8 t* R
State = 1: w/ h' D- d: @9 o5 t5 q" [
Case <490
! Z6 X$ u# u& G9 |6 W& i If GetOEMLED ( 15 ) = 0 Then 'If not set to Step Jog Mode
$ t) T" `5 {+ T DoOEMButton ( 275 ) 'Set jog to Continuous% D, h1 b W/ C5 u1 T v g- a
End If
5 f. S. G% e. x State = 2
5 H; x' b R. e3 |7 T3 H1 ZCase <707
4 O$ u. T1 A Q If GetOEMLED ( 57 ) = 0 Then 'If not set to MPG Jog Mode/ B2 g0 F' \( w* `5 H" }7 j
DoOEMButton ( 306 ) 'Set jog to MPG
- P, h% ?+ [! t! E8 V7 T) v1 d End If, J; s( d( w8 ~, A0 i
If GetOEMLED ( 59 ) = 0 Then
5 F) Z6 {$ A( w4 e& L7 {" H DoOEMButton ( 185 ) 'Set MPG to Jog X5 i+ s2 b) z* p6 Z
End If0 I: l0 u L/ ~9 v5 R) L9 b4 t# x
State = 3 ! A" s; l8 t; U
Case <919
1 d' }# U& e8 m3 { If GetOEMLED ( 57 ) = 0 Then 'If not set to MPG Jog Mode& t8 v- A# X8 t5 ?% E2 z/ U ]
DoOEMButton ( 306 ) 'Set jog to MPG
- L" R' Z; K' M8 a6 T0 R End If
. J3 t: O8 O1 [3 A- ?! W& C" z If GetOEMLED ( 60 ) = 0 Then
0 {- x, W, n1 G% T: Z+ R% g DoOEMButton ( 186 ) 'Set MPG to Jog Y; `, @- U* @; _3 V8 K: {
End If/ q6 Q0 ]. b% V) g9 b* S, }) R& Y
State = 4
! U! ~3 R, y/ N# C9 ]0 NCase >919
+ f; x2 R L' w0 w* R8 ?+ @3 u If GetOEMLED ( 57 ) = 0 Then 'If not set to MPG Jog Mode
a" g3 {" P: g# C DoOEMButton ( 306 ) 'Set jog to MPG
6 k* p+ L7 K+ z' h4 o& U End If0 F; Q* I4 Q# V& D: L0 U
If GetOEMLED ( 61 ) = 0 Then
" l6 |8 B6 e, y, ~. M2 \' I0 I# |6 K1 j DoOEMButton ( 187 ) 'Set MPG to Jog Z- U6 Z( ]7 m4 |# F( K3 G
End If
2 p+ I* m2 x4 j7 q9 t" b State = 5
4 b8 q6 j7 a: SEnd Select
/ J, a2 r, D. s7 R' O3 S) m7 q1 _0 y2 S, J1 v$ M6 [% L: h
' Logic for setting Jog Ammounts thru Analog In 2
4 [5 C# ^, N, l/ Y% w, yJOGInc = Getinput ( 65 ) 'analog input 2 on ModIO
/ @/ ^' b1 O% l) c* w, a& o( @+ hSelect Case JOGInc
: k+ }$ j) i0 f9 C" i" f7 k, F4 ^+ [Case <2565 P) D- Z+ h$ ~* M& Z
If GetOEMLED ( 57 ) <> 0 Then 'If is set Jog Step6 g& v9 I6 T4 t4 a$ {6 s
DoOEMButton ( 265 ) 'Set Step to 1mm
% t) p3 s3 ?( M5 P1 s End If1 H, q8 r7 M$ w0 | J% H
Case <714
/ |0 I( \/ m& N) [ ^8 T$ Y+ r: G If GetOEMLED ( 57 ) <> 0 Then 'If is set Jog Step* k8 _+ k$ I" Z# F
DoOEMButton ( 266 ) 'Set Step to 0.1mm
6 A* [" K! H+ f- |( w9 c# w End If
4 M: s E" }- I( OCase >7144 `8 F8 h5 R: B& q
If GetOEMLED ( 57 ) <> 0 Then 'If is set Jog Step# j' q: L6 R6 d2 P0 [
DoOEMButton ( 267 ) 'Set Step to 0.01mm
) _" o: J: J) O0 h4 Q End If
% [2 D1 ^* L$ T3 @: LEnd Select + F6 p# }6 {' @& L/ t: C2 [1 x
' Setting Feedrate Over rate from Analogue 3
# _* K9 U! h4 W7 XOption Explicit1 d, `1 Z* w+ g! \3 o: R/ r8 j; R3 d
Dim fro As Integer, t3 k' V4 {3 j% X
1 g- S5 |, i( E( ~ q
Const Input3Sig = 18% b4 V7 J. G. _# i. H2 a; P
{& `7 z2 z1 z0 h7 nfro = GetInput ( 66 )
: G6 v: ?0 p# Pfro = (fro * 195.0)/1024.01 V$ {+ A3 L) R& M: j4 N
SetDRO 21, FRO+5
+ l" N4 N5 B) o2 S( e% U+ h. n; g'
/ \1 T( L4 _8 S' u, sRem DRO display On ModIO/ p% M* f& m# \* @! k5 ?, l6 B
'7 r+ v2 Q- |! H4 F, C- }1 b- p8 x h
Option Explicit0 Z1 m# j* R3 U4 \
Dim Display As String7 k* a7 s# g& C" ]- V Q, J- O
Dim SVal As String
% {# d2 \ r- P8 a% C* UDim iCount As Integer
7 n7 H/ _$ n& e* f% VDim iBase As Integer
# _/ A4 V+ ] v) y2 a! DDim strMode (6) As String
6 y; J& g# r+ W7 G# |; \. w' Q'
5 R; R( j. l/ f2 MConst slave = 6 ' Default config
7 f- G8 z+ d4 z. g3 {Const NoAxesToDisplay = 48 @2 } Y( ~! G9 T6 {4 B
If GetLED (1) Then strMode (0) = " inch" Else strMode (0) = " mm"'Added extra space
( ~, Z8 w9 W+ _7 UIf getOEMLED (16) Then strMode (1) ="<m/c>" Else strMode (1) =" "'coord sys Extra Space9 s* y2 m7 V, S0 M. ?+ p
If GetOEMLED (83) Then strMode (2) =" " Else strMode (2) = " NoJog". ~* y6 }% r% h# w
If GetLED (0) Then strMode (3) = " EStop" Else strMode (3) = " ". h& C" }: O4 z! T9 Q+ v* E! o
strMode (4) = " "
6 u4 ?" O, _9 S* f) F5 {2 j' pstrMode (5) = " "
a: a+ ~" F. Q% p* d" nDisplay =""
: l5 Y7 g6 j4 XFor iCount = 0 To NoAxesToDisplay - 1+ H C, r2 U, o+ O
SVal = Right (" " & Format (GetDro (iCount), "+0.0000;-0.0000"), 11)
& C% `) C& V/ N If iCount < 3 Then 'X, Y, Z) @7 d- q5 s+ ~6 ]+ C S+ ~
iBase = Asc ("X")- K# n3 K' l% z0 h% l9 |) w
Else 'A, B, C
+ f5 x3 V8 }8 {6 t iBase = Asc ("A") - 30 o# l- Y/ M0 w
End If1 j' s8 C! G' Q( n2 k
Display = Display & " " & Chr (iBase + iCount) & SVal & " " & StrMode (iCount)
5 B2 \- [, h1 b5 j' X& DNext iCount8 W0 j, S' N" Z8 Z5 Q7 [
SetModIOString (slave, 0, 0, Display)
8 h. g: F: `! R& Z2 o2 u- ?. d6 \6 a) d. y p
这个程序接收来自MODBUS的三个寄存器的输入用来改变(Jog mode thru Analog In 1
# c/ ^, t; ?3 f$ Q8 W' Jog step val thru Analog In 2 ' Jog speed over ride thru Analog In 3)。和DRO的输出给MODBUS手轮显示坐标值。
; M7 J* }4 p" n& Z( |! U, x这个和数控的宏程序不一样呀,是c语言的吧 |
|