🏭 SCADA Workshop — Blink → Water Flow → Chocolate Factory
บทนี้คือ Workshop ลงมือทำ — ไม่ใช่บทอ่าน · เริ่มจากหลอดไฟกะพริบ (Concept ที่ง่ายที่สุด) ไปสู่ระบบเติมน้ำอัตโนมัติ จนถึง Capstone: โรงงานช็อกโกแลตที่ใช้ Recipe จริง · ทุก Step มีทั้ง Browser Sim ให้กดเล่นทันที + CX-Supervisor Lab Handout ให้ไปลงมือทำในซอฟต์แวร์จริง
· 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
1. อ่าน Objective + Process Diagram ของ Step นั้น
2. กดเล่น Browser Sim เพื่อทำความเข้าใจ Flow ก่อน
3. เปิด CX-Supervisor Trial ลงมือทำตาม Lab Handout
4. ผ่าน Checklist ท้าย Step ก่อนข้ามไป Step ถัดไป
🎯 เป้าหมายปลายทาง — SCADA จริงที่อยากให้ทำได้
🔴 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
เมนูตอนเริ่มสร้าง Project ใหม่ · ถ้ามี Lite license เลือก "Machine Edition Project" แทน เล่ม 1 · Exam 1 Blink
$Hour, $Date, $AMPM ที่เห็นคือ System Points สำเร็จรูป — Point ของเราจะเพิ่มต่อจากนี้ เล่ม 1
state == 1 · เลือกสี Blink Colour (ในภาพคือสีแดง)
นี่คือทางลัด: ไม่ต้องเขียน Script เลย — แค่ใส่ Animation "Blink" บน Shape แล้ว Run เล่ม 1 · Exam 1
-
เปิด Developer และสร้าง Project
Start → CX-Supervisor → CX-Supervisor Developer LiteFile → New Project→ ชื่อLAB1_Blink→ OK
ดูภาพข้างบน — เลือก CX-Supervisor Plus Project (หรือ Machine Edition ถ้าเป็น Lite) -
เพิ่ม Point
Project workspace → Points → Right-click → Add Point- Name:
Lamp_Run - Type: Boolean
- I/O Source: Internal (ยังไม่ต่อ PLC จริง — ทดสอบใน PC ก่อน)
- Name:
-
วาง Shape
เปิด Page
Main→ ลากวงกลม/สี่เหลี่ยมจาก Toolbox → ตั้งสีตามใจ -
ใส่ Animation
คลิกขวาที่ Shape →
Animationstab → เลือก- Visibility: Expression =
Lamp_Run.Value = 1· Show When True - หรือ Color: Expression =
Lamp_Run.Value· เลือกสีเมื่อ 0 และเมื่อ 1
- Visibility: Expression =
-
(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 -
Build & Run
Project → Build→Run· กด Toggle Switch บน Mimic หรือดู Auto-blink
☐ สร้าง 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.00Stop· 0.01Drain· 0.02
Page_OnTick (VBScript)
If Pump=1 → WaterLV++ · ถ้า ≥ 90 → Pump=0, Level_High=1
Field
Pump· 100.00- Tank ·
WaterLVD100
🖥️ Browser Sim — ลองสร้างก่อน
สร้าง 6 Points (ดู cheat sheet ในช่องซ้าย) → ใส่ Animations 2 ตัว → ▶ Run → Start → ดู Pump auto-stop ที่ 90%
📘 Lab Handout — ลงมือใน CX-Supervisor Developer
มี INLET pipe · OUTLET pipe · Tank rectangle (กรอบฟ้า) · Gauge แสดง 0–100 · ปุ่ม OFF/ON ทั้ง 2 ตัว
นี่คือ Stage Editor — ยังไม่ Run จึงไม่มีสีน้ำในถัง เล่ม 1 · Exam 4
Percentage Fill animation เติมสีน้ำเงินจากล่างขึ้นบน · Gauge เลื่อนขึ้นพร้อมกัน · ปุ่ม IN/OUT ใช้ควบคุม Pump
เป้าหมายของ Step 2 คือทำหน้าจอแบบนี้ให้ใช้งานได้ เล่ม 1 · Exam 4
ทุก 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
-
สร้าง Project ใหม่ + เพิ่ม PLC Connection (ถ้ามี CP1L)
File → New Project→LAB2_WaterFlowProject → Add PLC → CP1L · FinsEthernet · IP ของ PLC · Node 1· Test Connection
ถ้ายังไม่มี PLC จริง — ใช้ I/O Source = Internal ทุก Point -
เพิ่ม Points ครบ 6 ตัว ตามตาราง:
ชื่อ Type Address หน้าที่ StartBoolean 0.00(CIO Input)ปุ่ม Start หน้าตู้ StopBoolean 0.01ปุ่ม Stop DrainBoolean 0.02เปิดวาล์วระบาย PumpBoolean 100.00(CIO Output)คำสั่ง Pump motor WaterLVInteger D100(DM)ระดับน้ำ 0–100% Level_HighBoolean W0.00(Work)Flag เต็มถัง -
วาด Mimic — ถัง + ท่อ + Pump
- วาดถัง: Rectangle สูง · กรอบสีส้ม
- วาด Pump: ใช้ Library Symbol → Pumps
- วาง Numeric Display แสดง
WaterLV - วาง 3 ปุ่ม (Start/Stop/Drain) ผูกกับ Points
-
ใส่ 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
- Tank · Percentage Fill — คลิก Tank → Animations → Percentage Fill
-
เขียน 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 -
(ทางเลือก) เพิ่ม Trend + Alarm
- วาง Trend Object → Pens →
WaterLV0–100, Sample 1 s - Point
WaterLV→ Alarms tab → Add: High 90 · Message "Tank full"
- วาง Trend Object → Pens →
- Build & Run · ทดสอบ Auto-stop กด Start → ดูถังเติม → ถึง 90% → Pump ปิดเอง → Level_High = 1 → Alarm "Tank full" ขึ้น
☐ 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
Mix tank ตรงกลาง (มี Gauge 0–100) ·
PUMP_CHO + PUMP_MILK ฝั่งซ้ายป้อนเข้า · OUTLET valve ฝั่งขวาถ่ายลงขวด · Toggle Switch + START/STOP บนแผง
เล่ม 2 · Exam 5 · Plant Overview
Recipes (3 สูตร)
| Recipe | MilkPct | CocoaPct | ผลลัพธ์ |
|---|---|---|---|
| 🥛 Classic Milk Choc | 50% | 20% | นม·ครีมมี่ |
| 🌑 Dark Chocolate | 30% | 40% | โกโก้สูง·เข้ม |
| 🤍 White Chocolate | 70% | 10% | นมสูง·สีอ่อน |
📘 Lab Handout — ลงมือใน CX-Supervisor Developer
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
โครงเดียวกับ 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
นับว่ามี Output ตัวไหนทำงาน · CF103 = clock 0.02s · Counter เพิ่มเมื่อ Q:100.00, Q:100.01, Q:100.02 ทำงาน
ใช้เป็น Production Counter — นับจำนวน Batch ที่ผลิตเสร็จ เล่ม 2 · Exam 5 · Rung 3
StartPumpMilkScada
State 0 = "Off" สีแดง · State 1 = "On" สีเขียว · Style: Toggle Switch
ปุ่ม Start แต่ละตัวในตำราใช้ pattern นี้: 1 ปุ่ม → เขียนค่าลง 1 Work Bit (200.xx) → Ladder อ่านไปกระตุ้น Pump เล่ม 2 · Exam 5
-
Project ใหม่ + I/O Mapping
File → New Project → LAB3_ChocFactory
Points ตามตำราเล่ม 2:ชื่อ Point Type Address หมายเหตุ Start_PumpMilkBoolean 0.00ปุ่ม Start ปั๊มนม Stop_PumpMilkBoolean 0.03ปุ่ม Stop ปั๊มนม Start_PumpChoBoolean 0.01ปุ่ม Start ปั๊มโกโก้ Stop_PumpChoBoolean 0.04ปุ่ม Stop ปั๊มโกโก้ Start_OutletBoolean 0.02ปุ่มเปิด Outlet Stop_OutletBoolean 0.05ปุ่มปิด Outlet PumpMilkBoolean 100.00Output ปั๊มนม PumpChoBoolean 100.01Output ปั๊มโกโก้ OutletBoolean 100.02Output Outlet valve MilkPctInteger D100ระดับนมใน Mix tank CocoaPctInteger D102ระดับโกโก้ใน Mix tank StageInteger D104State machine 0–4 -
วาด Plant Mimic
- 3 ถัง: Milk (ซ้าย) · Mix (กลาง·ใหญ่) · Cocoa (ขวา)
- 2 ปั๊ม + 1 Outlet valve · ใช้ Library Symbol
- Bottle ใต้ Outlet (ปลายทาง)
- Mixer ในถัง Mix — Static image, ใช้ Animation Rotate ขณะปั่น
- Numeric Display:
MilkPct·CocoaPct· จำนวนขวดที่ผลิต
-
Animations ที่ใช้
- Mix tank → Percentage Fill ←
MilkPct + CocoaPct - Mix tank → Color เปลี่ยนตาม Recipe (ขาว→น้ำตาล→ดำ)
- PumpMilk/PumpCho → Color เมื่อ Output = 1 (สีเขียว)
- Mixer → Rotate Continuous เมื่อ Stage = 2 (Mixing)
- Bottle → Percentage Fill เมื่อ Outlet เปิด
- Mix tank → Percentage Fill ←
-
สร้าง 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
-
เพิ่ม Recipe Buttons
วาง 3 ปุ่มบน Mimic · OnClick Script (เลือก VBScript เป็น Language):
ภาษา: VBScript
' Button: Milk recipe RecipeLoad "ChocRecipes", "Milk" Stage.Value = 1 ' เริ่ม Stage 1 -
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 -
เพิ่ม Alarms
MilkPct· High = 95 · Message "Mix tank near full"Stage· Equal = 4 · Message "Dispensing to bottle"- วาง Alarm Summary บน Page ให้ Operator เห็น log
-
(ขั้นสูง) Trend + Data Log
- Trend:
MilkPct+CocoaPctเส้นต่างสี — Sample 200 ms - Data Logging → เก็บ BottleCount + RecipeName + เวลาทุก batch ลง CSV หรือ SQL
- Trend:
- Build & Run · ทดสอบ 3 Recipes เลือก Milk → ผลิต 1 ขวด → เลือก Dark → ดูสีเข้มขึ้น → ลอง White → ตรวจ Alarm log + Trend
· 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:
- ✓ เขียน Ladder + FBD + ST บน CX-Programmer (O02·O03)
- ✓ ต่อ Sensor / Output / Inverter / Temperature Controller (O04·O05)
- ✓ สื่อสาร Modbus RTU + FINS (O04·O06)
- ✓ เข้าใจ Concept SCADA + เปรียบเทียบทางเลือกในตลาด (O06)
- ✓ สร้าง SCADA จริงด้วย CX-Supervisor — Blink → Tank → Chocolate Factory (O07)
ขั้นต่อไป — ลอง Mitsubishi Track เพื่อเทียบ Syntax/Toolchain ที่ต่างกัน หรือไปทำ โปรเจคจริง ที่นำ Plant ของตัวเองมาเขียน · ใช้บทนี้เป็น Template ได้ทันที