OMRON Forums

# 48-bit-floating point operation modulo "%" on 48 fixed-point variable - avoiding data/precision loss

## Recommended Posts

Posted (edited)

Hi!

I got to handle an equation like this one in a plcc0:

q1 = (m1 - m2 + m3/m4)%p1

where

m1->d:\$ with varrying value from endlessly one-way running counter

m2->d:\$ with constant value (any range within +- 2^47)

m3->d:\$ with constant value (-1e08 to 1e08)

m4->y:\$ with constant value (1 to 10e6)

p1 with constant value (2 to 10e7)

I have to use the modulo operator "%" to limit the range of q1.

The reason is that I have only 32 bit to transmit the value of q1 further on to the host.

My concern is data loss when it comes to very high values (above 2e10 a q-variable 'looses' >1ct)

Is there a better place for the modulo operator '%'?

Or is there even a better way to get around?

From my understanding, any mathematical operation is fulfilled in a 48-bit-floatiing-point manner!? So there is no way around avoiding any data loss....

Anton

Edited by sutty
refine title
##### Share on other sites

• sutty changed the title to 48-bit-floating point operation modulo "%" on 48 fixed-point variable - avoiding data/precision loss
• Replies 3
• Created

#### Posted Images

Posted (edited)

If most of your equations are constant, you can use a computer to calculate them ahead of time, which can improve the accuracy of your calculations.

Due to the hardware limitations of the Turbo PMAC, it is difficult to avoid calculation errors.

Turbo PMAC uses Motorola's 5600 series fixed-point DSP with a 56-bit accumulator to ensure additional calculation accuracy.

Avoid very large numbers.

Whenever m1 - m2 + m3/m4=p1, m1 can be cleared to avoid the occurrence of maximum values.

The calculation accuracy of the hardware cannot be improved, but other methods can be used to avoid this problem.

Edited by MoMo
##### Share on other sites

Thank you MoMo!

I am not deep into Motorolas 56xxx-family. So, it would help us a lot, if you could provide us any formula to be able calculating the error depending on m1 resp also all the other constants involved.

Best Regards, Anton

##### Share on other sites

I'm not sure what your specific needs are. But I think I just want a remainder.

You can use the incremental value of M1 for each servo cycle to re-accumulate in a new variable. Once the value subtract (m2 - m3/m4)  is greater than p1, and keep the remainder to the variable.Then re-accumulate, which will avoid the occurrence of maximum values.

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

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

×

### Announcements

×
• Forums

• Events

• #### Store

×
• Create New...