Giter Club home page Giter Club logo

picmodbus's Introduction

PICmodbus PIC-CCS code

PIC Microcontroller Master and Slave Modbus RTU Protocol

ISIS Proteus file [https://github.com/worrajak/PICmodbus/blob/master/ModBus.DSN]

ScreenShot

1.Modbus master

PIC18F458 configuration

#include <18f458.h>
#fuses HS, NOWDT
#use delay(clock=20M)

#define MODBUS_TYPE MODBUS_TYPE_MASTER
#define MODBUS_SERIAL_TYPE MODBUS_RTU     //use MODBUS_ASCII for ASCII mode
#define MODBUS_SERIAL_RX_BUFFER_SIZE 64

SDM120 or modbus BuadRate to 2400bps

#define MODBUS_SERIAL_BAUD 2400

using EXT INT RB0 (PIC18F458)

#define MODBUS_SERIAL_INT_SOURCE MODBUS_INT_EXT

and config pin

#define MODBUS_SERIAL_TX_PIN PIN_B1   // Data transmit pin
#define MODBUS_SERIAL_RX_PIN PIN_B0   // Data receive pin

#define MODBUS_SERIAL_ENABLE_PIN   PIN_B2   // Controls DE pin for RS485
#define MODBUS_SERIAL_RX_ENABLE    0   // Controls RE pin for RS485

ScreenShot

ScreenShot

  1. Slave modbus PIC16F690
#include <16F690.h>
#DEVICE  *=16 ADC=10
#fuses   NOPROTECT,INTRC,NOWDT,PUT,NOBROWNOUT,MCLR
#use delay(clock=4M)

#define MODBUS_TYPE MODBUS_TYPE_SLAVE
#define MODBUS_SERIAL_TYPE MODBUS_RTU     //use MODBUS_ASCII for ASCII mode
#define MODBUS_SERIAL_RX_BUFFER_SIZE 64
#define MODBUS_SERIAL_BAUD 2400

using EXT INT RDA (UART) (PIC18F458)

#define MODBUS_SERIAL_INT_SOURCE MODBUS_INT_RDA

and config pin

#define MODBUS_SERIAL_TX_PIN PIN_B7   // Data transmit pin
#define MODBUS_SERIAL_RX_PIN PIN_B5   // Data receive pin

#define MODBUS_SERIAL_ENABLE_PIN   PIN_B4   // Controls DE pin for RS485
#define MODBUS_SERIAL_RX_ENABLE    0    // Controls RE pin for RS485

ScreenShot

ScreenShot

picmodbus's People

Contributors

worrajak avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.