Giter VIP home page Giter VIP logo

modbus-mitsubishi-fx3u's Introduction

Node.js Modbus Communication for Mitsubishi FX3U PLC

this is a com-modbus's specific device implementation for Mitsubishi FX3U PLC. only M and D address tested.

๐Ÿง‘โ€๐Ÿ”ง Installation

npm i --save git://adrianaryaputra/modbus-mitsubishi-fx3u.git

๐Ÿ“– Usage

const { 
    ModbusHandler, 
    ModbusDevice_FX3U, 
    SerialPort,
} = require('modbus-mitsubishi-fx3u');


// set serial port
const port = new SerialPort('/dev/tty-usbserial1', {
  baudRate: 57600
});


// set modbus handler and device
let modbusHandler = new ModbusHandler({
    msgSendInterval: 100,
    timeout: 100,
    retryCount: 10,
    chunkSizeWord: 4,
});

let fx3u = new ModbusDevice_FX3U({
    modbusHandler,
    modbusId: 1,
    modbusTimeout: 100,
});


// set modbus handler's serial port connection 
modbusHandler.setConnection(port).open();


// read PLC memory: M30 - M46
fx3u.read({
    type: fx3u.type.M, 
    address: 30,
    length: 2, // byte
    priority: 2, // lower have higher priority
    callback: (error, success) => console.log(error, success)
});

// write value: 1234 to PLC memory: D10
fx3u.write({
    type: fx3u.type.D, 
    address: 10,
    value: 1234,
    priority: 1, // lower have higher priority
    callback: (error, success) => console.log(error, success)
});

// pulse a single bit (turn it on then off after certain duration)
fx3u.pulse({
    type: fx3u.type.M, 
    address: 5,
    duration: 200, // ms
    priority: 2, // lower have higher priority
    callback: (error, success) => console.log(error, success)
});

modbus-mitsubishi-fx3u's People

Contributors

adrianaryaputra avatar

Watchers

 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.