asukiaaa / arduino-rs485 Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
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
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.