---
title: "Export the alarm history of a Yaskawa robot"
description: "Download ALMHIST.DAT, the alarm history of a Motoman controller, turn it into a CSV file with the code, job, line and date of each alarm, and find the alarms that come back."
---

# Export the alarm history of a Yaskawa robot

Which alarm stops this robot every week, and in which job? A Yaskawa Motoman controller keeps its alarm history in the file `ALMHIST.DAT`. This page shows what the file contains, and how to download it from a PC and turn it into a CSV file in C# or Python.

## What ALMHIST.DAT contains

The controller keeps the last 100 alarms of each category. Errors (the messages that do not stop the robot) are not stored. On the pendant, the history is in `SYSTEM INFO > ALARM HISTORY`, and `EX. MEMORY > SAVE > SYSTEM DATA` saves the file.

| Section | Category |
| --- | --- |
| `///MAJOR` | Major alarms |
| `///MINOR` | Minor alarms |
| `///IO_SYS` | User alarms (system) |
| `///IO_USR` | User alarms (user) |
| `///OFFLINE` | Off-line alarms |

These are the section titles of a DX200 file. Each alarm is a record of a few lines (invented values):

```
4107,OUT OF RANGE(ABSO DATA),ROBOT1,[SLURBT],[000100],PLAY,
PICK,12,5,STOP
,0,0,********
,0,0,********
,0,0,********
2026/10/14 08:12:40
```

| Line | Content |
| --- | --- |
| First | Alarm code, name, axis data, mode |
| Second | Job, line, step at the time of the alarm |
| Last | Date and time |

The layout of the record comes from a DX200, and it can differ with the controller and its software. The parser below keeps only the fields it needs and skips the lines it does not know.

## Export to CSV

The program reads the file through the web server of the controller (YRC1000 and YRC1000micro, no account, any mode), saves a copy, writes one CSV line per alarm, and prints the five alarms that come back most often.

**C# : AlarmHistoryCsv**
```csharp
using System.Text.RegularExpressions;
using UnderAutomation.Yaskawa;

public class AlarmHistoryCsv
{
    static void Main()
    {
        var parameters = new ConnectParameters("192.168.0.1");
        parameters.Http.Enable = true;
        var robot = new YaskawaRobot();
        robot.Connect(parameters);

        /**/
        string text = robot.Http.GetFile("ALMHIST.DAT");
        File.WriteAllText("ALMHIST.DAT", text); // the file that Yaskawa support asks for

        // A record: "code,name,axis data,mode,..." (mode is the 6th field), "job,line,step,...", other lines, the date
        var rows = new List<string[]>();
        string category = "";
        string[] alarm = null, job = null;
        foreach (string raw in text.Split('\n'))
        {
            string line = raw.Trim();
            if (line.StartsWith("///")) { category = line.Substring(3); alarm = null; }
            else if (alarm == null)
            {
                string[] f = line.Split(',');
                if (f.Length > 2 && int.TryParse(f[0], out _)) { alarm = f; job = null; }
            }
            else if (job == null) job = line.Split(',');
            else if (Regex.IsMatch(line, @"^\d{4}/\d\d/\d\d \d\d:\d\d"))
            {
                rows.Add(new[] { category, alarm[0], alarm[1], alarm.ElementAtOrDefault(5), job[0], job.ElementAtOrDefault(1), job.ElementAtOrDefault(2), line });
                alarm = null;
            }
        }

        File.WriteAllLines("alarms.csv", rows.Select(r => string.Join(";", r)).Prepend("Category;Code;Name;Mode;Job;Line;Step;Date"));

        // The alarms that come back most often, and the job where they occur
        foreach (var g in rows.GroupBy(r => $"{r[1]} {r[2]} in {r[4]}").OrderByDescending(g => g.Count()).Take(5))
            Console.WriteLine($"{g.Count()} x {g.Key}");
        /**/

        robot.Disconnect();
    }
}
```

**Python : AlarmHistoryCsv**
```python
import csv
import re
from collections import Counter
from underautomation.yaskawa.yaskawa_robot import YaskawaRobot
from underautomation.yaskawa.connect_parameters import ConnectParameters

parameters = ConnectParameters("192.168.0.1")
parameters.http.enable = True
robot = YaskawaRobot()
robot.connect(parameters)

##
text = robot.http.get_file("ALMHIST.DAT")
with open("ALMHIST.DAT", "w", newline="") as f:
    f.write(text)  # the file that Yaskawa support asks for

# A record: "code,name,axis data,mode,..." (mode is the 6th field), "job,line,step,...", other lines, the date
rows = []
category, alarm, job = "", None, None
for line in (raw.strip() for raw in text.splitlines()):
    if line.startswith("///"):
        category, alarm = line[3:], None
    elif alarm is None:
        fields = line.split(",")
        if len(fields) > 2 and fields[0].isdigit():
            alarm, job = fields, None
    elif job is None:
        job = line.split(",") + ["", ""]
    elif re.match(r"^\d{4}/\d\d/\d\d \d\d:\d\d", line):
        rows.append([category, alarm[0], alarm[1], (alarm + [""] * 6)[5], job[0], job[1], job[2], line])
        alarm = None

with open("alarms.csv", "w", newline="") as f:
    writer = csv.writer(f, delimiter=";")
    writer.writerow(["Category", "Code", "Name", "Mode", "Job", "Line", "Step", "Date"])
    writer.writerows(rows)

# The alarms that come back most often, and the job where they occur
for key, count in Counter(f"{r[1]} {r[2]} in {r[4]}" for r in rows).most_common(5):
    print(f"{count} x {key}")
##

robot.disconnect()
```

On a controller without the web server, read the file with the High Speed Ethernet Server: `HighSpeedEServer.GetFile("ALMHIST.DAT").Content`. With FTP, `Ftp.GetFile("ALMHIST.DAT")` needs the `ftp` account, because the file is in the system data. See [FTP](/yaskawa/documentation/ftp).

Example of output (invented values):

```
12 x 4107 OUT OF RANGE(ABSO DATA) in PICK
5 x 4315 COLLISION DETECT in WELD01
```

## What to do with it

- **Find the recurring alarm.** Count per code and per job: the job and the line point to the place in the program.
- **Compare robots.** The same export on every robot of a line shows the cell that stops more than the others.
- **Open a ticket.** Yaskawa support asks for `ALMHIST.DAT`. The program saves it next to the CSV: attach it as it is.

## Live alarms or history

| Need | Use |
| --- | --- |
| Know at once that the robot stops | `GetAlarm`: the 4 most recent alarms, read in a loop. See [Read and reset alarms](/yaskawa/documentation/how-to-read-reset-alarms) |
| Know why it stops every week | `ALMHIST.DAT`: 100 alarms per category, with the job and the line |

Live, the SDK reads the 4 most recent alarms: the longer history comes from the file.

## Without code

TouchUp, the robot workbench for VS Code, saves `ALMHIST.DAT` with the other system data in a Yaskawa backup, and compares two backups. See [Back up a controller](/touchup/documentation/backup).

## See also

- [Alarms](/yaskawa/documentation/hses-alarms): the reference of the alarm methods
- [Yaskawa controller files: what a backup contains](/yaskawa/documentation/yaskawa-controller-backup-files)
- [Read the operating hours](/yaskawa/documentation/yaskawa-robot-operating-hours)
- [HTTP: read files from the web server](/yaskawa/documentation/http)