Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: Tony Bullard on January 31, 2012, 04:03:39 PM

Title: Unstable analog inputs
Post by: Tony Bullard on January 31, 2012, 04:03:39 PM
I’m using two 10K pots for analog inputs through a ModIO for FRO and Speed % DROs The DROs float around about + and – 2% from set point. Is there a way to buffer or smooth out the inputs. I could write a macro with 100 “deadspots” but that doesn’t seem to be the way to go. Any help would be appreciated.

Thanks,

Tony
Title: Re: Unstable analog inputs
Post by: Peter Homann on January 31, 2012, 04:23:52 PM
Hi,
It is most likely from ripple in the power supply. The best way to deal with it is to filter it in software as you suggest.
Also think about putting in a +/- 5% dead band at the 100% point

Cheers,

Peter
Title: Re: Unstable analog inputs
Post by: Tony Bullard on January 31, 2012, 04:36:09 PM
Thanks Peter,

I'm using the +5V from the ModIo. Could I use an external power supply say from the PC and have less ripply? How about a good stand alone power supply?

Thanks,

Tony
Title: Re: Unstable analog inputs
Post by: Tony Bullard on January 31, 2012, 04:41:36 PM
Will the floating feed rate overwork Mach while running a program?

Thanks,
Tony
Title: Re: Unstable analog inputs
Post by: Peter Homann on February 01, 2012, 03:33:37 PM
Hi Tony,

No it won't be an issue as mach processes it regardless of whether it changes or not.  Most put a deadband in though. It just means that you don't have to be so spot on with the positioning of the knob.

Cheers,

Peter.
Title: Re: Unstable analog inputs
Post by: Tony Bullard on February 02, 2012, 08:28:14 AM
Hi Peter,

I was concerned that during a machining operation Mach might not keep up with calculating the vector velocity components of a multi axis feed twenty times a second.

Here’s the code I used in a macropump to buffer it a little. It is pretty jittery so I had to use wide deadbands.

Sub FRO()

a = getinput(64)
b= Fix(a/6.8267)   ‘150%
If b < (GetVar(607)-2.5) Or b > (GetVar(607)+2.5) Then
SetVar(607,b)
If GetVar(607) < 103 And GetVar(607) > 98 Then
SetDro(21,100)
DoOemButton(1014) 'reset overide
Exit Sub
End If
SetDro(21,GetVar(607))
End If
End Sub

Thanks for all your help.

Tony

Title: Re: Unstable analog inputs
Post by: stirling on February 02, 2012, 09:51:46 AM
Hi Tony - if I've understood your requirement properly you want to "band" your input?

x = int(y / z) * z

x will be y banded into divisions of z with an automatic dead zone at the top. Season to taste.

Ian
Title: Re: Unstable analog inputs
Post by: Tony Bullard on February 02, 2012, 10:49:46 AM
Thanks Ian,

One problem is, as I see it, with distinctive bands is that if the set point is near the edge of the band the output will be hunting between the two bands.
With “If b < (GetVar(609)-2.5) Or b > (GetVar(609)+2.5) Then
SetVar(609,b)” I was trying to get a fixed width band with variable location. This keeps sampling and keeping the output in the center of the band. I realize the “2.5” doesn’t do much good with the integers. Oops.

I probably misunderstood your formula. Relating to mine would it be:
b  =  INT (a/6.8267)* ?? EDIT: now that I look at it again doesn't (Y/Z)*Z = Y?

What I’m trying to avoid is the feed rate hunting while machining in FRO

I do like your way of thinking.

Tony

Title: Re: Unstable analog inputs
Post by: stirling on February 02, 2012, 01:16:00 PM
I see what your saying - I'll have a think...

But meanwhile...
now that I look at it again doesn't (Y/Z)*Z = Y?
Yes indeed it does BUT... INT(Y/Z)*Z does not ALLWAYS = Y and that's why it bands ;)

Ian
Title: Re: Unstable analog inputs
Post by: Tony Bullard on February 02, 2012, 02:07:14 PM
Yeah but if Y = analog input then it is always an integer, Right?

Then (Y/Z)*Z = Y = INT(Y/Z)*Z

Only when Y is not an integer will (Y/Z)*Z  not = INT(Y/Z)*Z

Just gives me something else to think about.
Thanks,
Tony


Title: Re: Unstable analog inputs
Post by: stirling on February 02, 2012, 04:25:35 PM
Nope... You're thinking INT(Y/Z*Z) but what we're doing is INT(Y/Z) * Z two vaaary difrant sings - simples!

(10/5)*5=10 ....... INT(10/5)*5=10 ............ INT(10/5) = 2 ........ 2*5 = 10
(11/5)*5=11 ....... INT(11/5)*5=10 ............ INT(11/5) = 2 ........ 2*5 = 10 etc.
(12/5)*5=12 ....... INT(12/5)*5=10
(13/5)*5=13 ....... INT(13/5)*5=10
(14/5)*5=14 ....... INT(14/5)*5=10
(15/5)*5=15 ....... INT(15/5)*5=15
(16/5)*5=15 ....... INT(15/5)*5=15

Ian
Title: Re: Unstable analog inputs
Post by: Tony Bullard on February 02, 2012, 04:39:58 PM
Thank you, I'll play with that a little. I like it.

Tony
Title: Re: Unstable analog inputs
Post by: stirling on February 03, 2012, 04:47:20 AM
Hi Tony - just for the fun of it...

a = getinput(64)
if ((a mod 6) > 0) then
  setDRO(21, INT(a / 6) + 45)
end if

This will map your 10bit ADC input to give you FROs in the range 45% to 215% with the input value having to change by a factor of 6 to change the output. There's a deadzone between each set to suppress jitter.

I understand why you chose 6.827 to give you EXACTLY 150% range but it doesn't really bring anything to the party and integer values allow the modulus to give you the deadzones. You can widen the deadzones by increasing the >0 to >1 or 2 but of course anything more than 4 and you'll have nothing but deadzone!

Ian
Title: Re: Unstable analog inputs
Post by: Tony Bullard on February 03, 2012, 07:19:49 AM
Thanks Ian,

I've never worked with modular arithmetic but it will give this old man something to do today. LOL. I guess I'll start here: http://www.math.rutgers.edu/~erowland/modulararithmetic.html.

Tony
Title: Re: Unstable analog inputs
Post by: stirling on February 03, 2012, 11:17:43 AM
 :)