Scripts
DISPENSE["head name"] lets a head run patterns, apply corrections and purge, and ALIGN["align name"] measures the part position (the keyword changed from FIDUCIAL to ALIGN in 4.0.28, and the old keyword is a build error). Head names (DISPENSE["…"]) and align names (SetAlign) are checked at build and a missing one is an error (head names are an error from 4.0.24). Pattern names of functions such as Run · RunFrom · RunCell · GetCellCount written as text are compared with the patterns of the job open at build time and give a warning if missing — not an error because each job (model) has its own patterns; temporary patterns that the same module makes with PathBegin are left out. See XScript — DISPENSE · XScript — ALIGN for details.
Example
FUNCTION DispenseLid()
{
// 1) Measure the part — find the references ( marks or edges ) of the job's method and compare with teaching
if( ALIGN["Tray"].Measure() == false )
{
LogError("Align failed : {0}", ALIGN["Tray"].GetLastError());
return false;
}
// 2) Put the result into the head ( applies from the next run )
if( DISPENSE["Head1"].SetAlign("Tray") == false )
{
LogError("SetAlign failed : {0}", DISPENSE["Head1"].GetLastError());
return false;
}
// 3) Run the pattern — waits until it finishes
if( DISPENSE["Head1"].Run("Lid_A") == false )
{
LogError("Dispense failed : {0} ({1})", DISPENSE["Head1"].GetLastError(), DISPENSE["Head1"].GetState());
return false;
}
return true;
}
FUNCTION PurgeNeedle()
{
// Go to the purge position and dispense for the head's purge time
if( DISPENSE["Head1"].MoveToPurge() == false )
{
return false;
}
return DISPENSE["Head1"].Purge(0);
}Run·Measurewait until they finish. Do not call them directly from a screen button event; call them from a sequence step orRunManualThread. To avoid waiting, useStartand check withIsBusy·Wait.- An array pattern run by
Run·RunFrom·RunFromCellin a sequence step waits between cells on STOP (chapter 13). While it waits,IsBusy()is true,GetState()is"Running"andIsPaused()is true. A run started withStartnever waits. - On failure they return false and the reason (English) is left in
GetLastError()and the log.
Function summary
| Kind | Functions | Description |
|---|---|---|
| Run | Run(p) · Start(p) · IsBusy() · Wait(ms) · Abort() · IsPaused() | Run to the end and wait / start and return at once / whether running / wait until finished (0 = no limit) / stop at once (valve off → path emergency stop) / whether it is waiting between cells for STOP to end (4.0.27~) |
| Resume | RunFrom(p, e) · GetLastCompleted() · GetElementIndex() | Run from an element number (a line whose middle it is gets skipped; array patterns accept 0 only) / end element of the last completed block / current element |
| Array | RunCell · RunFromCell · GetCellCount · GetCurrentCell · GetLastCompletedCell · SetCellSkip · ClearCellSkip · IsCellSkipped | One cell only / resume from a cell and element / cell count / current cell / completed cell / run-time skip (not saved) — pattern array in XScript — DISPENSE |
| State | GetState() · GetLastError() | "Idle" · "Running" · "Done" · "Aborted" · "Error" / last error (English) |
| Correction | SetWorkOffset(dx, dy, deg) · ClearWorkOffset() · SetFiducial2(p, x1, y1, x2, y2) · SetAlign(a) · ClearAlign() · GetAlign() · GetAlignScale() | Work offset (rotate around the pattern origin, then shift; counterclockwise +) / work offset from two fiducial marks / put an align result in (the same for every method, including the scale with uniform scale) — all from the next run. GetAlignScale() returns the scale of the align in use (with uniform scale the value the compiler multiplies by, 1 for rigid or no align — 4.0.28~). The align in the head is dropped at the first run or GetAlign() after a job change, and SetAlign refuses a result from other motors or measured before the method changed. On a reference-head setup it also puts in the camera offset of the align device settings and moves the rotation center (4.0.28~, chapter 9 · chapter 5) |
| Cell align | SetCellAlign(cell, a) · ClearCellAligns() · GetCellAlign(cell) · GetCellAlignCount() · GetCellInOrder(p, i) (4.0.28~) | Put a cell measurement result (ALIGN[a].MeasureCell) into that cell / clear them all / align name put in a cell ("" if none) / number of cells put in / cell number of the i-th cell in run order (Z · S) — single PCBs on a jig, chapter 9 |
| Height · mode | SetSurfaceZ(z) · ClearSurfaceZ() · SetMode("Run" | "DryRun") | Override surface Z (height measurement result) / back to the head setting / dry run (moves only, no valve) |
| Valve · purge | ValveOn() · ValveOff() · Purge(ms) · MoveToPurge() | Manual valve (refused while running) / dispense at the current position (0 or less = head purge time) / go to the purge position (Z safe → XY) |
| Parameters | GetParam(set, name) · SetParam(set, name, v) · SaveParams() | Read a set value (the default value if the set has none — it does not go through the head's default set, so it can differ from the value used in a run) / change it in memory (clamped to the range, from the next run) / save to the current job — allowed even while running |
| Temporary pattern | PathBegin · PathSet · PathPass · PathArc · PathLine · PathDot · PathCircle · PathHeight · PathEnd · SetPoints | Build an unsaved pattern in the script and run it with Run(name) (e.g. dispensing along a contour found by vision). PathHeight(x, y) adds a height point (4.0.26~) |
| Calculation | GetEstimatedTime(p) · GetLength(p) | Estimated time (s, no acceleration) / dispense length (mm) — all cells summed for an array (calculated without the cell aligns) |
| Process records | SetBoardId(id) · GetBoardId() · GetLastRunSec() | Board ID (written to the process records, kept until changed) / current ID / seconds of the last run — 10.2 |
| Material · purge | SetMaterial(lot) · GetMaterialLot() · GetMaterialAgeMin() · GetPotLifeLeftMin() · GetShotCount() · IsPurgeDue() · GetIdleSec() | Register material / lot / minutes since registration (-1 = not registered) / pot life left (-1 = off) / valve-on count / purge due / seconds since the last dispense (-1 = no record) — 10.3 |
| Needle calibration | RegisterTipRef() · CalibrateTip() · GetTipOffset() · RegisterNeedleXYRef() · CalibrateNeedleXY() · GetNeedleCalLeft() · ResetNeedleCalPlate() | Register Z reference / calibrate Z / Z difference from the reference needle / register XY reference / calibrate XY / dots left on the plate / plate cleaned — 10.4 |
| Height measurement | RegisterHeightRef(x, y) · MeasureSurfaceZ(x, y, ref z) | Register the height reference (a point in needle coordinates) / surface Z of a point — 10.5 |
| Weight calibration | CalibrateWeight() · GetFlowRatio() · SetFlowRatio(r) · GetLastWeightMg() | Find the ratio by test shots on the scale / current ratio / set the ratio (0.1 ~ 10) / last measured weight (mg) — 10.6 |
The calibration and measuring functions (RegisterTipRef · CalibrateTip · RegisterNeedleXYRef · CalibrateNeedleXY · RegisterHeightRef · MeasureSurfaceZ · CalibrateWeight) move the head and wait until they finish. On failure they return false and the reason is in GetLastError(). Calling Abort() from another thread stops the head motors at once (even while waiting for the scale) and they end with false (… aborted). In simulation mode reference registration (Register…) returns false, and calibration only moves, saves nothing and returns true. In dry-run mode CalibrateNeedleXY · RegisterNeedleXYRef · CalibrateWeight return false.
Note Examples for skipping array cells, resuming a run and applying an align are in XScript — DISPENSE · XScript — ALIGN.