Haas Adapter

Read a Haas control directly over Ethernet or RS-232 with Q-commands.
MTConnect.NET Docs Menu
  • Module name — MTConnect Haas Adapter agent module
  • Identifier — haas-adapter
  • NuGet package — MTConnect.NET-AgentModule-HaasAdapter
  • Source path — agent/Modules/MTConnect.NET-AgentModule-HaasAdapter/

Purpose

Reads a Haas CNC control (including the Haas Next Generation Control) directly over Ethernet or RS-232 using Haas Machine Data Collection — the ?Q query commands — and feeds the results into the agent, so no separate adapter process is needed. By default the module also adds a Device model containing the DataItems it reports, and fills in its Description with the model and serial number read from the control.

Machine Data Collection is enabled on the control by setting Setting 143 to the TCP port to use (ex. 5051). Ports 8082 and 9090 - 9999 are used by the control and must not be used.

NGC built-in agent

NGC controls also include a built-in MTConnect agent on port 8082 (http://<ip>:8082/<model>/current; software 100.20.000.1200 or higher recommended). It can be read with the HTTP adapter module instead of, or alongside, this module.

Configuration Schema

The module's configuration class is HaasAdapterModuleConfiguration. The keys below describe the YAML map under haas-adapter:.

KeyTypeDefaultPermissible valuesNotes
deviceKeystringnulldevice name or UUIDRequired. The Device observations are added to.
createDevicebooltruetrue, falseWhen true, the module adds a Device named deviceKey with the DataItems below. Set false to use a Device from Devices.xml.
deviceUuidstringdeviceKeyany stringUUID of the Device created when createDevice is true.
connectionstringethernetethernet, serialHow the module connects to the control.
readIntervalint1000millisecondsDelay between read cycles.
slowReadIntervalint10000millisecondsInterval between reads of slowly changing values (timers, counters, version, work offset, single block / optional stop).
responseTimeoutint2000millisecondsMaximum time to wait for a reply. The first ?Q100 after connecting is resent once if unanswered; any other timeout closes the connection, which is reopened on the next cycle.
unitsstringmmmm, inchThe units the control reports linear positions in (Setting 9). Inch values are converted to millimeters.
axeslist[X, Y, Z]X, Y, Z, A, B, CThe axes to read positions for.
workPositionsboolfalsetrue, falseAlso read work coordinate positions.
spindleLoadbooltruetrue, falseRead the spindle load (machines with a Haas vector drive).
coolantLevelboolfalsetrue, falseRead the coolant level (machines with a coolant level sensor).
serverstringlocalhosthostname or IP addressEthernet only.
portint50511-65535Ethernet only. The port set in Setting 143.
connectionTimeoutint5000millisecondsEthernet only. Maximum time to wait for the TCP connection to open.
comPortstringCOM1port nameSerial only (ex. COM1, /dev/ttyUSB0).
baudRateint19200baud rateSerial only. Must match Setting 11.
paritystringNoneNone, Even, Odd, Mark, SpaceSerial only. Must match Setting 12.
dataBitsint77, 8Serial only. Must match Setting 13.
stopBitsint11, 2Serial only.

DataItems

When createDevice is false, the Device in Devices.xml needs DataItems whose id or name match these keys.

Read Every Cycle

KeyDataItemSource
availAVAILABILITYAVAILABLE while the control replies to ?Q100; otherwise UNAVAILABLE (and every other DataItem is set UNAVAILABLE).
modeCONTROLLER_MODE?Q104 — MEM / DNC = AUTOMATIC, MDI = MANUAL_DATA_INPUT, JOG / ZERO = MANUAL, EDIT / LIST PROG = EDIT.
executionEXECUTION?Q500 — IDLE = READY, BUSY = ACTIVE, FEED HOLD = INTERRUPTED, ALARM ON = STOPPED.
programPROGRAM?Q500 — empty in MDI.
partCountPART_COUNT?Q500 — M30 counter #1.
systemSYSTEM condition?Q500 — FAULT while ALARM ON, otherwise NORMAL.
toolTOOL_NUMBER?Q201 — the tool in use.
x_act, y_act, z_actPOSITION (ACTUAL)?Q600 5021 - 5023 — machine position, millimeters.
a_act, b_act, c_actANGLE (ACTUAL)?Q600 5024 - 5026 — machine position, degrees.
x_work ... c_workPOSITION / ANGLE (ACTUAL)?Q600 5041 - 5046 — when workPositions is true. These reference a work coordinate system (type OBJECT) added to the Device Configuration (coordinateSystem="WORK" before MTConnect 2.0).
speedROTARY_VELOCITY (ACTUAL)?Q600 3027 — spindle speed, RPM.
spindleLoadLOAD?Q600 1098 — spindle load, percent.

Read Every slowReadInterval

KeyDataItemSource
firmwareFIRMWARE (VERSION)?Q101 — control software version.
powerOnTimeEQUIPMENT_TIMER (POWERED)?Q300 — seconds.
cycleStartTimeEQUIPMENT_TIMER (OPERATING)?Q301 — total cycle start time, seconds.
lastCycleTimePROCESS_TIMER (PROCESS)?Q303 — seconds.
previousCycleTimePROCESS_TIMER (PROCESS)?Q304 — seconds.
partCount2PART_COUNT?Q403 — M30 counter #2.
workOffsetWORK_OFFSET?Q600 4132 — active work offset number (ex. 54).
singleBlockCONTROLLER_MODE_OVERRIDE (SINGLE_BLOCK)?Q600 3030 — ON / OFF.
optionalStopCONTROLLER_MODE_OVERRIDE (OPTIONAL_STOP)?Q600 3033 — ON / OFF.
coolantLevelFILL_LEVEL?Q600 13013 — when coolantLevel is true.

The model (?Q102) and serial number (?Q100) fill in the Device Description.

Not available through Machine Data Collection: feed, rapid and spindle override percentages, current axis loads (#1064 - #1068 hold the maximum load seen), and active alarm numbers.

Wire Interaction

Haas controlEthernet or RS-232
Q-commands
haas-adapter moduleReads the control
AgentDevice and Observations
  1. Connect
  2. Module AgentAddDevice (createDevice = true)
  3. Module HaasTCP connect to <server>:<port>, or open <comPort>
  4. Every readInterval ms
  5. Module Haas?Q100
  6. Haas Module>SERIAL NUMBER, 1234567
  7. Module AgentAddObservation(avail, AVAILABLE)
  8. Module Haas?Q104, ?Q500, ?Q201, ?Q600 (positions, spindle)
  9. Haas Module>MODE, MEM / >PROGRAM, O01234, IDLE, PARTS, 42 / ...
  10. Module HaasEvery slowReadInterval ms: ?Q101, ?Q102, ?Q300, ?Q301, ?Q303, ?Q304, ?Q403, ?Q600 ...
  11. Haas Module>SOFTWARE VERSION, 100.24.000.1200 / ...
  12. Module AgentAddObservation(...)
  13. No reply or connection drop
  14. Module Agentavail and every DataItem set to UNAVAILABLE
A reply to ?Q100 is what sets the Device to AVAILABLE.

NGC replies start with > and end with CR/LF; older controls frame replies with STX / ETB. Both are accepted.

Example Configuration

modules:
  - haas-adapter:
      deviceKey: VF2
      server: 192.168.1.60
      port: 5051
      units: inch

A 5-axis machine with work positions:

modules:
  - haas-adapter:
      deviceKey: UMC-750
      server: 192.168.1.61
      units: inch
      axes: [X, Y, Z, A, C]
      workPositions: true

Over RS-232:

modules:
  - haas-adapter:
      deviceKey: VF2
      connection: serial
      comPort: COM1
      baudRate: 19200
      parity: None
      dataBits: 7

For multiple machines, declare the module once per machine. Created DataItem IDs are prefixed with the Device name, so they do not collide.

Troubleshooting

  • Always UNAVAILABLE — check that Setting 143 is set and the port matches it. Set the modules.haas-adapter logger to Debug to see connection details (Trace logs every command and reply).
  • Program and part count only change when the program stops — the control replies STATUS, BUSY to ?Q500 while running and does not report them in that state.
  • Unrecognized Mode warning — the control reported a mode that is not mapped; please report the logged value.
  • A value stays UNAVAILABLE — the control may not support that query on its software version (logged once as "not supported"), or the option (vector drive, coolant sensor, rotary axis) is not installed; disable it in the configuration.
  • Wrong values with other Machine Data Collection clients connected — the control sends every reply to every connected client. Labeled replies from other clients are ignored, but MACRO, value replies do not identify the variable.
  • Positions off by a factor of 25.4 — set units to match Setting 9.
  • Observations dropped with createDevice: false — the Device's DataItem id or name must match the keys above; verify against /probe.

Classes

The main classes in the MTConnect.NET-AgentModule-HaasAdapter package:

  • HaasAdapterModuleConfiguration — the module's configuration class.
  • HaasResponse — the Q-command reply parser.