Hi all,
I want to ask, how do I write code to read multiple address ? Because this multiple address will produce one reading of a sensor that I am currently using. I want to read the value of the sensor.
Fill it with your data structures, it is important to know tha every Variable in this union shares the same datastorage. for example you can write your REAL value, by accessing the array of bytes.
Instanciate the union in you POU (PLC_PRG, … ) and write your values. Sometimes you have to change the write order of the array, to change Byteorder of the REAL value.
Exaclty. But i guess you have to change the Byte Order. Because some Comanies work with intel byte order and some with motorola.
Therefore you can just switch the bytes like this, until you have an plausible value:
abInputData[0] := %IB78;
abInputData[1] := %IB77;
abInputData[2] := %IB80;
abInputData[3] := %IB79;
what if I want to read 2 value of sensor where another sensor need to read another 4 address. Do I have to create new UNION DUT? And also create new same variable that I have created for the 1st sensor? Sorry for asking too much.
You’re Welcome, you just can make an second instance of the same datatype.
Which will look like this:
myValue1 : U_BYTE_CONVERT;
myValue2 : U_BYTE_CONVERT;
…
and so on, so you can map the different values.
For Example the mapping would look like this:
another question I would like to ask. What if theres 2 sensor? where both first and second sensor are the same sensor and going to read the same address. How do I differentiate between these two if I want to read values from both sensors? Create new UNION DUT?
but how do i determine that this Union DUT is for this sensor 1 with IP address x.x.x.10 and this Union DUT is for sensor 2 with IP address x.x.x.9 for example.
Hi,
For example below in the picture, this is the code for 1st sensor (IP210) at PLC_PRG. How can I write the code at PLC_PRG for 2nd sensor (IP209) . Both of the sensor have the same address that need to be read, but how do I write the code for another sensor since the code does not declare any IP address.