Hello Guest it is April 25, 2024, 04:48:31 PM

Author Topic: analog output  (Read 1374 times)

0 Members and 1 Guest are viewing this topic.

analog output
« on: July 29, 2021, 02:13:41 PM »
i want use the analog output in mach to control one external axis
its only position axis so the precis in moment not so important ,only to arrive position
is some one try use mach encoder input and analog output to run such axis?
Re: analog output
« Reply #1 on: August 03, 2021, 01:00:51 AM »
??
Re: analog output
« Reply #2 on: August 04, 2021, 04:40:38 PM »
Hi,
Mach4 is not a feedback software solution. The time delay between the BoB (measuring the analogue voltage) and Mach receiving the data, plus the Mach
processing delay, plus the delay as the Mach output propagates through the motion buffer mean and 'around the loop delay' of at least several hundred
milliseconds......and that is just hopelessly too slow for any realistic feedback loop.

You might investigate how Mach does its Torch Height Control (THC). THC is generally considered a realtime feedback process however Mach has done it
using software alone and achieving bandwidths of about 10Hz. It seems to use PMC which is a much faster method of communication/output control.
Would 10Hz bandwidth be enough for your axis?

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: analog output
« Reply #3 on: August 04, 2021, 10:44:30 PM »
hi craig
i know,but in this case im not care about timing ,because its not axiss that have any interpolation with other axis
its just position device,so i can wait until its reach its position ,and i can slow the motion before i reach the position then stop
but how can i control the PMW without the use of the RPM S3 function i didnt see in any mach document
Re: analog output
« Reply #4 on: August 04, 2021, 11:58:54 PM »
Hi,

Quote
its just position device,so i can wait until its reach its position

That's the problem, you'll be waiting a very long time. Because of the feedback delay when the motor overshoots it will take
quite a while to turn-around, I doubt you'll ever get it to position.

You should use a step/direction capable motor as an out-of-band axis, then you can jog or otherwise program it to move to a given position
and does not require interpolation with other axes.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: analog output
« Reply #5 on: August 05, 2021, 12:24:42 AM »
this project its retrofit several old Europe cnc ,and that position axiss its only analog ,and i don't want replace the driver+ motor
about timing its not problem i can solve it in some ways,like delay in my action according feedback when close to the final position,also i can do script to learn the decll time so i can be more presize,this not the problem
the problem its very basic simple and i dont understand why any one from mach cant answer,what is command  how control the PMW output
there a tab with it on mach but no any instruction what and how to do
Re: analog output
« Reply #6 on: August 05, 2021, 02:20:45 AM »
Hi,
as far as I know there is only one PWM channel in Mach and that is for the spindle.

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

Offline smurph

*
  • *
  •  1,546 1,546
  • "That there... that's an RV."
    • View Profile
Re: analog output
« Reply #7 on: August 15, 2021, 05:21:11 PM »
You might investigate how Mach does its Torch Height Control (THC). THC is generally considered a realtime feedback process however Mach has done it
using software alone and achieving bandwidths of about 10Hz. It seems to use PMC which is a much faster method of communication/output control.
Would 10Hz bandwidth be enough for your axis?

Craig

As usual, Craig has a nose for what is needed.  :)

First you need an device that has analog outputs and has a Mach 4 plugin.  Most will implement the analog output as a register which means that you can used the API functions having to do with registers to control the output value. 

local hReg, rc
hReg, rc = mcRegGetHandle(inst, "device/reg/path")
rc = mcRegSetValue(hReg, 4095) -- full scale + on a unipolar 12 bit DAC.

Or you can do some more configuring in the analog tab of the configuration dialog and use the analog API functions.  All these functions do is a transformation so that you can operate on analog outputs in terms of voltages instead of raw values.  You accomplish this by mapping a analog register to an analog object.  On the Analog Output tab of the config dialog, set the device, the analog register, the numerator, denominator and the offset.  To set these values, you will have to know a bit about the DAC you are using, like how many bits of resolution and its voltage range.

For instance, say the DAC you are dealing with is -10v to +10v with 12 bit resolution.  Set

numerator = 20 (total voltage swing)
denominator = 4095 (12 bit max value)
offset = 2047 (basically, the zero volt value)

Now you can set the analog output in terms of voltage.  Say 5 volts.  The calculation is (volts / (numerator / denominator)) + offset.

(5 / (20 / 4096)) + 2047 = 3070.75  or the integer value of 3071.

so

rc = mc.mcAnalogOutputWrite(inst, 0, 5) -- Set analog object 0 to +5v

writes 3071 to the actual analog register.

The next thing required would be some position reference like an encoder register

Then you would read the encoder feedback and and implement a PID loop in the PLC script to control the analog voltage driving the servo.  The PID loop with PID values that you tune will make it work even though it is not real time and will compensate for the horrible time resolution.  It will not be fastest and it will not be real time coordinated with some other axis or event (impossible), but it will hit the numbers.  This is exactly how we do torch height control.  The only difference is we are using an arc voltage as a target instead of a position. 

People will say "But torch height control needs to be realtime" and I will say "Show me a motor or any motion system that can react instantly to any voltage change magnitude."  It doesn't have to be real time to be close enough to do the THC job. 

Now, I don't have time to write all of this for you, unfortunately.  My post is simply to sate that this can be done. 

Steve
« Last Edit: August 15, 2021, 05:24:46 PM by smurph »

Offline smurph

*
  • *
  •  1,546 1,546
  • "That there... that's an RV."
    • View Profile
Re: analog output
« Reply #8 on: August 15, 2021, 05:29:43 PM »
Also, you don't have to implement the PID in the PLC script if you want to implement it only in say an M code script.  That would take the relatively slow PLC script rate out of the equation.  Just hard loop the PID in the script (while loop).  Read the feedback, process the PID, write the analog value.  Repeat until you have hit your position. 

Steve
Re: analog output
« Reply #9 on: August 16, 2021, 01:31:39 AM »
steve thanks alot
ill read and test yours advise
i use pokeys ,do you think they analog output suport also -10 or i must add relay to convert polarity for reverse?