Skip to main content

Modbus ASCII Communication Protocol Explanation


    အရင်တုန်းကတော့ Modbus Overview ဆိုတဲ့ Post တစ်ခုနဲ့ရေးခဲ့ဖူးပါတယ်။ အခုကတော့ Modbus ASCII အကြောင်းကိုပဲ အဓိကထားပြောပြပါမယ်။နောက်ပိုင်းမှာ ဘာကြောင့် ASCII ကို RTU ထက်စာရင် သုံးတာနည်းလည်းဆိုတာလည်းဆိုတာ ရေးပေးထားပါတယ်။

    ကျွန်တော်တို့ သုံးနေကျဖြစ်တဲ့ Modbus ဟာ Communication Protocol တစ်ခုဖြစ်ပြီးတော့ PLC ထဲမှာလည်းသုံးနေကြတာကို တွေ့ရပါလိမ့်မယ်။ အခုခေတ်မှာတော့ PLC အပြင် PID Controller တွေ Sensor တွေ များစွာသော် Electronic Instrument တွေ VFD အစရှိသဖြင့် ပစ္စည်းတွေမှာလည်းအသုံးပြုလာကြပါတယ်။

    Modbus ဆိုတာ Master-Slave Mode တွေမှာ အလုပ်လုပ်ကြပါတယ်။ နားလည်လွယ်အောင်ပြောရရင် PLC ကနေ VFD ရဲ့ Frequency ကို Control လုပ်တယ်ဆိုပါတော့။ PLC ဟာ Master ဖြစ်ပြီးတော့ VFD ဟာ Slave ဖြစ်ပါတယ်။ PLC ဟာ VFD ကို Control လုပ်တာဖြစ်တဲ့အတွက် Master က Slave ကို လှမ်းခိုင်းတာပါပဲ။ Master က Slave ရဲ့ တန်ဖိုးအခြေအနေကို Read လုပ်ရုံသာမက Write ပါလုပ်လို့ရပါတယ်။

    Modbus ဟာ Serial Communication ရဲ့ Hardware Layer သုံးခုအပေါ်မှာ အလုပ်လုပ်ပါတယ်။

- RS 232
- RS 422
- RS 485 တို့ဖြစ်ကြပါတယ်။

    အဲ့ဒီ Hardware Layer ပေါ်မှာပဲ အများအားဖြင့် Transmission Method နှစ်မျိုးနဲ့ Modbus ဟာအလုပ်လုပ်ပါတယ်။

- RTU
- ASCII ဖြစ်ပါတယ်။ 

    သို့သော် ဒီ Transmission Method အပေါ်ကပဲ ပြုပြင်ထားတဲ့ တခြားများစွာသော် Communication ပုံစံတွေရှိတယ်ဆိုတာကိုလည်း မှတ်ထားစေချင်ပါတယ်။

    ကျွန်တော်တို့ Modbus ASCII ကို မစခင် သူ့ရဲ့ Basic Data Frame Structure ကို အရင်ဦးဆုံးပြောပါမယ်။ Frame ရဲ့ စစချင်းမှာ Address Field နဲ့စပါတယ်။ Address Field ဆိုတာက Slave ID ပါပဲ။ ပြီးရင် Function Code လာပါတယ်။ Read မလား Write မလား ဆိုပြီးတော့ သတ်မှတ်ထားတဲ့ Number တွေကိုထည့်ပေးရပါတယ်။ နောက်တစ်ခုက Data Field ပါ။ ဘယ် Data ထဲမှာ တန်ဖိုးတွေသွင်းမလဲ အစရှိသဖြင့်သုံးပါတယ်။ နောက်ဆုံးကတော့ CRC or Error Checking Field ဖြစ်ပါတယ်။ သူကတော့ အရှေ့ကပို့ခဲ့တဲ့ Number တွေမှန်မမှန်ကို Calculation လုပ်ပြီးတော့ စစ်တာပါ။

ASCII

    ASCII ဆိုတာကတော့ American Standard Code for Information Exchange ဆိုပြီးအဓိပ္ပာယ်ရပါတယ်။ Messages ရဲ့ အစနဲ့အဆုံးကို ASCII Character နဲ့ပဲသုံးပါတယ်။ အဲ့ဒီ ASCII Character တွေက Hexadecimal Character တွေဖြစ်ပါတယ်။

    Message ရဲ့ Format အစက Colon ':' နဲ့စပါတယ်။ အဆုံးကတော့ a carriage return and line feed နဲ့ဆုံးပါတယ်။ အဲ့တာကြောင့်မလို့ Message တွေကြားမှာရှိတယ် Space တွေက Variable တွေဖြစ်လာကြပါတယ်။ ASCII ဟာLRC (longitudinal redundancy check) ဆိုတဲ့ Error Checking Method ကိုသုံးပါတယ်။ 

    ခုနက Frame Format ကိုပြန်ကြည့်မယ်ဆိုရင် First Byte မှာ ဘာပါမလဲဆိုရင် Start Bits ပါမယ်။ Station Address အတွက် 2 Bytes, Function Code အတွက်2 Bytes , Data အတွက် 'n' Byte (ဘယ်လောက်သုံးလဲဆိုတာသုံးတဲ့သူပေါ်မူတည်ပါတယ်။) ,LRC အတွက် 2 Bytes နဲ့ နောက်ဆုံး Stop Bit အတွက် 2 Bytes ဆိုပြီးတော့ဖြစ်ပါတယ်။

Disadvantages of Modbus ASCII Communication

    Modbus ASCII ဟာ အသုံးအရမ်းနည်းပြီးတော့ Effective လည်း Modbus RTU ထက်စာရင် အရမ်းကို Effect မဖြစ်ပါဘူး။ 

    ဘာကြောင့်လည်းဆိုရင် အဓိကက "Error Checking Method" မှာ ပါ။ Modbus RTU မှာ Cyclical Redundancy Check (CRC) ကိုသုံးပါတယ်။ အဲ့တာနဲ့ LRC နဲ့ နှိုင်းယှဥ်ရင် CRC က Error Checking လုပ်တဲ့နေရာမှာ ပိုပြီးတော့ ကောင်းပါတယ်။ 

    Modbus ASCII ကို သိပ်မသုံးကြတော့ပါဘူး။ တချို့ Serial Modems နဲ့ Weight Balance Machine တွေမှာတော့ အသုံးပြုနေကြပါသေးတယ်။

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...