External Output / DPRNT

DPRNT Overview

DPRNT (Data Print) outputs formatted text from a macro to an external device such as a serial port, CF card, or network connection. It is commonly used for probing logs, SPC data collection, part counters, cycle time records, and inspection reports.

DPRNT requires POPEN to open the output channel before any data can be sent, and PCLOS to close it when finished.

POPEN and PCLOS

POPEN opens the output channel and must be called before any DPRNT statements. PCLOS closes the output channel and should always be called when output is complete. Only one channel can be open at a time.

POPEN
DPRNT[PROBE*RESULTS]
DPRNT[X*#500[44]]
DPRNT[Y*#501[44]]
PCLOS

DPRNT Syntax

The general syntax is: DPRNT[text and #variables[format]]

Allowed text characters are letters A-Z, digits 0-9, and the special characters * (output as a space), /, +, -, plus ?, @, &, _ when ISO output code is selected. Characters are output in EIA or ISO code according to the setting data (bit 1 (ISO) of parameter 0000).

Variables use a format specifier: #nnn[wp] where w = number of digits in the integer part and p = decimal places. For example, #100[53] formats #100 with 5 integer digits and 3 decimal places, producing output like    12.345. Using #100[40] formats as 4 integer digits with no decimals (and no decimal point):   12.

Format Specifiers

Format Width (digits before decimal) Decimals Example (#100=12.345) Output
[44]44DPRNT[VAL*#100[44]]  12.3450
[53]53DPRNT[VAL*#100[53]]   12.345
[40]40DPRNT[VAL*#100[40]]  12
[24]24DPRNT[VAL*#100[24]]12.3450
[30]30DPRNT[VAL*#100[30]] 12

Leading zeros are not printed as zeros: when bit 1 (PRT) of parameter 6001 is 0, a space is output for each leading zero (as shown above); when PRT is 1, leading zeros are suppressed entirely. The width value specifies the number of digits in the integer part. When decimal places are non-zero, the decimal digits are always output; a minus sign is output for negative values.

BPRNT (Binary Print)

BPRNT outputs characters as-is and variable values as 32-bit binary data instead of readable digits. It is less commonly used, mainly when the receiving computer expects binary data. The format specifier takes only the number of decimal places: BPRNT[text #var[p]] — the value is output as 2-word binary data scaled to include the specified decimal digits.

Practical Examples

Probing Results Log

POPEN
DPRNT[**PROBE*REPORT**]
DPRNT[DATE*#3011[80]]
DPRNT[TIME*#3012[80]]
DPRNT[X*MEASURED*#500[53]]
DPRNT[Y*MEASURED*#501[53]]
DPRNT[Z*MEASURED*#502[53]]
DPRNT[DEVIATION*#510[44]]
PCLOS

Part Counter

#500=#500+1 (INCREMENT COUNTER)
POPEN
DPRNT[PART*#500[60]*COMPLETE]
PCLOS

Cycle Time Log

#3001=0 (RESET TIMER)
(... machining ...)
#100=#3001/1000 (SECONDS)
POPEN
DPRNT[CYCLE*TIME*#100[53]*SEC]
PCLOS

See also: Alarms & Timers for #3011/#3012 date/time variables, and Renishaw Inspection Plus for probing output variables to log.

References

  • Peter Smid, Fanuc CNC Custom Macros, Industrial Press, 2004.
  • Fanuc, Operator’s Manual / Parameter Manual, FANUC Corporation.
  • Fanuc, Series 30i/31i/32i-MODEL B Plus Operator’s Manual (Common), B-64724EN/01, FANUC Corporation.

Have a question or want to contribute?

Contact us with corrections, additions, or topics you'd like covered.

Get in Touch