Hello Guest it is September 15, 2019, 01:44:54 PM

Author Topic: Mach 3 toolchange for dummies???  (Read 60468 times)

0 Members and 1 Guest are viewing this topic.

Re: Mach 3 toolchange for dummies???
« Reply #100 on: June 25, 2011, 06:02:47 PM »
Hi Peter,

I'm stuck at the point of referencing registers from Cubloc. My test code in Cubloc is:

Do
   If _D(66) = 1 Then
      High 40
   End If

   If _D(66) = 0 Then
      Low 40
   End If
Loop

Basically, turning on a relay when holding register 66 is set to 1. When I manually change holding register 66 through Test ModBus, the relay is set. However, when I use the following VBA code in Mach3:

Call SetModOutput (66,1)

The relay is not set- it seems like it's referencing a different register. My AutoPolling Options are set with Input Start Addresses of 1025 and 1536, and Output Start Address is 2048. I'm using this setup based on someone's post who had a similar project, but I have no idea what it means. Could you explain how the Start Addresses are used?

Do you have any idea where I'm going wrong?

Thanks,
Nate

Offline Hood

*
  •  25,849 25,849
  • Carnoustie, Scotland
    • View Profile
Re: Mach 3 toolchange for dummies???
« Reply #101 on: June 25, 2011, 07:07:08 PM »
It was mine you copied but mine is for the PLC I use so your address's may not be the same. The 1025 is decimal for 2001 Oct, 1536 dec for 3000 Oct (My analogue ins) and 2048 is dec for 4000 oct.

Hood
Re: Mach 3 toolchange for dummies???
« Reply #102 on: June 25, 2011, 09:35:12 PM »
Interesting Hood. sure it was your settings. long day...

What does the "oct" stand for? something to do with 8 bits?

Can you explain how the Start Addresses are used? in plain english?

Offline Hood

*
  •  25,849 25,849
  • Carnoustie, Scotland
    • View Profile
Re: Mach 3 toolchange for dummies???
« Reply #103 on: June 26, 2011, 03:19:11 AM »
Peter is the expert on this kind of stuff but my understanding is
My PLC works internally with Octal and Mach address is Decimal equivalent, so for example ModBus Inputs to my PLC ladder (OutPuts from Mach)  are written as B4000.0, B4000.1 etc in my ladder and ModBus outputs from my PLC are B2001,0, B2001.1 etc
If you know what registers your Cubloc uses and whether its octal or whatever then you can convert to decimal and that would be your start ranges in Mach.
Here is  a snippet from the lathes ladder to let you see, first is showing inputs to PLC from Mach, second showing Outputs from PLD to Mach..
Hood
« Last Edit: June 26, 2011, 03:31:03 AM by Hood »
Re: Mach 3 toolchange for dummies???
« Reply #104 on: June 26, 2011, 10:00:28 AM »
Re: Mach 3 toolchange for dummies???
« Reply #105 on: June 26, 2011, 11:40:46 AM »
keithmech-

Yes, I have studied it many times. Sadly, it pertains to TCP and not Serial...

Offline Hood

*
  •  25,849 25,849
  • Carnoustie, Scotland
    • View Profile
Re: Mach 3 toolchange for dummies???
« Reply #106 on: June 26, 2011, 11:47:18 AM »
You sure? seems to be serial but via the plugin.
Have you tried setting the start register as 0?
Hood
Re: Mach 3 toolchange for dummies???
« Reply #107 on: June 26, 2011, 02:42:10 PM »
Interesting...

He is using the plugin and serial setup. He mentions brains, but I dont see him using one.

I am using Version R3.042.040 was the "Plugin" added in later versions? I dont have it...

Offline Hood

*
  •  25,849 25,849
  • Carnoustie, Scotland
    • View Profile
Re: Mach 3 toolchange for dummies???
« Reply #108 on: June 26, 2011, 02:47:57 PM »
You do have the plugin, I told you before it comes with Mach ;)
Enable on Ports and Pins Modbus support and  Plugin support, restart Mach then from Functions config choose the serial modbus and the plugin will open.
Hood
Re: Mach 3 toolchange for dummies???
« Reply #109 on: June 26, 2011, 07:58:00 PM »
Hi Nate,

OK, To set up the Legacy Modbus for a remote PLC. This is for my toolchanger.
You will need to adjust the register numbers. I also use macro 999 that is run in the Mach3 init string to initialse my toolchanger variables, etc.

 The Mach3 Modbus interface should be configured. This is a config for my toolchanger (i,age below):

' ModIO Checkbox NOT checked
' First line of AutoPolling Input not checked - No inputs can go to Ports and Pins
' Second line of Inputs Checked, Slave = x, Start Regs = 1200, # Regs = 3
' First line of Autopolling Output not checked - no output Ports & Pins
' Second line of Output Slave = x, Start Regs = 1100, # Regs = 2




I set up modbus to read 3 registers  starting at address 1200. I also set up twp output registers starting at address 1100
Mach3 reads and writes the modbus data from buffers. There are 2 input buffers and 2 output buffers, organised as;
0-63       Input buffer 1
64-127   Input buffer 2
 
0-63      Output buffer 1
64-127   Output buffer 2
 
 
I use input buffer 2 and output buffer 2. This is because Mach3 maps some of buffer 1 to it's input and outputs signals. We don't want that.


When you want to read register 1200 you do it by;

value = GetInput (64)

This is because register 1200 was read into the 2nd input buffer starting at index 64



When you want to set register 1100 you do it by;

SetModOutput 64, tool ' output requested tool number

This is because register 1100 is written from the 2nd input buffer starting at index 64



So, you need to use GetInput(r) to read your registers, and SetModOutput r, v to write outputs.

I know that the commands GetInput and SetModOutput seem inconsistant in format but thats the way it is. 

I set up these constants so I can use the register names rather than the buffer index.

Const ChangerCurrPos  = 64      ' Inputs  1200 Current tool
Const ChangerCountReg = 65      ' 1201 Change done indicator
Const ChangerErrCode  = 66      ' 1202 Error code reply if problems

Const ChangerReqPos   = 64      ' Outputs 1100
Const ChangerInitReg  = 65      ' Outputs 1101


I hope this helps.

Cheers,

Peter.
----------------------------------------------------
Homann Designs
http://www.homanndesigns.com
email: peter at homanndesigns.com