Hello,
Is it possible to send a real value (positive or nagative) stored in a Register, from Robot to Siemens PLC connected only by Profinet?
If so, how?
Thank you
Hello,
Is it possible to send a real value (positive or nagative) stored in a Register, from Robot to Siemens PLC connected only by Profinet?
If so, how?
Thank you
No, only integer is possible. You have to convert the real value into an integer before sending it via PROFINET. There are different approaches on how to do that.
No, only integer is possible. You have to convert the real value into an integer before sending it via PROFINET. There are different approaches on how to do that.
Any idea where can read about this different approaches?
Thank you
Hi,
if the values are rather small the sender may, for example, multiply them by 100 and cut off the remaining fractions before sending and the receiver simply divides them by 100:
sender:
out = to_int(value*100)
receiver:
value = in/100
Most PLCs I know of can handle negative values from scratch. FANUC only allows integer from 0 to 65536 to be sent/received via IO and handles them as two's complement, thus this way, and for this example, you can send/receive values from -367,68 to 367,68. If you increase or decrease the divider / multiplier just the decimal point moves. If the values are bigger you may use separate inputs and outputs for decimals and fractions. For example:
sender:
out_decimals = to_int(value)
out_fractions = to_int((value - to_int(value))*100)
receiver:
value = in_decimals + ((in_fractions)/100)
This way you can send and receive values from -36768,99 to 36768,99. Increasing or decreasing the divider / multiplier results in less or more digits for the fraction. The decimals are limited to +-32768 anyway.
If the values are even bigger you have to tinker a lot using bit masks and logical operations.
Some programmers also using digital inputs and outputs to differntiate between positive and negative values. Below is a simplified example to show the basic principle:
! Send value from robot to PLC ;
R[1]=1.23 ;
R[1]=R[1]*100 ;
IF R[1]>=0 THEN ;
DO[1:Value is positive]=ON ;
ELSE ;
DO[2:Value is negative]=ON ;
R[1]=R[1]*(-1) ;
ENDIF ;
GO[1]=R[1] ;
There is much more to do to make the conversion more robust, e.g. make sure that there are no decimal places left, make sure that the value is within the maximum range of the group input/output (the maximum is 16 bit), sign check, etc.
I'm using a whole different solution for the conversion of Real2Int and Int2Real on my FANUCs.
Unfortunately, I cannot provide you with my code because I'm out of the office and I don't know the whole code by heart.
Thank you all;
I'll try to do it with your approaches and let you know if I success.
I'm using a whole different solution for the conversion of Real2Int and Int2Real on my FANUCs.
Unfortunately, I cannot provide you with my code because I'm out of the office and I don't know the whole code by heart.
I am interested in your solution, is it possible to you to share it when you get back to your office?
Thank you again
I am interested in your solution, is it possible to you to share it when you get back to your office?
Thank you again
Yes this is possible, I will keep it in mind. But it will be end of September until I'm back.
You need to be a member in order to leave a comment