1. ## automated mill

Hi
I have autoamted a conventional milling machine with gear motors with enkoders and vfd's.
i have made a program for this lathe that makes a circle, and this has worked quite nicely, but sometimes i get
some irregularities, and today i stumbled over the main culprit of the errors.
in the hmi i can set the start and stop degrees of the circle, for when i only want to mill a section of a circle.
when i start the program it sets the start location as the center of the circle and i calculate the x,y coordinates for positioning before the circle program starts.

the errors i get is when startdegrees are either 90,180,270,360
example for a startdegree of 90 and a circle radius of 50 i get an x value of 3,06 where it should be 0.
the y value is correct with 50.

am i missing something basic here maybe?

thanks,
Frank

2. ## Re: automated mill

can you post the exact code you use for converting degrees to radians. Are you using fixed or floating point arithmetic?

Where do your sin and cos functions come from? Are they in a library included with the mill controller software? Do you have a way of examining the values for x and y other than where the milling head starts? Do you have debugging facilities for your program?

short story is that your formulas are correct but the devil is always in the details.

Is your error consistent? Will you always get the same error with 90 deg. for example?

3. ## Re: automated mill

all mathematical functions i use are included in the programming software library. i use omron plc and program in structured text.
floating point
yes i continually monitor the values of x and y and calculate the angle relating to circle center.

yep, errors are consistent and only for the 4 extremities of the circle, if i have 89,999 degrees i get an accurate x,y posistion

Frank

4. ## Re: automated mill

Originally Posted by FrankAarre
all mathematical functions i use are included in the programming software library. i use omron plc and program in structured text.
floating point
yes i continually monitor the values of x and y and calculate the angle relating to circle center.

yep, errors are consistent and only for the 4 extremities of the circle, if i have 89,999 degrees i get an accurate x,y posistion

Frank
dollars to donuts it's the ATAN function that's glitching when fed zeros. Can you write a function, say my_deg_to_rad() that checks for those 4 cases and outputs the correct values for those 4 cases rather than calling deg_to_rad(), and calling deg_to_rad() if the input is not one of those 4 cases?

5. ## Re: automated mill

i wrote a small program to test just the math,
the ATAN() function doesn't have anything to do with the positioning where the error occurs, the deg_to_rad() function also seemed to give me the correct radian number
the ATAN() also seemed to produce the correct radian.
Looks like the SIN() and COS() functions that errs where the X and Y values should be 0, now that i know i can override this, but i don't like the idea that this error exist. I'm going to have a talk with the support at Omron about this.
i attached a pdf of functions included in library.

Frank

6. ## Re: automated mill

i calculate the x and y vectors as