Skip to main content

Modbus Function Command Format (1)




    ASCII သို့မဟုတ် RTU Mode ထဲက မည်သည့် Modbus Data ဘောင်တိုင်းမဆို သူတို့သတ်မှတ်ထားတဲ့ Data ကတော့ရှိပါတယ်။

    Modbus Data Frame တစ်ခုစီကို 8bitd(RTU) တွေနဲ့တည်ဆောက်ထားတာကြောင့် အများအားဖြင့် စာသားတစ်ခုချင်းစီကို Bytes (Hexadecimal တစ်လုံး နှစ်လုံး) အဖြစ်ကိုယ်စားပြုပါတယ်။

    ဥပမာအားဖြင့် 1100100101011011 ကဲ့သို့ Modbus Data နဲ့ 16-Bit စကားလုံးကို ပုံမှန်အားဖြင့် C95B နဲ့သတ်မှတ်ပြီး High ကို C9 နဲ့ Low ကို 5B ဆိုပြီးခွဲထားပါတယ်။

    Modbus Master Device ကနေပေးပို့တဲ့ "Query" Message ဟာ Slave Device ဆီကို ပို့ပြီး သက်ဆိုင်ရာ "Response" Message နဲ့ Queried ကနေ Master Device ကိုပြန်ပို့ပေးပြီးအလုပ်လုပ်ပါတယ်။

   အောက်‌ကပြထားတဲ့ ပုံတစ်ပုံချင်းစီကနေ Function Code တစ်ခုချင်းစီဘယ်လိုအလုပ်လုပ်ရ‌သလဲဆိုတာပြန်ရေးပေးထားပါတယ်။

Modbus Function Code 01- Read Coil
==============================
    ဒီ Modbus Function ဟာ Slave Device နဲ့အတူသူ့ရဲ့ Discrete Outputs ("Coils") ကို ဖတ်ပြီးတော့ အဲ့ဒီ Status တွေကို Data နဲ့ပြန်ပေးပါတယ်။

    ဒီ Function အတွက်သတ်မှတ်ထားတဲ့ Modbus Address ရဲ့ Range ကတော့ 00001 ကနေ 09999 (Decimal) အထိဖြစ်ပါတယ်။ သို့သော် Starting Address ကတော့ Hexadecimal နဲ့ဖော်ပြထားတာဖြစ်ပြီး Range ရဲ့အစကနေ (n-1)^ th Register နဲ့ဖော်ပြပါတယ်။ 

    ဥပမာပြောရရင် ပကတိ Decimal Address 00100 ကို Hexadecimal 0x0063 နဲ့ သတ်မှတ်ထားပါတယ်။ High-Order Byte ကို 63 နဲ့ သတ်မှတ်ထားပါတယ်။

    ပုံထဲမှာပြထားတဲ့အတိုင်း မီးခိုရောင်ဖျော့ဖျော့နဲ့ ခြယ်ထားတဲ့ အပိုင်းဖြစ်တဲ့ ဒုတိယအပိုင်းနဲ့ တတိယအပိုင်းကတော့ Coil Status ကို ကိုယ်စားပြုပါတယ်။ ဘာကြောင့်လဲဆိုရင် သူတို့ရဲ့တည်ရှိမှုဟာ One Byte ကျော်တန်ဖိုးရှိတဲ့ Coil များကိုတောင်းဆိုထားတယ်လို့ ယူဆထားသော်ကြောင့်ဖြစ်ပါတယ်။

Modbus Function Code 02 - Read Contact
==================================
    ဒီ Modbus Function ဟာ Slave Device နဲ့အတူ သူရဲ့ Discrete Inputs ("Contacts") ကိုဖတ်ပြီးတော့ အဲ့ဒီ Status တွေကို Data နဲ့ ပြန်ပေးပါတယ်။

    ဒီ Function အတွက်သတ်မှတ်ထားတဲ့ Modbus Address ရဲ့ Range ကတော့ 10001 ကနေ 19999 (Decimal) အထိဖြစ်ပါတယ်။ သို့သော် Starting Address ကတော့ Hexadecimal နဲ့ဖော်ပြတာဖြစ်ပြီး Range ရဲ့အစကနေ (n-1)^ th Register နဲ့ဖော်ပြပါတယ်။ 

    ဥပမာနဲ့ပြောပြရရင် ပကတိ Decimal Address "10256" ကို Hexadecimal "0x00FF" နဲ့သတ်မှတ်ထားပါတယ်။ High-Order Byte ကို "00" နဲ့ Low-Order Byte ကို "FF" နဲ့ သတ်မှတ်ထားပါတယ်။

Modbus Function Code 03 - Read Holding Register
======================================
    ဒီ Function ကတော့ Slave Device နဲ့အတူ သူ့ရဲ့ "Holding" Register ရဲ့ Status ကို ယူဖတ်ပါတယ်။ ဒီနေရာမှာ Register တစ်ခုချင်းရဲ့ Size ဟာ Two Bytes (16 Bits) ရှိတယ်လို့ ယူဆနိုင်ပါတယ်။

    ဒီ Function အတွက်သတ်မှတ်ထားတဲ့ Modbus Address ရဲ့ Range ကတော့ 40001 ကနေ 49999 (Decimal) အထိဖြစ်ပါတယ်။ အလားတူပဲ Starting Address ကတော့ Hexadecimal နဲ့ဖော်ပြတာဖြစ်ပြီး Range ရဲ့ အစကနေ (n-1)^ th Register နဲ့ဖော်ပြပါတယ်။ 

    ဥပမာနဲ့ပြောရရင် ပကတိ Decimal Address "40980" ကို Hexadecimal "0x03D3" နဲ့သတ်မှတ်ထားပါတယ်။ High-Order Byte ကို "03" နဲ့ Low-Order Byte ကို "D3" နဲ့သတ်မှတ်ထားပါတယ်။

    ဒီနေရာမှာ မှတ်ထားရမှာကတော့ Query Message တွေဟာ Register တွေရဲ့ နံပါတ်ကို သတ်မှတ်ထားတာကြောင့် Response Message တွေဟာလည်း Byte တွေရဲ့Number နဲ့ပဲ Reply လုပ်ပါတယ်။ Response Message ရဲ့ Number of Bytes Field ဟာ Query Message ရဲ့ Number of Registers Field ရဲ့တန်ဖိုး နှစ်ဆလောက်ရှိပါတယ်။ 

    "Hi" နဲ့ "Lo" Byte တန်ဖိုးများဖြင့် Query Message (65536) တွင်တောင်းဆိုနိုင်တဲ့အများဆုံးအရေအတွက်ဟာ Response Message မှာရှိတဲ့ Single Byte တန်ဖိုး (255 Byte) ဖြင့်လည်း Report လုပ်နိုင်တာကိုလည်းမှတ်ထားရမှာဖြစ်ပါတယ်။

Reference: Instrumentationtools 

Comments

Popular posts from this blog

Example of PLC ladder diagram for Filing and Heating Liquid in Tank

In the previous post, I wrote PLC program about Mixing and Heating process. Today, I'm going to write about Filling and Heating process in tank. It sounds like the same topic in previous post. Actually, it is different. We'll see the sequences and processes.  Here is the given sequences according to the Author : 1. Fill the tank up to 80%. When the tank is filled, turn ON the heater to raise the temperature up to 70 deg. 2. When this temperature is reached, turn OFF the heater & open the outlet valve. 3. When the level in the tank falls below 10%, close the output valve. In this situation, I do the ladder diagram via Sysmac Studio which is the product of Omron. I just remind you again, most of the control processes are used with Mitsubishi, Siemen and sometimes Delta's PLC due to cost effectively. I'm going to show you how it works with Sysmac Studio. In this case, I'm only using Name Tags. Before I'm talking about ladder diagram, I would like to tell about ...

IPv4 Vs IPv6 - What's the difference between IP Addresses

ကျွန်တော်တို့ IOT Project သို့မဟုတ် PLC တို့ HMIတို့ကို Ethernet နဲ့ချိတ်တဲ့အခါမှာ IP Address တို့ Subnet Mask တို့သတ်မှတ်ရတာတို့ကိုတွေ့ရမှာပါ။အခုကတော့ IP Addressအကြောင်းကိုမှ IPv4 နဲ့ IPv6 အကြောင်းကိုရေးမှာပါ။           IP Address ဆိုတာကတော့ ကျွန်တော်တို့ရဲ့အိမ်နံပါတ်လိုသဘောမျိုးလုပ်ထားပေးတဲ့ Internet Protocol တစ်ခုပါပဲ။ အိမ်တိုင်းအိမ်တိုင်းမှာသူရဲ့သက်ဆိုင်တဲ့နေရာလိပ်စာတွေရှိကြသလိုပဲ စက်တိုင်းမှာလည်းသူရဲ့ သက်ဆိုင်တဲ့ IP Address တွေရှိကြပါတယ်။ ဒါကတော့ IP Address အကြောင်းကိုရှင်းပြတဲ့ရိုးရှင်းတဲ့ ဥပမာတစ်ခုပါ။ ဒီမှာအဓိကထားပြီးရှင်းပြသွားမှာကတော့ IPv4 နဲ့ IPv6 ကိုရှင်းပြသွားမှာပါ။      What is IPv4 : simple meaning & features guide     ဒီ IPv4 မှာဘာတွေပါလဲဆိုတော့ Set Numbers လေးခုပါဝင်ပါတယ်။ ယေဘုယျအားဖြင့် ဘယ်လိုပုံစံနဲ့ရေးကြသလဲဆိုရင် 106.102.77.43 (ဒါကဥပမာပုံစံပါ။) လိုပုံစံမျိုးဖြစ်ပြီးတော့ မတူညီတဲ့ ကိန်းဂဏန်းလေးခုကို Cover လုပ်ပေးထားပါတယ်။ IPv4 ဘာကြောင့်ဖြစ်လာရလည်းဆိုရင် လွန်ခဲ့တဲ့ 1980 ဝန်းကျင်ကာလတွေမှာ I...

What is Master Control Relay in PLC?

A PLC's Master Control Relay (MCR) is defined by experts as a unique relay utilized in ladder logic programming to regulate the operation of several rungs or parts of a ladder diagram. In essence, it uses certain conditions to determine whether to enable or disable particular software sections. All rungs between the MCR and the associated end instruction are executed when the MCR is turned on. These rungs cannot run if the MCR is deactivated because they are circumvented. Large portions of a program can be controlled with a single condition because to this functionality, which enhances program organization and efficiency. In first photo, Master Control Relay is used as normally opened coil, called Master Coil. As you can see when the "Start" is triggered, Master Coil will be closed contact and executes the multiple rungs. If "Stop" is triggered, Master Coil is disable the execution of the other rungs. Similarly, in second figure, I...