91
Theory and applications of spline functions for a servo- mechanism Citation for published version (APA): Rosemont, de, H. (1985). Theory and applications of spline functions for a servo-mechanism. (TH Eindhoven. Afd. Werktuigbouwkunde, Vakgroep Produktietechnologie : WPB; Vol. WPB0200). Technische Hogeschool Eindhoven. Document status and date: Published: 01/01/1985 Document Version: Publisher’s PDF, also known as Version of Record (includes final page, issue and volume numbers) Please check the document version of this publication: • A submitted manuscript is the version of the article upon submission and before peer-review. There can be important differences between the submitted version and the official published version of record. People interested in the research are advised to contact the author for the final version of the publication, or visit the DOI to the publisher's website. • The final author version and the galley proof are versions of the publication after peer review. • The final published version features the final layout of the paper including the volume, issue and page numbers. Link to publication General rights Copyright and moral rights for the publications made accessible in the public portal are retained by the authors and/or other copyright owners and it is a condition of accessing publications that users recognise and abide by the legal requirements associated with these rights. • Users may download and print one copy of any publication from the public portal for the purpose of private study or research. • You may not further distribute the material or use it for any profit-making activity or commercial gain • You may freely distribute the URL identifying the publication in the public portal. If the publication is distributed under the terms of Article 25fa of the Dutch Copyright Act, indicated by the “Taverne” license above, please follow below link for the End User Agreement: www.tue.nl/taverne Take down policy If you believe that this document breaches copyright please contact us at: [email protected] providing details and we will investigate your claim. Download date: 10. Nov. 2020

Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

Theory and applications of spline functions for a servo-mechanismCitation for published version (APA):Rosemont, de, H. (1985). Theory and applications of spline functions for a servo-mechanism. (TH Eindhoven.Afd. Werktuigbouwkunde, Vakgroep Produktietechnologie : WPB; Vol. WPB0200). Technische HogeschoolEindhoven.

Document status and date:Published: 01/01/1985

Document Version:Publisher’s PDF, also known as Version of Record (includes final page, issue and volume numbers)

Please check the document version of this publication:

• A submitted manuscript is the version of the article upon submission and before peer-review. There can beimportant differences between the submitted version and the official published version of record. Peopleinterested in the research are advised to contact the author for the final version of the publication, or visit theDOI to the publisher's website.• The final author version and the galley proof are versions of the publication after peer review.• The final published version features the final layout of the paper including the volume, issue and pagenumbers.Link to publication

General rightsCopyright and moral rights for the publications made accessible in the public portal are retained by the authors and/or other copyright ownersand it is a condition of accessing publications that users recognise and abide by the legal requirements associated with these rights.

• Users may download and print one copy of any publication from the public portal for the purpose of private study or research. • You may not further distribute the material or use it for any profit-making activity or commercial gain • You may freely distribute the URL identifying the publication in the public portal.

If the publication is distributed under the terms of Article 25fa of the Dutch Copyright Act, indicated by the “Taverne” license above, pleasefollow below link for the End User Agreement:www.tue.nl/taverne

Take down policyIf you believe that this document breaches copyright please contact us at:[email protected] details and we will investigate your claim.

Download date: 10. Nov. 2020

Page 2: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

- Theory and applications of spline

functions for a serTo-mechanism.

Hu!ues de ROSEMONT: UniTersite d.

1"cbn010«1e de Coapi';p.e.

Februar-July 1985

N. WPB-0200

Page 3: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

Summary

Thanks -------Presentation of the work environment

the Eindhoven University _ _ _ the education at the university the mechanical engineering department

Presentation of the work the FAIR project the particular work itself

Theory of spline functions mathematical theory __ __

-' --~ ___ J

s _C

-, calculations with third degree cubic spline functions application of the calculations for four knots

-~ _10

Simulations of the interpolation on the PRIME how to use interpolation _ _ the basic flowchart of the fortran program the different programs results of the different programs conclusion

--,B -1$

_is'

_1' _it

Development of the programs on introduction to the work

the INTELLEC development system

-~ ___ .1~ presentation of the development system

development on the 8086 version measurements of the running times on

-- --~ the 8086 version ~!

conclusion General conclusion Appendix

summary in French documentation

_.l~ - 4,

1

Page 4: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

2

I Thanks

At the end of this training period, I want to express my greatest thanks to Mr. Heuvelman, my coach, who by his advice, his competence and his kindness has directed me and my investigation. Thanks too APA which provided me an application of my subject and specially to Jan and Rolland who helped me during the simulation step on the INTELLEC system. The first part of this work would have been impossible without the participation of Mr. Banens who introduced me to his fortran program and to the PRIME facilities. There are many people, especially Frits, who I will not forget because they made my stay at the university very pleasant. I also want to thank Lia who accepted to type this report.

Once back to France, one part of my heart will stay Dutch. Not only because of the arts, the landscapes with water and windmills, the people, the flowers or the beers, but because Dutch people know how to combine all of this to make their land a land of warm hospitality.

Page 5: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

II Presentation of the work environment

a) The Eindhoyen University

The Eindhoven university of technology has been founded in 1956. It offers nine courses of study in which students can qualify as graduate engineers specialising in the following subjects;

Technology in its social application Industrial engineering and management science Mathematics Computing science Technical physics Mechanical engineering Electrical engineering Chemical engineering Architecture, structural engineering and urban planning

Since the Eindhoven university of technology opened in 1957 more than 6600 students have graduated from it. The degree of doctor in the Technical sciences can be obtained by students submitting a doctorate thesis on research they have carried out.

b) The education at the university

3

A full university course in Netherlands used to take at least 4 years. But generally university studies can be divided in two phases; The first phase has a duration of four years and compises two examinations: the first or preliminary examination at the end of the first year and the final examination at the end of the fourth year. Students are allowed 2 extra years to complete the first phase. The first examination has to be passed at the end of the second year at the latest. In the second phase will be introduced in 1986/87, covers three typ~of training: - further professional training as physist, pharmacist with a

maximum of two years. - professional training of teachers for secondary schools with a

maximum of 1 year - training for research and technological design, with a maximum

of 1 a 2 years.

c) The mechanical engineering department

Design and production are the two main groups into which the highly varied tasks of mechanical engineers are divided. The nature of the tasks carried out by mechnical engineers varies from scientific research and development to industrial organisation. Apart from their theoritical knowledge mechanical engineers must possess specific practical skills. To this end, the curriculum includes amoung other

Page 6: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

things, participation in the work done by the department in its four divisions:

fundamentals of mechnical engineering product design and development design for industrial processing production engineering and automation In this department there are about two hundred employees (teachers, technical personel) and seven hundred students. I have worked during five months among them.

4

Page 7: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

III Presentation of the work

a) The FAIR project (Flexible Automation and Industrial Robots)

The research project FAIR is financed and directed by the Dutch government. The aim is to develop, for most applications of flexible automation/an industrial robot system. The mechanical and electrical engineering departments of the university as well as several companies, are involved in this project. In a very general view the university applies its theoretical experience and the companies their practical experience. Both are linked by a contract. For organisational reasons the project is subdivided into five small parts: 1. the general aspects of automation 2. the handling of parts 3. kinematics and dynamics of mechanical structures 4. the drive systems, the control systems and the applications of the

systems 5. the arc-welding and the sensory systems. My project has been done in the project group 4.

b) The practical work itself

5

I worked with the firm APA (Advanced Product Automation) which is developing a new welding-robot, in view of flexible automation, with the help of the university. So my practical work took place at the university but was directly connected to an industrial project. The developed welding-robot has several motors to move a torch from one point to another. Each motor has its own feedback control loop which, to reach a desired accuracy, needs a pilot value every 5 m.s. Knowing the position value in the space of the next point, the job of the main computer is to calculate the motion of each motors. These calculations are very complicated and require a long time to be done. Consequently, this computer is too busy to send information every 5 m.s to each motor. We resolved the problem by using slave computers. Thelreceive from the main computer a piece of information (for example every 100 m.s) and calculate by an interpolating method, the intermediate points every Sm.s. If we know two points the interpolation is linear and if more than three points are known we can use a polynomial method. Each motor is piloted by a slave computer and possesses its own interpolator.

'90.-.51 SLAVE

MAl N (Ot1tUTt"

COMPUTER

!,LAVE to ... PVTE."

Page 8: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

6

Because the interpolation must be accurate we must find a good method and so the first part of the project will be a simulation of different kinds of interpolations. This first part is purely theoritical. The linear functions and polynomial functions are well known and, consequently, only spline functions are described. The second part of this project will concern the real time simulation, the running time measurements and the implementation with hard-ware.

Page 9: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

IV) Theorie of spline functions

a) Mathematical theory

The theory comes from the books: -Data fitting by spline functions· T.N.E.

Properties

Greville, NRC Technical report No. 893 -Theory and applications of spline functions· TNE Greville, Academic Press.

7

A spline function sen) of degree m with knots n1' n2 ... nn is defined having the following properties:

Cal. in each interval (ni' ni+1) for i = 1, ... n the spline function is given by some polynamial of degree m or less.

(b). Sen) and each derivatives of order 1, 2, .. m-1 are continuous. SCn)t Sm (n1' n2 ... nn) has a unique representation of the form

n sen) = om (n) + r CJ. (n - nJ.)m

j=1

with om t wm and wm denotes the class of polynamials of degree m or less.

proof For j = 0,1 ... n let 0mj(n) be the polynomial that gives the value of Sen) in the interval (nj' nj+1)' It follows of conditions (a) and (b) that Omj(n)-Pmj-1(n) is a polynamial of degree m having m fold-zero at n = nj

that is: 0mj(n)-Pmj-1(n) = Cj(n-nj)m

thus Pml(n) = Omo{n) + (Pm1(n)-Pmo(n»+(Pm2(n)-Pm1(n»+(Pm3(n)-Pm2(n»

+ ... + COml{n)-Oml-1(n»

_ 1 m Oml(n) - Omo(n) + j;1 Cj(n-nj}

(1)

We must show that this representation is unique or in other words, that for a given Sen) the polynamial Omen} and the Cj are uniquely determined. for n < n1: Sen) = Omo(n) therefore Omen) = Omo{n)

Further m fold differentiation of (1) gives:

C· xm J

taking n = nJ·, this may be written as C· - ~ (s(m)(n' )-s(m)(n· » ) - m! J+o )-0

The natural spline interpolation

Page 10: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

8

A spline function of odd degree 2k-1 with knots n1' n2 ... o. is called a natural spline function if the two polynomials by which it is represented in the two intervals (- -,n1) and (nn' + -) are of degree k-1, or less. Let (ni' ji) i= 1 .. n) be given data points, with the abscissas ni in strictly increasing sequence and containing a finite interval (a, b). A function fen) of class ck fits the n data points with the conditions:

f (n·) = J. 1 1 i = 1 ... n (2 )

this is the smoothest function (smoothest being interpeted to mean

that the integral

possible)

b a = I (fk(n)2 db shall be made as small as

a

For k>n: the problem doesn't have a unique solution, as there is an infinity of polynamials of degree k-1 satisfying (2) for all of which a = O. For k = n: unique solution given by the lagrange interpolation polynomial For k < n: there is a unique function fen) for which the minimum is attained. This function turns out to be a spline function of degree 2k-1 having the abscissas n1' n2 ... nn as knots.

So a smoothest spline function can be written like:

Sen) (3 )

for n<n1' Sen) is automatically a function of degree k-1

for n>nn: Sen) = Qk-1(n) + '~1 cj(n-nj)2k-1 reduces to a polynomial of

degree k-1 if and only if tfie coefficient of every power of n higher than k-1 vanishes.

So for r = 0,1 ... , k-1 the coefficients of n2k- 1- r is (_1)r(r2k- 1) ¥ C·n~ j=1 J J

n r and we must have r C·n· = 0 j=1 J J

(4)

Thus an expression of the form (3) is a natural spline function of degree 2k-1 with the knots n1' n2 ... nn if and only if conditions (4) are satisfied.

Theorem: : let (~i,Ji)' i = 1 "n be given data points where the ni form a strictly lncreaslng sequence and let k be a positive integer not exceeding n. There is a unique natural spline function sen) of degree 2k-1 with the knots ni such that:

(5)

Page 11: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

b) Calculation with third degree spline function

If the coordinates of n data points are given, the smoothest interpolating function is a natural spline function 5(n) of degree 2x-1 (x<n). The parameters can be obtained by solving the system of equations consisting of condition (4) and {5} with S(ni) given by (3). Third degree spline functions (k = 2, 2k-1 = 3) are the Rost useful and interesting one.

9

A third degree natural spline function Sen) is given by a three degree polynomial in each interval (ni' nit') i=1 ... n-1 and by a linear function in each interval (ni' ni+1) and vanishes in (- ., n1) and (nn' + .). In a general way:

n-n· 5·{n) = S"{n·) + ~[5"(n) - S"(n·)]

1 ni+1-ni i+1 ~ (6)

with ni i n i ni+1 i = 1, 2, ... n-1

Sen) is easily caldulated if we know S(ni)' 5(ni+1)' 5·(ni) and S"(ni+1)'

S"(ni+1») (7)

Differentiation of (7) with respect to n gives:

NOw, we call 5i(n) the spline function between the knots [ni-1' ni] and Si+1en} the spline function between [ni' ni+1]' From (S) we deduce that:

(8.1): S'i(ni) = S(:t)=S~:~~i) + t (ni-ni_1)[2S"(ni)+5"(ni_1)]

5(ni+1)-5(ni) 1 (8.2): 5'i+1(ni) = n. -no - i (ni+1-ni)[5"(ni+1) + 25"(ni)]

H1 ~-1

To satisfy the condition (b) we must have the equality of (S.1) and (8.2) for each knot ni i= 2,3, ... n-1. So, from (8.1) and (S.2) we can write:

(9) 5(ni}-S(ni_1) 1 H ft

n· - n· 1 + li' (ni-ni-1) [25 {ni' + 5 (ni-1)] 1 1-

Page 12: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

For the knots n1 and nn' we can write the boundary conditions:

(10) S' (n,,) = S(:;>= :~n1) - t (n2 - n1)[2S"(n1) + S"(n2)]

(11) S'(~) ~ S(::)= :~:~-1) + t [nn - nn_1][2S"(nn) + S"(nn-1)]

Generally S'(n1) and S'(nn) are given. We will call them boundary conditions.

The system of equations (9), (10), (11) is a system of n equations with n unknown (S"(n1); S"(n2) ... S"(nn». After solution of this system, we can replace the calculated values of S"(ni) in the equation (7) rewritten:

10

From this equation (7) we can pullout the coefficients of the spline function. If Si+1(n)=~+c1h+ c2n2 + c3n3 with ni i n i ni+1' then Co' C1 and C3 are easily calculated. The reasoning to calculate the coefficients has been made for cubic natural spline functions, but it will be exactly the same if using cubic spline function. It only means, in this last case, that either first or second derivative boundary condition can be chosen and the case is simpler.

c) Application of the calculations for four knots

We suppose that [(n1' S(n1»' (n2' S(n2»' (n3' S(n3»' (n4,S(n4»] is a set of knots and the boundary condition S'(n1) and S'(n4) are known.

The boundary conditions given by ( 10) and (11) are:

S' (n1 ) = S(n2) - S(n1) 1 (n2 - n1) (2S"(n1) + S"(n2»

n2 - n1 - b

S' (n4) = S(n~) - s(nJ)

+ i (n4 - n3)(2S"(n4) + S"(n3» n4 - n3

The continuity conditions given by (9) are:

Page 13: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

In our case ni is the time and ni-ni-1 = An = cste. With this remark, the general system to resolve becomes:

11

S"(n3) t S"(n1) t 4 S"(n2) = ~ [(S(n3) - S(n2» - (s(n2) - s(n1)}] (An)

S"(n4) + S"(n2) t 4 S"(n3) = ~ [(S(n4) - S(n3» - (S(n3) - S(n2»] (6n) .

Let call a =(6:)2 [( sen3) - S(n2» - (S{n2) - S(n1»]

~ ={6!)2 [(S(n4' - S(n3» - (S(n3) - s(n2»]

_ 6 S(n2) - Sen,) 6 - An [ An - S'(n1)]

~ _ 6 I S(n4) - S(n3) ] v - An [5 (n4) - An

AI ' 1 I '() '() = S(n4) - S(n]' and ~ = 0 ways 1n our case, we ca cu ate 5 n4 as 5 n4 An v

in any case.

The results of this system are:

5"(n1) = ~ 6 + ~ p - ~ a

S"(n2) = - ~ p + it a - ~ 6

S"(n3' = - ~ a + ~ 6 + it p

S"(n4) = - ~ p + ~ a - ~ 6

If the spline function between the two first knots (n,. n2) is written:

Co + C1n + c2n2 + c3n3 = 51(n) we obtain the coeffcients values from (7):

Co = S(n1) C1 = [5(n1) - 5(n1)]/6n - ~ [2S"(n1) + 5"(n2)]

Page 14: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

_ S'(n 1) C2 - 2

C3 = ~x~n (S ' (n2) - S'(n1»

12

Page 15: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

13

v Simulation of interpolation on the PRIME

a) How to use the interpolations

In research work, simulation is of great importance because it gives an idea of reaH ty simply by using a computer. In our case, we expecb"d with the aid of a simulating program, to obtain an idea of the accuracy of the interpolation method. We attempted to calculate and visualize the error between a real curve and the interpolated curve. We wanted especially to try spline interpolation and linear interpolation on circles and straight lines.

In a welding application we can not enter all the knot values in the memories of a computer because:

it would take too much memory spaces . of varations in the parts to be welded together.

To get around this disavantage we can imagine that a sensitiv sensor follows the welding path just in front of the torch and detects a new knot every 100ms. The interpolation can be done on n knots (n 1 3) stored in only n memory places. In reality, we calculate the interpolating function between the two first knots ni and ni+1 with the knowledge of n knots (ni' ni+1, ... ni+n-1)' At the moment when the ni+n knot is detected, we can calculate the next interpolating function between the knots ni+1 and n1+2 .... This is a simulation of what will happen in reality. The number of knots n must be determined in order to have the best accuracy possible. Of course, when an interpolating function is calculated, we are able to give the set values every 5 m.s.

tor(h

b) The basic flowchart of the general fortran program

The program calculates cubic spline functions in the more general way. The boundary conditions can be given either by the first derivative, or the second derivative, or both and calculations can be done on n knots. The set values can be given as desired. This basic program was already written and I have just modified it in different ways to find the expected results.

Page 16: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

14

The calculations are carried out as explained in the paragraph ·Calculations with third degree spline functions·. To resolve the general system of n unknowns, n equations, the program uses a gaussian elimination method.

The computer used was a high computer PRIME and the different programs have been written in Fortran. We can say that we have two kinds of programs:

- The first calculates the errors and displays them on the screen - the second calculates the errors and draws the curve (a, £) on the

screen. (£=error, a=angle or time)

The general flowchart is:

Ca\ce.il'a.tions or tnt too .. clin"tt~ of the knots.

Ca.lc..ula.tiOIls, of tkf bounda.rr condition$

Abs1S""~ of thf intermediate points

O .. din~Ju of thf set points in the fi"$t inttW'va.l

Calculations of the Hrors

DtClwinq onto t.trfen

From one program to another what changes is the "calculation of the coordinates of the n knots·, They are not done in the same fashion if we are interpolating a circle or a straight line. The other parts are common to all the programs. To insure the continuity of the first derivative, the boundary condition on the first knot is picked from the preceeding calculations.

Page 17: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

15

c) The different programs

The basic program SP.FIN displays the values of Sen), 5'(n), and £(n) (£=error) to the screen. Each set of knots is given by hand and results are presented as figures. (See appendix A)

In reality, knots are separated by an equal time but the distance between two knots can vary a lot because of the welding speed. To take into account this phenomena one program generating knots with a range of speed has been written. The other programs generate knots with a constant speed.

The trials are done on circles and straight lines, the error is in the later programs, displayed as a curve £=f(n). The calculations of the knots is automatic, we just give the datas: R(radius), OM (angular speed), N (number of knots on which the interpolation must be done).

- SPC.FTN generates knots with a constant speed on a circle, calculates the spline functions and displayes to the screen the maximum error between two knots and the position (coordinates) of this error. (See appendix B)

The different graphic spline programs are: - SPCF.FTN uses a graphic function. The knots are generated on 1/4

circle with a constant speed. The boundaries conditions are given by the first derivatives. (See appendix C)

- SPCF2.FTN and SPCF12.FTN are the same as SPCF.FTN but, within the first case both of the boundary conditions of order 2 and, in the second case, a start boundary condition of order 1 and the arrival of order 2. (See appendix D)

- SPDF1.FTN calculates spline functions on a straight line followed by 1/4 circle with knots generated with a constant speed. The boundary conditions are given by the first derivatives. (See appendix E)

- SPSF.FTN draws 1/4 circle with knots generated with a range of speed. The boundary conditions are given by the first derivatives. (See appendix F)

- SPCFB.FTN gives the errOl on 1/4 circle with the first and last knot spaced out a _/2 angle. (See appendix G)

We have seen in the paragraph -Theory of spline- that the spline functions give the best polynomial curve (smoothest) passing through knots. Consequently it is not necessary to try the well known and classical polynomial functions. Only linear functions have been compared to spline functions: +ILF.FTN is a program interpolating 1/4 circle with linear functions. Rnots are generated with a range of speed. (See appendix H)

Page 18: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

16

The last program will be a program g~vlng the accuracy of a waving movement interpolated by spline functions: SPW.FTN. The waving movement is the movement of the torch following the welding path. (See appendix I)

----~--~--~--~ z

I SPCF

y

z. SPSF

" "" ,

I SfJDF1

-- tl' " - " ~t -," I :~----,

I i \

i

\" SPC.FB 'r~

" \ i l -_ 011:>' \1

-- - - "..1' "-(I -"

y

SPWF

T1 SP~f ; ra.nqe of srced ,

Tl.me

d) Results of the different programs

The parameters, for the graphic spline programs, are given in appendix J. The results are displayed in appendix K. First the theory of natural spline functions is confirmed. The spline functions calculated with first derivative boundary conditions give more accurate results than spline functions calculated with second derivatives or

x (time ~

Page 19: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

mixed first and second derivative boundary conditions. (See SPCF2, SPCF, SPCF12)

17

The error between the spline interpolated curve and two circles of different radius R1 and R2 is directly proportional to the ratio R2/R1 if the boundary conditions and the angle between each knot are the same. (See SPCF)

On a circle interpolated by spline functions, the maximum errors are situated at the entrance and the exit of the set of knots, and the errors are very small between these two sides. (See SPCF and SPSF) Calculations of spline functions with 5 knots don't give better results than calculations done with 4 knots. On the other hand, calculations with 4 knots are much better than calculations with 3 knots. Consequently, the best number of knots to calculate the spline functions is 4. (See SPDF1) After interpolating a circle, we don't arrive tangentially to the straight line. In this case, the error is the biggest at first and decreases after that. (See SPDF1.COMO)

z , ... " "' ........ '" . .

, I , ,.

y

Because spline functions are polynomial functions, a straight line, with good boundary conditions, is interpolated as a straight line.

Page 20: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

Spline functions give results about ten times better than linear functions when the chosen path is a circle. (compare SPSF and ILF)

e) Conclusion

18

After this siaulation step, we have a general idea of how the spline functions work. We have seen that the accuracy of this kind of interpolation is good enough for our applications. The trials have been done essentially on circles because one of the applications of this welding robot is to weld cylinders together.

Page 21: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

19

VI Development of the programs on the INTELLEC development system

a) Introduction to the work

In the first part of the practical work we studied the spline functions but we must keep in mind that the program will be implemented in a real servo­mechanism. The spline interpolator is only one part of the servo mechanism and some other tasks must be done during the 5 m.s. (calculation of the postion ... ). Consequently, the runing time of the program is an important parameter we must know. To obtain this running time, we must write first a spline program with a real time configuration which can display the results to verify if they are good (comparaison with the general fortran program results). After that we will implement the program in a hardware support to measure the running time itself. There are two different parts in the spline program. The calculation of the coefficients Co' C1, C2 and C3 every 100 ms and the calculation of the set values every 5 ms. The calculation of the coefficients must be, obviously,done during the 5 ms interval.

b) Presentation of the development system

The INTELLEC serie III micro-computer development system is more than a key­board, a video display and disk drives: it is a real tool for designing microcomputer software for the IAPX86,88 processor. We are able to write programs, debug programs, link them, locate them and run them on the board. We can connect, in addition to the INTELLEC serie lIlian emulator for running in a hardware environment programs written in the 9096 version. The board allows only software entrances or exits via the keyboard and the screen. This is a tool to develop software programs. The emulation is the controlled execution of the prototype software in an artificial hardware environment. It has the ability to externally control program execution while operating in the users's prototype.

In our case, the final and definitive environment of the program will be the 9096 processor. The serie III development system has been designed to run, on its board, programs written for the 8086 applications. It means that to display results on the screen, the program must be first developped with an 8086 version. Then to measure its running time, it will be written in the 8096 version and loaded in the emulator.

c) Development on the 8086 version

This system offers the possibility to write source programs in a high level language (PLM86) using the facilities of a run-time support. This run-time support is a kind of library with special functions:

Page 22: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

DQ$CREATE DQ$DETACH DQ$EXIT DQ$OPEN DQ$CLOSE DQ$READ DQ$WRITE

creates an input device as console input (:CI:) deletes an input device"· •• finishes a program opens a file closes a file reads an ASCII character into a file writes an ASCII character into a file

20

These functions allow us to enter data via the keyboard and to display results to the screen.

Before writting the real program it is necessary to think about the intermediary subprograms. (See appendix L)

INTCAR GETIHT

EXIINT

OUTCAR

gets an ASCII sting of characters from the keyboard gets an transforms an ASCII string into an integer value. trans formes an INTEGER value to an ASCII string and writes it on the screen writes an ASCII string from memories to the screen.

Al the programs are written in PLM because: - this language has a bloc structure and control construction that aid

structured programming. - this is a high level language with all the advantages (no need to be

concerned by the details of the target processor, use of data types and structure).

- it has the facilities for such data structures as structured array and pointer-based dynamic variables.

- PLM programs are portable across different INTEL's processor.

We can write the spline program in two different ways. The first idea is to take the general fClrtran program and to rewrite it in the same way for our application (See SPM.PLM in appendix M),the second one is to write something completely different on the basis of what is said in "application of the calculations for four knots". (See SP.PLM in appendix!) The two flowcharts are the same, only the programming method changes). The results of the fortran spline program SP.FTN and the SPM.PLM program are displayed in the appendix N.

Page 23: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

All the calculations are made with real values, but we display on the screen some integers values which are easier to do.

lnitia.\'5f the 4 Fa,!>t "a.lup~

I nit, a. t i $e t\-. e

bound~tr c.onda'on~

(a ltu l a.tion!> of t~e 4 toeffic.ien t\

(a.lc.vlatlon~ of t~e !.et points. \J .. i te t~ em to the ~(. ree n .

tJ.)Ct knot

y (ont,nue 1

1\1

(Exit

21

Page 24: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

22

d} Measurements of the running time on the 8096 version

As explained before during the 5 m.s interval a lot of calculations must be done: calculations of the next coefficients Co' C1, C2, C3/ calculation of the position and calculation of the next set point. So the running time of a program takes a lot of importance and we want to verify that all the calculations can be done during these 5 as. To aeasure the running time we use an emulator. The hardware part of the emulator is composed of two timers, one PWM output, a 10 bits AID converter, a high speed 1/0 unit, 5 1/0 ports.

The idea is to trigger an output port each time the program is finished and to run it indefinitely in a loop. In this way, the time between each change of state of the output port is the running time of the program. The output of the part is visualed on the screen of an oscilloscope. The single flowchart is:

I I

- >i

! Pro~"am to t e~t

Tt-iCJqer the output ro .. t

We want to mesure the diffferent running times of calculation (coefficients and set points). As explained in the f -Development of the 8086 version", the programs can be written in two different versions. The results are:

SPM~' .PlM SP9'.PlM CAlM96.PLI'1

... ,.1 m.s 6.2 m·s ~.4 Ift\\

Page 25: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

23

In this first trial, all the values are declared as real values. It means that all the calculations (x, I. + ,-) are executed in a special "real unit" of the processor and take a lot of time. We can reduce this time only by using "long integer" values (32 bits) but we must take care of the overflow and of the accuracy. We can consider, here, that the calculation time of the coefficient (sP96.PLM) is satisfying but we have to reduce the time of calculation of the set points.

After rewriting the setpoint calculation program with long integer values, we find a new time of:

CAl,6

The different programs SP96.PLM, sPM96.PLM, CAL96.PLM and CALM96.PLM can be seen in the appendix o.

e) Conclusion

The other programs, which must be included in the servo mechanism, have not yet been written. Consequently we do not know if the different running times are short enough to make all the calculations during the required time. Some documentation does not appear in this report because it is very big and not necessary for understanding the work. Nevertheless, for more information you can consult the INTELL's books: "PL/M-86 user's guide", "PL/M-96 user's guide", "Run time support manual for IAPX 86,88 applications", "ISIS-II user's guide·, "IAPX 86,88 family utilities user's guide", "MCS-96 utilities user's guide", "Microcontroller hankbook".

Page 26: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

24

VII General conclusion

This practical work gave me a general view of how to develop a project. The different steps, with their significantes, are:

the theoretical approach helps to understand all the details of the study and allows to have performance results. the general simulation shows which parameters are important, how the theory is working and if the choice of method is accurate. the simulation on a micro-computer is important to see if the particular application gives some coherent results compared with the general theory. the trials in a hardware environment give a real idea of what happens in real time. This is the final step where we decide if the method is acceptable.

This pyramidial scheme (from the more general to the particular shape) finds some applications in other research projects. I discovered the important role of the simulation. The spline function program, as part of the whole servo-mechanism, has been developed in a certain context. The team responsible for the servo design followed my project and gave me the necessary indications. I learned how to include a particular work in a general design with all the constraints that apply. The large simulation part gave a chance to become familiar with the computers and with some programming problems especially real-time problems. The hardware simulation taught me a lot about micro-processors.

Page 27: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

R'sum' en francais!

Le projet s'est d'roul' dans le. loeaux de l'universit' de teehnolocie de

Eindhoven et a at' 'ffectul au b'n'fice de la .oci't' APA. Oelle-ci travaille

actuelle.ent 1 la conception d'un robot de 80udure devant prendre place dans

des ateliers flexibles.

Afin d'avoir un asserviasement cohlrent, chaque .oteur 4u robot doit reeevoir

une valeur pilote toute les 5 m.s. Le aicroprocesseur central, occup' 1 calculer

les pOints de passace obliCI pour chaque moteur. ne peut accoaplir cette tlche:

il peut seulement fournir une valeur toute les 100 a.a. 1 chaque moteur.

L'idle consiste alora i aunir ehaque aoteur d'un aicroproceaaeur 8aclave

recevant une valeur toute lea 100 a.s. et reatituant, entre autre, la valeur

des points intermediairea toutea les 5 a,s.

Mon sujet Atait de rAaliser une 'tude aur les lonctiona d'interpolation

appel' 'spline' et d'en appliquer la th'orie i la conception d~un procramme

temps rAel. Celui-ci devait restituer des valeurs pilotes toutes les 5 a.s

i.partir des points cunnus toutes les 100 m.a.

Les differentes 'tapes ont ItA:

- l"tude thAorique des fonctions spline.

- la siaulation d'interpolations par fonctiona apline aur un ordinateur de

crande puissance.

- l'application du procraame 1 notre cas particulier et sa siaulation sur

un ayst~ae de d'veloppeaent INTELLEC.

- l'Acriture et la mise au pOint des procramm~temps rAel.

Les r'sultats obtenus permettent d'pprecier la pr'cision et la rapidit'

d'une telle interpolation.

Ce projet s'eat rival' partieuliirement enrichissant. 11 m'a permis de comprendr

les processus temps rAel mis en jeu dans une commande de robot et d'acquerir une

exp'rience cAn'ralten inforaatique. J'ai Acalement apprecier de pouvoir participer

i un travail d'Aquipe.

Page 28: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

c

c c c c c c c c c c c c c c c c c c c c c c c

c; c

c

c

c

c c C

SP. FlN:

SP. F1N:

This program is the basic spline program. The programmer gives the following datas: N,X(I),Y(I), ITYPEL, ITYPER, VALL.VALk. lMIN, IMAX. lhe variables are:

N: number of knots. X(l),Y(I): coordinates of the knots. XkEF(l),YREF(I): coordinates of the set points. J1YPElt,ITYPEL: left or right boundary condition

of order one (1) or two (2). VALL.VALR: left or right bounda~~ condition. DYHEF: first derivativ value of the spline function

on each set point. e: second darivativ values of the spline function

on each knot. XMIN,XMAX: interval in which the set points values are

calculated. lhe boundary conditions can be given either by the first

del'ivativ either blj the second.

I~EAl,*a X (400), Y (400), C (400), XREF (400) , VREF (400), DVREF (400) , TVALL.'VALH

INTEGER I,N, ITVPEL, ITVPER,CaDE, IMIN, IMAX

UO 2 1:;:;:1,400 2 XUEF ( 1)::::0. ~*l

10 WIHn~; <1, 12) 12 FOIU1t\ T ( 'N, X ( 1 ) , V ( 1 ), I;;:: 1, N ' )

I~EAD (1,.,cHR""10) N,(X(I),Y(I),I a l,N) IF (N.EG.O) GaTa 90

14 WRITE <1.1b) 16 FOkMAT ('lTYPEL, VALL, ITYPER, VALR')

I~EAD (1,., EI~R=-14) ITYPEL, VALL, ITVPER, VALR

CALL lilAC (C,X,Y,N,DYREF, ITYPEL,VALL, ITYPER,VALR,CODE) WRITE (1, la) (C CI), 1;;::1, N)

16 FORMAT ('C ;:;;, # I (5E15. 5»

20 Wf~rTE (1.22) 22 r:OOMAT ('IMIN, IMAX ')

UEAD (1, *, EHR=20) IMIN,IMAX IF (lMAX. E.G. 0) GOTO 10 CALL BIAVLl (C"X, Y, N, XREFiVREF, DVREF, IMAX) WfUTE: (1,24) (XREF(I),VREF<I),DVREF(I), I=IMIN, IMAX)

24 r'flOMA1" (3(~1!1. 6) .,(1 ;'0

?~ 'l" X l"l

"-'lit U 10 ENU

C Thi~ subroutine calculates the N second derivative e values ", the spline func.tion at each knot.

Page 29: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

C

c

c

C C

SP. F1N:

SUBROUTINE BlAC (COEFF,XNOD,VNOD,NNOO,WORK, * TYPEL,VALL,TVPER,VALR,CODE)

JNl'EGEn NNOll,TVPEL,TVPER,CODE REAL COEFF(NNOO),XNOOCNNOD),VNODCNNOD),WORK(NNOD),VALL,VALR

REAL li,OLDH,F,WORK1,COEFF1,VH INTEGER I,Nt,IBACK,FAIL

C For' the ~p~rup~iate equations refer to ... C C C C C C C C C C C

c

In this implementation, all equations are muliplied b~ 6 (six). Moreover:

1. The equatiolls are build ("assembled") for the intervals 1, 42 etc:. So thelj c1ill'S made in two rounds (normall" two intervals are ihvolv~d in the formulation of each equation)

2. Solution of the tridiagonal set of equations is done b~ Gau~sian elimination (without pivoting). The eleimination is done io~ediatl", backwards-substitution ends the so lut i on-p"oc e 5 s.

FAIL:.::;) IF (NNOD.LT.3) GOTO 90

C BEGIN CONDITION e C e e

c

c

EQ.uations fOl' interval 1 (X(1) ... X(42»: dVI :0 (Vl' - Vl) / H - H/6 * (2 * Cl + Cr) dVr = (Vr - VI) / H + H/6 * eCI + 2 * Cr)

FAIL;;. 2 H=XNOll(2)-XNOO(1) IF (H.LE.O.) GOTO 90 VU=b. *(VNOIH2)-VNOD( 1) )/H COEFF1==VH

FAIL!:'! IF (l·VPEL. NE. 1) GOTO 10

C TVPEL :::. 1 :f=il·s.t derivative prescribed C

c

c

W{JRK(1)::;.2 .... U COEFF(1)=VU-6.*VALL WOf-tK 1 =4i IBACK~l

GUlL] 20

10 IF (TVPEL NE. 2) GOTO 90 ,

C TVPEL = 2 : second derivative prescribed C Use onllJ the equation for dVr in interval 1 and substitute e VALL for Cl C

c

c

WUHKC1 )=1-COF.FF ( 1 ) =--VAl.L wonK 1 ::.() . lUACK=='2

20 Nl=NNOl}-l

Page 30: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

c

c c c c C C

c :30

SP. FTN:

EQ.uations fo}' interval i (X(i) ... X(1+1», i = 2 ... N-l: 4Yl = (Yr - Yl) / H - H/6 * (2 * Cl + Cr) dY1" r::::: (Yl' - Yl> I H + H/6 * (CI + 2 * C1")

h.ple8lent eq,uation i with: dYr(i-1)

FAlt"'2 00 30 1=-2,Nl tJU)H:o. ....

H=XNt:JIH 1+1 )-XNOD( 1) IF (H. t.E. O. ) GO TO 90 F::.OLDH/WOHK ( 1-1 ) WORK(I)=2.*(OLDH+H) - F*WORKl WORK1::=H YH=6. * (YNOlH 1+1 )-YNOD( I) ) IH COEFF ( I );::. YH-COEFF 1 - F *COEFF C 1-1 ) CClEFF1::-.::VH CONT 1 NUl:.

dYl< i) = 0

C END CONDITION C

FAIL=l IF OVPER. NE. 1) GOTD 40

c C TYPER t;:: 1 : fit'tot derivative prescribed C

c

c

F~/WURK(NNtJD-l)

WOf~K(NN(tD):;..2. *H - F*H COEFFCNNOJ)"-'6. *VALR-COEFFI - F*COEFFCNNOD-l) GOTO flO

40 IF (TVPER.NE.2) GOTO 90

C TYPER ;:.::; 2 : second derivative prescribed C

(;

WONK ( NNW) ) :: 1 • CUEFF (NNOD ) .:;.'VALR

C BACKSUHSTITUTION C

c

c c c

50 COEFF (NNOD) ;:;·COEFF (NNOD) IWORK (NNOD) l~Ull

60 1=1-1. COEFF(I)=-(COEFFCI)-(XNODCI+l)-XNOD(I»*COEFF(I+l»/WORK(I) IF (I. QT. lUACK) GOTO 60 fAIL=O

90 COUE""FAIL UETUnN END

C This subroutine calcules the ordinate of a set point. c

C

SUUROUTINE IHAVO (COEFF, XNOD, YNOD, NNOD, X, Y) INTEGER NNUU '-(EJ\L COEFFCNNODh XNODCNNOD), YNODCNNOD) , X, V

lN1F(·:fH 11.)2

Page 31: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

C SP.FTN:

c C Find inteT'val tu be u5ed C

c

V=YNOU(l) IF (X.LT.XNUO(l» GOTO 90 V==VNOl> ( NNOU) IF (X.GT. XNOO(NNOO» GOTO 90

C Lillec:n' 'Ill"'ul"ch is done heT'e C

C

10 11=12 12=11+1 IF (XNOD(12).LT. X) GOTO 10

C Interval is 11 - 12. Value may be at either boundary C

G c c

DX~XNOD(12)-XNOO(11)

F::o.DX"'*2/6. CL::zC(ltFF ( 1 t ) CR9:UEFF(12) YI .=YNQl> ( 11 ) Vn=-yNOO( 12) A3=F*(Cf(-CL) A2=3 .... F*CL At""YR-YL-F*(2. *CL+CR) AO""YL S=(X-XNOD(ll»/DX V~«A3*S+A2)*S+Al)*S+AO

90 kETUUN liND

C Thi. subl"uutine calculates the ordonate of a set point C and th~ fil'Sot derivative value of the spline function. C

C

C

SU~R~UTINE U1AV1 (COEFF,XNOO,VNOD,NNOD.X,V,DV) INTEQER NNOD REAL COE:FF(NNOD), XNOD(NNOD), V NOD(NNOO), X, V, DV

INTEGEa 11,12 REAL DX,S,CL,CR,VL,VR.F,AO,Al,A2,A3

C Find interval tu be used c

c

UV=O. J

Y==YNOU(l) IF (X. LT. X NOD ( 1» GOTO 90 Y;:;YNOl)(NNUU) IF (X.GT. XNOOCNNUD» GOTO 90

C Lineal" se~T'ch is done here e

c

12:=1 10 11==12

12==11+1 IF (XNODCI2).LT. X) GOTO 10

A

Page 32: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

C SP. F1N:

C Intel'val is. 11 - 12. Value may be at either boundary C

c c c

PX=XNOP(12)-XNOD(11) F;:;l)X+*21 b. CL"'-'CCtEFF(ll) Cf(;::;"cCIF..FF( 12) VL=VN01.)(ll) VR=VNUD(12) A3:;;:.F' .... ( CR-CL ) A2=3.*F-*CL A1~YR-YL-F-*{2. *CL+CR) AO~YL

S:::.::{ X-XNOUO 1> ) lOX DY""«3.*A3*S+2. *A2>*S+Al)/DX Y~«A3*S+A2)*S+Al)*S+AO

90 W:.l'URN E.HU

C Thi$ &ub~autine calculates the ordinate of a set point, C and the fi~st and second derivativ of the spline function. C

c

G

SUBROUTINE lHAV2 (COEFF, XNOD, YNOO, NNOO, X, Y, DY, COY) 1 NTEGEf( NNOP {-(EAL COEFr';'- (NNOD) I XNOO (NNOD) I YNOO (NNOD) , X, V, DV I DOV

INTEGER 11,12

C Find int.erval to be used C

C

DY~O.

UUY;··O. Y=-YNUIH 1) IF (X.Ll. XNOD(l» GOTO 90 V=YNOD(NNUU)

. IF (X. QT. XN(JD(NNOD» GOTO 90

C Linear sea~ch iG done here C

C

Icr-1 10 11=12

12".;11+1 IF (XNOP(12).LT. X) GOTO 10

C Interval is 11 -- 12. Value mal,l be at either boundar!:l C ~

DX=XNOP(12)-XNOD(11) F:::;DX**~Ub. CL~(JEFF(ll)

CR=COEFF(12) VL=VNOD(lJ) VR==YNOD ( 12 ) A3""Fit(CR'-CL) A2~.*f*Cl Al a YR-VL-f*(2:*CL+CR) AO..:'VL S=(X-XN(JD(11»/DX DDY~2. "H~i. *A3*S· .. A2> IDX**2

Page 33: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

c

c c c

SP. F1N:

UV=«3.*A3*U+2. *A2>*S+Al)/DX Vc«A3*S+A2)*S+Al)*S+AO

90 UETUHN ENU

C Thib bubroutine calculates the ordonates of the set C point value~ between 0 and IMAX. C

C

C

C

SUHIWU1INL~ I:lIAVI..O (COEFF~ XNOO, VNOD, NNOD, XL, YI.., NL) INlE.GE:.f{ NNW>, NI.. REAL COl:.F-F (NNOO), XNOO (NNOO) , VNOO (NNOO), XL (NL) I YL (NL)

1 NTEC::EH 1 1, 12. I I.. REAL DX,S.CO,Cl,YO,Yl,F,AO,Al,A2,A3

lL;;::.l

C Befol'e fil'st. XNOD C

G

10 IF (XL(JLL GE. XNOD(1» GOTO 20 VL ( lL) =VNOlH 1 ) lL=lL"'l IF (IL. GT. NL) GOTO 90 GO),O 10

C Lineal' '5of."iil·ch to find appropriate interval c:

c

20 12=1 30 11=12

12=11+1 IF 02. GT. NNOO) GOTO 80 IF (XNOD( 12>' LT. XL. ( IL» GOTD 30

C Intel'Vc.1 it. 11 -- I2. Value may be at either boundary C

c

DX=-XNUV<l2)--XNODC II) 1:;;;;"OX**2/6. CO .... Cm:.f-F ( 11 ) C 1 :.;..CtJt:.FF ( 1 Z' ) VO=YNOU(Il) VI ;;;YNOlH I? ) A3~-F*(C 1'-CO) A2;;:::3.itF*CO AlaYl-YO-f*(2.*CO+Cl) AO~YO

40 S;:...(XLClL)--XNOD( 11 »/OX '" YL( IL.);:.' ( CA:Ji1'S+A2>*S+Al )*S+AO lL~lL-t'l

IF (IL QT. N1.) GOTO 90 IF (XL(lL).LE. XNDDCI2» GOTD 40 GOlD 30

C BE.'YOHd la~t XNOU <:

c

BO YL( lL ):.-VNUU(NNOD) lL=IL+1 IF <1L LE. Nt) GOlD 80

Page 34: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

c

C C

c c (;

All

90

np.I·'IN: niT\: f\ (..-\of ~

done

RETURN P"m

This suh~outine calculates the set point values between c C C

o ~nd JMAX and the first deri~ativ value of the spline 'unction.

SUJJRC1UTINF BIAVLl (COEFF, XNOO, YNOD, NNOO, XL, VL, 'OVL, NL) JNTFGFR NNtlD,NL REAL CllF.FF(NNOO),XNOOCNNOO),YNOO(NNOO),XL(NL),YLCNL),DYL(NL)

C JNTEGER 11, 12, IL REAL DX,S.CO,Cl,YO,Yl,F,AO,Al,A2,A3

C

C C Before first XNOD C

C

10 IF (XLCIL).GE. XNODCl» GOTO 20 "'Y'L( IL)""'O. YL (IL ):-'VNon (1 ) lL=IL+l IF (JL. GT'. Nt) GOTO 90 OOTO 10

C Linear nearch to find appropriate interval C

C

20 J2=-1 30 11:'!:1?

J2=1 J+1 IF (12.GT.NNOO) GOTO 80 IF (XNOn(J?).LT. XttIL» GOTO 30

C Interval is 11 - 12. Value mal:! be at either boundary C

c

DX:::-:XNOP(I2)-XNOD(Il) F="X**?n ... CO~OFFF(}l)

Cl""'COEFF(J?) YO::::VNOf)(ll) Y1r;:oYN(ln(1~)

I'\3=F*(Cl'-CO) A2="::1.*F*CO A1 :=.VI-YO,-f*(2. *CO+C 1 ) AO:-:::YO

40 S~(XL(IL)-XNOD(Il»/DX n~_(IL)~«3.*A3*S+2. *A2)*S+Al)/DX YL ( IL) =: ( (A::l*S+A2) *S+A 1 ) *S+AO IL:::rJt+l IF (It.. GT. NL) GOTD 90 IF (XL (}L).LE. XNOD(I2» GOTO 40 GOm ::-10

C Beyond last XNOn C

ao PYL( IL'~O. 'Y'L(1L)~YNOn(NNOD)

n

Page 35: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

c

lL:=ll+l IF (IL.LE.NL) GUTO 80

c C All done C

c c c

90 HEnmN END

C This subroutine calculates the set point ordonates C beteau:.·ell () ,HId IMAX. the first and second derivativ C of the spline function. C

(;

C

sumWUT I Nr~ IH AVL2 (COEFF. XNOD. VNOD. NNOD, XL, VL, DVL, DDVL, NL ) 1 NTEGI::.H NNOl.h NL fU::'AL COl!f~ F ( NNOD ) • XNOD ( NNOD ) , VNOD ( NNOD ) J XL ( NL. ), VL. ( NL.) I DVL ( NL ) I

... UlJVL(NL)

INTEGEH II. )2. IL. rU::AL DX, S. CO, Cl. VO, Vb F, AO, AI, A2. A3

lL~ 1

C BefoT'e fh-st XNUD C

C

10 IF (XL( ll)' GE. XNOD( 1» GaTO 20 lJl>Vl ( It ) ~(J. lJVL( ll.) ;0. YL ( ll. ) t;.·YNUU ( 1 ) lL==lL-fol IF (lL.Gl.NL) GaTO 90 GOTO 10

C Line~r search to find appropriate interval C

c

20 12;::;.:1 30 11=12

12::;'11"1 IF (I,L G'1. NNOD) GOTD 80 H· (XNOlH l~)' LT. XL( IL» GaTO 30

C Intel'val is 11 - 12. Value may be at either boundary C

40

nX:;-.;XNUIH 12 )·-XNOD ( 11 ) f;'·UX**2/b. CO=-COI·.FI'; ( 1 J ) Cl=CQL:'FF (l~) VO~VN(JlJ(ll) w VJ=YNUU();") t\:J=f': ... ( (:1'_(; 0 ) i\::!=3.*F*CO AJ=Vl"~VO+*(2. *CO+Cl) I\O=VO St .. (XL (It )·XNOD ( 11) ) IDX UUVL(lL);;.;!. *(3. *A3*S+A2)/DX**2 UYL( lL):;r.( (~J. *A3*S+2. *A2)*S+A1 )/DX VL( lL)~·( (A::iJi-S+A2HtS+Al >*S+AO 1 L"'"lL-tj IF (IL.Gl.NI) GaTO 90

Page 36: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

c

SP.f-1N:

IF (XL(lL).lE. XNOD(12» GOTD 40 QOTO 30

C Beyolld lilsi XNUH C

c

80 llDYL< IL):.O. JJYLO L)::O. VL( IL )::'YNOD(NNOU) lL=Il.1-1 IF (lL.LE.NI..) GDTO 80

C All dune e

Page 37: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

SI'C. 1-"1 N:

C SPC. F1N: C C llUS PRUGHAM CALCULATES A SPLINE INTERPOLATED CURVE C Wl1H 'lUF KNOTS PLACED ON 1:4 CIRCLE, IT RESTITUTS C 1HE !'1t'\Xll't(\L ERROR BETWEEN TWO KNOTS, THE INTERPOLATION C IS lJONE; UN 'I HE CUnVE Y=f (X) AND Z=f (X) WHERE X IS THE TIME, C HIE PAI~t'\l"iL:H:RS ARE: C N~NUI'tU~N OF KNOTS C X(),Y()=COORDINATES OF THE KNOTS IN SPACE C 2 ():). C;OORDONA"re: IN TIME OF THE KNOTS C XU(l),YU(I).ZB(I)=COORDINATES OF THE KNOTS ON WHICH C THE SLINE FUNCTIONS ARE CALCULATED, C XIH:F(),YREF(I),ZREF(I)=COORDINATES OF THE CALCULATED C SET POINTS, C CY(l),Cl(I)~SECOND DERIVATIV VALUES FOR THE SPLINE C FUNCTIONS Y=(function of time) AND G Z=(function of time) FOR EACH KNOT C DYUl'h 1.>~REF=FIHST DERIVATIV VALUE C XI-I( 1). YN( I)' ZM( I): COORDINATES OF THE SET POINT C WHERE THE MAXIMAL ERROR OCCURS C DHM<I'It\X1MUM I:::RHOR BETWEEN TWO KNOTS (; VI\I Vf(, Vt\LZR:::o.RH~HT BOUNDARY CONDITIONS C VAL VI • VALZL::.'LEFf BOUNDARY CONDITIONS C UN: ANGULAR SPEED C Ll~LFN~lH BEFORE ARRIVING ON THE CIRCLE C Il:: 'U\I)) Uri c 1Fl,VANGLE WITCH SEPARATES EACH KNOT C PI'.t): G 1 VI' XREF ( IN TIME) C 'II-IF UOliNHARIIZS CONDITIONS AI~E THE FIRST C lJEHIVi\11Vl~::.i, THE ANGULAR SPEED IS CONSTANT, C (;

(;

C

(;

c

c C

(:

IU~ALt:,U (11'1, lU. R, TET,\, TElAO, ANC, T, VALYR, VALZR, *VALYl • VAl n . DYLF, OZLF. LDl. PAS

r~t: Al JI-(3 X <tJO L Y ( 50). Z ( 50). XB ( 10), YB ( 10). ZB ( 10) • DR:::! (400) , *XI<l:f';' (400) • YI<EF (400). ZREF (400), CY (50), CZ (50), DYREF (400), *Ul'fH:+ (400) I VR (400), DR2 (400)' DRM( 400), ZM (50). YM (50) I XM( 50)

IN·'l:~EI< 1. KJ, K2, K, ITYPEL, I1YPER, N. 11, J, IMAX, 12

1 0 ~nu 11". (1, J;') 12 HJI-(l'IlYi ('N. (1M. LU, R. TETA. PAS ')

W::.AlJ (1, *, (:HR-I0) N, OM. LO. R. TETA, PAS H· <11:11'.. e:n. 0, 3141592654) GOTO 10 1',,'1 ETA/UN '" t )) J ~ U .. ', FII\ 1F (l U. (,;' .. 11>1> GmO 10 U: (I U, NF, () GOlD J 3 " Fl AO:o:, 'II- 'I {\ GU'lll 1 'I

13 'I El P.O:· (l( t,', r", A-U» IH

C CiJlcul"ltl(lll Or the coordinates of the knots foT' C l.h(~ (i.lt,(·~, Tt::TA«P)/2LPt !J~'O PP) and TI.:'IA:>(P1Il').

Page 38: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

c

(;

c c c

C C G

c

SPC. FH'ol:

14 ;£0);.:0 VU)t.O X(1 ) .... 0 1 ~.:::2

15 ANG;;.. 'IETAOI,'II~TA* (1-2) 1 t..: (/\NG. (·n, 1. 'j·707rU~::~2-') GOTO 16 X ( 1 )~, ( 1 -~ 1 ) ,,', V ( I )~. a -·c~ *})C:US (AN(; ) 'I ( 1 ) lUHIPiol.H il N ( ANG ) Il':l +1 GOTfJ 1:'"

16 Kl:..11

UO 1U K: ,\J ,1\2 X (K ):;. (t~ -1 ) 1:·'1 V(K)= It..:· ('I ["11\0-0, 570796327+TETAi!-(K-2»

18 Z(lO:.ltH.H

Ciilc.ulatioll of the different boundary conditions for the GH;'f;~t; 'lETA«PI/2) and TETA)O(PI/2>'

IlVPt-l.::: J IlVPt·I~:.;' 1 1 :;;;.Q

19 ANG:...1E'I/\01-l1·TA*< 1+(N-2» IF (ANC·:. G'I, J. 570796327) GOTO 20 VAl. y[(t IH'UI'1~J)SIN(AN(';)

v/\Llk::-':U;,OI'HH)COS (AN(;» GUHJ ~~~1

20 VALVIi' 1-<*01'1 VAl.zn:: '0

22 IF (1. Nt~, () GOTO 24 VI\lYL~ 0

£;)4

2:;'

VAl:tl: luHIN (':(J)"O :~~

VI\LYl. ::oJ]YI 1-VAl2l::lit'lt-

CiJlc:ulcatioll e,f the coefficients and the set paints faT' N knots.

lJ(J :'l{.l l(::· J , N 1. 1 :,;., I"''' XHOO~X(ll)

VHHO'Y(lJ) 26 :t U (K) 't", ( I J )

Ct',Ll JlJAG (CV, XB, VU. N. DYHEF, ITVf-'EL. VALVL, ITYPER. VALYR) CAll UJAC CCZ.XB.Za,N,DZREe, ITVPELIVALZL, ITVPER,VALZR) J·O '

30 J="HJ XI([:F (,J) ",. p(\'~:i 1:'..1+ T '* I 1 r· (XIU+ (..1). LE. XB (;2» GO TO 30 )l'I,\X:::"..1 -J CALL lllA~ J (CY,XB.VD,N.XR~F.YREF,DVREF. IMAX,DYLF) C/\LL lUt\VI J (el, XB. ZB, N, XREF, ZREF, DZREF, IMAX, DZLF) ) F (YIU+ ( li'lf\X >. GT, R) GOTD 10 1(,; 0 ) ;.:., 1 H ))I(~H I~I); ()

C F:ihd 1.11(' IlIi;:<ilTlul IH'l~OT' between two knots.

Page 39: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

C SPC. flN:

(;

c (;

32 IF (K. G£:. IN,\X) GOTO 34 K~-K'H

UI( (K) ;.H···WiOHT ( (R-YRFF (K) } **2+ (ZREF( K) -LD) **2) m(2(K);..;1)AUH(DR(I~) } 11- (1)1(200. LT. DR3(I2» GOTO 32 Yi'! ( 12);· YW+ ( K ) XM( l~n;: XI(r·r- (K) :tN( nn:ll<H:(K) JJaM ( 1;.1.) ~ 'JJH (K ) Im::J ( I:! ) q)l(~ ( K ) Guro :i~"

::14 HIHH:: (l,:U,) (XM(I2),YM(I2},ZM(I2),DRM(I2» 36 r-cmNAT c' XN YI'" 21"1 DRM' I (4E l!>. 6»

WfUU .. (1. :if!) (DYLF, DZLF) 38 HJ1~Nt\'1 ('l)'{IF DZLF'/(2El5.6»

1:.:) H GUlO J '" I~NlJ

C Thi~ subroutine calculates the second derivativ C villuvh oPthe spline function at each krlot. C

c

(;

c

tiUUHCJln INl~ HlAC (COEFF. XNOD. YNOil. NNOD. WORK, * lYI'E:.L. VALL. TYPER. VALR) INIF(:!l~t< NNW), TYPC:L TYPER. CODE I<EAL tU c:n:"+f~ (NNOD), XNOD (NNOD) I YNOD (NNOD) I WORK (NNOD), VALL, VAL.R

l(bAt I'U Ij, CJl. VH, F. WORKl, COEFF 1, YH unl:;-(;!Hl I, Nj I lDACK. FAIL

C F 0" the lop 1J1'oln' i a te equat i on s re fer to '" C C In this ilrlld(~flll!lltation. all equations are muliplied by 6 (six). C i"Ioreovtn~:

(; 1. lhe ""t.I..:.titlllS arc build ("assembled") for the intervals 1,2 etc. {; tio they iJl't' made in two rounds (normally two intervals are C illvo)v(·d in the fOl'mulation or each equation) C 2. Solution uF the tridiagonal set of equations is done by C Gau!>f.:lilll "l)mination (without pivoting), The eleimination C i5 d(J1I1! i,u'II,·diatllj. backwards-substitution ends the C !>olutioll-,.Il'(lces!r., C

f·/Hl.:::J IF (NNUl>, LT, 3) Ga', 0 90

c C DEGIN CUNUIllUN C EQ.uatiollt.l'o)· inte'/'val 1 (X(!) ... X(2»: (! dYl t- (Yl' - Yl> I H - H/6 * (2 * C1 + Cr) C dYl' ::... (Yl' - Yl> I H + HIe * (el + 2 * Cr)

r-AIL~ 2 II"'XNWH?) 'XNOD( J ) IF (J I. L [~. O. ) GOTO flO YII"-o, .. (YNW)( 2) -YNCJD ( 1 ) ) IH COB+ J.: Ylj

Page 40: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

C t:.if'CF. 1";'1 N: C C TillS PI{Ut:I{AM IS THE SAME AS SPC. FTN BUT USES A GRAPHIC C fUNGlIUN. 1T CALCULATES FIRST THE POSITION OF THE C KNtllS, lltt-N THE ERRORS AND RESTITUTS THE CURVE ERROR=f(ANGLE) C WHHU:: X Hi THE TUIE. C 'lIlE INH:I<I'OlATION IS DONE ON THE CURVES Y=f(X) AND Z=f(X)' C 1JU::~ f'AHI\I"IE:'Il'RS ARF: C N::--NUI'1l.J[: I{ OF KNOTS C X(l),Y()gCOORDINATES OF THE KNOTS IN SPACE C Z(} ) "-'C(JttRDONATE IN TIME OF THE KNOTS C XU (1 ) • Yl:l ( I ). ZB <I ) :;;;COORD I NATES OF THE KNOTS ON WHI CH C THE SPLINE FUNCTIONS ARE CALCULATED. C XI<[F(), VREF( I). ZREF( I )=COORDINATES OF THE CALCULA1'ED C SET PUINTS, C CV().C/(I)=SECOND DERIVATIV VALUES FOR THE SPLINE C FUNC1IONS Y=('unction of time) AND C Z:;.(function of time) FOR EACH KNOT C V~<lf,D1REF=FIRST DERIVATIV VALUE C XI-I( 1) , VI'! <I ) , ZN ( I ) : COORD I NATES OF THE SET PO I NT C WHt..::ru:, niE MAX HIAL ERROR OCCURS C UI~;.. l:WWR BETWEEN THE CIRCLE AND THE INTERPOLATED CURVE C VALVf<, Vt\LZR=RIGHT BOUNDARY CONDITIONS C VALVL, W'.LZL=LEFT BOUNDAR V CONDITIONS C ON~'ANGUI AR SPfED C LD:;:-LENG1H BEFORE ARRIVING ON THE CIRCLE C It: lU\UHIH C 'I FI 'V~(\N(.~LE Wl TCH SEPARATES EACH KNOT C PAS=lll'll', BETWEEN EACH SET POINT C 11tL: BOUNDARIES CONDITIONS ARE THE FIRST C Uf.:.JHVf\l 1 V[-J" THF ANGULAR SPEED IS CONSTANT, C C

C

C

c

c

C C

ULUC,{ UA'lt\ CONNON IFNI\i'lESI N 1 (20), N2 (20)

UA1A Nl I 'fiPCF/,'. I ',18*' I I, * N;? I ' HPCF " I, H " 1 (HI-' I I

t:.NU DUmWU',lNl' "UNCT (TARG, VARG, NP, OK, GEG, IRES) HEAL lAUG' (:,00), VANG (500), SEG ( 1 ) INH,:(';EH NI~, IRES 1 IJQ 1 CAL UI~

I(FAl *0 LIN, I V. R, TETA, TETAO, ANG. T. VALVR. VALZR, *VALVL.VALlL,DVLF,lJZLF,PAS

f~FAI nf:! X n,(.) I V ( 50); Z (50), X1H 10), VB ( 10), zn ( 10) , *XI(I.::.I- ('tOO), VI(EF (400) > ZREF (400) I CV (50), CZ (50), DVREF (400), *UZUJ=F (4()(» I l'lR (?OO), XREF 1 <;;00), TT

, INH'Gt:J< 1, KJ. K2, K, ITVPEL. ITVPER, N, 11, ~, IMAX, 12. NP. KL

N=GHHl) (JM'~H':(~)

UJ""Gl:..G (:,) n~.;Q!· G (II ) 'I I:::TA<'(;:,(,: (:.,) PA5· Gf:"G (b)

Page 41: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

'I:;.... n£TA/tJN Tf:.;;:l. ~707'N.)~i27/01'1 iF (LU,NE.O) Gala 13 'II:TI\O::"J El f\ (;:OTD 14

13 '1 ETAO'~(I(*lt:-'1 A-LD) If< 14 1(1):::0

Y(l)=-O X(l):::..O 1:;.2

15 ANQ:::.;ll;TAO:·H-TA*< 1-2) IF (ANG. GT. 1. 57079£.327) GOTO 16 X( l);c<I -1 )i:·T Y ( 1 ) t::f~"f(*])<':US (AN(~ ) 1. ( 1) =LIH·j(-t:·milN (ANG) ):;;011-2

GOlU 1:.1 16 Kl;;;:l

l(2=l+b U(I 1 (i K:· J<' J • 1~2 X (K);:;... (K-l H'T Y(K)=fOHll:'(AO-O. 570796327+TETAiHK-2»

18 L (K ) ::; n I-LJ)

l1YI~fL::;...J

11YP£J~~'1 1=0 KL=O

19 AN<,FlfETAO '-H-'r A* ( 1 + (N-2 ) ) IF (ANe.:. G'J. 1. 570796327) GOTO 20 VALYk~:;n.OH*))Sl N (ANG) Vt\LZR;.::R*CJN*ue00 (ANG) ''{lTD 2::1.

20 VALYlt~H*LJN V t\J._l « .;.7.()

22 IF (I,NE.O) GOTO 24 VALVI::O VALZL:o.ft*tJN GOlD 2:"

24 Vf\L YL:::.UYLF VAL2L::;.;unF

25 00 2.6 K:::cl. N 11:;..) "K XIHK)=~X (U) Yil( K ) =Y ( 1 J. )

26 2lHK)=<lC l1) CAtL IJJAC «:Y. xu. VB. N. DYREF. ITYPEL. VALYL. ITYPER. VALYFO CI\L.L lilAC (ez, XB. ZB. N. DZREF. ITYPEL. VALZL. ITYPER. VALZR) ,.]:0.0()

30 ~;,J+l xr~EF (~);:..PAtj*..J+T*1

IF (XREF(..J)' LE. XB(2» GOTO 30 • INAX:.··J·l CAU.. BIAVLl (CV. Xlh VB. N. XREF. VHEF, DVREF. II'1AX. DVLF) CALL D1AVl .. l <ez. XB. ZB. N. XREF. ZREF, DZREF, IMAX. DZLF) IF (XREF (INAX). GT, IT) GOTO 40 K:o..:.O H!~~l t-1

32 IF (K.GE. IMAX) GU10 34 K~ .. J KL=Kl+l

Page 42: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

(; til' (,:1 •• 1-1 N:

c c c c

C

C C

DI~ (KIJ :;.1~-Df-i(iRT ( (R-YREF (K) ) **2+ ( ZREF (K) -L.D) **2) XlU:J:l CKL)::'XJ<EF(K) 001'0 3~1"

34 l=IH Gun) 1(:'

40 OK""'. 1 rwt:. NP::;;f(L DO ~o l=l,NJI lMG( 1 )r:XIU~rl (1 )*OM-TETA+TETAO Y I\H.(J( J )::- l>rH 1 )

:;'0 cor~., 1 NUF m'-Iuru~

l::NU;

SUllIWU1INl~ lilAC (COEFF, XNOD, YNOD, NNOD, WORK, .. TYPEL VAL.L., TYPER, VAL.R)

IN"I EGEJl NNUH, TYPEL, TYPER, CODE kEAL*O CUl:+F(NNOD), XNOD(NNDD), YNODCNNOD), WORK(NNOD), VAL.L., VAL.R

kfAL*a Ii, (llIlH, F, WOF<Kl. COEFF1, YB IKfEG@( I,Nl, IBACK,FAIL

C For the apf.ll'o,Jl·iate equations refer to ... C C In this im~lempntation, all equations are muliplied b~ b (six). C Moreuvel': C 1. The E:quat;ous are build ("assembled") flol' the intervals 1,2 etc. C So th(!1d ill'''- made in two rounds (normally two intervals are C illvCJlvt'd in the formulation of each equation) C 2. tioluti(m of the tridiagonal set of equations is done blJ C <;"us.t.:ian t~l:imination (without pivoting). The eleimination C i!o dtmE: irufllediatly, backwards-substitution ends the C t.uluti on·-ftl·ucess. C

FAll.:: ':.1 IF (NNUD. LT.::J) GOTD 90

c C BEGIN CUNUlllUN C Equations POl' interval 1 (X(1) ... X(2»: C dYl -- (y" - Yl> I Ii - H/6 '* (2 * Cl + Cr) C dYl' :;;. (Yl' - Yl> I H + H/6 '* (Cl + 2 '* Cr) C

c

c

FAIL:;.-&:! H:.:..XNUD (ZO-XNOD ( 1 ) J

lF (H. LE. O. ) GOTD 90 '{H~. '* ( YNUU ( 2 ) - YNOD ( 1 ) ) I H COEFr~ 1 ::;-;YH

FAlL_;;.:l IF CTYI'1::1 .. Nf. 1) GO TO 10

C TYPEL ;:; 1 : fil'fot derivative pl'oscribed C

"JOr~K ( J ) ::';':~!. *Ii COI:::FF ( 1 ) t;:Ylt--6. '*VAL.L.

Page 43: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

(; !.)pCF. VI N:

C

c

WOUK1=+i lllACK:..:1 OOTQ :-W

10 IF (TYPL::L, NE. 2) GOTD 90

C TYP8 = 2 : second derivative prescribed C UbC Dnly the equation for dYr in interval 1 and substitute C VALl-flol' C 1 C

C

C C C C C

WUltl~( 1 )=1. COEf':f ( 1 ) ~VALL WORK.l :..:(). IljACK::'2

20 Nl==NNUU'-1

E'luati ow; fa)' dYl :::: ( Vl' -dYr == ( Vl' -

interval i (X(i) .. , X(i+l». i '11> I H - H/6 * (2 * Cl + Cr) Yl> I H + H/6 * (el + 2 * Cr>

C 10,(11 f:!'fllcn t equation i with: dVr(i-l) dVl< 1)

C f'AIL::'~!

UU 30 1::::.2.NJ. OLDH:;::fi H::.::XNUl) ( 1'- J ) - XNOD ( I ) IF Hi. l-E. O. ) GOTO 90 F:::.(JL.VH/WUI~K ( 1-1 ) WOnKe I ):..:2. *(OLDH1·H) - F*WORKl WORK 1 ::00 YH~6. il-( YNOD ( 1+1 ) -YNOD ( I ) ) IH CO[:FF(l):.~YH-COEFFl - F*CDEFF(I-l) COEFF.1:;.;.Vli

30 CONTINUE C C END CONDITION C

FAIL;·1 IF (lVf'f:R. NF. 1) GOTD 40

C C TYPEIt =:: 1 : fil·£;t del'ivative prescribed C

C

F=-H/WUUK(NNlID-l) W{JlUH NNUU ) ::.: ;"'. *H - F *H CUf.rF(NN(JU):.;6. *VALR-CDEFFl - F*COEFF(NNOD-l) GO'IU ~

40 IF <TVt"E-..R. NE. 2) GOTD 90 C • C TVPBt ~ 2 : secund derivative prescribed C

C

WO(tK ( NNUU ) "" J . COEl+ ( NNlJU ) :.. VALH

C BACK-SUUS', I TUT 1 UN C

50 COr::J;F (NNW) ).~ COEFF (NNOD ) IWORK ( NNOD ) l=NNOD

60 1=1-1

= 2 . . , N-l:

= 0

.s

Page 44: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

A fff.,. ~"1- L COEFr· (l );~ (COEFF ( 1 )- (XNOD( 1+1 )-XNOD ( 1 ) >*COEFF (1+1) ) IWORKU ) IF (I.Gl. lUnCK) GOTO 60

C

C C C C

C

c

c

FAU.::,O

90 CUllE.oFAlL I~ETUHN

END

SUlJIWU1INf.: UIAVLl (COEFF, XNOD, VNOD, NNOD. XL, VL, DVL, NL, DLF) IN.1 EGfJ( NNUH, NL f~tAL *13 CUI.:+ F ( NNOD ); XNOD ( NNOD ) I VNOD ( NNOD ) I XL ( NL ) , VL (NL) ,DYL ( NL )

INTEGHt 1 J. 12. IL IU::ALi:'(:J DX, 8, CO, C1. YO, Yl, F, SF, AO, Al, A2. A3. DLF

lL=l

C Hefol'e foil'st XNtlO C

c

10 IF (XL(IL).GE. XNODCl» GOTO 20 UYL( lL):v.o. Yl.( n );.;YNOf)( 1 ) 1 L;:;l L"l IF () L. (·n . NL) GOTD 90 GOTO 10

C Lineal- sl'.n't::h to find appropriate interval C

c

20 1;t=---1 30 11;::.-·IP

] 2:..lJ .. J IF (l~!. GT, NNOO) GOTO eo IF (XNOD(12).LT. XL(IL» GOTO 30

c.; Intel'val it:> 11 ··12. Value may be at either boundary C

c

DX=XNOO(2J'-XNOO( 1)

t·~UX'JBI·2/6.

co=;~m:j-'F ( 1 ) C J ;:.:;(;m·FI- (;:0 YO;:.YNUD ( 1 ) V 1 ;;:YNLJll ( r! ) t'.:J9~* (C I-CO) A2:..:.3.*F§CO Al=Yl -YO-+·Jt(2. *CO+Cl) AO~YO v tlF::.;..:! UU·-;::;( (3. *A:iIl-SF+2, *A2)*SF+Al )/DX

40 !l'::':( XL<lL) -XNOD<I 1» IDX llYL( 1L.):"< C:L *A3*S+2. *A2)*S+Al) IDX YL n L ) :.;; ( (A:U'S+A2) *S +A 1 ) *S+AO H;:.:lLl-l IF (J L. G''-' NL) GOTO 90 H~ (XL (l L). LE. XNOD (12» GOTO 40 G01U ~iO

C BelJolld labt XNUll

Page 45: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

(; ~Cf. F1N:

C 80 UYl.- ( I L ) :;;{).

YL ( 1 L.) ""YNOU ( NNDD ) lL=IL"l IF (H. U:~. Nl) GDTO 80

C C All cJc.me C

C;O HEfUHN l:NU

Page 46: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

C SPCF12.FTN: C C This progra. interpolates 1/4 circle bU spline functions. C whith a fir~t derivative boundaru condition and a second one C respectivlu at the entrance and the exit of the set of knots. C The speed is constant. C The suhroutines BIAC and BIAVLl are the same a. in SPC.FTN. C The variables are: C N: nu.ber of knots. C ~: constant angular speed. C LD: length of the straight line before entering C the circle. It must be smaller than R*TETA. C R: radius of the circle. C TETA: angle between each knot. C PAS: tiae between each set point. C We displau to the screen th curve YARG-fCTARQ). C C C

c

C

C

c

c C

BLOC~ DATA C~ IFNAMESI Nl(20),N2(20)

DATA Nl I 'SPCF','. I ',IB*' , I, * fQ I "SPCF " '. Hi, IB*' , I am SUBROU11NE FUNCT (TARQ,VARQ,NP,OK,QEQ,IRES) REAL TARQ(500),VARQ(500),QEQ(1) INTEGER NP,IRES UlQICAl.. OK

REAt.*R ~,LD,R,TETA,TETAO.ANQ,T,VALVR,VALZR, * V AtVL,VALZL, DVLF, DZLF,PAS

REAL*a X(50),Y(SO),Z(50),XB(10),YB(10),ZB(10), *XREF(400), VREF(400), ZREF(400), CY(50), CZ(5Q), DVREF(400), *DZREF(400),DR(SOO),XREF1(500),TT

IN1E.QER 1,1'.1.1'.2, K, ITVPEL, ITVPER, N, 11.~, I"AX, 12, NP, KL

Nr''Oe G ( J ) OtI=GfQ(2) LD=..:QEQ(3) R=QEQ(4) TET A..,.-QEQ (5) PA£FQEQ(6) T=TF1'A/ot1 TT=1.570796327/0" IF (l D. NE. 0) GOTO 13 TETAO":T~"A Q(1l0 14

13 TET 1\0",- (R* TEl A-LD ) IR 14 l (1);:-0

Y( 1 ):<.0

X (1 )""0 1=2

15 AN(,}:lE1AO+TETA*(I-2) IF (I\NG.GT. 1.570796327) GOTO 16 X( 1 )=( I-I )*1 V( I ):-R-R*DCOS(ANQ)

Page 47: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

C SPCF12. F1N:

Z(I)=LD+R*DSIN(ANQ) 1=1+1 OCTO 15

16 IU==I K2=1+6 DO 19 K=Kl, K2 X(K):::CK-l)*T YCK)=R*CTETAO-0.570796327+TETA*(K-2»

19 Z(K)=R+lD ITVPELIO'" 1 ITYPER~:2

1=0 KL==O

19 ANG=TETAO+TETA*(I+(N-2» IF (ANQ.OT. t. 570796327) OOTO 20 YALYRv.R* (DM**2 > * DCOS(ANO) YALZR=-R*(0I1**2>*DSIN(ANQ) OOTO 22

20 YAL YR=-{) YALZR=O

22 IF (I.NE.O) OOTO 24 YALYL='-O YALZL=R*tm OOTO 25

24 YAL YL=DYLF YAl..ZL='DILF

25 DO 26 K=l,N 11==-I+K XB(K)a:::X(ll) YB(K)r-Y(ll)

26 ZB(K>=Z (11 ) CALL BIAC (CY,XB,YB,N,DYREF,ITYPEL,VALYL,ITYPER,VALYR) CALL BIAC (CZ,XB,ZB,N,DZREF,ITYPEL,VALZL,ITYPER,VALZR) ~ .. O

30 ,J=.J+l XREF(~)·~AS*~+T*I IF (XREF(~).LE. XB(2» OOTO 30 IMX=.J-l CALL B1AVll (CY, XB.YB,N, XREF,YREF,DYREF, IMAX,DVLF) CALL BIAVLl (CZ,XB.ZB,N,XREF,ZREF,DZREF,I~X,DZLF) IF ( XREf (1 HAX >. OT. TT) OOTO 40 K==O 12:0=1+1

32 IF (K.OE,. IHAX) OOTO 34 K=K+l KL=KL+l DR(KL)~R-DSGRT«R-YREF(K»**2+(ZREF(K)-LD)**2) XREFICKL)=XREF(K) GaTO 32

34 1=1+1 ooTO 19

40 OK:::. TRUE. NP=KL DCI 50 1::.'1,. TMG(I)~XREF1(I)*OM-TETA+TETAO YARG( 1 ):::oDR (J )

50 CONT I N\.JF Rf:T\JRN F.::NU

Page 48: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

C C C C C C C C C C C C C C C C C C C C

C

c

C

C

c c

SPDF1. FTN: ,

The p~og~a. inte~polates 1/4 ci~cle b~ spline functions .hith 3 knots given on a st~.ight line Just befo~ the ci~cle.

The baunda~~ conditions a~e given b~ the fi~st de~ivatives, and the speed is constant.

The sub~outjnes B1AC and BIAVLl a~e the .ame •• in SPC.FTN. The variables a~e:

N: nu.b.~ of knots. OK: constant angula~ .peed. LD: length of the st~aight line befo~e ente~ing

the c i~c Ie. It must be .malle~ than R*TETA. R: ~adiu. of the circle. TElA: angle between each knot. PAS: tiae between each .et paint.

We displav to the sc~een the cu~ve YARG-f(TARG).

Bt...QCK DAl'A COMMON IF~SI Nl(20),N2(20)

DATA Nt I '&PDF', i. 1 i, IB* I , I, * N2 I '&PDF i, '. H " IB* i '1 END SUBROUTINE FUNCT (TARG,YARG,NP,OK,GEG, IRES) REAL TARG(500),YARG(500),GEG(1) INTEQER NP,IRES L(.JgI CAL OK

REAI._ OM, l,n. R, TETA, TETAO, ANG, T, VALYR, VALZR, *YALVL,VAL2L,DYLF,DZLF,PAS,ZREFl

REAL X(5Q),Y(50),Z(50),XB(10),YB(10),ZB(10), *XREF(400), YREF(400), ZREF(400) , CY(50), CZ(50), DYREF(400), *DlREF(4QO),DR(500),XREF1(500),TT

IN1EGER I, Kl, K2, K, ITYPEL, ITVPER, N, 11.,J, IMAX, 12, NP, KL, NI

N=OEQ(l) CJfIf=...-QE.Q ( ~ ) LD=QEQ(3) R=OEQ(4) TETAl::'geQ( :;,) PAS=QEG(6) 1"II:>T£TI\I0I1 Nl=#-l 1'1'=1. 570796327/011+9*T

IF (lD.HE.O) GOTO 10 TE1"AO"'1ETA Q(JTO 13

10 U::"T AO=-· ( R* Tf! T A-LD ) IR 13 DO 14 1:.:1, Nl

X(I)=(I-l)*T Z(I)=R*fJtIf*X(l)

14 Y( 1)=0 I="4

Page 49: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

C SPDFI. F1N:

15 ANQ=TETAO+TETA*CI-4) IF (ANg.QT. 1.570796327) GOTO 16 XU )==( 1-1 )itT V(I)=R-R*COSCANG) Z(I)=LD+ZC3)+R*SIN(ANG) 1=1+1 QOro 15

16 Kl=l ~;:J+l0

00 18 K=::Kl, K2 XCK)"'(K·-l'*T VCK)=R*(TETAO-O. ~70796327+TETA*(K-4»

18 Z(k)=R+Z(3)+LD 1 TVPEL= 1 ITVPER=1 1=0 IU-=O ZREFtr-7.(3)+LD

19 ANCFTETAO+TETA* I IF CANG.QT. 1. 570796327) GOTO 20 VALVR~+DK*SIN(ANQ)

VALZRLft*DK*COSCANQ) QOTO 22

20 VAL VR=R*DI1 VALZR=O

22 IF (I.NE.O) GO TO 24 VAL VI-::::()

VAI~ ZL:..:R *OM GOTO 25

24 VAL VL::::J)Vl.F VAlZL:..-DZl.f

25 DO 26 K=l,N 11=I+K XBCK)=XCI1) VBCK)=YCJ1)

26 ZB(K)=Z<ll) CAlL BlAC (CY,XB,YB,N,DYREF,ITYPEL,VALYL,ITYPER,VALYR) CALL BIAC (CZ,XB,ZB,N,DZREF,ITYPEL,VALZL-ITYPER,VALZR) ..1--0

30 J=~+1 XR£F(~)=PAS*~+T*I IF (XREF(~).LE. XB(2» GOTO 30 l""Xr.~1 CALl., B1AVLl (CY, XB, YB, N, XREF, YREF, DYREF, IMAX, DVLF) CAl,L B1AVLl (CZ, XB, ZB, H, XREF, ZREF, DZREF, IMAX, DZLF) IF (XREF(IKAX).QT.TT) OOTO 40 K=O 12""1+1

32 IF (K.QE. lHAX) GOTO 36 K:::.t<.+l KL=«L+l If C1REfCIU. LE. ZREF1) GOTO 33 IF CVREF(K)' GT. R) GOTO 34 DRO<'L)::,R-SGRT( (R-YREF(K) >**2+(ZREF(K)-ZREFl >**2) QOTO 3:>

33 DR(KL )=YREFCK) 0010 35

34 DR(KL)"7REF1+R-ZREF(K) 35 XREFl (Kl.)=XREF(K)

QOTO 32

Page 50: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

Qt'1Jt- J. t- IN:

36 1=1+1 QOTO 19

40 OK=-. TRUE. NP=KL DO 50 J"'"l,'" TARG(J)==XREF1(I) VARG( I )=DR (I)

50 CONTINUE RETURN END

Page 51: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

C SPSF'". FTN: C C This p~og~am inte~polates 1/4 ci~cle bV spline functions, C with fi~st de~ivative bounda~v conditions and a ~ange of speed. C The va~iabl.s a~.: C N: nu.be~ of knots on which the inte~polation will be done. C ~X: .. ximum angular sp.ed to ~each. C ~X; .ngula~ acceleration C R: ~adius of the ci~cl. C T: tl •• between each knot C PAS: ti •• b.tween each .et points C Th. sub~outin.s BIAC and BIAVLl a~e the .ame a. 1n SPC.FTN. C We displav to the .c~een the cu~ve YAR9-fCTARQ). C C C

C

c

c

C

C

c

c

BLOCK DATA C~ IFNAMESI Nl(20),N2(20)

DATA Nl / 'SPSF I. I. I I, IB* I '/,

* N2 1 'SPSF I, '. H " 1 B* I '/

£HI)

SUBROUTINE FUNCT (TARG,YARG,NP,QK,GEG,IRES) REAL TARQ(5QO),YARG(500),QEG(1) INTEGER NP, IRES l..09ICAl OK

INTEGER N,I,IA, ITYPER, ITYPEL,Kl,K2,K,KL,I1, 12, * ~,l~X.NP,KA

REAL.*a ,'1, T1. T2. T3, TETA1, TETA2, *YALYR,VALZR,VALYL,VALZL,DYLF,DZLF

REAL*B X(100),Y(lOO),Z(100),ANQ(100),XB(10),YB(10), *lBC10),CY(10),CZ(10),XREF(400),YREF(400),ZREF(400), *DYREF(100),DZREF(100),DR(5Q0),XREF1(500)

N-.. =OEQ( 1) ~XII"QEQ(2)

AKA X =GEG (3) R&:CEQ(4) 1r~(,H5)

PASr«Q(6) 11=YMAX/AKAX TI=(1.570796327-AMAX*(Tl**2»/VMAX T2=Tl+11 r~*l"l+TI TEl' A 1 ="AMAX * ( T 1 **2 ) 12 lE"TA2:=:TE'TA1+(1.570796327-AMAX*(Tl**2» IF (TI.GT.O) GOTO 08 WAllE" (1,06)

06 f'()RMAT ('Tl OR Tl . LE. T') 08 XU ):=.0

Y(l)::;.O 7, (l )=:;0

I=';~ JA",'1

Page 52: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

c

c

SPSf-. fTN:

10 X(l)""'<I-t)*T IF (X(I).QE.T1) GOTO 12 ANQ(IA)=AKAX*(XCI>**2)/2 Y( I )=ft··R*DCOS(ANGC IA) ) Z(I):R*DSINeANG(IA» 1=1+1 1A=IA+l goTO 10

12 XU )&::;(I-1)*T IF (X(I).QE.T2) GOTO 14 ANQ(IA)aTETA1+(X(I)-Tl'*VHAX Y(I)=R-R*OCOSCANQCIA» Z(I)=R*OSIN(ANGCIA» IA=IA+l 1=1+1 goTO 12

14 X(l)=;(I-l)*l IF (X(I).QE.T3) GOTO 16 ANQ(IA)=TE1A2+(VHAX-AHAX*(X(I)-T2)/2)*(X(I)-T2) Y(t)~-R*DCOS(ANGCIA» 2(1)=R*OSIM(ANG(IA» IA=IA+l lal+l goTO 14

16 14.1=1 14.2=1+6 DO IS 14.=14.1. K2 X(K)=T3+(K-kl)*T YUc.)=R

IS ZUU=R ITVPS_""1 ITVPER=-1 I=:0 KL=O KA=N IA=M-l

20 IF (KA.QE.K2) GOTO 42 IF (X(KA).QT.Tl) GOTO 21 VALYR=R*DSINCANO(IA»*AHAX*XCKA) VALZR=R*DCOS(ANG(IA»*AHAX*X(KA) 0010 24

21 If exeKA). QT. T2) GOTO 22 VALYR=R*DSINCANQCIA»*VMAX VALZR=R*DCOSCANGCIA»*VMAX OOTO 24

22 IF (X(KA).QT.T3) GOTO 23 VALYR=R*DSINCANG(IA»*(VMAX-AMAX*(X(KA)-T2» VALZR~*DCOS(ANG(IA»*(VHAX-AHAX*(X(KA)-T2» QOTO 24

23 VALYR=O VALZR=O

24 IF (I.NE.O) OOTO 26 VN...YL=O VALZL::.;O cmTO 27

26 VALYLr.:;;DYLF YAL2L=D21. F

27 DO 28 K"-'l. N 1 1", I+K

Page 53: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

XBUO=XC 11) VS(K)=Y(Il)

28 ZBUO==Z(Jl) CALL BIAC (CY,X8,Y8,N,DYREF,ITYPEL,YALYL,ITYPER,VALYR) CALL BlAC (CZ,X8,Z8,N,DZREF,ITYPEL,VALZL,ITYPER,VALZR) .Jc:O

32 .JcJ+1 IF (~.OT.400) OOTO 33 XREFeJ)r.pAS*J+T*I IF (XREF(~).LE.XB(2» OOTO 32

33 UIAX",J-t CALL B1AYLl (CY,XB,YB,N,XREF,YREF,DYREF,IMAX,DYLF) CALL B1AVLt CCZ,XB,ZB,N,XREF,ZREF,DZREF,IMAX,DZLF) 1<.-0 12=1+1

34 IF (K.OE. I~X) OOTO 36 1<.=4(+1 1U..=KL+1 DR(KL)=R-DSGRT«R-YREF(K»**2+ZREF(K)**2) XREF1(KL)=XREF(K) QQTO 34

36 1=1+1 KA=KA+l lA=IA+l QQTO 20

42 OK::. TRUE. NPr.KL DO 50 1=1," IF (XREFI(I).QT.Tl) OOTO 44 TARQ(I)~~X*(XREF1(I)**2)/2

CKlTO 4S 44 IF (XREF1(1).OT.T2) OOTO 46

TARQ(I)~1£TA1+(XREF1(I)-Tl)*V"AX Q()TO 48

46 IF (XREF1(1).OE.T3) OOTO 47 TARO ( I )=TE1°A:!+(YMAX-AMAX*< XREFI < I )-T2) /2)*< XREFI (I) -T2) Q() TO 48

47 TARO(I)~1.570796327 48 YARO(I):DRCI) 50 CONTINUE

RETURN END

F

Page 54: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

oArlc t-'W(I(;WAM AS St-'(;f". t- TN BUT THERE IS A KNOT

C SAME PROGRAM AS SPCF.FTN BUT THERE IS A KNOT C AT THE ENTRANCE AND THE EXIT OF THE CIRCLE. C 114 CIRCLE C FIRST DERIVATIVES -LAST AND FIRST POINTS ON THE EXTREMA C C

c

c

c

C

C C

BLOCK DATA C~ON IFNAMESI Nl(20),N2(20)

DATA Nt I 'SPCF',', I " 19*' , I, * N2 I 'SPCF', I. H ',19*' '1

END SUBROUTINE FUNCT (TARG,YARG,NP,OK,GEG, IRES) REAL TARG(500),YARG(~OO),GEG(l) INTEGER NP,JRES UJQICAL OK

REAL*9 OM,LD.R.TETA,TETAO.ANG,T,VALYR,VALZR, *VALYl,VALZL,DYLF,DZLF,PAS

REAL*a X(50),Y(~0),Z(~0),XB(10),YB(10),ZB(10), *XREF(4~O),YREF(400),ZREF(400),CY(~O),CZ(50).DYREF(400),

*DlREF (11,00) , DR ( ~OO), XREF 1 (500), TT

N:-QEO( 1 ) [)fII::;GEG (2) 1,Jr--GEQ(3) R:..'QEG(4 ) 1'F1A="QEQ(5) PA&·QEQ(ll) l'==-TF1'A/otI IT=1.S7079032710M If- (lD. NE,. 0) GO TO 13 l'E'rA()='~TI::1A

QOm 14 13 lF1AOr.: (R*lEl'A-LD)/R 14 2 Cl )::0

Y( 1 );;;0

X( 1 ):·0

1"'''2 15 ANQ~lclAO+lfTA*(I-2)

IF (ANQ.QE. 1.~70796327) GOTO 16 X( I):=::( 1,-1 )*'1 Y( 1 )::R -R*DCOS(ANG) l(J)=LD+R*DSIN(ANG) 1=1+1 G01"0 l!i

16 Kl='l K?=I+6 DO 10 K;.KJ.K2 X(K)~(K-?)*T+(1.570796327-TETAO-(Kl-3)*TETA)/OM Y (K)::: k+Rltl E-1 A* (K-Kl )

1 B 2, ( K ) =L D foR ITYPEl '" 1 l'-YPf:R~l 1 :C'O KL "': 0

Page 55: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

C SAME PROGRAM AS SPCF.FTN BUT THERE IS A KNOT

19 ANQ::TE1AO+1ETA*( I+(N-2» IF (ANG.QE. 1.'70796327) GOTO 20 VAL YR::o-R*DM*I1SIN (ANG) VH_ZR~R*OM*DCOS(ANG)

G01-O 22 20 VAL.YR:;-;R*OM

VALZR==-O 22 IF (I.NE.O) GOTO 24

VALYl.=--O VALZL=-R*<lM QOTO 2~

24 YALYl::cDYlF VALZL::::DlLF

2' DO 26 K:::l.N 11==I+K XB(K)=-X(ll) YB(K)~Y(ll)

26 ZB(K):=;Z(]I) CALL BIAC (CY.XB,YB,N,DYREF,ITYPEL,VALYL,ITVPER,VALYR) CALL BJAC (CZ,XB,ZB,N,DZREF,ITYPEL,VALZL,ITVPER,VALZR) J:::O

30 J::-;-J+l XRf:F (J)=<"PAS*J+T*I IF (XREFeJ).LE. XB(2» GOTO 30 lK!\X=-J-l CALL BIAYLl (CY,XB,VB,N,XREF.YREF,DYREF,IMAX,DVLF) CALL BIAVLl (CZ,XB,ZB.N,XREF,ZREF,DZREF,IMAX,DZLF) If (XREF (lMAX >. GT. TT) GO TO 40 K~O

I2=IH 32 IF (K.~f. IMAX) GOTO 34

K=-K+' KL""Kl+l DR(KL)~R-DSORT«R-YREF(K»**2+(ZREF(K)-LD)**2) XREF1(Kl'~XREF(K) QOl'O 3:?

34 I~I+j gOTO 19

40 OK=. TRUE NP=KL 00 50 l~J,NP TARG(I)=XRFF1(1)*OM-TETA+TETAO YARGO )::.000)

50 CONTINUE RE1URN FND

Page 56: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

c JLF. FlN:

C Il.F. FTN: C C This subroutine calculate. the linear interpolation C of a 1:4 circle with a range af speed. e The variable. are: C VKAX: maximum angular speed to reach C ~X: angular acceleration e R: radius 0' the circle e T: time between two knots e PAS: angle between two set point. e We display an the screen the curve ERA1-'(ANG1). C C C

e

e

c

C

C

c e

BLOCK DATA C~ IFNA~SI Nl(20),N2C20)

DATA Nt I 'ILF.','I I,lB*' '1, * N2 I ' ILF. " 'H " IB*' '1

END

SUBROUTINE FUNCT (ANG1,ERA1,NP,OK,GEG) REAL ANQl(5QO),ERA1(500),GEO(1) INTEQER Nfl LOQICAl OK

REAL *8 lC (J 00) , ANG ( 100), X ( 100) , Y ( 100) , TARG (1 00) I * XREF ( lOa) , YREF (1 00 ) , ERA ( 100 ) I * XREF1(500),YREF1(500)

""" X r.QE 9 (J ) AMX=QEG(2) R=QE9(3) T=O£9(4) PAS==GEG(5) Tl~X/N1AX

TJ~(1.5707~b327-AMAX*(T1**2»/VMAX T2=T1+11 T3==>;1*T1+TI TETA1=AMAX*(Tl**2)/2 TETA2=-lE1Al+(1.570796327-AMAX*CT1**2» If (TI.91.0) GOTO 08 WRITE (J, 06)

06 FORMATC'TI . LT. 0') 08 1=1 10 TC( 1):: (1.-1)*T

IF (TeO)' Q1. T1> GOTO 12 ANG( J )::-Af1AX*(TC (I )**2) 12 X( J ):..ft-R*JlCOSCANG( I» Y(l)~R*DSJN(ANG(I» 1=-1 + J GOTO :to

12 TC( I)=-(] --1 )~T IF ClC (] ). 91. T2) GOTO 14 ANG( J ):;·TFIA1+(TC( I )-T1 )*VMAX

Page 57: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

c JLf-. F-1N:

X(I)=R-R*OCOS(ANQ(I» YCI)=R*DSINCANQ(I» 1r.I+l GOTO 12

14 TC(l)t::"·(l-l)*T IF (TCCI).QT.T3) QOTO 16 ANQ(I)::-lE1A2+(VMAX-AMAX*(TC(I)-T2)/2)*(TC(I)-T2) X(I)=R-R*DCOS(ANQ(I» Y(l)=R*DSINCANQ(I» 1=1+1 QOTO 14

16 N=I-l L=-'l K==1 1=2

17 Jet 18 TARQ(J):.-ANQ( 1-1 )+(.J-l )*PAS

XREF(.J):;.~-R*DCOS(TARO(.J»

IF (XRE.F- ("'). QT. X (I» QOTO 20 .J=.J+l OOTD lB

20 IMX:r·J-l DO 22 Kl~J,lMAX VREF(Kl)~Y(1-1)+(Y(I)-Y(I-l»/(X(I)-X(I-l»

=-(XREF(Kl)-X(I-1» XREF1(K)=XREF(K1) VREFl(K)~YRFF(Kl)

ERA(Kl):;.R-DSGRT«R-XREFCK1»**2+YREF(Kl)**2) ERA1 (K)=-ERA(K1) ANOt (K)::.lARCHKt)

22 K::4(+1 1:.;1+1 IF (I.LE.N) OOTO 17 OK;:::.l"RUE. NP=K-l RETURN END

Page 58: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

c SPWf. f-TN:

C SP'-F. FTN: C C C This program interpolates a waving curve A*SIN(X(I» C b~ spline functions. C The boundary conditions are given by the first derivatives. C lhe subroutines BIAC and BIAVLl are the Same as in SPC.FTN. C l'he paraaeters are: C N: number of knots C ~: angular speed C T: time between two knots C PAS: angle between two set point C A: amplitude of the waving curve C We display on the screen the curve ERA1-f(XREF1). C C

c

C

C

C

C

C

Bl.OCK DA1'A COf'QIION IFNAJlESI N1(20). N2(20)

DATA Nt I 'SPWF'.'. I ;, IB*' , I, * N2 I 'SPWF' I '. H ',1 B* ' , I

END

SUBROUTINE FUNCT (XREF1,ERAl,NP,OK.QEG) REAL XREF1(SOO),ERA1(500),GEG(1) INTEQ'ER NP LOQICAL OK

RF . .AL*8 OM. 1, PAS. A, VALVR. VALVL, DVLF

REAL*S X (l 00). VClOO). XB (10), VB (10). CV(10). XREF(100), * VREF(100),ERA(100).DVREF(100)

N=:QEG(l ) QI1=QEQ(2)

T=GEQ(3) PAS=r:-GEg ( ... ) (V:OEQ(S.)

K=t 1(2=-. I TYPE:.1..'"' 1 ITVPER~l

00 10 ]= .. 1, 100 XC I) =-Of1*T* ( 1-1)

10 Y(I)=A*DCOS(X(I» 1=0

11 1=-1+1 VAl. VR=-A*OM*DSI N (X (I +N-l ) ) IF (I.NE. 1) GOTO 12 VAl VL "'.0 QOlD 14

12 YALVL::DVLF 14 DO 16 ,-,=j,N

K=J+'-'-l XB('-')=X(K)

16 VBC'-')::..V(K) CAll. BlAe (CV, XB, VB. N. DVREF, ITVPEL. VALVL. ITVPER, VALVR) t::,·o

Page 59: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

C C

Qrtw". ,.t ... :

18 L=L+l XREF(L)=PAS*CL-l)+T*OM*(I-l) IF (XREF(L).LE. X8(2» QOTO 18 IMX=L-l CAl.L B1AVLl (CY, XB, YB, N, XREF, YREF, DYREF, IMAX, DYLF) DO 20 Kl=l,IMAX ERACK1)=A*ncOS(XREFCK1»-VREFCK1) E.RAl(K2)=-E.RACKl) XREFICK2)=XREFCKl)

20 K2=tU?+ 1 IF (J.LT. 10) QOTO 11 .=«2-1 OK:::., TRUE. RETURN END

Page 60: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

thrse following files give ~ou all the informations

These following 'iles give ~ou all the informations about the parameters used in the programs.

If one of the parameters is changed when running a program, the new value appears on the column 0' the drawn. We can modify each para.eter as we want.

First ap~ears the names of all the variabiesl then the initial values of these variables Con the same line and separated b~ • blanc), then the names of the two axes of the drawn and, to Finish, the initial values for the graphic function.

Content of the file SPCF. I:

N OM(T'ad/s) LD R TETACNuf) PAS(s)

4 1. O. 1. O. j 0.01 ERROR-VALUE ANGLE-VALUE

o 0 100

Content of the file SPSF. I:

N VMAXCrad/s) AMAXCrad/s/s) R T(s) PAS(s)

4 1. ~70796327 5.235997756 1 0.10.005 ERROR-VALUE ANGLE-VALUE

o 0 100

Content of the file ILF. 1:

VMAXCrad/s) AMAX (rad/sl!.) R T(s) PAS(rad)

1.57079632, ~.235997756 1 0.10.005 ERROR-YALUf. ANGLE -YALlI{';'

Page 61: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

o 0 100

Ihe~e following files give ~ou all the informations

Contr.nt 0' thr. file SPWF. I

N OM(rad/s) T(s) PAS(rad) A

4 1.256 0.1 0.025 2.~ ERROR-YALUE ANGLE(rad. )

o 0 100

Content 0' the 'ile SPDF. I:

N OM(rad/s) tD R TETA(rad) PASts)

4 1. O. 1. 0.1 0.01 ERROR-YAl.lIE TIME-VALUE.

o 0 100

Page 62: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

.----------------------- - .-

ERROR-VALUE .' , ' , '

, I I • I • , .

: r\ ~ ,I \. : I \l l! i

R

1.

:, 1/

. 0~ ~0~---1;. 2)Q0;----.-l;4fl0 ---a ~G0~--~. 8~0:------;1:-L.~00~----;-1.L. 2~0~.:I!.--J---:-=----1 . G0 ~.~. ____ ..

1.00

-I .SfL

.00

. , . , , , I , ' \:'

--------~--------------------------.----

3.

k

LL U () (/1

If! 10

Page 63: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

~~~~VALUE

. 80

.60

.40

-', , , , , , , I , I • I , , .

I • I , I , , ,

I , I I , , I • I , I , , . I , I I I I I • , , I \ I • I I

: \ , . I ,

: '\ '. : I \ \ : I \ \ : I \ \ : I \ \ : I \ \ ,I \ \ :1 \ \ if \ \ ., \ ' ~ \ \

\ " I \ I \ 1 ~ / \ 11 "

\ ~ / \ \ / \ \ / \ ,/ I :

I I " I

, I -, ,

I I , ,

'. , . . I . , , .

\ . , · · · \ \ //--"""""::':~ _----.... // ANGLE-VALUE

_1.-:::2:-;:::::0---"-'-""'fl--;:;-;::;-t---7if-'::. 2::::::0~\~/-,-r-. '-:-4 0=---'-:'/"'"'" .~b~0=-=----. 8~0~~--~--~-T:-'-~--==-OO:::-·-------__ -..:.::::;,-"""\,L..-2-=0-=:::....".J-.-4-:c-0 ---'1. 60 \ \ I /1 \

\ I I ' \ I \ 't / \ I \ /'. / \ I '_'/ \ ;' , I

\'" / \ I '- / \ /

\._/ -.20

'-.40 ,

TET A( rucJ )

0. 1

0.2

0.3

o

U

LL U Q (fl

L W (f)

o (Y

(Y)

L0

Page 64: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

~~~VALUE

.80

.60

.40

.20

,', , , I ,

I ' I , I , I \ I \

I ' I \ , ' . \

I ' I , I \ , \ I I I I I I , \ . \

• I , I , ' , \

\ \ , I , \ I \ , \ I \

: f\ \ : I \ \ : I \ \ : I \ \ ; I \ \ : I \ I

II \ l,

;1 \ " ;1 \ ; :1 \ \

~ \ : \ \ I " I I,

\ I

\ \ \ \ \ \ \ \

,20 \ \

\ I I \ l ,_/ '\

\

-.20_

'-.40

.80 ,

'_ .. " .

I , /__ I

1""- .... , ' , ' , \ I \ , \

I \ I \

I \ I \

, I I \

, I I I

I I , I

I I I , I I

I "

I I • I

I I I I

I I I

/ '\ /

/ \'-/ \ ..

// \/ 1.00 /\.20

,: \ " \ -' \ I

\ I \ I \ I \ I \ I \ I \ I \ I \ / \~/

GLE::~VALUE

TETM rad)

0.1

0.2

0.3

1.60

k

o z o U

N

Page 65: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

-.20

E~tf~ALUE

J<"'''\ I ,

I I I I

.40 / \ I I , , , , , ,

I , , I I \ I \ , \ I \ I \ I \ I \ I \ I \

.30 ! \ I \ I \ I \ I \ I \ I \ , \ I ,

I \ I \ \ \ \ \ \ \ I \

.20 J \ , \

: I' 1\

: / \ ; I , \ '\

I \ \ I \ \ I \ i I \ \

.10. 1 \ \ \ \ \ \,

\ \

\ \, \ ; \ \

\ ... \ ; --- -'---'--

-. 10

-.20

~\20 \ // .40 .. ,,// . 60-\ 'v '\..-..-/~

\ \ \ , , ,

\\"

, I

; , ,

.80

Arfe c\iX K TET A( rud)

0.1

0.2

0.3

o 2 o U

N LL U 0.. (/)

Page 66: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

ERROR-VALUE

_ .001:;-;:;:----~::--_--7:i ::--___ ~-----'::-::----___:_~----LI ______ ,;.A~N~G~L~F_+-~A~LU_r__.J. . 0 .20 .40 . G0 .80 1 .00 1 .20 1 ,G0

------------.----~,---------~---.--.,-,---",,-,---.. -".

:> uJ (/ I

f; (y

L' C\)

Page 67: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

.4

.20

• 1

ERROR-VALUE

, / \ , ' , ,

, ' , , , ' , , I ,

I ,

,

" , , , , I ,

I I

I I , ,

I ' I

, ' I I

I \ I I

I I I ,

/ " , , / \

I I I I

I , I ,

// ..... '" / \ I \: ,

I \ : '. f \: \

f ~ , I I \ ' ,

/ \ \ t I : \" : I : \ I I

/ I

I I

I I , , ,

I I , , , , ,

I I I

f I

I : \ ' /----" f " \ .. ./ ! ", I " \ .. // :" I / \ \, / : \ I , \ / I \

,

,,//' ..... I

I \ / : " O I ' . / ,: " . 9~~~~==~~'=---~\~~~=-~~=-~--~~----~~~~==~~~~~~~~==~~ o I • 2~ • G0 / '''-... y:00 1 • 20 '--1-~-4~( 1 • G0

I, \ ./ -- ___ / 1./ \ ./ I,. \ // I,: \"./

I' I I .... ,/'

\\ I /1 "-._.-'

~/ ,: ,

-.2

-) .-J

--------------------------

T( s)

• I

0.2

.3

Page 68: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

y. ~~X~1~0~-2~~ER~R~O~R-:V~A~LU~E~--------------------------------------------------~~~~iX ~ ~ .50 ..,

.40

. 3~L

. 20 .

- .20 .

rIME-VALUE 2.00 2.50

N

3.

4 •

5 .

Page 69: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

X10-2 .30

.20

.10

- .20

ERROR-VALUE

I · · I I

'\ I \ I I I I I \ I I I \ I

I \: I Ii

· · · • I • I I I

• I • I I I

• I I I . . \ .'

I'

I' I I I • I I I I I I I I I I I I I I I I I I I I I I I I I I I

I I I I I I I . I

I I I I I I

X-, " I \

I I " \ . I \ I

2~0~! \ \ f I Y \ I' .... :

I I I I • I I I I I I I I I I I I I I I • I I I I I I I I I

I I I I I I I I I I I I I I I I • • I

\.'

I I I

. , , 3.'50

TIME-VALUE 4.00 4.'50

T[TM roLl)

0.1

0.2

0.3

LJ_

( i (1 (J

OJ

Page 70: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

~.

r------------------------------------------------------------------------------X10-3 .30

.20

. 10

0--'

. - • 10

-.20

- ')(';\ .. v(J_

ERROR-VALUE

t\ 'I '\ , \ I I

I I I I I I I I

.1 I'I , I I I , I I I I , , , , , I , I , , , , ,

I , /~"-""'\ :

\ \ \ I \ I \ I \ I \ I \. .

~----------------------------------------

1.00

A II f I , I I I

I I I I I I I I I

I I , I ; I : ,l • 'I : ~l i ~ I I , I , : .

, . . . , I , , , I , I I I , , I I , , , . , , , , , , . / " "

TIME VALUE 2.50

LD

0.

0.02

0.04

n "2 () U

<S) (\J

(0 C'0

L0 co

Page 71: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

X10-2 3.00

2.50

2.00

1. 50

.50

ERROR-VALUE

I I

I I

I I

I I

: I

1 , I

I I

I I I

1 I ,

I I

I , I I

I I

I I I I ,

I I ,

I I I , ,

I , I I I , ,

I , I , , , , , ,

I I ,

I

/""'" 1

/ '\ I i\

I ' \ I \

I \ / : I

, .... / : I /" "'I j \

:' I' ! \ , I " I \

I '. I , ''. \

I , \ \

,/ ,'\ I

" , I , I

" ! I~ ~, /

/ I , ,

I

, "-'. , \

\ \ \ , , ,

\ \ \ \ \ ,

\ , \ , , ,

\ , \ I \ \ I \ , \ \

\ \ , \ \ , , \ , \ \ , \ I , \ , \ \ \ I , \ \ I I I \ , , , , , ,

I , I I , I I , \ ,

, I I , , ,

I , , , , , , , I , ,

"." .. -.. / ' " , , \ , ' , ' , \

I \ , \ I \ , \ , \

I ' I \ I \ , '

I \ , " : \ , ' , ' I \ I \ I \

I ' l t, I \ , \

I \ I \ I I , I I \ I \

I \ , ' , , I I I , ,

<'" -/ -, ! \

I \ ! \

,I \ " I \ , I \ ! I i , , I ! / II , I " I I " I \ : I \ " I \ : f \ if \ " I \ " I I

, , \ , , , ,

\

, , \ ,

, , , , I

I , I , , ", ,

\ I

\ : \ " V '\ : \

: \ . \ \ , ,

I

: I I ,

I , I , ,

\ \ I \ \ \ \ \ I i \ \ \

, \ \ \ \ \ \ \ ,

\ \ , ,

\ \ , \ I

, , I \ , , I

, I I \ I

T( 5 )

0. I

0.2

0.3

" \ I .00~ __ ~ __ ~~ ____ ~~ ____ ~~ __ ~ __ ~~~ __ ~~~ __ ~~~ __ ~~~~~~

.00

---_~ ____ -L~""""" _____ " ..

LL .. J

::> uJ (j'l

C) (Y

i'Y)

(0 o 1(1 ('0

Page 72: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

X10-3 .40 .-

<e .30

.20 -

.10

-.00 0

. 10

-.20 -

-- "40 -

- .50

ERROR-VALUE

\ I

20

\

\

ANGL[( rau. ) I ,

,40 .G0 . 8~ 1 00 1.20 1

\ ~ OJ

_._._-----_ ..... __ ._-

Page 73: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

.' ... , UV..1 .. I:.J\.I. IjLLI ... I'·II'';III.1.i..JI'~ \ .• W 11'11 ... 1·,.l .. iJ"j"'" 1 . .1..1'11,:. l'l\LJl .• ,I~.I.Jl.JI""t::.::i I, Fm~ Hiex 86 ~ tlU (':)f'PL.l:CI-Yl'HlNB. »:/

DWI'ATTACH : PFmCE[)Ur~E (P{\ TH!I>F' l' EXCEP!I>P) ~~C)fm EXTEI:;:NAL t DEC:LAI,C PAHNP P01:NTEI,; Dl:CU·\f~C EXCCF'!\>P POINTEr~ t END,

DQ$CREATE :F'ROCEDURE (PATH$P.EXCEP$P) WORD EXTERNAL~ DECLARE p~rH$p POINTER; DECL.!:)m:: EXCEP!f,P POINTEI:;: t END;

~U$D~TACH :PROCEDURE (CONNvEXCEF'$P) EX1ERNAL; DECLARE CONN WORD; DECUlf~E EXCEP~;P POINTE],. EI"O t

[)(:I$OPE1~: PI:"':CJCEDum:: (CON1~" (IaCCESS " NUI'hl;E:UF r EXCEP!f,P) EXTEF~Nf~\L t DECLARE CONN WORD; [)ECU~h:E ( (.1CCES~3 r NlJr"!~E:lJF) BYTE t DECL.ARE EXCEP$P PCU:NTER; EHDt

DUSREAD : ~:;:OCEDURE(CONN,8UF$F',COUNT,EXCEP$P) WORD EXTERNAL; DECLARE CONN WORD; I)LCL,!:)HE (BUF$P, E:XCEP~)P) POl:NTEJ~ j

DECI ... AI:;:E COUI'H worm; EHDj.

D(;j~>WI;\ITE PI:~ClCl::Dur~E (CONN I' E:UF!~P, COUNTvEXCEP1.P) EXTE}~NI;L; DECLARE CONN WORD. [)ECL.AF~E (BUFi'P" EXCEP~)P) P01.NTE];~ j DECLAI:;:E CDl.Ii~T worm; EI'~D ;

DU$CLOSE : PROCEDURE (CONN,EXCEP$P) EX1'ERNALi DECLARE CONN WORD; DLCLAHE EXCEP$P POXNTERi ENDt

DCl$EXIT ~ F'1~DCE:DlJl;~E ( EXCEP) EXTEF.:NAL t DECLARE EXCEP worm t Et·mj.

~>RESTOf~E .

Page 74: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

".. • bl au

/;i;;J.filT(.AI\;i ILL~:) i'·I;(ULl~.j)Ui~I;:: \,;i::, I ~::. :' I'I<U,'" Iii:, A STR(NG (IF ?ISC:n: cl;:lr~f1ClEl'~S •

i'ir12 ; DO;

~.I

/'11. DECLAI:;':(·\Tl:ON OF TI-\l::: I:;':UN--Tl:i'IE PROCEDUI:(Ef3 t OQ$ATT':'\CH: CF<EATES A CONNECT:r.ON TO AN EXISTJ:t·lG FILE.

, : CI: ': CONSOLE INI~'UT (EXISTING Fl:LI:;:). Cl: t NAt'lE OF THE CONNECTU)N.

DC~$OPE:N: OPEN (., PI:;':E:Vl:OUSL Y ESl ('~E:LISHED CONNECTION .. 1 NEANS r~EAD ACCESS L)NL Y • o S:IGNIFIES THAT NO BUFFEfU:NG SHOULD OCCUF<.

DQ~;'f~EAD: FETCHES D?\TAS nml1 AN OPEN FILE. E:UFFEf($PTf~ I:'o:nrrs TO THE (·\EI;:t1 WHEFi:E THE

ASC:II CI~HACTERS HILL. BE STORfm ~ 6 ~~PEC:I:FIE:S THE DESIHED NUl'1I:::Ef< OF BYlES TO

ElE I=i:EAD. DW~CL.OSE : WAITS FOF< COMPL.ETION OF 1/0 O/~'EI~:(fr:r()NS

TAKING PLACE ON THE FILE. DCi!~DET(~CH: t:lF<E(~I'(S THE: CONECTl:tlN ESTt!IE:LISHEO EW

DQ~~ATTACH.. ~/

~>INCLUDE ( : F 1 : U[)I .. EXT)

/~ C:l:: SEE ABOVE ST(·\TUS t worm v('~LUE Il~ WI·U:CH THE OPEI~/:.\rING SY~:;lEM

m::TUF<NS AN EXCEPTION CODE. ACTUAL i NUt'II:::!::!=( OF E:Y"rE TI:;:At~SFEF\I;~ED .. BUFFEr-< : SEE ABOVE. '#./

DECL(~I..:d ex wmm i DECLAf;:E ST iYl'US wmm; OECLARE BUFFER$PTR POD~TER; DECLPIRE (BUFF'I:~R E:ASED BUFFER$PTR) (6) E:YTE; DECLAI:;:E ACTU(.:.L WOI::':D t

CI:":DWI.ATrf~CI-I«!H.{h I :C:X:: I ) ,(!IST/;TLIS); CALL DQ$OPEN(CI,1~U~8STATUS)i ACTUAL-DQ$READCCI,BUFFER$PTR,6,@STATUS)1 C(")LL DQiI,CLOSE (CI" mST f%TUB) ; CI-4LL DWI>DETACH(C:X:,,@Sf'fi'T'US) t END INTC(·\F< ;. Ei'lD 11t12;

d _ t .. Jd , ..

Page 75: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

,.~. DUTtA.R. lil..l .. : Il··.' .. H.,I."i./L'I\.:. :0< .... 1,.':., ,,) .:0., ... ,i ... I \L.,L.l'! ,,1'/

fo\SC:r:l C'~aI:~'::ICTLI::':., x-:/

/'11. DECI_AI~'·\T:I:ON OF THI:;: F~UN--Tli,"\E PI;:OCEDUF<ES (SEE t U[)I. EXT) i D(~$CREI:'ITE: CHE,!iTES A CONNECTION TO AN EXISTING FILE.

I : CO: I: CONSOLE OUTPUT (EXIST1:NG FILE). CO t NAt'lE OF THE: CONi~ECn:ON.

DC~!~OPEJ~: PREP?IHES THE CONr~ECTION FOH ,,·mITE COI'IMANDS. 2 rlE/;'"NS WE HAVE A WfaTE ACCEBS ONLY. o SIGNIFIES THAT NO I:::LlFFERING SHOULD OCCUF~.

DQ$WHITE : Tf~ANSFEr·~s OAT A FIi:OM MAIN 1'1EI'iOI:;':'( TO A FILl::. 1 l:8 THE NUi'iBEI=i: OF E:YTE TO E:E I-UU:TTEN.

D(~\I;CLOBE : W{oiITS FOI::': COi'iPLET:rON OF I/O OPEI:~ATIONS TAKING PLACE ON THE FILE.

Dli!I.l,)ETACHE: BF~EI~I'(S THE CONNECTION ESTt-~E:LISHED BY DQ$CREATE. ~/

$INCLUDE(:FlIUOI.EXT)

OUTC(.\H : PRDCEDURE (...I) PUE:LIC t

/'11: ...I: ABC:r:I Cfo~lr<ACTEf~ TO DIBPL_AY TO TI .. II:: SCf~EEN. ST(.\TUS: WOfi:D IN WHICH THE: OPEJ~(. .. r:r:NG SYSTEM

RETLJHNS AN EXEPTION CODE. CO t SEE ~IE:OVE. 'K./

DECLAf~E ...J E~YTE: t DECL(.\I:;;£ CO ~ILJrm t DECL'::'f~E STATLJS WQI;~D;

C(J::;:I)Q~.CI:~EATE ({~ Ub I : CO: I ) , @~;rU~TUS) ; CI~L.L DU$OPEN ( CO ~ 2, () 'I £!!~iT ('~TUEi) ; C(:\LL Dti~a"'fUTE (CO I' @J, 1, @STATUS) j.

CALL DQ$CLOSE(COp@STATUS); CALL OQ$OETACH(CQ,@STATUS); END . OUTC'!lR t END t1Ml P

W':'~""'~~-""'_._"_'. ____ ~ __ ~"""t<. 'l1li we."" 1 1O£M4'. -141' . .

II

Page 76: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

,,:GETl.NT. '1ii..i..;;, ;··":UC.i ... U\.!I-·~i... LiI...I::, 1:1I··j j·:I-:A·L- .. U .. :: .. il· .. .i..r,\:J !'l,--UII lill:_ f'rr'"""'I-'\ '-I-(Cfl:ut'-IHO , C(:IL.l::Ul..(.~IlE~) .r: r~) :[NTt:GU~ W'IL.UE , AND PUT THE: CUI:<t)OI~ TlJ THE !~EXT Ll!..JI:::. ltV

/lKDECLAI;:ATIDN OF THE EXTEHNAI... PI:~OCE:DLJHES;

INTCAI;:: GETS AN f~SC:rI SnUNG FfWM THE I-(EY-ElOAI:;:O. (lUTC('~fi:: DISPLAYS TO THE SCr-<EEN ~li'i ASCII V{iLUE. ltV

INTCAI:< : PROCEDURE (E:UFFEF~~l>PTR) EXTERNAL; [)ECLf ... RE [:UFFEf~$PTl:;: POINTEI:": t ENDt

OUTCAR : F'ROCEDUF~E (J) EXTEHNAL t DECLAHE: J Ef'(n.::; O~D;

Gt::TINT ; PROCEDUF~E lJ'iTEGEFi: F'UE:LIC t

/:t<.CH I' LF ; ASC:U: VAL.UES. VALUE; INTEGEI;: VALUE OF THE ASCII SnU:NG. SnUNG: STFU:NC OF ASCII CAI;;:ACn~RS. 'N./

DECLARE. CI:;: LITEI~AL.LY t ODH I, DECLAI:~E LF L1 fERALL Y '0 AH I ;

DECLAI:":E VALUE INTEGEI;:; DECLARE STRING ( 6) E:YTE; m~CLAI:":E ( III .J ) E:YTE t DECLARE ~( WORD;

V(.tLUE :::: 0 t I :;: 0; I<:-~:O ; CI·)l..L l:tHC(.·IF< < (!~~rrl:;:Ii''''l;) ;. oJ =STHINC(O) AND 07FHa DU WHILE J <> CI~;'

J==STRINGOO AI"'D OlFH; If (d >r.: 30H AND

J <:::: 3<,1-1) THE:N DOt

l:F :r ":: 0 '1 HEN :r :;;; U VALUE ~ VALUE*10 + INT(J-30H);

END; ELSE DOt

l:F I .-.: 0 'j HEN DO.

IF J .•. I - ,

THEN DOi 1: :;;: -it

Et~1) ; IF J ;": '+' THEN nOi

I :;;: lt ENDt

E:ND, E:LSE DOt

J:::: I JK I t C(lLL. OUTCAI:;: ( .J) ;

VALUE"" 0; ,:r :::: 0.

END; r-'-~_"_£¥_._' "''''£ ____ , .1i"",l~iWoj', .. ') ' ..... _ • ..... ___ .... ,. __ ................ ___ .. _lJIt ____ 4_---___________ ,··..... k ___ _

Page 77: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

1<::;~(+1 t .J ;::; STI:::INGOO AND 07FH;

END, J::-~CI:;:t

CALL. DUTCAR(d); n:' I ::.;: '·1 THEN Vt!)LUE :::: 0 .•. VALUE; 1,=f:::TUI:":N VALUI::;

END GETINT; ENl.> t'it14;

Page 78: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

/'If. tlPM: 1'1-118 F'1:.:OGI:~'::li1 CF1L.CLJU~'IEH THE c.;OEFFICll::j~T!3 Ol~ A SPLINE FUNCTION)' DEFINED 8'1' FOUfi: I{NOTS, Ai-.!D RESTITUTES)' TO THE SCf\:EENI' THE VALUES OF THE SET POINTS BETWEEN THE TWO FU~ST I-{NOTS.. THE ENPLDYED NETHOD TO Cf"1LCUI_ATE THE COEFFIC]:I:::NTS IS THE S(.\NE (·\S THIS EJ1PLOYED IN THE: FOI:.:n;: ... '1N PRO(JI:;:':',rI SP:FTN. THE PROGF<?lN IS HRITTEN FOR (.\N 8086 APLICATION. ;.;(/

/)1; N 1/ X, Y 1/ CI;: , LF : DECLM~PITION OF THE 'o\Be:1:I Vp,LUES. VALL: LINI< BOUND,~,I=i:Y CONDITION .. VALR: RIGHT 80UNDARY CONDITION. CONTI: TEST Vp-ILUE TO I-(Nm..t IF THE Pf~OGRt'lM l-liUST CONTINUE .. COOY1: l:NTEGEfi: V(")LLJE OF THE HNOT mmClNATE. COOY : F~EI!-IL V':'ILUE OF THE I<NOT mmONATE. I:\U •••• A3: COI:::FFl:CIENTS OF THE SPL1:f..tt:.: FUNCTIONb.. '#../

DI:~CI_AkE N LITEf\AL.L Y I 4EH I ;

[)I::C:LAI~E X LIT Er-i:(.iLL Y I ~:;8H' ; DECLARE Y LITEf\ALLY '59H'; DECLARE CR LITERALLY 'OOH'; l)t~CLAI:~E LF LITER':"ILLY I 0(.11-1 I ;

D~CLARE VALL REAL INITIAL (0.); IX~CLf~RE VAU~ r~EAL t DECL.f\F..:E CONT1: E:YTE J:NITI(~L (5(1'1--1) t ()ECLAf~E COOy:r: ( .it) l:NTEGER t DECLAI':E COOl' (4) I:~E{'\L.;

DECLARE (AO,AlpA2?A3) REALi DECL~~E (Il,I,~) 8YTE;

/>KDECL.ARATION OF fiLL THE EXTEf~NAL PI:mC:EDur~E~3 t [)Q~>EXIT: Fl:NISHES A PI:;:OGF~Ar'1. GET:INT; GE:rs AN Asc:n: BTI::':ING nml"i THE ~(EY'-BOp,tm

PIND "H"ANSFOI:;:NS IT TO {'IN INTEGEF~ V(-\LUE. EXIINT t TRANSFor'::MS AN INTEGEI~ VAL.UE TO AN ASC1:I

STFnNG AND DISPLAYS IT TO THE SCt:~EEN. :rNTCAF< t GETS ?\N .!lsSCII CAI::':ACTEJ1: FI::':OM THE I<EY -E:OAI:m +

OUTe(.II:;:: DISPLAYS TO THE: SCI=i:EEN (iN ASCII CAI::':ACTER. '8./

DCH'EXrT' : PI:mCEDURE (EXCEP) EXTEf~NAL. ~ DECLARE EXCEP WORD; ENO;

GETINT : PI~OCEDum:: :[NTEGEF~ I::XTEI~N(1L; END;

EXIINT : PROCEDURE (1J'-'lLUE~~PTI~) EXTEI::':NAL t DE::CI_ARE VALUE:$PTI::': PO INTEl::': t END;

INTC(.\I::': : PHDCEDUI::':E: (BUFFEf~$p.;ni:) EXTERNAL; I)ECLI~RE E:UFFEHi>PTR POINTE};:; END;

OUTCAR :PROCEDURE (J) EXTERNAL' I)I:::CI_ARE ~ BYTE t ENDt

/)i;I)E:CL.,~F~(-~·n:CH" DF TI-II::: PPII:n:X:CUL"AI;: pr';:OCEDur~ES;

POINT: Pl:C~(S LIP THE: omn:NATE OF THE I-(NUTS • ... ".I1iI- .... """-.... ,,--~ ... -.,-.~- ---, --

Page 79: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

CALCC. ' ... "; ... '.'.;;,, , ....... ' "d,. < .. ',iI ... '. ", .• .. J; '. iI. ,;,' .. 1 ..... ' UI\:' ... , .. ',.Ji. nr(tF\~." ~ bL~.TWE:J:}~ THE Tl-!(J f'lRbl' t(i-lUTb.

SPL:r: CAI_CULI~TI:::S THE SET-'POINT Vi-~ll_UES (-iLL THE 5 I'\.S. AND DISPLAYS THEU~ Vr!iLUES TO THE. SCREEN. }IV

POINT : pr~OCEDURE (PY$PTR);

/».: TXT CONTAINS;: THE (.iSCII VALUE~1 OF LETTEl~S I PO:INT I. */

DECL~lf<E TXT (6) E:YTE DATA (501-II'''tFI··,,''t91-II'''tEH,:.'j41''1,51·:'H) t OE:CL(-'tRE PY$f'TR POINTER i DECLAI:<E F'Y Bf~SED PYlt)F'THLNTEGI::J~ t [)ECL(.\I:':E PYC: INTEGEJ~;:

DO I=O TO !;j i C('·\I_L oureAI=;: ( TXT ( I ) ) t

END, CAI_L OUTC,eIFi: ( Y) ; CI~LL OUT CAl:;: ( CR) ; CAL_L. OUT CAR (LF); PY::::GET1:NT; PYE;:'::f'Y;: CALL EXIINT(~PYE),

END POINT;

/>t.: TXT CONTAINS TI-Il:: ('~SCII VALUES OF THE LETTEI:;:S I CONTINUE: I •

STrUNG t STRING m:' ASC:I:I CAf~ACTEHB PICI-(ED FfWN THt:: r(E,( -E:()ARD +

J: ANSW~R (Y OR N) GIVEN BY THE USER. )K/

Dt~CI_Af~E TXT ( 9) EWlE DATA ("t~iH , "tFt-!, itEH I' ~j..ltH .. "'9H,~EH,5~H,~5H,3AH);

D£CLAf~E STKING ( 6) (lyrE; [)(J J~.;·O TO (~t

CALL OUTeAI:;: (TXT ( ..J) ) , ENI); C.:~L.L INTCAR ( litB'lT,ING) t 1:""0 ; .J:r~ST F(1NG ( 0 ) t DO WI-ULE J<>Y t:iND J<>N ;

J::::STI;:]:NG ( ]:) t 1::::1+1;

END; CI~:ILL OUT CAR ( J) i C,'·iLL OUTCAI:\ (CR) ; C{-)LL OUT CAR (LF) ; I;:ETUI=\:N J; END ASI";

;

C(.·iLCC; PHOCEDUI:;:E ( PY !WTH , Vl:TL $PTR , VITI;;:$PTI:;: ,

/Yf. WE:. CAN I;:ECOGNl:SE HERE THE SAME CALCULATION i"tETHOD AS :tN THE FORT1=;:AN PROGI:;:Al'i Sf). FTN • wmi:l< IS CALCULATED WITH THE NUI1ERICAL VALUE: X(I)-X(1·-:J.):.-:;:J.OO + >K/

DECLARE PYiI>PTH po:rNTEH t [)ECL(~I:;:E (vrrUt,PTF\, Vl:TR$PTI:;: v C:O$F'TR, Cl !~PTJ:;: p CZ$PTI;:,

C3!I;PTf() POINTER; ___ ._._,~.", _",,_._. __ '_ _&o .. ~,.

Page 80: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

, ... ~ •.•••• j"". . L

LJLCL(il'·.:L~:

DECLARE DECL(.\I;;:E DECLAf~E [)ECL(-'lI=(E: DE CLAm:: DECL(.\I=i:E DE CLAm::

, ,. . • • . t , "~. "

(1".1;1:1 i:~ U~'IGLL· \.U"ll'·;:I>I:'·'n,) I:·:L{;IL I (CO E:f.\~)ED CO$PTF<> HE(.:aL t (Cl BAf~E[) Cl.$vno REAL. (C~~ E:{i~3ED C2~I;PTF~) F~EAL. t (C3 BASED C3$PTR) REAL; WQI=;:K (~:l) f<EAL DATA (20 () • , ~l50 • ,371 + '<12Bei7) ; COt::FF 0 I:O:£AL; COEFF (.(t) Fi:I:::AL t

COEFFO=O.06*<PY(1)-PYCO»; COEFF(O)~O+06~(PY(1)-PY(O»-6.~VITL; DU I;~l TO 2;

COEFF(I)=O.06~(PY(I+l)-PY(I»-COEFFO­l()O./WORK(I-l)~COEFF(I-l);

COEFFO~O.06~(PY(I+l)-PY(I»J

END; COEFF (3) r.:;C) + )l{VITI,-COEFFO" .. 0 • 269230)l(COEFF (2) ; COEFF(3)=COEFF(3)/173.0771 " I:1::3; [)(J WI·HUE I>::.:: 1 t

COI~:FF (I-·l):.::: (COE:FF (I-·1 )-1 00. *COEFF (J:) ) IWCJI:;':I-( (l:-·l) t I::::I"-lt EI .. m;

C3=1.666.6666666)1(COEFF(1)-COEFF(O»; C2:.:::5000.)I{COEFFCO)' Cl~PY(1)-PYCO)-1666+6666666)1{(2.*COEFF(O)+COEFF(1»i CO~PY(O)t

END CALec,

SPLX: PROCEDURE (PY$PTR,CO$~rR,Cl$Pl~,

CZ~;PTR, C311;PTR 7 V ITL$P"H<) t

DECLARE p'($p'n:: POINTER t DECL(.\I:;':E Jl INTEGH( t DECLARE (PY BASED PYSPTR) (4) REALJ DECL(.\t(E (VITL$PTf(, CO$PH~, Cl. ~;P"n:i:, C2~;PTI:;':, C3~)PlF() F'ou.rrEI:;:; DECLARE (VITL BASED VITL$PTR) REAL; Dt::CL('~HE (C 0 BASED C () $PlF<) REAL; DECLAF~E (C1 E:ASED Cll1'PTR) f~EAL t DECL(.\!:-":E: (C2 BASED C~:!$p"nu REAL; DECLAI;::E (C3 E:(.:lSED C3$PTfi:) F<EAL; DECL(.\RE YLI INTEGEI:~ ;

DO Jl=O TO 100 BY 51 YLI;:::FIX ( ( (C::~)KFLOf;l T (d 1 ) 1100 .. +C:!) »:FL.Of!:l"r (.J 1 ) 1100 +

+Cl)*FLOAT(Jl)/l00.+CO); CALL EXIIN r (@YLI) t END;

C(:'..!LL ClUTCAR ( LF ) t VITL=C(3.)I(C3+2.*C2)+Cl)/100.; END BPL.I.

/»:E:EGIN OF THE M('%IN PI:;':OGI:(At·l. THE PARTICULAR PRUCEDURES f~lRE:

P01:NT: PICI-{S UP THE OHDINATE OF THE to~OTS. ASK: ASKS IF WE WANT GET OUT OF THE PROGRAM. GALec: C,~'LCLJL.ATE!3 THE COEFFICIENTS OF THE SPLINE FUNGT10N

E:ETWEEN THE TWO FII:(ST ~(NOTS .. SPI •. I: CALCUL.ATE:~) THE SET-POINT V(.\LUEB AI_L THE 5 M. S.

AND DISPLAYS THEIR VAL.LJE:$ TO THE SCREEN. FLOAT: TRANSFOI:O:i"lS AN INTEGEI:;: TO A 1=i:t:.:AL VfiLUE.

Page 81: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

I'::" .. ,. L.. . ,\ 1 ,~;. "~. ' . ' .

\h~Il..L .. ; l...U\.ll< UUl.Ji\.H.Jl~:II·(( l::Ui'lU.CITUi-.i y

VAU;: t I:UGHT B()UN[)(.1r~Y CCli-lD:L"LLCH.J. CClNT:[: lEST Vf~L..UE TO I'~NOW :rF n·ll::: PFmCf;:f~t'l HUBT CONTINUE. CUOYI: l:Wrt::GD~ V('~LUE OF THE ~a.JDT mmDNf~TE. CClOY: m::(.:IL. V(.:ILUE Dr THE ~(NOT ()RD()N~YrE +

AO •••• A3i COEFF1C1ENTS OF "1-1£ SPLINE FUN~Tl~NS. ~/

/~Cf!lL.LS THE SPECI('~L HEAL. UN:rr OF THE: PHOCESSOH}K/

DCl 11::::0 TO 3; CALL P01Nl"(@COOYICll»; COOY(I1)=FL.OAT (COOY1(I1»;

ENI); CALL CJUTCAI=<: (LF ) ; VAL.R=(COUY(3)-COOY(Z»/100.; /~LINEAR INTERPOLATION ~/ DO WHIL.E CONT1:::::Y; .

CALL. CALCC(@CUOY,@VALL,@VALR,@AO,@Alv@A2,@A3); CAL.L SPLI(@COOY,@AO,@Al,@A2,~A3,~VALL); DO 1:1;::0 TO 2;

COOY(Il)=COOY(Il+1); E:NlH C~ILL po:n,rf (@COCJY:X:C:D ) t CALL OUTCAR(LF); COOY(3)::.;FLOATCC(JOY1(3»' VALR=(COOY(3)-COOY(Z»/100.; CONTI~("~SI< t END;

C?\LL DC~EX~T CO) ; END SPI'1;

Page 82: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

/)~':'I::·· "l'(-I"':' 1::'I~.'rll'I:;' !').< f~ ~:I ['lll '. 'T''':-:'' 'fl"I':' C' ·1~·L:t:·l·l·"l·f.·:"',1 r'o:' I""J\:' (' Afren~l)( t1 , .. ), J .. _) . _ I ,/11' ... / 1 _... ..ft 1- .. ) ~.. U ..... r ... . .. .1. .:>, 1

':;PLH·!E I~ UNCTJ:lJN UEFn .. IED BY F(JtJl~: I<ND'l B ANI) t~ES1Tl LJTI:.~S \' ro THE sct~EEN ~ TI .. II::: l.h~LUES UF THE ~)ET POINTS BET~IEEN THE n·m FIRST ~(N(JTE. THE: Ei'''I:,'LDYE:D ME'} t1()t) TO CALCULATE HIE COEFF1:Cl:E:],!"n:> :rs THE ~:)I~i'1E I~\S THIS C'l:SCF:IBECo IN THE P{JI:~AGHAPH

I :\PPI...ICATI0f'! OF CALCUU'~TI()Nb Fm:: FOUf.: I<NOT!:) I. 1.'1' IS WfnTTEN F m;: {~N B086 f-lPPLIC{ln:Ui'!. ~/

SP:DU;

/»: N v X ~ Y ~. r.:F~ v LF : [)ECL(·,I';:ATION OF '1 HE {'Ist},l: I)!~LUES <

IH~LL ~ LEFT E:(]UND?}F:Y COND ITH1N • W,U;:: FG:GHT BOUNO{iHY CDNDITl:ON. COi'ITI: TES r VALUE TO I<NOW n: THE t='ROGI~AM r1UST CUNT1:NLJE:, CDOYT t l:i'!TE.GEJ~ I.JfiLUE OF THl:' ~{NOT OI:::DONA'l E +

COUY ~ HE(~,L. l)p,UJI::: OF THE I<NU r ORDONflTE, :r;/

[)ECU)I~:E: eli ~ 1.!'...J) BYTE; DECLt~I';:E N L.:rTEF~ALLY I .ltEH' : ~;'ECU\I;:I::: :.: L1TEI:":ALLY ':58H' ~ DLCLt,I';:E Y l.rn:::F<(.:\LL Y • '::;'?H' ; OEClJ\I,E CF~ LIlE:I~:('%LLY I (JI)H I ;

DECLAF;:E LF L.T rEF~taLL y I (11-:11-1 I ~

DECU\F:E VAL.L m::I(~L IN::LTIAL (0.); DECL.t,RE \)ALF: REAL.; DECL.~RE CONTI 8YTE INI1I~L (S9H); DECL.I~I;;:E CODYl: (4) INTEGEI~:;

t;IECLJ~RE C(JOY ,:,~) ~~E{~L ;

/A<[)CCLt,I';:(" rUli'! OF ':ILLH'Il::: EX n::m·!AI... PROCEDUI·::ES i t)(:f$·LKIT: F:n!lf;HLS f~l PI'·:O(";f~Ai"l ( GETJI'!T: GElS ('-iN ASC:n: STF:ING Ff~fJt"\ rHE: t(!:::Y-·BUC1F:C'

(-IND Il;:(~NSFm':i"iS r1' or 0 (',N l.i'HEGEF~ V{~LUE.

E~G:):NT ; n~t~N\3FlJl';:I"'i~j (iN IN TECER WiUJE TO AN (.'1 S CL): STRl:NG tiNt) O:r:SF'l.j·,Yh ):1 TD THE:: SCREEN.

:Li'·iTCt~!·;:! GETS I"-lN f~'~)C:.CI Ct'1F:AC fER FROl"! THE I<EY -·E:OI'tHC· , UUlC(:IF:: [)ISI~'LAYS TO THE: SCf.:EEN AN ABCl:!: CAI~:ACTE}·: < )jo'/

DCI'\,t::)C[r : PROCt:::t)URE (EXCEP) E;.::n::J~NAL;

DECLJil~:E t::XCEP !,~(Jfm;

ENe.;

SElIN']' :PR(K~8)URE INT~GER EXTERNAL' EN!:) )

UG:]}n : PI~OCEDUI~:E >: 'HILUE'!q:"'n~) E)CfEI~:N(1L.;

DECI3'lI~E lJAL.UEi;pn;: po:n·ITER; eN!);

HnC(''lI'': ~ P~~:OCEDU~·:E (I:::UF FEfNF'TH) EXTEJ;:N~~L?

DECL.!::IHE E:UFrl;J~'I;pn;; 1';'(J:n~ Il':};:?-.~ND ?

/:":IJECI...PII:;:ryr:nll-! OF "HE 1"'!~IFn]:CLJlJ\I:': PI:mCE:.Dl..II:,:ES; POIN'(': P:r:Cl<':l UP THE O"~D:l:N('WE LlF TI"lt:: I{NOTS. !'y:;I< ~ (\~)I'S :1:1 !4E Y·tlC:II'·fj LE''! nUT DF THL PI;;:OL·;Hf.:\i'i, ~31:'I. .. J:: [.:( ... L.CUL.ti rES rHE CDEFF:n:::r:l::NT'::> OF "t'HE SPLLNf: ,,:'Ut,!C r.nh'!

E:I~-j"l·!LI}! "tHE THD F:IHb') l<i'~Ut!3:' C(';I..CUL.rYr!:S '1 HE i.'(.~LUE~l ; '1\::' I'~·H,: '::~r.~ r pn 1';',1 rl,; ,~,I 1 T\.I~: .:; ;'i(~ /.\;.11"\ lyr';·'I.:'! ('.T!::'·,; TH:':;'i

Page 83: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

PCIINT : PI;:()CEDUF~E (py~;,pn;::.;

/)~ 1:<'1' C[JNTAIN~::; THE {\SC1:I l.,J(.~LlJES OF THE LETTEI~S I POHfl ' , 'N./

DECLARE TXT (b) BYTE DATt!) (50Hv4FI""'4f?I-I,4EI-11'~i'<+Hr~:iFH),

DE:CL(~I;:E r:'Y~>PTR PDINTEI-<; DECLAI'~E PY E:r~.:::)ED PY$PTR :1:i'lTEGEH;

DO :1::::0 TO 5; CALL OUT CAR (TXT(L»;

l:ND; CALL OUT CAn cn ; CAL.L llUTCAR (Cf;: ) ; CALI... ClUTCAF;: (LF); PY!":GE1'l:NT j

END POINT;

ASk :PRllCEDURE GYTEl

/)1: lxr CDNT(.:IINS THE ASCII \.JAL.UES OF THE LET'f D::S 'CONTIHUE'. SHUi'll;: STFUNG UF Asc:rI Cr-.RACTEHS PICI-(ED FI~:m'l l'HE I<E,(-"BClAI~:[). J: ANSWER <Y OR N) GIVEN BY THE USER. */

m~CL.AI:;:E TXT (9) BYTE OA r A ("LiH r 'fFH p "tEH" 54H I' 49H,4EH,55H,45H,3AH)i

DECLr!,HE ~rnU:NG (6) BYTE j DU ... hO TO ri't

C(~L.L. OUTe(.\F: ( TXT ( ... J) ) 3 END; CAL.L :no,lTCAF: «!~!nl~:ING) ;. 1::':0 :' ..J:"·ST~aN(:; ( () ) ~

IXI WH.L:U:: ,j<>Y f'lt-!D ...J<>N .... 1~::~;TF.::niG ( 1) ;

1>::1:+1 :

/!l: HE CAN f~ECClGN:r:,::)E THE S.~ll'1E:: CAL.CUL.ATIONS AS m::SCF:H::l:::D Ii-! '

THE ~H:.H.U~E:LF~:S {-IRE: C ( 0 ) ••• L': 3): COt.::FF J:c:rENTS m:' THE F:IR~iT SPLINt::: FU'-·!CTJ.:ON. THI:':SE:

COEFFICIENTS ARE MULTIPLIED BY 100. 'iL.l: 1.NTEGI~J~: VALUE!:) OF THE SET F'OlJ·n s. FTX ~ rRAN~3F(J!';:I'i::; AN n.rn::CEI;: VALUE TO A REAL." FLOtd': 'll~:Ai'lbFm;:I'lb A I~:EAL. TD ?IN l:NTEGLJ~ lHiL.LJE <

82 t SECOND DEFUVt~\T1V VALUES OF THE SPLINE 1·~·UNC'n:m! (-\T '{ HE TWO FII~:ST ~(N()'rs. »V

DECl...r~lF:I::: r:"( ",P rF: POLi'lTl:::I:;:; L'l' CL.t.r~E .: f:'Y 1:::(\bl:::D IY'(H:'TI~:) O:'~) F;:I::.r~\I ... ;: ()CCU~I~:I::: .: l.!rrL 'H::' n;: v I .... r rR 1;F'I'P) pun,!n:}~!

I) ~CL.I:!f\E .: l)].'l L Utlm::D \.J1.T1...1;PlF:) I:::EAl.. i­I.)I:::CI...{:"~,:I::: (\)l:TR E::(.:l~:)EO In:H::-r,PTR:I HEr'lt. ~ L'lT!."':!"':!:: C ':-:D 1·;:E(.:ll.. ~ DE::CI...{.lF:t::: YL.]: l:i-·!I'I:::GEt;:; 1..1~:CL.{iUE DIF ~ 3) 1:·:Etll ... ~ 1"',1·:'",'1 l.,I~·I::' {'::'.I .. I::!I::· .. I :,.'. '\ 1:;·1,:·, .. ·.1

Page 84: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

D~: CL.tIW·:;: ,..11 IHTI:::GU~!

DECLARE I INTEG8~i

DLCl.(.11 {E 82 (2) I:;:I:::.'~U

DIF(O)~PY(l)-PY(O); 1.)1 F ( 1. :. ::::F'Y (:2 ) ... py ( 1. ) ~

DIF(:2)~PY(3)-PY(2);

f1L':=D:IT ( :1. ) ··lHF ( 0 ) ; BE~DIF(2)-DIF(1)i

G(,::.::DJ]' (0 »)1(0. IJl··· l"lT1L.; S2(1)~-O.00533333)1(~~+O,OlB6666~AL-O.9333333l1(GA; S2(O)=3.lI(GA-O.~*S2(1); C (0) ""PY ( 0) ;

C( 1 > :::l)II~ (0 )",1.6. 66666b6lt.: (2 .lKSZ (0 )+82 (1) ) ; C(3)=O,001666666*(S2Cl)-S2(O»i DO J1."O TO 1;

I""FIX (t12 (J1 ) ) t Ci~LL EXIINT (@:[) t CALL OU1~AR(LF); ENDf:

CI~ILL OllTCi~R(LF) t DO ...11.;:0 TO 1 UO I::)' :;;

YLI=FIX«(C(3)lI<FLOAleJl)/100.+C(Z)/l00.>lI<FLOA'f(Jl) +C(1)/l00.).FLO~r(Jl)+C(O»;

CALL EXIINT(@YLI); CALL (lU rCAI;;: ( LF ) ) ENDt

V:l.TL.:"' (30 0 ~>r.C( 3)+2 +>KCC~: )+C (:l) /1 00 < ) ;

END SPLI;

/lK BEG1.N OF THE M('~IN PF:()Gt~:f~M.

THE PARTICULAR PPClCEDlIHES Ar~E~;

POINT: Pl,CI-(S UF;' THE mml:NATE. OF THE ~(I-IOTS .. A~l~( 1 ASI'(G .[F WE WAN r GET OUT OF ('HE PROGI=i:fiM. SF'U: i C?\LCLJU~TI~:S THE cCtEFF:I:CIENTS OF THE. SPL1NE FUNCTl.Di'-!

BETI-IEEN THE rHO FIRST I<NOTS, CALCULATES THE VAU.JI:~S OF THE SET I<NUTS AND DISF'LAIES THEM TO THF.:. BCHEEN.

N, X I' Y p CH ') l..F : DECLAHA lION OF THE I-":tSCIJ: VAL.LJES. l)f\LL.: LEFT E:(HJI'!I)(1f~Y CONDJ:TION ~ ~h::-IU{ 1 Rn;HT ~::OUNDt~I:;:Y COND l:T rON. CDNT:r i '11::!3T V(.'tI ... UE 'rll ~{NOW IF 1 HE PI:;:OGF~AM MUST CONTJ.HUE, CUClYJ:: n,! fECU".;: W1L.llE OF THE ~(NOT mmONf-l TE • C]OY: F:E:AL. 'HlLl.JI::. OF THE: .(1-10T OI~:l)ONI~TE. '11./

D(I ]:1'":0 HI :H CALL POINT(@COOYI(Il»; CUOY(Il)=FLOAT (COOY1(Il»;

ENO; \)(.lU:;:~: ( CCJ(JY ( :':1) -CUOY ( Z ) ) /:1. () 0 • i IX) !AHI1 .. E CDNTI·::;Y;

C(IL.L. SPLI': (~?COOY I' b'v{~LL ~ (it~,1(:IU\) ;

DO :fl. ":0 TU Z ~ COUY(11)~:lIUY(11+1);

[i'll) : CAU_ POIN1'(ffiCUOYI(3)~ COUY(3)~FL,UA"(COOYI(3»;

VALR~(COOY(3)-COOY(2»/10U.; ccn,rr:r:::::/::I'31{ } LNU?

Page 85: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

OK, SEQ SP

Re~u l ~~ of Sf. FTtJ OK, SEQ SP N, XU), YU), 1""1. .. N -4 o 0 100 900 200 20 300 500 ITVPEL, YALl .. , I1VPER, YALR 1 0 1 4.B C =

O. 514040E ()O -0. 48880E 00 IHIN, It1AX o 20

O.OOOOOOE 00 0.500000E 01 O. l00000E 02 O. 150000E 02 0.200000E 02 0.25OOO0E 02 O. 3Oooo0E 02 0.350000E 02 0.400000E 02 0.-45OOOOE 02 O. 500000£ 02 0.55OOOOE 02 0.600000E 02 0.650000E 02 O. 700000E 02 0.750000E 02 O. SOOOOOE 02 O. 850000E 02 O. 900000E 02 0.95OOOOE 02 O. loooo0E 03

IHIN, 1l1AX

000

O.OOOOOOE 00 0.622101E 01 0.240480E 02 0.'22270E 02 0.895040E 02 O. 134625E 03 O. 186336E 03 0.243383E 03 0.304512E 03 0.368469E 03 0.434oo0E 03 0.499851E 03 0.'64768E 03 0.627497E 03 0.686784E 03 0.74137'E 03 0.790016E 03 0.8314'3E 03 0.864432E 03 0.887698E 03 0.900000E 03

N, XU), Y( J), 1=1. .. N 4 100 900 200 20 300 500 400 -200 JTYPEL, YALL, I TYPER , YALR 1 1. 2~ 1 '-7 c =

-0.50784£ 00 0.41088E 00 11'11 N, lHAX 20 40

O. l00000E 03 0.900000E 03 O. 105000£ 03 0.900243E 03 O. II 0000E:. 03 0.888938E 03 O. 115000£ 03 0.867235E 03 O. 120000E 03 0.836280E 03 O. 125000£ 03 O. 797223E 03 O. 130000E 03 O. 751213E 03 O. 135OO0E 03 0.699396E 03 O. 14ooo0E 03 0.642923E 03 O. 14!;OOOE" 03 0.582941E 03 O. 1500()OF 03 O. 520598E 03 O. l~!iOOOF 0:1 0.457044E 03

0.37280£ 00 -0.18640£ 00

O. 000000£ 00 0.244660E 01 0.464240E 01 0.658740E 01 0.828160E 01 0.972500E 01 O. 109176E 02 O. 118'94E 02 O. 125504E 02 O. 129906E 02 O. 131800E 02 O. 131186E 02 O. 128064E 02 0.122434E 02 O. 114296E 02 O. 1036'OE 02 0.904959E 01 0.748339E 01 O. '66639E 01 0.3598'9E 01 O. 127999E 01

-0. 31968E 00

O. 127990E 01 -0. 114444E 01 -0. 333911E 01 -0. 530409E 01 -0.703940E 01 -0. 854503E 01 -0 982098£ 01 -0. 108673E 02 -0. 116838£ 02 -0. 122708£ 02 -0. 126280E 02 -0. 1275'5E 02

O. 15984E 00

Page 86: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

O. 160000E 03 O. 165000E 03 O. 170000E 03 O. 175000E 03 O. lBOOOOE 03 O. IB5000E 03 O. 190000E 03 O. 195000E 03 0.20000OE 03

nUN, IHAX o 0

0.393426E 03 0.330892E 03 0.270592E 03 0.213674E 03 O. 161289E 03 0.114975£ 03 O. 746919E 02 0.427838E 02 O. 199993E 02

N, X(l),Y(l), l=l. .. N o o 0 OK. C ALL OK. em -EOMO .~E.

-0. 126534E 02 -0. 123216E 02 -0. 117601E 02 -0. 109690E 02 -0. 994814E 01 -0. 869762E 01 -0. 721742E 01 -0. 590759E 01 -0.3567~ 01

Page 87: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

pelTH'C·;')­+00000 PUn·1T,(-y .:' 0 O·~·O () !~·ClINl·:·Y

'rOO(I~::O

FiJl:i-lT(·Y .; () 0'50 ()

, .. uoooo 0}'OOD06 .. ··0 0 () :,:: ... ~ +OO[l~:):;::

···n 0 0'.>0 .~. 0 0 1. :::~.'.i

· .. ·0 () l~kl +(uJZ.q3 ···00311(j +003c)8 .•. () 0'1: ~"'i +0 O':.'jU 0 ·;··00 ';:i,,)'::i ." 0 O(.I~:·7 .•. n (l ,;~n,',· +007'.1 .... no/'/o ,,;,00<-331 ., .. n I) ~3/).l.f .;. n OH13B •. \) 0<,1IJ ()

;;·(.n: ; ,If 'i' 'I" .... uc~::',Oli

.:U/--IT l!-.lUI::: t y • ... OO~}JOO "'009(1(J

···OOtiH9 +()OH67 ···OOB:kl + 0 IV' tl:7 ···007'.i:\. ,:,006:;:'(';>

.• ' \) 0 i;.1',J +00':;)1'53 ", t:I O~.,i;~::I. 0,,0 O':+~,!7

"'no :~'/.:: +003:'!-1 .... UOZll +(10":::1 .. + · .. ·1)01/; . .1.

"'\J 0 ~ .\.~5 .... \l 0 [) / .... :

-" I,) 1) '.J At 3 ,,, no (J ~::: \.1

;:I,Jli-!\··::.'{

· .. ·Ol:i(k:.!!

Page 88: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

/>r: SPM96 ~ 1"I-I:1:S PI:~OGI:;:,~~t'i Cf~LCULATES THE .... COEFFICIENTS. OF THE FIRST SPLINE FUNCTION. THIS IS A f~EAL-TIME PROGRAM WRITTEN F'OR A 8096 MICHOPI:;:OCES.SOI:;: f'%PPI_ICATION. AN OUTPUT PORT IS TRIGGEREI) TO Ell:: ABU.:: TO MESUf~E THE f~UNNING TIME. THE PROGRAri IS THE SAME AS Sf'M. PLM. ';t</

Sf:'M96 : DO; />r. 1'HE DIFFEf(ENT VAI:;:IAE:LES AHE:

py: Om)INATE 0\::' THE' .'NOT6. THEY Af(E .'NOWN BECAUSE THEY AI;;':E· GIVEN E:Y THE CENTI~AL COMPUTER +

VITL: LEFT BOUNDAf~Y CONDITION. GIVEN BY THE PRECEEDING CALCULATIONS.

VITR: RIGHT .BOUNDARY CONDITION. CALCULATED 8Y LINEAR API;'ROXIMATION.

CO ••• C3: COEFFICIENTS OF "fHE SF'LINE FUNCTION. PORT: BYTE SENDS TO TI-IE OUTPUT f'm,(T. COEFF: SECOND DEfUVATIV VALUES OF THE Sf'LINE FUNCTIONS

AT EACH WiOT. . WOHK: DATAS GIVEN BY THE FACT THAT X(I)-X(I'-;U=100 '&/

DECLAf~E paRr E:YTE AT (OOOFH); [)ECL(')RE I E:YTE t DECLARE COEFFO I:;:EAL; DECL( ... RE COEFF (4) RE'\L AT (CO,Cl,C2,C3); DECLARE (C3,L~,C1,CO) REAL; [)ECL(,\I~E (VITL, VITR) REAL DATA (0.,"" • ED t DECLARE wom< (3) REAL DATA (200.,350.,371.-<tZS57)t DECL(-\I=>:e: py (It) I:;:EAL DATA (0. ,5000. ,12000.,10000. );

CALL INIT$F~EAL!~MATH$UNIT t DlSABLE; DO WHILE l=::I t

PURf::::NUT PORT; COEFFO::::O.06JK(PY(1)-PY(O»; COEFF(O):..:COEFFO-6.lKVITL; DO I=l TO Z;

COEFF(I):;;:O + 06lK(F-'Y(I+l )·-PY<I) )-COEFFO-100 ./WOfU«I·-l )IKCOEFF(I-l) t

COEFFO=0.06IKCPYCI+1)-PYCI»i END;

CCJEFF'(3)=:6.lKVITR-COEFFO-O .269230lKCOEFF(Z); COEFF(3)=COEFFC3)/173.077; 1>::3 ; 00 WHIL.E I>=:I.;

COEFFcr-l ):.::(COEFF(I-1 )-100 • lKCOEFFCI:) )/l-mRK(I-:l.); I:-.::I·-l ; END;

C3~O.00166666666*(COEFF(1)-COEFFCO»t C2::::0.5*COEFF(0); Cl.::::( F'Y( 1 )-PY( 0) ) *0.01-16. 666666666»:(Z.lKCOEFF (0 )+COEFF (1) ) t CO::::PY(O);

END; END SPN96 t w .

IlK THE TOT t!\L F<c!\i'1 MEMOI:;:Y SPACE NEEDED IS: 45 BYTES. It 1. E::YTE COEFFO; 4 BYTES COEFF,CO ••• C3t :l6 BYTES Vl~H,VITL: B BYTES PYl 16 BYTES W()I:;:I-( : 12 E::yn.::s OF ROM MEJ'iCJRY

Page 89: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

/tti SP,.:lc"l: lHD3 PROGf\:I~,i~i C{~LCUL.,~IlES THE Ii COEFF1:CH::HrS OF r~!rel\eI ix 0 FJ:nST ::3PL.INI:: r: UNCTl:C)N. '1'1-115 1:S I~ REI~L.·-·r nn:: PI~:(lGH?li"i WI~ITTEN n)!;: (.) 8096 Nl:CI;;':OPHOCEt,SOF~ ?)PPLI.C(.)THJN. AN C)U fPUT pmn IS TI:U:(';(:;Em;J) TO I:::E !~E:U~ TO !'iESURE TI-II::: I::':UNNING TIME. THE PROGRAN H, HiE SANE AS SP. PLM. )1(/

SF'96 ~I)():

/'>\: THE AT ATTf·:IE:UTE (~LLOW~:; US TO SI~"'E ME:MOI~IES BY STOI~:l:NG

Vr-iLUES l:i'''! PLACES NO MOI:;:E US£D. THE DIFFERENT VAHIAt::I ... ES {iHE:

PY! Om)INATE OF THE ~~NOTS. THEY ARE W'JO\-JN E:ECAUSE lHI:~Y (·\I~:I:': GII,IEN E:Y 11-11::: CEN11:;:AL COMPUTEf<.

VITL t I...EF r t::OUNOAf~Y CONDIT:tON. GIVEN E:Y THE PF~ECEE::Ol:NG CALCULATIONS.

CO ••• C3: COEFFI:cn::NTS OF THE SPLINE FUNCT1:ON. THE'!, ARE MULTIPLIED BY 100,

POI~-:T : E:Y'rE SENDS 1'0 THE OUTPUT POHT. S2 t SECOND DERI,IATIV Vf!)LUE:: OF THE: SPLINE FUNCTION

FOR THE TWO FIRtn ~<NUTS. F:n:! BUIL.T--IN FUNCTION -n~:f-lNSFORHl:Nt:; f.) HE(.lL. TO (·\t~

.Ii'!TE(~ER l)(':jLUE, >1</

DI:::CL{\EE DIF (3) Fi:E,!:,L F 1-'181 ; DL CUim:: ( {"L 'J BE I' GA ;. DE:' REi~lL F liST; DECLm;:E CO LONcun AT (.Al.) t DECLI':Ii;:E C1 LONCINT (.iT (.E:E); OECI... f)1-;:E: 1:2 LONC:lN'l I~ T (, GA) $ DECL.ARE C3 U.JNCJ:NT AT (. DE) ; DE:CU'IRE I E:y-n::; DECLARE PY (4) REAL DA1'A (0,,5000.,12000,,10000,); DECLARE VITL REAL DArA (0.); DECL{)f;:E POF:-T E:Yl ~~ f.lT (I) (J 0 FH) s [)f.:: c u:\m:: 82 (:z. ~ f;.:E(.'-lL ~IT (. OIF ( 1. :. ) :

C(':")L.L. J.NIT~~r";-:E{~U;,N(.1'n·I<!'UNl1;

DISt~Bl.E ; DU WHILE 1::-:]:;

POPT=NOT PORT, ~IF(O)~~Y(l)-PY(O);

DIF(l)=PY(Z)-PY(l); DIF(2)=PY(3)-~Y(2);

~~L"::DIF ( 1 ;. --Dl:F ( 0 :. ; UE~D1F(2)-DrF(1);

GA=DIF(O)~O.Ol-VITL;

82 ( 0) :::1 ,5)1«(:;(.:1-,,0. 25)l(tQ (:L ;. t CO:'·FIX (F'Y «()) :t.:1 0 0 • ) }. Cl...::FIX (Dl:F ( 0) .. ··1.6 ,. 6b666:t< (4t • :t<S2 ( 0 ) +B2 ( 1 ) ) ) ~

C2":.FD( (SZ ( () ) ) 1 C3:·F D( (0. 0 () :\.6666666»: (~)2 { 1 ) _MS:':: ( () ) ,-,82 ( 0 ) ) ) ; END;;

END !::;P96;

/)1.: TDTI~IL.. RAN SP{-ILE i"IU'imn NEEDED ~ ,~o B'n E~:) D:r:F r :::;~:: 1 12 !::YTEG ,::',1 ,!' 1:::1::: 1 (.;(.~! C (I v , ,C:::: -: 1.6 1:_:\''fE~::'

Page 90: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

/'): U\LM';)6 ~ TH:n; PI;:DC;fi:~II"i C?\I...CULI~d E13 THI:. SET PDll,n lJtILUIi;.!:, OF t~ :3PL.Tr.i[ FUNCTHH" v DEFn-lED BY rrs CC)EFF:tCl.ENH.l CAL.CUL.ATI:~t,

Ii" bl:'i"l'l'cS .I·:'LM r [:['1 WEEN THE n,IO f: II:;':S" l<NUTS.. TI·Il:S PI:;:OGl'f-lM C(.-lN BE !;~LJi"'! ON .:,-, 0096 PF<:ClCESmm~. TO NEBUm:: THE l;:l.IN Tl:ME WE rl:~J.:L;GEH (,N UlJTPUT POI:;:"-. THE. CALCUUfTn:n·H:;; AF~E DONE Ht:RI~~ w:n H I:':E{·~L. IJfiLUES, lIi./

.' >,: 1::'U!:n' ~ BYTE SENLH3 TO THE OUTI:·'l.JT PORT. ,(L.:I:t lH-lLUE. UF THE SET PO:nJ.T .. CU ••• C3: COEFFICTEN1S OF THE SPLINE FUNCTION. v:rTl .. ~ LEFT BOUND(:)I":Y CDNOITTUh!. ~x: A8SYSCE UF THE SPLINE FUNCTION 10 CALCULA1E

THE SET PCnNT V~\l..UEb. )1(/ D[CU'!I',:E: PORr [~YTE r!lT (00 (J FH) t [)CCL.r't~{[ 'fL.T I'-:EAL; DECL..l\I:·:E (CO vCl r C~~ y [:3) I:;:I;;.{~L DI-'·f1r!l (51. "-48. ,37. ,-,18. ) t DECLARE VITL REAL; .ATL.flr;:E PX !'::Ei'IL J DI:::CL.i~II·;:E 1 By'IE:'

:ALL INlr$R~~L$MA'rH$UNlT; PX "0" ; )U !.-IHIL..E:: :1:::1 ~

POI·n~·'NUT i::'m;:l:' ! ')(:;:;1«+':.1. t 'I'Ll: ( ( >: C3wPX) +C;;:: )I.<PX+Cl :' )I.:I;·X·H .. O ~ '.'rn.:.: (C:J+CJ+CJ) A<:1:·;·,:+C:?+C2) l+q·:·X+C:t. i

-':r:. ;::(;1'1 '~)r'~~CL lvIE::iviURf 1·~U::UEi.): :~l=:: l::!{j E::b r~t.H··-l rI:i"H::: : :] (*!.( 1"'1:::). ~:: ... '

Page 91: Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline

:.( 1_:I··tI ... ?,~·): TI·{iS F'f~ClCr;:(d'i C(,',LCULIYf!::.!::; "\ HI::. bL'f F'U:U,!T VALUE!; or 1:1

~;li:;'L.Ti'K: FUNCTHJI">! ~ DEY'JNFl> t::Y .L fS CUE}' F .Ie.LENTS CALCUl.{'ITEI) :l:i'~ ~:;t-'~)6 .I:;'U'I ~I i::I::.TWEEN THE TWD FU~S'r I-(NUT!:>. TI'{lS PF.:O[·;I:,:t!ii"l C(..iN i:::I:: I:;:UN Uj" '~-i BO'/6 1:'h:UCU:)~:;l.lr;:. TO NESLJI:~E THE I,:UN Tl:MI::: Wt~ntr.Gct.:}~ \:li'I (JUT ::'UT PDF:·I. THi::. [{oILCUL.,Yf :rON!:; {i~U:. DONE HI::}.:E wrlH L.mlb:l:NTEGEH 1 • .'(:)L.UES. X<:/

.,", PUi(T'! L:YTE ~)Ll~L'S TO THE ULn I~'ln 1~'Of(r.

·(L.T; V(:\LLJE LiF IHE SET \·:otni-.!T • • :: {I • + • :::::3: COEFFIC:IENTS CJF "f HE bl·:'L.INL FUNLTJ:CH'I.

\ .. ,:< : (If.::SY':=;CL Dr: 'I HE bPI...:ll-!l~ F U(!LTJ.ON TU C?'-IU.;l.JL.(·\"n:. THE SE1' POlMf VALUES. *!

:+.LI...{II~:I:: F'UI;;:!' I:::YTE: j:'d ': (J [I OF· I-! ) ; L)L::Cl..f~11 ;:E '(U.: L.ClNc:rNT:> H::lI..AI':E ',CO~· [1 r C~:: ~I C:l) UJNCTNT !)(.·If ,.~, (5:i., ·-'H3, ::17 ,,-.. l.8) ;

r;'ECt...(:,};:L I)J ll.. l.ONG.fNT t ::;'LC:l .. (d~:E j:OX nn EGU·;:;

IXl W I-II: u::-, 1'>)("-;\='>:"

F'OF(f""i'!UT F:'W;:T i PXO<:i ':'+')(; ·{LI~«(C~~PX)+C2)*PX+Ll)*PX+CO)/l.OOi

VTH .. ''': ( ( (C~3+C:3+C:J;' IKP)( 'H::~::+CL) >Kf'X+C 1.) /1.00 ;

:~ R~M SPACE MEMORY NEEDED: 26 BYTES RUM 'TIME : 0.48 MS. ~!