Page 1 of 1
MODBUS implementation
Posted: Wed Mar 16, 2016 6:15 pm
by satya369
Does any one know how to implement MODBUS protocol on pyboard?
Here is the basic description of what I want to do.
1. Read a variable (for example accelerator x axis) and store it in a register X
2. Use my user interface software to read the register from pyboard using Modbus RTU
3. I also want to write to variable Y using my user interface through Modbus RTU.
Once I can figure out how to implement this, I will expand this to reading and writing to multiple registers.
Can someone point me out in right direction?
Re: MODBUS implementation
Posted: Thu Mar 17, 2016 3:56 am
by miltmobley
All I know about modbus i read on wikipedia. But it appears to be a command and control protocol that can be used
over serial links, with some computer being the master and your pyboard being a slave. You would have to implement
a monitor program to run on the pyboard that would continuously wait for commands to arrive on the serial link, process
them and return data and/or status to the master, similar to the way the gdb debug stub does.
Hope this helps.
Re: MODBUS implementation
Posted: Fri Mar 18, 2016 2:20 am
by satya369
I am stuck at how to implement the code on pyboard. I have my MODBUS code on my PC that works with another device that already has MODBUS protocal implemented on it. I was able to talk to the salve and write to it.
The step where I am stuck is, with MODBUS protocol I have to define registers and have to implement communication on Pyboard. I was able to send ASCII commands like "X=1", "X" to the pyboard and got responses back through UART. But have no idea how to implement MODBUS. Little complex for the knowledge I have.
Re: MODBUS implementation
Posted: Fri Mar 18, 2016 7:32 am
by vfl68
I had a look on MODBUS on Wikipedia, and found that link :
https://github.com/bashwork/pymodbus/tr ... r/pymodbus
It seems to be a python implementation of the different MODBUS protocols.
Perhaps you can start from that and adapt it to micropython,
Re: MODBUS implementation
Posted: Sat Mar 19, 2016 2:44 pm
by satya369
I think this is a MOBUS protocol you can implement on your PC to talk to devices that can talk MODBUS as well. I already have basic MODBUS protocol implemented on my PC.
I am also look for information about how to implement MODBUS on the Pyboard itself. Since the pyboard has to respond to MODBUS commands that I send from my PC. Right now I dont think pyboard is setup to respond as registers have to be defined.
Re: MODBUS implementation
Posted: Sat Mar 19, 2016 4:55 pm
by pythoncoder
I think @vfl68 was suggesting that you use some of the code from that site to create an implementation to run on the Pyboard. Strip it down to a usable subset capable of running on a resource-constrained device. That would be my approach; easier than designing it from scratch.
Re: MODBUS implementation
Posted: Sun Mar 20, 2016 4:08 am
by satya369
Thank you for the clarification.
I was looking at some of the examples that pymodbus has, these might be helpful. @vfl68, thank you for the information.
If I have any questions I will let you guys know.
Re: MODBUS implementation
Posted: Tue Oct 31, 2017 12:27 am
by Bradnz
Hi
I’m looking for a modbus rtu library or code example. How did you get on with this? Do you have anything you would be happy to share with me? I’m a bit stuck and need modbus operating on micropython for a project
Thx