+ Post New Thread
Results 1 to 15 of 15
  1. #1
    Member level 1
    Points: 183, Level: 2

    Join Date
    Jul 2018
    Posts
    39
    Helped
    0 / 0
    Points
    183
    Level
    2

    Modbus Schneider data through UART

    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

  2. #2
    Super Moderator
    Points: 67,706, Level: 63
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    13,846
    Helped
    3158 / 3158
    Points
    67,706
    Level
    63

    Re: Modbus Schneider data through UART

    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
    Please don´t contact me via PM, because there is no time to respond to them. No friend requests. Thank you.



  3. #3
    Member level 1
    Points: 183, Level: 2

    Join Date
    Jul 2018
    Posts
    39
    Helped
    0 / 0
    Points
    183
    Level
    2

    Re: Modbus Schneider data through UART

    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 bassa; 21st July 2018 at 04:52. Reason: add code tag



    •   AltAdvertisment

        
       

  4. #4
    Super Moderator
    Points: 67,706, Level: 63
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    13,846
    Helped
    3158 / 3158
    Points
    67,706
    Level
    63

    Re: Modbus Schneider data through UART

    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
    Please don´t contact me via PM, because there is no time to respond to them. No friend requests. Thank you.



  5. #5
    Member level 1
    Points: 183, Level: 2

    Join Date
    Jul 2018
    Posts
    39
    Helped
    0 / 0
    Points
    183
    Level
    2

    Re: Modbus Schneider data through UART

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



    •   AltAdvertisment

        
       

  6. #6
    Member level 2
    Points: 787, Level: 6

    Join Date
    Oct 2015
    Location
    Helsinki, Finland
    Posts
    42
    Helped
    11 / 11
    Points
    787
    Level
    6

    Re: Modbus Schneider data through UART

    Use existing modbus library like minimalmodbus, which is easy to use.

    https://minimalmodbus.readthedocs.io/en/master/



    •   AltAdvertisment

        
       

  7. #7
    Member level 1
    Points: 183, Level: 2

    Join Date
    Jul 2018
    Posts
    39
    Helped
    0 / 0
    Points
    183
    Level
    2

    Re: Modbus Schneider data through UART

    i'm using this RS485converter..
    Click image for larger version. 

Name:	018-max485.jpg 
Views:	0 
Size:	42.1 KB 
ID:	148050Click image for larger version. 

Name:	018-max485.jpg 
Views:	0 
Size:	42.1 KB 
ID:	148050
    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/homegea...g-rs485-serial



  8. #8
    Super Moderator
    Points: 67,706, Level: 63
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    13,846
    Helped
    3158 / 3158
    Points
    67,706
    Level
    63

    Re: Modbus Schneider data through UART

    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
    Please don´t contact me via PM, because there is no time to respond to them. No friend requests. Thank you.



  9. #9
    Member level 1
    Points: 183, Level: 2

    Join Date
    Jul 2018
    Posts
    39
    Helped
    0 / 0
    Points
    183
    Level
    2

    Re: Modbus Schneider data through UART

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



  10. #10
    Member level 2
    Points: 787, Level: 6

    Join Date
    Oct 2015
    Location
    Helsinki, Finland
    Posts
    42
    Helped
    11 / 11
    Points
    787
    Level
    6

    Re: Modbus Schneider data through UART

    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/OLin...ource-hardware

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



  11. #11
    Super Moderator
    Points: 249,762, Level: 100
    Awards:
    1st Helpful Member

    Join Date
    Jan 2008
    Location
    Bochum, Germany
    Posts
    43,481
    Helped
    13214 / 13214
    Points
    249,762
    Level
    100

    Re: Modbus Schneider data through UART

    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.



  12. #12
    Member level 1
    Points: 183, Level: 2

    Join Date
    Jul 2018
    Posts
    39
    Helped
    0 / 0
    Points
    183
    Level
    2

    Re: Modbus Schneider data through UART

    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



  13. #13
    Super Moderator
    Points: 67,706, Level: 63
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    13,846
    Helped
    3158 / 3158
    Points
    67,706
    Level
    63

    Re: Modbus Schneider data through UART

    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
    Please don´t contact me via PM, because there is no time to respond to them. No friend requests. Thank you.



  14. #14
    Member level 1
    Points: 183, Level: 2

    Join Date
    Jul 2018
    Posts
    39
    Helped
    0 / 0
    Points
    183
    Level
    2

    Re: Modbus Schneider data through UART

    [QUOTE=FvM;1624021]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



    •   AltAdvertisment

        
       

  15. #15
    Member level 1
    Points: 183, Level: 2

    Join Date
    Jul 2018
    Posts
    39
    Helped
    0 / 0
    Points
    183
    Level
    2

    Re: Modbus Schneider data through UART

    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?



--[[ ]]--