SPiiPlus Utilities Users Guide (V4-20)
SPiiPlus Utilities Users Guide (V4-20)
U ser’s Guide
Version 4.20
V e r s i o n 4 . 2 0 , October 30, 2006
COPYRIGHT
Copyright ® 1999 - 2006 ACS Motion Control Ltd.
Changes are periodically made to the information in this document. Changes are published as release
notes and are be incorporated into future revisions of this document.
No part of this document may be reproduced in any form without prior written permission from ACS
Motion Control.
TRADEMARKS
ACS Motion Control, PEG and SPii are trademarks of ACS Motion Control Ltd.
Visual Basic and Windows are trademarks of Microsoft Corporation.
Any other companies and product names mentioned herein may be the trademarks of their respective
owners.
Website: http://www.AcsMotionControl.com
Information: [email protected]
Tech Support: [email protected]
Page Change
Cover Updated logo and company name
Table of Contents
1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1 Organization of this Guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Related SPiiPlus Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.3 The SPiiPlus Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.4 Conventions Used in this Guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.5 Statement Text and Icons Used in this Guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2 General Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.1 Operation Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.2 C Library Concept . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.3 Communication Channels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.4 Controller Simulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.5 Programming Languages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.6 Supplied Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.7 Highlights . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.8 Use of Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.9 Callbacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.10 Timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.11 Hardware Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.12 Dual-port RAM (DPRAM) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.13 Non-waiting Calls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
List of Figures
Figure 1 C Library Concept 5
List of Tables
Table 1 Related SPiiPlus Tools 1
Table 2 Collateral Documentation 2
Table 3 Document Conventions 3
Table 4 Hardware Interrupt Generation 10
1 Introduction
The SPiiPlus C Library supports the creation of a user application that operates in a PC host
computer and communicates with SPiiPlus motion controllers. The SPiiPlus C Library
implements a rich set of controller operations and conceals from the application the complexity
of low-level communication and synchronization with the controller.
Note
Highlights an essential operating or maintenance procedure,
condition, or statement
Model
Model Dependent Text Here!
CAUTION
Caution describes a condition that may result in damage to
equipment.
2 General Information
Host
Application 2
Remote
C Library Application
spiiplushost
2.7 Highlights
• Unified support of all communication channels (Serial, Ethernet, PCI Bus)
All functions except acsc_OpenComm*** functions are identical for all communication
channels. The user application remains substantially the same and works through any of the
available communication channels.
• Controller simulator as an additional communication channels
All library functions can work with the Simulator exactly as with the actual controller. The
user application activates the simulator by opening a special communication channel. The
user is not required to change his application in order to communicate with the Simulator.
• Support of multi-threaded user application
The user application can consist of several threads. Each thread can call SPiiPlus C Library
functions simultaneously. The library also provides special functions for the
synchronization SPiiPlus C functions called from concurrent threads.
• Automatic synchronization and mutual exclusion of concurrent threads
Both waiting and non-waiting calls of SPiiPlus C functions can be used from different
threads without any blocking or affect one to another. The library provides automatic
synchronization and mutual exclusion of concurrent threads so the threads are not delayed
one by another. Each thread operates with its maximum available rate.
• Concurrent support of up to 10 communication channels in one application
One application can open up to 10 communication channels simultaneously. Different
communication channels are usually connected to different controllers. However, two or
more communication channels can be connected to one controller. For example, one
application can communicate with one controller through both Ethernet and serial links.
• Acknowledgement for each controller command
The library automatically checks the status of each command sent by the user application to
the controller. The user application can check the status to confirm that the command was
received successfully. This applies for both waiting and non-waiting calls.
• Communication history
The library supports the storage of all messages sent to and received from the controller in
a memory buffer. The application can retrieve the full or partial contents of the buffer and
can clear the history buffer.
• Separate processing of unsolicited messages
Most messages sent from the controller to the host are responses to the host commands.
However, the controller can send unsolicited messages, for example, because of executing
the disp command. The library separates the unsolicited messages from the overall message
flow and provides special function for handling unsolicited messages.
• Rich set of functions for setting and reading parameters, motion, program
management, I/O ports, safety controls, and other.
• Two calling modes
Most library functions can be called in either waiting or non-waiting mode. In waiting
mode, the calling thread does not continue until the controller acknowledges the command
execution. In non-waiting mode, a function returns immediately and the actual work of
sending the command and receiving acknowledgement is performed by the internal thread
of the library.
• Debug Tools
The library provides different tools that facilitate debugging of the user application. The
simulator and the communication history mentioned above are the primary debugging
tools. The user can also open a log file that stores all communications between the
application and the controller.
• Setting user callback functions for predefined events
The possibility exists to set a callback function that will be called when a specified event
occurs in the controller. This lets you define a constant reaction by the user host application
to events inside the controller without polling the controller status. See “Callbacks” on
Page 9,
• Wait-for-Condition Functions
To facilitate user programming, the library includes functions that delay the calling thread
until a specific condition is satisfied. Some of the functions periodically pole the relevant
controller status until the condition is true, or the time out expired. Some of these functions
are based on the callback mechanism, see “Callbacks” on Page 9. The functions with this
option are:
• acsc_WaitMotionEnd
• acsc_WaitLogicalMotionEnd
• acsc_WaitProgramEnd
• acsc_WaitInput
These functions will use the callback mechanism if the callback to the relevant event is set,
otherwise polling is used.
• Support for Windows 9/x/NT/2000/ME
The user application that communicates through the library takes no notice of the
operational environment. The library itself chooses the proper device driver and conceals
all differences between the operating systems from the user application.
Where:
• Handle is a communication handle returned by one of the acsc_OpenComm*** functions.
• Flags are a bit-mapped parameter that can include one or more motion flags.
For example:
ACSC_AMF_WAIT Plan the motion, but don’t start until the acsc_Go function is
called
ACSC_AMF_RELATIVE The Point value is relative to the end-point of the previous
motion. If the flag is not specified, the Point specifies an absolute
coordinate.
2.9 Callbacks
There is an option to define an automatic response in the user application to several events
inside the controller. The user specifies a function that will be called when certain event occurs.
This approach helps user application to avoid polling of the controller status and only to execute
the defined reaction when it is needed.
The library may set several callbacks in the same time. Every one of them runs in its own thread
and doesn’t delay the others.
Callbacks are supported in all communication channels. The library hides the difference from
the application, so that the application handles the callbacks in all channels in the same way.
The events that may have a callback functions are:
• Hardware detected events
• PEG
• MARK1 and MARK2
• Emergency Stop
• Software detected events
• Physical motion end
• Logical motion end
• Motion failure
• Motor failure
• ACSPL+ program end
• ACSPL+ line execution
• ACSPL + “interrupt” command execution
• Digital input goes high
• Motion start
• Motion profile phase change
• Trigger function detects true trigger condition
• Controller sent complete message on a communication channel
2.10 Timing
When working with PCI bus, the callbacks are initiated through physical interrupts generated
by the controller. In the Simulator, the interrupt mechanism is emulated with OS mechanisms.
In all other kinds of communication, the controller sends an alert message over the
communication channel in order to inform the host about the event.
Although the implementation is transparent, the timing is different varies for each
communication channel as follows:
• In PCI communication, the callbacks are based upon PCI interrupts and response is very fast
(sub-millisecond level).
• In all other channels, callback operation includes sending/receiving a message that requires
much more time. Specific figures depend on the communication channel rate.
From the viewpoint of the Callback Mechanism, all communication channels are functionally
equivalent, but differ in timing.
Note
Do not use ‘0’ as the Null character.
• If Wait is a valid pointer, the call is non-waiting and the function returns immediately.
• If Wait is ACSC_IGNORE, the call is non-waiting and will neglect of the operation result.
ACSC_WAITBLOCK is defined as follows:
Structure: ACSC_WAITBLOCK { HANDLE Event; int Ret; };
When a thread activates a non-waiting call, the library passes the request to an internal thread
that sends the command to the controller and then monitors the controller responses. When the
controller responds to the command, the internal thread stores the response in the internal
buffers. The calling thread can retrieve the controller response with help of the
acsc_WaitForAsyncCall function and validate the completion result in the Ret member of the
structure.
Up to 256 non-waiting calls can be activated before any acsc_WaitForAsyncCall is called. It
is important to understand that acsc_WaitForAsyncCall must be called for every non-waiting
call. Otherwise, the response will be stored forever in the library’s internal buffers. A call,
which is called when more then 256 calls are already activated is delayed for a certain time and
waits until acsc_WaitForAsyncCall is called by one of the previous calls. If the time expires,
an ACSC_COMMANDSQUEUEFULL error is returned.
By default, this time-out is zero. This means that the call number 257 immediately returns with
the ACSC_COMMANDSQUEUEFULL error.
{
// something doing here
….
// retrieve controller response
if (acsc_WaitForAsyncCall(Handle, buf, &Received, &wait, 5000))
{
buf[Received] = ‘\0’;
printf(“Motors state: %s\n”, buf);
}
else
{
acsc_GetErrorString(Handle, wait.Ret, buf, 100, &Received);
buf[Received] = ‘\0’;
printf(“error: %s\n”, buf);
}
}
else
{
printf(“transaction error: %d\n”, acsc_GetLastError());
}
// example of non-waiting call of acsc_Transaction with neglect of the
// operation result. Function does not wait for the controller response.
// The call of acsc_WaitForAsyncCall has no sense because it does not
// return the controller response for this calling mode.
If (acsc_Transaction( Handle,cmd,strlen(cmd),buf,
100, &Received, ACSC_IGNORE))
{
printf(“transaction error: %d\n”, acsc_GetLastError());
}