Fez spider modbus tcp ip

sto cercando di far comunicare la mia scheda Fez spider con un modulo Ethernet ENC28 con uno scada.
Le libreria che sto utilizzando vanno in conflitto con la scheda.
Qualcuno ha già fatto comunicare i due sistemi ?
Che librerie Modbus potrei utilizzare?
Qualcuno ha già utilizzato la Fez Spider come master.
Grazie per la collaborazione

I think English language would be better to ask questions…

Instant translation:

I’m trying to communicate my Fez spider with a ENC28 Ethernet module with one expires.
The library that I’m using are in conflict with the Board.
Someone has already done the two systems communicate?
That I could use Modbus Library?
Someone has already used the Fez Spider as master.
Thank you for your cooperation

I’m currently working on Modbus RTU and TCP library for NETMF.
Both - Master and slave - modes will be supported.

I think I can make an initial release by the next weekend

I will try to use it when available.

Someone has already used the Fez Spider as master tcp/ip

There is already a modus library for netmf. It was built for other nermf devices but it will work on our devices with very little changes.

Is this the one you refer to?


1 Like

I just have posted my Modbus library on CodeShare:

@ Gus - I would like to know which one your referring to as well because I am doing MODBUS RTU work now…

@ jvetter - There are a lot of Modbus RTU/TCP libraries out there.
Mine works quite well.
If you need support or additional function codes, I could assist you.

@ Reinhard Ostermeier - I’m going to start using your library. Where can I find the latest? I have found a few links on this site to different versions…

Also, I assume this works with the RS485 module?

There is currently one version in Codeshare which is the latest
The other one in codeshare from me is for Medusa (Arduino)

I made no changes to it so far, and it might have some bugs.
But I can fix them quickly during this week if you find some.

And yes, I tested it with RS485 module.

@ Reinhard Ostermeier - Excellant, thanks! I’m going to be using it with Fez Raptor and the RS485 module in an attempt to interface with another vendors devices.

I will let you know how it goes.

@ Reinhard Ostermeier - Is there any example code for your library?

@ Reinhard Ostermeier - I think I figured everything except how to use a raptor port with System.io.ports.SerialPort versus Gadgeteer.Interfaces.Serial…how does that work?

@ Reinhard Ostermeier - Ok, what I have done is to replace System.io.ports.Serial Port with Gadgeteer.Interfaces.Serial in ModbusRtuInterface and fixed the couple of other references. Then I just pass the port from the RS485 module to your code (see below). That all seem kosher? Thanks!

rs485.Initialize(38400, GT.Interfaces.Serial.SerialParity.Even, GT.Interfaces.Serial.SerialStopBits.One, 8);
ModbusRtuInterface rtuIf = new ModbusRtuInterface(rs485.Port);
ModbusMaster master = new ModbusMaster(rtuIf);
master.WriteSingleRegister(0xF7, 9002, 0x01);

public class ModbusRtuInterface : IModbusInterface
      private readonly Gadgeteer.Interfaces.Serial _Serial;
      //private readonly SerialPort _Serial;
      private readonly long _HalfCharLength;
      private long _NextSend;

      public ModbusRtuInterface(Gadgeteer.Interfaces.Serial serial, short maxDataLength = 252)
         if (serial.DataBits < 8)
            throw new ArgumentException("serial.DataBits must be >= 8");
         _Serial = serial;
         MaxDataLength = maxDataLength;
         MaxTelegramLength = (short)(maxDataLength + 4);

         // calc char length in µs
         if (serial.BaudRate > 19200)
            // use a fixed value for high baudrates (recommended by Modbus spec.)
            _HalfCharLength = 500;
            short bitCnt = (short) serial.DataBits;
            switch (serial.StopBits)
               case Gadgeteer.Interfaces.Serial.SerialStopBits.One:
               case Gadgeteer.Interfaces.Serial.SerialStopBits.OnePointFive:
               case Gadgeteer.Interfaces.Serial.SerialStopBits.Two:
                  bitCnt += 2;
            if (serial.Parity != Gadgeteer.Interfaces.Serial.SerialParity.None)
            _HalfCharLength = (short)((bitCnt * 1000 * 10000) / serial.BaudRate) >> 1;

I usually do not use Gadgeteer.
An other option would have been to not add the RS485 module in Gadgeteer designer and create the System.Io.Serial in code with the correct COM port.
Since the interface in my Modbus library is exchangeable, I could add it as an additional option.

About samples:
The basics are shown in the usage sample in Codeshare.

If you know how to use one function code, you know them all.
In fact the top level of the Modbus interface is quite easy to use.

But be prepared to get surprised how the device manufacturers use it. Sometimes you just can shake your head about that.

@ Reinhard Ostermeier - Yea, the problem though is it does more work under the hood that would be missed if you don’t use the gadgeteer one. Also, I don’t know how do determine the port name on the device which is what I was asking about earlier.

Doesn’t look like my devices can talk for whatever reason. Guessing maybe the voltages are too low coming from the gadgeteer device.

Normally the voltage is not a big issue, but the RS485 needs 5V. Most other modules worked fine with 3V3 only.

You have to make sure you have the right polarity on the RS485.
I think the labeling of the module is inverse.

A = Data +
B = Data -

you can also add termination resistors to both ends of your bus.
Just put a 120 Ohm resistor between A and B (aka + and -)
Normally on short wires, and if the baud rates are not too high it’s not required.

Also baud rate, stop bits and parity is important to be equal.