Jump to content

Combining INT16 Values


jeepers52004

Recommended Posts

Hi forum goers.  I would like to combine two values from two separate INT16 registers into a single INT16 register without adding or subtracting them. 

 

For example:

INT16-1 contains the value "34"

INT16-2 contains the value "56"

 

I'd like INT16-3 to contain "3456"

 

Is this possible and if so, can you show me the way.

 

Thanks!

Michael

Link to comment
Share on other sites

This is not always possible (since the result might exceed the limit of INT16, for example:

Int16-1: 123

Int16-2: 456

 

You will get 123456, while the limit of Int16 is 32787 (and uint16 is 65535).

 

As for the math, count the number of digits in the right number (the lowest part), if it has 2 digits, then it means that you need to multiply the higher number by 10^2 (which is 100), so you get:

 

34 * 100 + 56

 

 

If you need it as a string, then you can use the message builder.

Link to comment
Share on other sites

Would you then use the real to int function to put the result into a single register and just create a "dummy" register to hold the fractional part of the real to int function result? 

 

On a related "newbie" type question, is there a means to set or reset multiple coils in a single instruction or is the only method to use the set and reset coil elements for each individual coil to set or reset?

 

Thanks!

Michael

Link to comment
Share on other sites

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.