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 include A-Z, 0-9, and special characters: * (outputs a space), +, -, ., /, (, ).

Variables use a format specifier: #nnn[wp] where w = total digits before the decimal point and p = decimal places. For example, #100[53] formats #100 as 5 digits total before the decimal, 3 decimal places, producing output like 00012.345. Using #100[40] formats as 4 digits with no decimals: 0012.

Format Specifiers

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

Leading zeros are always included. The width value specifies the number of digits before the decimal point. Negative values include a minus sign in the output.

BPRNT (Binary Print)

BPRNT is similar to DPRNT but outputs data in binary format. It is less commonly used and is primarily intended for PMC (Programmable Machine Controller) interface communication. The syntax is the same as DPRNT: BPRNT[text #var[format]].

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.

Have a question or want to contribute?

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

Get in Touch