Jump to content

Marko_marus

Members
  • Posts

    4
  • Joined

  • Last visited

Marko_marus's Achievements

Newbie

Newbie (1/4)

0

Reputation

  1. Hi, I have another problem. When I read values from PLC, there is some mistake when I try to access value in [0] My code: rw[0] = new ReadOperands() { OperandType = OperandTypes.MI, NumberOfOperands = 20, StartAddress = 1 }; try { _plc.ReadWrite(ref rw); object[] values = (object[])(rw[0].ResponseValues); Y = Convert.ToDouble(values[0]) / 100.0; When reading other values (values[1], values[2]...) everything is OK. What am I doing wrong?
  2. Thank you for reply, it is much appreciated.
  3. Thank you for reply, but I do not completely understand plc.ReadWrite()... If I state: ... OperandType = OperandTypes.MF, ... do I automatically start reading Memory Float registers? In my PLC (Vision 1040), adresses from (hex)7000 ared designated for float variables, so if I state that I want to read MF operand type, do I automatically start reading from (hex)7000? Or do I need to state: .... StartAddress = 28672 .... (hex 7000 = dec 28672) ? Is there no other documentation other than "Unitronics_Communication_Driver_for_Dot_Net.pdf"?
  4. Hi, I am new to Unitronics, and I am supposed to write a SCADA application that communicates to Vision 1040 and reads some values. I need to read 20 float values. Using Ethernet connection, TCP. The target PC runs Win7 64-bit, I am using VisualStudio 2010, .Net Framework 4.0 Client Profile. I read "Using the Unitronics Communication Driver for .Net", and examined examples on Unitronics Download section. I can establish communication with PLC, code: Ethernet eth; try { eth = new Ethernet("192.168.1.1", 20256, EthProtocol.TCP, 3, 3000); PLC nasaBeba = PLCFactory.GetPLC(eth, 0); //nasaBeba.ReadWrite( } catch (Exception ex) { MessageBox.Show("error: " + ex.Message); } What I don't understand is how the PLC.ReadWriteRequest() works. I am trying to read one float value from address (hex)7000, this is starting value of "float" registers in vision1040 PLC (found this in documentation). My code: ReadWriteRequest[] rw = new ReadWriteRequest[1]; rw[0] = new ReadOperands() { OperandType = OperandTypes.MF, NumberOfOperands = 1, StartAddress = 7001 }; try { nasaBeba.ReadWrite(ref rw); object[] values = (object[])(rw[0].ResponseValues); label1.Text = values[0].ToString(); } catch { System.Windows.Forms.MessageBox.Show("error"); } Anyway, I woud like to have some explanation how does PLC.ReadWrite() works, and expecialy how to prepare ReadWriteRequest: - how to set address? Do I set it in hex values, or do I need to convert to decade value? - does OperandType determine size of data I am reading? If I put "OperandType = OperandTypes.MF" doeas it mean that I automatically read size of float with one read? Any help with ReadWrite() and ReadWriteRequest would be greatly appreciated. Or if you could just point me to documentation that I need to examine... Thank you in advance, Marko
×
×
  • Create New...