Posted 29 Jul 2016 Hi, anyone who can help me white my issue in sysmac? Pleas Lock at the Picture file for my question. Regards Stian Share this post Link to post Share on other sites
Posted 30 Jul 2016 I'm not familiar with this processor, but if the value is a signed integer, toggling the most significant bit in the word will switch from a positive to a negative number, you could use an AND mask to do this when the sequence bit is active. Steve Share this post Link to post Share on other sites
Posted 30 Jul 2016 7 hours ago, nehpets said: I'm not familiar with this processor, but if the value is a signed integer, toggling the most significant bit in the word will switch from a positive to a negative number, you could use an AND mask to do this when the sequence bit is active. Steve That's not true. The positive and negative values will not match if all you do is flop the MSB. Think about this.... 0111 1111 1111 1111 is 32,767 1111 1111 1111 1111 is -1 The MSB has a value of -32768. All other bits are positive. If it's >0 it's positive. If you want it negative subtract that value from zero. If it's <0 then it's negative. Use the ABS instruction to make it positive. Share this post Link to post Share on other sites
Posted 31 Jul 2016 Crossbow Yeah you're right, I have aboslutely no idea what I was thinking - my brain must be somewhat addled after four 16hr shifts, please disregard my post. Steve Share this post Link to post Share on other sites
Posted 31 Jul 2016 Don't worry about it, buddy. I pulled the same stunt about three years ago. Took me three days to figure out it wasn't as simple as it seems. Share this post Link to post Share on other sites
Posted 1 Aug 2016 A more rudimentary method is to do Two's Complement Math. It is performed by inverting all the bits then adding 1. Omron's C Series PLCs have a Two's Complement instruction. Sysmac Studio has a Neg instruction to do this for you. Share this post Link to post Share on other sites
Posted 2 Aug 2016 Hi Stian, Maybe you can use function Mul (*): P300 Length*(-1). Good luck! Qing Share this post Link to post Share on other sites
Posted 2 Aug 2016 it takes two steps - first you need flip-flop to toggle bit. then depending of this bit is set or not make result positive or negative. Share this post Link to post Share on other sites
Posted 9 Aug 2016 Some of the solutions above are a bit more complicated than necessary. I agree with Qing, just multiply by -1 with a leading edge one shot on the bit, like this: Share this post Link to post Share on other sites
Posted 27 Aug 2016 I would subtract the value from zero. An old habit from classic PLCs, where this executes times faster than multiplication, and also prevents unnecessary change of the data format. Share this post Link to post Share on other sites
Posted 29 Aug 2016 On 8/27/2016 at 9:49 AM, Sergei Troizky said: I would subtract the value from zero. An old habit from classic PLCs, where this executes times faster than multiplication, and also prevents unnecessary change of the data format. That would certainly work, but in the NJ, the * function does not necessarily require a data format change. For instance, you can multiply two integers (INT) and still use an integer variable (also INT) for the answer. Share this post Link to post Share on other sites