function NewPing not return value when I activate Modbus function

I am trying to send from Arduino to Siemens S7 with Modbus the readings from the ultrasonic sensor. When I don't use the Modbus function "MB" the distance are calculated correctly, when I initialized the "mb" function the return value from "NEWPING" function is 0.

tank.ino (1006 Bytes)

Which Arduino are you using? On the 328-based Arduinos, such as the Uno, pins 11, 12, and 13 are the SPI pins, which are used by the Arduino to communicate with the Ethernet shield. You can NOT use them for the ping sensor, too.

Thanks, I change the pins and it's working.