Is it correct ? Do i need to sum all the KW and I will get the total consumption for an hour ?
(1/4 * 4.8) + (1/4 * 4.9) + (1/4 * 4.8) + (1/4 * 4.8) = 4.825 KWH
Is it correct ? Do i need to sum all the KW and I will get the total consumption for an hour ?
(1/4 * 4.8) + (1/4 * 4.9) + (1/4 * 4.8) + (1/4 * 4.8) = 4.825 KWH
@jeremyh below is the sample of my database.
could you teach me how to calculate.
@jeremyh Hello Jeremy. Want to ask you one more question. I am not from the Electric background. So, I find a difficulty in calculating the power consumption of the meter. For you information, my system going to add the data in the database for every one minute. How am i going to calculate the power consumption for the device for a day (24 hours). I have Kw value for every minute.
Do I have to add the Kw value for every minute up to the whole day ?
Thank you.
@jeremyh yaa, the data will be insert into the database every minute.
@jeremyh so what should I do next is, minus 1 from all the register that I want since it start count from 0 right ? Thank you so much again. Thank you for helping me around since the beginning.
@jeremyh Thank you so much jeremy. You really save my life. I try 3109 in my java code, and it show the correct value that I want. Thank you so much for helping me out. Can you explain more on how you get the 3109 value ? Why in the documentation it say that 3110 ?
God bless you Jeremy..
@jeremyh actually some of my senior said that I suppose to add 40001 from its original register due to modbus protocol. I want to read the data from the register 3110 actually. In the documentation, the 3110 refer to the Frequency (Hz). That is my I get the 43111 register.
But I also try the 43110 and 43109 as you ask me to, but both the result is value: -4.5918E-41
@jeremyh For me, it interface is not a problem. The problem right now is that, I am not able to read the data from the power meter. I also have done the TCP master. Below is the latest code that I try
ModbusFactory factory = new ModbusFactory();
IpParameters params = new IpParameters();
params.setHost("10.168.168.197");
params.setPort(502);
params.setEncapsulated(false);
ModbusMaster master = factory.createTcpMaster(params, true);
// master.setRetries(4);
master.setTimeout(2000);
master.setRetries(0);
long start = System.currentTimeMillis();
try {
master.init();
ModbusLocator locator = new ModbusLocator(1, RegisterRange.HOLDING_REGISTER, 43111, DataType.TWO_BYTE_BCD);
System.out.println("value: "+master.getValue(locator));
}
finally {
master.destroy();
}
System.out.println("Took: " + (System.currentTimeMillis() - start) + "ms");
}
and the output of the coding is :
value: 8000
Took: 78ms
while there is no 8000 value at the power meter. Thank you.
@jeremyh Hi Jeremy. My goal is to read the data in the Schneider Power Login meter. The value going to be store in the database. My system going to show the meter value. Its like the real time data. The system going to take the meter reading every 5 second and show the value in the system. My system using the Java Language and Spring framework.
Below is the example of my system interface.
@hussam I downloaded the mango 2.5.2. But it just like another software that you can use to interact with the electrical device. How should I integrate the mango with my system ?
@hussam Hi hussam. Thank you for the reply. Is Modbus4j and Mango 2.5.2 is the different library ? About the serial com name, I still confuse about the value. Can you explain more ?
By the way odious, this is me writing a question in this forum. You can see what I've done so far, and maybe you can help me more. Thank you in advance for any kind of help and guidance.
Click here to read and understand more about my problem.
My Question
Hi odious,
I wonder if you still active in this forum. I want to communicate my system with the device. And I following the example in the Modbus4J and it does not give me the result that I want. I was wondering, if you could give me the full code on how you create a connection between the device and the system and being able to read the data from the device.
Currently I am working with the Schneider Power Logic electrical device. I want to read the data from the device and show the value in my system. So far, I discover J2mod, Jamod and Modbus4Java library. I used all modbus4java to connect and get the device's data.
Actually I still confuse whether I suppose to create Master side or Slave side. Based on my understanding, the device will be Slave and my system will be Master (1st question).
Below is the setting AT MY DEVICE. It indicate that the device in slave mode and its protocol is Modbus RTU. So, I need to create a master apps to communicate with it right which is using the ModbusRTU protocol right ? (2nd question)
Mode: Slave
Protocol: Modbus RTU
Address: 1
Baud Rate: 38400
Parity: None
Below is the code of my apps act as the Master and using the ModbusRTU protocol
public static void main(String[] args) throws ModbusTransportException, ErrorResponseException {
ModbusFactory factory = new ModbusFactory();
SerialParameters params = new SerialParameters();
params.setCommPortId("COM6");
params.setBaudRate(9600);
params.setDataBits(8);
params.setStopBits(1);
params.setParity(0);
ModbusMaster master = factory.createRtuMaster(params);
master.setTimeout(1000);
master.setRetries(0);
long start = System.currentTimeMillis();
try {
master.init();
} catch (Exception e) {
System.out.println( "Modbus Master Init Error: " + e.getMessage());
return;
}
try {
System.out.println("Reg. 1001 Value:" + master.getValue(1, RegisterRange.HOLDING_REGISTER, 3110, DataType.FOUR_BYTE_FLOAT_SWAPPED));
}
finally {
master.destroy();
}
System.out.println("Time elapsed: " + (System.currentTimeMillis() - start) + "ms"); }
This is the code that I get from the sample code provide by the Modbus4Java page. The other thing that concern me is the value of params.setCommPortId("COM6"); What other value than "COM6" that I can put there. Because basically it receive a String value. So am I able to put any String value to it ? And what is the function of this particular setCommPortID. (3rd question)
Looking at the sample code provide by the Modbus4Java page, it does not put the IP address of the device. But in my case, my device got an IP address. And the IP address only use in the Slave apps only. How should my system recognize the IP address of the device ? (4th question).
And after I run this code snippet, I got an error:
Native lib Version = RXTX-2.1-7
Java lib Version = RXTX-2.1-7
Modbus Master Init Error: com.serotonin.io.serial.SerialPortException: gnu.io.NoSuchPortException
Please, please and please help me. I been stuck with this almost a month. Really hope someone out there will be able to help me. Thank you in advance for any kind of help and suggestion.