Identify the direction of arc's

  • Thread starter Thread starter bsharp
  • Start date Start date
  • Tags Tags
    Direction
AI Thread Summary
The content discusses the translation of APT code, which describes arcs, into G-code for CNC programming. It details the format of the APT commands, including "GOTO" for linear movements, "INDRV" for direction vectors, and "TLON,GOFWD" for arc specifications. The challenge lies in determining the direction of the arcs, which is not straightforward due to the relationship between the direction vector and arc points. A solution involves calculating the angle between the direction vector and the arc points, where the sign of the angle indicates the arc's direction (clockwise or counterclockwise). The author successfully developed a VB translator that converts APT code to G-code, allowing for the correct specification of arc direction using G02 and G03 prefixes based on the calculated angle. The process required significant learning and problem-solving, resulting in a custom G-code post processor that outperforms commercial alternatives.
bsharp
Messages
7
Reaction score
0
I am trying to translate a file from one format to another. The file I am trying to read from gives me the coordinates of arcs like this.

A three arc circle going clockwise:
GOTO / 0.80353, -0.60825, 0.75000, 0.000000, 0.000000, 1.000000
INDIRV/ -0.86603, 0.50000, 0.00000
TLON,GOFWD/ (CIRCLE/ 0.86603, -0.50000, 0.75000,$
0.12500),ON,(LINE/ 0.86603, -0.50000, 0.75000,$
0.92853, -0.39175, 0.75000)
INDIRV/ 0.86603, -0.50000, 0.00000
TLON,GOFWD/ (CIRCLE/ 0.86603, -0.50000, 0.75000,$
0.12500),ON,(LINE/ 0.86603, -0.50000, 0.75000,$
0.97428, -0.56250, 0.75000)
INDIRV/ -0.50000, -0.86603, 0.00000
TLON,GOFWD/ (CIRCLE/ 0.86603, -0.50000, 0.75000,$
0.12500),ON,(LINE/ 0.86603, -0.50000, 0.75000,$
0.80353, -0.60825, 0.75000)
The same three arc circle going counterclockwise:
GOTO / 0.80353, -0.60825, 0.75000, 0.000000, 0.000000, 1.000000
INDIRV/ 0.86603, -0.50000, 0.00000
TLON,GOFWD/ (CIRCLE/ 0.86603, -0.50000, 0.75000,$
0.12500),ON,(LINE/ 0.86603, -0.50000, 0.75000,$
0.92853, -0.39175, 0.75000)
INDIRV/ -0.86603, 0.50000, 0.00000
TLON,GOFWD/ (CIRCLE/ 0.86603, -0.50000, 0.75000,$
0.12500),ON,(LINE/ 0.86603, -0.50000, 0.75000,$
0.75777, -0.43750, 0.75000)
INDIRV/ -0.50000, -0.86603, 0.00000
TLON,GOFWD/ (CIRCLE/ 0.86603, -0.50000, 0.75000,$
0.12500),ON,(LINE/ 0.86603, -0.50000, 0.75000,$
0.80353, -0.60825, 0.75000)

The “GOTO” command is a linear move followed by it’s cords “X,Y,Z”
The “INDRV” is from what I can figure is a direction vector “X,Y,Z”?
The TLON,GOFWD line specifies the arc center cords “X,Y,Z”
The line after specifies the radius “0.12500” and arc center cords
The next line specifies the ending cords “X,Y,Z”.

Some how I need to determine the direction of each arc. I have tried comparing the starting and ending cords but it will not always work.
If the arc is 360 deg the “INDRV” cord will be positive or negative the corresponding arc center cord.
I think I have to calculate the direction from the “INDRV” based on the starting or ending cords some how.
If you look at the last arc in each example the only thing different is the starting cords “the ending cords from the previous arc”. If some one could help me out with this it would be great.
 
Computer science news on Phys.org
Since not one sole answered this ugly question. And after asking a thirty year mechanical engineer veteran and also a 4 year degree physics major.
This is how I solved it on my own. Once plotted out on a graph it is a lot more obvious. Just calculate the angle from the Direction Vector to the center of the arc. This will basically be two vectors. One being the direction vector start point to arc start point and the second as arc start to arc center. Once you can reliably calculate the angle it will be a negative value for one direction and a positive value for the opposite.

http://www.vb-helper.com/howto_find_angles.html"
Basically the sign of the solution will give you the direction.
It also works regardless of quadrant position in Cartesian space.
 
Last edited by a moderator:
Looks like BasicA... But no, it's VB.
 
mugaliens said:
Looks like BasicA... But no, it's VB.

The "three arc circle" code posted above is actualy APT
http://en.wikipedia.org/wiki/APT_%28programming_language%29"

I wrote a translator in VB to convert APT code to G code http://en.wikipedia.org/wiki/G-code.
The problem I was having with the arc direction was that in G code the direction is specified in a prefix of ether G03 "cw" or G02 "ccw" and in APT the arc direction is specified by a direction vector's relationship with the arc points. so to translate the "APT" arc direction vector to the "G code" equivalent prefix. I needed to calculate the angle between the direction Vector and the Arc points and the sign of the angle will determine the direction "cw or ccw". With this it is easy in VB to say "If arcsign <0 than gcode = G03" or something like that.
It took a lot of learning and turning of some pretty rusty gears but I got it and now I am proud to say I have a G code post processor that I wrote myself and is faster and more precise than any commercial one out there.
 
Last edited by a moderator:
Sorry if 'Profile Badge' is not the correct term. I have an MS 365 subscription and I've noticed on my Word documents the small circle with my initials in it is sometimes different in colour document to document (it's the circle at the top right of the doc, that, when you hover over it it tells you you're signed in; if you click on it you get a bit more info). Last night I had four docs with a red circle, one with blue. When I closed the blue and opened it again it was red. Today I have 3...
Thread 'ChatGPT Examples, Good and Bad'
I've been experimenting with ChatGPT. Some results are good, some very very bad. I think examples can help expose the properties of this AI. Maybe you can post some of your favorite examples and tell us what they reveal about the properties of this AI. (I had problems with copy/paste of text and formatting, so I'm posting my examples as screen shots. That is a promising start. :smile: But then I provided values V=1, R1=1, R2=2, R3=3 and asked for the value of I. At first, it said...
Back
Top