Hielscher Ultrasonics
고객님의 공정에 대해 기꺼이 상담해 드리겠습니다.
전화해 주세요: +49 3328 437-420
이메일 문의: [email protected]

Hielscher 초음파 처리기 XML 데이터용 실시간 Excel 로거

이 Hielscher 초음파 처리기용 실시간 Excel 로거는 XML 형식으로 스트리밍되는 실시간 초음파 처리 데이터를 시각화할 수 있는 경량 VBA 기반 솔루션입니다. 초음파 처리기의 로컬 IP를 통해 자동으로 연결하고, 실시간 공정 데이터를 읽어 Excel 표에 기록하며, 동적 차트를 업데이트합니다. 이를 통해 사용자는 Excel 내에서 직접 출력, 진폭, 에너지, 온도 등의 주요 매개변수를 실시간으로 모니터링할 수 있습니다.

작동 방식

스크립트를 실행하면 XML 소스 주소, 즉 초음파 처리기의 xml 데이터 주소(예: http://192.168.233.233/mdata.xml )를 입력하라는 메시지가 사용자에게 표시됩니다. 그런 다음 구조화된 머리글 행을 만들고 매초 데이터를 가져오기 시작합니다. 각각의 새 데이터 포인트가 표에 추가되고, 선으로 연결된 분산형 차트가 시간에 따른 출력, 진폭 및 에너지 추이를 표시합니다. 센서 오류 값(예: 센서가 연결되지 않은 경우)은 모두 자동으로 걸러집니다.

Windows 사용자용 지침

Excel에서 Visual Basic 편집기를 열고 새 모듈을 삽입한 다음 전체 스크립트를 붙여넣으세요. InitLogger 매크로를 실행하면 로거가 자동으로 시작됩니다. 매크로가 활성화되어 있고 Excel에 네트워크 접근 권한이 있는지 확인하세요.

macOS 사용자용 지침

Excel에서 Visual Basic 편집기를 여세요. 새 모듈을 삽입하고 전체 스크립트를 붙여넣으세요. 동일한 매크로를 실행하기만 하면 입력한 IP를 사용하여 데이터를 가져옵니다. macOS 사용자는 Excel이 AppleScript를 실행하도록 허용해야 하며, 권한 요청 메시지가 표시되면 시스템 환경설정에서 네트워크 접근 권한을 부여해야 할 수도 있습니다.

초음파 처리기 XML 데이터를 Excel 스프레드시트로 불러오는 Excel VBA 코드.

Excel VBA 코드를 실행하여 초음파 처리기 XML 데이터를 스프레드시트로 불러오세요.

업데이트, 면책 조항 및 라이선스

장치 유형과 제공된 소프트웨어 버전에 따라 XML 데이터 문자열이 달라질 수 있습니다. 포함된 값의 개수가 다르고 순서나 형식도 다를 수 있습니다. 따라서 이에 맞게 아래 스크립트를 조정해야 할 수도 있습니다. 기술 지원, 버그 수정 또는 향후 업데이트를 제공할 의무는 없습니다. 이 도구는 어떠한 종류의 보장이나 보증도 없이 제공됩니다. 여기에는 상품성 또는 특정 목적에의 적합성과 같은 묵시적 보증의 배제가 명시적으로 포함됩니다. Hielscher Ultrasonics는 소프트웨어 사용으로 인해 발생하는 직접적, 간접적 또는 결과적 손해를 포함한 어떠한 손해에 대해서도 책임을 지지 않습니다. 이는 예시일 뿐입니다. 비상업적 목적 및 연구 목적으로만 무료로 사용할 수 있습니다. 적절한 출처 표시를 하는 경우 재배포가 허용됩니다. 사전 서면 동의 없이 상업적으로 재판매하거나 독점 시스템에 포함하는 것은 엄격히 금지됩니다.

초음파 처리기 데이터를 Excel로 불러오기 위한 Excel 구현.

초음파 처리기 XML 데이터를 Excel 스프레드시트로 가져오기

정보 요청




초음파 처리기의 실시간 데이터를 Excel 스프레드시트에 직접 기록하는 방법이 영상에서는 초음파 처리기의 XML 데이터를 Microsoft Excel에 기록하는 방법을 보여 줍니다.
이 영상에서는 초음파 처리기의 XML 데이터를 Microsoft Excel에 기록하는 방법을 보여 줍니다.

' ==============================================================================
' Realtime Excel Logger for Hielscher Sonicator XML Data
'
' Description:
' This VBA module fetches XML data from a Hielscher sonicator over the network
' (typically from a local IP like http://192.168.233.233/mdata.xml), parses it,
' logs real-time data into Excel, and visualizes selected parameters (Power, Amplitude,
' and Energy) using a live updating scatter-line chart.
'
' Disclaimer & License:
' This script is provided "as is" without any warranty. It is free for non-commercial
' use, and redistribution is permitted only with attribution. Resale or inclusion in
' commercial software is strictly prohibited without explicit permission.
' (c) Hielscher Ultrasonics GmbH (Germany), 2025. All rights reserved. https://www.hielscher.com
' Last Update: June 17th, 2025, for sonicator software version 25.0.1
' ==============================================================================

' === Realtime Excel Logger Module ===
Dim nextRow As Long                     ' Row index for logging the next data point
Dim chartObject As chartObject          ' Reference to the live chart object
Dim isRunning As Boolean                ' Controls whether logging continues

' === MAIN ENTRY POINT ===
Sub InitLogger()
    Dim ws As Worksheet
    Set ws = Sheet1                     ' Use the first worksheet

    ws.Cells.Clear                      ' Clear all existing content on the sheet

    ' Request and store the XML source IP address
    ws.Cells(1, 1).Value = "XML Source"
    ws.Cells(1, 2).Value = InputBox("Enter device IP address", "XML Source", "http://192.168.233.233/mdata.xml")

    ' Create header row starting at row 2
    ws.Cells(2, 1).Resize(1, 14).Value = Array( _
        "Timestamp", "Status", "Total Power (W)", "Net Power (W)", "Amplitude (%)", _
        "Energy (Ws)", "ADC", "Frequency (Hz)", "Temperature (°C)", "Time (s)", _
        "ControlBits", "LimitType", "SetPower (%)", "Cycle (%)")

    nextRow = 3                         ' Start logging at row 3
    isRunning = True                    ' Enable logging loop
    Application.OnTime Now + TimeSerial(0, 0, 1), "LoggerTick" ' Schedule first data fetch
End Sub

' === PERIODIC TIMER CALLBACK ===
Sub LoggerTick()
    If Not isRunning Then Exit Sub
    FetchOnce
    Application.OnTime Now + TimeSerial(0, 0, 1), "LoggerTick" ' Schedule next fetch
End Sub

' === FETCH AND LOG DATA ===
Sub FetchOnce()
    Dim ipAddress As String, rawData As String
    Dim dataFields() As String, mStart As Long, mEnd As Long
    Dim ws As Worksheet: Set ws = Sheet1

    ipAddress = Trim(ws.Cells(1, 2).Value)   ' Get IP from input cell
    If ipAddress = "" Then Exit Sub          ' Exit if IP is missing

    rawData = GetMDataXML(ipAddress)         ' Fetch the raw XML from device
    If rawData = "" Then Exit Sub            ' Exit if fetch failed

    ' Extract only the content inside  ... 
    mStart = InStr(rawData, "")
    mEnd = InStr(rawData, "")
    If mStart = 0 Or mEnd = 0 Then Exit Sub  ' Exit if tag not found

    rawData = Mid(rawData, mStart + 7, mEnd - mStart - 7)
    dataFields = Split(rawData, ";")        ' Parse by semicolon delimiter
    If UBound(dataFields) < 12 Then Exit Sub ' Ensure all fields are present

    ' Determine next available row
    nextRow = ws.Cells(ws.Rows.Count, 1).End(xlUp).Row + 1

    ' Write parsed values into worksheet
    With ws
        .Cells(nextRow, 1).Value = Format(Now, "yyyy-mm-dd HH:nn:ss")           ' Timestamp (rounded to seconds)
        .Cells(nextRow, 2).Value = Val(dataFields(0))                            ' Status
        .Cells(nextRow, 3).Value = Val(dataFields(1)) / 10                       ' Total Power (W)
        .Cells(nextRow, 4).Value = Val(dataFields(2)) / 10                       ' Net Power (W)
        .Cells(nextRow, 5).Value = Val(dataFields(3)) / 10                       ' Amplitude (%)
        .Cells(nextRow, 6).Value = Val(dataFields(4))                            ' Energy (Ws)
        .Cells(nextRow, 7).Value = Val(dataFields(5)) / 10                       ' ADC
        .Cells(nextRow, 8).Value = Val(dataFields(6))                            ' Frequency (Hz)
        .Cells(nextRow, 9).Value = IIf(Val(dataFields(7)) = 2550, "", Val(dataFields(7)) / 10) ' Temperature (°C), blank if 255
        .Cells(nextRow, 10).Value = Val(dataFields(8)) / 10                      ' Time (s)
        .Cells(nextRow, 11).Value = Val(dataFields(9))                           ' ControlBits
        .Cells(nextRow, 12).Value = IIf(Val(dataFields(10)) = 0, "", Val(dataFields(10)))     ' LimitType, blank if 0
        .Cells(nextRow, 13).Value = Val(dataFields(11)) / 20                     ' SetPower (%)
        .Cells(nextRow, 14).Value = Val(dataFields(12)) / 10                     ' Cycle (%).Value = Val(dataFields(12)) / 10     ' Cycle (%)
    End With

    UpdateChart
End Sub

' === CREATE / UPDATE SCATTER-LINE CHART ===
Sub UpdateChart()
    Dim ws As Worksheet: Set ws = Sheet1
    Dim lastRow As Long: lastRow = ws.Cells(ws.Rows.Count, 1).End(xlUp).Row
    If lastRow < 4 Then Exit Sub

    ' Format timestamp column to display yyyy-mm-dd HH:mm:ss
    ws.Columns(1).NumberFormat = "yyyy-mm-dd hh:mm:ss"

    ' Create chart if not already initialized
    If chartObject Is Nothing Then
        Set chartObject = ws.ChartObjects.Add(Left:=ws.Cells(2, 16).Left, Top:=ws.Cells(2, 16).Top, Width:=500, Height:=300)
        chartObject.Name = "LiveChart"
    End If

    ' Configure the scatter line chart with latest data
    With chartObject.Chart
        .ChartType = xlXYScatterLines
        Do While .SeriesCollection.Count > 0: .SeriesCollection(1).Delete: Loop

        ' Plot Total Power
        .SeriesCollection.NewSeries
        .SeriesCollection(1).Name = "Power (W)"
        .SeriesCollection(1).XValues = ws.Range("A3:A" & lastRow)
        .SeriesCollection(1).Values = ws.Range("C3:C" & lastRow)

        ' Plot Amplitude
        .SeriesCollection.NewSeries
        .SeriesCollection(2).Name = "Amplitude (%)"
        .SeriesCollection(2).XValues = ws.Range("A3:A" & lastRow)
        .SeriesCollection(2).Values = ws.Range("E3:E" & lastRow)

        ' Plot Energy
        .SeriesCollection.NewSeries
        .SeriesCollection(3).Name = "Energy (Ws)"
        .SeriesCollection(3).XValues = ws.Range("A3:A" & lastRow)
        .SeriesCollection(3).Values = ws.Range("F3:F" & lastRow)

        .HasTitle = True
        .ChartTitle.Text = "Hielscher Sonicator: Live Chart"
        .Axes(xlCategory).HasTitle = True
        .Axes(xlCategory).AxisTitle.Text = "Time"
        .Axes(xlValue).HasTitle = True
        .Axes(xlValue).AxisTitle.Text = "Value"

        ' Format the X-axis to show MM:SS
        .Axes(xlCategory).TickLabels.NumberFormat = "mm:ss"
    End With
End Sub

' === FETCH XML VIA PLATFORM-SPECIFIC METHOD ===
Function GetMDataXML(ip As String) As String
    Dim os As String: os = Application.OperatingSystem

    ' macOS: use AppleScript shell call to curl
    If InStr(1, os, "Mac", vbTextCompare) > 0 Then
        Dim script As String
        script = "do shell script " & Chr(34) & "curl -s " & ip & Chr(34)
        On Error Resume Next
        GetMDataXML = MacScript(script)
        If Err.Number <> 0 Then GetMDataXML = ""

    ' Windows: use MSXML2.XMLHTTP request
    Else
        Dim http As Object
        Set http = CreateObject("MSXML2.XMLHTTP")
        On Error Resume Next
        http.Open "GET", ip, False
        http.Send
        If Err.Number = 0 And http.Status = 200 Then
            GetMDataXML = http.responseText
        Else
            GetMDataXML = ""
        End If
    End If
End Function

고객님의 공정에 대해 기꺼이 상담해 드리겠습니다.

✕