2

I am working on a slave computer and want to save the data transmitted from the master raspberry pi pico.

In micropython there is modbus library github link. I want to use this library but there is a hardware issue about using rs485. I want communicate direct usb without using rs485. Is it possible ? I can't configure code for this.

Main code example is:

uart_id = 0x01
modbus_obj = Serial(uart_id, pins=('P9', 'P10'))
# if the serial modbus requires a ctrl pin, you can set it like this:
modbus_obj = Serial(uart_id, pins=('P9','P10'), ctrl_pin='P8')

What is uart_id ? And what are pins ? How should I configure this example for send data via usb COM port, I want to read datas from modbus poll on computer.

Also,

######################### READ COILS #########################
#slave_addr=0x0A
#starting_address=0x00
#coil_quantity=100

#coil_status = modbus_obj.read_coils(slave_addr, starting_address, coil_quantity)
#print('Coil status: ' + ' '.join('{:d}'.format(x) for x in coil_status))

Read coils example, there is a slave_addr. What is this and how can I assign this address ?

1
  • How long is the cable between the two computers? Rs485 is normally used for long connections because it uses twisted pair wires.
    – NomadMaker
    Jul 22, 2022 at 22:50

1 Answer 1

1

UART_ID, PINS are the particular UART and the corresponding Tx, Rx Pins. Micropython library for RPI Pico serial communications parameters.

What is your slave computer? You need write code in your slave computer to save the data from master. You could convert usb to serial on the slave computer, I am assuming it is a PC, and connect it to the RPI PICO serial port.

The slaves need to have an address which can be from 1-247. The following link is an intro to modbus, which would explain the modbus protocol in general and would contain description of slave ID, coils and registers.

https://www.controlglobal.com/articles/2019/introduction-to-modbus/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.