Jump to content

Recommended Posts

Posted

  I have an Jazz application where I am trying to keep track of a hundreds of tonnes of a product in 1kg increments and as such want to use 32 bit numbers. I couldn't actually find it documented if I try using SB82 with addition to handle what will happen when I eventually exceed 16 bits. IF it is as simple as setting SB82 adding MI0 to MI2 and putting the result in MI4. If I am right in my hope that I can do this will it take MI0 and MI1 as an 32 bit number or will it just take MI0.

  If SB82 doesn't allow for 32 bit addition can someone give me a method of adding a 16 bit number to a 32 bit number for a 32 bit result.

Posted

Hello,

 

You are correct.  Setting SB82 will turn take two adjacent MIs and combine them for a 32-bit integer.  The first MI (f.e. MI0) will hold the lower byte of the number, and the adjacent MI (f.e MI1) will hold the higher byte of the 32-bit number. 

 

We recommend storing this value into two other MIs so you can use the 16-bit functionality of the MIs, then resetting SB82, otherwise all of your MI values will be treated as 32-bit 'long' integers.  Therefore, in the ladder:

 

-Set SB82 and store MI0 and MI1 into MI2 and MI3:

     - A Parameter : MI0 (as 32-bit 'long integer' with MI1)

     - B Parameter: MI2 (with MI3, treated as two independent 16-bit integers)

 

-Reset SB82

     - MI0 and MI1 are treated as two independent MI values

     - MI2 and MI3 are treated as one 32-bit 'long integer'

 

Hope this helps.

Posted

That's great info thanks Shane.

Just out of curiosity does SB2 stay set for the duration of sequencing until reset, for the next instruction or for the 1 net. I've assumed that it's just been for the next instruction but I haven't had a test run of it as yet and without the ability to simulate the process I'm just guessing.

 

Thanks

Alan

Posted

I worked out that I need to reset SB82.

Now I have an issue. I am running very low on program space and need to add the 9 consective 16 bit numbers to 9 consecutive 32 numbers. I haven't worked out a recursive way of doing it without gobbling up most of the last 100 instructions I have left to play with. Everthing I have thought of so far uses pretty well all of that 100 and I need some of that 100 for other stuff.

For example I need to add MI0 to MI20(MI21), MI1 to MI22(23), MI2 to MI24(25) etc

  • MVP 2023
Posted

This sounds like the Jazz Wall to me.  Can you upgrade to a V130, considering all the time you're putting into it?

 

Joe T.

 

PS - The "Jazz Wall" is when you start with a Jazz because the price is so attractive but you figure out in the course of programming that it's just not enough PLC to do what you want without serious code acrobatics or even at all.  It's my own personal definition and in no way represents the opinion of Unitronics.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

This site uses cookies. By clicking I accept, you agree to their use.