GithubHelp home page GithubHelp logo

modbus_rs485_slave's Introduction

ModBus_RS485_Slave

Library for communicating with Modbus devices over RS232/USB/485 via RTU protocol

Ported to Particle by Paul Kourany, 2015

Update May 2016

  • Added in a RXEN pin
  • Changed how RXEN and TXEN works

The SN65HVD70 is a RS485 device that should work identically to the MAX485.

RXEN and TXEN can be controlled independently by initializing like this: Modbus master(0, 1, TXEN_PIN, RXEN_PIN);

In configurations where the RS485 pins RXEN and TXEN are tied together, initialization changes to this: Modbus master(0, 1, TXEN_PIN);

In some circumstances, such as when using the Sparkfun RS-485 breakout, there is only a single CTS pin which will not work by just initializing TXEN. Instead, both TXEN and RXEN must be initialized and both tied into the CTS pin.

Otherwise, the operation is exactly the same. Both RS845 chips use serial communication and so will both need to conform to the same serial -> MODBUS communication pattern.

modbus_rs485_slave's People

Contributors

hwestbrook avatar pkourany avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

modbus_rs485_slave's Issues

Device SOS when using Serial4/Serial5

I just noticed a strange behavior of the lib when using Serial4/Serial5 on Electron. I modified the switch statement like this:

  switch( u8serno ) {
  case 1:
    port = &Serial1;
    break;

  case 4:
    port = &Serial4;
    break;

  case 5:
    port = &Serial5;
    break;

  case 0:
  default:
    port = &Serial1;
    break;
  }

and did all the imports:

#include "Serial4/Serial4.h"
#include "Serial5/Serial5.h"

but the Electron won't run the code but was flashing SOS with code 1 (Hard Fault). After a couple of hours i tried to change all port-> usages like

port->flush();
to
Serial4.flush();
and it worked. What was my mistake in the first try?

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.