Tim's Folded Card Box

by Palingenesis in Craft > Gift Wrapping

4967 Views, 73 Favorites, 0 Comments

Tim's Folded Card Box

Folded_Box_001.png

This is a little program I wrote to create folded card boxes of any size.

I recently got myself a small laser that will cut thin card, so decided to make this so that I could easaly make boxes for all my trinkets, bits and pieces.

Handy for little gifts also.

Supplies

Folded_Box_002.png
Folded_Box_004.png

Pen (XY) Plotter with Laser that is controlled with G-Code. (Can use pen and cut drawn pattern with scissors).

Tim's XY Stepper Controller.

The Laser

Folded_Box_003.png

The laser I got was advertised as 5.5W. from eBay.

I have learned that the advertised power is usually the highest number the seller can find in the data sheet that accompanies the item. Bigger numbers sell products.

There is: Input Power and Laser Output Power.

The Input Power is the power it uses from the power supply to run the laser module.

The Laser Output Power is the Power/Energy produced on a target by the light from the Laser module.

Also, I have learned that some cloned laser modules are over powered, what I mean is they are boosted over the laser diodes normal working power. This reduces the half-life of the laser. Knowing this, I try not to use a diode laser at its full power.

The software I have written to create the G-Code to produce the pattern of the Folded Box uses modified M03 and M05 commands to control the laser power. There is an "L" command within the M03 command to set the power level.

G-Code

The G-Code my software produces uses the following Commands:

G00 X<value> Y<value> F<value>

G01 X<value> Y<value> F<value>

G02 X<value> Y<value> I<value> J<value> F<value>

G00 Z<value>

The Z value is only used if using a pen in a plotter (or 3D Printer) that uses a stepper motor to control a pens height. It is sent as a command on it's own.

X, Y, Z, I and J are metric values in millimetres (mm).

F value is millimetres per. minute. (mm/min)

The laser power commands are as follows:

On = M03 L<value> The value is a number 0 to 255 which sets the power level. (255 = 100%)

Off = M05

The machine, XY plotter, 3D Printer needs to understand these codes, if not you can edit the script in any text editor using find and replace, for the commands your machine understands.

For example, if your machine has GRBL firmware installed and has been configured for laser, the the "L" used in the M03 commands needs changing to "S".

Semi-colon " ; ", open and closed brackets " ( ) " are use for comments. Anything after a Semi-colon on a line or between the brackets should be ignored by the software sending the script.

About G-Code

G-Code is quite an old type of script. Early machines that used it did not have variable speed spindles, lasers or servos. So todays flavours of G-code may differ slightly when it coms to controlling tools attached to the machine. Depending on who writes the firmware for a machine, decides what new commands to add to control new tools added to a machine. It looks like grbl went for the "S" as in spindle speed, I went for "L" for level, as my firmware on my plotter controls spindle, servo and laser with the same command.

Other machines may need variations on this.

Typical G-Code Script

;Created using Tim's Stepper XY Controller
;22/11/2021 00:00:00
;Creat G-Code - FOLDED BOX
;Width		= 35
;Height		= 10
;Length		= 35
;Thickness	= 0.25
;Fold Power	= 175
;Fold Speed	= 550
;Fold No. Passes	= 1
;Cut Power	= 175
;Cut Speed	= 350
;Cut No. Passes	= 2
G21 ;Set to mm
G90 ;Set to Absolute positioning
M05 L0 P0 (Up / off)
(Set Feeds)
G00 X0.0 Y0.0 F6000 ;Home Also sets G00 Speed
G01 X0.0 Y0.0 F350 ;Home Also sets G01 Speed
(Mark Fold Lines)
M05 L0 P0 (Up / off)
G00 X21.5 Y45.75 F6000
M03 L175 (Down / on)
G01 X21.5 Y10.25 F550
M05 L0 P0 (Up / off)
G00 X58.5 Y45.75 F6000
M03 L175 (Down / on)
G01 X58.5 Y10.25 F550
M05 L0 P0 (Up / off)
G00 X11.5 Y45.75 F6000
M03 L175 (Down / on)
G01 X11.5 Y10.25 F550
M05 L0 P0 (Up / off)
G00 X68.5 Y45.75 F6000
M03 L175 (Down / on)
G01 X68.5 Y10.25 F550
M05 L0 P0 (Up / off)
G00 X11 Y45.5 F6000
M03 L175 (Down / on)
G01 X11 Y10.5 F550
M05 L0 P0 (Up / off)
G00 X69 Y45.5 F6000
M03 L175 (Down / on)
G01 X69 Y10.5 F550
M05 L0 P0 (Up / off)
G00 X22 Y10.5 F6000
M03 L175 (Down / on)
G01 X58 Y10.5 F550
M05 L0 P0 (Up / off)
G00 X22 Y45.5 F6000
M03 L175 (Down / on)
G01 X58 Y45.5 F550
M05 L0 P0 (Up / off)
G00 X22 Y10.125 F6000
M03 L175 (Down / on)
G01 X22 Y0.5 F550
M05 L0 P0 (Up / off)
G00 X22 Y45.875 F6000
M03 L175 (Down / on)
G01 X22 Y55.5 F550
M05 L0 P0 (Up / off)
G00 X58 Y10.125 F6000
M03 L175 (Down / on)
G01 X58 Y0.5 F550
M05 L0 P0 (Up / off)
G00 X58 Y45.875 F6000
M03 L175 (Down / on)
G01 X58 Y55.5 F550
M05 L0 P0 (Up / off)
G00 X22.5 Y55.5 F6000
M03 L175 (Down / on)
G01 X57.5 Y55.5 F550
M05 L0 P0 (Up / off)
G00 X22.5 Y90.75 F6000
M03 L175 (Down / on)
G01 X57.5 Y90.75 F550
M05 L0 P0 (Up / off)
G00 X22.5 Y90.5 F6000
M03 L175 (Down / on)
G01 X22.5 Y55.75 F550
M05 L0 P0 (Up / off)
G00 X57.5 Y90.5 F6000
M03 L175 (Down / on)
G01 X57.5 Y55.75 F550
M05 L0 P0 (Up / off)
G00 X21.75 Y101 F6000
M03 L175 (Down / on)
G01 X21.75 Y91 F550
M05 L0 P0 (Up / off)
G00 X58.25 Y101 F6000
M03 L175 (Down / on)
G01 X58.25 Y91 F550
(Cut Hole 1)
M05 L0 P0 (Up / off)
G00 X22 Y35.875 F6000
M03 L175 (Down / on)
G01 X22.25 Y35.875 F350
G01 X22.25 Y20.125 F350
G01 X22 Y20.125 F350
G01 X22 Y35.875 F350
(Cut Hole 2)
M05 L0 P0 (Up / off)
G00 X57.75 Y35.875 F6000
M03 L175 (Down / on)
G01 X58 Y35.875 F350
G01 X58 Y20.125 F350
G01 X57.75 Y20.125 F350
G01 X57.75 Y35.875 F350
(Cut Outside)
M05 L0 P0 (Up / off)
G00 X73.75 Y0.5 F6000
M03 L175 (Down / on)
G01 X6.25 Y0.5 F350
G01 X6.25 Y10.125 F350
G01 X22 Y10.125 F350
G01 X22 Y10.5 F350
G01 X21.5 Y10.25 F350
G01 X11.5 Y10.25 F350
G01 X11 Y10.5 F350
G01 X1 Y10.5 F350
G01 X1 Y20.125 F350
G01 X-0.25 Y20.375 F350
G01 X-0.25 Y35.625 F350
G01 X1 Y35.875 F350
G01 X1 Y45.5 F350
G01 X11 Y45.5 F350
G01 X11.5 Y45.75 F350
G01 X21.5 Y45.75 F350
G01 X22 Y45.5 F350
G01 X22 Y45.875 F350
G01 X6.25 Y45.875 F350
G01 X6.25 Y55.5 F350
G01 X22.5 Y55.5 F350
G01 X22.5 Y56 F350
G01 X22.230 Y56.027 F350
G02 X17.5 Y61.251 I0.520 J5.224 F350
G01 X17.5 Y84.999 F350
G02 X22.230 Y90.223 I5.25 J0 F350
G01 X22.5 Y90.25 F350
G01 X22.5 Y90.75 F350
G01 X21.75 Y91 F350
G01 X14.748 Y91 F350
G02 X12.353 Y94.420 I0 J2.545 F350
G02 X21.75 Y101 I9.397 J-3.420 F350
G01 X58.25 Y101 F350
G02 X67.647 Y94.420 I0 J-10 F350
G02 X65.252 Y91 I-2.395 J-0.875 F350
G01 X58.25 Y91 F350
G01 X57.5 Y90.75 F350
G01 X57.5 Y90.25 F350
G01 X57.770 Y90.223 F350
G02 X62.5 Y84.999 I-0.520 J-5.224 F350
G01 X62.5 Y61.251 F350
G02 X57.770 Y56.027 I-5.25 J0 F350
G01 X57.5 Y56 F350
G01 X57.5 Y55.5 F350
G01 X73.75 Y55.5 F350
G01 X73.75 Y45.875 F350
G01 X58 Y45.875 F350
G01 X58 Y45.5 F350
G01 X58.5 Y45.75 F350
G01 X68.5 Y45.75 F350
G01 X69 Y45.5 F350
G01 X79 Y45.5 F350
G01 X79 Y35.875 F350
G01 X80.25 Y35.625 F350
G01 X80.25 Y20.375 F350
G01 X79 Y20.125 F350
G01 X79 Y10.5 F350
G01 X69 Y10.5 F350
G01 X68.5 Y10.25 F350
G01 X58.5 Y10.25 F350
G01 X58 Y10.5 F350
G01 X58 Y10.125 F350
G01 X73.75 Y10.125 F350
G01 X73.75 Y0.5 F350
M05 L0 P0 (Up / off)
(Cut Hole 1)
M05 L0 P0 (Up / off)
G00 X22 Y35.875 F6000
M03 L175 (Down / on)
G01 X22.25 Y35.875 F350
G01 X22.25 Y20.125 F350
G01 X22 Y20.125 F350
G01 X22 Y35.875 F350
(Cut Hole 2)
M05 L0 P0 (Up / off)
G00 X57.75 Y35.875 F6000
M03 L175 (Down / on)
G01 X58 Y35.875 F350
G01 X58 Y20.125 F350
G01 X57.75 Y20.125 F350
G01 X57.75 Y35.875 F350
(Cut Outside)
M05 L0 P0 (Up / off)
G00 X73.75 Y0.5 F6000
M03 L175 (Down / on)
G01 X6.25 Y0.5 F350
G01 X6.25 Y10.125 F350
G01 X22 Y10.125 F350
G01 X22 Y10.5 F350
G01 X21.5 Y10.25 F350
G01 X11.5 Y10.25 F350
G01 X11 Y10.5 F350
G01 X1 Y10.5 F350
G01 X1 Y20.125 F350
G01 X-0.25 Y20.375 F350
G01 X-0.25 Y35.625 F350
G01 X1 Y35.875 F350
G01 X1 Y45.5 F350
G01 X11 Y45.5 F350
G01 X11.5 Y45.75 F350
G01 X21.5 Y45.75 F350
G01 X22 Y45.5 F350
G01 X22 Y45.875 F350
G01 X6.25 Y45.875 F350
G01 X6.25 Y55.5 F350
G01 X22.5 Y55.5 F350
G01 X22.5 Y56 F350
G01 X22.230 Y56.027 F350
G02 X17.5 Y61.251 I0.520 J5.224 F350
G01 X17.5 Y84.999 F350
G02 X22.230 Y90.223 I5.25 J0 F350
G01 X22.5 Y90.25 F350
G01 X22.5 Y90.75 F350
G01 X21.75 Y91 F350
G01 X14.748 Y91 F350
G02 X12.353 Y94.420 I0 J2.545 F350
G02 X21.75 Y101 I9.397 J-3.420 F350
G01 X58.25 Y101 F350
G02 X67.647 Y94.420 I0 J-10 F350
G02 X65.252 Y91 I-2.395 J-0.875 F350
G01 X58.25 Y91 F350
G01 X57.5 Y90.75 F350
G01 X57.5 Y90.25 F350
G01 X57.770 Y90.223 F350
G02 X62.5 Y84.999 I-0.520 J-5.224 F350
G01 X62.5 Y61.251 F350
G02 X57.770 Y56.027 I-5.25 J0 F350
G01 X57.5 Y56 F350
G01 X57.5 Y55.5 F350
G01 X73.75 Y55.5 F350
G01 X73.75 Y45.875 F350
G01 X58 Y45.875 F350
G01 X58 Y45.5 F350
G01 X58.5 Y45.75 F350
G01 X68.5 Y45.75 F350
G01 X69 Y45.5 F350
G01 X79 Y45.5 F350
G01 X79 Y35.875 F350
G01 X80.25 Y35.625 F350
G01 X80.25 Y20.375 F350
G01 X79 Y20.125 F350
G01 X79 Y10.5 F350
G01 X69 Y10.5 F350
G01 X68.5 Y10.25 F350
G01 X58.5 Y10.25 F350
G01 X58 Y10.5 F350
G01 X58 Y10.125 F350
G01 X73.75 Y10.125 F350
G01 X73.75 Y0.5 F350
M05 L0 P0 (Up / off)
M05 L0 P0 (Up / off)
G00 X0.0 Y0.0 F6000 ;Go to Home Position
M18

User Interface

FF5CNMTKWAOKSVU.png
Folded_Box_005.png

Hopefully I have made most of it simple and obvious.

The "Folded Box" program is a sub-program of my main program Tim's XY controller. To get to this program click the "Create G-Code" button.

I have made many programs to create G-Code, this Instructable is all about making Folded Boxes.

Click the "Folded Box" tab.

Starting top left are the parameters of the box. Width, Height, Length and thickness of the card. All dimensions are in millimetres and are internal measurements.

To the right of these is the "Use Separate Fold Settings". This should be ticked for Lasers. Fold settings will be different to the cut setting, these want to be set so that the laser scores the card enough to make the card fold easaly along the line marked with the laser.

Above these setting is information of the Area/size of card that will be needed.

In the centre of the application are the main settings of the cut.

Position settings should be left as shown in the picture.

Max Plot Area is the dimensions that your machine can plot.

Rotation rotates the plot 90 degrees clockwise. If your machine will plot a greater distance in one direction than the other, sometimes rotating the plot will make it fit.

Tools Up/Down, with the laser the setting should be as shown in the picture, with the On setting to the power you want to use with your laser.

If you want to just have the laser fully on and off, check the box Use Only M03/M05.

If you are going to use a pen to draw the pattern and have a servo lifting and dropping the pen, check the box Use Only M03/M05.

If you are going to use a pen to draw the pattern and have a stepper motor to rise and lower the pen (modifies 3D printer), check the box Use Z, and set the Z Position settings for the heights.

Speeds, normally G00 speed is set in the firmware of the machine, it is fastest the machine axis can travel. Depending on the firmware/machine this could be the case, I have added a setting for the G00 command speed and an option to include it in the code for those machines that may not use the G00 command correctly. The G01 should be set to the speed your laser cuts.

Preview Scale increases/decreases the size of the pattern seen in the preview window.

Multi-pass, if your laser needs more than one pass to cut, set this to how many passes it requires.

Once all settings have been set, click the "Update Preview" button, then click the "Generate G-Code" button.

In the application the G-Code is split into three sections. Header, Main Script and Footer.

The Header, contains information about the plot and settings to set the state of the machine.

The Main Script has all the code to draw the pattern for the box.

The Footer contains code to tell the machine what to do when it has finished drawing the pattern.

All three sections can be edited I you know G-Code and want to change anything before saving.

Saving the G-Code File

Folded_Box_006.png

There are two save buttons, "Save G-code To File And Close" and "Save G-code To File"

Make sure you have Generated G-Code before saving.

Save G-code To File And Close, Saves the G-Code to a File and closes the application.

Save G-code To File, Saves the G-Code to a File keeping the application open.

When the Save File Dialog window opens, it will give you a name for the file based on the settings used, you can change this to what ever you want.

Also the suffix will be set to ".tgc" (Tims G Code)

If you are going to use the file with different software you can change it.

Your choses are shown in the picture.

As I have mentioned, G-Code now comes in many flavours. The reason my files default to .tgc is because this file is my flavour of G-Code, which my plotter understands. Other machines may need some editing to the file produced, as mentioned earlier.

Sending Code to Your Plotter

Main_Aplication.png
Folded_Box_007.png
Folded_Box_008.png

To send the file created to your machine, you can use whatever software you are comfortable with. The file is a typical G-Code file.

All G-Code files are basic text documents and can be opened and edited with any text editor. Notepad will open one.

Using my application to send a G-Code file is fairly simple.

Coms, this is where you connect to your machine. Set the port and baud rate and click the "Connect" button.

Once connected click the "Open G-Code File" button. This will open a Open File Dialog window, choose the file created.

As mentioned before, my software defaults to ".tcg" you can change it.

With the Application connected and the file loaded, you will be able to click the "Plot G-Code File" button. This sends the file to the plotter.

On my application there are options for choosing different tools/machine's, these are bespoke to my plotter, these should be ignored. My plotter is designed and built by myself and has many tool options.

The Cut Pattern

Folded_Box_009.png

Folds

Folded_Box_010.png

Fold all folds inwards to the scored lines.

Ends

Folded_Box_011.png
Folded_Box_012.png

Fold ends over small tabs.

Top

Folded_Box_013.png

The tabs on either side of the top fit inside the ends of the box.

Close

Folded_Box_014.png
Folded_Box_015.png

To close the box, insert the tabs on either side of the front flap into the folded ends.

Video

Tim's XY Stepper Controller (Folded Box)

This is how it should go.


Sorry about the sound, towards the end of the video. I don't edit, I just go for it. It must have been a glitch in the recording. This was my second attempt.

Its the bit about modifying the "L" to "S" so that it can be re-save and used with grbl firmware.

Other Plotters

The only difficulty I see with other plotters is the command for turning on/off the laser and setting the power of the laser.

If any one has difficulty in this area just say and give some details of the plotter they are using and I will try to help.