Vitaly K.
-
Posts
10 -
Joined
-
Last visited
Content Type
Profiles
Forums
Gallery
Events
Blogs
Downloads
Articles
Media Demo
Posts posted by Vitaly K.
-
-
So as some people proposed, you need to put the number 0x8000 to a ML, so the MSB won't be 1.
I understand this solution. I think my solution (multipliing by -1) isn't worse.
And I suppose the fact (MSB must be 0 if you shift right) must be noticed in help-files.
-
Hi,
You can achieve the result you want by dividing the original value by 8192 (2^13)
It seems that the Shift Right does not preserve sign.
Hi.
Dividing by 8192 gives the same result. I see the solution. I must analyze the result and multiply by -1 if MSB=1.
But seems to me that it is PLC's bug. There must be possible to shift bits from any position.
-
If you would like to see what is happening with the bits, i would recommend using the memory field and setting it up like in this image. You can watch the bits shifting right. If the MSB is a 0, it will shift in a 0, and if it is a 1, it will shift in a 1.
8000h has MSB=1. So MI will be filled by 1 while shifting. Am I right?
Then how can I fill MI by 0 while shifting to get 0000000000000100?
-
According windows calculator the result is absolutely correct.
I think the result must be 0000000000000100 but not 1111111111111100.
-
-
I use FB protocol. Thank you for the answer.
-
About the second question - you can store/copy received MI to another MI and there to perfomr Swap. In this case you will have two registers - each one with its value.
If I copy MI to another MI during every program scan, the swapped value of another MI will be overwritten by the unswapped value in the next program scan. There must be condition for copiing.
-
PLC V130 receives double float (64 bit) as 8 bytes with the following format:
http://en.wikipedia.org/wiki/IEEE_754-1985#Double-precision_64_bit
Can I easily get double float like here: http://www.unitronics.com/forum/topic.asp?TOPIC_ID=2102&SearchTerms=swap+bytes ?
And one more question about FB Swap bytes. It puts swapped bytes into the same MI's. But these MI's are cyclically got from COM-port. So MI's values blink: swapped-unswapped. How can I avoid of the blinking?
-
Hi.
Who can give me an example how to connect PLC Unitronics and some device supporting only Modbus ASCII? I know that Unitronics supports only Modbus RTU.
I need a program using FB Protocol.
Shift right (FB SHR)
in Vision & Samba PLC + HMI Controllers & VisiLogic Software
Posted
I understand that this bit means the sign.
It isn't moving left or right like other bits.
One more example is below.
8000h = 1000000000000000
E000h = 1110000000000000
But if I shift right 2 positions the result must be 2000h = 0010000000000000.