TOP Contributors

  1. MIKROE (2642 codes)
  2. Alcides Ramos (348 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (112 codes)
  5. Chisanga Mumba (90 codes)
  6. S P (73 codes)
  7. dany (71 codes)
  8. MikroBUS.NET Team (35 codes)
  9. NART SCHINACKOW (34 codes)
  10. Armstrong Subero (27 codes)

Most Downloaded

  1. Timer Calculator (136225 times)
  2. FAT32 Library (69494 times)
  3. Network Ethernet Library (55711 times)
  4. USB Device Library (45994 times)
  5. Network WiFi Library (41640 times)
  6. FT800 Library (40803 times)
  7. GSM click (28789 times)
  8. PID Library (26333 times)
  9. mikroSDK (26060 times)
  10. microSD click (25146 times)
Libstock prefers package manager

Package Manager

We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]

< Back
Library

Modbus RTU Master Implementation; GUI - demo

Rating:

5

Author: Vladimir Djukovic

Last Updated: 2013-04-14

Package Version: 1.0.0.1

Category: Communication

Downloaded: 3101 times

Not followed.

License: MIT license  

The project contains a simple graphical user interface software mainly used as a testing tool and integral part of the entire application which refers to the Modbus RTU application protocol implemented in master controllers based on MCUs.

NEW: Modbus RTU Master function codes library, basic functions added

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "Modbus RTU Master Implementation; GUI - demo" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "Modbus RTU Master Implementation; GUI - demo" changes.

Do you want to report abuse regarding "Modbus RTU Master Implementation; GUI - demo".

  • Information
  • Comments (0)
DOWNLOAD LINK RELATED COMPILER CONTAINS
mikroC PRO for PIC
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc

Library Blog

Image1

Image1

main display

View full image

Video1

01 06 There is a mistake in this video, BROADCAST IS NOT SUPPORTED by fcode 01 and has no sense there.

Watch on YouTube

Video2

0vide02

Watch on YouTube

NEW, 14.04.2013.

FUNCTION CODE LIBRARY ADDED:

01 Read Coil Status
02 Read Input Status
03 Read Holding Registers
04 Read Input Registers
05 Force Single Coil
06 Preset Single Register

Under Function codes Library section of the package file:
Look at the picture bellow (package Modbus RTU Master installed);

opcode:

Modbus_MASTER_Config (baud_rate, system_clock, parity_setting);
//baud rate in bps
//system_clock in MHz
//parity setting:
//- 0 no parity check involved
//- 1 odd parity applied
//- 2 even parity

//Timeout value set
Timeout_Set (timeout_value); //timeout value in miliseconds, 1500ms by default


// 01 Read Coil Status
Function_01 (slave_address, starting_address, number_of_coils);

// 02 Read Input Status
Function_02 (slave_address, starting_address, number_of_inputs);

// 03 Read Holding Registers
Function_03 (slave_address, starting_address, number_of_registers);

// 04 Read Input Registers
Function_04 (slave_address, starting_address, number_of_registers);

// 05 Force Single Coil
Function_05 (slave_address, coil_address, force_data);        // force_data (coil state) = 0 or 1

// 06 Preset Single Register
Function_06 (slave_address, register_address, preset_data);

Example:

//Modbus RTU Master initialization 
Modbus_MASTER_Config (9600, 16., 2);   // baud rate = 9600 bps, f_osc = 16Mhz, even parity,  
                                                               // TIMEOUT is 1500ms by default    
       // note: system_clock value is required in order to get        // UART baud rate parameters calculated
Timeout_Set (2500);       // new value for the timeout period approximatelly2500ms

// .....

// part of code where the user software (master device) initiates Modbus transaction
// eg. the master requests contents of ten holding registers at adresses 40250 to 40259 from slave 
// device 15 
Function_03 (15, 250, 10);
// the response message is being stored into resp_msg, 256 bytes long array that is defined within 
// the library, it can't be redefined by the user, it has sufficient capacity to recive the longest Modbus  // RTU ADU frame (256 bytes) anyway   
// the user software serves over the received message content
// there is a 8-bit status register defined by the library RESPSTAT which status bits tells the       // master whether a response mesage is received or not upon the receiving is complete. It is on the // user software to check it out. That part of code should be applied as the next section after writting // function code library function   

RESPSTAT register:

bit 7: -
bit 6: -
bit 5: -
bit 4: -
bit 3: RERR                               communication error occured
bit 2: TOUT TIMEOUT expired
bit 1: ROK RESPONSE OK
bit 0: MRXF calculated number of mesage bytes received (reception complete)

example: (continued from the previous modbus requesting)
if (ROK_bit == 1)
   Response_processing(); // response OK (expected response received - normal or exception)
else
   Response_fault ();         // none response received, timeout expired or communication error

        




package file

package file

function codes library

View full image

video 3

Library test: Read Holding Registers - example

Watch on YouTube

video 4

Library Test: Parity error vs TIMEOUT (unmatched parity check option)

Watch on YouTube

ALSO FROM THIS AUTHOR

Programmable Timer

4

An timer application with four independent programmable outputs each one with eight ON/OFF programs on daily basis (0-24h). Fully supported via an character LCD interface gives a comfort of setting the desired program. Additional usefull settings implemented also.

[Learn More]

Modbus RTU Implementation & Ladder Logic

5

This project contains some library code aimed to be used for developing slave PLC type controllers using microcontrollers for their hardware configurations

[Learn More]

FTP Server

0

Demo - test; Simple embedded FTP server application in LAN environment based on PIC18F devices; Can be useful for special purposes. More on project blog page.

[Learn More]