Comments (12)
- OK
- OK
- This looks correct; you'll initialize the Serial port using the standard Arduino syntax specifying baud rate, size, parity, and stop bit(s). Device is address #1 on the RS485 network.
- Modbus holding registers are 16-bit. Page 57 of the manual referenced in #2 above indicates "In the transfer of individual data values, it treats two registers as an object with the starting address (e.g., 3900) considered as the object name." Your code looks correct to read 2 consecutive registers starting at 3913 for the current average. You'll need to assemble these unsigned 16-bit values into an unsigned 32-bit value and convert to float. This spreadsheet appears to do what you desire.
from modbusmaster.
- I have interfaced EM-6433 using arduino over Rs485. Rs485 IC used is SN75HVD08.
- EM-6433 settings are slave id:1 & baud:19200, even parity & 1 stop
Confirmed it aftr turing on meter & go to its settings table. - Case 1: If I permanently pull down N_RE pin & pull up DE pin of SN75HVD08, then when I used the attached code I always receive 0xE2 in return from device ie ku8MBResponseTimedOut. In code ignore the code which ouput high & low the RE & DE pin. This is used in case 2. In this case, this is commented out.
- Case2: Since this SN75HVD08 is half duplex so I connected RE & DE pins to arduino as in attached circuit. Also I have modified ModbusMaster.cpp file in line 728 & 729, where I added code to disable Tx & enable rx from IC. When I use this code I receive error 0x02 in result, which is ku8MBIllegalDataAddress.
What am I doing wrong here. I also interchanged A & B pins to slave device EM-6433 + & -. But no correct result obtained.
5.All ckt diagram and code is here: https://drive.google.com/open?id=0B-jbeBk3wfkWaWo1ek5ISUxoTzA
from modbusmaster.
I don't see anything obvious, but I'm not familiar with your device. Here's how I would proceed: start with as small a working example as possible and build upon that.
- Get one of the examples working with your device. Remove any extraneous code and start from as basic a setup as possible. This ensures your baud rate, parity, stop are correctly applied.
- Build upon the example by adding layers of complexity (LCD display, etc).
Do you use a logic analyzer such as a Saleae Logic or similar unit? This will help you decode the signal to ensure it's being sent/received correctly. Note that I don't have any relationship with Saleae, other than as a satisfied customer.
from modbusmaster.
Hi
- SN75HVD08 has Rx & Tx enable pins. I have shorted them, & in the code I keep this pin high, which means keep on transmitting any data.
In the code snippet below I added a line which brings pins low. This means now receive. Below is code which i have edited in your library:
if (_postTransmission)
{
_postTransmission();
}
digitalWrite(2, LOW);
// loop until we run out of time or bytes, or an error occurs
u32StartTime = millis();
while (u8BytesLeft && !u8MBStatus)
{
if (_serial->available())
{
#if MODBUSMASTER_DEBUG
digitalWrite(MODBUSMASTER_DEBUG_PIN_A, true);
#endif
u8ModbusADU[u8ModbusADUSize++] = _serial->read();
u8BytesLeft--;
#if MODBUSMASTER_DEBUG
digitalWrite(MODBUSMASTER_DEBUG_PIN_A, false);
#endif
}
-
As soon as receive is done again bring the pin to high, this way I am able to get correct data.
Is it ok? -
Second, I am reading mutliple slave devices in a line. How to send each slave id. Do I have to evrytime initialize like this:
node.begin(slave_id, Serial1);
delay(100);
digitalWrite(r_enable, HIGH); /* rx enable /
result = node.readHoldingRegisters(address - 1U , 2U);
digitalWrite(r_enable, HIGH); / rx enable */
from modbusmaster.
To read multiple devices, you'll instantiate each one as a separate object:
...
ModbusMaster device1;
ModbusMaster device2;
...
Serial.begin(19200);
device1.begin(1, Serial);
device2.begin(2, Serial);
...
from modbusmaster.
Hi VindhyaChaltakniki,
I am also working on the same project, that is to query a EM6400 multifunction meter for different parameters using an arduino module, i wanted to know if you got the results properly. I am using the same library that you are using, however i am using Max485 ic as a RS485 to TTL Converter, and in Max485 it automatically switches between Transmission and Recieve Modes. So you may use that for it if you are still stuck with it, I wanted to know is your slave working with a Software such as MODSCAN as a master?? My EM6400 is responding well with this software but with the arduino , it is giving an exception of timeout, what can be the problem?
from modbusmaster.
Hello ,
i'm trying to read veritech MFM using this library, but im getting response 0xF2 that timeout . i tried using halfdyplex example still im not finding output. and i wanted to read input registers of MFM.
im using software serial instead of hardware is that the problem ?
here is my code
void loop()
{
static uint32_t i;
uint8_t j, result;
uint16_t data[6];
result = node.readInputRegisters(53, 2);
Serial.println(result);
// do something with data if read is successful
if (result == node.ku8MBSuccess)
{
for (j = 0; j < 6; j++)
{
data[j] = node.getResponseBuffer(j);
}
Serial.print(data[0]);
Serial.print(data[1]);
Serial.print(data[2]);
Serial.println(data[3]);
delay(1000);
}
}
can please explain two parameters of this function - result = node.readInputRegisters(53, 2);
1st parm i understood that its add of reg what about second parm? is that the pointer to store output?
thank you
from modbusmaster.
Hello sir,
i'm also trying with EM6436 energy meter from Schneider
can you please provide me the code which you have written for em6433
from modbusmaster.
@sachinsinghal9 Hi! Doing A similar project with EM1200. Were you able to find a solution? CAn you share me the details?
from modbusmaster.
@gau999 did u find the solution
from modbusmaster.
Hello All, did you find the solution?
could you please share the ideas?
by
thiruppathi
[email protected]
from modbusmaster.
@gau999 @kprakash811 did u find the solution?
from modbusmaster.
Related Issues (20)
- Unable to communicate with Auber Instruments SYL-2381 Temperature Controller
- Read Holding Registers returns 266 (Error) HOT 1
- Can Serial1 (Rx1 and Tx1) be used via a DUE to communicate over Modbus, or must it be Serial0 (Rx and Tx)? HOT 2
- Modbus RTU communications Using RS-232. No response, CRC exception codes. HOT 3
- Issues uploading sketch to arduino and disconnecting pin 0
- PIN ID HOT 4
- CRC?
- Reading 32 bits number from two registers HOT 5
- Question about readWriteRegister example HOT 1
- ReadHoldingRegisters takes 2seconds HOT 3
- Changing Slave ID
- Possible to get raw data from slave? HOT 1
- Modbus function 0x16 maskWriteRegister
- Pico W Readings From Read Holding Registers Not Stable
- Read Holding register using usb-rs485 and Arduino Mega
- Communication with PLC
- QUESTIONS - How to get values only present in the 0x10 segment
- [QUESTIONS] writemultipleregisters - possible to skip x addresses?
- MAX13487e - Error 227
- Report Slave ID
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from modbusmaster.