Ercan Kiraz

Ercan Kiraz

  • NA
  • 4
  • 0

"NC code" text file parsing with C#

Aug 5 2009 4:25 AM
Hi falks! I need to parse a text file including an NC code which is a simple CNC tool motion determinator. In the file, each line shows the instantaneous positon of the tool tip. For example, the first line is X0 Y0 Z0 F200 and second line X10 Y10 Z10 this means that the tool is at (0,0,0) and will go to (10,10,10) with a speed of 200 m/min. This motion will take some time. Depending on the machine tool specificaion (user will enter), according to sampling time entered by user (0.1 second for example) succesive points will be determined between (0,0,0) and (10,10,10) one point in each 0.1 second. I have to parse the text file and give a list as an output showing the position of the tool at eah multiples of the sampling time. A sample NC code is: G1X0Y0Z0F200 X10.Y10.Z10. X21.Y16.Z8. Y10.Z5. G1 means linear motion. I will use only linear motion. Blanks between the characters are not important. However, to specify X position of tool as 10 it should be written as "X10." or "X10.0". X10 means 10*sampling time (e.g 10*0,1=1). Any caharacter which is not writen in a line means that it is the same as the last written form in earlier lineas. My output will be like X Y Z 0 0 0 0 0,1 1 1 1 0,2 2 2 2 0,3 . . . . . . . . . . . . . . . I need help!

Answers (1)