📜 ⬆️ ⬇️

Introduction to the DLMS / COSEM stack for the MS Instruments MSP430 family of Texas Instruments



Recently, the DLMS / COSEM protocol has been actively used in metering devices (electricity, heat, water, gas meters) domestically produced. Almost every company specializing in the production of microcontrollers has a certified DLMS / COSEM stack, using which you can reduce the cost and development time of the metering device that supports this protocol. This article focuses on the DLMS / COSEM stack for the MS Instruments MSP430 microcontroller from Texas Instruments.

The TI DLMS / COSEM stack has the following features:


In order to "feel" the stack, we need:
')
  1. Development environment IAR Embedded Workbench for MSP430;
  2. DLMS / COSEM client, take the free open source DLMSDirector from the company Gurux;
  3. Evaluation Board EVM430-F6779;
  4. MSP-FET430UIF debugger / programmer.

Download and unpack


The DLMS / COSEM stack is available at ( http://www.ti.com/tool/dlmsobj-eval ), you must have a TI account to download it. The stack itself is packaged in a distribution called DLMS-4.0.6-windows-installer . After its installation, the installation folder will contain the “DLMS_Object” zip folder in which the stack files are located.

The library consists of the following files:


All these files are already collected in the project under the name dlms_obj.eww.

Launch of the project


In this section, we will launch a demo project and see how COSEM objects are represented. To do this, open the dlms_obj.eww file in IAR for MSP430 and select the required microcontroller, in our case this is MSP430F67791.



We collect the project and we program the controller. Open the DLMSDirector program and add a new device with the following parameters:



Press the "OK" button. Then in the “Devices” tree we select our device, click the “Connect” button and ... we get this error:



It is easily fixed , we open the uart_comms.c file of the dlms_obj.eww project and in line 132 we see that when configuring the UART a “typo” was made:



The correct line should be:

P3SEL0 |=(BIT0|BIT1); 

After the correction, the connection with the metering device is successfully established, with the result that the “Read” button becomes available, and in the status line we see “Ready”:



To download information from the metering device, press the “Read” button. This process is not fast, so you have to wait a bit. As a result, we get a tree from COSEM objects:



In this stack, in open access, by default, five objects are displayed:


For example, information about the current time in the metering device is as follows:



We can not only find out the time, but also get information about the time zone, the source of clocking, the date and time of daylight saving time and back, and in high secrecy mode, it is possible to set these parameters.

To access the metering device in low privacy mode, you must use the following settings (The default password is 00000000):



In this mode, many more COSEM objects are available:



Adding a new COSEM object


To add a new object, open the file config.c of the project dlms_obj.eww , find the structure:

 const struct object_desc_s object_list[] 

and add the following line to it:

 {ASSOC_PC_MR_US, CLASS_ID_DATA, 0, { 0, 0, 96, 1, 0, 255}, 2, Obj_Meter_Sr_No, 0, NULL} 

Where:


Then we create a structure with a list of attributes in the same file:

 static const struct attribute_desc_s Obj_Meter_Sr_No[] = { {1, ACCESS_PCR__MRR__USR_, TAG_OCTET_STRING, (void *) object_list[11].instance_id, NULL}, {2, ACCESS_PCR__MRR__USR_, TAG_OCTET_STRING, (void *) Meter_Sr_No, NULL}, }; 

Where:


In our case, the object does not have a callback function, and a byte string is used as the data type.

Meter_Sr_No points to the following structure:

 const uint8_t Meter_Sr_No[] = { 8, 'A','B','C','D','1','2','3','4' }; 

That's all the procedures for creating a new object. Result:



Conclusion


This article does not provide a complete description of the DLMS / COSEM library for the MSP430 microcontroller family, since it is difficult to do this without highlighting the main points of the protocol itself. However, those who need such descriptions can familiarize themselves with it by downloading it from the TI website ( http://www.ti.com/tool/dlmsobj-eval ).

Source: https://habr.com/ru/post/302180/


All Articles