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
91
Embed
Theory and applications of spline functions for a servo ... · Theory of spline functions mathematical theory __ __ -' --~ ___ J s _C -, calculations with third degree cubic spline
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
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.
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
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.
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
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
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."
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.
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
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
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)
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:
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:
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.
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.
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)
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 ~
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.
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.
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 servomechanism. 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 keyboard, 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:
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.
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
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\\
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".
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.
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.
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
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.
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
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)
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
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
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
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
(; ~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
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
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
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
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
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
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
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)
22 K::4(+1 1:.;1+1 IF (I.LE.N) OOTO 17 OK;:::.l"RUE. NP=K-l RETURN END
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
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
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
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.
/'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
CALL. DUTCAR(d); n:' I ::.;: '·1 THEN Vt!)LUE :::: 0 .•. VALUE; 1,=f:::TUI:":N VALUI::;
END GETINT; ENl.> t'it14;
/'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.;
/>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./
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 •
/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;:,
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.
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»;
':;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 ;
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
/!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:}~!
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;
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
/>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</
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
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
/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. :. ) :
/)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~::'
/'): 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:'