Saturday, November 3, 2018

Read Energy Meter- EM1340(Rishabh Instruments) data in Raspberry Pi via Modbus communication







Overview of the Energy Meter:
RISH EM series measures important electrical parameters in 3 phase and single phase Network & replaces the multiple analog panel meters. It measures electrical parameters like Active / Reactive / Apparent energy , power as per models. It has inbuilt RS485 port available to transfer the data in realtime. The instrument has optional output as one pulse output for energy measurement.
Its Application:
Energy billing
Electrical load monitoring
Sub-metering
Genset, Test Benches and Laboratories


      EM1340 Manuals Click here


Configuration of the Energy Meter for enabling RS485 :

  • Set Slave Address(Between 1-247)
  • Set Baudrate(9600-115200)
  • Set Parity Bit(odd : odd parity with one stop bit , no 1 : no parity with one stop bit , no 2 : no parity with two stop bit,  E : even parity with one stop bit)
  • For Configuring CT:  Set-AP=100(Primary value), Set-AS=5(Secondary Value)[ If CT value= 100/5A]


Connecting the RS485 to USB Converter:

 Connect -      A(meter_side)  ---------A(converter_side)
                       B(meter_side)  ---------B(converter_side)



Getting data's on the PC Side:

   Modscan Software:
         Plug the USB converter into your PC and get the COM PORT no device manager section and  than do the necessary configuration settings .




  
Enter the  Slave Address of the meter in the Device ID and Select the Input Register from the drop down.
Here in the respective register address, you will be able to see the real time values.

Note: Select the device length maximum upto 30, else you will encounter an error.


Getting data's on the Raspberry Pi :


  •  Plug the USB to RS485 Converter into the USB port of the Raspberry Pi
  • Open Terminal and type the command- ls/dev. It will show that the converter is connected to ttyUSB0.
  • In the terminal, type - sudo pip install minimalmodbus   (We will be using minimal modbus library)
  • Open Python IDLE and run the following program

Python Code:


import minimalmodbus

import time

while True:
    try:
        powermeter1 = minimalmodbus.Instrument('/dev/ttyUSB0', 1) 
        # serial port name, slave address (in decimal)
        powermeter1.serial.baudrate = 19200
        powermeter1.serial.bytesize = 8
        # use only one of the 3 lines below to set the parity, and remark the other two lines 
        powermeter1.serial.parity   = minimalmodbus.serial.PARITY_NONE
        powermeter1.serial.stopbits = 1
        powermeter1.serial.timeout  = 1   # seconds
        powermeter1.address
        M1_volts1_address=0x00
        M1_volts2_address=0x02
        M1_volts3_address=0x04
        M1_frequency_address=0x46
        M1_volts1= powermeter1.read_float(M1_volts1_address, 4)
        print("Line 1 Voltage(R)   ")+ str(M1_volts1)
        M1_volts2= powermeter1.read_float(M1_volts2_address, 4)
        print("Line 2 Voltage(Y)  ")+ str(M1_volts2)
        M1_volts3= powermeter1.read_float(M1_volts3_address, 4)
        print("Line 3 Voltage(B)  ")+ str(M1_volts3)

        M1_frequency= powermeter1.read_float(M1_frequency_address, 4)
        print("Frequency  ")+ str(M1_frequency)
   
    except:
        print("Disconnected")



Watch The Video-












    

6 comments:

  1. i try same setup but the reslt is timeout...so kindly help to solve...

    thanks reg, siranjeevi(siranjeevi@drumbuffer.com)

    ReplyDelete
    Replies
    1. can you have code for arduino

      Delete
    2. Serial parameters might not be correct. Pls check. Use modscan software to check

      Delete
  2. can you have code for arduino

    ReplyDelete
    Replies
    1. use modbus master library it work with rish device use modsacn to check query

      Delete