Jump to content

Math exponentiation


Recommended Posts

Hi Pawks,

Jazz 2 (JZ20) does not support exponential function.

Jazz 2 have limited Long support and no float point support.

What kind of calculations do you need?

What is a formula?

What is an input and output numbers range?

You can look at Internet, how to realize approximate exponent calculation in integer numbers.

If you are in need of math functions, you can use Samba PLC, which have support of Exp function and Floating Point support.

BR

Link to comment
Share on other sites

Hi,

 

Thank you for answer.

 

I only needed 2^x, where x is an integer up to around 10 max, so the results are 2,4,8,....,1024.

 

If anyone else would like to know i used loop function.

every loop i multiply number by 2 and decrease x by 1 until x equals zero.

 

Not a big problem, i just thought that such function already existed.

 

Thanks again,

 

Regards,

Pawks
 

Link to comment
Share on other sites

Hello Pawks,

 

have you thought about using the shift register special function?  When shifting an MI to the right, you are multiplying the number by 2 each shift.  So for 2^5, you could use the shift register function and shift the bits by 5 to the right.  The only issue is when the number becomes very large - if you shift the bits in the MI too far, the bits at the end will drop resulting in an incorrect number.

 

Shift function:

 

SI 87 = number to be shifted

SI88 = number of bits to shift

Set SB 87 to shift to the left

Set SB 88 to shift to the right

 

Hope this helps.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...