User`s manual

http://www.adtechcn.com 65
Chapter VIII Examples of Programming for Developing
Motion Control Card
Although the programming languages are of great variety, they in nature share some common
points. In short, programming languages can be summarized as “three structures and one
idea”. By three structures it means all programming languages are focused on sequence
structure, loop structure and branch structure. By one idea it means the algorithm and module
division are used to complete the design, which is the key and critical part of programming.
To ensure the usability, standardization, expansibility and maintainability of the program, the
examples given below are presented from the perspective of design and divided into several
modules as follows: motion control module (further packaging the library functions provided
by the control card), implementation module (together with the code segment), monitoring
module and stop module.
The application of ADT-8840’s functions library in VB and VC programming languages will be
briefly presented as follows. If other languages are used, the user can make reference from
exemplified VB and VC procedures.
) 1. VB programming
1.1 Preparation
(1) Create a new project, and save it as “test.vbp”;
(2) By referring to the method mentioned earlier, add “adt8840.bas” module to the project.
1.2 Motion control module
(1) Add a new module to the project, and save it as “ctrlcard.bas”;
(2) First self-define the initialization functions of the control card in this module and initialize
the library functions that need to be packaged into the initialization functions.
(3) Keep self-defining other related motion control functions, such as speed setting function,
single-axis motion function and interpolation motion function.
(4) The source code of “ctrlcard.bas”
'********************** motion control module ********************
'To quickly develop application system with high usability, expansibility and
maintainability,
All motion-control functions are of immediate return. When the drive commands is sent out, the
motion process will be controlled by the control card. At the time, the user can oversee the whole
motion process through the upper PC in a real-time manner, or compulsorily stop the motion.
Note: When an axis is moving, it is not allowed to send new drive command to it. Otherwise,
the system will quit the previous drive and execute the new drive command.