Lynxmotion Tech Support

www.lynxmotion.com
It is currently Tue May 21, 2013 3:09 am

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Fri Oct 15, 2010 1:19 pm 
Offline
Roboteer

Joined: Tue Feb 05, 2008 6:33 pm
Posts: 129
Hello,

So I have a 2dof servo arm that has a pen and a want to create a program that will allow it to draw a circle. I know how to do the inverse kinetics to get the servo values needed in excel but i would like my Atom basic 28 to do them. However, then consulting my atom manual it only has sin and cos, but i need arc cosine. Does the basic atom have a substitute function or can this micro controller do inverse kinetics?
thnx


Top
 Profile  
 
PostPosted: Fri Oct 15, 2010 1:39 pm 
Offline
Robot Guru
User avatar

Joined: Fri May 25, 2007 8:21 pm
Posts: 3868
Location: Central Coast, CA, USA
Check the Phoenix 21 build (probably others) for a "ArcCosinus Table" (acos) and the related function.

Alan KM6VV

_________________
Visit:
http://groups.yahoo.com/group/SherlineCNC/
http://tech.groups.yahoo.com/group/HexapodRobotIK/


Top
 Profile  
 
PostPosted: Sat Oct 16, 2010 11:30 pm 
Offline
Roboteer

Joined: Tue Feb 05, 2008 6:33 pm
Posts: 129
Well, after doing some research on "tables" and looking at the phoenix code i created this code that spits out the table so i could graph it in excel to see how actuate it is.
i graphed a perfect acos and then what the table will give. it looks close enough but i will try to get the shape a little better.
After reading some of the comments in the phoenix code i don't understand the math behind getting more accuracy:(

Code:
acos var word
counter var word
counter = 0
GetACos bytetable   255,254,252,251,250,249,247,246,245,243,242,241,240,238,237,236,234,233,232,231,229,228,227,225, |
               224,223,221,220,219,217,216,215,214,212,211,210,208,207,206,204,203,201,200,199,197,196,195,193, |
               192,190,189,188,186,185,183,182,181,179,178,176,175,173,172,170,169,167,166,164,163,161,160,158, |
               157,155,154,152,150,149,147,146,144,142,141,139,137,135,134,132,130,128,127,125,123,121,119,117, |
               115,113,111,109,107,105,103,101,98,96,94,92,89,87,84,81,79,76,73,73,73,72,72,72,71,71,71,70,70, |
               70,70,69,69,69,68,68,68,67,67,67,66,66,66,65,65,65,64,64,64,63,63,63,62,62,62,61,61,61,60,60,59, |
               59,59,58,58,58,57,57,57,56,56,55,55,55,54,54,53,53,53,52,52,51,51,51,50,50,49,49,48,48,47,47,47, |
               46,46,45,45,44,44,43,43,42,42,41,41,40,40,39,39,38,37,37,36,36,35,34,34,33,33,32,31,31,30,29,28, |
               28,27,26,25,24,23,23,23,23,22,22,22,22,21,21,21,21,20,20,20,19,19,19,19,18,18,18,17,17,17,17,16, |
               16,16,15,15,15,14,14,13,13,13,12,12,11,11,10,10,9,9,8,7,6,6,5,3,0


do       
Acos = GetACos(counter)
counter = counter + 1
serout s_out,i9600,[dec Acos,13]
while counter < 278


Top
 Profile  
 
PostPosted: Sun Oct 17, 2010 9:26 am 
Offline
Robot Guru
User avatar

Joined: Sat Apr 15, 2006 1:42 pm
Posts: 4414
Hi Bane,

From your post on Robot Forum, it looks like you simply output the values from this table and compared it to what excel shows for arccos, which is probably not correct. I know that Xan spent a reasonable amount of time on the code to make it accurate. That is why I believe that the code actually uses this byttable in three parts. I think your graph might look better if you did something like:

Code:
;GetSinCos / ArcCos
c1DEC      con 10
c2DEC      con 100
c4DEC      con 10000
AngleDeg1       var sword ;!!!sword      ;Input Angle in degrees, decimals = 1
ABSAngleDeg1    var word      ;Absolute value of the Angle in Degrees, decimals = 1
sin4            var sword ;!!!sword      ;Output Sinus of the given Angle, decimals = 4
cos4         var sword ;!!!sword      ;Output Cosinus of the given Angle, decimals = 4
AngleRad4      var sword ;!!!sword      ;Output Angle in radials, decimals = 4
NegativeValue   var bit         ;If the the value is Negative

; Local test stuff...
cos4t         var   sword
ar4t         var   sword


GetACos bytetable   255,254,252,251,250,249,247,246,245,243,242,241,240,238,237,236,234,233,232,231,229,228,227,225, |
               224,223,221,220,219,217,216,215,214,212,211,210,208,207,206,204,203,201,200,199,197,196,195,193, |
               192,190,189,188,186,185,183,182,181,179,178,176,175,173,172,170,169,167,166,164,163,161,160,158, |
               157,155,154,152,150,149,147,146,144,142,141,139,137,135,134,132,130,128,127,125,123,121,119,117, |
               115,113,111,109,107,105,103,101,98,96,94,92,89,87,84,81,79,76,73,73,73,72,72,72,71,71,71,70,70, |
               70,70,69,69,69,68,68,68,67,67,67,66,66,66,65,65,65,64,64,64,63,63,63,62,62,62,61,61,61,60,60,59, |
               59,59,58,58,58,57,57,57,56,56,55,55,55,54,54,53,53,53,52,52,51,51,51,50,50,49,49,48,48,47,47,47, |
               46,46,45,45,44,44,43,43,42,42,41,41,40,40,39,39,38,37,37,36,36,35,34,34,33,33,32,31,31,30,29,28, |
               28,27,26,25,24,23,23,23,23,22,22,22,22,21,21,21,21,20,20,20,19,19,19,19,18,18,18,17,17,17,17,16, |
               16,16,15,15,15,14,14,13,13,13,12,12,11,11,10,10,9,9,8,7,6,6,5,3,0


for cos4t = 0 to 9999 step 20
   gosub GetArcCos[cos4t], ar4t
   serout s_out, i9600, ["Arccos .",dec4 cos4t, " =", dec ar4t, 13]
next
stop

;--------------------------------------------------------------------
;[GETARCCOS] Get the sinus and cosinus from the angle +/- multiple circles
;Cos4       - Input Cosinus
;AngleRad4    - Output Angle in AngleRad4
GetArcCos[Cos4]
  ;Check for negative value
  IF (Cos4<0) THEN
    Cos4 = -Cos4
    NegativeValue = 1
  ELSE
    NegativeValue = 0
  ENDIF

  ;Limit Cos4 to his maximal value
  Cos4 = (Cos4 max c4DEC)
 
  IF (Cos4>=0 AND Cos4<9000) THEN
    AngleRad4 = GetACos(Cos4/79) ;79=table resolution (1/127)
    AngleRad4 = AngleRad4*616/c1DEC ;616=acos resolution (pi/2/255)
   
  ELSEIF (Cos4>=9000 AND Cos4<9900)
    AngleRad4 = GetACos((Cos4-9000)/8+114) ;8=table resolution (0.1/127), 114 start address 2nd bytetable range
    AngleRad4 = AngleRad4*616/c1DEC ;616=acos resolution (pi/2/255)
   
  ELSEIF (Cos4>=9900 AND Cos4<=10000)
    AngleRad4 = GetACos((Cos4-9900)/2+227) ;2=table resolution (0.01/64), 227 start address 3rd bytetable range
    AngleRad4 = AngleRad4*616/c1DEC ;616=acos resolution (pi/2/255)
  ENDIF 
       
  ;Add negative sign
  IF NegativeValue THEN
    AngleRad4 = 31416 - AngleRad4
  ENDIF

return AngleRad4

Note: I did not run this, but the idea is the code should generate about 500 values where each of the values passed on different by: .0020 or in the code by 20 as we are using fixed point here with 4 decimal places.

Kurt


Top
 Profile  
 
PostPosted: Sun Oct 17, 2010 1:42 pm 
Offline
Roboteer

Joined: Tue Feb 05, 2008 6:33 pm
Posts: 129
thanks kurt, i think i'm getting it now.
The code you posted works perfect and should suffice as far as accuracy. Now i have to figure out how to convert my excel math in to Basic for servo output. I posted a pic of the test 2dof robot arm just if you wanted to see what i'm working with and the excel sheet that can compute the circle and inverse kinematics.

also, for some stupid reason i can't seem to factor in the linkage origin in excel. From the equation i used it defaults to 0,0. any ideas?
bane


Attachments:
circle algorithm 2.1 center 0,0.xls [50.5 KiB]
Downloaded 72 times
1017101412 - Copy.jpg
1017101412 - Copy.jpg [ 20.44 KiB | Viewed 883 times ]
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group