Beijer Electronics (formerly QSI Corporation)

Manufacturer of Mobile Data and Human Machine Interface Terminals.
It is currently Thu Nov 23, 2017 11:29 am

All times are UTC - 7 hours




Post new topic Reply to topic  [ 33 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
PostPosted: Mon Nov 28, 2011 10:49 am 
Offline

Joined: Thu Aug 09, 2007 4:44 pm
Posts: 67
btw... this is the only formula I am using that requires these imaginary numbers or fractional powers. If we can figure out how to handle the cubed root I will be able to complete this project.


Top
 Profile  
 
PostPosted: Mon Nov 28, 2011 10:53 am 
Offline
QSI Support
QSI Support
User avatar

Joined: Wed Mar 08, 2006 12:25 pm
Posts: 881
Location: Salt Lake City, Utah
Well, it seems like the complex conjugate roots were only of interest when solving equations, not when calculating a raw cube root.

Much more interesting is that the result you are getting is exactly half what Mathematica is presenting (to within the expected levels of floating point precision that you have available). I would be inclined to think that you are somehow dropping a multiplication factor of two somewhere (possibly in one of the inputs).

Another thing that I would do is run the app in the debugger and look at the intermediate values and run your equation through Mathematica as a bunch of intermediate calculations and compare them.

_________________
Jeremy
http://www.beijerinc.com


Top
 Profile  
 
PostPosted: Mon Nov 28, 2011 11:26 am 
Offline

Joined: Thu Aug 09, 2007 4:44 pm
Posts: 67
Jeremy,

I have been running the intermediate calculations through mathematica and getting identical results as what I get in Qlarity for the most part, except for when there's an imaginary number present.

It is interesting that the real part of the complex number is exactly half of the result I got... but I don't think I left anything out.

In Mathematica, p2+p4= (-3373920000 + 9120000*Sqrt[321])^(1/3)
...which is essentially the same value I get with my Qlarity code.
Simplified by Mathematica the result is 737.613 + 1277.58 i

if I reverse the signs in order to make this the cube root of a positive number like this :
(+3373920000 - 9120000*Sqrt[321])^(1/3)

Mathematica gives me 1475.23.

Thoughts?


Top
 Profile  
 
PostPosted: Mon Nov 28, 2011 1:59 pm 
Offline

Joined: Thu Aug 09, 2007 4:44 pm
Posts: 67
Perhaps this explains it... from here:
http://en.wikipedia.org/wiki/Cube_root

square root of three * 737.613 = 1277.58


Attachments:
cubed roots.png
cubed roots.png [ 1.33 KiB | Viewed 2684 times ]
Top
 Profile  
 
PostPosted: Mon Nov 28, 2011 2:09 pm 
Offline
QSI Support
QSI Support
User avatar

Joined: Wed Mar 08, 2006 12:25 pm
Posts: 881
Location: Salt Lake City, Utah
I'm afraid I don't know. This is definitely getting beyond my math skillset

_________________
Jeremy
http://www.beijerinc.com


Top
 Profile  
 
PostPosted: Mon Nov 28, 2011 2:37 pm 
Offline

Joined: Thu Aug 09, 2007 4:44 pm
Posts: 67
Jeremy,

This seems to be what mathematica is doing to create the complex cubed root, which follows what was explained at wikipedia.

You take (-1/2)*the real number cube root (-1475.23 in my case, *-1/2 = 737.613) and add the same number multiplied by the square root of 3. This equals 737.613 + 1277.58... which is what I get in mathematica, but without the "i" imaginary number.

So I can handle the cubed roots as follows, but I still don't know what to do with the "i" imaginary number which should follow the 1277.58:

Code:
p1=(1/(6*power(2,(1.0/3.0))*dur))*(1-SQRT(3))
p2=(-2*power(dist,3))-(6*MA*power(dist,2))-(6*dist*power(MA,2))-(2*power(MA,3))+(6*power(dist,2)*MD)+(12*dist*MA*MD)+(6*power(MA,2)*MD)-(6*dist*power(MD,2))-(6*MA*power(MD,2))+(2*power(MD,3))+(18*dist*MA*dur*initspeed)+(18*power(MA,2)*dur*initspeed)-(18*MA*MD*dur*initspeed)-(27*MA*power(dur,2)*power(initspeed,2))
p3=(4*power(((6*MA*dur*initspeed)-power(dist+MA-MD,2)),3))
p4=SQRT((p3+power(p2,2)))

tmp=(p2+p4)
if tmp < 0 then
    p5 = power(-tmp, 1.0/3.0)
    p5a= p5/2
    p5b= ((p5/2)*SQRT(3))
    p6 = p5/2+((p5/2)*SQRT(3))
else
    p6 = power(tmp, 1.0/3.0)
endif

p7=(dist+MA-MD)/(3*dur)
p8=(SQRT(3)+1)*((6*MA*dur*initspeed)-power(dist+MA-MD,2))
p9=(3*power(2,(2.0/3.0))*dur)*p6
p10=(p7-p8)/p9
p11=(p1*p6)+p10


Top
 Profile  
 
PostPosted: Mon Nov 28, 2011 2:48 pm 
Offline
QSI Support
QSI Support
User avatar

Joined: Wed Mar 08, 2006 12:25 pm
Posts: 881
Location: Salt Lake City, Utah
Unfortunately I don't either. Why exactly are you performing this complex calculation? Presumably you are looking to boil all this down to a single number, is the real portion sufficient? Is there no one who is familiar with the problem domain that you can ask about imaginary roots and such?

_________________
Jeremy
http://www.beijerinc.com


Top
 Profile  
 
PostPosted: Mon Nov 28, 2011 3:01 pm 
Offline

Joined: Thu Aug 09, 2007 4:44 pm
Posts: 67
The calculation will result in a number which equals the speed command that will be sent to a galil controller, in order to complete a move in the exact amount of time specified (the 't' variable) in the equation. The formula is vastly simpler (and contains no imaginary numbers) when the initial speed of the motor is 0, but sometimes a motor is already moving when a command is given and I must be able to handle that situation.

I am not sure who else I can ask... at this point the problem seems to be how to write up the formula in a lanquage(Qlarity) that doesn't handle imaginary numbers. I think I have to figure out how at what point in the Qlarity code the imaginary number generated by the cubed root is cancel out by the imaginary number contained in the original formula, the two multiplied together equaling -1.

The result should always be a real number in the end.


Top
 Profile  
 
PostPosted: Mon Nov 28, 2011 3:28 pm 
Offline
QSI Support
QSI Support
User avatar

Joined: Wed Mar 08, 2006 12:25 pm
Posts: 881
Location: Salt Lake City, Utah
I guess my point is that I have never worked in a programming language that had much intrinsic support for imaginary numbers (nor, frankly have I needed them in any of the HMI work I have done over the years). I am not a motion control expert, nor do we have any on staff here.

From my (very obsolete now) recollection of Galil basic, their on-board programming language had all sorts of stuff to deal with those kinds of calculations in a very straightforward manner. I do know that we have had people using the Gailil with Qlarity for nearly a decade now and I don't recall anyone ever doing this level of intense calculation on the HMI. While your contacts at Galil may not have any knowledge of Qlarity, they may be able to help you with a straightforward command to tell the controller to complete the move in a specific time frame.

_________________
Jeremy
http://www.beijerinc.com


Top
 Profile  
 
PostPosted: Mon Nov 28, 2011 4:12 pm 
Offline

Joined: Thu Aug 09, 2007 4:44 pm
Posts: 67
Yes, the Galil controllers do take a number of simple commands to create motion, but there is no provision for creating a move in a specified amount of time. The user generally enters the speed, distance, accel & decel rates and the Galil controller executes this move. If you want to know how long this move will take you will have to do the math yourself using some combination of the Kinematic equations. I need to be able to comand a move in a specified length of time, so I must work out the exact speed command to send to the controller in advance, as calculated from user input of the distance, time, accel counts and decel counts variables. I've communicated quite a bit with galil to come up with the correct formulas for doing this. Perhaps they have an engineer with knowledge enough of imaginary numbers to help with this.


Top
 Profile  
 
PostPosted: Mon Nov 28, 2011 4:22 pm 
Offline

Joined: Thu Aug 09, 2007 4:44 pm
Posts: 67
Initially you seemed to think that there was a simple method for dealing with imaginary numbers, involving breaking the imaginary number in to two parts... is this no longer the case? I just never understood what to do with the two parts and then we got lost on this cubed root problem...


Top
 Profile  
 
PostPosted: Mon Nov 28, 2011 4:31 pm 
Offline
QSI Support
QSI Support
User avatar

Joined: Wed Mar 08, 2006 12:25 pm
Posts: 881
Location: Salt Lake City, Utah
My original understanding was that the imaginary numbers would eventually cancel out. (This may have been a misunderstanding on my part from the way the earlier posts were worded). My simple technique was simply to introduce additional variables to hold the imaginary portions until such time as they would cancel out. I don't have some sort of additional trick up my sleeve that I am withholding.

As it seems to turn out, they don't eventually cancel out. A good question for Galil would be: What do I do with the imaginary stuff? Or perhaps more basic "What do I do if I end up taking the square root of a negative number?" Those may be things that they can immediately recognize as problems or they may have techniques to work with them.

_________________
Jeremy
http://www.beijerinc.com


Top
 Profile  
 
PostPosted: Mon Nov 28, 2011 4:39 pm 
Offline

Joined: Thu Aug 09, 2007 4:44 pm
Posts: 67
I wish you had a few more tricks! I am still under the impression that the imaginary numbers will cancel out, because I know that the end result is always a real number. Does this not mean they will cancel out?


Top
 Profile  
 
PostPosted: Mon Nov 28, 2011 4:41 pm 
Offline
QSI Support
QSI Support
User avatar

Joined: Wed Mar 08, 2006 12:25 pm
Posts: 881
Location: Salt Lake City, Utah
I don't know. You told me that Mathematica was returning a complex result (x + yi). Therefore, I assumed that they didn't cancel out.

I can certainly be of help where programming Qlarity comes to play. I am not going to be a lot of assistance when it comes to pure mathematics or motion control though.

_________________
Jeremy
http://www.beijerinc.com


Top
 Profile  
 
PostPosted: Mon Nov 28, 2011 4:55 pm 
Offline

Joined: Thu Aug 09, 2007 4:44 pm
Posts: 67
Sorry... I must not have been clear. I was simply refering to the result of the cubed root being a complex number, not the result of the whole equation. By my count there are 4 "i" imaginary numbers in the equation that must cancel out. Two are present in the original equation in these portions:
(1 - i Sqrt[3])
(i Sqrt[3]+1)

and two are produced by the complex numbers that are results of the two cube root functions:

both are ( 737.613 + 1277.58 i) using the current sample values.

The final result of the whole equation is a real number: 59.6704 ...using the current sample values.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 33 posts ]  Go to page Previous  1, 2, 3  Next

All times are UTC - 7 hours


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:  
cron
Powered by phpBB® Forum Software © phpBB Group