Generating Scripts with AI
Max — MachineMetrics' AI assistant — can write a complete adapter script from a plain-language description of what you need. The more precisely you describe your setup, the more accurate the script will be on the first try.
Access Max using the Ask Max button in the top navigation bar, or by clicking the chat icon in the bottom-right corner of this page.
There are two common situations where you would ask Max to generate a script:
| Scenario | What it does | Examples |
|---|---|---|
| Scenario 1: Hardware Adapter | Reads physical signals or registers and maps them to MachineMetrics data | Sealevel I/O, WISE, Modbus PLC, OPC-UA |
| Scenario 2: Transform Adapter | Takes an existing data item and extracts or reshapes its value | Parse operation number from a FANUC header, extract job ID from a program name |
Scenario 1: Hardware Adapter Scripts
Use this scenario when you are reading signals from hardware — a Sealevel or WISE I/O module, a Modbus PLC, an OPC-UA server, or similar — and need a script that maps those signals to execution state, part count, and other MachineMetrics data items.
What to Tell the AI
Work through these four areas before starting your chat.
1. Hardware and Protocol
Tell Max what device you are reading from:
- Sealevel eI/O-170E / eI/O-170PoE — analog and digital I/O module
- Advantech WISE-4050 or WISE-4050/LAN — wireless or wired I/O module
- Modbus TCP device — PLC, gateway, or controller (include make/model if known)
- OPC-UA server — include namespace info if you have it
- FANUC FOCAS, EtherNet/IP, or other CNC protocol — mention the controller model
2. What Is Wired Where
For each signal you are using, tell Max:
- Which terminal or channel — e.g., Opto 1, Opto 2, AN1, DI0, register 40005
- What is physically connected — e.g., spindle contactor relay, part ejector relay, green stack light, encoder, current transducer
- Signal type — analog voltage (0–10V CT), digital wet contact (machine supplies 24VDC), digital dry contact (relay closure, no voltage on wire), or Modbus register/coil
3. What Each Signal Means — the Most Important Part
Describe in plain English what should happen in MachineMetrics when each signal activates:
"When Opto 1 is ON, the machine is cutting — mark it as ACTIVE. When Opto 1 goes OFF, wait 10 seconds before switching to READY so brief tool changes don't drop the state."
"Opto 2 pulses briefly (less than 1 second) each time a part is ejected. Each pulse should count as one finished part."
"AN1 is a 0–10V current transducer on the spindle motor cable. When the voltage rises above 1.5V the machine is running and should be ACTIVE."
"Register at address 0, function code 3 on the WISE is the DI0 hardware counter. When it increases, parts are being made — derive execution state from counter activity with a 10-second hold."
4. Any Special Logic
- Should parts only count when the machine is also in auto mode?
- Do you need to ignore signals during setup programs or warmup?
- Are there multiple signals that together determine state — e.g., green light AND not in alarm?
- Is there a timing requirement like an off-delay to absorb tool changes?
Example: A Good Prompt
"I'm using a Sealevel eI/O-170E. Opto 1 is wired to the normally-open contact of a relay that closes when the spindle contactor energizes — so when Opto 1 is ON the machine is running and should be ACTIVE, when OFF it should be READY. Add a 10-second off-delay so brief tool changes don't drop to READY. Opto 2 is wired to a part ejector relay that pulses for about half a second each time a part comes off — count each ON pulse as one completed part. AN1 is a 0–10V current transducer on the spindle motor cable; output the voltage as a data item for trending."
Max will respond with a complete, commented adapter script covering all three signals.
Example: A Vague Prompt (Avoid This)
"I have a Sealevel and need execution and part count."
This tells Max almost nothing about wiring, signal types, thresholds, or logic. The result will be a generic template that still needs significant manual editing. Two extra minutes of description saves far more time than editing a vague script.
Quick-Reference Checklist
Fill this in for each signal before opening a chat with Max:
| Question | Example Answer |
|---|---|
| Hardware / protocol? | Sealevel eI/O-170E |
| Terminal or channel? | Opto 1 |
| What is connected to it? | Spindle contactor relay, normally-open contact |
| Signal type? | Dry contact |
| What does the signal being ON mean? | Machine spindle is running |
| MachineMetrics state or action? | ACTIVE execution state |
| Any timing? | 10-second off-delay |
| Conditions or filtering? | None for this signal |
Repeat for every input: Opto 2, AN1, DI0, a register address, and so on.
Scenario 2: Transform Adapter Scripts
Use this scenario when you already have a working machine connection (FANUC FOCAS, OPC-UA, Modbus, etc.) and want to take one of its existing data items and extract, reformat, or derive something new from it — without touching the original adapter.
A transform adapter sits on top of the parent adapter and only sees the data items you declare. No hardware addresses or registers are involved.
Common examples:
- A FANUC machine sends a header field like
CUSTOMER/JOB-5678/OP30— you want to extract justOP30as a data item calledoperation - A program name follows a pattern like
P12345-REV-A— you want just the part number12345 - An alarm code arrives as a raw number — you want a human-readable label based on ranges
- You want to combine spindle speed and feed rate into a single derived efficiency metric
What to Tell the AI
1. The Parent Adapter Type
Tell Max which adapter is already collecting data on this machine:
- FANUC FOCAS, Mitsubishi, Mazak, Okuma, DMG MORI, etc.
- OPC-UA, Modbus, EtherNet/IP
- This tells Max to generate a
declare-keysstyle script, not a hardware adapter
2. The Source Data Item Name
Tell Max the exact name of the data item that contains the value you want to work with. This is the name as it appears in MachineMetrics — you can find it in the machine's Diagnostics tab.
"The data item is called
program_comment."
"The data item is called
header."
3. A Real Example of What It Contains
Paste an actual sample of the value — this is more useful than describing it abstractly. Max can infer the pattern from a real example.
"Here is an example of what the header contains:
CUSTOMER-ABC/JOB-5678/OP30"
"The program comment looks like this:
(PART:A5678 OP:10 REV:B)"
4. What You Want Extracted — Give a Rule, Not Just an Example
Describe the extraction rule in plain English rather than just naming the value you want. A rule generalizes to every future value the field might contain.
| Instead of this... | Say this... |
|---|---|
| "Extract OP30" | "Extract everything after the last /" |
| "Get A5678" | "Extract the value after PART:" |
| "Pull out 10" | "Extract the digits after OP:" |
| "Get the part number" | "Extract the first sequence of digits in the string" |
5. What to Call the Output Data Item
Tell Max the name you want for the new data item in MachineMetrics:
"Call the output
operation."
"Output it as
part_number."
6. Any Additional Handling
- Should the extraction fail gracefully if the pattern is not present?
- Do you want to pass any other data items from the parent adapter through unchanged?
- Should any data items from the parent be blocked from MachineMetrics?
Example: A Good Prompt
"I have a FANUC FOCAS machine. There is a data item called
program_commentthat contains a header string. Here is a real example of what it looks like:CUSTOMER-ABC/JOB-5678/OP30. I want to extract the operation number — which is always the segment after the last/— and output it as a new data item calledoperation. Use a rule-based extraction, not hardcoded text, so it works for any header that follows this format."
From this, Max will generate a transform adapter using declare-keys and a pattern-match regex that extracts everything after the final /.
Example: A Vague Prompt (Avoid This)
"I need to get the operation from the program comment."
Max does not know what the data item is named, what the comment actually looks like, where in the string the operation lives, or what rule to apply. Always provide the data item name, a real sample value, and a plain-English extraction rule.
Quick-Reference Checklist
| Question | Example Answer |
|---|---|
| Parent adapter type? | FANUC FOCAS |
| Source data item name? | program_comment |
| Sample of the actual value? | CUSTOMER-ABC/JOB-5678/OP30 |
| Extraction rule (not just the target value)? | Everything after the last / |
| Output data item name? | operation |
| Pass other data items through? | Yes, pass execution and part_count through unchanged |
| Block any items? | No |
Click the Ask Max button in the navigation bar. Tell Max which scenario applies, then paste in your answers to the relevant checklist. The more concrete your description — especially a real sample value and a rule rather than just an example — the better the script will be on the first attempt.