บทที่ O07 · SCADA Workshop · Capstone

🏭 SCADA Workshop — Blink → Water Flow → Chocolate Factory

บทนี้คือ Workshop ลงมือทำ — ไม่ใช่บทอ่าน · เริ่มจากหลอดไฟกะพริบ (Concept ที่ง่ายที่สุด) ไปสู่ระบบเติมน้ำอัตโนมัติ จนถึง Capstone: โรงงานช็อกโกแลตที่ใช้ Recipe จริง · ทุก Step มีทั้ง Browser Sim ให้กดเล่นทันที + CX-Supervisor Lab Handout ให้ไปลงมือทำในซอฟต์แวร์จริง

โครงสร้าง 3 Step
· Step 1 · Blink — Boolean Point 1 ตัว · Animation ตัวเดียว · เข้าใจ Editor → Runtime
· Step 2 · Water Flow — 6 Points + Percentage Fill + Script + Auto-stop
· Step 3 · Chocolate Factory — Multi-pump + Mixing + Recipe + Alarm log · ครบทุก Concept ของ SCADA
วิธีใช้แต่ละ Step
1. อ่าน Objective + Process Diagram ของ Step นั้น
2. กดเล่น Browser Sim เพื่อทำความเข้าใจ Flow ก่อน
3. เปิด CX-Supervisor Trial ลงมือทำตาม Lab Handout
4. ผ่าน Checklist ท้าย Step ก่อนข้ามไป Step ถัดไป

🎯 เป้าหมายปลายทาง — SCADA จริงที่อยากให้ทำได้

Electric Furnace SCADA mimic
Industrial Sample Electric Furnace #1 System — Plant overview พร้อม Operator name, Power Meter, Trend, Gauge, Alarm — Mimic เดียวเห็นทั้งโรงงาน เล่ม 1 · ตำราอ้างอิง
Sugar/Syrup plant mimic
Industrial Sample Sugar Stew Plant — Stew Motor + Steam Valve + Sugar Hopper + Cyclone — Object หลากหลายชนิดบนหน้าเดียว · มีอักษรกำกับชัดเจน เล่ม 1 · ตำราอ้างอิง
6-step CX-Supervisor workflow diagram
Workflow 6 ขั้นตอนของ Page หนึ่งหน้า: วาดภาพ → กำหนดตัวแปร → กำหนดการเคลื่อนไหว → เขียน Script → เชื่อมต่อ PLC → รันโปรเจค · Workshop นี้พาทำครบทั้ง 6 เล่ม 1 · บทที่ 1

🔴 Step 1 · Blink — ไฟกะพริบหน้าเดียว

Objective

เข้าใจ ทาง 3 ทาง ของทุก SCADA project: Point (Tag) → Animation บน Shape → Runtime · จุดประสงค์ของ Step นี้ ไม่ใช่ ให้ไฟกะพริบ แต่ให้รู้ว่า "อะไรเชื่อมกับอะไร" ก่อนเข้าระบบที่ซับซ้อน

Process Diagram

Point: Lamp_Run

Boolean · 100.00

Animation: Visibility / Color

Shape บน Mimic Page

Runtime

Toggle 0↔1 / Script

🖥️ Browser Sim — ลองสร้างก่อน

กรอก Point → คลิกหลอดเพื่อเลือก → กดปุ่ม Animation → กด ▶ Build & Run → Toggle หรือเปิด Auto-blink

📘 Lab Handout — ลงมือใน CX-Supervisor Developer

New Project menu in CX-Supervisor
Step 1 File → New Project → CX-Supervisor Plus Project
เมนูตอนเริ่มสร้าง Project ใหม่ · ถ้ามี Lite license เลือก "Machine Edition Project" แทน เล่ม 1 · Exam 1 Blink
Point Editor with system points
Step 2 Point Editor — กดที่ไอคอนสีเหลือง (วงกลมแดงในภาพ) เพื่อ Add Point
$Hour, $Date, $AMPM ที่เห็นคือ System Points สำเร็จรูป — Point ของเราจะเพิ่มต่อจากนี้ เล่ม 1
Blink animation dialog with Digital Expression state == 1
Step 4 Blink Animation dialog — Digital Expression: state == 1 · เลือกสี Blink Colour (ในภาพคือสีแดง)
นี่คือทางลัด: ไม่ต้องเขียน Script เลย — แค่ใส่ Animation "Blink" บน Shape แล้ว Run เล่ม 1 · Exam 1
  1. เปิด Developer และสร้าง Project Start → CX-Supervisor → CX-Supervisor Developer Lite
    File → New Project → ชื่อ LAB1_Blink → OK
    ดูภาพข้างบน — เลือก CX-Supervisor Plus Project (หรือ Machine Edition ถ้าเป็น Lite)
  2. เพิ่ม Point Project workspace → Points → Right-click → Add Point
    • Name: Lamp_Run
    • Type: Boolean
    • I/O Source: Internal (ยังไม่ต่อ PLC จริง — ทดสอบใน PC ก่อน)
  3. วาง Shape เปิด Page Main → ลากวงกลม/สี่เหลี่ยมจาก Toolbox → ตั้งสีตามใจ
  4. ใส่ Animation คลิกขวาที่ Shape → Animations tab → เลือก
    • Visibility: Expression = Lamp_Run.Value = 1 · Show When True
    • หรือ Color: Expression = Lamp_Run.Value · เลือกสีเมื่อ 0 และเมื่อ 1
  5. (Optional) สร้าง Auto-blink Script Project → Scripts → Add → Page_OnTimer (interval = 500 ms)
    ⚠️ CX-Supervisor มี Script 2 ภาษาให้เลือก — ต้องเลือกให้ถูก
    ตอนสร้าง Script ใหม่ CX-Supervisor จะถาม Language:
    · VBScript — Syntax แบบ Microsoft · ใช้ ' comment · If ... Then ... End If · Point.Value · Application.LogEvent
    · CX-Supervisor Script — Syntax เฉพาะของ Omron · ใช้ (* ... *) comment · IF ... THEN ... ENDIF · Point := value
    Lab นี้ทุก Snippet เขียนด้วย VBScript — ตอนสร้าง Script ให้เลือก VBScript จาก dropdown ทุกครั้ง · ถ้าเลือกผิดภาษา Build จะ Error ทันที

    ภาษา: VBScript

    Lamp_Run.Value = Not Lamp_Run.Value
  6. Build & Run Project → BuildRun · กด Toggle Switch บน Mimic หรือดู Auto-blink
เช็คก่อนข้ามไป Step 2
☐ สร้าง Point ได้ครบ ทั้งใน Sim และ CX-Supervisor
☐ ใส่ Animation อย่างน้อย 1 ตัวบน Shape
☐ กด Run แล้วเห็นการเปลี่ยนแปลง (กะพริบหรือเปลี่ยนสี)
อธิบายได้ ว่า Point/Animation/Runtime ต่างกันยังไง

💧 Step 2 · Water Flow Tank — เติมน้ำอัตโนมัติ

Objective

ขยายจาก 1 Point เป็น 6 Points ครอบคลุม 4 พื้นที่ Address (CIO Input/Output, DM Word, Work Bit) · ใช้ Animation Percentage Fill + Color · เริ่มเขียน Script ที่มี Logic ดับ Pump เองเมื่อเต็มถัง — เข้าใจ "Closed-loop Level Control"

Process Diagram

Operator

  • Start · 0.00
  • Stop · 0.01
  • Drain · 0.02

Page_OnTick (VBScript)

If Pump=1 → WaterLV++ · ถ้า ≥ 90 → Pump=0, Level_High=1

Field

  • Pump · 100.00
  • Tank · WaterLV D100

🖥️ Browser Sim — ลองสร้างก่อน

สร้าง 6 Points (ดู cheat sheet ในช่องซ้าย) → ใส่ Animations 2 ตัว → ▶ Run → Start → ดู Pump auto-stop ที่ 90%

📘 Lab Handout — ลงมือใน CX-Supervisor Developer

Water Tank mimic — empty state with OFF/ON switches
Editor WATER TANK — Mimic (ตอนยังไม่รัน)
มี INLET pipe · OUTLET pipe · Tank rectangle (กรอบฟ้า) · Gauge แสดง 0–100 · ปุ่ม OFF/ON ทั้ง 2 ตัว
นี่คือ Stage Editor — ยังไม่ Run จึงไม่มีสีน้ำในถัง เล่ม 1 · Exam 4
Water Tank mimic — running with water filling
Runtime WATER TANK — กำลังรัน
Percentage Fill animation เติมสีน้ำเงินจากล่างขึ้นบน · Gauge เลื่อนขึ้นพร้อมกัน · ปุ่ม IN/OUT ใช้ควบคุม Pump
เป้าหมายของ Step 2 คือทำหน้าจอแบบนี้ให้ใช้งานได้ เล่ม 1 · Exam 4
Animation Editor showing all animation types
Animation Animation Editor — Object Actions
ทุก Animation ที่ใช้ได้: Blink, Close Page, Colour Change (Analogue/Digital), Display Page, Display Value, Move, Resize, Execute Script
Step 2 จะใช้: Display Value (Gauge) + Move/Resize (ระดับน้ำ) + Colour Change (Pump) เล่ม 1
  1. สร้าง Project ใหม่ + เพิ่ม PLC Connection (ถ้ามี CP1L) File → New ProjectLAB2_WaterFlow
    Project → Add PLC → CP1L · FinsEthernet · IP ของ PLC · Node 1 · Test Connection
    ถ้ายังไม่มี PLC จริง — ใช้ I/O Source = Internal ทุก Point
  2. เพิ่ม Points ครบ 6 ตัว ตามตาราง:
    ชื่อTypeAddressหน้าที่
    StartBoolean0.00 (CIO Input)ปุ่ม Start หน้าตู้
    StopBoolean0.01ปุ่ม Stop
    DrainBoolean0.02เปิดวาล์วระบาย
    PumpBoolean100.00 (CIO Output)คำสั่ง Pump motor
    WaterLVIntegerD100 (DM)ระดับน้ำ 0–100%
    Level_HighBooleanW0.00 (Work)Flag เต็มถัง
  3. วาด Mimic — ถัง + ท่อ + Pump
    • วาดถัง: Rectangle สูง · กรอบสีส้ม
    • วาด Pump: ใช้ Library Symbol → Pumps
    • วาง Numeric Display แสดง WaterLV
    • วาง 3 ปุ่ม (Start/Stop/Drain) ผูกกับ Points
  4. ใส่ Animation
    • Tank · Percentage Fill — คลิก Tank → Animations → Percentage Fill
      Expression: WaterLV.Value · Min 0 / Max 100 · Direction: Bottom to Top
    • Pump · Color — Expression: Pump.Value · 0=Gray, 1=Green
  5. เขียน Script Logic Scripts → Page_OnTick (interval = 500 ms) · ตอนสร้าง Script เลือก VBScript เหมือน Step 1

    ภาษา: VBScript

    ' Start button — start pump
    If Start.Value = 1 Then
        Pump.Value = 1
        Level_High.Value = 0
    End If
    
    ' Stop button
    If Stop.Value = 1 Then
        Pump.Value = 0
    End If
    
    ' Pump fills tank
    If Pump.Value = 1 Then
        WaterLV.Value = WaterLV.Value + 1
        If WaterLV.Value >= 90 Then
            Pump.Value = 0
            Level_High.Value = 1
            Application.LogEvent "Tank full — pump auto-stopped"
        End If
    End If
    
    ' Drain valve removes water
    If Drain.Value = 1 And WaterLV.Value > 0 Then
        WaterLV.Value = WaterLV.Value - 1
    End If
  6. (ทางเลือก) เพิ่ม Trend + Alarm
    • วาง Trend Object → Pens → WaterLV 0–100, Sample 1 s
    • Point WaterLV → Alarms tab → Add: High 90 · Message "Tank full"
  7. Build & Run · ทดสอบ Auto-stop กด Start → ดูถังเติม → ถึง 90% → Pump ปิดเอง → Level_High = 1 → Alarm "Tank full" ขึ้น
เช็คก่อนข้ามไป Step 3
☐ Points 6 ตัวสร้างครบ — ตรง Area ถูกต้อง (Input/Output/DM/Work)
☐ Percentage Fill ทำงานถูกทิศ — เติมจากล่างขึ้นบน
☐ Script auto-stop ที่ 90% ได้
เข้าใจหลัก "Self-holding" — แม้ปล่อยปุ่ม Start แล้ว Pump ยังทำงานต่อจนถึงเงื่อนไขหยุด

🍫 Step 3 · Chocolate Factory — Capstone

Objective

โปรเจค รวมทุกอย่าง: Multi-pump (2 ปั๊ม), Mixing tank, Outlet valve, Recipe สำหรับเปลี่ยนสูตร, Alarm log, Multi-stage sequence — เหมือนระบบ Batch จริงในอุตสาหกรรม
อิงตำรา การประยุกต์ใช้โปรแกรม SCADA ในงานอุตสาหกรรม เล่ม 2 · Exam 5 (Milk + Chocolate blending)

Process Diagram

Chocolate Factory SCADA mimic — Mix tank with PUMP_CHO, PUMP_MILK and OUTLET valve
Plant Mimic Chocolate Factory — CX-Supervisor Mimic
Mix tank ตรงกลาง (มี Gauge 0–100) · PUMP_CHO + PUMP_MILK ฝั่งซ้ายป้อนเข้า · OUTLET valve ฝั่งขวาถ่ายลงขวด · Toggle Switch + START/STOP บนแผง เล่ม 2 · Exam 5 · Plant Overview

Recipes (3 สูตร)

RecipeMilkPctCocoaPctผลลัพธ์
🥛 Classic Milk Choc50%20%นม·ครีมมี่
🌑 Dark Chocolate30%40%โกโก้สูง·เข้ม
🤍 White Chocolate70%10%นมสูง·สีอ่อน

📘 Lab Handout — ลงมือใน CX-Supervisor Developer

📌 ที่มา — Vol 2 Exam 5 ของจริง ภาพข้างล่างมาจาก การประยุกต์ใช้โปรแกรม SCADA ในงานอุตสาหกรรม เล่ม 2 · Exam 5 โดยตรง — ใช้เป็นแม่แบบได้เลย ทั้ง Tag names · Address · Ladder logic ในตำราจริงตรงกับ Sim ทุกอย่าง
Ladder logic — PUMP_MILK self-holding rung
Ladder Rung 1 — PUMP_MILK (CX-Programmer)
Self-hold: START_PUMP_MILK (I:0.00) + Q:100.00 hold · Stop: STOP_PUMP_MILK (I:0.03) + Stop_PumpMilkScada (200.03)
200.00 / 200.03 = Internal Work Bits ที่ SCADA เขียนแทนปุ่มจริง เล่ม 2 · Exam 5 · Rung 1
Ladder logic — OUTLET valve rung
Ladder Rung 2 — OUTLET valve
โครงเดียวกับ PUMP_MILK · I:0.02 Start, I:0.05 Stop · Q:100.02 → OUTLET
เพิ่ม Rung 3 สำหรับ PUMP_CHO เหมือนกัน (I:0.01 / I:0.04 / Q:100.01) เล่ม 2 · Exam 5 · Rung 2
Reversible counter — PUMP_MILK / PUMP_CHO / OUTLET
Counter Reversible Counter CNT(012)
นับว่ามี Output ตัวไหนทำงาน · CF103 = clock 0.02s · Counter เพิ่มเมื่อ Q:100.00, Q:100.01, Q:100.02 ทำงาน
ใช้เป็น Production Counter — นับจำนวน Batch ที่ผลิตเสร็จ เล่ม 2 · Exam 5 · Rung 3
Toggle Button Wizard binding StartPumpMilkScada
SCADA Toggle Button Wizard — Boolean Point: StartPumpMilkScada
State 0 = "Off" สีแดง · State 1 = "On" สีเขียว · Style: Toggle Switch
ปุ่ม Start แต่ละตัวในตำราใช้ pattern นี้: 1 ปุ่ม → เขียนค่าลง 1 Work Bit (200.xx) → Ladder อ่านไปกระตุ้น Pump เล่ม 2 · Exam 5
  1. Project ใหม่ + I/O Mapping File → New Project → LAB3_ChocFactory
    Points ตามตำราเล่ม 2:
    ชื่อ PointTypeAddressหมายเหตุ
    Start_PumpMilkBoolean0.00ปุ่ม Start ปั๊มนม
    Stop_PumpMilkBoolean0.03ปุ่ม Stop ปั๊มนม
    Start_PumpChoBoolean0.01ปุ่ม Start ปั๊มโกโก้
    Stop_PumpChoBoolean0.04ปุ่ม Stop ปั๊มโกโก้
    Start_OutletBoolean0.02ปุ่มเปิด Outlet
    Stop_OutletBoolean0.05ปุ่มปิด Outlet
    PumpMilkBoolean100.00Output ปั๊มนม
    PumpChoBoolean100.01Output ปั๊มโกโก้
    OutletBoolean100.02Output Outlet valve
    MilkPctIntegerD100ระดับนมใน Mix tank
    CocoaPctIntegerD102ระดับโกโก้ใน Mix tank
    StageIntegerD104State machine 0–4
  2. วาด Plant Mimic
    • 3 ถัง: Milk (ซ้าย) · Mix (กลาง·ใหญ่) · Cocoa (ขวา)
    • 2 ปั๊ม + 1 Outlet valve · ใช้ Library Symbol
    • Bottle ใต้ Outlet (ปลายทาง)
    • Mixer ในถัง Mix — Static image, ใช้ Animation Rotate ขณะปั่น
    • Numeric Display: MilkPct · CocoaPct · จำนวนขวดที่ผลิต
  3. Animations ที่ใช้
    • Mix tank → Percentage FillMilkPct + CocoaPct
    • Mix tank → Color เปลี่ยนตาม Recipe (ขาว→น้ำตาล→ดำ)
    • PumpMilk/PumpCho → Color เมื่อ Output = 1 (สีเขียว)
    • Mixer → Rotate Continuous เมื่อ Stage = 2 (Mixing)
    • Bottle → Percentage Fill เมื่อ Outlet เปิด
  4. สร้าง Recipe Group Project → Add → Recipe → ChocRecipes
    Fields: MilkTarget · CocoaTarget
    Recipes 3 รายการ:
    • Milk: Milk=50 · Cocoa=20
    • Dark: Milk=30 · Cocoa=40
    • White: Milk=70 · Cocoa=10
  5. เพิ่ม Recipe Buttons วาง 3 ปุ่มบน Mimic · OnClick Script (เลือก VBScript เป็น Language):

    ภาษา: VBScript

    ' Button: Milk recipe
    RecipeLoad "ChocRecipes", "Milk"
    Stage.Value = 1   ' เริ่ม Stage 1
  6. State Machine Script Page_OnTick (interval = 200 ms) · เลือก VBScript เป็น Language

    ภาษา: VBScript

    Select Case Stage.Value
      Case 1  ' Pump Milk จนถึง target
        PumpMilk.Value = 1 : PumpCho.Value = 0 : Outlet.Value = 0
        If MilkPct.Value < MilkTarget.Value Then
            MilkPct.Value = MilkPct.Value + 1
        Else
            PumpMilk.Value = 0 : Stage.Value = 2
        End If
      Case 2  ' Pump Cocoa จนถึง target
        PumpMilk.Value = 0 : PumpCho.Value = 1
        If CocoaPct.Value < CocoaTarget.Value Then
            CocoaPct.Value = CocoaPct.Value + 1
        Else
            PumpCho.Value = 0 : Stage.Value = 3 : MixTimer = 0
        End If
      Case 3  ' Mixing 2 วินาที
        MixTimer = MixTimer + 1
        If MixTimer >= 10 Then Stage.Value = 4
      Case 4  ' Outlet ถ่ายลงขวด
        Outlet.Value = 1
        MilkPct.Value = MilkPct.Value - 1
        CocoaPct.Value = CocoaPct.Value - 1
        If MilkPct.Value <= 0 And CocoaPct.Value <= 0 Then
            Outlet.Value = 0
            BottleCount.Value = BottleCount.Value + 1
            Stage.Value = 0
            Application.LogEvent "Bottle produced"
        End If
    End Select
  7. เพิ่ม Alarms
    • MilkPct · High = 95 · Message "Mix tank near full"
    • Stage · Equal = 4 · Message "Dispensing to bottle"
    • วาง Alarm Summary บน Page ให้ Operator เห็น log
  8. (ขั้นสูง) Trend + Data Log
    • Trend: MilkPct + CocoaPct เส้นต่างสี — Sample 200 ms
    • Data Logging → เก็บ BottleCount + RecipeName + เวลาทุก batch ลง CSV หรือ SQL
  9. Build & Run · ทดสอบ 3 Recipes เลือก Milk → ผลิต 1 ขวด → เลือก Dark → ดูสีเข้มขึ้น → ลอง White → ตรวจ Alarm log + Trend
Pitfalls ที่พบบ่อย
· Stage Variable หาย — ใช้ Holding (H) แทน DM ถ้าไม่อยาก reset ทุกครั้งที่ Build
· Percentage Fill เติมจากบน — ตรวจ Fill Direction ใน Animation dialog (เลือก Bottom to Top)
· Mixer หมุนตลอด — Rotate animation ต้องผูก Expression Stage.Value = 2 ไม่ใช่ค่าคงที่
· Recipe ไม่โหลด — ตรวจชื่อ Recipe Group ใน RecipeLoad ให้ตรงตัวพิมพ์

🎯 Capstone Checklist

ตรวจสอบความเข้าใจ
☐ 12 Points สร้างครบ · address ตรงตาม spec
☐ Mimic แสดงภาพทั้ง Plant — ไม่ใช่แค่ตัวเลข
☐ Animations อย่างน้อย 4 ประเภท (Fill · Color · Rotate · Visibility)
☐ Recipe Switch ทำงานได้ทั้ง 3 สูตร
☐ State Machine ทำ Sequence จบครบ (Stage 1→2→3→4→0)
☐ Alarm log + Trend chart ทำงาน
นำเสนอ Plant ของตัวเองได้ — บอก Concept SCADA ครบ 3 ส่วน (Point/Page/Script)

🎉 จบ Omron Track — ครบ Toolchain Automation

ขอแสดงความยินดี — ถ้าทำมาถึงตรงนี้ได้ คุณมีทักษะครบเซตของ Omron Automation:

ขั้นต่อไป — ลอง Mitsubishi Track เพื่อเทียบ Syntax/Toolchain ที่ต่างกัน หรือไปทำ โปรเจคจริง ที่นำ Plant ของตัวเองมาเขียน · ใช้บทนี้เป็น Template ได้ทันที

เอกสารอ้างอิงสำหรับบทนี้