Writing gcode
Now that the board is aligned you can start writing the code.
For a PCB with two size components and at least one IC the sequence of instructions would be as follows:
– Load profile 1
– Dispense all 0603 pads
– Load profile 2
– Dispense all 0805 pads
– Load profile 3
– Dispense the IC lines
The profile change can be done either manually (by physically adjusting the dispenser) or by sending specific commands via the same external trigger port.
Code to switch profiles
Timing diagram: (only works when screen is displaying menu #5)
In this example we’re sending instructions to change to profile 3. Resulting code:
- M106 S255 (output high, starts at 0ms)
- G4 P5 (wait 5ms)
- M106 S0 (output low)
- G4 P30 (wait 30ms)
- M106 S255 (output high)
- G4 P60 (wait to select profile, example: #3=60ms, #5=100ms, #10=200ms)
- M106 S0 (output low)
- G4 P300 (wait an extra 300ms to let the dispenser exit this mode)
Line 6 determines which profile will be selected, in 20ms increments. There’s a total of 15 available profiles. Try sending the commands while looking at the screen in the dispenser, it should update immediately with the new value.
Note: Not all machines execute instructions with precise timings, if you see a different profile being selected than you intended, try reducing wait time on line 4 and/or line 6 by a couple of ms.
Finished code example
In this simple board there’s 6 components in total (4 resistors, 1 large LED and 1 IC) but only three different dispensing settings are needed, shown in blue, red and gray.
G1 F3000 ; Sets movement speed
; Code to load to profile 1 (Blue in this example)
M106 S255 ; output high
G4 P5 ; wait 5ms
M106 S0 ; output low
G4 P30 ; wait 30ms
M106 S255 ; output high
G4 P20 ; wait 20ms selects profile #1
M106 S0 ; output low
G4 P300 ; wait an extra 300ms to let the dispenser exit this mode
; Start dispensing 0603 pads:
G1 Z3 ; Lift tip by 3mm
G1 X0 Y0 ; moves to Pad 1 coordinates: X0 Y0
G1 Z.2 ; lowers the tip to dispense height: 0.2mm
M106 S255 ; Start extruding paste
G4 P1000 ; Wait 1 second to let the dispense cycle finish (in dot mode motor stops automatically)
M106 S0
; Repeat for next three deposits, only change is XY coordinates:
G1 Z3
G1 X2.8
G1 Z.2
M106 S255
G4 P1000
M106 S0
G1 Z3
G1 Y1.7
G1 Z.2
M106 S255
G4 P1000
M106 S0
G1 Z3
G1 X0
G1 Z.2
M106 S255
G4 P1000
M106 S0
; Now load profile #2 for 0805 components: (Color red)
M106 S255
G4 P5
M106 S0
G4 P30
M106 S255
G4 P40 ; wait 40ms selects profile #2
M106 S0
G4 P300
; Dispense the 4 pads of the two 0805 resistors:
G1 Z3
G1 X.6 Y7.4
G1 Z.2
M106 S255
G4 P1000
M106 S0
G1 Z3
G1 X2.5
G1 Z.2
M106 S255
G4 P1000
M106 S0
G1 Z3
G1 Y11.2
G1 Z.2
M106 S255
G4 P1000
M106 S0
G1 Z3
G1 X.6
G1 Z.2
M106 S255
G4 P1000
M106 S0
; For the large LED it’s better to apply four drops of paste instead of a single large one, this reduces the risk of oozing and shortens setup time.
G1 Z3
G1 X10.2 Y11.4
G1 Z.2
M106 S255
G4 P1000
M106 S0
G1 Z3
G1 Y12.6
G1 Z.2
M106 S255
G4 P1000
M106 S0
G1 Z3
G1 X12.6
G1 Z.2
M106 S255
G4 P1000
M106 S0
G1 Z3
G1 Y11.4
G1 Z.2
M106 S255
G4 P1000
M106 S0
; And finally the IC lines, profile 3 is loaded: (Color gray)
M106 S255
G4 P5
M106 S0
G4 P30
M106 S255
G4 P60 ; wait 60ms selects profile #3
M106 S0
G4 P300
; Dispenser is now in Manual mode, this means paste will flow as long as the output is held high. During this time the syringe will be moving slowly, forming a line.
G1 Z3 ; lifts tip by 3mm
G1 X7.6 Y7.6 ; moves into position
G1 Z.2 ; lowers the tip to dispense height: 0.2mm
G1 F1000 ; sets slower movement speed
M106 S255 ; start paste extrusion
G4 P400 ; waits a fraction of a second to let paste come out
G1 Y.6 ; drags the tip 7mm towards the bottom of the board
M106 S0 ; stops dispensing (but paste keeps flowing)
G1 Y-2.15 ; moves the tip the remaining 2.75mm
G4 P1000 ; waits one second to give the piston time to retract
G1 F3000 ; sets original XYZ movement speed
; Second line on the IC is the same except for the coordinates:
G1 Z3
G1 X15.1
G1 Z.2
G1 F1000
M106 S255
G4 P400
G1 Y4.85 ; drags the tip 7mm to the top of the board
M106 S0 ; stops dispensing (but paste keeps flowing)
G1 Y7.6 ; moves the tip the remaining 2.75mm
G4 P1000 ; waits one second to give the piston time to retract
G1 F3000
G1 Z3