Pete B wrote:
Hope this helps!
Attachments: WISHBONE.zip [25.03 KiB]
Downloaded 20 times
I have a zip file with the same name but my file has QBasic.exe included to compile it etc. The wishbone.bas file is a little over 30 Kb long.
The following is the "wishbone.txt" that is part of the .zip file. It explains what he was doing in the program.
Please note that this program has a copyright, 'LINKAGE ANALYSIS ...WISHBONE.......................(C)1996:M J McDERMOTT which was extended to 2000 in another the .bas file.
_________________________________________________________________________________
PROCEDURES IN THE PROGRAM
SusDefine - to input the data
THis procedure was inspired by the data input section of the program TORUS.BAS included in Microsoft QuickBasic 4.0. It uses the procedure Modify.
Modify( Lower, Upper, Variable, Increment)
Changes a variable by an increment within a range between an upper and a lower limit, on a keystroke. If the key is PageUp the increment is positive; for PageDown, it's negative. Pressing Control at the same time cuts the increment by a factor of ten. The key designations are in lines 60-74 of SusDefine
PQ - to locate a point in space
The most frequent requirement in calculating suspension movements in three dimensions is to find the position in space of the meeting point of three links of known length whose other ends are fixed and known. This point is where the three spheres intersect which are centred on the three known points and which have their radii equal to the three known link lengths. In the diagram the three fixed points are A,B and C. Their radii are L,M and N. Since the unknown point P lies on each of the three spheres we have three equations:
( xa - xp )2+( ya -yp )2+( za - zp )2=L2 ..............................................(1)
( xb - xp )2+( yb -yp )2+( zb - zp )2=M2 ..............................................(2)
( xc - xp )2+( yc -yp )2+( zc - zp )2=N2 ..............................................(3)
these are each multiplied out to give the following:
xp2 + yp2 + zp2 - 2xaxp - 2yayp - 2zazp = L2 - xa2 - ya2 - za2 .............(4)
xp2 + yp2 + zp2 - 2xbxp - 2ybyp - 2zbzp = M2 - xb2 - yb2 - zc2 ............(5)
xp2 + yp2 + zp2 - 2xcxp - 2ycyp - 2zczp = N2 - xc2 - yc2 - zc2 .............(6)
By subtracting (5) from (4), then (6) from (5), then (4) from (6), we get three new equations (7), (8) and (9) in the three unknowns xp, yp and zp, the co-ordinates of P.
2 (xa - xb ) xp + 2 (ya - yb ) yp + 2 (za - zb ) zp = (M2 - L2 ) - ( B2 - A2 ) = MLBA...(7)
2 (xb - xc ) xp + 2 (yb - yc ) yp + 2 (zb - zc ) zp = (N2 - M2 ) - ( C2 - B2 ) = NMCB...(8)
2 (xc - xa ) xp + 2 (yc - ya ) yp + 2 (zc - za ) zp = (L2 - N2 ) - ( A2 - C2 ) = LNAC...(9)
where A2 = xa 2 + y a2 + z a2 etc. The procedure PQ does this in section AA. Rather than ( xa - xb ) etc it uses a matrix notation T ( 1, 2 ) etc, which is better suited to numerical calculations.
At this point someone usually suggests that this is a suitable case for a quick solution by a matrix method, and reaches for the matrix inversion and multiplication functions included in most spreadsheets. Unfortunately this doesn't work because we have over-simplified the problem by throwing away the squared terms in (4), (5) and (6) when obtaining (7), (8) and (9). We have to go first through the process of expressing xp and yp in terms of zp. To do this we multiply (7) by (xb - xc ) to give (10), (8) by (xa - xb ) to produce (11), and then subtract (10) from (11). PQ does this in section CC.
This gives :
2((ya - yb)(xb - xc ) - (yb - yc)(xa - xb )) yp =
(MLBA(xb - xc) -NMCB(xb - xc)) - 2((za - zb)(xb - xc ) - (za - zb)(xb - xc )) zp
There is a similar equation for xp in terms of zp. These two expressions are then used to rewrite equation (1) in zp only. This is rather a long collection of terms in zp2 and zp. Anyone deeply interested is recommended to follow the detail in the program listing. The main point, though, is that this is a standard form of a quadratic equation, so that the standard school mathematics rule can be used to find the "roots" or answers. If the quadratic equation is written as
azp2 + bzp + c = 0
then the solutions are zp = -b +/- (square root of (b2 - 4ac))
2a
Once having found zp, it is straightforward to find yp and xp by using the two relationships derived earlier.
If you have been following the arguments you will have noticed that like all quadratic equations this one has two solutions. Mathematically, each is equally valid but in engineering terms only one makes sense. The two solutions are (a) the correct one, and (b) the wrong one, which is the mirror image of the correct one, in which the plane of the mirror is formed by the three fixed points A, B and C. To avoid seriously wrong results the program has to include a way of choosing the correct one. The simplest way is to tell the program the original co-ordinates of the point P. The correct new position usually isn't very far away from the original. You have already entered this information anyway because it was needed to calculate the lengths of the suspension links. The correct solution is the one closer in space to the original. PQ does this in section DD.
There is, unfortunately, another situation for the program to cope with, which is that computers don't like dividing by zero. This is because the result would be infinity, the machine can't handle it, and the program will crash. If one or more of the fixed points A, B or C have the same x or y or z co-ordinates, and this is not uncommon since wishbone pickups are often parallel to the axis of the chassis, then one or more of the terms such as (zb - za) will be zero and would cause the dreaded 'division by zero'. In section BB the procedure searches for these zeros and rearranges the order of the equations to avoid creating them when forming equations (7), (8) and (9). There always has to be a suitable order because in the real world of real suspension layouts the points A, B, and C can't all be in exactly the same places or the suspension woudn't locate the wheel properly.
The procedure is 'called' many times in the program by the command PQ (A, B, C, D, E, F, G, H). In these calls A, B and C are the point numbers of the three fixed points; D,E and F are the numbers of the three fixed links; G is the point number of the unknown point before it is moved, and H the new number after movement.
Procedure QWB
This is used to find the line of intersection the planes which pass through the three fixed points of each of a pair of wishbones. It uses the fact that the equation of a plane can be expressed as:
(x - xa) { (yb - ya) (zc - za) - (yc - ya) (zb - za)}
-(y - ya) { (xb - xa) (zc - za) - (xc - xa) (zb - za)}
+(x - xa) { (xb - xa) (yc - ya) - (xc - xa) (yb - ya)} = 0
where xa , ya and za are the co-ordinates of the fixed point A etc, all of which are known.
There is a corresponding equation for the other wishbone of a pair. The task of this procedure is to find the IC and the squat centre. Since there are the two wishbone equations there is enough information to solve the problem of finding the line of intersection of the two planes which is, of course, the instantaneous axis of rotation of the suspension. By definition x = 0 for the IC since it lies in the vertical transverse plane through the 'axle'. Similarly, from the definition of the squat centre we specify z = half the
track. The IC and the squat centre are then located by separately solving the two equations simultaneously, with x and z specified appropriately. The procedure is called by the command UPL ( A,B,C,D,E,F,M,N). A, B and C are the point numbers of one of the wishbones; D, E and F the point numbers of the other wishbone. M is the point number you want to give to the IC, N the one you want to give to the squat centre. This procedure looks for wishbones which are parallel in side view, corresponding to zero anti-dive or squat, which would lead to a division by zero and a crashed program. When this is detected the correct result of zero squat height is given but it outputs a default horizontal squat centre position of 999.999, which could be rounded to 1000, rather than the correct value of infinity.
Procedure UPL
This finds the plane through the three fixed points of the upright, using the same geometry as procedure QWB. It then constructs a 'stub axle' which is fixed to the upright with its inner end at the fore-and -aft position x = 0 and at a height y = half the tyre diameter. It is given a length of 6 units and the position of its outer end is then determined by the static camber and toe-in angles you have fed in via your data file. It is invoked by the command UPL ( A, B, C, M, N) in which A, B and C are the point numbers of the upright fixings (the upper and lower BJs and the TRE). M and N are the point numbers you want to give to the inner and outer ends of the stub axle.
Procedure AX
This is a complement to UPL. After the suspension has been deflected, AX is called to find the new position of the stub axle. It then calculates the new camber and toe-in angles using measurements calculated in UPL, repeatedly using the ubiquitous procedure PQ. It is called by AX (A, B, C, M, N, MM, NN, CAM, TOE) where A, B, C, M, N are the same as in UPL, MM and NN are the point numbers of the new positions of the stub axle, and CAM and TOE are the new values of these angles.
Function L (A,B)
Computes the SQUARE of the distance between two points numbered A and B.
Function R (A)
Computes the SQUARE of the distance of the point numbered A from the origin.
_______________________ End of file (finally)
_____________________________________________