Code Monkey home page Code Monkey logo

arduino-rs485's People

Contributors

asukiaaa avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

arduino-rs485's Issues

Example code

Hi,

i have your example code on a Atmega4808 running and on the other side a linux machine with mbpoll and got some errors. Maybe you could help me to understand your code closer.

#include 

#define PIN_RS485_DE PIN_PF6
#define PIN_RS485_RE PIN_PF6
#define RS485_BAUDRATE 9600
#define RS485_DEVICE_ADDRESS 33
rs485_asukiaaa::ModbusRtu::Central modbus(&Serial, PIN_RS485_DE, PIN_RS485_RE);

void setup() {
  modbus.begin(RS485_BAUDRATE);
}

void loop() {
  uint8_t data[] = { 0, 1, 2 };
  modbus.writeQuery(RS485_DEVICE_ADDRESS, rs485_asukiaaa::ModbusRtu::FnCode::Write, data, 3);
}

ping PF6 -> on hardware picture RS485_DIR

rs485

on the linux side i run mbpoll to read the data via an usb-ftdi-rs485 adapter:

mbpoll -a 33 -b 9600 -t 3 -c 3 -r 1 /dev/ttyUSB0 -v
debug enabled
Set mode to RTU for serial port
Set device=/dev/ttyUSB0
mbpoll 1.0-0 - FieldTalk(tm) Modbus(R) Master Simulator
Copyright © 2015-2019 Pascal JEAN, https://github.com/epsilonrt/mbpoll
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions; type 'mbpoll -w' for details.

Opening /dev/ttyUSB0 at 9600 bauds (E, 8, 1)
Set response timeout to 1 sec, 0 us
Protocol configuration: Modbus RTU
Slave configuration...: address = [33]
start reference = 1, count = 3
Communication.........: /dev/ttyUSB0, 9600-8E1
t/o 1.00 s, poll rate 1000 ms
Data type.............: 16-bit register, input register table

-- Polling slave 33... Ctrl-C to stop)
[21][04][00][00][00][03][B7][6B]
Waiting for a confirmation...
<00><00><00><00><00>
ERROR CRC received 0x0 != CRC calculated 0x71C0
Read input register failed: Invalid CRC
-- Polling slave 33... Ctrl-C to stop)
[21][04][00][00][00][03][B7][6B]
Waiting for a confirmation...
<00><00><00><00><00>
ERROR CRC received 0x0 != CRC calculated 0x71C0
Read input register failed: Invalid CRC
-- Polling slave 33... Ctrl-C to stop)
[21][04][00][00][00][03][B7][6B]
Waiting for a confirmation...
<00><00><00><00><00>
ERROR CRC received 0x0 != CRC calculated 0x71C0
Read input register failed: Invalid CRC
-- Polling slave 33... Ctrl-C to stop)
[21][04][00][00][00][03][B7][6B]
Waiting for a confirmation...
<00><00><00><00><00>
ERROR CRC received 0x0 != CRC calculated 0x71C0
Read input register failed: Invalid CRC
-- Polling slave 33... Ctrl-C to stop)
[21][04][00][00][00][03][B7][6B]

I wonder how can i set the register id in the arduino code. Do you maybe have more examples ?

many thanks

cheers

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.