Sine and Cosine

To overcome the speed - and integer-limitations of the RCX in computing the sine and cosine we propose a new approximation. It is based on Euler's series:

The function has been implemented into Robolab with some additional features -like text oriented variable management- which you can download HERE. How to use the sub.vis is explained at the Robo-Soccer pages 1-ONE and 2-TWO.

Note that the sine and cosine are returned in %.

For those not too familiar with Robolab, here the LASM code for computing sin(74), the result being stored in variable 0. A_rad is variable 5, h1 var 6 and h2 is var 7:

delt 0

task 0
set 0,5,2,74  <---ANGLE
mulv 5,2,281
divv 5,2,161
set 0,6,0,5
divv 6,2,5
set 0,7,0,5
mulv 7,0,5
divv 7,2,-25
mulv 6,0,7
divv 6,2,-480
sumv 7,2,10000
divv 7,2,32
mulv 6,0,7
divv 6,2,-313
sumv 6,0,5
chkl 2,100,1,0,6,Label1002
set 0,6,2,100
jmpl Label1003
Label1002:
Label1003:
set 0,0,0,6
endt

Tests show that one computation needs about 50ms, which is much quicker than our previous Sinus approximation.


The following test-program demonstrates the quality of the function:

  

 

with an important LABVIEW global variable , with reset-containers and for-loop.

DOWNLOAD all the files

  1. Conv_dec_to_quotient.vi
  2. COSINE.vi
  3. FOR_LOOP.vi
  4. FOR_NEXT.vi
  5. Read_variables.vi
  6. RESET_CONTAINERS.vi
  7. S_RCX C-Container.vi
  8. S_RCX Generic Container.vi
  9. S_Value of C-Container.vi
  10. S_Value of Generic Container.vi
  11. SINE.vi
  12. Test_sinus2.vi
  13. Variable.gbl.vi

RetourMain Page