How to Implement Data Communication Using Modbus RTU? (part 1)

Mar 19

How to Implement Data Communication Using Modbus RTU? (part 1)

Not so long ago, I was engaged in the MC programming (in the framework of the work on the nanosatellite), in particular, I implemented a communication between devices by different protocols. So, where do we start? When it is necessary to solve this kind of problem, first of all, you should choose (if there are “hardware” restrictions, it means that the choice is partly made for us): data communication type (synchronous, asynchronous); interface (RS-232, RS-422, RS-485, USB, Bluetooth, etc.); protocol (WAKE, Modbus, etc.). To make the right choice, you need to take into account the scope, speed and signal transmission distance limits and other characteristics. One of my tasks was to implement a data communication between a computer and the STM32F105 MC on the existing board. On the interface board, there was the RS-485 for asynchronous serial data communication, which allows implementing connection of up to 32 devices at the same time, has a speed of 30 Mbit/s and a transmission distance of 1 200 m (see Table 1). Parameter RS-485 Data communication type Differential Maximum number of receivers 32 Maximum cable length 1200 m Maximum transmission rate 30 MBit/sec Output voltage -7…+12 V Receiver sensitivity ±200 mV Table 1. RS-485 interface parameters In principle, it is possible to implement a data communication without a protocol, but in this way, nobody guarantee data integrity and timely delivery, so a common practice is to use specialized protocols. Data communication protocol is a set of agreements of a logic level interface that define a data communication between different programs. These agreements define a uniform method for transmitting messages and error handling in the interaction of software of spaced apart devices, connected by one or another interface. A standardized data communication protocol also enables to develop interfaces (now at the physical level), which are not tied to a particular hardware platform and manufacturer (e.g., USB, Bluetooth). Communication protocols generally operate on the “master-slave” principle. A master initiates a communication and sends a request to slave devices (slaves), and slave devices respond (or do not respond) to requests according to the address in a package. There are many protocols, but one of the most common is Modbus. The Modbus protocol was established many years ago but is still very popular....

Read More

IT Jam 2012 Report

Sep 20

IT Jam 2012 Report

September 1 is not only the day of knowledge, peonies, and teachers, but it is also a day of fun for more than 3,000 IT specialists in the NSC “Olimpiiskii“. Truly speaking, I have not seen anywhere else such a long queue for registration. When registering, in addition to cute notebooks-pens-markers-pins-magnets, you could also get a card of the first off-line social network, RFIDLE. The card is linked to my Facebook page, and with the help of it, I can give likes, add friends and upload photos using special terminals. The idea is excellent, but unfortunately, terminals often denied. In a couple of days, RFIDLE sent me a questionnaire by mail, and it turned out that we became participants of a beta testing, so let’s hope that developers are already fixing the system. “We are here to celebrate!” said IT Jam slogans. On two stages (under the titles “New ideas and technologies” and “From vision to implementation”) technical gurus told stories of their success in a simple and humorous way. Apart from Ukrainian speakers Max Istchenko (founder of the well-known DOU Ukrainian developer community) and Michael Zavileiskii (General Manager of the DataArt company), there were also foreign guests: Christopher Marsh (technical developer at AKQA), Greg Young (independent consultant and entrepreneur), Torben Maygaard (Ciklum founder) and others. Companies raffled off licenses (I, for example, wanted to win a license from JetBrains for Resharper, but alas, failed to), cups, T-shirts, Lego; held competitions and polls (DataArt gave everybody beans in bags for voting; some members even took them home, maybe in order to plant). But I was lucky enough to win a 20% discount on the preparation for the Microsoft certification in the training center, which is also good. Around the pavilion, there were Chucks Norris with jokes and a different stuff for entertainment. But the most important thing was going on in the community spots, where developers of different areas were communicating and exchanging contacts. Ironically, I almost missed the .NET lectures but had a great time with the guys from Podcasting. It was very entertaining to learn from the “inside” how to create podcasts, as I often listen to Mikhail Marchenko and to his podcast “Frankly about IT careerism”....

Read More

Knowledge Day with IT-Jam 2012

Jul 30

Knowledge Day with IT-Jam 2012

The first of September. Young children go to school with large bags and flowers, and big kids are going to the most anticipated in the Kiev IT-event of the fall, but without bags and, of course, no flowers. This year, we will communicate in 5 areas to suit all tastes: .NET, QA, Web Development, and the Mobile Java (hope for Java and .NET pavilions will be located far enough away from each other, given the perennial holy wars of developers). By the way, on IT Jam site are presented various Community Spots (.NET, IOS, Agile, etc.) and registration still open. Well, see you on September 1 in NSK “Olympic”! And let everything be in the jam 🙂...

Read More

Competition for Programmers Organized by the “Infopulse”

Jun 20

Competition for Programmers Organized by the “Infopulse”

A few days ago I’ve participated in the competition for programmers organized by the “Infopulse”, which was held in honor the company being at Habrahabr for one year. There were very interesting puzzles for fans of “tuning up” mind after work. It was necessary to determine the programming language in 6 tasks, find a line with an error, correct it and justify your correction. The one, who sent correct answers first, was given tickets for the match Sweden-France, a part of our Euro 2012. The first tasks were only for a start, later they got more difficult, and I struggled for a very long time with the last one. It was an assembler for the DCPU-16, which could only be debugged using an emulator. Oh, the employees of the “Infopulse” company! They have really puzzled a girl 😉 Result: I didn’t win, @MarkAblov was the first to send the right answers, but the competition was informative....

Read More

.NET Saturday in SkyPoint

May 27

.NET Saturday in SkyPoint

I’ve visited the .NET Saturday organized by the Ciklum Company on May 26. I’ll tell you a little bit about my impressions. The program was really nice, exactly as the organizers warned. There were: Eugene Zharkov – “Windows 8 Metro App: JavaScript Dark Side”; Petr Afanasiev – “Perfect API: ASP.NET Web API inside!”; Sergey Koshel – “When optimistic lock is not a case (.NET/SQL)”; Vitaliy Domnikov – “F# – To Iterate is Human, to Recurse, Divine”; Alexandr Ivanitskiy – “XAML – a markup language for WPF, Silverlight and Metro applications”. In addition to the main screen, there was an additional screen installed for tweets with the CiklumNET hashtag, which perfectly entertained the audience. It is a pity that I couldn’t attend all the lectures, but Vitali’s lecture on F# made a great impression on me, however, the lecture by Alexander was saved only by trolls twitting about cups, women, and dresses. So, from now on, I will visit meetups in Ciklum more frequently. Oh yes, I almost forgot. I promised to try F# and finally did it. The program is the calculation of factorial of the n number. Click to toggle codeblock 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 // Create function for calculating factorial let rec factorial n = match n with | 0 -> 1 | _ -> n * factorial (n - 1)   // using System open System   Console.Write(@"Enter n = ") let n = Convert.ToInt32(Console.ReadLine())   // Calculate and write result let result = factorial n Console.Write(@"Result = ") Console.WriteLine(result) // Create function for calculating factorial let rec factorial n = match n with | 0 -> 1 | _ -> n * factorial (n - 1) // using System open System Console.Write(@"Enter n = ") let n = Convert.ToInt32(Console.ReadLine()) // Calculate and write result let result = factorial n Console.Write(@"Result = ") Console.WriteLine(result) It is really possible to write programs on this functional language quite quickly and efficiently if you want to work with math functions. Dark side is the same: you have to think...

Read More

Ya.Subbotnik

May 06

Ya.Subbotnik

On May 5, I actively participated in a Saturday work. No, I did not dig and plant and did not even clean a street (not a woman’s business). I participated in Ya.Subbotnik in Kiev organized by the Yandex company. I liked the following talks most of all: “Modern machine of a HTML developer” on the details of creating and testing web app in Yandex, on cross-browser problems (multiple browsers, customizations, plug-ins, users’ love for night releases and other stuff and how not to shoot your leg trying to please everyone), on the use of additional tools of partner companies and of Yandex (from Yandex utilities I remember only Borschtik, which allows making one CSS-file from many; by the way, I have not eaten borscht for a long time :P), on testing in virtual environment, etc. “API of the Yandex Maps 2.0″ on the new features of Yandex maps. Also, there were many lectures on the BEM (Block-Element-Modifier) for the fans of this methodology. By the way, I found a clear explanation of the basic BEM principles in the article “BEM 101”. In the talk on GIT, the lecturer actively encouraged the audience to move from SVN to GIT, motivating it by the “painless” merge (and we, SVN users, know how a brain melts when our branches join) and lots of other amenities. Result: I was satisfied with the time spent. Friendly atmosphere, familiar faces and interesting...

Read More