View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Lumpy Lumpy is offline
external usenet poster
 
Posts: 4
Default Looping question

I need to turn spreadsheet data into a .txt file for running a computerized
saw. I am trying to get a single board cut into multiple pieces.

The boards going in are all the same length, in this example 585mm long.
They get cut into pieces of varying lengths. If the pieces are 58mm, then
one board might get cut into 10 pieces. If they are 290mm, then one board
would get cut into two pieces. I've already optimized the desired cutting
list to figure out how to cut them most efficiently and exported that data
into a spreadsheet.

The spreadsheet looks something like this:
Board Piece Length
1 104 123.4
1 105 456.7
2 106 582.1

This is a reduced dataset to illustrate the problem. In this example 2 raw
boards each 585mm long need to be cut into 3 differetn pieces. The first
board gets cut into pieces 104 and 105. The second board gets cut into piece
106.

The text file I need for this looks something like this:
G28
G1 X123.4 M6
G1 X456.7 M6
G28
G1 X89.0 M6
G28

Line 1
Where "G28" means return the carriage to the home position.

Line 2
G1 = "move the carrier" Xnumber means "in the x direction, this number of
units" and M6= "wait for the operator to hit the next button" (the operator
will use the saw to cut the wood off at the 123.4 length and then hit the
"next piece" button)

Line 3
same as Line 2 but for a different length piece

Line 4
Return the carriage to the home position again and wait for the operator to
load the next board and hit the "next piece" button again. The carrier needs
to return to the home position after each board is cut into its requsite
pieces.

Line 5
Move and wait

Line 6
Return home and wait.

I need to do this for a much larger dataset where some boards can get cut
into any number of pieces, depending on how the optimization process grouped
them.

I think I need some sort of overall looping structure to keep going until
the list is over and another looping structure inside it to loop until the
board number changes, then insert a G28 M6 line and start over.

I hope it an easy request, thanks for any help.