serial port - How to use NModbus and C# with PLC to to turn outputs on and off -


Hi all I am using the NModbus library, and was running on VS2012 and then VS-2010, but it was trying to run for VS 2008. And it's going to be better.

When I run the code in DOS prompt, this is my output

  Modbus.IO.ModbusSerialTransport Write - TX: 1,16, 7,208,0,3 , 6,0,1,0,5,15,14,14,152 modusbus.io.modbusrtrrrrrrrrrrrrrrrrrrrrrrrrrrr transport-rx: 1,16,7,208,0,3,128,133  

Now when If I run this script then I get flicker on my PLC unit for Rx and TX, but I do not see high output on my PLC here. Ministry associated piece of code

  {(serialport port = new serialport ( "COM1")) {// configure serial port port.BaudRate = 38400; Port.DataBits = 8; Port.Parity = Parity.Odd; Harbour. Port = stop One; Port.Open (); // modbus Master Build IModbusSerialMaster Master = ModbusSerialMaster.CreateRtu (port); Byte Slave ID = 1; Ushort startup base = 2000; // ushort [] registers = new users [] {1, 2, 3}; Ushort [] Registers = New Users [] {01, 05, 15}; // write three registers master.RiteMultipleRegisters (slaveId, startAddress, registers); Can anyone help me understand TX and RX, and maybe help me in pointing out how I can set high output from C #. Script? 

If you convert the hexadecimal representation of the bytes is easy to understand the TX and RX data. For TX data we have:

01 10 07 d0 00 03 06 00 01 00 05 00 FF 95 98

01 Modbs Slave address

10 write more Rivostrs function of the Modbus function code

<

00 03 (3)

is the number of being written <<06>

00 01

strong> value is going

< p> 00 0 F has written a letter to the cost to register in 2000

00 05

95 98 calculated for the frame CRC

we have to Rx data:

< strong> 01 10 07 D0 00 03 80 85

write Mulitple to registers respond to function out only one slave function codes starting out, and a reaction with the number of registers requested Calculate CRC for plus response frame ( 80 85 ).

You can get the Modus specifications from you. You can find the format of all requests and feedback frames in the Modbus application protocol specification.

You need to check your PLC document to see how the output is mapped for the registers. As they outputs are turned on / off, they probably are mapped to the coil, should write to multiple Coils function in this case.


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

c# - Create dynamic LINQ query expression at runtime which translates into a parameterized SQL query for nullable types -

cmake - cpack generates RPMs with %files entries that conflict with the RPM spec. How to fix? -