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