Hello Guest it is March 28, 2024, 05:33:16 AM

Author Topic: input as a dro display (not closed loop),  (Read 3949 times)

0 Members and 1 Guest are viewing this topic.

input as a dro display (not closed loop),
« on: September 20, 2016, 03:53:07 PM »
I’m trying to use encoder input as a dro display (not closed loop), where can I do the scaling. Also I’m getting conflict with mach4 overriding the register at zero. Also how can I make a button to zero the dro display?
Thanks a million
Re: input as a dro display (not closed loop),
« Reply #1 on: September 21, 2016, 09:45:10 PM »
What plug-in and motion device are you using?

Whether you can alter the encoder value by editing a DRO depends on how the plug-in implements the encoder functionality.  For example, the PMDX-SmartBOB plug-in presents a register specifically for displaying in a DRO.  And if that encoder does not have an index, you can change the value by editing the DRO.  If the encoder DOES have an index, the plug-in will not allow you to change the DRO value as it is determined by the index pulse and amount of rotation.

Bob
Re: input as a dro display (not closed loop),
« Reply #2 on: September 22, 2016, 05:04:53 AM »
Hi,
really interested by Bob_at_pmdx post.

One of the reasons that I bought Mach4 was that I was struggling to achieve the functionality
I wanted from an encoder, amongst other things not being able to reset the raw count.

In the Mach4 configuration screen there is an MPG tab which I assumed I could use as an
encoder input. Bobs comment suggests that the motion plug confers this ability. Can either
be used and what are the logical differences between them?

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: input as a dro display (not closed loop),
« Reply #3 on: September 22, 2016, 02:51:50 PM »
If the motion device (or I/O device) supports encoder interfaces, then the plug-in for that device will register one or more encoder devices with Mach4.  It does this by creating a Mach4 register of type "encoder".  That register can then be mapped to a DRO, and/or mapped to an MPG (this is what the Mach4 config "MPG" tab is for).  You can also write Lua scripts to read (and sometimes write) that encoder register to do whatever custom thing you want.  Note that you should only map an encoder to an MPG if you want to use that encoder to jog the machine.  If you want to do anything else with the encoder (like, for example, create a Lua script to allow it to change the feed rate override), DO NOT map it to an MPG.

You can find out what registers your device plug-in provides by going to the "Diagnostics" menu and selecting "RegFile" (presuming that you have the "RegFile" plug-in enabled).  That will show you all of the plug-ins.  If you click on the "+" next to the plug-in to expand it, you will see all the registers that the plug-in exposes to Mach4.

A word of caution when mapping an encoder to an MPG.  By default, if there is an MPG defined, Mach4 will use that to jog the "current" axis (determined by calls to mc.mcMpgSetAxis(), and set to the X axis by default on startup).  Whenever Mach4 is enabled, changes in the encoder count will cause motion based on the change in encoder counts.  If the encoder is configured to reset it's count to zero once per revolution, that will cause *LOTS* of motion as Mach4 will see the count go from, say, 99 to 0 for a 100 count encoder.  That looks like a huge jog request.  Likewise, if you change the encoder value via a DRO while Mach4 is enabled, that will also cause Mach4 to try and jog the current axis.

The plug-in determines whether to allow DRO edits to actually change the encoder count.  I had to explicitly add code to the PMDX-SmartBOB plug-in to allow that feature.  I have no idea if any other plug-ins provide this functionality.  Likewise I also added code to prevent changes to the encoder count from the DRO if the encoder is mapped to an MPG *AND* if Mach4 is enabled (see caution above). 

Bob
Re: input as a dro display (not closed loop),
« Reply #4 on: September 22, 2016, 08:58:39 PM »
im using mach 4 with ess, i have put a dro display on my screen and it works but the counts are not correct . but i do not know how to scale or zero it i need to know how and where to put a script eg dro## value = ess encoder divided by 2000
regarding mpg,never use it as encoder input as it causes the axis to look at it for closing the loop giving crazy movement
Re: input as a dro display (not closed loop),
« Reply #5 on: September 22, 2016, 09:32:36 PM »
im using mach 4 with ess, i have put a dro display on my screen and it works but the counts are not correct . but i do not know how to scale or zero it i need to know how and where to put a script eg dro## value = ess encoder divided by 2000
I would *guess* that the DRO is showing raw encoder counts, but that is just a guess as I don't know how the ESS plug-in handles encoders.  The Lua code to scale the encoder value should probably go in the PLC script so that it runs periodically (search these forums if you don't know where that is).   There are lots of messages about how to do things in scripts so there are probably examples or reading registers and writing to DROs.  Check in the "Mach4 Toolbox" sub-forum.

How to do this with an ESS I have no idea.  Someone here might chime in, or you could/should try posting on the Warp9 support forums.

regarding mpg,never use it as encoder input as it causes the axis to look at it for closing the loop giving crazy movement
Mach4 does not have *any* closed-loop control capability built in to the core.  What *will* happen if you map an encoder to an MPG is that the Mach4 core will attempt to translate changes in encoder counts to jog motion for the currently selected jog axis.  Depending on the MPG configuration parameters that jog motion can be quite erratic.  And as I mentioned earlier, should the encoder wrap from max count to zero it will queue up a whole bunch of motion.

Bob
Re: input as a dro display (not closed loop),
« Reply #6 on: September 22, 2016, 09:37:35 PM »
thanks
Re: input as a dro display (not closed loop),
« Reply #7 on: September 23, 2016, 02:40:55 AM »
Hi All,
your posts have been most informative and I have a much clearer understanding
of what to do to achieve the result.

Thanks
Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'