Znaleziono 5 wyników

autor: k-m-r1
21 maja 2010, 23:50
Forum: Mach 2 / 3 / 4 (ArtSoft software)
Temat: macro wymiany narzędzia
Odpowiedzi: 13
Odsłony: 5816

ja radze jakis port wykorzystac

Kod: Zaznacz cały

Input/Output signals, Modbus I/O, a serial port and "foreign" ports 
[edit] 
Signals 

Scripts can access the input signals (both on parallel ports and defined virtually in response to keycodes) such as the state of home and limit switches and can control output signals. 
Function IsActive (sigNo as Integer) as Boolean
Function IsOutputActive (sigNo as Integer) as Boolean
Sub ActivateSignal (sigNo as Integer) 
Sub DeActivateSignal (sigNo as Integer) 

IsActive tests input signals. IsOutputActive tests output signals. They will return True if the signal is active (i.e. its LED would be lit on the Diagnostics screen). In other words this test is after the application of the Active Hi/Active Lo configuration of the signal hot a test of "0 volts" or "5 volts" on the signal's pin. 

ActivateSignal and DeActivateSignal similarly control the logical state of output pins. Mach3 will apply the Active Hi/Active Lo configuration to establish the electrical state required. 
Function IsSuchSignal (sigNo as Integer) as Boolean

Returns TRUE if the signal is enabled. It is used to avoid things like digitising if the machine has no probe input defined. 

For all these routines, the required signal is coded using the values defined on the VB Constants for Signal Names page. 
Sub SetTriggerMacro (MacroNo as Integer) 

Defines the number of a macro to be executed when an OEMTrigger is set (slightly unexpectedly on the Config>Set System Hotkeys dialog) to generate OEM code 301. This provides script execution without the requirement for a screen button as intermediary. 

For example if SetTriggerMacro 456 has been executed then a signal on any OEMTrigger configured to 301 will run the code in the file M546.M1S when activated. 
[edit] 
Modbus

Modbus is a standard (details here) serial protocol which allows control of a device such as a Programmable Logic Controller (PLC) or dedicated interface (like Peter Homann's ModIO). Typically thois expands the input/output capability of Mach systems for non-time-critical functions. 

Mach supports direct access to the registers of a Modbus device and will perform autopolling to map registers into ports and pins and to give simple access to the state of analog inputs and MPG counters. 
[edit] 
Direct input routines
Function FillFromCoil (slave as Integer, startAddress as Integer, nBytes as Integer) as Integer
Function FillFromStatus (slave as Integer, startAddress as Integer, nBytes as Integer) as Integer 
Function FillFromHolding (slave as Integer, startAddress as Integer, nBytes as Integer) as Integer
Function FillFromInput(slave as Integer, startAddress as Integer, nBytes as Integer) as Integer 


These routines will request a memory transfer from the current ModBus device's Coil, Status, Holding and Input registers. The requested number of bytes starting from the address specified will be transfered to an internal buffer in Mach. Routine returns a 1 if successful in its transfer. 


Function GetModWord(index as Integer) as Integer

This rotuine will return a "16 bit word". All data transfered from the device using the Fill routines, sends its information to a buffer. This routine will return a 16 bit word in the buffer selected by index. The first word is selected by index = 0 
Function ModGetInputBit(nBit as Integer) as Integer 

This routine will return the bit chosen by the index nBit as a one or a zero from the input buffer above. The first bit (i.e. most significant in the first word) is selected by nBit = 0 

Example: 
FillFromInput( 1, 102, 5 ) ' this will transfer 5 bytes to the buffer system from address 102 in the device.
i = ModGetInputBit (6) ' will get the 6th bit from that 5 byte array which you transfered


[edit] 
Polled input/output
Function GetInput (buffIndex as Integer) as Integer
Sub SetModOutput (buffIndex as Integer, value as Integer) 

Reads or writes a 16 bit word from/to the buffers updated by polling the Modbus. Access to these buffers is a memory access rather than an I/O transaction implied by the raw reading routines so these calls can be made as frequently as desired. 

buffIndex values 0 through 63 are single bits corresponding to the input and output pins of Port 0. The mapping of these to Modbus device registers is defined in the Config>Setup Modbus Control dialog. 

buffIndex values 64 through 127 are 16 bit words. These are mapped in Config>Setup Modbus Control dialog. For full details see Modbus in Mach. 
Sub SetModIOString (slave as Integer, xDisp as Integer, yDisp as Integer, Text as String) 


Writes the string on the ModIO LCD screen (if present). 

Notes: 

(a) xDisp must be an even number, i.e. writing must start at a 16 bit word boundary in the ModIO. 

(b) SetHomannString (xDisp as Integer, yDisp as Integer, Text as String) is a legacy routine equivalent to SetModIOString, with Slave = 1 
[edit] 
Serial port 

You can send bytes of raw data to a serial port. The port number (i.e. n in COMn) to be used and the baud rate for transmission is set in Config>Logic. RTS/CTS hardware flow control protocol will be used to control large volumes of data but this will not be normally required. Data is transmitted 8 data bits, 1 stop bit No Parity by a call of SendSerial. 
Sub SendSerial (chars as String) 

Example: to write the value of X DRO to an LCD display connected to the serial (RS232) port. 
Call SendSerial ("X-Axis = " & GetDRO (0)) 


[edit] 
Foreign ports 

Scripts can access ports on the PC which are additional to the one (or perhaps two) parallel port(s) defined in Config>Ports and Pins. These are accessed at the basic hardware port address level and you will have to be aware of the details of the individual port addresses, allocation of data and status bits etc. 
Function GetPortByte (pAddr as Integer) as Byte
Sub PutPortByte (pAddr as Integer, bData as Byte) 

This feature should be used with great care as, if misused, it can interfere with any peripheral on your system, including the hard-drive.
skoro piszesz makra to zrozumiesz
zrubzinnego portu sterowanie bez zabawy w jakies sygnałyzwrotne i magazynek jak coś siądzie to bedziesz miał dopiero cyrki
autor: k-m-r1
18 maja 2010, 22:56
Forum: Mach 2 / 3 / 4 (ArtSoft software)
Temat: macro wymiany narzędzia
Odpowiedzi: 13
Odsłony: 5816

a masz może wyjscie midi?

ale czy to nie utrudni g-code?
no i jak chcesz to zrobic bo mach odczyta 31 pozycje jako inne narzedzie z magazynku

najprosciej dokupic port lpt za 30 zł masz sledzia z kontrolerem

aha niekoniecznie pozycja bitowa 00000 odpada ja robie wyżłobienia i gdy następuje zmiana z 111111 na 00000 to w tym momęcie jest kolejne narzedzie robisz tajakby na tarczy rowki
autor: k-m-r1
18 maja 2010, 13:05
Forum: Mach 2 / 3 / 4 (ArtSoft software)
Temat: macro wymiany narzędzia
Odpowiedzi: 13
Odsłony: 5816

251mz, tak da sie sterowac ale po co?
moje pytanie co Tobie da sygnał że chłodziwo jest albo go nie ma
ja wiem że lepiej uproscic sterowanie chłodziwa niż kombinowac z programem

może dac czujnik gdziec niedaleko dyszy i zrobic zatrzymanie bądz dodatkową lampke informującom o braku chłodziwa w ten sposób dajesz sygnał np pauza do programu i nieruszy a lampka miga i wiesz że cos jest z chłodziwen
autor: k-m-r1
15 maja 2010, 07:05
Forum: Mach 2 / 3 / 4 (ArtSoft software)
Temat: macro wymiany narzędzia
Odpowiedzi: 13
Odsłony: 5816

251mz, to tylko nazwa nikt nie jest tu fahowcem piszmy jasno by każdy wiedział o co chodzi

M6End.m1s
Kod:
dim Z,z1,z2,z3
dim tool ; pare zmiennych
z = 70.72 do czego ta czesc

z3 = GetDRO(2) ; pobranie pozycji osi Z
z3 = z3 - 70 do czego te wyliczenia

Code "g0"
Code "g53 x1.56 y-31.84" ; ruch do pozycji XY czujnika dlugosci narzędzi
While IsMoving()
Wend ; pętla, która czeka az maszyna dojedzie

Code "G31 Z" & z3 & "f600" ; funkcja która bedzie jechała osią Z w dół aż do napotkania sygnału "DIGITIZE" ale nie wiecej niz do wartości Z3 wyliczonej wyzej
While IsMoving()
Wend

Z1 = GetVar( 2002 ) ' pobranie osi Z maszyny , ta metoda jest dokladniejsza poniewaz podczas zderzenia jest zapamietywana wartosc i nie zalezy od predkosci hamowania silnika po zatrzymaniu
Z2 = Z+z1 to działanie co ma na celu

message (z2) ; wyswietlenie wartosci na dolnym pasku wiadomosci pominoł bym to

Code "G0"
Code "G53 z0"
While IsMoving() ; podjechanie do góry Z maszyny Z0
Wend

call SetOEMDRO(42,z2) jesli tutaj zamiast z2 wpisze z1 to jest git ale wtedy jak ustawie zero materiału to masztna nie bierze tego pod uwagę
Tool = GetDRO( 24 ) ; wpisanie wyliczonej wartosci do rejestru dlugosci narzedzia
Code "G43 H"&Tool ; i wywolanie korekty dla tego narzedzia

Code "G53 z-1" tego nie rozumiem
While IsMoving()
Wend
Code "G53 z0"
While IsMoving()
Wend
autor: k-m-r1
13 maja 2010, 14:35
Forum: Mach 2 / 3 / 4 (ArtSoft software)
Temat: macro wymiany narzędzia
Odpowiedzi: 13
Odsłony: 5816

a kolega analizował krok po kroku?

bo na moje oko raz pracujesz w jednych współrzędnych raz w innych

zerknij na to GetOEMDRO (85) 'get ZPos Machine i z3 = GetDRO(2) ; pobranie pozycji osi Z

Wróć do „macro wymiany narzędzia”