-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Does it work on Raspberry PI Pico? #7
Comments
Hey, I haven't tested it on a Pico yet but there should not be any issues. |
Lyansun, hello. I do the same thing and I've already understood that this library isn't work on Raspberry Pi Pico without changings or adding external WiFi modules. Did you solve this problem?
|
Hello @AlKoAl What exactly do not works? Could you paste here the errors? |
Good morning, @beyonlo. At the begining, there is no specific errors. The whole code (from main.py and boot.py) isn't working on Raspberry Pi Pico because this platform doesn't have WiFi module as well as network library among the preinstalled libraries. It definitely should work on Raspberry Pi Pico W, but i don't have it, and it will probably work on W5100S-EVB-Pico. But this is not my problem to work with. I've just try to find some micropython lybrary which can give me the simplest way to develope Modbus RTU slave on this platform. My task is to create a simple transceiver, which will get the modbus commands from the higher level and control devices, such as turning on and off LEDs. (I understand, that it is usually done with microcontrollers programmed on C). Should i use UART-RS-485 transiver to create a wire connection with master? (I don't even know that. I'm frustrated.) As I understand this library is developed to work with two devises: one will be the slave other is master which is "talking" by WiFi. (Maybe i misunderstood something.) Can I just create only slave on Rasberry and control it with for example Modscan32 (or other programs, I don't now) like you do? |
This lib should be works without issues in any platform where MicroPython runs, including RPico and RPico-W
You can use the this lib with
On the
This project (great thanks to @brainelectronics) is the mostly simplest and amazing way to do what do you want using MicroPython.
That depends what do you want. If your communication need to be RS485 for example, so you need to use
No. You can do choose to use just the Modbus RTU Slave for example and other software can do ModBus RTU Master. This library implement the ModBus protocol, supporting all 4 types of ModBus types:
So, you choose from this library what type of ModBus do you want to use. And of course, you can to use all that 4 types working together, if is what do you need. Here a brief summary how
Yes |
Oh, thank you so much for such a detailed answer! |
You are welcome!
I saw that video, very good :) |
It doesn't work on Pi Pico W. Full error:
|
It is true. I was traing to change the code and ctrl_pin is some of those functions that is available in this repo (it will be possible if you change the example), but "wait_tx_done" isn't available on micropython rp2040 version (but it's OK on ESP32 or ESP8266). You could try to change the function, for example to just "wait" for several miliseconds. It will work, but kinda weird. At the end i've just got problems with synchronization and droped whole idea. |
Relates to #34 |
good news @AlKoAl, the package has been cleaned up with version 2.0.0 and serial as well as tcp dependencies have been removed from modbus, see also https://micropython-modbus.readthedocs.io/en/2.0.0/UPGRADE.html#update-imports |
I found a discrepancy in the initial response from function code 6 that doesn’t seem to take place with function code 16. I am not near my laptop at the moment, but I took good screenshots I can send on Monday. I’d also like to learn more about got and help contribute to the repo.
Sent from Proton Mail for iOS
…On Sat, Dec 31, 2022 at 1:30 AM, Jones ***@***.***> wrote:
The issue should be fixed by [#45](#45)
***@***.***(https://github.com/j-broome) if you have further issues please create a new issue 😊
—
Reply to this email directly, [view it on GitHub](#7 (comment)), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/A4MAUFXC77UKE6IWUKUB5U3WP7OH3ANCNFSM5YFGHVIA).
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
No problem you're always welcome! |
I used Modbus Poll and watched the communication between my PC and the Pico. When I write a single register (FC6), the initial response is messed up, but then it works. When I do the same thing with FC16 (still only writing a single register), the initial response looks great. So I THINK it is not my transceiver flow control but something weird in response code of that particular function code. I ran out of time on Friday, but the obvious thing to do is try a C library and see if the issue goes away.
Feel free to school me on this, but at first I thought the transceiver had a flow control issues because the response included the exact message I sent. But that went away with FC16. I have proper pull-up and pull-up down resistors on the UART lines as well as in the A and B lines (510 ohms) of the 485 bus.
Sent from Proton Mail for iOS
…On Sat, Dec 31, 2022 at 1:39 AM, Jones ***@***.***> wrote:
> I found a discrepancy in the initial response from function code 6 that doesn’t seem to take place with function code 16. I am not near my laptop at the moment, but I took good screenshots I can send on Monday. I’d also like to learn more about got and help contribute to the repo.
No problem you're always welcome!
Just one note, if you create an issue please try to paste your code with code highlighting or part of the code so we can support here faster. It's just easier to reproduce than code screenshots 😉
—
Reply to this email directly, [view it on GitHub](#7 (comment)), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/A4MAUFR4MMAJAD5HTWDV5K3WP7PKTANCNFSM5YFGHVIA).
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
@NormanStudentRobotic Hello! Your project is very great, and this lib will fit very well for your project! So, of course you need to run the ModBus RTU Slave on the first RPICO board and the ModBus RTU Master on the second RPICO. Well, I see that your schematic you do not using a control pin to send/receive data over
I see this error in your report. You are using I hope that this can help you. |
Hi @NormanStudentRobotic
By default, The following code should fix your issue. I'll also update the documentation and examples accordingly rtu_pins = (Pin(0), Pin(1)) # (TX, RX)
baudrate = 9600
client = ModbusRTU(
addr=slave_addr, # address on bus
pins=rtu_pins, # given as tuple (TX, RX)
baudrate=9600,
uart_id=1
) |
…nd host examples, print uPy and lib version, relates to #7
Hi @NormanStudentRobotic import os
from umodbus import version
os_info = os.uname()
print('MicroPython infos: {}'.format(os_info))
print('Used micropthon-modbus version: {}'.format(version.__version__)) I've created a RP2-RP2 setup according to your prevoius comments setup with the two RS485 modules. I'm using the RTU client and RTU host example as is. Only these changes have been made rtu_client_example.pyuart_id = 0
rtu_pins = (Pin(0), Pin(1)) # (TX, RX)
client = ModbusRTU(
addr=10, # address on bus
pins=rtu_pins, # given as tuple (TX, RX)
baudrate=9600, # optional, default 9600
uart_id=uart_id # optional, default 1, see port specific docs
) rtu_host_example.pyuart_id = 0
rtu_pins = (Pin(0), Pin(1)) # (TX, RX)
host = ModbusRTUMaster(
pins=rtu_pins, # given as tuple (TX, RX)
baudrate=9600, # optional, default 9600
uart_id=uart_id # optional, default 1, see port specific docs
) See also #59 |
I am very sorry folks. Maybe I made a mistake, that is after exchanging the connection from TX outlet from the RS3485 TTL to GPIO 2 and RX to GPIO TX, I got the result and also I got an error. The result is almost identical when I tested with Arduino MEGA and Arduino NANO EVERY. Below is the result from running the program Running ModBus version: 2.3.4 This is the programming cat read_holding_registers.pyimport time from umodbus.serial import Serial as ModbusRTUMaster address = 0 success = True |
Hi Guys, |
@Reseva Could you please put this code before all others code and paste the result here? import gc
print(f'mem_alloc: {gc.mem_alloc()} | mem_free: {gc.mem_free()}') And please, paste always the all output here, so we can help you better. |
Sure, here is the code: ethernet.w5x00_init() ===============================================TCP Slave setupport = 502 # port to listen to IP Address of Modbus TCP Serverip = '192.168.1.20' Setup Modbus TCP Clientmodbus_client = ModbusTCPMaster(slave_ip=ip,slave_port=port,timeout=5) And here is the output: |
@Reseva There is something wrong on the W5100S-EVB-Pico board, because it has just ~50KB of free memory (mem_alloc: 5408 + mem_free: 44576). As I remember the rp2040 has around 180KB of free memory, maybe the W5100S ethernet is using so much RAM? Well, problem is that with 50KB free RAM can't run this lib without freeze it in the firmware. So, please, freeze (compile the lib together with MicroPython) the modbus lib inside the firmware to works. |
Guyz,
|
after adding
Everything is okay |
…nd host examples, print uPy and lib version, relates to brainelectronics#7
Hey buddy, how does this library work on pico?
The text was updated successfully, but these errors were encountered: