sutty Posted June 25 Share Posted June 25 (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.... Thank you in advance! Anton Edited June 25 by sutty refine title Quote Link to comment Share on other sites More sharing options...
MoMo Posted June 25 Share Posted June 25 (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 June 25 by MoMo Quote Link to comment Share on other sites More sharing options...
sutty Posted June 27 Author Share Posted June 27 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 Quote Link to comment Share on other sites More sharing options...
MoMo Posted June 27 Share Posted June 27 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.