[Teensy3.1]:[Modbus] Communication Issue

Status
Not open for further replies.

Prasad

Member
Hi,

I am facing a problem with Modbus communication particularly at the receiving side.
Here the Master device is my Teensy3.1 controller (Rx-7, Tx-8) and slave is L&T Nova energy meter.
(http://www.larsentoubro.com/lntcorporate/uploads/product/nova manual.pdf)

The interface is via MAX345, the connection diagram is attached below.
Attached the SimpleModbusMaster project for reference.

The following procedures were followed to test the communication.

1. The slave Id is set to 2, baud rate is set to 9600 with parity None.
2. Sent a frame "2 4 0 0 0 2 113 248" from controller to the slave(L&T Nova).--> "modbus_construct(packet1, 2, READ_INPUT_REGISTERS, 0001, 2, readRegs)"
3. Verified the frames at various levels like i/p of MAX485 and o/p of MAX485. The frame was correct.
4. But on sending this frame, the response seen in the controller is exception error '2'.
5. Further we connected the o/p of MAX485 to Docklight (parallel with controller also connected). --> RS485 to USB converter used to view in PC (Docklight)
6. We observed that on sending the above frame from controller, slave was successfully sending the response to Docklight but failed response in the controller.

The frame received in Docklight
Hex "02 04 04 00 00 59 C0 F2 84"
Dec "002 004 004 000 000 089 192 242 132"

We used chipkin software for analysing the modbus frame received in Docklight

Response Analysis
-----------------
Device Address =2 =0x02
Function =4 =0x04 =Read Input Registers
Point Count =2 (Implied by byte count=4)
Point Index =1 Value=0 =0000. (Address is unknown because the Poll Message was not provided.)
Point Index =2 Value=22976=0x59c0. (Address is unknown because the Poll Message was not provided.)
Note that without knowledge of the poll, the specific addresses of each point cannot be determined as this information is not contained in the response.

Note: The 22976 is the phase1 voltage register of L&T Nova with Multiplication factor of 0.01(229.76V)

Kindly request you to help me in get this issue solved.

Thanks,
Prasad
 

Attachments

  • SimpleModbusMasterArduino.zip
    1.7 MB · Views: 179
  • Teensy Modbus.JPG
    Teensy Modbus.JPG
    131.3 KB · Views: 413
Just a guess, but do you need to level shift the TX pin so the RS485 chip sees a 5v signal instead of a 3.3v signal?

Now, on the Teensy 3.1 you don't have to level shift the RX pin, since the chip is 5v tolerant, but it probably won't hurt if you do. If you used a Teensy 3.0 you would need to level shift it.

There are various level shifters out there that can handle serial communications. This happens to be the one I just got for i2c and neopixels: http://www.pololu.com/product/2595

Another possibility is your device wants a different number of stop bits than the Teensy provides by default.
 
Last edited:
Hi Michael,

Thanks for the quick response,
I changed the stop bit to 1 and above that i also modified the code in function " waiting_for_reply() " as below

while (noOfBytes2Read = (*ModbusPort).available()){

for(int c = 0; c < noOfBytes2Read; c++)
{
frame[buffer] = (*ModbusPort).read();
Serial.print(frame[buffer], 16);
Serial.print(' ');
buffer++;
}
}

The frame i am receiving is analysed in chipkin software and the frame gives the same voltage value (data)as displayed in meter.

Is there any function which is used to retrieve the data from the received frame?

Thanks,
Prasad
 
Last edited:
Hi Prasad,

I think your setup is probably working fine, you just need to work on the code a little. Exception code 2 means Illegal Data Addresses which might be because you have told Modbus lib to send 7 packets, but you have only set up one. The rest are not initialised, so you will be sending junk to the slave.

The packet you have setup appears to get a valid response. The data read form the slave should be in readRegs[], so you should print that and see if it has the expected value.

Your diagram does not show in RE-/DE is connected to pin 2, but I think it must be otherwise the request would not get through.
 
Status
Not open for further replies.
Back
Top