Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[General] Modbus Schneider data through UART

Status
Not open for further replies.

NeethuVP

Member level 2
Joined
Jul 20, 2018
Messages
45
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Activity points
352
I have a modbus schneider connected to a orangepi via uart..using RS485 converter.. i need to read the schneider data through uart.. how can i read the registers of modbus(3901) via uart? please help me
 

Hi,

Who is the master and who is the slave?
UART setup: usually 19200 baud, 8E1

* Master sends a request to the slave
* Slave will read, parse and respond
* Master needs to read and parse the response

Are you familiar with modbus? If not, then read the specification.

Klaus
 

Orangepi is the master and schneider is the slave.. it uses 9600 baud rate 8EI... The master send a request to read the registers.. the slave ID is 1 and sending the request as "\x01\x03\x0F\x48\x00\x02\x47\x09".. but nothing is responding.. here is my code to read the UART data..
Code:
import serial
           from pyA20.gpio import gpio
           from pyA20.gpio import port
           from time import sleep
           gpio.init()
           gpio.setcfg(port.PA7, gpio.OUTPUT)
           ser = serial.Serial(
                                        port='/dev/ttyS3',
                                        baudrate = 9600,
                                        parity=serial.PARITY_NONE,
                                        stopbits=serial.STOPBITS_ONE,
                                        bytesize=serial.EIGHTBITS,
                                        timeout=1
                                   )
              gpio.output(port.PA7, gpio.HIGH)
              ByteStringToSend = "\x01\x03\x0F\x48\x00\x02\x47\x09"
              ser.write(ByteStringToSend)
              sleep(0.5)
              gpio.output(port.PA7, gpio.LOW)
              ReceivedData = ""
              while (ReceivedData == ""):
                      RecievedData = ser.readline();
                      print RecievedData.encode('hex')
              ser.close()

please help me
~
 
Last edited by a moderator:

Hi,

Are you sure the Schneider is able to run as slave?

Show your hardware circuit and wiring.
Is it 2W or 4W?

the slave ID is 1
Please use the correct terminology. Do you mean "device address"?

parity=serial.PARITY_NONE,
But you know it is 8E1, Which means EVEN parity.

Pleae give (links to) the documents you refer to.

Klaus
 

Sorry it is not EVEN parity.. it is PARITY_NONE.. i can read from the Schneider through RS485 USB converter
 

i'm using this RS485converter..
018-max485.jpg018-max485.jpg
This converter is connected directly to the OrangePi GPIO pins. On the board those pins are 8,10,29 (Tx, Rx, PA7) respectively.

OrangePi <=> Converter

8 - Tx <=> DI
10- Rx <=>RO
PA7 (29) <=>RE
in the converter RE& DE pins are shoted..
i used this document for the connection of converter and OranngePI
https://doc.homegear.eu/data/homegear-homematicwired/configuration.html#config-rs485-serial
 

Hi,

i can read from the Schneider through RS485 USB converter
I first thought this means: it is working now

But now I realize this is a second system.

Then why don't you simply compare the traffic on the bus with a scope?

Klaus
 

Sorry Klaus, i didn't get you .. what's mean by the traffic on the bus? how to compare it?
 

I understood that serial communication is working, but modbus protocol is a problem. The problem seems to be uart serial on Orange Pi hardware pins. There are several different Orange Pi boards and several operation systems available.
from pyA20.gpio import gpio
pyA20, https://pypi.org/project/pyA20/ is for Olimex board https://www.olimex.com/Products/OLinuXino/A20/A20-OLinuXino-MICRO/open-source-hardware

There is OPi.GPIO for Orange PI boards. Perhaps it works better
https://opi-gpio.readthedocs.io/en/latest/index.html
 

Reviewing the code in post #3, you are blocking the receiver for 0.5 seconds, so you surely can't receive the response within the specified MODBUS timeout. A sufficient condition to make the code fail.

I'm not sure how ser.write() is connected to the low level UART driver, if it's performing a blocking direct or buffered UART write. You'll preferably use a driver with half duplex feature that controls the RS485 TE signal based on the output shift register state. Consider that TE must be enabled until the last bit is shifted out, but not block the bus longer than 3.5 character frames.
 

i'm using Orange Pi one board... i tried with the OPi.GPIO, but same issue no response is getting.. what was the issue? i don't know
 

Hi,

Sorry Klaus, i didn't get you .. what's mean by the traffic on the bus? how to compare it?
* Use a scope to see the signals of the Modbus with using the (working) USB converter
* Use a scope to see the signals of the Modbus with using OrangePi (non working)
* then find out where the differece is

Klaus
 

Reviewing the code in post #3, you are blocking the receiver for 0.5 seconds, so you surely can't receive the response within the specified MODBUS timeout. A sufficient condition to make the code fail.

I'm not sure how ser.write() is connected to the low level UART driver, if it's performing a blocking direct or buffered UART write.
i commented the sleep and now i'm able to get response
Thank you FvM
 

i also have a L&T ER300P meter using rs485 communication. i want to read the L&T meter registers through the orangepi..i used the post#3 code to read the uart data(with sleep commented).. but i didn't get the response... what to do?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top