# GracoPd2kDual API

## Add-On Instructions (AOIs)

### MainCtrl

Provides several inputs for controlling the PD2K proportioner (e.g. system mode, setpoints).

The enable input must be on for any other inputs to take effect. The boolean command inputs each function like execute inputs, meaning the command will automatically reset these once set to true.

The current control mode setting (pressure or flow) determines which of the setpoint inputs are written to the PD2K system. This switches automatically when the control mode is changed.

clearAlarm (INPUT BOOL)

  Clear alarm

completeJob (INPUT BOOL)

  Complete job

ctrlMode (INPUT BOOL)

  Ctrl mode SP (0=flow, 1=pressure)

enable (INPUT BOOL)

  Enable command

mix (INPUT BOOL)

  Goto mix

mixFill (INPUT BOOL)

  Goto mix fill

powerOff (INPUT BOOL)

  Power off

powerOn (INPUT BOOL)

  Power on

quickStop (INPUT BOOL)

  Goto quick stop

recipePurge (INPUT BOOL)

  Goto recipe purge

standby (INPUT BOOL)

  Goto standby

mixUnitNum (INPUT DINT)

  Mix unit number (1-2)

flowCtrlSP (INPUT DINT)

  Flow control setpoint (cc/min)

presCtrlSP (INPUT DINT)

  Pressure control setpoint (psi)

busy (OUTPUT BOOL)

  Command busy flag

valid (OUTPUT BOOL)

  Command valid flag

aborted (OUTPUT BOOL)

  Command aborted flag

error (OUTPUT BOOL)

  Command error flag

state (OUTPUT DINT)

  State code

moduleStatus (INOUT DINT[62])

  Data from module to PLC

moduleCmds (INOUT DINT[30])

  Data from PLC to module

#### State Codes

- 16#0000 - Idle

- 16#3XXX - Valid

- 16#8000 - Error, invalid mix unit number

### ReadAlarmInfo

Reads data from an alarm record.

indexNum (INPUT DINT)

  the chronological alarm index number to look up, where 0 is the most recent, and 199 is the 200th most recent.

execute (INPUT BOOL)

  executes the command.

code (INOUT STRING4)

  the code for the alarm.

dateTime (INOUT TypeDateTime)

  The date and time the alarm occurred.

moduleStatus (INOUT DINT[62])

  The module input data.

moduleCmds (INOUT DINT[30])

  The module output data.

busy (OUTPUT BOOL)

  The busy command flag

done (OUTPUT BOOL)

  The done command flag

aborted (OUTPUT BOOL)

  The aborted command flag

error (OUTPUT BOOL)

  The error command flag

state (OUTPUT DINT)

  State data for the command

#### State Codes

- 16#1xxx - Busy

- 16#2000 - Done

- 16#4000 - Aborted, command overwritten by another process

- 16#8000 - Error, invalid command ID

- 16#8001 - Error, timeout waiting for DCS registers to become available

- 16#8002 - Error, command unsuccessful

- 16#8003 - Error, timeout waiting for acknowledge from PD2K

### ReadEventInfo

Reads data from an event record.

indexNum (INPUT DINT)

  the chronological event index number to look up, where 0 is the most recent, and 199 is the 200th most recent.

execute (INPUT BOOL)

  executes the command.

code (INOUT STRING4)

  the code for the event.

dateTime (INOUT TypeDateTime)

  The date and time the event occurred.

moduleStatus (INOUT DINT[62])

  The module input data.

moduleCmds (INOUT DINT[30])

  The module output data.

busy (OUTPUT BOOL)

  The busy command flag

done (OUTPUT BOOL)

  The done command flag

aborted (OUTPUT BOOL)

  The aborted command flag

error (OUTPUT BOOL)

  The error command flag

state (OUTPUT DINT)

  State data for the command

#### State Codes

- 16#1xxx - Busy

- 16#2000 - Done

- 16#4000 - Aborted, command overwritten by another process

- 16#8000 - Error, invalid command ID

- 16#8001 - Error, timeout waiting for DCS registers to become available

- 16#8002 - Error, command unsuccessful

- 16#8003 - Error, timeout waiting for acknowledge from PD2K

### ReadFlushSeq

Returns the current configuration values for a flush sequence number.

flushSeqNum (INPUT DINT)

  the flush sequence number to configure. The acceptable range is 1-5. If not in range, an error will be raised.

execute (INPUT BOOL)

  executes the command.

moduleStatus (INOUT DINT[62])

  The module input data.

moduleCmds (INOUT DINT[30])

  The module output data.

gunPurgeTime (OUTPUT DINT)

  the current gun purge time in seconds.

initialFlushVol (OUTPUT DINT)

  the current value for the initial flush volume setpoint in cc.

finalFlushVol (OUTPUT DINT)

  the current value for the final flush volume setpoint in cc.

numWashCycles (OUTPUT DINT)

  the current number of wash cycles.

strokesPerWashCycle (OUTPUT DINT)

  the current number of strokes per wash cycle.

busy (OUTPUT BOOL)

  The busy command flag

done (OUTPUT BOOL)

  The done command flag

aborted (OUTPUT BOOL)

  The aborted command flag

error (OUTPUT BOOL)

  The error command flag

state (OUTPUT DINT)

  State data for the command

#### State Codes

- 16#1xxx - Busy

- 16#2000 - Done

- 16#4000 - Aborted, command overwritten by another process

- 16#8000 - Error, invalid command ID

- 16#8001 - Error, timeout waiting for DCS registers to become available

- 16#8002 - Error, command unsuccessful

- 16#8003 - Error, timeout waiting for acknowledge from PD2K

### ReadGrandTotals

Returns the material grand total volume data.

execute (INPUT BOOL)

  executes the command.

moduleStatus (INOUT DINT[62])

  The module input data.

moduleCmds (INOUT DINT[30])

  The module output data.

materialA (OUTPUT DINT)

  the grand total volume of material A used, in gallons.

materialB (OUTPUT DINT)

  the grand total volume of material B used, in gallons.

materialAB (OUTPUT DINT)

  the summed grand total of materials A and B, in gallons.

solvent (OUTPUT DINT)

  the grand total volume of solvent used, in gallons.

busy (OUTPUT BOOL)

  The busy command flag

done (OUTPUT BOOL)

  The done command flag

aborted (OUTPUT BOOL)

  The aborted command flag

error (OUTPUT BOOL)

  The error command flag

state (OUTPUT DINT)

  State data for the command

#### State Codes

- 16#1xxx - Busy

- 16#2000 - Done

- 16#4000 - Aborted, command overwritten by another process

- 16#8000 - Error, invalid command ID

- 16#8001 - Error, timeout waiting for DCS registers to become available

- 16#8002 - Error, command unsuccessful

- 16#8003 - Error, timeout waiting for acknowledge from PD2K

### ReadJobInfo

Reads data from a job record.

indexNum (INPUT DINT)

  the chronological job index number to look up, where 0 is the most recent, and 199 is the 200th most recent.

execute (INPUT BOOL)

  executes the command.

userID (INOUT STRING9)

  the user ID used for the job.

dateTime (INOUT TypeDateTime)

  the completion date and time of the job record.

moduleStatus (INOUT DINT[62])

  The module input data.

moduleCmds (INOUT DINT[30])

  The module output data.

mixUnitNum (OUTPUT DINT)

  Mix unit number

jobNum (OUTPUT DINT)

  The actual job number of the record.

recipeNum (OUTPUT DINT)

  The recipe number used for the job.

abVol (OUTPUT DINT)

  The sum of materials (A+B) used for the job in cc.

busy (OUTPUT BOOL)

  The busy command flag

done (OUTPUT BOOL)

  The done command flag

aborted (OUTPUT BOOL)

  The aborted command flag

error (OUTPUT BOOL)

  The error command flag

state (OUTPUT DINT)

  State data for the command

#### State Codes

- 16#1xxx - Busy

- 16#2000 - Done

- 16#4000 - Aborted, command overwritten by another process

- 16#8000 - Error, invalid command ID

- 16#8001 - Error, timeout waiting for DCS registers to become available

- 16#8002 - Error, command unsuccessful

- 16#8003 - Error, timeout waiting for acknowledge from PD2K

### ReadRecipe

Returns the current configuration values for a recipe number.

mixUnitNum (INPUT DINT)

  mix unit number (1-2)

recipeNum (INPUT DINT)

  the recipe number to read. The acceptable range is 0-60.

execute (INPUT BOOL)

  Executes the command.

moduleStatus (INOUT DINT[62])

  The module input data.

moduleCmds (INOUT DINT[30])

  The module output data.

materialA (OUTPUT DINT)

  the current value for the first material number (paint component).

materialB (OUTPUT DINT)

  the current value for the second material number (catalyst component).

flushSeqA (OUTPUT DINT)

  the current flush sequence number associated with material A.

flushSeqB (OUTPUT DINT)

  the current flush sequence number associated with material B.

mixRatioSP (OUTPUT REAL)

  the current mix ratio setpoint. The value corresponds to the ratio antecedent, i.e. the material A amount. For example, a value of 2.5 corresponds to a ratio of 2.5:1 (material A to material B).

potLifeTimeSP (OUTPUT DINT)

  the current pot life time setpoint in minutes.

mixPressureTol (OUTPUT DINT)

  mix pressure tolerance (%)

busy (OUTPUT BOOL)

  The busy command flag

done (OUTPUT BOOL)

  The done command flag

aborted (OUTPUT BOOL)

  The aborted command flag

error (OUTPUT BOOL)

  The error command flag

state (OUTPUT DINT)

  State data for the command

#### State Codes

- 16#1xxx - Busy

- 16#2000 - Done

- 16#4000 - Aborted, command overwritten by another process

- 16#8000 - Error, invalid command ID

- 16#8001 - Error, timeout waiting for DCS registers to become available

- 16#8002 - Error, command unsuccessful

- 16#8003 - Error, timeout waiting for acknowledge from PD2K

### ReadUserID

Returns the current user ID for the system.

The returned value is a string of up to 9 characters, not including a null terminator.

execute (INPUT BOOL)

  Executes the command

mixUnitNum (INPUT DINT)

  mix unit number (1-2)

userID (INOUT STRING9)

  The returned user ID

moduleStatus (INOUT DINT[62])

  The module input data

moduleCmds (INOUT DINT[30])

  The module output data

busy (OUTPUT BOOL)

  The busy command flag

done (OUTPUT BOOL)

  The done command flag

aborted (OUTPUT BOOL)

  The aborted command flag

error (OUTPUT BOOL)

  The error command flag

state (OUTPUT DINT)

  State data for the command

#### State Codes

- 16#1xxx - Busy

- 16#2000 - Done

- 16#4000 - Aborted, command overwritten by another process

- 16#8000 - Error, invalid command ID

- 16#8001 - Error, timeout waiting for DCS registers to become available

- 16#8002 - Error, command unsuccessful

- 16#8003 - Error, timeout waiting for acknowledge from PD2K

### RecipeChange

Performs a recipe change operation.

execute (INPUT BOOL)

  executes the command.

mixUnitNum (INPUT DINT)

  mix unit number (1-2)

recipeNum (INPUT DINT)

  The next recipe number to use.

moduleStatus (INOUT DINT[62])

  The module input data.

moduleCmds (INOUT DINT[30])

  The module output data.

busy (OUTPUT BOOL)

  The busy command flag

done (OUTPUT BOOL)

  The done command flag

aborted (OUTPUT BOOL)

  The aborted command flag

error (OUTPUT BOOL)

  The error command flag

state (OUTPUT DINT)

  State data for the command

#### State Codes

- 16#1xxx - Busy

- 16#2000 - Done

- 16#4000 - Aborted, command overwritten by another process

- 16#8000 - Error, system must be powered on

- 16#8001 - Error, another recipe change is already in progress

- 16#8002 - Error, system alarm is active

- 16#8003 - Error, another operation is active

- 16#8004 - Error, alarm occurred

- 16#8005 - Error, unexpected system mode

- 16#8006 - Error, recipe change did not finish

- 16#8007 - Error, timeout waiting for system registers to become available

- 16#8008 - Error, invalid mix unit number

### SendDCS

Sends a dynamic command structure (DCS) message to the PD2K system.

For more information about DCS commands, see the system operation manual.

execute (INPUT BOOL)

  executes the command.

cmdID (INPUT DINT)

  the command number to send.

arg0 (INPUT DINT)

  argument 0.

arg1 (INPUT DINT)

  argument 1.

arg2 (INPUT DINT)

  argument 2.

arg3 (INPUT DINT)

  argument 3.

arg4 (INPUT DINT)

  argument 4.

arg5 (INPUT DINT)

  argument 5.

arg6 (INPUT DINT)

  argument 6.

arg7 (INPUT DINT)

  argument 7.

arg8 (INPUT DINT)

  argument 8.

moduleStatus (INOUT DINT[62])

  The module input data.

moduleCmds (INOUT DINT[30])

  The module output data.

return0 (OUTPUT DINT)

  Return value 0 from the PD2K.

return1 (OUTPUT DINT)

  Return value 1 from the PD2K.

return2 (OUTPUT DINT)

  Return value 2 from the PD2K.

return3 (OUTPUT DINT)

  Return value 3 from the PD2K.

return4 (OUTPUT DINT)

  Return value 4 from the PD2K.

return5 (OUTPUT DINT)

  Return value 5 from the PD2K.

return6 (OUTPUT DINT)

  Return value 6 from the PD2K.

return7 (OUTPUT DINT)

  Return value 7 from the PD2K.

return8 (OUTPUT DINT)

  Return value 8 from the PD2K.

busy (OUTPUT BOOL)

  The busy command flag

done (OUTPUT BOOL)

  The done command flag

aborted (OUTPUT BOOL)

  The aborted command flag

error (OUTPUT BOOL)

  The error command flag

state (OUTPUT DINT)

  State data for the command

#### State Codes

- 16#1xxx - Busy

- 16#2000 - Done

- 16#4000 - Aborted, command overwritten by another process

- 16#8000 - Error, invalid command ID

- 16#8001 - Error, timeout waiting for DCS registers to become available

- 16#8002 - Error, command unsuccessful

- 16#8003 - Error, timeout waiting for acknowledge from PD2K

### StatusToUDT

Reads a PD2K module array into a structured UDT.

moduleStatus (INOUT DINT[62])

  The module input data.

statusUDT (INOUT TypePd2kDualStatus)

  The structured data from the device.

### WriteFlushSeq

Configures the values for a flush sequence number.

flushSeqNum (INPUT DINT)

  the flush sequence number to configure. The acceptable range is 1-5. If not in range, an error will be raised.

gunPurgeTime (INPUT DINT)

  the gun purge time to set in seconds. The acceptable range is 0-999. If not in range, an error will be raised.

initialFlushVol (INPUT DINT)

  the initial flush volume setpoint in cc. The acceptable range is 0-9999. If not in range, an error will be raised.

finalFlushVol (INPUT DINT)

  the final flush volume setpoint in cc. The acceptable range is 0-9999. If not in range, an error will be raised.

numWashCycles (INPUT DINT)

  the number of wash cycles to set. The acceptable range is 0-99. If not in range, an error will be raised.

strokesPerWashCycle (INPUT DINT)

  the number of strokes per wash cycle to set. The acceptable range is 0-99. If not in range, an error will be raised.

execute (INPUT BOOL)

  executes the command.

moduleStatus (INOUT DINT[62])

  The module input data.

moduleCmds (INOUT DINT[30])

  The module output data.

busy (OUTPUT BOOL)

  The busy command flag

done (OUTPUT BOOL)

  The done command flag

aborted (OUTPUT BOOL)

  The aborted command flag

error (OUTPUT BOOL)

  The error command flag

state (OUTPUT DINT)

  State data for the command

#### State Codes

- 16#1xxx - Busy

- 16#2000 - Done

- 16#4000 - Aborted, command overwritten by another process

- 16#8000 - Error, invalid command ID

- 16#8001 - Error, timeout waiting for DCS registers to become available

- 16#8002 - Error, command unsuccessful

- 16#8003 - Error, timeout waiting for acknowledge from PD2K

### WriteMaterialReadyFlag

Sets the flag used to signal that the upstream material management is loaded correctly prior to a recipe change.

This flag is only used when multiple materials for a pump are fed to the PD2K via a single valve at the inlet valve stack (i.e. a piggable system).

mixUnitNum (INPUT DINT)

  mix unit number (1-2)

materialReadyFlag (INPUT BOOL)

  the new flag value (false=not ready, true=ready).

execute (INPUT BOOL)

  executes the command.

moduleStatus (INOUT DINT[62])

  The module input data.

moduleCmds (INOUT DINT[30])

  The module output data.

busy (OUTPUT BOOL)

  The busy command flag

done (OUTPUT BOOL)

  The done command flag

aborted (OUTPUT BOOL)

  The aborted command flag

error (OUTPUT BOOL)

  The error command flag

state (OUTPUT DINT)

  State data for the command

#### State Codes

- 16#1xxx - Busy

- 16#2000 - Done

- 16#4000 - Aborted, command overwritten by another process

- 16#8000 - Error, invalid command ID

- 16#8001 - Error, timeout waiting for DCS registers to become available

- 16#8002 - Error, command unsuccessful

- 16#8003 - Error, timeout waiting for acknowledge from PD2K

### WriteRecipe

Configures the values for a recipe number.

execute (INPUT BOOL)

  Executes the command.

mixUnitNum (INPUT DINT)

  mix unit number (1-2)

recipeNum (INPUT DINT)

  the recipe number to configure. The acceptable range is 0-60.

materialA (INPUT DINT)

  the first material number to set (paint component). The acceptable range is 0-30.

materialB (INPUT DINT)

  the second material number to set (catalyst component). The acceptable range is 0,31-34.

materialAFlushSeq (INPUT DINT)

  the flush sequence number to use with material A. The acceptable range is 1-5.

materialBFlushSeq (INPUT DINT)

  the flush sequence number to use with material B. The acceptable range is 1-5. If not in range, an error will be raised.

mixRatioSP (INPUT REAL)

  the mix ratio setpoint to use. The value corresponds to the ratio antecedent, i.e. the material A amount. For example, a value of 2.5 corresponds to a ratio of 2.5:1 (material A to material B). For single component recipes, set the value to 0. The max precision is two decimal places; anything beyond that will be rounded. The acceptable range is 0-50.

potLifeTimeSP (INPUT DINT)

  the total pot life time to set in minutes. The acceptable range is 0-999 minutes.

mixPressureTol (INPUT DINT)

  mix pressure tolerance (%)

moduleStatus (INOUT DINT[62])

  The module input data.

moduleCmds (INOUT DINT[30])

  The module output data.

busy (OUTPUT BOOL)

  The busy command flag

done (OUTPUT BOOL)

  The done command flag

aborted (OUTPUT BOOL)

  The aborted command flag

error (OUTPUT BOOL)

  The error command flag

state (OUTPUT DINT)

  State data for the command

#### State Codes

- 16#1xxx - Busy

- 16#2000 - Done

- 16#4000 - Aborted, command overwritten by another process

- 16#8000 - Error, invalid command ID

- 16#8001 - Error, timeout waiting for DCS registers to become available

- 16#8002 - Error, command unsuccessful

- 16#8003 - Error, timeout waiting for acknowledge from PD2K

### WriteUserID

Sets the current user ID for the system.

The user ID can be up to 9 characters in length. The value sent to the PD2K will include a null terminator for a total of 10 characters. Only ASCII characters are supported.

execute (INPUT BOOL)

  Executes the command

mixUnitNum (INPUT DINT)

  Mix unit number (1-2)

userID (INOUT STRING9)

  The new user ID

moduleStatus (INOUT DINT[62])

  The module input data

moduleCmds (INOUT DINT[30])

  The module output data.

busy (OUTPUT BOOL)

  The busy command flag

done (OUTPUT BOOL)

  The done command flag

aborted (OUTPUT BOOL)

  The aborted command flag

error (OUTPUT BOOL)

  The error command flag

state (OUTPUT DINT)

  State data for the command

#### State Codes

- 16#1xxx - Busy

- 16#2000 - Done

- 16#4000 - Aborted, command overwritten by another process

- 16#8000 - Error, invalid command ID

- 16#8001 - Error, timeout waiting for DCS registers to become available

- 16#8002 - Error, command unsuccessful

- 16#8003 - Error, timeout waiting for acknowledge from PD2K

## User-Defined Types (UDTs)

### TypePd2kPumpStatusFlags

Status flags for a PD2K pump.

off (BOOL)

  pump is off.

standby (BOOL)

  pump is in standby.

busy (BOOL)

  pump is busy.

flushing (BOOL)

  pump is flushing.

priming (BOOL)

  pump is priming.

### TypePd2kDualStatus

Status data read from a PD2K Dual system.

gunTriggerStatus1 (BOOL)

  gun 1 trigger status (1 = on)

gunTriggerStatus2 (BOOL)

  gun 2 trigger status(1 = on)

mixUnit1 (TypePd2kMixUnitStatus)

  mix unit 1

mixUnit2 (TypePd2kMixUnitStatus)

  mix unit 2

pump1 (TypePd2kPump)

  pump 1

pump2 (TypePd2kPump)

  pump 2

pump3 (TypePd2kPump)

  pump 3

pump4 (TypePd2kPump)

  pump 4

dcsReturn0 (DINT)

  DCS return 0

dcsReturn1 (DINT)

  DCS return 1

dcsReturn2 (DINT)

  DCS return 2

dcsReturn3 (DINT)

  DCS return 3

dcsReturn4 (DINT)

  DCS return 4

dcsReturn5 (DINT)

  DCS return 5

dcsReturn6 (DINT)

  DCS return 6

dcsReturn7 (DINT)

  DCS return 7

dcsReturn8 (DINT)

  DCS return 8

dcsAck (DINT)

  DCS acknowledge

### TypePd2kMixUnitStatus

Status data for a mix unit

eventFlag (BOOL)

  event flag

standby (BOOL)

  in standby

interlockStatus (BOOL)

  interlock status

systemMode (DINT)

  system mode

systemModeFlags (TypePd2kSystemModeFlags)

  system mode flags

actualMixFlow (DINT)

  actual mix flow (cc/min)

actualMixRatio (DINT)

  actual mix ratio

actualPotLifeRemaining (DINT)

  actual pot life remaining

activeRecipeNum (DINT)

  active recipe number

activeMaterialA (DINT)

  active material A

activeMaterialB (DINT)

  active material B

activeFlushSeqA (DINT)

  active flush sequence A

activeFlushSeqB (DINT)

  active flush sequence B

activeRatioSP (DINT)

  active ratio SP

activePotLifeSP (DINT)

  active pot life SP

activeJobNum (DINT)

  active job number

jobSprayVolA (DINT)

  job sprayed volume A (cc)

jobSprayVolB (DINT)

  job sprayed volume B (cc)

jobSolventVol (DINT)

  job solvent volume used (cc)

### TypePd2kPump

Status data for a PD2K pump

status (DINT)

  pump status

statusFlags (TypePd2kPumpStatusFlags)

  pump status flags

actualMaterial (DINT)

  actual material number

actualFlowRate (DINT)

  actual flow rate (cc/min)

actualFluidPres (DINT)

  actual fluid pressure (psi)

### TypePd2kSystemModeFlags

Flags for the PD2K system mode.

pumpOff (BOOL)

  pump off

colorChange (BOOL)

  color change enabled

colorChangePurgeA (BOOL)

  color change purging component A

colorChangePurgeB (BOOL)

  color change purging component B

colorChangeFilling (BOOL)

  color change filling

colorChangeMixFill (BOOL)

  color change mix fill

colorChangeMix (BOOL)

  color change mixing

colorChangeMixIdle (BOOL)

  color change mix idle

purgeA (BOOL)

  purging component A

purgeB (BOOL)

  purging component B

standbyMixReady (BOOL)

  standby mix ready

standbyFillReady (BOOL)

  standby fill ready

standbyMixNotReady (BOOL)

  standby mix not ready

standbyAlarm (BOOL)

  standby alarm

lineFillingFlushing (BOOL)

  line is filling or flushing

pumpPrimeFlush (BOOL)

  pump is priming or flushing

maintCalibration (BOOL)

  maintenance/calibration

mixSolventPush (BOOL)

  mix solvent push