Machsupport Forum

Mach Discussion => Brains Development => Topic started by: iandmac on June 30, 2009, 12:29:08 AM

Title: Brain for encoder to DRO via modbus
Post by: iandmac on June 30, 2009, 12:29:08 AM
Hi all

I have an encoder on each of my mill axes connected to a cnc4pc M11 modbus board via serial to Mach3.  I am trying to write a brain to display each axis position in a DRO when my machine is under manual control.  This card decodes each encoder and uses three holding registers to store the counts.  I need to grab the values, scale them, then display them in some OEMDRO's.  I've put these DRO's on a separate screen which I can change to for manual control, leaving the standard Mach3 screens essentially unchanged for G-Code control.

My first working attempt for one axis only looked like:

MOD 64 (input) -> formula A * 0.01016  -> OEMDRO 1000

This works well and is very encouraging.  To be of any practical value however I need to be able to re-zero the DRO using an on-screen button.  I can't seem to find a way to capture the input value in the brain as an offset (when the button is pressed) and retrieve it for subtraction from the current value as it is sent to the DRO.  Any ideas for a solution or alternative approach welcome.

Regards, Ian
Title: Re: Brain for encoder to DRO via modbus
Post by: poppabear on July 04, 2009, 04:10:28 PM
Ian,

    I would suggest using the OEM "Encoder" DROs to start your value, then you can use the button functions that Zero these same encouder DROs, which in turn would zero your User DRO.

further, I would recommend using the Plugin Serial modbus as opposed to the old style modbus, with the plugin you can bring in each of the Modbus types from the M11.  I.e. cfg1 = 1000 outputs, dfc2 = 2000 inputs, 5000 = MPGs/encoders.

scott
Title: Re: Brain for encoder to DRO via modbus
Post by: iandmac on July 06, 2009, 09:32:11 PM
Thanks, I'll give it a go.  Ian