0

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 ?

0

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, privacy policy and cookie policy

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