SPiiPlus C Library Reference Programmer's Guide
SPiiPlus C Library Reference Programmer's Guide
Programmer's Guide
March 2019
Document Revision: 2.70
SPiiPlus C Library Reference Programmer's Guide
COPYRIGHT
Changes are periodically made to the information in this document. Changes are published as release notes and later
incorporated into 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, SPiiPlus, PEG, MARK, ServoBoost, NetworkBoost and NanoPWN are trademarks of ACS Motion Control Ltd.
EtherCAT is registered trademark and patented technology, licensed by Beckhoff Automation GmbH, Germany.
Any other companies and product names mentioned herein may be the trademarks of their respective owners.
www.acsmotioncontrol.com
support@acsmotioncontrol.com
sales@acsmotioncontrol.com
NOTICE
The information in this document is deemed to be correct at the time of publishing. ACS Motion Control reserves the right to
change specifications without notice. ACS Motion Control is not responsible for incidental, consequential, or special damages of
any kind in connection with using this document.
Version 2.70 2
SPiiPlus C Library Reference Programmer's Guide
Related Documents
Documents listed in the following table provide additional information related to this document.
The most updated version of the documents can be downloaded by authorized users from
www.acsmotioncontrol.com/downloads.
Document Description
SPiiPlus Command & Command and variables of high level language for
Variable Reference Guide programming SPiiPlus controllers.
SPiiPlus COM Library COM Methods, Properties, and Events for Communication with
Reference Guide the Controller
PEG and MARK Operations A guide to the PEG and MARK operations for the SPiiPlus
Application Notes family of controllers.
SPiiPlus ADK Suite v2.50 Describes new features and changes introduced since the last
Release Notes SPiiPlus ADK Suite version 2.40 release.
Version 2.70 3
SPiiPlus C Library Reference Programmer's Guide
Format Description
Monospace + grey
Code example
background
Blue Hyperlink
Flagged Text
Warning - describes a condition that may result in serious bodily injury or death.
Version 2.70 4
SPiiPlus C Library Reference Programmer's Guide
Revision History
Date Revision Description
September
2.40.10 Updated number of buffers to 63
2017
Version 2.70 5
SPiiPlus C Library Reference Programmer's Guide
September
01 First Release
2014
Version 2.70 6
SPiiPlus C Library Reference Programmer's Guide
Table of Contents
1. Introduction 24
1.1 Document Scope 24
2. SPiiPlus C Library Overview 25
2.1 Operation Environment 25
2.2 Communication Log 25
2.2.1 Run-Time Logging 25
2.2.2 Log Types 25
2.3 C Library Concept 25
2.4 Communication Channels 26
2.5 Controller Simulation 26
2.6 Programming Languages 26
2.7 Supplied Components 26
2.8 Highlights 26
2.9 Use of Functions 28
2.10 Callbacks 29
2.10.1 Timing 30
2.10.2 Hardware Interrupts 30
2.11 Dual-Port RAM (DPRAM) 30
2.12 Shared Memory 31
2.13 Non-Waiting Calls 31
3. Using the SPiiPlus C Library 34
3.1 Library Structure 34
3.2 Building C/C++ Applications 34
3.3 Redistribution of User Application 35
3.3.1 Redistributed Files 35
3.3.2 File Destinations 35
3.3.3 Kernel Mode Driver Registration 36
4. C Library Functions 38
4.1 Communication Functions 39
4.1.1 acsc_OpenCommSerial 40
4.1.2 acsc_OpenCommEthernetTCP 41
4.1.3 acsc_OpenCommEthernetUDP 42
Version 2.70 7
SPiiPlus C Library Reference Programmer's Guide
4.1.4 acsc_OpenCommSimulator 43
4.1.5 acsc_CloseSimulator 44
4.1.6 acsc_OpenCommPCI 44
4.1.7 acsc_GetPCICards 45
4.1.8 acsc_SetServerExtLogin 46
4.1.9 acsc_CloseComm 47
4.1.10 acsc_Transaction 48
4.1.11 acsc_Command 50
4.1.12 acsc_WaitForAsyncCall 51
4.1.13 acsc_CancelOperation 53
4.1.14 acsc_GetEthernetCards 54
4.1.15 acsc_GetConnectionsList 56
4.1.16 acsc_GetConnectionInfo 58
4.1.17 acsc_TerminateConnection 59
4.2 Service Communication Functions 60
4.2.1 acsc_GetCommOptions 61
4.2.2 acsc_GetDefaultTimeout 61
4.2.3 acsc_GetErrorString 62
4.2.4 acsc_GetLastError 63
4.2.5 acsc_GetLibraryVersion 64
4.2.6 acsc_GetTimeout 64
4.2.7 acsc_SetIterations 65
4.2.8 acsc_SetCommOptions 66
4.2.9 acsc_SetTimeout 67
4.2.10 acsc_SetQueueOverflowTimeout 67
4.2.11 acsc_GetQueueOverflowTimeout 68
4.3 ACSPL+ Program Management Functions 69
4.3.1 acsc_AppendBuffer 69
4.3.2 acsc_ClearBuffer 71
4.3.3 acsc_CompileBuffer 72
4.3.4 acsc_LoadBuffer 73
4.3.5 acsc_LoadBufferIgnoreServiceLines 75
4.3.6 acsc_LoadBuffersFromFile 76
4.3.7 acsc_RunBuffer 78
Version 2.70 8
SPiiPlus C Library Reference Programmer's Guide
4.3.8 acsc_StopBuffer 79
4.3.9 acsc_SuspendBuffer 80
4.3.10 acsc_UploadBuffer 81
4.4 Read and Write Variables Functions 82
4.4.1 acsc_ReadInteger 82
4.4.2 acsc_WriteInteger 84
4.4.3 acsc_ReadReal 86
4.4.4 acsc_WriteReal 87
4.5 Load/Upload Data To/From Controller Functions 89
4.5.1 acsc_LoadDataToController 89
4.5.2 acsc_UploadDataFromController 92
4.6 Multiple Thread Synchronization Functions 94
4.6.1 acsc_CaptureComm 94
4.6.2 acsc_ReleaseComm 95
4.7 History Buffer Management Functions 96
4.7.1 acsc_OpenHistoryBuffer 96
4.7.2 acsc_CloseHistoryBuffer 97
4.7.3 acsc_GetHistory 97
4.8 Unsolicited Messages Buffer Management Functions 99
4.8.1 acsc_OpenMessageBuffer 99
4.8.2 acsc_CloseMessageBuffer 100
4.8.3 acsc_GetSingleMessage 101
4.8.4 acsc_GetMessage 102
4.9 Log File Management Functions 103
4.9.1 acsc_SetLogFileOptions 103
4.9.2 acsc_OpenLogFile 104
4.9.3 acsc_CloseLogFile 105
4.9.4 acsc_WriteLogFile 106
4.9.5 acsc_FlushLogFile 107
4.9.6 acsc_GetLogData 107
4.10 SPiiPlusSC Log File Management Functions 108
4.10.1 acsc_OpenSCLogFile 109
4.10.2 acsc_CloseSCLogFile 109
4.10.3 acsc_WriteSCLogFile 110
Version 2.70 9
SPiiPlus C Library Reference Programmer's Guide
Version 2.70 10
SPiiPlus C Library Reference Programmer's Guide
Version 2.70 11
SPiiPlus C Library Reference Programmer's Guide
Version 2.70 12
SPiiPlus C Library Reference Programmer's Guide
Version 2.70 13
SPiiPlus C Library Reference Programmer's Guide
Version 2.70 14
SPiiPlus C Library Reference Programmer's Guide
Version 2.70 15
SPiiPlus C Library Reference Programmer's Guide
Version 2.70 16
SPiiPlus C Library Reference Programmer's Guide
Version 2.70 17
SPiiPlus C Library Reference Programmer's Guide
Version 2.70 18
SPiiPlus C Library Reference Programmer's Guide
Version 2.70 19
SPiiPlus C Library Reference Programmer's Guide
Version 2.70 20
SPiiPlus C Library Reference Programmer's Guide
List Of Figures
Figure 2-1. C Library Concept 26
Figure 4-1. Emergency Stop Button 381
Version 2.70 21
SPiiPlus C Library Reference Programmer's Guide
List of Tables
Table 4-1. Communication Functions 39
Table 4-2. Service Communication Functions 60
Table 4-3. ACSPL+ Program Management Functions 69
Table 4-4. Read and Write Variables Functions 82
Table 4-5. Load File to ACSPL+ Variables Functions 89
Table 4-6. Multiple Thread Synchronization Functions 94
Table 4-7. History Buffer Management Functions 96
Table 4-8. Unsolicited Messages Buffer Management Functions 99
Table 4-9. Log File Management Functions 103
Table 4-10. SPiiPlusSC Log File Management Functions 108
Table 4-11. System Configuration Functions 111
Table 4-12. Setting and Reading Motion Parameters Functions 121
Table 4-13. Axis/Motor Management Functions 149
Table 4-14. Motion Management Functions 161
Table 4-15. Point-to-Point Motion Functions 174
Table 4-16. Track Motion Control Functions 182
Table 4-17. Jog Functions 186
Table 4-18. Slaved Motion Functions 190
Table 4-19. Multi-Point Motion Functions 196
Table 4-20. Arbitrary Path Motion Functions 200
Table 4-21. PVT Functions 205
Table 4-22. Segmented Motion Functions 213
Table 4-23. Points and Segments Manipulation Functions 250
Table 4-24. Data Collection Functions 260
Table 4-25. Status Report Functions 265
Table 4-26. Input/Output Access Functions 272
Table 4-27. Safety Control Functions 292
Table 4-28. Wait-for-Condition Functions 315
Table 4-29. Callback Registration Functions 324
Table 4-30. Variables Management Functions 330
Table 4-31. Service Functions 333
Version 2.70 22
SPiiPlus C Library Reference Programmer's Guide
Version 2.70 23
SPiiPlus C Library Reference Programmer's Guide
1. Introduction
1. Introduction
1.1 Document Scope
The SPiiPlus C Library supports the creation of a user application that operates on 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.
Version 2.70 24
SPiiPlus C Library Reference Programmer's Guide
2. SPiiPlus C Library Overview
Version 2.70 25
SPiiPlus C Library Reference Programmer's Guide
2. SPiiPlus C Library Overview
2.8 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.
Version 2.70 26
SPiiPlus C Library Reference Programmer's Guide
2. SPiiPlus C Library Overview
Version 2.70 27
SPiiPlus C Library Reference Programmer's Guide
2. SPiiPlus C Library Overview
int acsc_ToPoint(HANDLE Handle, int Flags, int Axis, double Point, ACSC_
WAITBLOCK* Wait)
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:
Version 2.70 28
SPiiPlus C Library Reference Programmer's Guide
2. SPiiPlus C Library Overview
ACSC_
Plan the motion, but don’t start until the acsc_Go function is called.
AMF_WAIT
ACSC_
The Point value is relative to the end-point of the previous motion. If the flag is
AMF_
not specified, the Point specifies an absolute coordinate.
RELATIVE
2.10 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
Version 2.70 29
SPiiPlus C Library Reference Programmer's Guide
2. SPiiPlus C Library Overview
2.10.1 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.
The DPRAM is a memory block that is accessible from the host and from the controller. This feature
provides fast data exchange between the host and the controller.
Version 2.70 30
SPiiPlus C Library Reference Programmer's Guide
2. SPiiPlus C Library Overview
The SPiiPlus controller provides 1024 bytes of dual-port ram memory (DPRAM). Relative address
range of DPRAM is from byte 0 to byte 0x3FF.
The first 128 bytes (relative addresses from 0 to 0x080) are reserved for system use. The rest of
the memory is free for the user needs.
The DPRAM functions are available with any communication channel, however it is important to
remember that only PCI bus communication provide real physical access to controllers DPRAM and
works very fast (sub-millisecond level).
In all other channels, the DPRAM operation is simulated. Each operation includes communication
with the controller. Specific figures depend on the communication channel rate.
Using DPRAM communication in a non-PCI communication channel is recommended if an
application is primarily intended for PCI channel, but requires full compatibility with other
communication channels.
Shared Memory is applicable only to the SPiiPlusSC. For details of the SPiiPlus SC see the
SPiiPlusSC Motion Controller User Guide.
Shared Memory refers to a 100 KByte section of the memory where variables used by both the
SPiiPlus SC RTOS processes and the Windows processes are stored. Access to the shared memory
by the Windows applications does not affect the RTOS execution. Special C read and write functions
have been incorporated to access the Shared Memory (see Shared Memory Functions).
There are three possible approaches regarding when a library function returns control to the
calling thread:
> Waiting call
The function waits for the controller response and then returns. For many commands, the
controller response does not signal the completion of the operation. The controller response only
acknowledges that the controller accepted the command and started the process of its execution.
For example, the controller responds to a motion command when it has planned the motion, but
has not executed yet.
> Non-waiting call
The library function initiates transmission of the command to the controller and returns
immediately without waiting for the controller response. An internal library thread sends the
command to the controller and retrieves the result. To get the result of operation the application
calls the acsc_WaitForAsyncCall function.
> Non-waiting call with neglect of operation results
The same as the previous call, only the library does not retrieve the controller response. This mode
can be useful when the application ignores the controller responses.
Version 2.70 31
SPiiPlus C Library Reference Programmer's Guide
2. SPiiPlus C Library Overview
Most library functions can be called in either waiting or non-waiting mode. The pointer Wait to the
ACSC_WAITBLOCK structure provides the selection between waiting and non-waiting modes as
follows:
> Zero Wait (NULL character) defines a waiting call. The function does not return until the
controller response is received.
> 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.
If you work with multiple non-waiting calls and the ACSC_COMMANDSQUEUEFULL error
pops up all the time, the structure of your application is too demanding. This means
that you are trying to activate more than 256 calls without retrieving the results.
If the error message pops up occasionally, try increasing the timeout.
#include “ACSC.h”
Char* cmd = “?$\r”; // get motors state
char buf[101];
int Received;
ACSC_WAITBLOCK wait;
// example of the waiting call of acsc_Transaction
if (!acsc_Transaction( Handle, // communication handle
Version 2.70 32
SPiiPlus C Library Reference Programmer's Guide
2. SPiiPlus C Library Overview
Version 2.70 33
SPiiPlus C Library Reference Programmer's Guide
3. Using the SPiiPlus C Library
> ACSC.H – C header file with API functions and Constant declarations.
Version 2.70 34
SPiiPlus C Library Reference Programmer's Guide
3. Using the SPiiPlus C Library
accessible to the application. The library installation puts the file in the SYSTEM32 directory,
where it can be found by any application.
> ACSCL_X64.DLL – ACS Motion Control© C Library API for 64-bit environment
> ACSPCI32.SYS – ACS Motion Control© kernel-mode PCI Device Driver (for 32-bit
environment)
> ACSPCI64.SYS – ACS Motion Control© kernel-mode PCI Device Driver (for 64-bit
environment)
> ACS.ESTOP.EXE – ACS Motion Control© SPiiPlus Emergency Stop
> ACSCSRV.EXE – ACS Motion Control© SPiiPlus User Mode Driver (UMD)
Version 2.70 35
SPiiPlus C Library Reference Programmer's Guide
3. Using the SPiiPlus C Library
In order to provide WinDriver information for Windows "Plug and Play," redistribute INF files as
follows:
> ACSPCI.INF
> WINDRVR6.INF
The INF files are required only for registration process; they should be placed in well-
known destinations.
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run a new
string value named “ACSCSRV”
The string should contain the full path to the location of ACSCSRV.EXE.
On start-up Windows will start the UMD on the current machine for each user that logs in.
Version 2.70 36
SPiiPlus C Library Reference Programmer's Guide
3. Using the SPiiPlus C Library
Version 2.70 37
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
4. C Library Functions
This chapter describes each of the functions available in the SPiiPlus C Library. The functions are
arranged in functional groups.
For each function there is a:
> Description - A short description of the use of the function
> Syntax - The calling syntax
> Arguments - List and definition of function arguments
> Return value - A description of the value, if any, that the function returns
> Comments - Where relevant, additional information on the function
> Example - Short code example in C language
The functions are grouped in the following categories:
> Communication Functions
> Service Communication Functions
> ACSPL+ Program Management Functions
> Read and Write Variables Functions
> Load/Upload Data To/From Controller Functions
> Multiple Thread Synchronization Functions
> History Buffer Management Functions
> Unsolicited Messages Buffer Management Functions
> Log File Management Functions
> SPiiPlusSC Log File Management Functions
> System Configuration Functions
> Setting and Reading Motion Parameters Functions
> Axis/Motor Management Functions
> Motion Management Functions
> Point-to-Point Motion Functions
> Track Motion Control Functions
> Jog Functions
> Slaved Motion Functions
> Multi-Point Motion Functions
> Arbitrary Path Motion Functions
> PVT Functions
> Segmented Motion Functions
> Points and Segments Manipulation Functions
Version 2.70 38
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
Function Description
acsc_ Opens communication with the controller via Ethernet using TCP
OpenCommEthernetTCP protocol.
acsc_ Opens communication with the controller via Ethernet using the
OpenCommEthernetUDP UDP protocol.
acsc_
Starts up the Simulator and opens communication with it.
OpenCommSimulator
acsc_OpenCommPCI Opens communication with the SPiiPlus PCI via PCI Bus.
Version 2.70 39
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
Function Description
4.1.1 acsc_OpenCommSerial
Description
The function opens communication with the controller via a serial port.
Syntax
HANDLE acsc_OpenCommSerial(int Channel, int Rate)
Arguments
Rate This parameter must be equal to the controller variable IOBAUD for the successful
link with the controller. If ACSC_AUTO constant is passed, the function will
automatically determine the baud rate.
Return Value
If the function succeeds, the return value is a valid communication handle. The handle must be
used in all subsequent function calls that refer to the open communication channel.
If the function fails, the return value is ACSC_INVALID (-1).
Version 2.70 40
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
Comments
After a channel is open, any SPiiPlus C function works with the channel irrespective of the physical
nature of the channel.
Example
4.1.2 acsc_OpenCommEthernetTCP
Description
The function opens communication with the controller via Ethernet using TCP protocol.
Syntax
int acsc_OpenCommEthernetTCP(char* Address, int Port)
Arguments
Return Value
If the function succeeds, the return value is a valid communication handle. The handle must be
used in all subsequent function calls that refer to the open communication channel.
If the function fails, the return value is ACSC_INVALID (-1).
Version 2.70 41
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
Comments
None.
Example
HANDLE hComm=(HANDLE)-1;
int Port = 703;
hComm = acsc_OpenCommEthernetTCP("10.0.0.1",Port);
if (hComm == ACSC_INVALID)
{
printf("Error while opening communication: %d\n",
acsc_GetLastError());
return -1;
}
4.1.3 acsc_OpenCommEthernetUDP
Description
The function opens communication with the controller via Ethernet using the UDP protocol.
Syntax
int acsc_OpenCommEthernetUPD(char* Address, int Port)
Arguments
Return Value
If the function succeeds, the return value is a valid communication handle. The handle must be
used in all subsequent function calls that refer to the open communication channel.
If the function fails, the return value is ACSC_INVALID (-1).
Comments
None
Version 2.70 42
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
Example
HANDLE hComm=(HANDLE)-1;
int Port = 704;
hComm = acsc_OpenCommEthernetUDP("10.0.0.1",Port);
if (hComm == ACSC_INVALID)
{
printf("Error while opening communication: %d\n",
acsc_GetLastError());
return -1;
}
4.1.4 acsc_OpenCommSimulator
Description
The function executes the SPiiPlus stand-alone simulator via SPiiPlus User ModeDriver in the case
that it is not running.
The function connects to the simulator via TCP/IP protocol.
Syntax
HANDLE acsc_OpenCommSimulator()
Return value
If the function succeeds, then the return value is a HANDLE that is used as a standing connection to
the simulator.
If the function fails, then the return value is ACSC_INVALID (-1) and an appropriate error is set.
Error codes (in case of failure)
ACSC_SIMULATOR_RUN_EXT – if the ports set for simulator in UMD are taken by another application.
ACSC_SIMULATOR_NOT_SET – in case a simulator execution attempt was made without setting a
simulator executable and default simulator executable was not found.
Example
Version 2.70 43
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
4.1.5 acsc_CloseSimulator
Description
The function Stops the SPiiPlus simulator via UMD in the case that it is running.
Syntax
int acsc_CloseSimulator()
Return value
If the function succeeds,: return value = 1.
In the case of function failure: return value = 0.
4.1.6 acsc_OpenCommPCI
Description
The function opens a communication channel with the controller via PCI Bus.
Up to 4-communication channels can be open simultaneously with the same SPiiPlus card through
the PCI Bus.
Syntax
HANDLE acsc_OpenCommPCI(int SlotNumber)
Arguments
Return Value
If the function succeeds, the return value is a valid communication handle. The handle must be
used in all subsequent function calls that refer to the open communication channel.
If the function fails, the return value is ACSC_INVALID (-1).
Comments
To open PCI communication the host PC, one or more controller cards must be inserted into the
computer PCI Bus.
Version 2.70 44
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
After a channel is open, any SPiiPlus C function works with the channel irrespective of the physical
nature of the channel.
Example
4.1.7 acsc_GetPCICards
Description
The function retrieves information about the controller cards inserted in the computer PCI Bus.
Syntax
int acsc_GetPCICards(ACSC_PCI_SLOT* Cards, int Count, int* ObtainedCards)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function scans the PCI Bus for the inserted controller cards and fills the Cards array with
information about the detected cards.
The Structure ACSC_PCI_SLOT is defined as follows:
Structure: ACSC_PCI_SLOT {int BusNumber; int SlotNumber; int Function;};
Where:
> BusNumber = bus number
> SlotNumber = slot number of the controller card
> Function = PCI function of the controller card
Within these arguments, SlotNumber can be used in the acsc_OpenCommPCI call to open
communication with a specific card. Other members have no use in the SPiiPlus C Library.
Version 2.70 45
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
If no controller cards are detected, the function assigns the ObtainedCards with zero and does not
fill the Cards array. If one or more controller cards are detected, the function assigns the
ObtainedCards with a number of detected cards and places one ACSC_PCI_SLOT structure per each
detected card into the Cards array.
If the size of Cards array specified by the Count parameter is less than the number of detected
cards, the function assigns the ObtainedCards with a number of actually detected cards, but fills
only the Count elements of the Cards array.
Example
ACSC_PCI_SLOT CardsList[16];
int DetectedCardsCount;
if (acsc_GetPCICards(CardsList, // pointer to the declared array
// to save the detected
// cards information
16, // size of this array
&DetectedCardsCount // number of cards that were
// actually detected
))
{
printf("Found %d SB1218PCI cards\n", DetectedCardsCount);
}
else
{
printf("error while scanning PCI bus: %d\n", acsc_GetLastError());
}
4.1.8 acsc_SetServerExtLogin
Description
The function defines the User Mode Driver (UMD) host IP address, and port along with passing login
data.
Syntax
int acsc_SetServerExtLogin(char *IP, int Port, char *Username, char *Password,
char *Domain)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
Version 2.70 46
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
Comments
Use the function only if the application needs to establish communication with a controller through
a remote computer.
If the function is not called, by default, all connections are established through the local computer.
Only a controller connected to the local computer by a serial cable, PCI bus or Ethernet can be
accessed.
The function sets the IP address and port number of the User Mode Driver (UMD) host and logs the
user in. Once the function is called all acsc_OpenCommxxx calls will attempt to establish
communication via the UMD that was specified in the most recent acsc_SetServrExtLogin call. In
order to establish communication via a different UMD host acsc_SetServrExtLogin has to be called
again.
Applications can simultaneously communicate through several communication servers. Use the
following pattern to open communication channels through several servers:
Example
acsc_SetServerExtLogin("10.0.0.13",7777,"Mickey","viva11","ACS-Motion")
Handle=acsc_OpenCommPCI(-1)//Will attempt to find active UMD running on
host
//"10.0.0.13" and listenning on Port 7777
//on the host attempting to login as "Mickey"
//and open communication with PCI card at that host
4.1.9 acsc_CloseComm
Description
The function closes communication via the specified communication channel.
Syntax
int acsc_CloseComm(HANDLE Handle)
Version 2.70 47
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function closes the communication channel and releases all system resources related to the
channel. If the function closes communication with the Simulator, the function also terminates the
Simulator.
Each acsc_OpenComm*** call in the application must have the corresponding acsc_CloseComm call
in order to return the resources to the system.
Example
if (!acsc_CloseComm(Handle))
{
printf("error closing communication: %d\n", acsc_GetLastError());
}
4.1.10 acsc_Transaction
Description
The function executes one transaction with the controller, i.e. it sends a command and receives a
controller response.
Syntax
int acsc_Transaction (HANDLE Handle, char* OutBuf, int OutCount, char* InBuf,
int InCount, int* Received, ACSC_WAITBLOCK* Wait)
Any ASCII command being sent to the controller must end with the '\r' (13) character,
otherwise it will not be recognized as valid.
Arguments
Version 2.70 48
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The full operation of transaction includes the following steps:
1. Send OutCount characters from OutBuf to the controller.
2. Waits until the controller response is received or the timeout occurs. In the case of
timeout, set Received to zero, store error value and return.
3. Store the controller response in InBuf. If the controller response is longer than InCount,
store only InCount characters.
4. Writes to Received the exact number of the characters stored in InBuf.
5. Analyzes the controller response, and set the error value if the response indicates an
error.
If the Wait argument is NULL, the call is waiting and the function does not return until the full
operation is finished.
If the Wait argument points to a valid ACSC_WAITBLOCK structure, the call is non-waiting and the
function returns immediately after the first step. An internal library thread executes the rest of the
operation. The calling thread can validate if the operation finished and can retrieve the operation
result using the acsc_WaitForAsyncCall function.
Example
Version 2.70 49
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
ACSC_WAITBLOCK wait;
// example of the waiting call of acsc_Transaction
if (!acsc_Transaction( Handle, // communication handle
cmd, // pointer to the buffer that contains
// executedcontroller’s command
strlen(cmd), // size of this buffer
buf, // input buffer that receives controller
// response
100, // size of this buffer
&Received, // number of characters that were actually
// received
NULL // waiting call
))
{
printf("transaction error: %d\n", acsc_GetLastError());
}
// example of non-wainig call of acsc_Transaction
if (acsc_Transaction(Handle, cmd, strlen(cmd), buf, 100, &Received,
&wait))
{
// something doing here
….
// waiting for the controller’s response 5 sec
if (acsc_WaitForAsyncCall( Handle, buf, &Received, &wait, 5000))
{
buf[Received] = ‘\0’;
printf(“Controller serial number: %s\n”, buf);
}
4.1.11 acsc_Command
Description
The function sends a command to the controller and analyzes the controller response.
Syntax
int acsc_Command (HANDLE Handle, char* OutBuf, int OutCount,
ACSC_WAITBLOCK* Wait)
Any ASCII command being sent to the controller must end with '\r' (13) character,
otherwise it will not be recognized as valid.
Arguments
Version 2.70 50
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function is similar to acsc_Transaction except that the controller response is not transferred to
the calling thread. The function is used mainly for the commands that the controller responds to
with a prompt. In this case, the exact characters that constitute the prompt are irrelevant for the
calling thread. The function provides analysis of the prompt, and if the operation fails, the calling
thread can obtain the error code.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.1.12 acsc_WaitForAsyncCall
Description
The function waits for completion of asynchronous call and retrieves a data.
Version 2.70 51
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
Syntax
int acsc_WaitForAsyncCall(HANDLE Handle, void* Buf, int* Received,
ACSC_WAITBLOCK* Wait, int Timeout)
Arguments
Pointer to the buffer that receives controller response. This parameter must be
the same pointer that was specified for asynchronous call of SPiiPlus C function.
Buf
If the SPiiPlus C function does not accept a buffer as a parameter, Buf has to be
NULL pointer.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero. The Ret field of Wait contains the error code that the
non-waiting call caused. If Wait.Ret is zero, the call succeeded: no errors occurred.
Comments
The function waits for completion of asynchronous call, corresponds to the Wait parameter, and
retrieves controller response to the buffer pointed by Buf. The Wait and Buf must be the same
pointers passed to SPiiPlus C function when asynchronous call was initiated.
If the call of SPiiPlus C function was successful, the function retrieves controller response to the
buffer Buf. The Received parameter will contain the number of actually received characters.
If the call of SPiiPlus C function does not return a response (for example: acsc_Enable, acsc_Jog, etc.)
Buf has to be NULL.
If the call of SPiiPlus C function returned the error, the function retrieves this error code in the Ret
member of the Wait parameter.
If the SPiiPlus C function has not been completed in Timeout milliseconds, the function aborts
specified asynchronous call and returns ACSC_TIMEOUT error.
If the call of SPiiPlus C function has been aborted by the acsc_CancelOperationfunction, the function
returns ACSC_OPERATIONABORTED error.
Version 2.70 52
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
Example
4.1.13 acsc_CancelOperation
Description
The function cancels any asynchronous (non-waiting) call or all operations with the specified
communication handle.
Syntax
int acsc_CancelOperation(HANDLE Handle, ACSC_WAITBLOCK* Wait)
Arguments
Pointer to the ACSC_WAITBLOCK structure that was passed to the function that
Wait
initiated the asynchronous (non-waiting) call.
Version 2.70 53
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
Return Value
If the function succeeds, the return value is non-zero. The corresponding asynchronous call was
successfully canceled.
If the function fails, the return value is zero.
Comments
If Wait points to a valid ACSC_WAITBLOCK structure, the function cancels the corresponding call with
the error ACSC_OPERATIONABORTED. If the corresponding call was not found the error ACSC_
CANCELOPERATIONERROR will be returned by acsc_GetLastErrorfunction.
If Wait is NULL, the function cancels all of the waiting and non-waiting calls for the specified
communication handle.
Example
4.1.14 acsc_GetEthernetCards
Description
The function detects available controllers through a standard Ethernet connection. By default, the
function searches the local network segment. The default setting can be changed, as described
below.
Syntax
int acsc_GetEthernetCards(in_addr*IPaddresses,int Max, int*Ncontrollers,
unsigned long BroadcastAddress)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Version 2.70 54
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
Comments
Function Execution
The function executes as follows:
1. Broadcasts a message to the network
2. Collects all received replies
3. Filters out all replies sent by nodes other than the SPiiPlus controller
4. The function then stores controller's IP addresses in the IPaddresses array, assigns
Ncontrollers with the number of detected controllers and returns.
If the size of the IPaddresses array appears too small for all detected controllers (Ncontrollers >
Max), only Max addresses are stored in the array.
In order to convert the in_addr structure to a dot-delineated string, use the inet_ntoa() Microsoft
Windows function.
Broadcasting Considerations
If BroadcastAddress needs to be specified as other than ACSC_NONE, use the inet_addr Microsoft
Windows function to convert the dot-delineated string to an integer parameter.
The function uses the following broadcasting message:
"ACS-TECH80\r"
The target port for broadcasting is 700. A node that doesn't support port 700 simply does not see
the broadcasting message. If a node other than the controller supports port 700, the node receives
the message. However, since the message format is meaningful only for SPiiPlus controllers, any
other node that receives the message either ignores it or responds with an error message that is
filtered out by the function.
Normally, the user specifies ACSC_NONE in the BroadcastAddress parameter. In this case, the
function uses broadcast address 255.255.255.255. The address causes broadcasting in a local
segment of the network. If the host computer is connected to several local segments (multi-home
node), the broadcasting message is sent to all connected segments.
The user may wish to specify explicit broadcasting addresses in the following cases:
> To reduce the broadcasting area. In a multi-home node, the specific address can restrict
broadcasting to one of the connected segments.
> To extend the broadcasting area. If a wide area network (WAN) is supported, a proper
broadcasting address can broadcast to the entire WAN, or part of the WAN.
For information about how to use broadcasting addresses, refer to the network documentation.
Version 2.70 55
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
SPiiPlus controllers running with FW 4.50 or below will not be found with a mask other
than ACSC_NONE
Example
in_addr IPaddresses[100];
int Ncontrollers;
char *DotStr;
char Version[100];
int N;
HANDLE h;
int I;
if (!acsc_GetEthernetCards(IPaddresses,100, &Ncontrollers,ACSC_NONE))
{
printf("Error %d\n", acsc_GetLastError());
}
for(I=0;I<Ncontrollers;I++)
{
DotStr=inet_ntoa(IPaddresses[I]);
h=acsc_OpenCommEthernet(DotStr,ACSC_SOCKET_STREAM_PORT);
if(h!=ACSC_INVALID)
{
if(acsc_GetFirmwareVersion(h,Version, 100,&N,NULL))
{
Version[N]=0;
printf("%s\n",Version);
}
acsc_CloseComm(h);
}
}
4.1.15 acsc_GetConnectionsList
Description
The function retrieves all currently opened connections on the active server and their details.
Syntax
int acsc_GetConnectionsList(ACSC_CONNECTION_DESC* ConnectionsList,
int MaxNumConnections, int* NumConnections)
Arguments
Version 2.70 56
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
If the size of the ConnectionsList array appears too small for all detected connections (Connections
> MaxNumConnections), only MaxNumConnections connections are stored in the array.
This function can be used to check if there are some unused connections that remain from an
application that did not close the communication channel or were not gracefully closed (terminated
or killed).
Each connection from returned list can be terminated only by the acsc_TerminateConnection
function.
Version 2.70 57
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
Example
int NConnections;
ACSC_CONNECTION_DESC Connections[100];
int I;
char app_name[]="needed_app.exe";
if (!acsc_GetConnectionsList(Connections, 100, &NConnections))
{
printf("Error %d\n", acsc_GetLastError());
}
for(I=0;I<NConnections;I++)
{
if ((strcmp(Connections[I].Application, app_name)==0) &&
(OpenProcess(0,0,Connections[I].ProcessId) == NULL))
// Check if process is
//still running by OpenProcess() function,
//only if it was executed on local PC.
{
if (!acsc_TerminateConnection(&(Connections[i])))
{
printf("Error closing communication of %s application: %d\n",
Connections[I].Application, acsc_GetLastError());
}
else
{
printf("Communication of %s application is successfully closed!\n",
Connections[I].Application);
}
}
}
4.1.16 acsc_GetConnectionInfo
Description
The function is used to retrieve the details of opened communication channel.
Syntax
int acsc_GetConnectionInfo(HANDLE Handle,
ACSC_CONNECTION_INFO* ConnectionInfo)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Version 2.70 58
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
Example
ACSC_CONNECTION_INFO ConnectionInfo;
if (!acsc_GetConnectionInfo(Handle, &ConnectionInfo))
{
printf("acsc_GetConnectionInfo(): Error Occurred - %d\n",
acsc_GetLastError());
return;
}
4.1.17 acsc_TerminateConnection
Description
The function terminates a given communication channel (connection) of the active server.
Syntax
int acsc_TerminateConnection(ACSC_CONNECTION_DESC* Connection)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
This function can be used to terminate an unused connection that remains from an application that
did not close the communication channel or was not gracefully closed (terminated or killed). The
Connection parameter should be passed as it was retrieved by acsc_GetConnectionsList function.
Example
int NConnections;
ACSC_CONNECTION_DESC Connections[100];
int I;
char app_name[]="needed_app.exe";
acsc_SetServerExtLogin("10.0.0.13",7777,”Greg”,”MyPassword”,”ACS-
Version 2.70 59
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
Motion”);
if (!acsc_GetConnectionsList(Connections, 100, &NConnections))
{
printf("Error %d\n", acsc_GetLastError());
}
for(I=0;I<NConnections;I++)
{
if ((strcmp(Connections[I].Application, app_name)==0) &&
(OpenProcess(Connections[I].ProcessId) == NULL))
// Check if process is still
//running by OpenProcess() function, only
//if it was executed on local PC.
{
if (!acsc_TerminateConnection(&(Connections[i])))
{
printf("Error closing communication of %s application: %d\n",
Connections[I].Application, acsc_GetLastError());
}
else
{
printf("Communication of %s application is successfully closed!\n",
Connections[I].Application);
}
}
}
Function Description
Version 2.70 60
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
Function Description
4.2.1 acsc_GetCommOptions
Description
The function retrieves the communication options.
Syntax
int acsc_GetCommOptions(HANDLE Handle, unsigned int* Options)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function retrieves the current communication options. To set the communication option call
acsc_SetCommOptions.
Example
4.2.2 acsc_GetDefaultTimeout
Description
The function retrieves default communication timeout.
Version 2.70 61
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
Syntax
int acsc_GetDefaultTimeout(HANDLE Handle)
Arguments
Return Value
If the function succeeds, the return value is the default time-out value in milliseconds.
If the function fails, the return value is zero.
Comments
The value of the default time-out depends on the type of established communication channel.
Time-outalsodepends on the baud rate value for serial communication.
Example
4.2.3 acsc_GetErrorString
Description
The function retrieves the explanation of an error code.
Syntax
int acsc_GetErrorString(HANDLE Handle, int ErrorCode, char* ErrorStr, int Count,
int* Received)
Arguments
ErrorStr Pointer to the buffer that receives the text explanation of ErrorCode.
Return Value
If the function succeeds, the return value is non-zero.
Version 2.70 62
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
Comments
The function retrieves the string that contains the text explanation of the error code returned by
the acsc_GetLastError, acsc_GetMotorError, and acsc_GetProgramError functions.
The function will not copy more than Count characters to the ErrorStr buffer. If the buffer is too
small, the error explanation can be truncated.
For the SPiiPlus C Library error codes, the function returns immediately with the text explanation.
For the controller’s error codes, the function refers to the controller to get the text explanation.
Example
char ErrorStr[256];
int ErrorCode, Received;
ErrorCode = acsc_GetLastError();
if (acsc_GetErrorString(Handle, // communication handle
ErrorCode, // error code
ErrorStr, // buffer for the error explanation
255, // available buffer length
&Received // number of actually received bytes
)
{
ErrorStr[Received] = '\0';
printf("function returned error: %d (%s)\n", ErrorCode, ErrorStr);
}
4.2.4 acsc_GetLastError
Description
The function returns the calling thread’s last-error code value. The last-error code is maintained on
a per-thread basis. Multiple threads do not overwrite each other’s last-error code.
Syntax
int acsc_GetLastError()
Arguments
This function has no arguments.
Return Value
The return value is the calling thread’s last-error code value.
Comments
It is necessary to call acsc_GetLastError immediately when some functions return zero value. This is
because all of the functions rewrite the error code value when they are called.
For a complete List of Error Codes, see Error Codes.
Version 2.70 63
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
Example
4.2.5 acsc_GetLibraryVersion
Description
The function retrieves the SPiiPlus C Library version number.
Syntax
unsigned int acsc_GetLibraryVersion()
Arguments
This function has no arguments.
Return Value
The return value is the 32-bit unsigned integer value, which specifies binary version number.
Comments
The SPiiPlus C Library version consists of four (or less) numbers separated by points: #.#.#.#. The
binary version number is represented by 32-bit unsigned integer value. Each byte of this value
specifies one number in the following order: high byte of high word – first number, low byte of
high word – second number, high byte of low word – third number and low byte of low word –
forth number. For example version “2.10” has the following binary representation (hexadecimal
format): 0x020A0000.
First two numbers in the string form are obligatory. Any release version of the library consists of
two numbers. The third and fourth numbers specify an alpha or beta version, special or private
build, etc.
Example
4.2.6 acsc_GetTimeout
Description
The function retrieves communication timeout.
Syntax
int acsc_GetTimeout(HANDLE Handle)
Arguments
Return Value
If the function succeeds, the return value is the current timeout value in milliseconds.
Version 2.70 64
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
Example
4.2.7 acsc_SetIterations
Description
The function sets the number of iterations in one transaction.
Syntax
int acsc_SetIterations(HANDLE Handle, int Iterations)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
If, after the transmission of command to the controller, the controller response is not received
during the predefined time, the library repeats the transmission of command. The number of
those iterations is defined by the Iterations parameter for each communication channel
independently.
Most of the SPiiPlus C functions perform communication with the controller by transactions (i.e.,
they send commands and wait for responses) that are based on the acsc_Transaction function.
Therefore,the changing of number of iterations can have an influence on the behavior of the user
application.
The default the number of iterations for all communication channels is 2.
Version 2.70 65
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
Example
if (!acsc_SetIterations(Handle, 2))
{
printf("number of iterations setting error: %d\n",
acsc_GetLastError());
}
4.2.8 acsc_SetCommOptions
Description
The function sets the communication options.
Syntax
int acsc_SetCommOptions(HANDLE Handle, unsigned int Options)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function sets the communication options. To get current communication option, call acsc_
GetCommOptions.
To add some communication options to the current configuration, modify an Option parameter
that has been filled in by a call to acsc_GetCommOptions. This ensures that the other
communication options will have same values.
Version 2.70 66
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
Example
4.2.9 acsc_SetTimeout
Description
The function sets the communication timeout.
Syntax
int acsc_SetTimeout(HANDLE Handle, int Timeout)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function sets the communication timeout.
All of the subsequent waiting calls of the functions will wait for the controller response Timeout in
milliseconds. If the controller does not respond to the sent command during this time, SPiiPlus C
functions return with zero value. In this case, the call of acsc_GetLastError will return the ACSC_
TIMEOUT error.
Example
if (!acsc_SetTimeout(Handle, 5000))
{
printf("timeout set error: %d\n", acsc_GetLastError());
}
4.2.10 acsc_SetQueueOverflowTimeout
Description
The function sets the Queue Overflow Timeout.
Version 2.70 67
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
Syntax
int acsc_SetQueueOverflowTimeout (HANDLE Handle, int Delay)
Arguments
Return Value
If the function fails, the return value is zero.
Comments
The function sets Queue Overflow Timeout value in milliseconds. See also Non-Waiting Calls.
Example
if (!acsc_ SetQueueOverflowTimeout(Handle,100))
{
printf("Queue Overflow Timeout setting error: %d\n",
acsc_GetLastError());
}
4.2.11 acsc_GetQueueOverflowTimeout
Description
The function retrieves the Queue Overflow Timeout.
Syntax
int acsc_GetQueueOverflowTimeout(HANDLE Handle)
Arguments
Return Value
If the function succeeds, the return value is the current Queue Overflow Timeout value in
milliseconds.
If the function fails, the return value is ACSC_NONE.
Comments
See Non-Waiting Calls for an explanation about Queue Overflow Timeout.
Version 2.70 68
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
Example
Function Description
acsc_ Clears the specified program buffer and then loads ACSPL+
LoadBufferIgnoreServiceLines program to this buffer.
4.3.1 acsc_AppendBuffer
Description
The function appends one or more ACSPL+ lines to the program in the specified buffer.
Version 2.70 69
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
Syntax
int acsc_AppendBuffer(HANDLE Handle, int Buffer, char* Program, int Count,
ACSC_WAITBLOCK* Wait)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function appends one or more ACSPL+ lines to the program in the specified buffer. If the
buffer already contains any program, the new text is appended to the end of the existing program.
No compilation or syntax check is provided during downloading. In fact, any text, not only a correct
program, can be inserted into a buffer. In order to compile the program and check its accuracy, the
compile command must be executed after downloading.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
Version 2.70 70
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
4.3.2 acsc_ClearBuffer
Description
The function deletes the specified ACSPL+ program lines in the specified program buffer.
Syntax
int acsc_ClearBuffer(HANDLE Handle, int Buffer, int FromLine, int ToLine,
ACSC_WAITBLOCK* Wait)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Version 2.70 71
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
Comments
The function deletes the specified ACSPL+ program lines in the specified program buffer.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.3.3 acsc_CompileBuffer
Description
The function compiles ACSPL+ program in the specified program buffer(s).
Syntax
int acsc_CompileBuffer(HANDLE Handle, int Buffer, ACSC_WAITBLOCK* Wait)
Arguments
Version 2.70 72
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
Return Value
The function returns non-zero if it succeeded to perform the compile operation on the buffer, such
that the communication channel is OK, the specified buffer is not running and compile operation
was performed. However, it does not mean that compilation succeeded. If the return value is zero,
compile operation could not be performed by some reason.
In order to get information about compilation results, use acsc_ReadInteger to read PERR [X], which
contains the last error that occurred in buffer X. If PERR [X] is zero, the buffer was compiled
successfully.
Otherwise, PERR [X] tells you about the error that occurred during the compilation.
Comments
The function compiles ACSPL+ program in the specified program buffer or all programs in all
buffers if the parameter Buffer is ACSC_NONE.
If attempting to compile the D-Buffer, all other buffers will be stopped and put in a
non-compiled state.
The function can wait for the controller response or can return immediately as specified by the
Wait argument.
The controller response indicates that the program was compiled successfully.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.3.4 acsc_LoadBuffer
Description
The function clears the specified program buffer and then loads ACSPL+ program to this buffer.
Syntax
int acsc_LoadBuffer(HANDLE Handle, int Buffer, char* Program, int Count,
ACSC_WAITBLOCK* Wait)
Version 2.70 73
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function clears the specified program buffer and then loads ACSPL+ program to this buffer.
No compilation or syntax check is provided during downloading. Any text, not only a correct
program, can be inserted into a buffer. In order to compile the program and check its accuracy, the
compile command must be executed after downloading.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
Version 2.70 74
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
// ACSPL+ program(s).
strlen(buf), // size of this buffer
NULL // waiting call
))
{
printf("transaction error: %d\n", acsc_GetLastError());
}
4.3.5 acsc_LoadBufferIgnoreServiceLines
Description
The function clears the specified program buffer and then loads ACSPL+ to this buffer.
All lines that start with # are ignored.
This function is obsolete and is maintained only for backwards compatibility. When
loading files saved from the MultiDebugger and MMI use the acsc_
LoadBuffersFromFile function.
Syntax
int acsc_LoadBufferIgnoreServiceLines(HANDLE Handle, int Buffer, char* Program,
int Count, ACSC_WAITBLOCK* Wait)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Version 2.70 75
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
Comments
The function clears the specified program buffer and then loads ACSPL+ program to this buffer.
No compilation or syntax check is provided during downloading. Any text, not only a correct
program, can be inserted into a buffer. In order to compile the program and check its accuracy, the
compile command must be executed after downloading.
You can use this function in order to load program from a file created by SPiiPlus MMI
Program Manager if it contains a program in only one buffer. If there are programs in
more than one buffer, they will all be appended because the separators are ignored.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.3.6 acsc_LoadBuffersFromFile
Description
The function opens a file that contains one or more ACSPL+ programs allocated to several buffers
and download the programs to the corresponding buffers.
Syntax
int acsc_LoadBuffersFromFile(HANDLE Handle, char *Filename,
ACSC_WAITBLOCK* Wait)
Version 2.70 76
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function analyzes the file, determines which program buffers should be loaded, clears them
and then loads ACSPL+ programs to those buffers.
SPiiPlus software tools save ACSPL+ programs in the following format:
The number of buffers in a file may change from 0 to 63 (depending on controller), without any
default order.
No compilation or syntax check is provided during downloading. Any text, not only a correct
program, can be inserted into a buffer. In order to compile the program and check its accuracy, the
compile command must be executed after downloading.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
Version 2.70 77
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
4.3.7 acsc_RunBuffer
Description
The function starts up ACSPL+ program in the specified buffer.
Syntax
int acsc_RunBuffer(HANDLE Handle, int Buffer, char* Label,
ACSC_WAITBLOCK* Wait)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function starts up ACSPL+ program in the specified buffer. The execution starts from the
specified label, or from the first line if the label is not specified.
If the program was not compiled before, the function first compiles the program and then starts it.
If an error was encountered during compilation, the program does not start.
If the program was suspended by the acsc_SuspendBuffer function, the function resumes the
program execution from the point where the program was suspended.
The function can wait for the controller response or can return immediately as specified by the
Wait argument.
Version 2.70 78
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
The controller response indicates that the program in the specified buffer was started successfully.
The function does not wait for the program end. To wait for the program end, use the acsc_
WaitProgramEnd function.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.3.8 acsc_StopBuffer
Description
The function stops the execution of ACSPL+ program in the specified buffer(s).
Syntax
int acsc_StopBuffer(HANDLE Handle, int Buffer, ACSC_WAITBLOCK* Wait)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Version 2.70 79
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
Comments
The function stops ACSPL+ program execution in the specified buffer or in all buffers if the
parameter Buffer is ACSC_NONE.
The function has no effect if the program in the specified buffer is not running.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.3.9 acsc_SuspendBuffer
Description
The function suspends the execution of ACSPL+ program in the specified program buffer(s).
Syntax
int acsc_SuspendBuffer(HANDLE Handle, int Buffer, ACSC_WAITBLOCK* Wait)
Arguments
Version 2.70 80
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function suspends ACSPL+ program execution in the specified buffer or in all buffers if the
parameter Buffer is ACSC_NONE. The function has no effect if the program in the specified buffer is
not running.
To resume execution of the program in the specified buffer, call the acsc_RunBuffer function.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.3.10 acsc_UploadBuffer
Description
The function uploads ACSPL+ program from the specified program buffer.
Syntax
int acsc_UploadBuffer(HANDLE Handle, int Buffer, int Offset, char* Program,
int Count, int* Received, ACSC_WAITBLOCK* Wait)
Arguments
Example
Version 2.70 81
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
Function Description
4.4.1 acsc_ReadInteger
Description
The function reads value(s) from integer variable.
Syntax
int acsc_ReadInteger(HANDLE Handle, int NBuf, char* Var, int From1, int To1,
int From2, int To2, int* Values, ACSC_WAITBLOCK* Wait)
Arguments
Number of program buffer for local variable or ACSC_NONE for global and standard
NBuf
variable.
Var Pointer to a null-terminated character string that contains a name of the variable.
From1,
Index range (first dimension).
To1
From2,
Index range (second dimension).
To2
Version 2.70 82
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function reads specified integer variable or array.
The variable can be a standard controller variable, a user global variable, or a user local variable.
Standard and user global variables have global scope. Therefore, parameter Nbuf must be ACSC_
NONE (-1) for these classes of variables.
User local variable exists only within a buffer. The buffer number must be specified for user local
variable.
If the variable is scalar, all indexes From1, To1, From2, To2 must be ACSC_NONE. The function reads
the requested value and assigns it to the variable pointed by Values.
If the variable is a one-dimensional array, From1, To1 must specify the index range and From2, To2
must be ACSC_NONE. Array Values must be of size To1-From1+1 at least. The function reads all
requested values from index From1 to index To1 inclusively and stores them in the Values array.
If the variable is a two-dimensional array, From1, To1 must specify the index range of the first
dimension and From2, To2 must specify the index range of the second dimension. Array Values
must be of size (To1-From1+1)x(To2-From2+1) values at least. The function uses the Values array in
such a way: first, the function reads To2-From2+1 values from row From1 and fills the Values array
elements from 0 to To2-From2, then reads To2-From2+1 values from raw From1+1 and fills the
Values array elements from To2-From2+1 to 2*(To2-From2)+1, etc.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Values and Wait items until a call to the acsc_WaitForAsyncCall function.
Version 2.70 83
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
Example
4.4.2 acsc_WriteInteger
Description
The function writes value(s) to integer variable.
Syntax
int acsc_WriteInteger(HANDLE Handle, int NBuf, char* Var, int From1, int To1,
int From2, int To2, int* Values, ACSC_WAITBLOCK* Wait)
Arguments
Number of program buffer for local variable or ACSC_NONE for global and standard
NBuf
variable.
Var Pointer to the null-terminated character string contained name of the variable.
From1,
Index range (first dimension).
To1
From2,
Index range (second dimension).
To2
Version 2.70 84
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function writes to a specified integer variable or array.
The variable can be a standard controller variable, user global or user local.
Standard and user global variables have global scope. Therefore, parameter Nbuf must be ACSC_
NONE (-1) for these classes of variables.
User local variable exists only within a buffer. The buffer number must be specified for user local
variable.
If the variable is scalar, all indexes From1, To1, From2, To2 must be ACSC_NONE (-1). The function
writes the value pointed by Values to the specified variable.
If the variable is a one-dimensional array, From1, To1 must specify the index range and From2, To2
must be ACSC_NONE (-1). Array Values must contain To1-From1+1 values at least. The function writes
the values to the specified variable from index From1 to index To1 inclusively.
If the variable is a two-dimensional array, From1, To1 must specify the index range of the first
dimension and From2, To2 must specify the index range of the second dimension. Array Values
must contain (To1-From1+1)x(To2-From2+1) values at least. The function uses the Values array as
follows: first, the function retrieves the Values elements from 0 to To2-From2 and writes them to
row From1 of the specified controller variable, then retrieves the Values elements from To2-
From2+1 to 2*(To2-From2)+1 and writes them to row From1+1 of the specified controller variable,
etc.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
Version 2.70 85
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
4.4.3 acsc_ReadReal
Description
The function reads value(s) from a real variable.
Syntax
int acsc_ReadReal(HANDLE Handle, int NBuf, char* Var, int From1, int To1, int From2,
int To2, double* Values, ACSC_WAITBLOCK* Wait)
Arguments
Number of program buffer for local variable or ACSC_NONE for global and standard
NBuf
variable.
Var Pointer to the null-terminated character string contained name of the variable.
From1,
Index range (first dimension).
To1
From2,
Index range (second dimension).
To2
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Version 2.70 86
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
Comments
The function reads specified real variable or array.
The variable can be a standard controller variable, user global variable, or user local variable.
ACSPL+ and user global variables have global scope. Therefore, parameter Nbuf must be ACSC_
NONE (-1) for these classes of variables.
User local variable exists only within a buffer. The buffer number must be specified for user local
variable.
If the variable is scalar, all indexes From1, To1, From2, To2 must be ACSC_NONE. The function reads
the requested value and assigns it to the variable pointed by Values.
If the variable is a one-dimensional array, From1, To1 must specify the index range and From2, To2
must be ACSC_NONE. Array Values must be of size To1-From1+1 at least. The function reads all
requested values from index From1 to index To1 inclusively and stores them in the Values array.
If the variable is a two-dimensional array, From1, To1 must specify the index range of the first
dimension and From2, To2 must specify the index range of the second dimension. Array Values
must be of size (To1-From1+1)x(To2-From2+1) values at least. The function uses the Values array in
such a way: first, the function reads To2-From2+1 values from row From1 and fills the Values array
elements from 0 to To2-From2, then reads To2-From2+1 values from raw From1+1 and fills the
Values array elements from To2-From2+1 to 2*(To2-From2)+1, etc.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Values and Wait items until a call to the acsc_WaitForAsyncCall function.
Example
4.4.4 acsc_WriteReal
Description
The function writes value(s) to the real variable.
Version 2.70 87
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
Syntax
int acsc_WriteReal(HANDLE Handle, int NBuf, char* Var, int From1, int To1,
int From2, int To2, double* Values, ACSC_WAITBLOCK* Wait)
Arguments
Number of program buffer for local variable or ACSC_NONE for global and standard
NBuf
variable.
Var Pointer to the null-terminated character string contained name of the variable.
From1,
Index range (first dimension).
To1
From2,
Index range (second dimension).
To2
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function writes to the specified real variable or array.
The variable can be a standard controller variable, user global or user local.
Standard and user global variables have global scope. Therefore, parameter Nbuf must be ACSC_
NONE (-1) for these classes of variables.
User local variable exists only within a buffer. The buffer number must be specified for user local
variable.
Version 2.70 88
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
If the variable is scalar, all indexes From1, To1, From2, To2 must be ACSC_NONE (-1). The function
writes the value pointed by Values to the specified variable.
If the variable is a one-dimensional array, From1, To1 must specify the index range and From2, To2
must be ACSC_NONE (-1). Array Values must contain To1-From1+1 values at least. The function writes
the values to the specified variable from index From1 to index To1 inclusively.
If the variable is a two-dimensional array, From1, To1 must specify the index range of the first
dimension and From2, To2 must specify the index range of the second dimension. Array Values
must contain (To1-From1+1)x(To2-From2+1) values at least. The function uses the Values array in
such a way: first, the function retrieves the Values elements from 0 to To2-From2 and writes them
to row From1 of the specified controller variable, then retrieves the Values elements from To2-
From2+1 to 2*(To2-From2)+1 and writes them to row From1+1 of the specified controller variable,
etc.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
Function Description
4.5.1 acsc_LoadDataToController
Description
The function writes value(s) from text file to SPiiPlus controller (variable or file).
Version 2.70 89
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
Syntax
int acsc_LoadDataToController(HANDLE Handle,int Dest, char* DestName, int From1,
int To1, int From2, int To2, char* SrcFileName, int SrcNumFormat,
bool bTranspose, ACSC_WAITBLOCK* Wait)
Arguments
Number of program buffer for local variable, ACSC_NONE for global and
Dest standard variable. ACSC_FILE for loading directly to file on flash memory
(only arrays can be written directly into controller files).
If TRUE, then the array will be transposed before being loaded; otherwise,
bTranspose
this parameter has no affect.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function writes to a specified variable (scalar/array) or directly to a binary file on the controller's
flash memory. The variable can be an ACSPL+ variable, user global or user local.
The input file (pointed to by the SrcFileName argument) must be in ANSI format, otherwise error
168, ACSC_INVALID_FILE_FORMAT, is returned.
ACSPL+ and user global variables have global scope. Therefore, Dest must be ACSC_NONE (-1) for
these classes of variables. User local variable exists only within a buffer. The buffer number must
be specified for user local variable.
Version 2.70 90
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
If Dest is ACSC_NONE (-1) and there is no global variable with the name specified by DestName, it
would be defined. Arrays will be defined with dimensions (To1+1, To2+1).
If performing loading directly to a file, From1, To1, From2 and To2 are meaningless.
If the variable is scalar, the From1, To1, From2, and To2 arguments must be ACSC_NONE (-1). The
function writes the value from the file specified by SrcFileName to the variable specified by Name.
If the variable is a one-dimensional array, From1, To1 must specify the index range and the From2,
To2 must be ACSC_NONE (-1). The text file, pointed to by the SrcFileName argument, must contain
To1 to From1+1 values, at least. The function writes the values to the specified variable from the
From1 index to the To1 index inclusively.
If the variable is a two-dimensional array, From1, To1 must specify the index range of the first
dimension and From2, To2 must specify the index range of the second dimension. The text file,
pointed to by the SrcFileName argument, must contain ((To1-From1+1) x (To2-From2+1)) values, at
least; otherwise, an error will occur.
The function uses the text file as follows:
1. The function retrieves the To2-From2+1 values and writes them to row From1 of the
specified controller variable
2. Then retrieves next To2-From2+1 values and writes them to row From1+1 of the specified
controller variable, etc.
If bTranspose is TRUE, the function actions are inverted. It takes To1-From1+1 values and
writes them to column From2 of the specified controller variable, then retrieves next
To1-From1+1 values and writes them to column From2+1 of the specified controller
variable, etc.
The text file is processed line-by-line; any characters except numbers, dots, commas and exponent
'e' are translated as separators between the numbers. A line that starts with no digits is considered
as comment and ignored.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function has been made.
Version 2.70 91
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
Example
4.5.2 acsc_UploadDataFromController
Description
This function writes value(s) from the SPiiPlus controller (variable or file) to a text file.
Syntax
int acsc_UploadDataFromController(HANDLE Handle, int Src, char * SrcName,
int SrcNumFormat, int From1, int To1, int From2, int To2, char* DestFileName,
char* DestNumFormat, bool bTranspose, ACSC_WAITBLOCK* Wait)
Arguments
Number of the program buffer for local variable, ACSC_NONE for global
Src and ASCPL+ variables, and ACSC_FILE for downloading directly from file
on flash memory.
Version 2.70 92
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function writes data to the specified file from a specified variable (scalar/array) or directly from
a binary file in the controller's flash memory.
The variable can be a standard ASCPL+ variable, user global or user local. The ASCPL+ and user
global variables have global scope. In this case, the Src argument has to be ACSC_NONE (-1) for these
classes of variables. User local variable exists only within a buffer. The buffer number has to be
specified for user local variable.
If the variable (or file) with the name specified by SrcName does not exist, an error occurs.
If loading directly from the file, From1, To1, From2 and To2 are meaningless.
If the variable is a scalar, all From1, To1, From2 and To2 values must be ACSC_NONE (-1). The function
writes the value from variable specified by SrcName to the file specified by DestFileName.
If the variable is a one-dimensional array, From1, To1 must specify the index range, and From2, To2
must be ACSC_NONE (-1). The function writes the values from the specified variable from the From1
value to the To1 value, inclusively, to the file specified by DestFileName.
If the variable is a two-dimensional array, From1, To1 must specify the index range of the first
dimension, and From2, To2 must specify the index range of the second dimension. The function
uses the variable as follows: first, the function retrieves the To2-From2+1 values from the row
specified in From1 and writes them to the file specified by DestFileName. It then retrieves To2-
From2+1 values from the From1+1 row and writes them, and so forth.
Version 2.70 93
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
If bTranspose is TRUE, the function actions are inverted. It takes To1-From1+1 values from the row
specified by From2 and writes them to first column of the destination file. Then retrieves the next
To1-From1 values from row From2+1 and writes them to the next column of the file.
The destination file’s format can be determined by string specified by DestNumFormat. This string
will be used as argument in *printf function.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
Function Description
4.6.1 acsc_CaptureComm
Description
The function captures a communication channel.
Syntax
int acsc_CaptureComm(HANDLE Handle)
Arguments
Version 2.70 94
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function captures the communication handle for the calling thread and prevents access to this
communication handle from other threads.
If one thread captures the communication handle and another thread calls one of SPiiPlus C Library
functions using the same handle, the second thread will be delayed until the first thread executes
acsc_ReleaseComm.
The function provides ability to execute a sequence of functions without risk of intervention from
other threads.
Example
if (!acsc_CaptureComm(Handle))
{
printf("capture communication error: %d\n", acsc_GetLastError());
4.6.2 acsc_ReleaseComm
Description
The function releases a communication channel.
Syntax
int acsc_ReleaseComm(HANDLE Handle)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function releases the communication handle captured by acsc_CaptureComm and allows other
threads to communicate through the channel.
Version 2.70 95
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
Example
if (!acsc_ReleaseComm(Handle))
{
printf("release communication error: %d\n", acsc_GetLastError());
}
Function Description
4.7.1 acsc_OpenHistoryBuffer
Description
The function opens a history buffer.
Syntax
LP_ACSC_HISTORYBUFFER acsc_OpenHistoryBuffer(HANDLE Handle, int Size)
Arguments
Return Value
The function returns pointer to ACSC_HISTORYBUFFER structure.
If the buffer cannot be allocated, the return value is zero.
Comments
The function allocates a history buffer that stores all commands sent to the controller and all
responses and unsolicited messages received from the controller.
Only one history buffer can be open for each communication handle.
The buffer works as a cyclic buffer. When the amount of the stored data exceeds the buffer size,
the newly stored data overwrites the earliest data in the buffer.
Version 2.70 96
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
Example
4.7.2 acsc_CloseHistoryBuffer
Description
The function closes the history buffer and discards all stored history.
Syntax
int acsc_CloseHistoryBuffer(HANDLE Handle)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function closes the history buffer and releases the used memory. All information stored in the
buffer is discarded.
Example
if (!acsc_CloseHistoryBuffer(Handle))
{
printf("closing history buffer error: %d\n", acsc_GetLastError());
}
4.7.3 acsc_GetHistory
Description
The function retrieves the contents of the history buffer.
Syntax
int acsc_GetHistory(HANDLE Handle, char* Buf, int Count, int* Received,
BOOL bClear)
Version 2.70 97
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function retrieves the communication history from the history buffer and stores it in the buffer
pointed by Buf.
The communication history includes all commands sent to the controller and all responses and
unsolicited messages received from the controller. The amount of received data does not exceed
the size of the history buffer. The history buffer works as a cyclic buffer: when the amount of the
stored data exceeds the buffer size, the newly stored data overwrites the earliest data in the
buffer.
Therefore, as a rule, the retrieved communication history includes only the recently sent
commands and receives responses and unsolicited messages. The depth of the retrieved history
depends on the history buffer size.
The history data is retrieved in historical order, i.e. the earliest message is stored at the beginning
of Buf. The first retrieved message in Buf can be incomplete, because of being partially
overwritten in the history buffer.
If the size of the Buf is less than the size of the history buffer, only the most recent part of the
stored history is retrieved.
Example
int Received;
char Buf[10000];
if (!acsc_GetHistory(Handle, // communication handle
Buf, // pointer to the buffer that receives a
// communication history
10000, // size of this buffer
&Received, // number of characters that were actually
Version 2.70 98
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
// received
TRUE // clear contents of the history buffer
))
{
printf("getting history error: %d\n", acsc_GetLastError());
}
Function Description
4.8.1 acsc_OpenMessageBuffer
Description
The function opens an unsolicited messages buffer.
Syntax
LP_ACSC_HISTORYBUFFER acsc_OpenMessageBuffer(HANDLE Handle, int Size)
Arguments
Return Value
The function returns pointer to ACSC_HISTORYBUFFER structure.
If the buffer cannot be allocated, the return value is zero.
Comments
The function allocates a buffer that stores unsolicited messages from the controller.
Unsolicited messages are messages that the controller sends on its own initiative and not as a
response to command. For example, the DISP command in an ACSPL+ program forces the controller
to send an unsolicited message.
Version 2.70 99
SPiiPlus C Library Reference Programmer's Guide
4. C Library Functions
Only one message buffer can be open for each communication handle.
If the message buffer has been open, the library separates unsolicited messages from the
controller responses and stores them in the message buffer. In this case, the acsc_GetMessage
function retrieves unsolicited messages. If the message buffer is not open, acsc_Receive retrieves
both replies and unsolicited messages. If the user application does not call acsc_Receive or acsc_
GetMessage and uses only acsc_Transaction and acsc_Command, the unsolicited messages are
discarded.
The message buffer works as a FIFO buffer: acsc_GetMessage extracts the earliest message stored
in the buffer. If acsc_GetMessage extracts the messages slower than the controller produces them,
buffer overflow can occur, and some messages will be lost. Generally, the greater the buffer, the
less likely is buffer overflow to occur.
Example
4.8.2 acsc_CloseMessageBuffer
Description
The function closes the messages buffer and discards all stored unsolicited messages.
Syntax
int acsc_CloseMessageBuffer(HANDLE Handle)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function closes the message buffer and releases the used memory. All unsolicited messages
stored in the buffer are discarded.
Example
if (!acsc_CloseMessageBuffer(Handle))
{
printf("closing unsolicited messages buffer error: %d\n",
acsc_GetLastError());
}
4.8.3 acsc_GetSingleMessage
Description
The function retrieves single unsolicited message from the buffer. This function only works if you
setup a buffer using acsc_OpenMessageBuffer. If there is no message in the buffer, the function
waits until the message arrives or timeout expires.
Syntax
int acsc_GetSingleMessage (HANDLE Handle, char *Message,int Count,int *Length, int Timeout)
Arguments
Message Pointer to the buffer that receives unsolicited messages, it should be at least 1K.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
If message arrives, Length will contain the received message length. If the timeout expires, the
function exits with the ACSC_TIMEOUT error.
Example
int L;
char Buf[10000];
if (!acsc_GetSingleMessage(Handle, // communication handle
Buf, // pointer to the buffer that
// receives unsolicited messages
10000 //Size of the buffer
4.8.4 acsc_GetMessage
Description
The function retrieves unsolicited messages from the buffer. This function only works if you setup
a buffer using acsc_OpenMessageBuffer.
Syntax
int acsc_GetMessage(HANDLE Handle, char* Buf, int Count, int* Received, BOOL bClear)
Arguments
If TRUE, the function clears the contents of the unsolicited messages buffer after
bClear retrieving the message.
If FALSE, the unsolicited messages buffer is not cleared.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function retrieves all stored unsolicited messages from the message buffer.
The function always returns immediately. If no, unsolicited message is received, the function
assigns zero to the Received variable.
Parameter Count specifies the buffer size. If a received message contains more than Count
characters, the function transfers to buffer only Count characters, assigns Received with Count
value and returns non-zero. The remaining characters of the message are removed from the
message buffer.
If the Count is equal to or more than the length of the message, the function transfers the whole
message to buffer and assigns variable Received with a number of characters that were actually
transferred.
Example
int Received;
char Buf[10000];
if (!acsc_GetMessage( Handle, // communication handle
Buf, // pointer to the buffer that
// receives unsolicited messages
10000, // size of this buffer
&Received, // number of characters that were
// actually received
TRUE // clear contents of the
// unsolicited messages buffer
))
{
printf("getting unsolicited message error: %d\n",
acsc_GetLastError());
}
Function Description
4.9.1 acsc_SetLogFileOptions
Description
The function sets the log file options.
Syntax
acsc_SetLogFileOptions(HANDLE Handle,
ACSC_LOG_DETALIZATION_LEVEL Detailization,
ACSC_LOG_DATA_PRESENTATION Presentation)
Arguments
Detailization Medium - Value 1: Communication traffic and some internal C Lib process data
will be logged.
Maximum -Value 2: Communication traffic and all internal process data will be
logged.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function configures the log file options. The function may be called before or after the log file
is opened.
Example
4.9.2 acsc_OpenLogFile
Description
The function opens a log file.
Syntax
int acsc_OpenLogFile(HANDLE Handle, char* FileName)
Arguments
FileName Pointer to the null-terminated string contained name or path of the log file.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function opens a binary file that stores all communication history.
Only one log file can be open for each communication handle.
If the log file has been open, the library writes all incoming and outgoing messages to the specified
file. The messages are written to the file in binary format, i.e., exactly as they are received and sent,
including all service bytes.
Unlike the history buffer, the log file cannot be read within the library. The main usage of the log
file is for debug purposes.
Example
if (!acsc_OpenLogFile(Handle, "acs_comm.log"))
{
printf("opening log file error: %d\n", acsc_GetLastError());
}
4.9.3 acsc_CloseLogFile
Description
The function closes the log file.
Syntax
int acsc_CloseLogFile(HANDLE Handle)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
An application must always call the acsc_CloseLogFile before it exits. Otherwise, the data written to
the file might be lost.
Example
if (!acsc_CloseLogFile(Handle))
{
printf("closing log file error: %d\n", acsc_GetLastError());
}
4.9.4 acsc_WriteLogFile
Description
The function writes to log file.
Syntax
int acsc_WriteLogFile(HANDLE Handle, char* Buf, int Count)
Arguments
Buf Pointer to the buffer that contains the string to be written to log file.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function writes data from a buffer to log file.
The log file has to have been opened previously using acsc_OpenLogFile
Example
4.9.5 acsc_FlushLogFile
Description
This function allows flushing the SPiiPlus UMD (User Mode Driver) internal binary buffer to a
specified text file from the C Library application.
Syntax
acsc_FlushLogFile(char*filename)
Arguments
Comments
If Continuous Log is active, the function will fail
Example
if (!acsc_FlushLogFile( filename))
{
printf("transaction error: %d\n", acsc_GetLastError());
}
4.9.6 acsc_GetLogData
Description
The function is used to retrieve the data of firmware log.
Syntax
int acsc_GetLogData(HANDLE Handle, char* Buf, int Count, int* Received,
ACSC_WAITBLOCK* Wait)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Example
These functions can only be used with the SPiiPlusSC Motion Controller.
Function Description
acsc_FlushSCLogFile Flushes contents of the SPiiPlusSC log file to a specified text file.
4.10.1 acsc_OpenSCLogFile
Description
The function opens the SPiiPlusSC log file.
Syntax
int acsc_OpenSCLogFile(HANDLE Handle, char* FileName)
Arguments
FileName Pointer to the null-terminated string containing the name or path of the log file.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function opens a binary file that stores all SPiiPlusSC log history.
The messages are written to the file in binary format, i.e., exactly as they are received and sent,
including all service bytes.
The main use of the log file is for debug purposes.
Example
if (!acsc_OpenSCLogFile(Handle, "acs_sc.log"))
{
printf("opening SPiiPlus SC log file error: %d\n", acsc_GetLastError());
}
4.10.2 acsc_CloseSCLogFile
Description
The function closes the SPiiPlusSC log file.
Syntax
int acsc_CloseSCLogFile(HANDLE Handle)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
Comments
An application must always call the acsc_CloseSCLogFile before it exits; otherwise, the data written
to the file might be lost.
Example
if (!acsc_CloseSCLogFile(Handle))
{
printf("closing log file error: %d\n", acsc_GetLastError());
}
4.10.3 acsc_WriteSCLogFile
Description
The function writes to the SPiiPlusSC log file.
Syntax
int acsc_WriteSCLogFile(HANDLE Handle, char* Buf, int Count)
Arguments
Buf Pointer to the buffer that contains the string to be written to the log file.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function writes data from a buffer to the SPiiPlusSC log file.
The log file has to have been opened previously using acsc_OpenLogFile
Example
4.10.4 acsc_FlushSCLogFile
Description
The function enables flushing the SPiiPlusSC internal binary buffer to a specified text file from the C
Library application.
Syntax
int acsc_FlushSCLogFile(char*Filename, BOOL bClear)
Arguments
Comments
If Continuous Log is active, the function will fail.
Example
if (!acsc_FlushSCLogFile(filename,TRUE))
{
printf("transaction error: %d\n", acsc_GetLastError());
}
Function Description
Function Description
4.11.1 acsc_SetConf
Description
The function writes system configuration data.
Syntax
int acsc_SetConf(HANDLE Handle, int Key, int Index, double Value,
ACSC_WAITBLOCK* Wait)
Arguments
Configuration key, see Configuration Keys, that specifies the configured feature.
Key
Assigns value of key argument in ACSPL+ SETCONF function.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function writes system configuration data. The Key parameter specifies the feature number
and the Index parameter defines axis or buffer to which it should be applied. Use ACSC_CONF_XXX
constants in the value field. For complete details of system configuration see the description of the
SETCONF function in the SPiiPlus ACSPL+ Programmer’s Guide.
Example
4.11.2 acsc_GetConf
Description
The function reads system configuration data.
Syntax
int acsc_GetConf(HANDLE Handle, int Key, int Index, double *Value,
ACSC_WAITBLOCK* Wait)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function reads system configuration data. The Key parameter specifies the feature number
and the Index parameter defines axis or buffer to which it should be applied. For detailed
description of system configuration see “SPiiPlus ACSPL+ Programmer’s Guide” for the details of
the GETCONF function.
Example
4.11.3 acsc_GetVolatileMemoryUsage
Description
The function retrieves the percentage of the volatile memory load.
Syntax
int _ACSCLIB_ WINAPI acsc_GetVolatileMemoryUsage(HANDLE Handle, double* Value, ACSC_
WAITBLOCK* Wait)
Arguments
Value Pointer to a variable that receives the percentage of the volatile memory load
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Example
4.11.4 acsc_GetVolatileMemoryTotal
Description
The function retrieves the amount of total volatile memory in bytes.
Syntax
int _ACSCLIB_ WINAPI acsc_GetVolatileMemoryTotal(HANDLE Handle, double* Value, ACSC_
WAITBLOCK* Wait)
Arguments
Value Pointer to a variable that receives the amount of total volatile memory in bytes.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Example
4.11.5 acsc_GetVolatileMemoryFree
Description
The function retrieves the amount of free volatile memory in bytes.
Syntax
int _ACSCLIB_ WINAPI acsc_GetVolatileMemoryFree(HANDLE Handle, double* Value, ACSC_
WAITBLOCK* Wait)
Arguments
Value Pointer to a variable that receives the amount of free volatile memory in bytes
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Example
4.11.6 acsc_GetNonVolatileMemoryUsage
Description
The function retrieves the percentage of the non-volatile memory load.
Syntax
int _ACSCLIB_ WINAPI acsc_GetNonVolatileMemoryUsage(HANDLE Handle, double* Value, ACSC_
WAITBLOCK* Wait)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Example
4.11.7 acsc_GetNonVolatileMemoryTotal
Description
The function retrieves the amount of total non-volatile memory in bytes.
Syntax
int _ACSCLIB_ WINAPI acsc_GetNonVolatileMemoryTotal(HANDLE Handle, double* Value, ACSC_
WAITBLOCK* Wait)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Example
4.11.8 acsc_GetNonVolatileMemoryFree
Description
The function retrieves the amount of free non-volatile memory in bytes.
Syntax
int _ACSCLIB_ WINAPI acsc_GetNonVolatileMemoryFree(HANDLE Handle, double* Value, ACSC_
WAITBLOCK* Wait)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Example
4.11.9 acsc_SysInfo
Description
The function returns certain system information based on the argument that is specified.
Syntax
int acsc_SysInfo(HANDLE Handle, int Key, double *Value,
ACSC_WAITBLOCK* Wait)
Arguments
Configuration Key, see System Information Keys, specifies the configured feature.
Key
Assigns value of key argument in ACSPL+ SYSINFO function.
Return Value
If the function succeeds, the return value is non-zero.
double Value = 0;
if (!acsc_SysInfo(Handle, ACSC_SYS_MODEL_KEY, &Value, NULL))
{
printf("acsc_SysInfo(): Error Occurred - %d\n", acsc_GetLastError());
return;
}
Function Description
acsc_
Defines a value of kill deceleration.
SetKillDeceleration
acsc_
Retrieves a value of kill deceleration.
GetKillDeceleration
Function Description
4.12.1 acsc_SetVelocity
Description
The function defines a value of motion velocity.
Syntax
int acsc_SetVelocity(HANDLE Handle, int Axis, double Velocity,
ACSC_WAITBLOCK* Wait)
Arguments
The value specifies required motion velocity. The value will be used in the
Velocity subsequent motions except for the master-slave motions and the motions
activated with the ACSC_AMF_VELOCITY flag.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function writes the specified value to the controller.
One value can be specified for each axis.
A single-axis motion uses the value of the corresponding axis. A multi-axis motion uses the value of
the leading axis. The leading axis is an axis specified first in the motion command.
The function affects the motions initiated after the function call. The function has no effect on any
motion that was started or planned before the function call. To change velocity of an executed or
planned motion, use the acsc_SetVelocityImm function.
The function has no effect on the master-slave motions and the motions activated with the ACSC_
AMF_VELOCITY flag.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.12.2 acsc_GetVelocity
Description
The function retrieves a value of motion velocity.
Syntax
int acsc_GetVelocity(HANDLE Handle, int Axis, double* Velocity,
ACSC_WAITBLOCK* Wait)
Arguments
Velocity Pointer to the variable that receives the value of motion velocity.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function retrieves the value of the motion velocity. The retrieved value is a value defined by a
previous call of the acsc_SetVelocity function, or the default value if the function was not called
before.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Velocity and Wait items until a call to the acsc_WaitForAsyncCall function.
Example
4.12.3 acsc_SetAcceleration
Description
The function defines a value of motion acceleration.
Syntax
int acsc_SetAcceleration(HANDLE Handle, int Axis, double Acceleration,
ACSC_WAITBLOCK* Wait)
Arguments
The value specifies required motion acceleration. The value will be used in
Acceleration
the subsequent motions except the master-slave motions.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function writes the specified value to the controller.
One value can be specified for each axis.
A single-axis motion uses the value of the corresponding axis. A multi-axis motion uses the value of
the leading axis. The leading axis is an axis specified first in the motion command.
The function affects the motions initiated after the function call. The function has no effect on any
motion that was started or planned before the function call. To change acceleration of an executed
or planned motion, use the acsc_SetAccelerationImm function.
The function has no effect on the master-slave motions.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.12.4 acsc_GetAcceleration
Description
The function retrieves a value of motion acceleration.
Syntax
int acsc_GetAcceleration(HANDLE Handle, int Axis, double* Acceleration,
ACSC_WAITBLOCK* Wait)
Arguments
Acceleration Pointer to the variable that receives the value of motion acceleration.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function retrieves the value of the motion acceleration. The retrieved value is a value defined
by a previous call of the acsc_SetAcceleration function, or the default value if the function was not
called before.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Acceleration and Wait items until a call to the acsc_WaitForAsyncCall function.
Example
4.12.5 acsc_SetDeceleration
Description
The function defines a value of motion deceleration.
Syntax
int acsc_SetDeceleration(HANDLE Handle, int Axis, double Deceleration,
ACSC_WAITBLOCK* Wait)
Arguments
The value specifies a required motion deceleration. The value will be used in
Deceleration
the subsequent motions except the master-slave motions.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function writes the specified value to the controller.
One value can be specified for each axis.
A single-axis motion uses the value of the corresponding axis. A multi-axis motion uses the value of
the leading axis. The leading axis is an axis specified first in the motion command.
The function affects the motions initiated after the function call. The function has no effect on any
motion that was started or planned before the function call. To change deceleration of an
executed or planned motion, use the acsc_SetDecelerationImm function.
The function has no effect on the master-slave motions.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.12.6 acsc_GetDeceleration
Description
The function retrieves a value of motion deceleration.
Syntax
int acsc_GetDeceleration(HANDLE Handle, int Axis, double* Deceleration,
ACSC_WAITBLOCK* Wait)
Arguments
Deceleration Pointer to the variable that receives the value of motion deceleration.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function retrieves the value of the motion deceleration. The retrieved value is a value defined
by a previous call of the acsc_SetDeceleration function, or the default value if the function was not
previously called.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Deceleration and Wait items until a call to the acsc_WaitForAsyncCall function.
Example
4.12.7 acsc_SetJerk
Description
The function defines a value of motion jerk.
Syntax
int acsc_SetJerk(HANDLE Handle, int Axis, double Jerk, ACSC_WAITBLOCK* Wait)
Arguments
The value specifies a required motion jerk. The value will be used in the
Jerk
subsequent motions except for the master-slave motions.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function writes the specified value to the controller.
One value can be specified for each axis.
A single-axis motion uses the value of the corresponding axis. A multi-axis motion uses the value of
the leading axis. The leading axis is an axis specified first in the motion command.
The function affects the motions initiated after the function call. The function has no effect on any
motion that was started or planned before the function call. To change the jerk of an executed or
planned motion, use the acsc_SetJerkImm function.
The function has no effect on the master-slave motions.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.12.8 acsc_GetJerk
Description
The function retrieves a value of motion jerk.
Syntax
int acsc_GetJerk(HANDLE Handle, int Axis, double* Jerk,
ACSC_WAITBLOCK* Wait)
Arguments
Jerk Pointer to the variable that receives the value of motion jerk.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function retrieves the value of the motion jerk. The retrieved value is a value defined by a
previous call of the acsc_SetJerk function, or the default value if the function was not called before.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Jerk and Wait items until a call to the acsc_WaitForAsyncCall function.
Example
4.12.9 acsc_SetKillDeceleration
Description
The function defines a value of motion kill deceleration.
Syntax
int acsc_SetKillDeceleration(HANDLE Handle, int Axis, double KillDeceleration,
ACSC_WAITBLOCK* Wait)
Arguments
The value specifies a required motion kill deceleration. The value will be
KillDeceleration
used in the subsequent motions.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function writes the specified value to the controller.
One value can be specified for each axis.
A single-axis motion uses the value of the corresponding axis. A multi-axis motion uses the value of
the leading axis. The leading axis is an axis specified first in the motion command.
The function affects the motions initiated after the function call. The function has no effect on any
motion that was started or planned before the function call.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.12.10 acsc_GetKillDeceleration
Description
The function retrieves a value of motion kill deceleration.
Syntax
int acsc_GetKillDeceleration(HANDLE Handle, int Axis, double* KillDeceleration,
ACSC_WAITBLOCK* Wait)
Arguments
KillDeceleration Pointer to the variable that receives the value of motion kill deceleration.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function retrieves the value of the motion kill deceleration. The retrieved value is a value
defined by a previous call of the acsc_SetKillDeceleration function, or the default value if the
function was not called before.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
KillDeceleration and Wait items until a call to the acsc_WaitForAsyncCall function.
Example
4.12.11 acsc_SetVelocityImm
Description
The function defines a value of motion velocity. Unlike acsc_SetVelocity, the function has
immediate effect on any executed or planned motion.
Syntax
int acsc_SetVelocityImm(HANDLE Handle, int Axis, double Velocity,
ACSC_WAITBLOCK* Wait)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function writes the specified value to the controller.
One value can be specified for each axis.
A single-axis motion uses the value of the corresponding axis. A multi-axis motion uses the value of
the leading axis. The leading axis is an axis specified first in the motion command.
The function affects:
> The currently executed motion. The controller provides a smooth transition from the
instant current velocity to the specified new value.
> The waiting motions that were planned before the function call.
> The motions that will be commanded after the function call.
The function has no effect on the master-slave motions.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.12.12 acsc_SetAccelerationImm
Description
The function defines a value of motion acceleration. Unlike acsc_SetAcceleration, the function has
immediate effect on any executed and planned motion.
Syntax
int acsc_SetAccelerationImm(HANDLE Handle, int Axis, double Acceleration,
ACSC_WAITBLOCK* Wait)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function writes the specified value to the controller.
One value can be specified for each axis.
A single-axis motion uses the value of the corresponding axis. A multi-axis motion uses the value of
the leading axis. The leading axis is an axis specified first in the motion command.
The function affects:
> The currently executed motion.
> The waiting motions that were planned before the function call.
> The motions that will be commanded after the function call.
The function has no effect on the master-slave motions.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.12.13 acsc_SetDecelerationImm
Description
The function defines a value of motion deceleration. Unlike acsc_SetDeceleration, the function has
immediate effect on any executed and planned motion.
Syntax
int acsc_SetDecelerationImm(HANDLE Handle, int Axis, double Deceleration,
ACSC_WAITBLOCK* Wait)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function writes the specified value to the controller.
One value can be specified for each axis.
A single-axis motion uses the value of the corresponding axis. A multi-axis motion uses the value of
the leading axis. The leading axis is an axis specified first in the motion command.
The function affects:
> The currently executed motion.
> The waiting motions that were planned before the function call.
> The motions that will be commanded after the function call.
The function has no effect on the master-slave motions.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.12.14 acsc_SetJerkImm
Description
The function defines a value of motion jerk. Unlike acsc_SetJerk, the function has immediate effect
on any executed and planned motion.
Syntax
int acsc_SetJerkImm(HANDLE Handle, int Axis, double Jerk,
ACSC_WAITBLOCK* Wait)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function writes the specified value to the controller.
One value can be specified for each axis.
A single-axis motion uses the value of the corresponding axis. A multi-axis motion uses the value of
the leading axis. The leading axis is an axis specified first in the motion command.
The function affects:
> The currently executed motion.
> The waiting motions that were planned before the function call.
> The motions that will be commanded after the function call.
4.12.15 acsc_SetKillDecelerationImm
Description
The function defines a value of motion kill deceleration. Unlike acsc_SetKillDeceleration, the
function has an immediate effect on any executed and planned motion.
Syntax
int acsc_SetKillDecelerationImm(HANDLE Handle, int Axis, double Deceleration,
ACSC_WAITBLOCK* Wait)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function writes the specified value to the controller.
One value can be specified for each axis.
A single-axis motion uses the value of the corresponding axis. A multi-axis motion uses the value of
the leading axis. The leading axis is an axis specified first in the motion command.
The function affects:
> The currently executed motion
> The waiting motions that were planned before the function call
> The motions that will be commanded after the function call
The function has no effect on the master-slave motions.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.12.16 acsc_SetFPosition
Description
The function assigns a current value of feedback position.
Syntax
int acsc_SetFPosition(HANDLE Handle, int Axis, double FPosition,
ACSC_WAITBLOCK* Wait)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function assigns a current value to the feedback position. No physical motion occurs. The motor
remains in the same position; only the internal controller offsets are adjusted so that the periodic
calculation of the feedback position will provide the required results.
For more information see the explanation of the SET command in the SPiiPlus ACSPL+
Programmer’s Guide.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.12.17 acsc_GetFPosition
Description
The function retrieves an instant value of the motor feedback position.
Syntax
int acsc_GetFPosition(HANDLE Handle, int Axis, double* FPosition,
ACSC_WAITBLOCK* Wait)
Arguments
Pointer to a variable that receives the instant value of the motor feedback
FPosition
position.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function retrieves an instant value of the motor feedback position. The feedback position is a
measured position of the motor transferred to user units.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
FPosition and Wait items until a call to the acsc_WaitForAsyncCall function.
Example
4.12.18 acsc_SetRPosition
Description
The function assigns a current value of reference position.
Syntax
int acsc_SetRPosition(HANDLE Handle, int Axis, double RPosition,
ACSC_WAITBLOCK* Wait)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function assigns a current value to the reference position. No physical motion occurs. The
motor remains in the same position; only the internal controller offsets are adjusted so that the
periodic calculation of the reference position will provide the required results.
For more information see explanation of the SET command in the SPiiPlus ACSPL+ Programmer’s
Guide.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.12.19 acsc_GetRPosition
Description
The function retrieves an instant value of the motor reference position.
Syntax
int acsc_GetRPosition(HANDLE Handle, int Axis, double* RPosition,
ACSC_WAITBLOCK* Wait)
Arguments
Pointer to a variable that receives the instant value of the motor reference
Rposition
position.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function retrieves an instant value of the motor reference position. The reference position is a
value calculated by the controller as a reference for the motor.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
RPosition and Wait items until a call to the acsc_WaitForAsyncCall function.
Example
4.12.20 acsc_GetFVelocity
Description
The function retrieves an instant value of the motor feedback velocity. Unlike acsc_GetVelocity, the
function retrieves the actually measured velocity and not the required value.
Syntax
int acsc_GetFVelocity(HANDLE Handle, int Axis, double* FVelocity,
ACSC_WAITBLOCK* Wait)
Arguments
Pointer to a variable that receives the instant value of the motor feedback
FVelocity
velocity.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function retrieves an instant value of the motor feedback velocity. The feedback velocity is a
measured velocity of the motor transferred to user units.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
FVelocity and Wait items until a call to the acsc_WaitForAsyncCall function.
Example
4.12.21 acsc_GetRVelocity
Description
The function retrieves an instant value of the motor reference velocity.
Syntax
int acsc_GetRVelocity(HANDLE Handle, int Axis, double* RVelocity,
ACSC_WAITBLOCK* Wait)
Arguments
Pointer to a variable that receives the instant value of the motor reference
RVelocity
velocity.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function retrieves an instant value of the motor reference velocity. The reference velocity is a
value calculated by the controller in the process of motion generation.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
RVelocity and Wait items until a call to the acsc_WaitForAsyncCall function.
Example
Function Description
4.13.1 acsc_CommutExt
Description
This function initiates a motor commutation.
Syntax
Int acsc_CommutExt(HANDLE handle, int Axis, float Current, int Settle, int Slope, ACSC_WAITBLOCK
*Wait)
Arguments
Current Desired excitation current in percentage 0-100, ACSC_NONE for default value.
Specifies the time it takes for auto commutation to settle, in milliseconds. ACSC_
Settle
NONE for the default value of 500ms.
Specifies the time it takes for the current to rise to the desired value, ACSC_NONE
Slope
for default value.
Return Values
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function activates a motor. After the activation, the motor begins to follow the reference and
physical motion is available.
Settle can only be set if Current is set. Similarly Slope can only be set if Settle is set.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.13.2 acsc_Enable
Description
The function activates a motor.
Syntax
int acsc_Enable(HANDLE Handle, int Axis, ACSC_WAITBLOCK* Wait)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function activates a motor. After the activation, the motor begins to follow the reference and
physical motion is available.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.13.3 acsc_EnableM
Description
The function activates several motors.
Syntax
int acsc_EnableM(HANDLE Handle, int* Axes, ACSC_WAITBLOCK* Wait)
Arguments
Array of axis constants. Each element specifies one involved axis: ACSC_AXIS_0
corresponds to axis 0, ACSC_AXIS_1 to axis 1, etc. After the last axis, one additional
Axes element must be located that contains -1 which marks the end of the array.
For the axis constants see Axis Definitions.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function activates several motors. After the activation, the motors begin to follow the
corresponding reference and physical motions for the specified motors are available.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.13.4 acsc_Disable
Description
The function shuts off a motor.
Syntax
int acsc_Disable(HANDLE Handle, int Axis, ACSC_WAITBLOCK* Wait)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function shuts off a motor. After shutting off the motor cannot follow the reference and
remains at idle.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.13.5 acsc_DisableAll
Description
The function shuts off all motors.
Syntax
int acsc_DisableAll(HANDLE Handle, ACSC_WAITBLOCK* Wait)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function shuts off all motors. After the shutting off none of motors can follow the
corresponding, reference and all motors remain idle.
If no motors are currently enabled, the function has no effect.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.13.6 acsc_DisableExt
Description
The function shuts off a motor and defines the disable reason.
Syntax
int acsc_DisableExt(HANDLE Handle, int Axis,int Reason,
ACSC_WAITBLOCK* Wait)
Arguments
Integer number that defines the reason of disable. The specified value is stored in
Reason the MERR variable in the controller and so modifies the state of the disabled
motor.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function shuts off a motor. After shutting off the motor cannot follow the reference and
remains at idle.
If Reason specifies one of the available motor termination codes, the state of the disabled motor
will be identical to the state of the motor disabled for the corresponding fault. This provides an
enhanced implementation of user-defined fault response.
If the second parameter specifies an arbitrary number, the motor state will be displayed as
“Kill/disable reason: <number> - customer code. This provides ability to separate different DISABLE
commands in the application.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.13.7 acsc_DisableM
Description
The function shuts off several specified motors.
Syntax
int acsc_DisableM(HANDLE Handle, int* Axes, ACSC_WAITBLOCK* Wait)
Arguments
Array of axis constants. Each element specifies one involved axis: ACSC_AXIS_0
corresponds to axis 0, ACSC_AXIS_1 to axis 1, etc. After the last axis, one additional
Axes element must be located that contains -1 which marks the end of the array.
For the axis constants see Axis Definitions.
Return Value
If the function succeeds, the return value is non-zero.
Comments
The function shuts off several motors. After the shutting off, the motors cannot follow the
corresponding reference and remain idle.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.13.8 acsc_Group
Description
The function creates a coordinate system for a multi-axis motion.
Syntax
int acsc_Group(HANDLE Handle, int* Axes, ACSC_WAITBLOCK* Wait)
Arguments
Array of axis constants. Each element specifies one involved axis: ACSC_AXIS_0
corresponds to axis 0, ACSC_AXIS_1 to axis 1, etc. After the last axis, one additional
Axes element must be located that contains -1 which marks the end of the array.
For the axis constants see Axis Definitions.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function creates a coordinate system for a multi-axis motion. The first element of the Axes
array specifies the leading axis. The motion parameters of the leading axis become the default
motion parameters for the group.
An axis can belong to only one group at a time. If the application requires restructuring the axes, it
must split the existing group and only then create the new one. To split the existing group, use
acsc_Split function. To split all existing groups, use the acsc_SplitAll function.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.13.9 acsc_Split
Description
The function breaks down an axis group created before.
Syntax
int acsc_Split(HANDLE Handle, int* Axes, ACSC_WAITBLOCK* Wait)
Arguments
Array of axis constants. Each element specifies one involved axis: ACSC_AXIS_0
corresponds to axis 0, ACSC_AXIS_1 to axis 1, etc. After the last axis, one additional
Axes element must be located that contains -1 which marks the end of the array.
For the axis constants see Axis Definitions.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function breaks down an axis group created before by the acsc_Group function. The Axes
parameter must specify the same axes as for the acsc_Group function that created the group.
After the splitting up the group no longer exists.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.13.10 acsc_SplitAll
Description
The function breaks down all axis groups created before.
Syntax
int acsc_SplitAll(HANDLE Handle, ACSC_WAITBLOCK* Wait)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function breaks down all axis groups created before by the acsc_Group function.
The application may call this function to ensure that no axes are grouped. If no groups are currently
existed, the function has no effect.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
Function Description
acsc_
Terminates several motions using the full deceleration profile.
HaltM
acsc_
Terminates all currently executed motions.
KillAll
acsc_ Terminates a motion using reduced deceleration profile and defines the kill
KillExt reason.
acsc_ Terminates a motion immediately and provides a smooth transition to the next
Break motion.
4.14.1 acsc_Go
Description
The function starts up a motion waiting in the specified motion queue.
Syntax
int acsc_Go(HANDLE Handle, int Axis, ACSC_WAITBLOCK* Wait)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
A motion that was planned with ACSC_AMF_WAIT flag does not start until the acsc_Go function is
executed. Being planned, a motion waits in the appropriate motion queue.
Each axis has a separate motion queue. A single-axis motion waits in the motion queue of the
corresponding axis. A multi-axis motion waits in the motion queue of the leading axis. The leading
axis is an axis specified first in the motion command.
The acsc_Go function initiates the motion waiting in the motion queue of the specified axis. If no
motion waits in the motion queue, the function has no effect.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.14.2 acsc_GoM
Description
The function synchronously starts up several motions that are waiting in the specified motion
queues.
Syntax
int acsc_GoM(HANDLE Handle, int* Axes, ACSC_WAITBLOCK* Wait)
Arguments
Array of axis constants. Each element specifies one involved axis: ACSC_AXIS_0
corresponds to axis 0, ACSC_AXIS_1 to axis 1, etc. After the last axis, one additional
Axes element must be located that contains -1 which marks the end of the array.
For the axis constants see Axis Definitions.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
A motion that was planned with ACSC_AMF_WAIT flag does not start until the acsc_GoM function is
executed. After being planned, a motion waits in the appropriate motion queue.
Each axis has a separate motion queue. A single-axis motion waits in the motion queue of the
corresponding axis. A multi-axis motion waits in the motion queue of the leading axis. The leading
axis is an axis specified first in the motion command.
The acsc_GoM function initiates the motions waiting in the motion queues of the specified axes. If
no motion waits in one or more motion queues, the corresponding axes are not affected.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.14.3 acsc_Halt
Description
The function terminates a motion using the full deceleration profile.
Syntax
int acsc_Halt(HANDLE Handle, int Axis, ACSC_WAITBLOCK* Wait)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function terminates the executed motion that involves the specified axis. The terminated
motion can be either single-axis or multi-axis. Any other motion waiting in the corresponding
motion queue is discarded and will not be executed.
If no executed motion involves the specified axis, the function has no effect.
The terminated motion finishes using the full third-order deceleration profile and the motion
deceleration value.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.14.4 acsc_HaltM
Description
The function terminates several motions using the full deceleration profile.
Syntax
int acsc_HaltM(HANDLE Handle, int* Axes, ACSC_WAITBLOCK* Wait)
Arguments
Array of axis constants. Each element specifies one involved axis: ACSC_AXIS_0
corresponds to axis 0, ACSC_AXIS_1 to axis 1, etc. After the last axis, one additional
Axes element must be located that contains -1 which marks the end of the array.
For the axis constants see Axis Definitions.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function terminates all executed motions that involve the specified axes. The terminated
motions can be either single-axis or multi-axis. All other motions waiting in the corresponding
motion queues are discarded and will not be executed.
If no executed motion involves a specified axis, the function has no effect on the corresponding
axis.
The terminated motions finish using the full third-order deceleration profile and the motion
deceleration values.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.14.5 acsc_Kill
Description
The function acsc_Kill terminates a motion using reduced deceleration profile.
Syntax
int acsc_Kill(HANDLE Handle, int Axis, ACSC_WAITBLOCK* Wait)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function terminates the executed motion that involves the specified axis. The terminated
motion can be either single-axis or multi-axis. Any other motion waiting in the corresponding
motion queue is discarded and will not be executed.
If no executed motion involves the specified axis, the function has no effect.
The terminated motion finishes with the reduced second-order deceleration profile and the kill
deceleration value.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.14.6 acsc_KillAll
Description
The function terminates all currently executed motions.
Syntax
int acsc_KillAll(HANDLE Handle, ACSC_WAITBLOCK* Wait)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function terminates all currently executed motions. Any other motion waiting in any motion
queue is discarded and will not be executed.
If no motion is currently executed, the function has no effect.
The terminated motions finish with the reduced second-order deceleration profile and the kill
deceleration values.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.14.7 acsc_KillM
Description
The functionterminates several motions using reduced deceleration profile.
Syntax
int acsc_KillM(HANDLE Handle, int* Axes, ACSC_WAITBLOCK* Wait)
Arguments
Array of axis constants. Each element specifies one involved axis: ACSC_AXIS_0
corresponds to axis 0, ACSC_AXIS_1 to axis 1, etc. After the last axis, one additional
Axes element must be located that contains -1 which marks the end of the array.
For the axis constants see Axis Definitions.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function terminates all executed motions that involve the specified axes. The terminated
motions can be either single-axis or multi-axis. All other motions waiting in the corresponding
motion queues are discarded and will not be executed.
If no executed motion involves a specified axis, the function has no effect on the corresponding
axis.
The terminated motions finish with the reduced second-order deceleration profile and the kill
deceleration values.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.14.8 acsc_KillExt
Description
The function terminates a motion using reduced deceleration profile and defines the kill reason.
Syntax
int acsc_KillExt(HANDLE Handle, int Axis, int Reason,ACSC_WAITBLOCK* Wait)
Arguments
Integer number that defines the reason of kill. The specified value is stored in the
Reason
MERR variable in the controller and so modifies the state of the killed motor.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function terminates the executed motion that involves the specified axis. The terminated
motion can be either single-axis or multi-axis. Any other motion waiting in the corresponding
motion queue is discarded and will not be executed.
If no executed motion involves the specified axis, the function has no effect.
The terminated motion finishes with the reduced second-order deceleration profile and the kill
deceleration value.
If Reason specifies one of the available motor termination codes, the state of the killed motor will
be identical to the state of the motor killed for the corresponding fault. This provides an enhanced
implementation of user-defined fault response.
If the second parameter specifies an arbitrary number, the motor state will be displayed as
“Kill/disable reason: <number> - customer code. This provides ability to separate different KILL
commands in the application.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
KillDeceleration and Wait items until a call to the acsc_WaitForAsyncCall function.
Example
4.14.9 acsc_Break
Description
The function terminates a motion immediately and provides a smooth transition to the next
motion.
Syntax
int acsc_Break(HANDLE Handle, int Axis, ACSC_WAITBLOCK* Wait)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function terminates the executed motion that involves the specified axis only if the next
motion is waiting in the corresponding motion queue. The terminated motion can be either single-
axis or multi-axis.
If the motion queue contains no waiting motion, the break command is not executed immediately.
The current motion continues instead until the next motion is planned to the same motion queue.
Only then is the break command executed.
If no executed motion involves the specified axis, or the motion finishes before the next motion is
planned, the function has no effect.
When executing the break command, the controller terminates the motion immediately without
any deceleration profile. The controller builds instead a smooth third-order transition profile to the
next motion.
Use caution when implementing the break command with a multi-axis motion, because the
controller provides a smooth transition profile of the vector velocity. In a single-axis motion, this
ensures a smooth axis velocity. However, in a multi-axis motion an axis velocity can change abruptly
if the terminated and next motions are not tangent to the junction point. To avoid jerk, the
terminated and next motion must be tangent or nearly tangent in the junction point.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.14.10 acsc_BreakM
Description
The function terminates several motions immediately and provides a smooth transition to the next
motions.
Syntax
int acsc_BreakM(HANDLE Handle, int* Axes, ACSC_WAITBLOCK* Wait)
Arguments
Array of axis constants. Each element specifies one involved axis: ACSC_AXIS_0
corresponds to axis 0, ACSC_AXIS_1 to axis 1, etc. After the last axis, one additional
Axes element must be located that contains –1 which marks the end of the array.
For the axis constants see Axis Definitions.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function terminates the executed motions that involve the specified axes. Only those motions
are terminated that have the next motion waiting in the corresponding motion queue. The
terminated motions can be either single-axis or multi-axis.
If a motion queue contains no waiting motion, the break command does not immediately affect
the corresponding axis. The current motion continues instead until the next motion is planned to
the same motion queue. Only then, the break command is executed.
If no executed motion involves the specified axis, or the corresponding motion finishes before the
next motion is planned, the function does not affect the axis.
When executing the break command, the controller terminates the motion immediately without
any deceleration profile. Instead, the controller builds a smooth third-order transition profile to the
next motion.
Use caution when implementing the break command with a multi-axis motion, because the
controller provides a smooth transition profile of the vector velocity. In a single-axis motion, this
ensures a smooth axis velocity, but in a multi-axis motion, an axis velocity can change abruptly if the
terminated and next motions are not tangent in the junction point. To avoid jerk, the terminated
and next motion must be tangent or nearly tangent in the junction point.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
Function Description
acsc_
Initiates a multi-axis motion to the specified point.
ToPointM
acsc_ Initiates a single-axis motion to the specified point using the specified
ExtToPoint velocity or end velocity.
acsc_ Initiates a multi-axis motion to the specified point using the specified
ExtToPointM velocity or end velocity.
4.15.1 acsc_ToPoint
Description
The function initiates a single-axis motion to the specified point.
Syntax
int acsc_ToPoint(HANDLE Handle, int Flags, int Axis, double Point,
ACSC_WAITBLOCK* Wait)
Arguments
Flags Bit-mapped parameter that can include one or more of the following flags:
ACSC_AMF_WAIT: plan the motion but don’t start it until the function acsc_Go is
executed.
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.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function initiates a single-axis point-to-point motion.
The motion is executed using the required motion velocity and finishes with zero end velocity. The
required motion velocity is the velocity specified by the previous call of the acsc_SetVelocity
function or the default velocity if the function was not called.
To execute multi-axis point-to-point motion, use acsc_ToPointM. To execute motion with other
motion velocity or non-zero end velocity, use acsc_ToPoint or acsc_ExtToPointM.
The controller response indicates that the command was accepted and the motion was planned
successfully. The function does not wait for the motion end. To wait for the motion end, use acsc_
WaitMotionEnd function.
The motion builds the velocity profile using the required values of velocity, acceleration,
deceleration, and jerk of the specified axis.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.15.2 acsc_ToPointM
Description
The function initiates a multi-axis motion to the specified point.
Syntax
int acsc_ToPointM(HANDLE Handle, int Flags, int* Axes, double* Point,
ACSC_WAITBLOCK* Wait)
Arguments
Bit-mapped parameter that can include one or more of the following flags:
ACSC_AMF_WAIT: plan the motion but don’t start it until the function acsc_GoM is
executed.
Flags ACSC_AMF_RELATIVE: the Point values are relative to the end point of the previous
motion. If the flag is not specified, the Point specifies absolute coordinates.
ACSC_AMF_MAXIMUM: not to use the motion parameters from the leading axis but
to calculate the maximum allowed motion velocity, acceleration, deceleration, and
jerk of the involved axes.
Array of axis constants. Each element specifies one involved axis: ACSC_AXIS_0
corresponds to axis 0, ACSC_AXIS_1 to axis 1, etc. After the last axis, one additional
Axes element must be located that contains –1 which marks the end of the array.
For the axis constants see Axis Definitions.
Array of the target coordinates. The number and order of values must correspond
Point to the Axes array. The Point must specify a value for each element of Axes except
the last –1 element.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function initiates a multi-axis point-to-point motion.
The motion is executed using the required motion velocity and finishes with zero end velocity. The
required motion velocity is the velocity specified by the previous call of the acsc_SetVelocity
function, or the default velocity if the function was not called.
To execute single-axis point-to-point motion, use acsc_ToPoint.To execute motion with other
motion velocity or non-zero end velocity, use acsc_ExtToPoint or acsc_ExtToPointM.
The controller response indicates that the command was accepted and the motion was planned
successfully. The function does not wait for the motion end. To wait for the motion end, use acsc_
WaitMotionEnd function.
The motion builds the velocity profile using the required values of velocity, acceleration,
deceleration, and jerk of the leading axis. The leading axis is the first axis in the Axes array.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.15.3 acsc_ExtToPoint
Description
The function initiates a single-axis motion to the specified point using the specified velocity or end
velocity.
Syntax
int acsc_ExtToPoint(HANDLE Handle, int Flags, int Axis, double Point, double Velocity,
double EndVelocity, ACSC_WAITBLOCK* Wait)
Arguments
Bit-mapped parameter that can include one or more of the following flags:
ACSC_AMF_WAIT: plan the motion but don't start it until the function acsc_Go
is executed.
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
Flags
coordinate.
ACSC_AMF_VELOCITY: the motion will use velocity specified by the Velocity
argument instead of the default velocity.
ACSC_AMF_ENDVELOCITY: the motion will come to the end point with the
velocity specified by the EndVelocity argument.
Velocity in the target point. The argument is used only if the ACSC_AMF_
EndVelocity ENDVELOCITY flag is specified. Otherwise, the motion finishes with zero
velocity.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function initiates a single-axis point-to-point motion.
If the ACSC_AMF_VELOCITY flag is specified, the motion is executed using the velocity specified by
the Velocity argument. Otherwise, the required motion velocity is used. The required motion
velocity is the velocity specified by the previous call of the acsc_SetVelocity function, or the default
velocity if the function was not called.
If the ACSC_AMF_ENDVELOCITY flag is specified, the motion velocity at the final point is specified by
the EndVelocity argument. Otherwise, the motion velocity at the final point is zero.
To execute a multi-axis point-to-point motion with the specified velocity or end velocity, use acsc_
ExtToPointM. To execute motion with default motion velocity and zero end velocity, use acsc_
ExtToPoint or acsc_ToPointM.
The controller response indicates that the command was accepted and the motion was planned
successfully. The function does not wait for the motion end. To wait for the motion end, use acsc_
WaitMotionEnd function.
The motion builds the velocity profile using the required values of acceleration, deceleration and
jerk of the specified axis.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.15.4 acsc_ExtToPointM
Description
The function initiates a multi-axis motion to the specified point using the specified velocity or end
velocity.
Syntax
int acsc_ExtToPointM(HANDLE Handle, int Flags, int* Axes, double* Point,
double Velocity, double EndVelocity, ACSC_WAITBLOCK* Wait)
Arguments
Bit-mapped parameter that can include one or more of the following flags:
ACSC_AMF_WAIT: plan the motion but don't start it until the function acsc_Go
is executed.
ACSC_AMF_RELATIVE: the Point values are relative to the end of the previous
motion. If the flag is not specified, the Point specifies absolute coordinates.
Flags ACSC_AMF_VELOCITY: the motion will use velocity specified by the Velocity
argument instead of the default velocity.
ACSC_AMF_ENDVELOCITY: the motion will come to the end with the velocity
specified by the EndVelocity argument.
ACSC_AMF_MAXIMUM: not to use the motion parameters from the leading
axis but to calculate the maximum allowed motion velocity, acceleration,
deceleration and jerk of the involved axes.
Array of axis constants. Each element specifies one involved axis: ACSC_AXIS_0
corresponds to axis 0, ACSC_AXIS_1 to axis 1, etc. After the last axis, one
Axes additional element must be located that contains –1 which marks the end of
the array.
For the axis constants see Axis Definitions.
Array of the target coordinates. The number and order of values must
Point correspond to the Axes array. The Point must specify a value for each element
of Axes except the last –1 element.
Vector velocity in the target point. The argument is used only if the ACSC_
EndVelocity AMF_ENDVELOCITY is specified. Otherwise, the motion finishes with zero
velocity.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function initiates a multi-axis point-to-point motion.
If the ACSC_AMF_VELOCITY flag is specified, the motion is executed using the velocity specified by
the Velocity argument. Otherwise, the required motion velocity is used. The required motion
velocity is the velocity specified by the previous call of the acsc_SetVelocity function, or the default
velocity if the function was not called.
If the ACSC_AMF_ENDVELOCITY flag is specified, the motion velocity at the final point is specified by
the EndVelocity argument. Otherwise, the motion velocity at the final point is zero.
To execute a single-axis point-to-point motion with the specified velocity or end velocity, use acsc_
ExtToPoint. To execute a motion with default motion velocity and zero end velocity, use acsc_
ToPoint or acsc_ToPointM.
The controller response indicates that the command was accepted and the motion was planned
successfully. The function does not wait for the motion end. To wait for the motion end, use acsc_
WaitMotionEnd function.
The motion builds the velocity profile using the required values of acceleration, deceleration and
jerk of the leading axis. The leading axis is the first axis in the Axes array.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
Function Description
4.16.1 acsc_Track
Description
The function initiates a single-axis track motion.
Syntax
int acsc_Track(HANDLE Handle, int Flags, int Axis, ACSC_WAITBLOCK* Wait)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function initiates a single-axis track motion. After the motion is initialized, ptp motion will be
generated with every change in TPOS value.
The controller response indicates that the command was accepted and the motion was planned
successfully.
Example
4.16.2 acsc_SetTargetPosition
Description
The function assigns a current value of track position.
Syntax
int acsc_SetTargetPosition(HANDLE Handle, int Axis, double TargetPosition,
ACSC_WAITBLOCK* Wait)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function assigns a current value to the Track position. If the corresponding axis is initialized
with track motion, the change of TPOS will cause generation of ptp motion to that new value.
For more information see the explanation of the track command in the SPiiPlus ACSPL+
Programmer’s Guide.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.16.3 acsc_GetTargetPosition
Description
The function retrieves the instant value of track position.
Syntax
int acsc_GetTargetPosition(HANDLE Handle, int Axis, double *TargetPosition,
ACSC_WAITBLOCK* Wait)
Arguments
The pointer to variable that receives the instant value of the target
TargetPosition
position.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function reads a current value of the corresponding TPOS variable. If the corresponding axis is
initialized with track motion, TPOS controls the motion of the axis.
For more information see the explanation of the track command in the SPiiPlus ACSPL+
Programmer’s Guide.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
Function Description
4.17.1 acsc_Jog
Description
The function initiates a single-axis jog motion.
Syntax
int acsc_Jog(HANDLE Handle, int Flags, int Axis, double Velocity,
ACSC_WAITBLOCK* Wait)
Arguments
Bit-mapped parameter that can include one or more of the following flags:
ACSC_AMF_WAIT: plan the motion but don’t start it until the function acsc_Go is
Flags executed.
ACSC_AMF_VELOCITY: the motion will use the velocity specified by the Velocity
argument instead of the default velocity.
If the ACSC_AMF_VELOCITY flag is specified, the velocity profile is built using the
value of Velocity. The sign of Velocity defines the direction of the motion.
Velocity If the ACSC_AMF_VELOCITY flag is not specified, only the sign of Velocity is used in
order to specify the direction of motion. In this case, the constants ACSC_
POSITIVE_DIRECTION or ACSC_NEGATIVE_DIRECTION can be used.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function initiates a single-axis jog. To execute multi-axis jog, use acsc_JogM.
The jog motion is a motion with constant velocity and no defined ending point. The jog motion
continues until the next motion is planned, or the motion is killed for any reason.
The motion builds the velocity profile using the default values of acceleration, deceleration and jerk
of the specified axis. If the ACSC_AMF_VELOCITY flag is not specified, the default value of velocity is
used as well. In this case, only the sign of Velocity is used in order to specify the direction of motion.
The positive velocity defines a positive direction, the negative velocity – negative direction.
If the ACSC_AMF_VELOCITY flag is specified, the value of Velocity is used instead of the default
velocity. The sign of Velocity defines the direction of the motion.
The function can wait for the controller response or can return immediately as specified by the
Wait argument.
The controller response indicates that the command was accepted and the motion was planned
successfully. No waiting for the motion end is provided.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.17.2 acsc_JogM
Description
The function initiates a multi-axis jog motion.
Syntax
int acsc_JogM(HANDLE Handle, int Flags, int* Axes, int* Direction, double Velocity,
ACSC_WAITBLOCK* Wait)
Arguments
Bit-mapped parameter that can include one or more of the following flags:
ACSC_AMF_WAIT: plan the motion but don’t start it until the function acsc_Go is
Flags executed.
ACSC_AMF_VELOCITY: the motion will use the velocity specified by the Velocity
argument instead of the default velocity.
Array of axis constants. Each element specifies one involved axis: ACSC_AXIS_0
corresponds to axis 0, ACSC_AXIS_1 to axis 1, etc. After the last axis, one additional
Axes element must be located that contains –1 which marks the end of the array.
For the axis constants see Axis Definitions..
Array of directions. The number and order of values must correspond to the
Axes array. The Direction array must specify direction for each element of Axes
except the last –1 element. The constant ACSC_POSITIVE_DIRECTION in the
Direction
Direction array specifies the correspondent axis to move in positive direction,
the constant ACSC_NEGATIVE_DIRECTION specifies the correspondent axis to
move in the negative direction.
If the ACSC_AMF_VELOCITY flag is specified, the velocity profile is built using the
Velocity value of Velocity.
If the ACSC_AMF_VELOCITY flag is not specified, Velocity is not used.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function initiates a multi-axis jog motion. To execute single-axis jog motion, useacsc_Jog.
The jog motion is a motion with constant velocity and no defined ending point. The jog motion
continues until the next motion is planned, or the motion is killed for any reason.
The motion builds the vector velocity profile using the default values of velocity, acceleration,
deceleration and jerk of the axis group. If the ACSC_AMF_VELOCITY flag is not specified, the default
value of velocity is used as well. If the ACSC_AMF_VELOCITY flag is specified, the value of Velocity is
used instead of the default velocity.
The function can wait for the controller response or can return immediately as specified by the
Wait argument.
The controller response indicates that the command was accepted and the motion was planned
successfully. The function cannot wait or validate the end of the motion. To wait for the motion
end, use the acsc_WaitMotionEnd function.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
Function Description
4.18.1 acsc_SetMaster
Description
The function initiates calculating of master value for an axis.
Syntax
int acsc_SetMaster(HANDLE Handle, int Axis, char* Formula,
ACSC_WAITBLOCK* Wait)
Arguments
Formula ASCII string that specifies a rule for calculating master value.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function initiates calculating of master value for an axis.
The master value for each axis is presented in the controller as one element of the MPOS array.
Once the acsc_SetMaster function is called, the controller is calculates the master value for the
specified axis each controller cycle.
The acsc_SetMaster function can be called again for the same axis at any time. At that moment, the
controller discards the previous formula and accepts the newly specified formula for the master
calculation.
The function can wait for the controller response or can return immediately as specified by the
Wait argument.
The controller response indicates that the command was accepted and the controller starts
calculating the master value according to the formula.
The Formula string can specify any valid ACSPL+ expression that uses any standard or user global
variables as its operands.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.18.2 acsc_Slave
Description
The function initiates a master-slave motion.
Syntax
int acsc_Slave(HANDLE Handle, int Flags, int Axis, ACSC_WAITBLOCK* Wait)
Arguments
Bit-mapped parameter that can include one or more of the following flags:
ACSC_AMF_WAIT: plan the motion but don’t start it until the function acsc_Go is
Flags executed.
ACSC_AMF_POSITIONLOCK: the motion will use position lock. If the flag is not
specified, velocity lock is used (see "Comments" on page 214).
Slaved axis: ACSC_AXIS_0 corresponds to axis 0, ACSC_AXIS_1 – to axis 1, etc. For the
Axis
axis constants see Axis Definitions.
Return Value
If the function succeeds, the return value is non-zero.
Comments
The function initiates a single-axis master-slave motion with an unlimited area of following. If the
area of following must be limited, use acsc_SlaveStalled.
The master-slave motion continues until the motion is killed or the motion fails for any reason.
The function can wait for the controller response or can return immediately as specified by the
Wait argument.
The controller response indicates that the command was accepted and the motion was planned
successfully.
The master value for the specified axis must be defined before by the call to acsc_SetMaster
function. The acsc_SetMaster function can be called again in order to change the formula of master
calculation. If at this moment the master-slave motion is in progress, the slave can come out from
synchronism. The controller then regains synchronism, probably with a different value of offset
between the master and slave.
If the ACSC_AMF_POSITIONLOCK flag is not specified, the function activates a velocity-lock mode of
slaved motion. When synchronized, the APOS axis reference follows the MPOS with a constant
offset:
APOS = MPOS + C
The value of C is latched at the moment when the motion comes to synchronism, and then remains
unchanged as long as the motion is synchronous. If at the moment of motion start the master
velocity is zero, the motion starts synchronously and C is equal to the difference between initial
values of APOS and MPOS.
If the ACSC_AMF_POSITIONLOCK flag is specified, the function activates a position-lock mode of
slaved motion. When synchronized, the APOS axis reference strictly follows the MPOS:
APOS = MPOS
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
{
printf("transaction error: %d\n", acsc_GetLastError());
}
4.18.3 acsc_SlaveStalled
Description
The function initiates master-slave motion within predefined limits.
Syntax
int acsc_SlaveStalled(HANDLE Handle, int Flags, int Axis, double Left, double Right, ACSC_
WAITBLOCK* Wait)
Arguments
Bit-mapped parameter that can include one or more of the following flags:
ACSC_AMF_WAIT: plan the motion but don’t start it until the acsc_Go function is
Flags executed.
ACSC_AMF_POSITIONLOCK: the motion will use position lock. If the flag is not
specified, velocity lock is used (see "Comments" on page 214).
Slaved axis: ACSC_AXIS_0 corresponds to axis 0, ACSC_AXIS_1 – to axis 1, etc. For the
Axis
axis constants see Axis Definitions.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function initiates single-axis master-slave motion within predefined limits. Use acsc_Slave to
initiate unlimited motion. For sophisticated forms of master-slave motion, use slaved variants of
segmented and spline motions.
The function can wait for the controller response or can return immediately as specified by the
Wait argument.
The controller response indicates that the command was accepted and the motion was planned
successfully.
The master-slave motion continues until the kill command is executed, or the motion fails for any
reason.
The master value for the specified axis must be defined before by the call to acsc_SetMaster
function. The acsc_SetMaster function can be called again in order to change the formula of master
calculation. If at this moment the master-slave motion is in progress, the slave can come out from
synchronism. The controller then regains synchronism, probably with a different value of offset
between the master and slave.
If the ACSC_AMF_POSITIONLOCK flag is not specified, the function activates a velocity-lock mode of
slaved motion. When synchronized, the APOS axis reference follows the MPOS with a constant
offset:
APOS = MPOS + C
The value of C is latched at the moment when the motion comes to synchronism, and then remains
unchanged as long as the motion is synchronous. If at the moment of motion start the master
velocity is zero, the motion starts synchronously and C is equal to the difference between initial
values of APOS and MPOS.
If the ACSC_AMF_POSITIONLOCK flag is specified, the function activates a position-lock mode of
slaved motion. When synchronized, the APOS axis reference strictly follows the MPOS:
APOS = MPOS
The Left and Right values define the allowed area of changing the APOS value. The MPOS value is
not limited and can exceed the limits. In this case, the motion comes out from synchronism, and the
APOS value remains (stalls) in one of the limits until the change of MPOS allows following again.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
Function Description
4.19.1 acsc_MultiPoint
Description
The function initiates a single-axis multi-point motion.
Syntax
int acsc_MultiPoint(HANDLE Handle, int Flags, int Axis, double Dwell,
ACSC_WAITBLOCK* Wait)
Arguments
Bit-mapped parameter that can include one or more of the following flags:
ACSC_AMF_WAIT: plan the motion but don’t start it until the function acsc_Go is
executed.
ACSC_AMF_RELATIVE: the coordinates of each point are relative. The first point is
relative to the instant position when the motion starts; the second point is relative
Flags to the first, etc. If the flag is not specified, the coordinates of each point are
absolute.
ACSC_AMF_VELOCITY: the motion uses the velocity specified with each point
instead of the default velocity.
ACSC_AMF_CYCLIC: the motion uses the point sequence as a cyclic array. After
positioning to the last point it does positioning to the first point and continues.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function initiates a single-axis multi-point motion. To execute multi-axis multi-point motion,
use acsc_MultiPointM.
The motion executes sequential positioning to each of the specified points, optionally with dwell in
each point.
The function itself does not specify any point, so that the created motion starts only after the first
point is specified. The points of motion are specified by using the acsc_AddPoint or acsc_
ExtAddPoint functions that follow this function.
The motion finishes when the acsc_EndSequence function is executed. If the call of acsc_
EndSequence is omitted, the motion will stop at the last point of the sequence and wait for the
next point. No transition to the next motion in the motion queue will occur until the function acsc_
EndSequence executes.
The function can wait for the controller response or can return immediately as specified by the
Wait argument.
The controller response indicates that the command was accepted and the motion was planned
successfully. The function cannot wait or validate the end of the motion. To wait for the motion
end, use the acsc_WaitMotionEnd function.
During positioning to each point, a velocity profile is built using the default values of acceleration,
deceleration, and jerk of the specified axis. If the ACSC_AMF_VELOCITY flag is not specified, the
default value of velocity is used as well. If the ACSC_AMF_VELOCITY flag is specified, the value of
velocity specified in subsequent acsc_ExtAddPoint functions is used.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.19.2 acsc_MultiPointM
Description
The function initiates a multi-axis multi-point motion.
Syntax
int acsc_MultiPointM(HANDLE Handle, int Flags, int* Axes, double Dwell,
ACSC_WAITBLOCK* Wait)
Arguments
Bit-mapped parameter that can include one or more of the following flags:
ACSC_AMF_WAIT: plan the motion but don’t start it until the function acsc_GoMis
executed.
ACSC_AMF_RELATIVE: the coordinates of each point are relative. The first point is
relative to the instant position when the motion starts; the second point is relative
Flags to the first, etc. If the flag is not specified, the coordinates of each point are
absolute.
ACSC_AMF_VELOCITY: the motion will use the velocity specified with each point
instead of the default velocity.
ACSC_AMF_CYCLIC: the motion uses the point sequence as a cyclic array: after
positioning to the last point does positioning to the first point and continues.
Array of axis constants. Each element specifies one involved axis: ACSC_AXIS_0
corresponds to axis 0, ACSC_AXIS_1 to axis 1, etc. After the last axis, one additional
Axes element must be located that contains –1 which marks the end of the array.
For the axis constants see Axis Definitions..
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function initiates a multi-axis multi-point motion. To execute single-axis multi-point motion,
use acsc_MultiPoint.
The motion executes sequential positioning to each of the specified points, optionally with dwell in
each point.
The function itself does not specify any point, so the created motion starts only after the first point
is specified. The points of motion are specified by using acsc_AddPointM or acsc_ExtAddPointM,
functions that follow this function.
The motion finishes when the acsc_EndSequenceM function is executed. If the call of acsc_
EndSequenceM is omitted, the motion will stop at the last point of the sequence and wait for the
next point. No transition to the next motion in the motion queue will occur until the function acsc_
EndSequenceM executes.
The function can wait for the controller response or can return immediately as specified by the
Wait argument.
The controller response indicates that the command was accepted and the motion was planned
successfully. The function cannot wait or validate the end of the motion. To wait for the motion
end, use acsc_WaitMotionEnd function.
During positioning to each point, a vector velocity profile is built using the default values of velocity,
acceleration, deceleration, and jerk of the axis group. If the AFM_VELOCITY flag is not specified, the
default value of velocity is used as well. If the AFM_VELOCITY flag is specified, the value of velocity
specified in subsequent acsc_ExtAddPointM functions is used.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
Function Description
acsc_ Initiates a single-axis spline motion. The motion follows an arbitrary path
Spline defined by a set of points.
acsc_ Initiates a multi-axis spline motion. The motion follows an arbitrary path defined
SplineM by a set of points.
4.20.1 acsc_Spline
Description
The function initiates a single-axis spline motion. The motion follows an arbitrary path defined by a
set of points.
Syntax
int acsc_Spline(HANDLE Handle, int Flags, int Axis, double Period,
ACSC_WAITBLOCK* Wait)
Arguments
Bit-mapped parameter that can include one or more of the following flags:
ACSC_AMF_WAIT: plan the motion but don’t start it until the acsc_Go function is
executed.
ACSC_AMF_RELATIVE: use the coordinates of each point as relative. The first point
is relative to the instant position when the motion starts; the second point is
relative to the first, etc. If the flag is not specified, the coordinates of each point
are absolute.
ACSC_AMF_VARTIME: the time interval between adjacent points is non-uniform
and is specified along with each added point. If the flag is not specified, the interval
is uniform and is specified in the Period argument.
Flags
ACSC_AMF_CYCLIC: use the point sequence as a cyclic array: after the last point
come to the first point and continue.
ACSC_AMF_CUBIC: use a cubic interpolation between the specified points (third-
order spline).
If the flag is not specified, linear interpolation is used (first-order spline).
If the flag is specified and the ACSC_AMF_VARTIME is not specified, the
controller builds PV spline motion.
If the flag is specified and the ACSC_AMF_VARTIME is specified, the
controller builds PVT spline motion.
Time interval between adjacent points. The parameter is used only if the ACSC_
Period
AMF_VARTIME flag is not specified.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function initiates a single-axis spline motion. To execute multi-axis spline motion, use acsc_
SplineM.
The function can wait for the controller response or can return immediately as specified by the
Wait argument.
The controller response indicates that the command was accepted and the motion was planned
successfully. The function cannot wait or validate the end of the motion. To wait for the motion
end, use the acsc_WaitMotionEnd function.
The motion does not use the default values of velocity, acceleration, deceleration, and jerk. The
points and the time intervals between the points completely define the motion profile.
Points for arbitrary path motion are defined by the consequent calls of acsc_AddPoint or acsc_
ExtAddPoint functions. The acsc_EndSequence function terminates the point sequence. After
execution of the acsc_EndSequence function, no acsc_AddPoint or acsc_ExtAddPoint functions for
this motion are allowed.
The trajectory of the motion follows through the defined points. Each point presents the instant
desired position at a specific moment. Time intervals between the points are uniform, or non-
uniform as defined by the ACSC_AMF_VARTIME flag.
This motion does not use a motion profile generation. The time intervals between the points are
typically short, so that the array of the points implicitly specifies the desired velocity in each point.
If the time interval does not coincide with the controller cycle, the controller provides interpolation
of the points according to the ACSC_AMF_CUBIC flag.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
ErrNum=0;
}while(ErrNum==3065);
}
// finish the motion
acsc_EndSequence(Handle, ACSC_AXIS_0, NULL); // the end of arbitrary path
4.20.2 acsc_SplineM
Description
The function initiates a multi-axis spline motion. The motion follows an arbitrary path defined by a
set of points.
Syntax
int acsc_SplineM(HANDLE Handle, int Flags, int* Axes, double Period,
ACSC_WAITBLOCK* Wait)
Arguments
Bit-mapped parameter that can include one or more of the following flags:
ACSC_AMF_WAIT: plan the motion but don’t start it until the acsc_GoM function is
executed.
ACSC_AMF_RELATIVE: the coordinates of each point are relative. The first point is
relative to the instant position when the motion starts; the second point is relative
to the first, etc. If the flag is not specified, the coordinates of each point are
absolute.
Flags ACSC_AMF_VARTIME: the time interval between adjacent points is non-uniform
and is specified along with each added point. If the flag is not specified, the interval
is uniform and is specified in the Period argument.
ΑCSC_AMF_CYCLIC: the motion uses the point sequence as a cyclic array: after the
last point the motion comes to the first point and continues.
ACSC_AMF_CUBIC: use a cubic interpolation between the specified points (third-
order spline). If the flag is not specified, linear interpolation is used (first-order
spline).
Array of axis constants. Each element specifies one involved axis: ACSC_AXIS_0
corresponds to axis 0, ACSC_AXIS_1 to axis 1, etc. After the last axis, one additional
Axes element must be located that contains –1 which marks the end of the array.
For the axis constants see Axis Definitions..
Time interval between adjacent points. The parameter is used only if the ACSC_
Period
AMF_VARTIME flag is not specified.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function initiates a multi-axis spline motion. To execute a single-axis spline motion, use acsc_
Spline.
The function can wait for the controller response or can return immediately as specified by the
Wait argument.
The controller response indicates that the command was accepted and the motion was planned
successfully. The function cannot wait or validate the end of the motion. To wait for the motion
end, use the acsc_WaitMotionEnd function.
The motion does not use the default values of velocity, acceleration, deceleration, and jerk. The
points and the time intervals between the points define the motion profile completely.
Points for arbitrary path motion are defined by the consequent calls of the acsc_AddPointM or
acsc_ExtAddPointM functions. The acsc_EndSequenceM function terminates the point sequence.
After execution of the acsc_EndSequenceM function, no acsc_AddPointM or acsc_ExtAddPointM
functions for this motion are allowed.
The trajectory of the motion follows through the defined points. Each point presents the instant
desired position at a specific moment. Time intervals between the points are uniform, or non-
uniform as defined by the ACSC_AMF_VARTIME flag.
This motion does not use motion profile generation. Typically, the time intervals between the
points are short, so that the array of the points implicitly specifies the desired velocity in each point.
If the time interval does not coincide with the controller cycle, the controller provides interpolation
of the points according to the ACSC_AMF_CUBIC flag.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
int Points[2];
if (!acsc_SplineM( Handle, // communication handle
0, // create the arbitrary path motion
// with uniform interval 10 ms
Axes, // axes XY
10, // uniform interval 10 ms
NULL // waiting call
))
{
printf("transaction error: %d\n", acsc_GetLastError());
}
// add some points
for (i = 0; i <100; i++)
{
Points[0] = i * 100; Points[1] = i * 50;
do
{
if(!acsc_AddPointM(Handle, Axes, Points, NULL))
ErrNum=acsc_GetLastError();
else
ErrNum=0;
}while(ErrNum==3065);
}
// finish the motion
acsc_EndSequenceM(Handle, Axes, NULL); // the end of arbitrary path
motion
Function Description
4.21.1 acsc_AddPVPoint
Description
The function adds a point to a single-axis PV spline motion and specifies velocity.
Syntax
int acsc_AddPVPoint(HANDLE Handle, int Axis, double Point, double Velocity,
ACSC_WAITBLOCK* Wait)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
Before this function can be used, PV spline motion must be initiated by calling acsc_Spline with the
appropriate flags.
The function adds a point to a single-axis PV spline motion with a uniform time and specified
velocity at that point
To add a point to a multi-axis PV motion, use acsc_AddPVPointM. To add a point to a PVT motion
with non-uniform time interval, use the acsc_AddPVTPoint and acsc_AddPVTPointM functions. The
function can wait for the controller response or can return immediately as specified by the Wait
argument.
The controller response indicates that the command was accepted and the point is added to the
motion buffer. The point can be rejected if the motion buffer is full. In this case, you can call this
function periodically until the function returns non-zero value.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
int i;
if (!acsc_Spline(Handle, // communication handle
ACSC_AMF_CUBIC, //PV motion uniform time inteval
ACSC_AXIS_0, // axis 0
10, // uniform interval 10 ms
NULL // waiting call
))
{
printf("transaction error: %d\n", acsc_GetLastError());
}
// add some points
for (i = 0; i <100; i++)
acsc_AddPVPoint(Handle,ACSC_AXIS_0,i*100,i*100,NULL);
//position,velocity and time interval for each point
// the end of the arbitrary path motion
acsc_EndSequence(Handle, ACSC_AXIS_0, NULL);
4.21.2 acsc_AddPVPointM
Description
The function adds a point to a multiple-axis PV spline motion and specifies velocity.
Syntax
int acsc_AddPVPointM(HANDLE Handle, int *Axis, double *Point, double *Velocity,
ACSC_WAITBLOCK* Wait)
Arguments
Array of axis constants. Each element specifies one involved axis: ACSC_AXIS_0
corresponds to axis 0, ACSC_AXIS_1 to axis 1, etc. After the last axis, one additional
Axes element must be located that contains –1 which marks the end of the array.
For the axis constants see Axis Definitions..
Array of the coordinates of added point. The number and order of values must
Point correspond to the Axes array. The Point must specify a value for each element of
Axes except the last –1 element.
Array of the velocities of added point. The number and order of values must
Velocity correspond to the Axes array. The Velocity must specify a value for each element
of Axes except the last –1 element.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
Before this function can be used, PVT spline motion must be initiated by calling acsc_SplineM with
the appropriate flags.
The function adds a point to a multiple-axis PV spline motion with a uniform time and specified
velocity at that point.
To add a point to a single-axis PV motion, use acsc_AddPVPoint. To add a point to a PVT motion with
non-uniform time interval, use the acsc_AddPVTPoint andacsc_AddPVTPointM functions.
The function can wait for the controller response or can return immediately as specified by the
Wait argument.
The controller response indicates that the command was accepted and the point is added to the
motion buffer. The point can be rejected if the motion buffer is full. In this case, you can call this
function periodically until the function returns non-zero value.
All axes specified in the Axes array must be specified before the call of the acsc_MultiPointM or
acsc_SplineMfunction. The number and order of the axes in the Axes array must correspond
exactly to the number and order of the axes of acsc_MultiPointM or acsc_SplineMfunctions.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
int i;
int Axis[]={ACSC_AXIS_0, ACSC_AXIS_1, ACSC_AXIS_4,-1};
double Point[3];
double Velocity[3];
if (!acsc_SplineM( Handle, // communication handle
ACSC_AMF_CUBIC, // PV motion
Axis, // axis 0
10, // uniform interval 10 ms
NULL // waiting call
))
{
printf("transaction error: %d\n", acsc_GetLastError());
}
// add some points
for (i = 0; i <100; i++)
{
Point[0]=i*50; Point[1]=i*100; Point[2]=i*150;
Velocity[0]=i*50; Velocity [1]=i*100; Velocity [2]=i*150;
acsc_AddPVPointM(Handle,Axis,Point,Velocity,NULL);
//position,velocity and time interval for each point
}
// the end of the arbitrary path motion
acsc_EndSequence(Handle, ACSC_AXIS_0, NULL);
4.21.3 acsc_AddPVTPoint
Description
The function adds a point to a single-axis PVT spline motion and specifies velocity and motion time.
Syntax
int acsc_AddPVTPoint(HANDLE Handle, int Axis, double Point, double Velocity,
double TimeInterval, ACSC_WAITBLOCK* Wait)
Arguments
If the motion was activated by the acsc_Spline function with the ACSC_AMF_
TimeInterval VARTIME flag, this parameter defines the time interval between the previous
point and the present one.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
Before this function can be used, PV spline motion must be initiated by calling acsc_Spline with the
appropriate flags.
The function adds a point to a single-axis PVT spline motion with a non-uniform time and specified
velocity at that point.
To add a point to a multi-axis PVT motion, use acsc_AddPVTPointM. To add a point to a PV motion
with uniform time interval, use the acsc_AddPVPoint and acsc_AddPVPointM functions.
The function can wait for the controller response or can return immediately as specified by the
Wait argument.
The controller response indicates that the command was accepted and the point is added to the
motion buffer. The point can be rejected if the motion buffer is full. In this case, you can call this
function periodically until the function returns non-zero value.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
int i;
if (!acsc_Spline(Handle, // communication handle
ACSC_AMF_CUBIC|ACSC_AMF_VARTIME,//PVT motion
ACSC_AXIS_0, // axis 0
0, // uniform interval is not used
NULL // waiting call
))
{
printf("transaction error: %d\n", acsc_GetLastError());
}
// add some points
for (i = 0; i <100; i++)
acsc_AddPVTPoint(Handle,ACSC_AXIS_0,i*100,i*100,100+i,NULL);
//position,velocity and time interval for each point
// the end of the arbitrary path motion
acsc_EndSequence(Handle, ACSC_AXIS_0, NULL);
4.21.4 acsc_AddPVTPointM
Description
The function adds a point to a multiple-axis PVT spline motion and specifies velocity and motion
time.
Syntax
int acsc_AddPVTPointM(HANDLE Handle, int *Axis, double *Point,
double *Velocity,double TimeInterval, ACSC_WAITBLOCK* Wait)
Arguments
Array of axis constants. Each element specifies one involved axis: ACSC_AXIS_
0 corresponds to axis 0, ACSC_AXIS_1 to axis 1, etc. After the last axis, one
Axes additional element must be located that contains –1 which marks the end of
the array.
For the axis constants see Axis Definitions..
Array of the coordinates of added point. The number and order of values
Point must correspond to the Axes array. The Point must specify a value for each
element of Axes except the last –1 element.
Array of the velocities of added point. The number and order of values must
Velocity correspond to the Axes array. The Velocity must specify a value for each
element of Axes except the last –1 element.
If the motion was activated by the acsc_SplineM function with the ACSC_
TimeInterval AMF_VARTIME flag, this parameter defines the time interval between the
previous point and the present one.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
Before this function can be used, PVT spline motion must be initiated by calling acsc_SplineM with
the appropriate flags.
The function adds a point to a multiple-axis PVT spline motion with a non-uniform time and
specified velocity at that point.
To add a point to a single-axis PVT motion, use acsc_AddPVTPoint. To add a point to a PV motion
with uniform time interval, use the acsc_AddPVPoint and acsc_AddPointM functions.
The function can wait for the controller response or can return immediately as specified by the
Wait argument.
The controller response indicates that the command was accepted and the point is added to the
motion buffer. The point can be rejected if the motion buffer is full. In this case, you can call this
function periodically until the function returns non-zero value.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
int i;
int Axis[]={ACSC_AXIS_0, ACSC_AXIS_1, ACSC_AXIS_2,-1};
double Point[3];
double Velocity[3];
if (!acsc_SplineM(Handle, // communication handle
ACSC_AMF_CUBIC|ACSC_AMF_VARTIME,//PVT motion
Axis, // axis 0
0, // uniform interval is not used
NULL // waiting call
))
{
printf("transaction error: %d\n", acsc_GetLastError());
}
// add some points
for (i = 0; i <100; i++)
{
Point[0]=i*50; Point[1]=i*100; Point[2]=i*150;
Velocity[0]=i*50; Velocity [1]=i*100; Velocity [2]=i*150;
acsc_AddPVTPointM(Handle,Axis,Point,Velocity,100+i,NULL);
//position,velocity and time interval for each point
}
// the end of the arbitrary path motion
acsc_EndSequence(Handle, ACSC_AXIS_0, NULL);
Function Description
acsc_
Initiates a multi-axis extended segmented motion.
ExtendedSegmentedMotionExt
4.22.1 acsc_SegmentedMotion
Description
The function initiates a multi-axis segmented motion.
Syntax
int acsc_SegmentedMotion(HANDLE Handle, int Flags, int* Axes, double* Point,
ACSC_WAITBLOCK* Wait)
Arguments
Bit-mapped parameter that can include one or more of the following flags:
ACSC_AMF_WAIT: plan the motion but don’t start it until the function acsc_GoM is
Flags executed.
ACSC_AMF_VELOCITY: the motion will use velocity specified for each segment
instead of the default velocity.
ACSC_AMF_CYCLIC: the motion uses the segment sequence as a cyclic array: after
the last segment, move along the first segment etc.
ACSC_AMF_VELOCITYLOCK: slaved motion: the motion advances in accordance to
the master value of the leading axis.
ACSC_AMF_POSITIONLOCK: slaved motion, strictly conformed to master.
ACSC_AMF_EXTRAPOLATED: if a master value travels beyond the specified path,
the last or the first segment is extrapolated.
ACSC_AMF_STALLED: if a master value travels beyond the specified path, the
motion stalls at the last or first point.
Array of axis constants. Each element specifies one involved axis: ACSC_AXIS_0
corresponds to axis 0, ACSC_AXIS_1 to axis 1, etc. After the last axis, one additional
Axes element must be located that contains –1 which marks the end of the array.
For the axis constants see Axis Definitions..
Array of the coordinates of the initial point on the plane. The number and order of
Point values must correspond to the Axes array. The Point must specify a value for each
element of Axes except the last –1 element.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function initiates a multi-axis segmented motion.
Segmented motion moves axes along a continuous path. The path is defined as a sequence of
linear and arc segments on the plane. Although segmented motion follows a flat path, it can
involve any number of axes, because the motion plane can be connected to the axes at any
projection transformation. To effect such transformation, use the acsc_Projection function.
The function itself does not specify any segment, so the created motion starts only after the first
segment is specified. The segments of motion are specified by using acsc_SegmentLineExt, acsc_
ExtendedSegmentArc1, acsc_ExtendedSegmentArc2 functions that follow this function.
The motion finishes when the acsc_EndSequenceM function is executed. If the call of acsc_
EndSequenceM is omitted, the motion will stop at the last segment of the sequence and wait for
the next segment. No transition to the next motion in the motion queue will occur until the
function acsc_EndSequenceM is executed.
During positioning to each point, a vector velocity profile is built using the default values of velocity,
acceleration, deceleration, and jerk of the axis group. If the AFM_VELOCITY flag is not specified, the
default value of velocity is used as well. If the AFM_VELOCITY flag is specified, the value of velocity
specified in subsequent acsc_SegmentLineExt, acsc_ExtendedSegmentArc1, or acsc_
ExtendedSegmentArc2 functions is used.
The flags ACSC_AMF_EXTRAPOLATED and ACSC_AMF_STALLED are relevant only for slaved motion
and must be used with ACSC_AMF_VELOCITYLOCK or ACSC_AMF_POSITIONLOCK flags.
The function can wait for the controller response or can return immediately as specified by the
Wait argument.
The controller response indicates that the command was accepted and the motion was planned
successfully. The function does not wait and does not validate the end of the motion. To wait for
the motion end, use the acsc_WaitMotionEnd function.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.22.2 acsc_ExtendedSegmentedMotionExt
Description
The function waits for the end of data collection.
Syntax
int acsc_ExtendedSegmentedMotion(HANDLE Handle, int Flags, int* Axes, double* Point,
double Velocity, double EndVelocity, double JunctionVelocity, double Angle, double CurveVelocity,
double Deviation, double Radius, double MaxLength,double StarvationMargin, char* Segments,
ACSC_WAITBLOCK* Wait);
Arguments
angle in radians.
If ACSC_AMF_ANGLE flag is not specified while ACSC_AMF_
JUNCTIONVELOCITY flag is specified, the controller accepts
default value of 0.01 radians that is about 0.57 degrees.
If none of the ACSC_AMF_JUNCTIONVELOCITY and ACSC_AMF_
ANGLE flags are specified, the controller provides automatic
calculation as described in Automatic corner processing.
ACSC_AMF_AXISLIMIT
Enable velocity limitations under axis limits.
With this flag set, setting the ACSC_AMF_VELOCITY flag will result
in the requested velocity being restrained by the velocity limits
of all involved axes.
ACSC_AMF_CURVEVELOCITY
Decelerate to curvature discontinuity point.
This flag requires an additional parameter that specifies velocity
at curvature discontinuity points.
Curvature discontinuity occurs in linear-to-arc or arc-to-arc
smooth junctions.
If the flag is not set, the controller does not decelerate to
smooth junction disregarding curvature discontinuity in the
junction.
If the flag is set, the controller detects curvature discontinuity
points on the path and provides deceleration to the specified
velocity.
The specified value should be less than the required velocity;
otherwise the parameter is ignored.
The flag can be set together with flags ACSC_AMF_
JUNCTIONVELOCITY and/or ACS_AMF_ANGLE.
If neither of ACSC_AMF_JUNCTIONVELOCITY, ACS_AMF_ANGLE or
ACSC_AMF_CURVEVELOCITY is set, the controller provides
automatic calculation of the corner processing.
ACSC_AMF_CURVEAUTO
If the Flag is specified the controller provides automatic
calculations as described in Enhanced automatic corner and
curvature discontinuity points processing.
ACSC_AMF_CORNERDEVIATION
Use a corner rounding option with the specified permitted
deviation. This flag requires an additional parameter that
specifies maximal allowed deviation of motion trajectory from
the corner point. This flag cannot be set together with flags
Array of axis constants. Each element specifies one involved axis: ACSC_
AXIS_0 corresponds to axis 0, ACSC_AXIS_1 to axis 1, etc. After the last
Axes axis, one additional element must be located that contains –1 which
marks the end of the array.
For the axis constants see Axis Definitions.
Array of the starting point coordinates. The number and order of values
Point must correspond to the Axes array. Point must specify a value for each
element of Axes except the last –1 element.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Extended error information can be obtained by calling acsc_GetLastError.
Comments
The function itself does not specify any segment, so the created motion starts only after the first
segment is specified.
The segments of motion are specified by using acsc_SegmentLineExt, acsc_ExtendedSegmentArc1,
acsc_ExtendedSegmentArc2 functions that follow this function.
The motion finishes when the acsc_EndSequenceM function is executed. If the call of acsc_
EndSequenceM is omitted, the motion will stop at the last segment of the sequence and wait for
the next segment. No transition to the next motion in the motion queue will occur until the
function acsc_EndSequenceM is executed.
During positioning to each point, a vector velocity profile is built using the default values of velocity,
acceleration, deceleration, and jerk of the axis group. If the ACSC_AFM_VELOCITY flag is not
specified, the default value of velocity is used as well. If the ACSC_AFM_VELOCITY flag is specified,
the value of velocity specified in subsequent acsc_SegmentLineExt, acsc_ExtendedSegmentArc1, or
acsc_ExtendedSegmentArc2 functions is used.
The function can wait for the controller response or can return immediately as specified by the
Wait argument.
The controller response indicates that the command was accepted and the motion was planned
successfully. The function does not wait and does not validate the end of the motion. To wait for
the motion end, use the acsc_WaitMotionEnd function.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
ACSC_AMF_VELOCITY | ACSC_AMF_CORNERRADIUS,
// Velocity and corner radius flags are set, parameters now required.
Axes, //Axes 0,1 active
Point, // Starting point
5000, // Velocity is set to 5000
ACSC_NONE, //EndVelocity is the default value
ACSC_NONE, //JunctionVelocity is the default value
ACSC_NONE, // Angle is the default value
ACSC_NONE, // CurveVElocity is the default value
ACSC_NONE, // Deviation
10, // Radius is set
ACSC_NONE, // Maximum corner length is default
ACSC_NONE, // Starvation margin is the default value
NULL, //Segments are set to NULL
ACSC_SYNCHRONOUS // Waiting call
)){
printf(“transaction error: %d\n”, acsc_GetLAstError());
}
4.22.3 acsc_SegmentLineExt
Description
The function adds a linear segment that starts at the current point and ends at the destination
point of segmented motion.
Syntax
Int acsc_SegmentLineExt(HANDLE handle, int Flags, int* Axes, Double* Point, double Velocity,
double EndVelocity, int Time, char* Values, char* Variables, int Index, char* Masks, ACSC_
WAITBLOCK* Wait);
Arguments
Bit-mapped argument that can include one or more of the following flags:
ACSC_AMF_VELOCITY: the motion will use velocity specified for each segment
instead of the default velocity.
Flags
ACSC_AMF_ENDVELOCITY: this flag requires additional parameter that specifies
end velocity. The controller decelerates to the specified velocity in the end of
segment. The specified value should be less than the required velocity;
otherwise the parameter is ignored. This flag affects only one segment.
Array of axis constants. Each element specifies one involved axis: ACSC_AXIS_0
corresponds to axis 0, ACSC_AXIS_1 to axis 1, etc. After the last axis, one
Axes additional element must be located that contains –1 which marks the end of
the array.
For the axis constants see Axis Definitions..
Array of the final point coordinates. The number and order of values must
Point correspond to the Axes array. The Point must specify a value for each element
of Axes except the last –1 element.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function adds a linear segment that starts at the current point and ends at the destination
point to segmented motion.
All axes specified in the Axes array must be specified before the call of the acsc_SegmentedMotion
or acsc_ExtendedSegmentedMotionExt function. The number and order of the axes in the Axes
array must correspond exactly to the number and order of the axes of the acsc_SegmentedMotion
or acsc_ExtendedSegmentedMotionExt function.
The Point argument specifies the coordinates of the final point. The coordinates are absolute in the
plane.
ACSC_AMF_VELOCITY and ACSC_AMF_VARTIME are mutually exclusive, meaning they cannot be
used together.
The function can wait for the controller response or can return immediately as specified by the
Wait argument.
The controller response indicates that the command was accepted and the segment is added to
the motion buffer. The segment can be rejected if the motion buffer is full. In that case, you can call
this function periodically until the function returns a non-zero value
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
// add line segment with final point (1000, -1000), vector velocity 25000
Point[0] = 1000; Point[1] = -1000;
if (!acsc_SegmentLineExt(Handle, // Communication handle
ACSC_AMF_VELOCITY, // Velocity is specified
Axes, // Axes 0 and 1
Point, // Final point
25000, // Vector velocity
ACSC_NONE, // End velocity is not specified
ACSC_NONE, // Time is not specified
NULL, // Values array is not specified
NULL, // Variables array is not specified
ACSC_NONE, // Index is not specified
NULL, // Masks array is not specified
NULL // Waiting call
))
{
printf("transaction error: %d\n", acsc_GetLastError());
}
// add line segment with final point (1000, 1000), vector velocity 5000
Point[0] = 1000; Point[1] = 1000;
if (!acsc_SegmentLineExt(Handle,
ACSC_AMF_VELOCITY, // Velocity is specified
Axes, // Axes 0 and 1
Point, // Final point
5000, // Vector velocity
ACSC_NONE, // End velocity is not specified
ACSC_NONE, // Time is not specified
NULL, // Values array is not specified
NULL, // Variables array is not specified
ACSC_NONE, // Index is not specified
NULL, // Masks array is not specified
ACSC_SYNCHRONOUS // Waiting call
))
{
printf("transaction error: %d\n", acsc_GetLastError());
}
// finish the motion
acsc_EndSequenceM(Handle, Axes, NULL);
4.22.4 acsc_ExtendedSegmentArc1
Description
The function adds to the motion path an arc segment that starts at the current point and ends at
the destination point with the specified center point.
Syntax
Arguments
Bit-mapped argument that can include one or more of the following flags:
ACSC_AMF_VELOCITY: the motion will use velocity specified for each segment
instead of the default velocity.
ACSC_AMF_ENDVELOCITY: this flag requires an additional parameter that
specifies end velocity. The controller decelerates to the specified velocity in
the end of segment. The specified value should be less than the required
velocity; otherwise the argument is ignored. This flag affects only one
segment.
ACSC_AMF_VARTIME: this flag requires an addition parameter that specifies
the segment processing time in milliseconds. The segment processing time
Flags defines velocity at the current segment only and has no effect on subsequent
segments.
This flag also disables corner detection and processing at the end of
segment.
If this flag is not specified, deceleration is not required. However, in
special cases the deceleration might occur due to corner processing
or other velocity control conditions.
ACSC_AMF_USERVARIABLES: synchronize user variables with segment
execution. This flag requires additional parameters that specify values, user
variable and mask. See details in the Values, Variables, and Masks arguments
below.
Array of axis constants. Each element specifies one involved axis: ACSC_AXIS_0
corresponds to 0, ACSC_AXIS_1 to 1, etc. After the last axis, one additional
Axes element must be located that contains –1 which marks the end of the array.
For the axis constants see Axis Definitions.
Array of the center coordinates. The number and order of values must
Center correspond to the Axes array. The Center must specify a value for each
element of the Axes except the last–1 element.
Array of the final point coordinates. The number and order of values must
FinalPoint correspond to the Axes array. The FinalPoint must specify a value for each
element of Axes except the last –1 element.
The masks are only applied for integer values: variables(n) = values(n) AND
mask(n)
If Values is a real array, the masks argument should be NULL.
Set this argument to ACSC_NONE if not used.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
All axes specified in the Axes array must be specified before the call of the acsc_SegmentedMotion
function. The number and order of the axes in the Axes array must correspond exactly to the
number and order of the axes of the acsc_SegmentedMotion function.
The Point argument specifies the coordinates of the final point. The coordinates are absolute in the
plane.
ACSC_AMF_VELOCITY and ACSC_AMF_VARTIME are mutually exclusive, meaning they cannot be
used together.
The function can wait for the controller response or can return immediately as specified by the
Wait argument.
The controller response indicates that the command was accepted and the segment is added to
the motion buffer. The segment can be rejected if the motion buffer is full. In that case, you can call
this function periodically until the function returns a non-zero value.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the "acsc_WaitForAsyncCall" on page 51 function.
Example
4.22.5 acsc_ExtendedSegmentArc2
Description
The function adds an arc segment to a segmented motion and specifies the coordinates of the
center point and the rotation angle.
Syntax
Arguments
Bit-mapped argument that can include one or more of the following flags:
ACSC_AMF_VELOCITY: the motion will use velocity specified for each segment
instead of the default velocity.
ACSC_AMF_ENDVELOCITY: this flag requires an additional parameter that
specifies end velocity. The controller decelerates to the specified velocity in
the end of segment. The specified value should be less than the required
velocity; otherwise the argument is ignored. This flag affects only one
segment.
ACSC_AMF_VARTIME: this flag requires an addition parameter that specifies
the segment processing time in milliseconds. The segment processing time
Flags defines velocity at the current segment only and has no effect on subsequent
segments.
This flag also disables corner detection and processing at the end of
segment.
If this flag is not specified, deceleration is not required. However, in
special cases the deceleration might occur due to corner processing
or other velocity control conditions.
ACSC_AMF_USERVARIABLES: synchronize user variables with segment
execution. This flag requires additional parameters that specify values, user
variable and mask. See details in the Values, Variables, and Masks arguments
below.
Array of axis constants. Each element specifies one involved axis: ACSC_AXIS_0
corresponds to 0, ACSC_AXIS_1 to 1, etc. After the last axis, one additional
Axes element must be located that contains –1 which marks the end of the array.
For the axis constants see Axis Definitions.
Array of the center coordinates. The number and order of values must
Center correspond to the Axes array. The Center must specify a value for each
element of the Axes except the last–1 element.
Array indicating the final points of the secondary axes, array size must be
FinalPoints number of secondary axes (size of Axes – 2).
Set this argument to NULL if not used.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
All axes specified in the Axes array must be specified before the call of the acsc_
SegmentedMotion or acsc_ExtendedSegmentedMotionExt function. The number and order of the
axes in the Axes array must correspond exactly to the number and order of the axes of the acsc_
SegmentedMotion or acsc_ExtendedSegmentedMotionExt function.
The Point argument specifies the coordinates of the final point. The coordinates are absolute in the
plane.
ACSC_AMF_VELOCITY and ACSC_AMF_VARTIME are mutually exclusive, meaning they cannot be
used together.
The function can wait for the controller response or can return immediately as specified by the
Wait argument.
The controller response indicates that the command was accepted and the segment is added to
the motion buffer. The segment can be rejected if the motion buffer is full. In that case, you can call
this function periodically until the function returns a non-zero value.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the "acsc_WaitForAsyncCall" on page 51 function.
Example
if (!acsc_ExtendedSegmentArc2(Handle,
ACSC_AMF_VELOCITY | ACSC_AMF_ENDVELOCITY,// Flags
axes,// Axes
center,//Center
-3.141529,// Angle
FinalPointArc2,// FinalPoints
5000,// Velocity
10000,// EndVelocity
ACSC_NONE,// Time
NULL,// Values
NULL,// Variables
ACSC_NONE,// Index
NULL,// Masks
NULL))// Wait
{
printf("transaction error: %d\n", acsc_GetLastError());
}
4.22.6 acsc_Stopper
Description
The function provides a smooth transition between two segments of segmented motion.
Syntax
int acsc_Stopper(HANDLE Handle, int* Axes, ACSC_WAITBLOCK* Wait)
Arguments
Array of axis constants. Each element specifies one involved axis: ACSC_AXIS_0
corresponds to axis 0, ACSC_AXIS_1 to axis 1, etc. After the last axis, one additional
Axes element must be located that contains –1 which marks the end of the array.
For the axis constants see Axis Definitions.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The controller builds the motion so that the vector velocity follows the smooth velocity diagram.
The segments define the projection of the vector velocity to axis velocities. If all segments are
connected smoothly, axis velocity is also smooth. However, if the user defined a path with an
inflection point, axis velocity has a jump in this point. The jump can cause a motion failure due to
the acceleration limit.
The function is used to avoid velocity jump in the inflection points. If the function is specified
between two segments, the controller provides smooth deceleration to zero in the end of first
segment and smooth acceleration to specified velocity in the beginning of second segment.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.22.7 acsc_Projection
Description
The function sets a projection matrix for segmented motion.
Syntax
int acsc_Projection(HANDLE Handle, int* Axes, char* Matrix,
ACSC_WAITBLOCK* Wait)
Arguments
Array of axis constants. Each element specifies one involved axis: ACSC_AXIS_0
corresponds to axis 0, ACSC_AXIS_1 to axis 1, etc. After the last axis, one additional
Axes element must be located that contains –1 which marks the end of the array.
For the axis constants see Axis Definitions.
Pointer to the null-terminated string containing the name of the matrix that
Matrix
provides the specified projection.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function sets a projection matrix for segmented motion.
The projection matrix connects the plane coordinates and the axis values in the axis group. The
projection can provide any transformation as rotation or scaling. The number of the matrix rows
must be equal to the number of the specified axes. The number of the matrix columns must equal
two.
The matrix must be declared before as a global variable by an ACSPL+ program or by the acsc_
DeclareVariable function and must be initialized by an ACSPL+ program or by the acsc_WriteReal
function.
For more information about projection, see the SPiiPlus ACSPL+ Programmer’s Guide.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
Function Description
4.23.1 acsc_BlendedSegmentMotion
Description
The function initiates a multi-axis blended segmented motion. Extended segmented motion
provides new features:
Syntax
int acsc_BlendedSegmentMotion(HANDLE handle, int Flags, int* Axes, double* Position, double
SegmentTime, double AccelerationTime, double JerkTime, double DwellTime, ACSC_WAITBLOCK
*Wait)
Arguments
Return Value
If the function succeeds, a non-zero is returned.
If the function fails, return value is zero.
Comments
Blended segmented motion is a type of segmented motion that doesn’t provide look-ahead
capabilities, unlike Extended segmented motion. Both type of motions are intended for processing
a complex multi-axis trajectory and smoothing corners between segments, but do it in different
ways. The Extended segmented motion (XSEG) allows achieving highest throughput within the
defined axis limitations and the defined accuracy. The Blended segmented motion (BSEG) allows
passing along the trajectory with the defined timing constrains.
The function itself does not specify any movement, so the created motion starts only after the first
segment is specified.
The segments of motion are specified by using acsc_BlendedLine, acsc_BlendedArc1, acsc_
BlendedArc2 functions that follow this function.
The motion finishes when the acsc_EndSequenceM function is executed. If the call of acsc_
EndSequenceM is omitted, the motion will stop at the last segment of the sequence and wait for
the next segment. No transition to the next motion in the motion queue will occur until the
function acsc_EndSequenceM is executed.
The function can wait for the controller response or can return immediately as specified by the
Wait argument.
The controller response indicates that the command was accepted and the motion was planned
successfully. The function does not wait and does not validate the end of the motion. To wait for
the motion end, use the acsc_WaitMotionEnd function.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.23.2 acsc_BlendedLine
Description
The function adds a linear segment that starts at the current point and ends at the destination
point of segmented motion.
Syntax
Int acsc_BlendedLine (HANDLE handle, int Flags, int* Axes, double* Point, double SegmentTime,
double AccelerationTime, double JerkTime, double DwellTime, ACSC_WAITBLOCK* Wait);
Arguments
Array of axis constants. Each element specifies one involved axis: ACSC_
AXIS_0 corresponds to axis 0, ACSC_AXIS_1 to axis 1, etc. After the last
Axes
axis, one additional element must be located that contains –1 which
marks the end of the array. For the axis constants see Axis Definitions.
Array of the final point coordinates. The number and order of values
Point must correspond to the Axes array. The Point must specify a value for
each element of Axes except the last –1 element.
Return Value
If the function succeeds, a non-zero is returned.
If the function fails, return value is zero.
Comments
The function adds a linear segment that starts at the current point and ends at the destination
point to segmented motion.
All axes specified in the Axes array must be specified in a previous call to the acsc_
BlendedSegmentMotion function. The number and order of the axes in the Axes array must
correspond exactly to the number and order of the axes of the call to the acsc_
BlendedSegmentMotion function.
The Point argument specifies the coordinates of the final point. The coordinates are absolute in the
plane.
The function can wait for the controller response or can return immediately as specified by the
Wait argument.
The controller response indicates that the command was accepted and the segment is added to
the motion buffer. The segment can be rejected if the motion buffer is full. In that case, you can call
this function periodically until the function returns a non-zero value.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete
theWait item until a call to the "acsc_WaitForAsyncCall" on page 51 function.
Example
4.23.3 acsc_BlendedArc1
Description
The function adds to the motion path an arc segment that starts at the current point and ends at
the destination point with the specified center point.
Syntax
Int acsc_BlendedArc1 (HANDLE handle, int Flags, int* Axes, double* Center, double* FinalPoint, int
Rotation, double SegmentTime, double AccelerationTime, double JerkTime, double DwellTime,
ACSC_WAITBLOCK* Wait);
Arguments
Array of axis constants. Each element specifies one involved axis: ACSC_
AXIS_0 corresponds to axis 0, ACSC_AXIS_1 to axis 1, etc. After the last
Axes
axis, one additional element must be located that contains –1 which
marks the end of the array. For the axis constants see Axis Definitions.
Array of the center coordinates. The number and order of values must
Center correspond to the Axes array. The Center must specify a value for each
element of the Axes except the last –1 element.
Array of the final point coordinates. The number and order of values
FinalPoint must correspond to the Axes array. The Point must specify a value for
each element of Axes except the last –1 element.
Return Value
If the function succeeds, a non-zero is returned.
If the function fails, return value is zero.
Comments
All axes specified in the Axes array must be specified in a previous call to the acsc_
BlendedSegmentMotion function. The number and order of the axes in the Axes array must
correspond exactly to the number and order of the axes of the call to the acsc_
BlendedSegmentMotion function.
The FinalPoint argument specifies the coordinates of the final point. The coordinates are absolute
in the plane.
The function can wait for the controller response or can return immediately as specified by the
Wait argument.
The controller response indicates that the command was accepted and the segment is added to
the motion buffer. The segment can be rejected if the motion buffer is full. In that case, you can call
this function periodically until the function returns a non-zero value.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.23.4 acsc_BlendedArc2
Description
The function adds an arc segment to a segmented motion and specifies the coordinates of the
center point and the rotation angle.
Syntax
Int acsc_BlendedArc2 (HANDLE handle, int Flags, int* Axes, double* Center, double Angle, double
SegmentTime, double AccelerationTime, double JerkTime, double DwellTime, ACSC_WAITBLOCK*
Wait);
Arguments
Array of axis constants. Each element specifies one involved axis: ACSC_
AXIS_0 corresponds to axis 0, ACSC_AXIS_1 to axis 1, etc. After the last
Axes
axis, one additional element must be located that contains –1 which
marks the end of the array. For the axis constants see Axis Definitions.
Array of the center coordinates. The number and order of values must
Center correspond to theAxes array. The Center must specify a value for each
element of the Axes except the last –1 element.
Return Value
If the function succeeds, a non-zero is returned.
If the function fails, return value is zero.
Comments
All axes specified in the Axes array must be specified in a previous call to the acsc_
BlendedSegmentMotion function. The number and order of the axes in the Axes array must
correspond exactly to the number and order of the axes of the call to the acsc_
BlendedSegmentMotion function.
The Center argument specifies the coordinates of the Center point. The coordinates are absolute in
the plane.
The function can wait for the controller response or can return immediately as specified by the
Wait argument.
The controller response indicates that the command was accepted and the segment is added to
the motion buffer. The segment can be rejected if the motion buffer is full. In that case, you can call
this function periodically until the function returns a non-zero value.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the "acsc_WaitForAsyncCall" on page 51 function.
Example
Function Description
acsc_
Adds a point to a multi-axis multi-point or spline motion.
AddPointM
acsc_ Informs the controller that no more points will be specified for the current
EndSequence single-axis motion.
acsc_ Informs the controller that no more points or segments will be specified
EndSequenceM for the current multi-axis motion.
4.24.1 acsc_AddPoint
Description
The function adds a point to a single-axis multi-point or spline motion.
Syntax
int acsc_AddPoint(HANDLE Handle, int Axis, double Point,
ACSC_WAITBLOCK* Wait)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function adds a point to a single-axis multi-point or spline motion. To add a point to a multi-axis
motion, use acsc_AddPVPointM. To add a point with a specified non-default velocity or time interval
use acsc_AddPVPoint or acsc_AddPVPointM.
The function can wait for the controller response or can return immediately as specified by the
Wait argument.
The controller response indicates that the command was accepted and the point is added to the
motion buffer. The point can be rejected if the motion buffer is full. In this case, you can call this
function periodically until the function returns non-zero value.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.24.2 acsc_AddPointM
Description
The function adds a point to a multi-axis multi-point or spline motion.
Syntax
int acsc_AddPointM(HANDLE Handle, int* Axes, double* Point,
ACSC_WAITBLOCK* Wait)
Arguments
Array of axis constants. Each element specifies one involved axis: ACSC_AXIS_0
corresponds to axis0, ACSC_AXIS_1 to axis 1, etc. After the last axis, one additional
Axes element must be located that contains –1 which marks the end of the array.
For the axis constants see Axis Definitions.
Array of the coordinates of added point. The number and order of values must
Point correspond to the Axes array. The Point must specify a value for each element of
Axes except the last –1 element.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function adds a point to a multi-axis multi-point or spline motion. To add a point to a single-axis
motion, use acsc_AddPoint. To add a point with a specified non-default velocity or time interval use
acsc_ExtAddPoint or acsc_ExtAddPointM.
The function can wait for the controller response or can return immediately as specified by the
Wait argument.
The controller response indicates that the command was accepted and the point is added to the
motion buffer. The point can be rejected if the motion buffer is full. In this case, you can call this
function periodically until the function returns non-zero value.
All axes specified in the Axes array must be specified before the call of the acsc_MultiPointM or
acsc_SplineM function. The number and order of the axes in the Axes array must correspond
exactly to the number and order of the axes of acsc_MultiPointM or acsc_SplineM functions.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
break;
}
}
// finish the motion
acsc_EndSequenceM(Handle, Axes, NULL); // the end of the multi-point
motion
4.24.3 acsc_ExtAddPoint
Description
The function adds a point to a single-axis multi-point or spline motion and specifies a specific
velocity or motion time.
Syntax
int acsc_ExtAddPoint(HANDLE Handle, int Axis, double Point, double Rate,
ACSC_WAITBLOCK* Wait)
Arguments
If the motion was activated by the acsc_MultiPoint function with the ACSC_AMF_
VELOCITY flag, this parameter defines the motion velocity.
Rate If the motion was activated by the acsc_Spline function with the ACSC_AMF_
VARTIME flag, this parameter defines the time interval between the previous point
and the present one.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function adds a point to a single-axis multi-point motion with specific velocity or to single-axis
spline motion with a non-uniform time.
To add a point to a multi-axis motion, use acsc_ExtAddPointM. To add a point to a motion with
default velocity or uniform time interval, the acsc_AddPoint and acsc_AddPointM functions are
more convenient.
The function can wait for the controller response or can return immediately as specified by the
Wait argument.
The controller response indicates that the command was accepted and the point is added to the
motion buffer. The point can be rejected if the motion buffer is full. In this case, you can call this
function periodically until the function returns a non-zero value.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.24.4 acsc_ExtAddPointM
Description
The function adds a point to a multi-axis multi-point or spline motion and specifies a specific
velocity or motion time.
Syntax
int acsc_ExtAddPointM(HANDLE Handle, int* Axes, double* Point, double Rate,
ACSC_WAITBLOCK* Wait)
Arguments
Array of axis constants. Each element specifies one involved axis: ACSC_AXIS_0
corresponds to axis 0, ACSC_AXIS_1 to axis 1, etc. After the last axis, one additional
Axes element must be located that contains –1 which marks the end of the array.
For the axis constants see Axis Definitions.
Array of the coordinates of added point. The number and order of values must
Point correspond to the Axes array. The Point must specify a value for each element of
Axes except the last –1 element.
If the motion was activated by the acsc_MultiPoint function with the ACSC_AMF_
VELOCITY flag, this parameter defines as motion velocity.
Rate If the motion was activated by the acsc_Spline function with the ACSC_AMF_
VARTIME flag, this parameter defines as time interval between the previous point
and the present one.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function adds a point to a multi-axis multi-point or spline motion. To add a point to a single-axis
motion, use acsc_ExtAddPoint. To add a point to a motion with a default velocity or a uniform time
interval, the acsc_ExtAddPointM function is more convenient.
The function can wait for the controller response or can return immediately as specified by the
Wait argument.
The controller response indicates that the command was accepted and the point is added to the
motion buffer. The point can be rejected if the motion buffer is full. In this case, you can call this
function periodically until the function returns non-zero value.
All axes specified in the Axes array must be specified before the call of the acsc_MultiPointM or
acsc_SplineM function. The number and order of the axes in the Axes array must correspond
exactly to the number and order of the axes of acsc_MultiPointM or acsc_SplineM functions.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.24.5 acsc_EndSequence
Description
The function informs the controller, that no more points will be specified for the current single-axis
motion.
Syntax
int acsc_EndSequence(HANDLE Handle, int Axis, ACSC_WAITBLOCK* Wait)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The motion finishes when the acsc_EndSequence function is executed. If the call of acsc_
EndSequence is omitted, the motion will stop at the last point of the sequence and wait for the
next point. No transition to the next motion in the motion queue will occur until the acsc_
EndSequence function executes.
The function can wait for the controller response or can return immediately as specified by the
Wait argument.
This function applies to the single-axis multi-point or spline (arbitrary path) motions.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
}
// end of the multi-point motion
if (!acsc_EndSequence( Handle, // communication handle
ACSC_AXIS_0, // axis 0
NULL // waiting call
))
{
printf("transaction error: %d\n", acsc_GetLastError());
}
4.24.6 acsc_EndSequenceM
Description
The function informs the controller, that no more points or segments will be specified for the
current multi-axis motion.
Syntax
int acsc_EndSequence(HANDLE Handle, int* Axes, ACSC_WAITBLOCK* Wait)
Arguments
Array of axis constants. Each element specifies one involved axis: ACSC_AXIS_0
corresponds to axis 0, ACSC_AXIS_1 to axis 1, etc. After the last axis, one additional
Axes element must be located that contains –1 which marks the end of the array.
For the axis constants see Axis Definitions.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The motion finishes when the acsc_EndSequenceM function is executed. If the call of acsc_
EndSequenceM is omitted, the motion will stop at the last point or segment of the sequence and
wait for the next point. No transition to the next motion in the motion queue will occur until the
acsc_EndSequenceM function executes.
The function can wait for the controller response or can return immediately as specified by the
Wait argument.
This function applies to the multi-axis multi-point, spline (arbitrary path) and segmented motions.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
Function Description
4.25.1 acsc_DataCollectionExt
Description
The function initiates data collection.
Syntax
int acsc_DataCollectionExt(HANDLE Handle, int Flags, int Axis, char*
Array, int NSample,double Period, char* Vars, ACSC_WAITBLOCK* Wait)
Arguments
Bit-mapped parameter that can include one or more of the following flags:
ACSC_DCF_SYNC: Start data collection synchronously to a motion.
ACSC_DCF_WAIT: Create the synchronous data collection, but do not start until
the acsc_Go function is called. This flag can only be used with the ACSC_DCF_SYNC
flag.
Flags
ACSC_DCF_TEMPORAL: Temporal data collection, the sampling period is calculated
automatically according to the collection time.
ACSC_DCF_CYCLIC: Cyclic data collection uses the collection array as a cyclic buffer
and continues indefinitely. When the array is full, each new sample overwrites
the oldest sample in the array.
Axis constant of the axis to which the data collection must be synchronized. The
Axis parameter is required only for axis data collection (ACSC_DCF_SYNC flag).
For the axis constants see Axis Definitions
Pointer to the null-terminated string contained the name of the array that stores
the collected samples.
Array
The array must be declared as a global variable by an ACSPL+ program or by the
acsc_DeclareVariable function.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
Data collection started by this function without the ACSC_DCF_SYNC flag is called system data
collection. Data collection started with the ACSC_DCF_SYNC flag is called axis data collection. Data
collection started with the ACSC_DCF_CYCLIC flag is called cyclic data collection. Unlike the standard
data collection that finishes when the collection array is full, cyclic data collection does not self-
terminate. Cyclic data collection uses the collection array as a cyclic buffer and can continue to
collect data indefinitely. When the array is full, each new sample overwrites the oldest sample in
the array. Cyclic data collection can only be terminated by calling acsc_StopCollect function.
The array that stores the samples can be one or two-dimensional. A one-dimensional array is
allowed only if the variable list contains one variable name.
The number of the array rows must be equal to or more than the number of variables in the
variable list. The number of the array columns must be equal to or more than the number of
samples specified by the NSample argument.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.25.2 acsc_StopCollect
Description
The function terminates data collection.
Syntax
int acsc_StopCollect(HANDLE Handle, ACSC_WAITBLOCK* Wait)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The usual system data collection finishes when the required number of samples is collected or the
acsc_StopCollect function is executed. The application can wait for data collection end with the
acsc_WaitCollectEndExt function.
The temporal data collection runs until the acsc_StopCollect function is executed.
The function terminates the data collection prematurely. The application can determine the
number of actually collected samples from the S_DCN variable and the actual sampling period from
the S_DCP variable.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.25.3 acsc_WaitCollectEndExt
Description
The function waits for the end of data collection.
Syntax
Int acsc_WaitCollectEndExt(HANDLE handle, int Timeout, int Axis)
Arguments
Timeout Maximum wait time in milliseconds, If INFINITE - timeout interval never elapses
Return Value
If the function succeeds, a non-zero value is returned.
If the function fails, the return value is zero.
Comments
If using Axis data collection (data collection is synced to axis) set Axis to be the axis number you are
collecting data from, otherwise set Axis to be ACSC_NONE.
The function does not return while data collection is in progress and the correct parameters have
been passed.
Verifies AST<Axis#>.#DC flag for Synced data collection, otherwise verifies S_ST.#DC system flag.
Using the function with the wrong parameters (i.e. calling the function with an axis number while
performing a system data collection) will result in undefined behavior.
Example
Function Description
acsc_GetIndexState Retrieves the current state of the index and mark variables.
4.26.1 acsc_GetMotorState
Description
The function retrieves the current motor state.
Syntax
int acsc_GetMotorState(HANDLE Handle, int Axis, int* State,
ACSC_WAITBLOCK* Wait)
Arguments
Pointer to a variable that receives the current motor state. The parameter can
include one or more of the following flags:
ACSC_MST_ENABLE — a motor is enabled
State
ACSC_MST_INPOS — a motor has reached a target position
ACSC_MST_MOVE — a motor is moving
ACSC_MST_ACC — a motor is accelerating
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function retrieves the current motor state.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
State and Wait items until a call to the acsc_WaitForAsyncCall function.
Example
{
printf("transaction error: %d\n", acsc_GetLastError());
}
4.26.2 acsc_GetAxisState
Description
The function retrieves the current axis state.
Syntax
int acsc_GetAxisState(HANDLE Handle, int Axis, int* State,
ACSC_WAITBLOCK* Wait)
Arguments
Pointer to a variable that receives the current axis state. The parameter can
include one or more of the following flags:
ACSC_AST_LEAD – an axis is leading in a group
ACSC_AST_DC – an axis data collection is in progress
ACSC_AST_PEG – a PEG for the specified axis is in progress
ACSC_AST_MOVE – an axis is moving
State
ACSC_AST_ACC – an axis is accelerating
ACSC_AST_SEGMENT – a construction of segmented motion for the specified axis is
in progress
ACSC_AST_VELLOCK – a slave motion for the specified axis is synchronized to
master in velocity lock mode
ACSC_AST_POSLOCK - a slave motion for the specified axis is synchronized to
master in position lock mode
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function retrieves the current axis state.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
State and Wait items until a call to the acsc_WaitForAsyncCall function.
Example
4.26.3 acsc_GetIndexState
Description
The function retrieves the current set of bits that indicate the index and mark state.
Syntax
int acsc_GetIndexState(HANDLE Handle, int Axis, int* State,
ACSC_WAITBLOCK* Wait)
Arguments
Pointer to a variable that receives the current set of bits that indicate the index
and mark state. The parameter can include one or more of the following flags:
ACSC_IST_IND – a primary encoder index of the specified axis is latched
State
ACSC_IST_IND2 – a secondary encoder index of the specified axis is latched
ACSC_IST_MARK – a MARK1 signal has been generated and position of the specified
axis was latched
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function retrieves the current set of bits that indicate the index and mark state.
The controller processes index/mark signals as follows:
When an index/mark signal is encountered for the first time, the controller latches feedback
positions and raises the corresponding bit. As long as a bit is raised, the controller does not latch
feedback position even if the signal occurs again. To resume latching logic, the application must call
the acsc_ResetIndexState function to explicitly reset the corresponding bit.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
State and Wait items until a call to the acsc_WaitForAsyncCall function.
Example
4.26.4 acsc_ResetIndexState
Description
The function resets the specified bit of the index/mark state.
Syntax
int acsc_ResetIndexState(HANDLE Handle, int Axis, int Mask,
ACSC_WAITBLOCK* Wait)
Arguments
The parameter contains bit to be cleared. Only one of the following flags can be
specified:
Mask
ACSC_IST_IND – a primary encoder index of the specified axis is latched
ACSC_IST_IND2 – a secondary encoder index of the specified axis is latched
ACSC_IST_MARK – a MARK1 signal has been generated and position of the specified
axis was latched
Mask
ACSC_IST_MARK2 – a MARK2 signal has been generated and position of the
specified axis was latched
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function resets the specified bit of the index/mark state. The parameter Mask contains a bit,
which must be cleared, i.e. the function resets only that bit of the index/mark state, which
corresponds to non-zero bit of the parameter Mask. To get the current index/mark state, use acsc_
GetIndexState function.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.26.5 acsc_GetProgramState
Description
The function retrieves the current state of the program buffer.
Syntax
int acsc_GetProgramState(HANDLE Handle, int Buffer, int* State,
ACSC_WAITBLOCK* Wait)
Arguments
Pointer to a variable that receives the current state of the program buffer. The
parameter can include one or more of the following flags:
ACSC_PST_COMPILED – a program in the specified buffer is compiled
ACSC_PST_RUN – a program in the specified buffer is running
State ACSC_PST_AUTO – an auto routine in the specified buffer is running
ACSC_PST_DEBUG – a program in the specified buffer is executed in debug mode,
i.e. breakpoints are active
ACSC_PST_SUSPEND – a program in the specified buffer is suspended after the
step execution or due to breakpoint in debug mode
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function retrieves the current state of the program buffer.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
State and Wait items until a call to the acsc_WaitForAsyncCall function.
Example
Function Description
acsc_GetInputPort Retrieves the current state of the specified digital input port.
acsc_GetInputPort Retrieves the current state of the specified digital input port.
acsc_GetOutputPort Retrieves the current state of the specified digital output port.
Function Description
acsc_SetOutputPort Sets the specified digital output port to the specified value.
acsc_ Retrieves the current value of the specified analog input signal from
GetAnalogInputNT an external source such as a sensor or a potentiometer.
acsc_ Retrieves the current value of the specified analog output signal that
GetAnalogOutputNT is sent to an external device such as a sensor or a potentiometer.
acsc_ Writes the specified value to the specified analog output signal that is
SetAnalogOutputNT sent to an external device such as a sensor or a potentiometer.
acsc_
Retrieves the current state of the specified extended input port.
GetExtInputPort
acsc_
Retrieves the current state of the specified extended output port.
GetExtOutputPort
acsc_
Sets the specified extended output port to the specified value.
SetExtOutputPort
4.27.1 acsc_GetInput
Description
The function retrieves the current state of the specified digital input.
Syntax
int acsc_GetInput(HANDLE Handle, int Port, int Bit, int* Value,
ACSC_WAITBLOCK* Wait)
Arguments
Pointer to a variable that receives the current state of the specific input. The value
Value
will be populated by 0 or 1.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function retrieves the current state of the specified digital input. To get values of all inputs of
the specific port, use the acsc_GetInputPort function.
Digital inputs are represented in the controller variable IN. For more information about digital
inputs, see the SPiiPlus ACSPL+ Programmer’s Guide.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Value and Wait items until a call to the acsc_WaitForAsyncCall function.
Example
4.27.2 acsc_GetInputPort
Description
The function retrieves the current state of the specified digital input port.
Syntax
int acsc_GetInputPort(HANDLE Handle, int Port, int* Value,
ACSC_WAITBLOCK* Wait)
Arguments
Value Pointer to a variable that receives the current state of the specific input port.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function retrieves the current state of the specified digital input port. To get the value of the
specific input of the specific port, use the acsc_GetInput function.
Digital inputs are represented in the controller variable IN. For more information about digital
inputs, see the SPiiPlus ACSPL+ Programmer’s Guide.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Value and Wait items until a call to the acsc_WaitForAsyncCall function.
Example
4.27.3 acsc_GetOutput
Description
The function retrieves the current state of the specified digital output.
Syntax
int acsc_GetOutput(HANDLE Handle, int Port, int Bit, int* Value,
ACSC_WAITBLOCK* Wait)
Arguments
Pointer to a variable that receives the current state of the specific output. The
Value
value will be populated by 0 or 1.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function retrieves the current state of the specified digital output. To get values of all outputs
of the specific port, use the acsc_GetOutputPort function.
Digital outputs are represented in the controller variable OUT. For more information about digital
outputs, see the SPiiPlus ACSPL+ Programmer’s Guide.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Value and Wait items until a call to the acsc_WaitForAsyncCall function.
Example
4.27.4 acsc_GetOutputPort
Description
The function retrieves the current state of the specified digital output port.
Syntax
int acsc_GetOutputPort(HANDLE Handle, int Port, int* Value,
ACSC_WAITBLOCK* Wait)
Arguments
Pointer to a variable that receives the current state of the specific output. The
Value
value will be populated by 0 or 1.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function retrieves the current state of the specified digital output port. To get the value of the
specific output of the specific port, use the acsc_GetOutput function.
Digital outputs are represented in the controller variable OUT. For more information about digital
outputs, see SPiiPlus ACSPL+ Programmer’s Guide.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Value and Wait items until a call to the acsc_WaitForAsyncCall function.
Example
4.27.5 acsc_SetOutput
Description
The function sets the specified digital output to the specified value.
Syntax
int acsc_SetOutput(HANDLE Handle, int Port, int Bit, int Value,
ACSC_WAITBLOCK* Wait)
Arguments
The value to be written to the specified output. Any non-zero value is interpreted
Value
as 1.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function sets the specified digital output to the specified value. To set values of all outputs of a
specific port, use the acsc_SetExtOutputPort function.
Digital outputs are represented in the controller variable OUT. For more information about digital
outputs, see the SPiiPlus ACSPL+ Programmer’s Guide.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.27.6 acsc_SetOutputPort
Description
The function sets the specified digital output port to the specified value.
Syntax
int acsc_SetOutputPort(HANDLE Handle, int Port, int Value,
ACSC_WAITBLOCK* Wait)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function sets the specified digital output port to the specified value. To set the value of the
specific output of the specific port, use the acsc_SetOutput function.
Digital outputs are represented in the controller variable OUT. For more information about digital
outputs, see the SPiiPlus ACSPL+ Programmer’s Guide.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.27.7 acsc_GetAnalogInputNT
Description
The function retrieves the current value of the specified analog input signal from an external
source such as a sensor or a potentiometer.
Syntax
int _ACSCLIB_ WINAPI acsc_GetAnalogInputNT(HANDLE Handle, int Port, double* Value, ACSC_
WAITBLOCK* Wait)
Arguments
Pointer to a variable that receives current value of the specified analog input as a
Value
percentage (range is -100% to 100%) of the maximum level.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function retrieves the current value of the specified analog input signal from an external
source such as a sensor or a potentiometer.
Analog inputs are represented in the controller variable AIN. For more information about analog
inputs, see SPiiPlus ACSPL+ Programmer’s Guide.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Value and Wait items until a call to the acsc_WaitForAsyncCall function.
Example
0, // port 0
&State, // received value
NULL // waiting call
))
{
printf("acsc_GetAnalogInputNT(): Error Occurred - %d\n",
acsc_GetLastError());
}
4.27.8 acsc_GetAnalogOutputNT
Description
The function retrieves the current value of the specified analog output signal that is sent to an
external device such as a sensor or a potentiometer.
Syntax
int _ACSCLIB_ WINAPI acsc_GetAnalogOutputNT(HANDLE Handle, int Port, double* Value, ACSC_
WAITBLOCK* Wait)
Arguments
Pointer to a variable that receives current value of the specified analog output as a
Value
percentage (range is -100% to 100%) of the maximum level.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function retrieves the current value of the specified analog output signal that is sent to an
external device such as a sensor or a potentiometer. To write a value to the specific analog output,
use the acsc_SetAnalogOutputNT function.
Analog outputs are represented in the controller variable AOUT. For more information about
analog outputs, see SPiiPlus ACSPL+ Programmer’s Guide.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Value and Wait items until a call to the acsc_WaitForAsyncCall function.
Example
4.27.9 acsc_SetAnalogOutputNT
Description
The function writes the specified value to the specified analog output signal that is sent to an
external device such as a sensor or a potentiometer.
Syntax
int _ACSCLIB_ WINAPI acsc_SetAnalogOutputNT(HANDLE Handle, int Port, double Value, ACSC_
WAITBLOCK* Wait)
Arguments
The value is written to the specified analog output as a percentage (range is -100%
Value
to 100%) of the maximum level
Return Value
If the function succeeds, the return value is non-zero.
4.27.10 acsc_GetExtInput
Description
The function retrieves the current state of the specified extended input.
Syntax
int acsc_GetExtInput(HANDLE Handle, int Port, int Bit, int* Value,
ACSC_WAITBLOCK* Wait)
Arguments
Pointer to a variable that receives the current state of the specific input. The value
Value
will be populated by 0 or 1.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function retrieves the current state of the specified extended input. To get values of all inputs
of the specific extended port, use the acsc_GetExtInputPort function.
Extended inputs are represented in the controller variable EXTIN. For more information about
extended inputs, see SPiiPlus ACSPL+ Programmer’s Guide.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Value and Wait items until a call to the acsc_WaitForAsyncCall function.
Example
4.27.11 acsc_GetExtInputPort
Description
The function retrieves the current state of the specified extended input port.
Syntax
int acsc_GetExtInputPort(HANDLE Handle, int Port, int* Value,
ACSC_WAITBLOCK* Wait)
Arguments
Value Pointer to a variable that receives the current state of the specific input port.
Return Value
If the function succeeds, the return value is non-zero. If the function fails, the return value is zero.
Comments
The function retrieves the current state of the specified extended input port. To get the value of
the specific input of the specific extended port, use the acsc_GetExtInput function.
Extended inputs are represented in the controller variable EXTIN. For more information about
extended inputs, see SPiiPlus ACSPL+ Programmer’s Guide.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Value and Wait items until a call to the acsc_WaitForAsyncCall function.
Example
4.27.12 acsc_GetExtOutput
Description
The function retrieves the current state of the specified extended output.
Syntax
int acsc_GetExtOutput(HANDLE Handle, int Port, int Bit, int* Value,
ACSC_WAITBLOCK* Wait)
Arguments
Pointer to a variable that receives the current state of the specific output. The
Value
value will be populated by 0 or 1.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function retrieves the current state of the specified extended output. To get values of all
outputs of the specific extended port, use the acsc_GetExtOutputPort function.
Extended outputs are represented in the controller variable EXTOUT. For more information about
extended outputs, see SPiiPlus ACSPL+ Programmer’s Guide.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Value and Wait items until a call to the acsc_WaitForAsyncCall function.
Example
4.27.13 acsc_GetExtOutputPort
Description
The function retrieves the current state of the specified extended output port.
Syntax
int acsc_GetExtOutputPort(HANDLE Handle, int Port, int* Value,
ACSC_WAITBLOCK* Wait)
Arguments
Pointer to a variable that receives the current state of the specific output. The
Value
value will be populated by 0 or 1.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function retrieves the current state of the specified extended output port. To get the value of
the specific output of the specific extended port, use the acsc_GetExtOutputPort function.
Extended outputs are represented in the controller variable EXTOUT. For more information about
extended outputs, see SPiiPlus ACSPL+ Programmer’s Guide.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Value and Wait items until a call to the acsc_WaitForAsyncCall function.
Example
4.27.14 acsc_SetExtOutput
Description
The function sets the specified extended output to the specified value.
Syntax
int acsc_SetExtOutput(HANDLE Handle, int Port, int Bit, int Value,
ACSC_WAITBLOCK* Wait)
Arguments
The value to be written to the specified output. Any non-zero value is interpreted
Value
as 1.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function sets the specified extended output to the specified value. To set values of all outputs
of the specific extended port, use the acsc_SetExtOutputPort function.
Extended outputs are represented in the controller EXTOUT variable. For more information about
extended outputs, see the SPiiPlus ACSPL+ Programmer’s Guide.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.27.15 acsc_SetExtOutputPort
Description
The function sets the specified extended output port to the specified value.
Syntax
int acsc_SetExtOutputPort(HANDLE Handle, int Port, int Value,
ACSC_WAITBLOCK* Wait)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function sets the specified extended output port to the specified value. To set the value of the
specific output of the specific extended port, use the acsc_SetExtOutput function.
Extended outputs are represented in the controller variable EXTOUT. For more information about
extended outputs, see the SPiiPlus ACSPL+ Programmer’s Guide.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
Function Description
acsc_GetFault Retrieves the set of bits that indicate the motor or system faults.
acsc_ Sets the mask that defines for which motor or system faults the
SetResponseMask controller provides default response.
acsc_ Retrieves the mask that defines for which motor or system faults
GetResponseMask the controller provides default response.
acsc_
Retrieves the current state of the specified safety input port.
GetSafetyInputPort
acsc_ Retrieves the set of bits that define inversion for the specified
GetSafetyInputPortInv safety input port.
acsc_ Sets the set of bits that define inversion for the specified safety
SetSafetyInputPortInv input port.
The function clears the current faults and results of previous faults
acsc_FaultClear
stored in the MERR variable.
The function clears the current faults and results of previous faults
acsc_FaultClearM
stored in the MERR variable for multiple axis.
4.28.1 acsc_GetFault
Description
The function retrieves the set of bits that indicate the motor or system faults.
Syntax
int acsc_GetFault(HANDLE Handle, int Axis, int* Fault, ACSC_WAITBLOCK* Wait)
Arguments
The axis constant specifying the axis (ACSC_AXIS_0 corresponds to axis 0, ACSC_
AXIS_1 to axis 1, etc.) to receive the motor faults or ACSC_NONE to receive the
Axis system faults.
For the axis constants see Axis Definitions.
Fault Pointer to the variable that receives the current set of fault bits.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function retrieves the set of bits that indicate motor or system faults.
Motor faults are related to a specific motor, the power amplifier, and the Servo processor. For
example: Position Error, Encoder Error, or Driver Alarm.
System faults are not related to any specific motor. For example: Emergency Stop or Memory Fault.
The parameter Fault receives the set of bits that indicates the controller faults. To recognize the
specific fault, constants ACSC_SAFETY_*** can be used. See Safety Control Masks for a detailed
description of these constants.
For more information about the controller faults, see the SPiiPlus ACSPL+ Programmer’s Guide.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Fault and Wait items until a call to the acsc_WaitForAsyncCall function.
Example
4.28.2 acsc_SetFaultMask
Description
The function sets the mask that enables or disables the examination and processing of controller
faults.
Syntax
int acsc_SetFaultMask(HANDLE Handle, int Axis, int Mask,
ACSC_WAITBLOCK* Wait)
Certain controller faults provide protection against potential serious bodily injury and
damage to the equipment. Be aware of the implications before disabling any alarm,
limit, or error.
Arguments
The axis constant specifying the axis (ACSC_AXIS_0 corresponds to axis 0, ACSC_
AXIS_1 to axis 1, etc.) to mask the motor faults, or ACSC_NONE to mask the system
Axis faults.
For the axis constants see Axis Definitions.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function sets the mask that enables/disables the examination and processing of the controller
faults. The two types of controller faults are motor faults and system faults.
The motor faults are related to a specific motor, the power amplifier or the Servo processor. For
example: Position Error, Encoder Error or Driver Alarm.
The system faults are not related to any specific motor. For example: Emergency Stop or Memory
Fault.
For more information about the controller faults, see the SPiiPlus ACSPL+ Programmer’s Guide.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.28.3 acsc_GetFaultMask
Description
The function retrieves the mask that defines which controller faults are examined and processed.
Syntax
int acsc_GetFaultMask(HANDLE Handle, int Axis, int* Mask,
ACSC_WAITBLOCK* Wait)
Arguments
The axis constant specifying the axis (ACSC_AXIS_0 corresponds to axis 0, ACSC_
AXIS_1 to axis 1, etc.) to get the motor faults mask, or ACSC_NONE to get the system
Axis faults mask.
For the axis constants see Axis Definitions.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function retrieves the mask, defining which controller faults are examined and processed. If a
bit of the parameter Mask is zero, the corresponding fault is disabled.
The controller faults are of two types: motor faults and system faults.
The motor faults are related to a specific motor, the power amplifier or the Servo processor. For
example: Position Error, Encoder Error or Driver Alarm.
The system faults are not related to any specific motor, for example: Emergency Stop or Memory
Fault.
For more information about the controller faults, see the SPiiPlus ACSPL+ Programmer’s Guide.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Mask and Wait items until a call to the acsc_WaitForAsyncCall function.
Example
4.28.4 acsc_EnableFault
Description
The function enables the specified motor or system fault.
Syntax
int acsc_EnableFault(HANDLE Handle, int Axis, int Fault,
ACSC_WAITBLOCK* Wait)
Arguments
The axis constant specifying the axis (ACSC_AXIS_0 corresponds to axis 0, ACSC_
AXIS_1 to axis 1, etc.) to enable the motor fault or ACSC_NONE to enable the system
Axis fault.
For the axis constants see Axis Definitions.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function enables the examination and processing of the specified motor or system fault by
setting the specified bit of the fault mask to one.
The motor faults are related to a specific motor, the power amplifier, and the Servo processor. For
example: Position Error, Encoder Error, and Driver Alarm.
The system faults are not related to any specific motor. For example: Emergency Stop, Memory
Fault.
For more information about the controller faults, see SPiiPlus ACSPL+ Programmer’s Guide.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.28.5 acsc_DisableFault
Description
The function disables the specified motor or system fault.
Syntax
int acsc_DisableFault(HANDLE Handle, int Axis, int Fault,
ACSC_WAITBLOCK* Wait)
Certain controller faults provide protection against potential serious bodily injury and
damage to the equipment. Be aware of the implications before disabling any alarm,
limit, or error.
Arguments
The axis constant specifying the axis (ACSC_AXIS_0 corresponds to axis 0, ACSC_
AXIS_1 to axis 1, etc.) to disable the motor faults or ACSC_NONE to disable the
Axis system faults.
For the axis constants see Axis Definitions.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function disables the examination and processing of the specified motor or system fault by
setting the specified bit of the fault mask to zero.
The motor faults are related to a specific motor, the power amplifier, and the Servo processor. For
example: Position Error, Encoder Error, and Driver Alarm.
The system faults are not related to any specific motor, for example: Emergency Stop, Memory
Fault.
For more information about the controller faults, see SPiiPlus ACSPL+ Programmer’s Guide.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.28.6 acsc_SetResponseMask
Description
The function retrieves the mask that defines the motor or the system faults for which the
controller provides the default response.
Syntax
int acsc_SetResponseMask(HANDLE Handle, int Axis, int Mask,
ACSC_WAITBLOCK* Wait)
Certain controller faults provide protection against potential serious bodily injury and
damage to the equipment. Be aware of the implications before disabling any alarm,
limit, or error.
Arguments
The axis constant specifying the axis (ACSC_AXIS_0 corresponds to axis 0, ACSC_
AXIS_1 to axis 1, etc.) to set the mask of responses to the motor faults, or ACSC_
Axis NONE to set the mask of responses to the system faults.
For the axis constants see Axis Definitions.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function retrieves the mask that defines the motor or the system faults for which the
controller provides the default response.
The default response is a controller-predefined action for the corresponding fault. For more
information about the controller faults and default responses, see the SPiiPlus ACSPL+
Programmer’s Guide.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.28.7 acsc_GetResponseMask
Description
The function retrieves the mask that defines the motor or the system faults for which the
controller provides the default response.
Syntax
int acsc_GetResponseMask(HANDLE Handle, int Axis, int* Mask,
ACSC_WAITBLOCK* Wait)
Arguments
The axis constant specifying the axis (ACSC_AXIS_0 corresponds to axis 0, ACSC_
AXIS_1 to axis 1, etc.) to get the mask of responses to the motor faults, or ACSC_
Axis NONE to get the mask of responses to the system faults.
For the axis constants see Axis Definitions.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function retrieves the mask that defines the motor or the system faults for which the
controller provides the default response. If a bit of the parameter Mask is zero, the controller does
not provide a default response to the corresponding fault.
The default response is a controller-predefined action for the corresponding fault. For more
information about the controller faults and default, responses see the SPiiPlus ACSPL+
Programmer’s Guide.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Mask and Wait items until a call to the acsc_WaitForAsyncCall function.
Example
4.28.8 acsc_EnableResponse
Description
The function enables the response to the specified motor or system fault.
Syntax
int acsc_EnableResponse(HANDLE Handle, int Axis, int Response,
ACSC_WAITBLOCK* Wait)
Arguments
The axis constant specifying the axis (ACSC_AXIS_0 corresponds to axis 0, ACSC_
AXIS_1 to axis 1, etc.) to enable the response to the specified motor fault, or
Axis ACSC_NONE to enable the response to the specified system fault.
For the axis constants see Axis Definitions.
The default response to be enabled. Only one default response can be enabled
at a time.
Response
To specify the default response, one of the constants ACSC_SAFETY_*** can be
used. See Safety Control Masks for a detailed description of these constants.
Return Value
If the function succeeds, the return value is non-zero.
Comments
The function enables the default response to the specified motor or system fault by setting the
specified bit of the response mask to one.
The default response is a controller-predefined action for the corresponding fault. For more
information about the controller faults and default responses, see SPiiPlus ACSPL+ Programmer’s
Guide.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.28.9 acsc_DisableResponse
Description
The function disables the default response to the specified motor or system fault.
Syntax
int acsc_DisableResponse(HANDLE Handle, int Axis, int Response,
ACSC_WAITBLOCK* Wait)
Certain controller faults provide protection against potential serious bodily injury and
damage to the equipment. Be aware of the implications before disabling any alarm,
limit, or error.
Arguments
The axis constant specifying the axis (ACSC_AXIS_0 corresponds to axis 0, ACSC_
AXIS_1 to axis 1, etc.) to disable the default response to the specified motor
Axis fault, or ACSC_NONE to disable response to the specified system fault.
For the axis constants see Axis Definitions.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function disables the default response to the specified motor or system fault by setting the
specified bit of the response mask to zero.
The default response is a controller-predefined action for the corresponding fault. For more
information about the controller faults and default responses, see SPiiPlus ACSPL+ Programmer’s
Guide.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.28.10 acsc_GetSafetyInput
Description
The function retrieves the current state of the specified safety input.
Syntax
int acsc_GetSafetyInput(HANDLE Handle, int Axis, int Input, int* Value,
ACSC_WAITBLOCK* Wait)
Arguments
The axis constant specifying the axis (ACSC_AXIS_0 corresponds to axis 0, ACSC_
AXIS_1 to axis 1, etc.) to get the specified safety motor input, or ACSC_NONE to get
Axis the specified system safety input.
For the axis constants see Axis Definitions.
Input ACSC_SAFETY_RL2
ACSC_SAFETY_LL2
ACSC_SAFETY_HOT
ACSC_SAFETY_DRIVE
ACSC_SAFETY_ES
See Safety Control Masks for a detailed description of these constants.
Pointer to a variable that receives the current state of the specified inputs. The
Value value will be populated by 0 or 1. The value will receive 1 if any of the specified
safety inputs in the Input field is on. Otherwise, it receives 0.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function retrieves the current state of the specified safety input. To get values of all safety
inputs of the specific axis, use the acsc_GetSafetyInput function.
Safety inputs are represented in the controller variables SAFIN and S_SAFIN. For more information
about safety inputs, see SPiiPlus ACSPL+ Programmer’s Guide.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Value and Wait items until a call to the acsc_WaitForAsyncCall function.
Some safety inputs can be unavailable in a specific controller model. For example,
SPiiPlus SA controller does not provide Motor Overheat, Preliminary Left Limit, and
Preliminary Right Limit safety inputs.
See specific model documentation for details.
Example
4.28.11 acsc_GetSafetyInputPort
Description
The function retrieves the current state of the specified safety input port.
Syntax
int acsc_GetSafetyInputPort(HANDLE Handle, int Axis, int* Value,
ACSC_WAITBLOCK* Wait)
Arguments
The axis constant specifying the axis (ACSC_AXIS_0 corresponds to axis 0, ACSC_
AXIS_1 to axis 1, etc.) to get the specified safety motor inputs port, or ACSC_NONE
Axis to get the specified safety system inputs port.
For the axis constants see Axis Definitions.
Pointer to a variable that receives the current state of the specific safety input
port.
To recognize a specific motor safety input, only one of the following constants can
be used:
ΑCSC_SAFETY_RL
ACSC_SAFETY_LL
Value ACSC_SAFETY_RL2
ACSC_SAFETY_LL2
ACSC_SAFETY_HOT
ACSC_SAFETY_DRIVE
To recognize a specific system safety input, only ACSC_SAFETY_ES constant can be
used.
See Safety Control Masks for a detailed description of these constants.
Return Value
If the function succeeds, the return value is non-zero.
Comments
The function retrieves the current state of the specified safety input port. To get the state of the
specific safety input of a specific axis, use the acsc_GetSafetyInput function.
Safety inputs are represented in the controller variables SAFIN and S_SAFIN. For more information
about safety inputs, see SPiiPlus ACSPL+ Programmer’s Guide.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Value and Wait items until a call to the acsc_WaitForAsyncCall function.
Some safety inputs can be unavailable in a specific controller model. For example,
SPiiPlus SA controller does not provide Motor Overheat, Preliminary Left Limit, and
Preliminary Right Limit safety inputs.
See specific model documentation for details.
Example
4.28.12 acsc_GetSafetyInputPortInv
Description
The function retrieves the set of bits that define inversion for the specified safety input port.
Syntax
int acsc_GetSafetyInputPortInv(HANDLE Handle, int Axis, int* Value,
ACSC_WAITBLOCK* Wait)
Arguments
The axis constant specifying the axis (ACSC_AXIS_0 corresponds to axis 0, ACSC_
AXIS_1 to axis 1, etc.) to get the inversion for the specified safety motor inputs port,
Axis or ACSC_NONE to get the inversion for the specified safety system inputs port.
For the axis constants see Axis Definitions.
Pointer to a variable that receives the set of bits that define inversion for the
specific safety input port.
To recognize a specific bit, use the following constants:
ACSC_SAFETY_RL
ACSC_SAFETY_LL
ACSC_SAFETY_RL2
Value
ACSC_SAFETY_LL2
ACSC_SAFETY_HOT
ACSC_SAFETY_DRIVE
Use the ACSC_SAFETY_ES constant to recognize an inversion for the specific
system safety input port,.
See Safety Control Masks for a detailed description of these constants.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function retrieves the set of bits that define inversion for the specified safety input port. To set
the specific inversion for the specific safety input port, use the acsc_GetSafetyInputPortInv
function.
If a bit of the retrieved set is zero, the corresponding signal is not inverted and therefore high
voltage is considered an active state. If a bit is raised, the signal is inverted and low voltage is
considered an active state.
The inversions of safety inputs are represented in the controller variables SAFINI and S_SAFINI. For
more information about safety inputs, see the SPiiPlus ACSPL+ Programmer’s Guide.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Value and Wait items until a call to the acsc_WaitForAsyncCall function.
Some safety inputs can be unavailable in a specific controller model. For example,
SPiiPlus SA controller does not provide Motor Overheat, Preliminary Left Limit, and
Preliminary Right Limit safety inputs.
See specific model documentation for details.
Example
4.28.13 acsc_SetSafetyInputPortInv
Description
The function sets the set of bits that define inversion for the specified safety input port.
Syntax
int acsc_SetSafetyInputPortInv(HANDLE Handle, int Axis, int Value,
ACSC_WAITBLOCK* Wait)
Arguments
ACSC_SAFETY_RL, ACSC_SAFETY_LL,
ACSC_SAFETY_RL2, ACSC_SAFETY_LL2,
ACSC_SAFETY_HOT, ACSC_SAFETY_DRIVE.
To set an inversion for the specific system safety input port, use only the ACSC_
SAFETY_ES constant.
See Safety Control Masks for a detailed description of these constants.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function sets the bits that define inversion for the specified safety input port. To retrieve an
inversion for the specific safety input port, use the acsc_GetSafetyInputPortInv function.
If a bit of the set is zero, the corresponding signal will not be inverted and therefore high voltage is
considered an active state. If a bit is raised, the signal will be inverted and low voltage is considered
an active state.
The inversions of safety inputs are represented in the controller variables SAFINI and S_SAFINI. For
more information about safety, inputs see SPiiPlus ACSPL+ Programmer’s Guide.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Some safety inputs can be unavailable in a specific controller model. For example,
SPiiPlus SA controller does not provide Motor Overheat, Preliminary Left Limit, and
Preliminary Right Limit safety inputs.
See specific model documentation for details.
Example
4.28.14 acsc_FaultClear
Description
The function clears the current faults and the result of the previous fault stored in the
MERR variable.
Syntax
int acsc_FaultClear(HANDLE Handle, int Axis, ACSC_WAITBLOCK* Wait)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function clears the current faults of the specified axis and the result of the previous fault
stored in the MERR variable.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.28.15 acsc_FaultClearM
Description
The function clears the current faults and results of previous faults stored in the MERR variable for
multiple axes.
Syntax
int acsc_FaultClearM(HANDLE Handle, int *Axes, ACSC_WAITBLOCK* Wait)
Arguments
Array of axis constants. Each element specifies one involved axis: ACSC_AXIS_0
corresponds to axis 0, ACSC_AXIS_1 to axis 1, etc. After the last axis, one additional
Axes element must be located that contains –1 which marks the end of the array.
For the axis constants see Axis Definitions.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
If the reason for the fault is still active, the controller will set the fault immediately after this
command is performed. If cleared fault is Encoder Error, the feedback position is reset to zero.
Example
Function Description
acsc_WaitInput Waits for the specified state of the specified digital input.
4.29.1 acsc_WaitMotionEnd
Description
The function waits for the end of a motion.
Syntax
int acsc_WaitMotionEnd (HANDLE Handle, int Axis, int Timeout)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function does not return while the specified axis is involved in a motion, the motor has not
settled in the final position and the specified time-out interval has not elapsed.
The function differs from the acsc_WaitLogicalMotionEnd function. Examining the same motion, the
acsc_WaitMotionEnd function will return latter. The acsc_WaitLogicalMotionEnd function returns
when the generation of the motion finishes. On the other hand, the acsc_WaitMotionEnd function
returns when the generation of the motion finishes and the motor has settled in the final position.
Example
4.29.2 acsc_WaitLogicalMotionEnd
Description
The function waits for the logical end of a motion.
Syntax
int acsc_WaitLogicalMotionEnd (HANDLE Handle, int Axis, int Timeout)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function does not return while the specified axis is involved in a motion and the specified time-
out interval has not elapsed.
The function differs from the acsc_WaitMotionEnd function. Examining the same motion, the acsc_
WaitMotionEnd function will return later. The acsc_WaitLogicalMotionEnd function returns when
the generation of the motion finishes. On the other hand, the acsc_WaitMotionEnd function
returns when the generation of the motion finishes and the motor has settled in the final position.
Example
4.29.3 acsc_WaitForAsyncCall
Description
The function waits for completion of asynchronous call and retrieves a data.
Syntax
int acsc_WaitForAsyncCall(HANDLE Handle, void* Buf, int* Received,
ACSC_WAITBLOCK* Wait, int Timeout)
Arguments
Pointer to the buffer that receives controller response. This parameter must be
the same pointer that was specified for asynchronous call of SPiiPlus C function.
Buf
If the SPiiPlus C function does not accept a buffer as a parameter, Buf has to be
NULL pointer.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero. The Ret field of Wait contains the error code that the
non-waiting call caused. If Wait.Ret is zero, the call succeeded: no errors occurred.
Comments
The function waits for completion of asynchronous call, corresponds to the Wait parameter, and
retrieves controller response to the buffer pointed by Buf. The Wait and Buf must be the same
pointers passed to SPiiPlus C function when asynchronous call was initiated.
If the call of SPiiPlus C function was successful, the function retrieves controller response to the
buffer Buf. The Received parameter will contain the number of actually received characters.
If the call of SPiiPlus C function does not return a response (for example: acsc_Enable, acsc_Jog, etc.)
Buf has to be NULL.
If the call of SPiiPlus C function returned the error, the function retrieves this error code in the Ret
member of the Wait parameter.
If the SPiiPlus C function has not been completed in Timeout milliseconds, the function aborts
specified asynchronous call and returns ACSC_TIMEOUT error.
If the call of SPiiPlus C function has been aborted by the acsc_CancelOperation function, the
function returns ACSC_OPERATIONABORTED error.
Example
4.29.4 acsc_WaitProgramEnd
Description
The function waits for the program termination in the specified buffer.
Syntax
int acsc_WaitProgramEnd (HANDLE Handle, int Buffer, int Timeout)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function does not return while the ACSPL+ program in the specified buffer is in progress and
the specified time-out interval has not elapsed.
Example
4.29.5 acsc_WaitMotorEnabled
Description
The function waits for the specified state of the specified motor.
Syntax
int acsc_WaitMotorEnabled (HANDLE Handle, int Axis, int State, int Timeout)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function does not return while the specified motor is not in the desired state and the specified
time-out interval has not elapsed. The function examines the MST.#ENABLED motor flag.
Example
4.29.6 acsc_WaitInput
Description
The function waits for the specified state of digital input.
Syntax
int acsc_WaitInput (HANDLE Handle, int Port, int Bit, int State, int Timeout)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The basic configuration of the SPiiPlus PCI model provides only 16 inputs. Therefore, the Port must
be 0, and the Bit can be specified from 0 to 15.
Example
4.29.7 acsc_WaitUserCondition
Description
The function waits for the user-defined condition.
Syntax
int acsc_WaitUserCondition(HANDLE Handle,
ACSC_USER_CONDITION_FUNC UserCondition, int Timeout)
Arguments
Return Value
If the function succeeds, the return value is non-zero. If the function fails, the return value is zero.
Comments
The function calls the UserCondition function in order to determine the termination moment.
While the UserCondition function returns zero and the specified time-out interval has not elapsed,
the acsc_WaitUserCondition function calls UserCondition periodically. Once the UserCondition
function returns non-zero results, the acsc_WaitUserCondition function also returns.
The UserCondition function accepts as argument the Handle parameter, passed to the function
acsc_WaitUserCondition.
If the condition is satisfied, the UserCondition function returns 1, if it is not satisfied – 0. In case of an
error the UserCondition function returns –1.
Example
4.29.8 acsc_WaitMotorCommutated
Description
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function does not return while the specified motor is not in the desired state and the specified
time-out interval has not elapsed. The function examines the MFLAGS.#BRUSHOK flag.
Example
Function Description
acsc_
Sets the mask for the specified interrupt.
SetCallbackMask
acsc_
Retrieves the mask for the specified interrupt.
GetCallbackMask
acsc_
Sets the priority for all callback threads.
SetCallbackPriority
4.30.1 acsc_InstallCallback
Description
The function installs a user-defined callback function for the specified interrupt condition with
user-defined parameter.
Syntax
int acsc_InstallCallback(HANDLE Handle,
ACSC_USER_CALLBACK_FUNCTION Callback, void* UserParameter,
int Interrupt)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function installs a user-defined callback function Callback for the specified interrupts condition
Interrupt.
The library calls the Callback function when the specified interrupt occurs. The bit-mapped
parameter Param of the function Callback identifies for which axis/buffer/input the interrupt was
generated. See Callback Interrupt Masks for a detailed description of the parameter Param for each
interrupt.
One callback can be installed for each interrupt, for same communication channel. The library
creates a separate thread for each interrupt. Therefore, each callback function is called in a
separate thread so that the callbacks do not delay one another.
User on Callback registration defines the parameter UserParameter. It is especially useful when
several SPiiPlus cards are used. That allows setting the same function as a Callback on certain
interrupt, for all the cards. Inside that function user can see by the UserParameter, which card
caused the interrupt.
To uninstall a specific callback, call the function acsc_InstallCallback with the parameter Callback
equals to NULL and the parameter Interrupt equals the specified interrupt type. This action will
uninstall the callback for specified communication channel.
Before the PEG interrupts can be detected, the acsc_AssignPins function must be
called.
Example
4.30.2 acsc_SetCallbackMask
Description
The function sets the mask for specified callback.
Syntax
int acsc_SetCallbackMask(HANDLE Handle, int Interrupt, unsigned __int64 Mask)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function sets the bit mask for specified interrupt. To get current mask for specified interrupt,
call acsc_GetCallbackMask.
Using a mask, you can reduce the number of calls of your callback function. The callback will be
called only if the interrupt is caused by an axis/buffer/input that corresponds to non-zero bit in the
related mask.
Example
// the example shows how to configure the interrupt mask to monitor only
// specific axis
if (!acsc_SetCallbackMask(Handle, // communication handle
ACSC_INTR_PHYSICAL_MOTION_END, // specified
interrupt
ACSC_MASK_AXIS_0 // enable interrupt only for
the axis 0 ))
{
printf("transaction error: %d\n", acsc_GetLastError());
}
4.30.3 acsc_GetCallbackMask
Description
The function retrieves the mask for specified interrupt.
Syntax
int acsc_GetCallbackMask(HANDLE Handle, int Interrupt, unsigned __int64 *Mask)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function retrieves the bit mask for specified interrupt. To set the mask for specified interrupt,
use acsc_SetCallbackMask.
Example
// the example shows how to get the mask for specific interrupt
unsigned __int64 Mask;
if (!acsc_GetCallbackMask( Handle, // communication handle
ACSC_INTR_PHYSICAL_MOTION_END, // specified interrupt
&Mask // received value
))
{
printf("transaction error: %d\n", acsc_GetLastError());
}
4.30.4 acsc_SetCallbackPriority
Description
The function sets the priority for all callback threads.
The function can be used only with the PCI communication channel.
Syntax
int acsc_SetCallbackPriority(HANDLE Handle, int Priority)
Arguments
Specifies the priority value for the callback thread. This parameter can be one of
the operating system defined priority levels.
For example the Win32 API defines the following priorities:
THREAD_PRIORITY_ABOVE_NORMAL
THREAD_PRIORITY_BELOW_NORMAL
Priority THREAD_PRIORITY_HIGHEST
THREAD_PRIORITY_IDLE
THREAD_PRIORITY_LOWEST
THREAD_PRIORITY_NORMAL
THREAD_PRIORITY_TIME_CRITICAL
As default, all callback threads have a normal priority.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The operating system uses the priority level of all executable threads to determine which thread
gets the next slice of CPU time. Basically, threads are scheduled in a round-robin fashion at each
priority level, and only when there are no executable threads at a higher level does scheduling of
threads at a lower level take place.
When manipulating priorities, be very careful to ensure that a high-priority thread does not
consume all of the available CPU time. See the relevant operating system guides for details.
Example
Function Description
4.31.1 acsc_DeclareVariable
Description
The function creates the persistent global variable.
Syntax
int acsc_DeclareVariable (HANDLE Handle, int Type, char* Name,
ACSC_WAITBLOCK* Wait)
Arguments
Name Pointer to the null-terminated ASCII string contained name of the variable.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function creates the persistent global variable specified by the parameter Name of type
specified by the parameter Type. The variable can be used as any other standard or global variable.
If it is necessary to declare one or two-dimensional array, the parameter Name should also contains
the dimensional size in brackets.
The lifetime of a persistent global variable is not connected with any program buffer. The
persistent variable survives any change in the program buffers and can be erased only by the acsc_
ClearVariables function.
The function can wait for the controller response or can return immediately as specified by the
Wait argument.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.31.2 acsc_ClearVariables
Description
The function deletes all persistent global variables.
Syntax
int acsc_ClearVariables (HANDLE Handle, ACSC_WAITBLOCK* Wait)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function deletes all persistent global variables created by the acsc_DeclareVariable function.
The function can wait for the controller response or can return immediately as specified by the
Wait argument.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
Function Description
acsc_
Retrieves the firmware version of the controller.
GetFirmwareVersion
acsc_GetAxesCount The function returns the number of axes defined in the system.
4.32.1 acsc_GetFirmwareVersion
Description
The function retrieves the firmware version of the controller.
Syntax
int acsc_GetFirmwareVersion(HANDLE Handle, char* Version, int Count,
int* Received, ACSC_WAITBLOCK* Wait)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function retrieves the character string that contains the firmware version of the controller. The
function will not copy more than Count characters to the Version buffer. If the buffer is too small,
the firmware version can be truncated.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Version, Received, and Wait items until a call to the acsc_WaitForAsyncCall function.
Example
4.32.2 acsc_GetSerialNumber
Description
The function retrieves the controller serial number.
Syntax
int acsc_GetSerialNumber(HANDLE Handle, char* SerialNumber, int Count,
int* Received, ACSC_WAITBLOCK* Wait)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function retrieves the character string that contains the controller serial number. The function
will not copy more than Count characters to the SerialNumber buffer. If the buffer is too small, the
serial number can be truncated.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
SerialNumber, Received and Wait items until a call to the acsc_WaitForAsyncCall function.
Example
4.32.3 acsc_GetBuffersCount
Description
The function returns the number of available ACSPL+ programming buffers.
Syntax
int acsc_GetBuffersCount(HANDLE Handle, double *Value,
ACSC_WAITBLOCK* Wait)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Example
double Value = 0;
if (!acsc_GetBuffersCount(Handle, &Value, NULL))
{
printf("acsc_GetBuffersCount(): Error Occurred - %d\n",
acsc_GetLastError());
return;
}
4.32.4 acsc_GetAxesCount
Description
The function returns the number of available axes.
Syntax
int acsc_GetAxesCount(HANDLE Handle, double *Value, ACSC_WAITBLOCK* Wait)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Example
double Value = 0;
if (!acsc_GetAxesCount(Handle, &Value, NULL))
{
printf("acsc_GetAxesCount(): Error Occurred - %d\n",
acsc_GetLastError());
return;
}
4.32.5 acsc_GetDBufferIndex
Description
The function returns the index of the D-Buffer.
Syntax
int acsc_GetDBufferIndex(HANDLE Handle, double *Value,
ACSC_WAITBLOCK* Wait)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Example
double Value = 0;
if (!acsc_GetDBufferIndex(Handle, &Value, NULL))
{
printf("acsc_GetDBufferIndex(): Error Occurred - %d\n",
acsc_GetLastError());
return;
}
Function Description
acsc_
Retrieves the reason why the motor was disabled.
GetMotorError
acsc_ Retrieves the error code of the last program error encountered in the
GetProgramError specified buffer.
acsc_
Used to retrieve the last EtherCAT error.
GetEtherCATError
4.33.1 acsc_GetMotorError
Description
The function retrieves the reason for motor disabling.
Syntax
int acsc_GetMotorError(HANDLE Handle, int Axis, int* Error,
ACSC_WAITBLOCK* Wait)
Arguments
Error Pointer to a variable that receives the reason why the motor was disabled.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function retrieves the reason for motor disabling.
If the motor is enabled the parameter, Error is zero. If the motor was disabled, the parameter Error
contains the reason for motor disabling.
See SPiiPlus ACSPL+ Programmer’s Guide for all available motor error code descriptions.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Error and Wait items until a call to the acsc_WaitForAsyncCall function.
Example
))
{
if (Error > 0)
{
if (acsc_GetErrorString(Handle, Error, ErrorStr, 255,
&Received))
{
ErrorStr[Received] = '\0';
printf("Motor error: %d (%s)\n", Error, ErrorStr);
}
}
}
else
{
if (Error > 0)
{
if (acsc_GetErrorString(Handle, Error, ErrorStr, 255,
&Received))
{
ErrorStr[Received] = '\0';
printf("Motor error: %d (%s)\n", Error, ErrorStr);
}
}
}
else
{
printf("transaction error: %d\n", acsc_GetLastError());
}
4.33.2 acsc_GetProgramError
Description
The function retrieves the error code of the last program error encountered in the specified
buffer.
Syntax
int acsc_GetProgramError(HANDLE Handle, int Buffer, int* Error,
ACSC_WAITBLOCK* Wait)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function retrieves the error code of the last program error encountered in the specified
buffer.
If the program is running, the parameter Error is zero. If the program terminates for any reason,
the parameter Error contains the termination code.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Error and Wait items until a call to the acsc_WaitForAsyncCall function.
Example
4.33.3 acsc_GetEtherCATError
Description
The function is used to retrieve the last EtherCAT error.
Syntax
int acsc_GetEtherCATError(HANDLE Handle, int* Error,
ACSC_WAITBLOCK* Wait)
Arguments
Pointer to a variable that receives the last EtherCAT error that has occurred (see
Error
Comments).
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
Any EtherCAT error sets ECST.#OP to false and the error code is latched in the ECERR variable.The
EtherCAT errors are given in Table 4-33.
Table 4-33. EtherCAT Errors
Error Error
Remarks
Code Message
General
Appears for any unspecified EtherCAT error. In general, it rarely
6000 EtherCAT
appears.
Error
EtherCAT
6001 cable not Check that the EtherCAT connections are firmly seated.
connected
EtherCAT
master is in On start up all slaves did not succeed to initialize to full OP state.
6002
incorrect Can be caused by wrong configuration or a problem in a Slave
state
Not all
The Master has detected that at least one frame that was sent
EtherCAT
6003 has not returned. This implies a hardware problem in the cables or
frames can
Slaves.
be processed
EtherCAT
The EtherCAT-related hardware in the Master could not be
6005 initialization
initialized. Check the EtherCAT hardware.
failure
EtherCAT
cannot The bus scan could not be completed. This implies hardware level
6006
complete the problems in the EtherCAT network.
operation
Error Error
Remarks
Code Message
Not all
One or more of the Slaves has changed its state to other than OP,
EtherCAT
6008 or it may be due to a Slave restart or internal fault that internally
slaves are
forces the Slave to go to PREOP or SAFEOP.
operational
EtherCAT The Master has detected that the Slave does not behave as
6009 protocol expected for too long, and reports timeout. Implies a Slave
timeout hardware problem. Try power down, and system restart.
Slave The Master cannot initialize a Slave by the configuration file. It can
6010 initialization be caused by either wrong configuration, or a hardware problem
failed in the Slave.
Bus
6011 configuration The bus topology differs from that in configuration file.
mismatch
CoE
6012 A Slave with CoE support has reported an emergency message.
emergency
EtherCAT
Slave won't
6013 Hardware fault, for example DHD with broken (logic) supply.
enter INIT
state
Example
int Value = 0;
if (!acsc_GetEtherCATError(Handle, &Value, NULL))
{
printf("acsc_GetEtherCATError(): Error Occurred - %d\n",
acsc_GetLastError());
return;
}
Function Description
Function Description
4.34.1 acsc_ReadDPRAMInteger
Description
The function reads 32-bit integer from the DPRAM.
Syntax
acsc_ReadDPRAMInteger(HANDLE Handle, int address,int *Value)
Arguments
Address Address has to be even number from 128 to 1020 (DRAM size is 1024)
Return Value
The function returns non-zero on success.
If the value cannot be read, the return value is zero.
Comments
Address has to be even number in the range of 128 to 508, because we use 16-bit alignment when
working with DPRAM. Addresses less than 128 are used for internal purposes.
Example
4.34.2 acsc_WriteDPRAMInteger
Description
The function writes 32-bit integer to the DPRAM.
Syntax
acsc_WriteDPRAMInteger(HANDLE Handle, int address,int Value)
Arguments
Address Address has to be even number from 128 to 1020 (DRAM size is 1024)
Return Value
The function returns non-zero on success.
If the value cannot be written, the return value is zero.
Comments
Address has to be even number in the range of 128 to 508, because we use 16-bit alignment when
working with DPRAM. Addresses less than 128 are used for internal purposes.
Example
4.34.3 acsc_ReadDPRAMReal
Description
The function reads 64-bit Real from the DPRAM.
Syntax
acsc_ReadDPRAMReal(HANDLE Handle, int address, double *Value)
Arguments
Address Address has to be even number from 128 to 1020 (DRAM size is 1024)
Return Value
The function returns non-zero on success.
If the value cannot be read, the return value is zero.
Comments
Address has to be even number in the range of 128 to 504, because we use 16-bit alignment when
working with DPRAM. Addresses less than 128 are used for internal purposes.
Example
4.34.4 acsc_WriteDPRAMReal
Description
The function writes 64-bit Real to the DPRAM.
Syntax
acsc_WriteDPRAMReal(HANDLE Handle, int address, double Value)
Arguments
Address Address has to be even number from 128 to 1020 (DRAM size is 1024)
Return Value
The function returns non-zero on success.
If the value cannot be written, the return value is zero.
Comments
Address has to be even number in the range of 128 to 504, because we use 16-bit alignment when
working with DPRAM. Addresses less than 128 are used for internal purposes.
Example
The Shared Memory functions have been added in support of SPiiPlus SC to enable
accessing memory addresses. They cannot be used with any other SPiiPlus family
product.
Function Description
4.35.1 acsc_GetSharedMemoryAddress
Description
The function reads the address of shared memory variable.
Syntax
int acsc_GetSharedMemoryAddress(HANDLE Handle, int NBuf, char* Var,
unsigned int* Address, ACSC_WAITBLOCK* Wait)
Arguments
Number of program buffer for local variable or ACSC_NONE for global and
NBuf
standard variable.
Var Pointer to a null-terminated character string that contains a name of the variable.
Address Pointer to the variable that receives the address of specified variable.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
4.35.2 acsc_ReadSharedMemoryInteger
Description
The function reads value(s) from an integer shared memory variable.
Syntax
int acsc_ReadSharedMemoryInteger(HANDLE Handle, unsigned int Address,
int From1, int To1, int From2, int To2, int* Values)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
4.35.3 acsc_WriteSharedMemoryInteger
Description
The function writes value(s) to the integer shared memory variable.
Syntax
int acsc_WriteSharedMemoryInteger(HANDLE Handle, unsigned int Address,
int From1, int To1, int From2, int To2, int* Values)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
4.35.4 acsc_ReadSharedMemoryReal
Description
The function reads value(s) from a real shared memory variable.
Syntax
int acsc_ReadSharedMemoryReal(HANDLE Handle, unsigned int Address, int From1,
int To1, int From2, int To2, double* Values)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
4.35.5 acsc_WriteSharedMemoryReal
Description
The function writes value(s) to the real shared memory variable.
Syntax
int acsc_WriteSharedMemoryReal(HANDLE Handle, unsigned int Address, int From1,
int To1, int From2, int To2, double* Values)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
The D-Buffer should contain the definition of the relevant shared memory variable:
global real shm HELLO_VAR(2)(2)
The EtherCAT functions can be used only with the SPiiPlus family of products
Function Description
4.36.1 acsc_GetEtherCATState
Description
The function is used to retrieve the EtherCAT state.
Syntax
int acsc_GetEtherCATState(HANDLE Handle, int* State, ACSC_WAITBLOCK* Wait)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The EtherCAT state is contained in the ACSPL+ ECST variable. The EtherCAT state is reflected in the
first six bits as given in Table 4-37.
Table 4-37. ECST Bits
The scan process was performed successfully, that is, the Master was
0 #SCAN
able to detect what devices are connected to it.
All bus devices are successfully set to INIT state. The Master started
2 #INITOK
all devices to the initial state.
All bits (except #INSYNC in some cases) should be true for proper bus functioning, for
monitoring the bus state, checking bit #OP is enough. Any bus error will reset the #OP
bit.
Example
int Value = 0;
if (!acsc_GetEtherCATState(Handle, &Value, NULL))
{
printf("acsc_GetEtherCATState(): Error Occurred - %d\n",
acsc_GetLastError());
return;
}
4.36.2 acsc_MapEtherCATInput
Description
The function is used for raw mapping of network input variables of any size. Once the function is
called successfully, the firmware copies the value of the network input variable at the
corresponding EtherCAT offset into the ACSPL+ variable, every controller cycle.
The function call is legal only when the EtherCAT state is operable (that is, ECST.OP=1).
Syntax
int acsc_MapEtherCATInput(HANDLE Handle, int Flags, int Offset,
char* VariableName, ACSC_WAITBLOCK* Wait)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Example
4.36.3 acsc_MapEtherCATOutput
Description
The function is used for raw mapping of network output variables of any size. Once the function is
called successfully, the firmware copies the value of specified ACSPL+ variable into the network
output variable at the corresponding EtherCAT offset, every controller cycle.
The function call is legal only when the EtherCAT state is operable (that is, ECST.OP=1).
Syntax
int acsc_MapEtherCATOutput(HANDLE Handle, int Flags, int Offset,
char* VariableName, ACSC_WAITBLOCK* Wait)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Example
4.36.4 acsc_UnmapEtherCATInputsOutputs
Description
The function resets all previous mapping defined by acsc_MapEtherCATInput and acsc_
MapEtherCATOutput functions.
The function call is legal only when the EtherCAT state is operable (that is, ECST.OP=1).
Syntax
int acsc_UnmapEtherCATInputsOutputs(HANDLE Handle,
ACSC_WAITBLOCK* Wait)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Example
if (!acsc_UnmapEtherCATInputsOutputs(Handle, NULL))
{
printf("acsc_UnmapEtherCATInputsOutputs(): Error Occurred - %d\n",
acsc_GetLastError());
return;
}
4.36.5 acsc_GetEtherCATSlaveIndex
Description
The function returns the index of EtherCAT slave according to the parameters that are specified.
Syntax
int acsc_GetEtherCATSlaveIndex(HANDLE Handle, int VendorID, int ProductID,
int Count, int* SlaveIndex, ACSC_WAITBLOCK* Wait)
Arguments
Internal count of the device within those devices having the same Product and
Count
Vendor IDs.
SlaveIndex Pointer to a variable that receives the index of the EtherCAT slave.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Example
double SlaveIndex = 0;
if (!acsc_GetEtherCATSlaveIndex(Handle, 0x00000540, 0x02040000, 1,
&SlaveIndex, NULL))
{
printf("acsc_GetEtherCATSlaveIndex(): Error Occurred - %d\n",
acsc_GetLastError());
return;
}
4.36.6 acsc_GetEtherCATSlaveOffset
Description
The function returns offset of a network variable of the specified EtherCAT slave in EtherCAT
telegram.
Syntax
int acsc_GetEtherCATSlaveOffset(HANDLE Handle, char* VariableName,
int SlaveIndex, double* SlaveOffset, ACSC_WAITBLOCK* Wait)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Example
double Value = 0;
if (!acsc_GetEtherCATSlaveOffset(Handle, "DIGITAL_INPUTS",
(int)SlaveIndex, &Value, NULL))
{
printf("acsc_GetEtherCATSlaveOffset(): Error Occurred - %d\n",
acsc_GetLastError());
return;
}
4.36.7 acsc_GetEtherCATSlaveVendorID
Description
The function returns the Vendor ID of specified EtherCAT slave.
Syntax
int acsc_GetEtherCATSlaveVendorID(HANDLE Handle, int SlaveIndex,
double* VendorID, ACSC_WAITBLOCK* Wait)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Example
double VendorID = 0;
if (!acsc_GetEtherCATSlaveVendorID(Handle, (int)SlaveIndex, &VendorID,
NULL))
{
printf("acsc_GetEtherCATSlaveVendorID(): Error Occurred - %d\n",
acsc_GetLastError());
return;
}
4.36.8 acsc_GetEtherCATSlaveProductID
Description
The function returns the Product ID of the specified EtherCAT slave.
Syntax
int acsc_GetEtherCATSlaveProductID(HANDLE Handle, int SlaveIndex,
double* ProductID, ACSC_WAITBLOCK* Wait)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Example
double ProductID = 0;
if (!acsc_GetEtherCATSlaveProductID(Handle, (int)SlaveIndex, &ProductID,
NULL))
{
printf("acsc_GetEtherCATSlaveProductID(): Error Occurred - %d\n",
acsc_GetLastError());
return;
}
4.36.9 acsc_GetEtherCATSlaveRevision
Description
The function returns the Revision of the specified EtherCAT slave.
Syntax
int acsc_GetEtherCATSlaveRevision(HANDLE Handle,
int SlaveIndex, double* Revision, ACSC_WAITBLOCK* Wait)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Example
double Revision = 0;
if (!acsc_GetEtherCATSlaveRevision(Handle, (int)SlaveIndex, &Revision,
NULL))
{
printf("acsc_GetEtherCATSlaveRevision(): Error Occurred - %d\n",
acsc_GetLastError());
return;
}
4.36.10 acsc_GetEtherCATSlaveType
Description
The function returns the type of the specified EtherCAT slave.
Syntax
int acsc_GetEtherCATSlaveType(HANDLE Handle, int VendorID, int ProductID,
double* SlaveType, ACSC_WAITBLOCK* Wait)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Example
double Value = 0;
if (!acsc_GetEtherCATSlaveType(Handle, (int)VendorID, (int)ProductID,
&Value, NULL))
{
printf("acsc_GetEtherCATSlaveType(): Error Occurred - %d\n",
acsc_GetLastError());
return;
}
4.36.11 acsc_GetEtherCATSlaveState
Description
The function returns the EtherCAT machine state of the specified EtherCAT slave.
Syntax
int acsc_GetEtherCATSlaveState(HANDLE Handle, int SlaveIndex, double* SlaveState,
ACSC_WAITBLOCK* Wait)
Arguments
Pointer to a variable that receives the state of the specified EtherCAT slave.
1 - INIT
2 - PREOP
SlaveState
4 - SAFEOP
8 - OP
If specified slave does not exist or is not accessible, -1 is returned.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Example
double Value = 0;
if (!acsc_GetEtherCATSlaveState(Handle, (int)SlaveIndex, &Value, NULL))
{
printf("acsc_GetEtherCATSlaveState(): Error Occurred - %d\n",
acsc_GetLastError());
return;
}
Function Description
Sets the parameters for the Incremental PEG mode - for SPiiPlusNT
acsc_PegIncNT
and SPiiPlusSC controllers only.
Sets the parameters for the Random PEG mode - for SPiiPlusNT and
acsc_PegRandomNT
SPiiPlusSC controllers only.
Waits for the all values to be loaded and the PEG engine to be ready
acsc_WaitPegReady to respond to movement on the specified axis - for SPiiPlusNT and
SPiiPlusSC controllers only.
4.37.1 acsc_PegInc
Description
The function initiates incremental PEG. Incremental PEG function is defined by first point, last point
and the interval.
Syntax
int acsc_PegInc(HANDLE Handle, int Flags, int Axis, double Width, double FirstPoint,
double Interval, double LastPoint, int TbNumber, double TbPeriod,
ACSC_WAITBLOCK* Wait)
Arguments
PEG axis: ACSC_AXIS_0 corresponds to axis 0, ACSC_AXIS_1 to axis 1, etc. For the
Axis
axis constants see Axis Definitions.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function initiates incremental PEG generation. See details in ACSPL+ programmers guide. The
time-based pulse generation is optional, if it is not used, TbPeriod and TbNumber should be ACSC_
NONE.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.37.2 acsc_PegRandom
Description
The function initiates random PEG. Random PEG function specifies an array of points where
position-based events should be generated.
Syntax
int acsc_PegRandom(HANDLE Handle,int Flags,int Axis,double Width,
char* PointArray,char* StateArray,int TbNumber, double TbPeriod,
ACSC_WAITBLOCK* Wait)
Arguments
PEG axis: ACSC_AXIS_0 corresponds to axis 0, ACSC_AXIS_1 to axis 1, etc. For the
Axis
axis constants see Axis Definitions.
Null-terminated string contained the name of the real array that stores
positions at which PEG pulse should be generated
PointArray
The array must be declared as a global variable by an ACSPL+ program or by the
acsc_DeclareVariable function.
Null-terminated string contained the name of the integer array that stores
desired output state at each position.
StateArray The array must be declared as a global variable by an ACSPL+ program or by the
acsc_DeclareVariable function.
If output state change is not desired, this parameter should be NULL.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function initiates random PEG generation (see SPiiPlus ACSPL+ Programmer’s Guide).
StateArray should be NULL if output state won’t change because of PEG.
The time-based pulse generation is optional, if it is not used, TbPeriod and TbNumber should be
ACSC_NONE.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.37.3 acsc_AssignPins
Description
The function defines whether a digital output is allocated to the corresponding bit of the OUT array
(for general purpose use) or allocated for PEG function use.
Syntax
int acsc_AssignPins(HANDLE Handle,int Axis,unsigned short Mask,
ACSC_WAITBLOCK* Wait)
Arguments
PEG axis: ACSC_AXIS_0 corresponds to axis 0, ACSC_AXIS_1 to axis 1, etc. For the axis
Axis
constants see Axis Definitions.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The function calls the ACSPL command SETCONF(205, axis, Mask), where Mask is the output mask.
For a description of the output mask, see the description of SETCONF in the SPiiPlus ACSPL+
programmers guide.
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.37.4 acsc_StopPeg
Description
The function stops PEG.
Syntax
int acsc_StopPeg(HANDLE Handle,int Axis, ACSC_WAITBLOCK* Wait)
Arguments
PEG axis: ACSC_AXIS_0 corresponds to axis 0, ACSC_AXIS_1 to axis 1, etc. For the axis
Axis
constants see Axis Definitions.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
If Wait points to a valid ACSC_WAITBLOCK structure, the calling thread must not use or delete the
Wait item until a call to the acsc_WaitForAsyncCall function.
Example
4.37.5 acsc_AssignPegNT
This function can be used only with the SPiiPlus family of controllers.
Description
The function is used for engine-to-encoder assignment as well as for the additional digital outputs
assignment for use as PEG state and PEG pulse outputs.
Syntax
int acsc_AssignPegNT(HANDLE Handle, int Axis, int EngToEncBitCode,
int GpOutsBitCode, ACSC_WAITBLOCK* Wait)
Arguments
General Purpose outputs assignment to use as PEG state and PEG pulse
GpOutsBitCode outputs according to the ASSIGNPEG chapter in the PEG and MARK
Operations Application Notes.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Example
int Axis = 0;
int EngToEncBitCode = 5;
int GpOutsBitCode = 0;
if (!acsc_AssignPegNT(Handle, Axis, EngToEncBitCode, GpOutsBitCode,
NULL))
{
printf("acsc_AssignPegNT(): Error Occurred - %d\n",
acsc_GetLastError());
return;
}
4.37.6 acsc_AssignPegOutputsNT
This function can be used only with the SPiiPlus family of controllers.
Description
The function is used for setting output pins assignment and mapping between FGP_OUT signals to
the bits of the ACSPL+ OUT(x) variable, where x is the index that has been assigned to the controller
in the network during System Configuration.
OUT is an integer array that can be used for reading or writing the current state of the General
Purpose outputs - see the SPiiPlus Command & Variable Reference Guide.
Syntax
int acsc_AssignPegOutputsNT(HANDLE Handle, int Axis, int OutputIndex, int BitCode,
ACSC_WAITBLOCK* Wait)
Arguments
Bit code for engine outputs to physical outputs mapping according to the
BitCode
ASSIGNPEG chapter in the PEG and MARK Operations Application Notes.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Example
int Axis = 0;
int OutputIndex = 2;
int OutputBitCode = 1;
if (!acsc_AssignPegOutputsNT(Handle, Axis, OutputIndex, OutputBitCode,
NULL))
{
printf("acsc_AssignPegOutputsNT(): Error Occurred - %d\n",
acsc_GetLastError());
return;
}
4.37.7 acsc_AssignFastInputsNT
This function can be used only with the SPiiPlus family of controllers.
Description
The function is used to switch MARK_1 physical inputs to ACSPL+ variables as fast general purpose
inputs.
The function is not related to PEG activity. It is included for the sake of completeness,
since many times fast inputs are used in applications that use PEG functionality
The function is used for setting input pins assignment and mapping between FGP_IN signals to the
bits of the ACSPL+ IN(x) variable, where x is the index that has been assigned to the controller in
the network during System Configuration.
IN is an integer array that can be used for reading the current state of the General Purpose inputs -
see the SPiiPlus Command & Variable Reference Guide.
Syntax
int acsc_AssignFastInputsNT(HANDLE Handle, int Axis, int InputIndex, int BitCode,
ACSC_WAITBLOCK* Wait)
Arguments
PEG axis: ACSC_AXIS_0 corresponds to axis 0, ACSC_AXIS_1 to axis 1, etc. For the
Axis
axis constants see Axis Definitions..
Bit code for mapping engines inputs to physical inputs the ASSIGNPEG and
BitCode
ASSIGNPOUTS chapters in the PEG and MARK Operations Application Notes.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Example
int Axis = 0;
int InputIndex = 1;
int InputBitCode = 7;
if (!acsc_AssignFastInputsNT(Handle, Axis, InputIndex, InputBitCode,
NULL))
{
printf("acsc_AssignFastInputsNT(): Error Occurred - %d\n",
acsc_GetLastError());
return;
}
4.37.8 acsc_PegIncNT
This function can be used only with the SPiiPlus family of controllers.
Description
The function is used for setting the parameters for the Incremental PEG mode. The Incremental
PEG function is defined by first point, last point and the interval.
Syntax
int acsc_PegIncNT(HANDLE Handle, int Flags, int Axis, double Width,
double FirstPoint, double Interval, double LastPoint, int TbNumber,
double TbPeriod, ACSC_WAITBLOCK* Wait)
Arguments
Using this switch is recommended for any application that uses the PEG_I
command, regardless if interval matches the whole number of encoder counts.
ACSC_AMF_SYNCHRONOUS - PEG starts synchronously with the motion
sequence.
PEG axis: ACSC_AXIS_0 corresponds to axis 0, ACSC_AXIS_1 to axis 1, etc. For the
Axis
axis constants see Axis Definitions..
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Example
int Flags = 0;
double Width = 0.5;
double FirstPoint = 0;
double LastPoint = 10000;
double Interval = 1000;
if (!acsc_PegIncNT(Handle, Flags, Axis, Width, FirstPoint, Interval,
LastPoint, ACSC_NONE,
ACSC_NONE, NULL))
{
printf("acsc_PegIncNT(): Error Occurred - %d\n", acsc_GetLastError());
return;
}
int Timeout = 5000;
if (!acsc_WaitPegReadyNT(Handle, Axis, Timeout))
{
printf("acsc_WaitPegReadyNT(): Error Occurred - %d\n",
acsc_GetLastError());
return;
}
4.37.9 acsc_PegRandomNT
This function can be used only with the SPiiPlus family of controllers.
Description
The function is used for setting the parameters for the Random PEG mode. The Random PEG
function specifies an array of points where position-based events are to be generated.
Syntax
int acsc_PegRandomNT(HANDLE Handle, int Flags, int Axis, double Width, int Mode,
int FirstIndex, int LastIndex, char* PointArray, char* StateArray,
int TbNumber, double TbPeriod, ACSC_WAITBLOCK* Wait)
Arguments
PEG axis: ACSC_AXIS_0 corresponds to axis 0, ACSC_AXIS_1 to axis 1, etc. For the
Axis
axis constants see Axis Definitions..
Output signal configuration according to the ASSIGNPEG chapter in the PEG and
Mode
MARK Operations Application Notes..
Null-terminated string containing the name of the real array that stores
positions at which PEG pulse are to be generated
PointArray
The array must be declared as a global variable by an ACSPL+ program or by the
acsc_DeclareVariable function.
Null-terminated string containing the name of the integer array that stores
desired output state at each position.
StateArray The array must be declared as a global variable by an ACSPL+ program or by the
acsc_DeclareVariable function.
If output state change is not desired, this parameter should be NULL.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Example
int Mode = 0;
int FirstIndex = 0;
int LastIndex = 10;
if (!acsc_PegRandomNT(Handle, Flags, Axis, Width, Mode, FirstIndex,
4.37.10 acsc_WaitPegReady
This function can be used only with the SPiiPlus family of controllers.
Description
The function waits for the all values to be loaded and the PEG engine to be ready to respond to
movement on the specified axis.
The function can be used in both the Incremental and Random PEG modes.
Syntax
int acsc_WaitPegReadyNT(HANDLE Handle, int Axis, int Timeout)
Arguments
PEG axis: ACSC_AXIS_0 corresponds to axis 0, ACSC_AXIS_1 to axis 1, etc. For the
Axis
axis constants see Axis Definitions..
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Example
{
printf("acsc_WaitPegReadyNT(): Error Occurred - %d\n",
acsc_GetLastError());
return;
}
4.37.11 acsc_StartPegNT
This function can be used only with the SPiiPlus family of controllers.
Description
The function is used to initiate the PEG process.
Syntax
int acsc_StartPegNT(HANDLE Handle, int Axis, ACSC_WAITBLOCK* Wait)
Arguments
PEG axis: ACSC_AXIS_0 corresponds to axis 0, ACSC_AXIS_1 to axis 1, etc. For the axis
Axis
constants see Axis Definitions..
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
4.37.12 acsc_StopPegNT
This function can be used only with the SPiiPlus family of controllers.
Description
The function is used to terminate the PEG process immediately on the specified axis. The function
can be used in both the Incremental and Random PEG modes.
Syntax
int acsc_StopPegNT(HANDLE Handle, int Axis, ACSC_WAITBLOCK* Wait)
Arguments
PEG axis: ACSC_AXIS_0 corresponds to axis 0, ACSC_AXIS_1 to axis 1, etc. For the axis
Axis
constants see Axis Definitions..
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Example
Function Description
4.38.1 acsc_RegisterEmergencyStop
Description
The function initiates the Emergency Stop functionality for calling application.
Syntax
int acsc_RegisterEmergencyStop();
Arguments
None
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
SPiiPlus UMD (User Mode Driver) and the C Library provide the user application with the ability to
open/close the Emergency Stop button. Clicking the Emergency Stop button sends a stop
command to all motions and motors to all channels, thereby stopping all motions and disabling all
motors.
In the SPiiPlus UMD, when it has been selected, the Emergency Stop button stops all motions and
disables all motors. Previously only SPiiPlus MMI provided such functionality. Now such functionality
is also available for user applications.
Calling acsc_RegisterEmergencyStop will cause an Emergency Stop button to appear in the right
bottom corner of the computer screen. If this button is already displayed, that is, activated by
another application, a new button does not appear, but all functionality is available for the new
application. Clicking the Emergency Stop button causes the stopping of all motions and motors
command to all channels that are used in the calling application.
Calling acsc_RegisterEmergencyStop requires having the local host SPiiPlus UMD running, even if it
is used through a remote connection, because the Emergency Stop button is part of the local
SPiiPlus UMD. If the local SPiiPlus UMD is not running, the function fails.
Only a single call is required per application. It can be placed anywhere in code, even before the
opening of communication with controllers.
An application can remove the Emergency Stop button by calling acsc_UnregisterEmergencyStop.
The Emergency Stop button disappears if there are no additional registered applications using it.
Termination of SPiiPlus UMD also removes the Emergency Stop button, so restarting the SPiiPlus
UMD requires calling acsc_RegisterEmergencyStop() again.
Registering the Emergency Stop button more than once per application is meaningless, but the
function succeeds anyway. In order to ensure that the Emergency Stop button is active, it is
recommended to place a call to acsc_RegisterEmergencyStop after each call to any of
OpenComm***() functions.
Example
int OpenCommunication()
{
HANDLE Handle = OpenCommEthernet( // It can be any kind of OpenComm***
"10.0.0.100", // TCP-IP address of the controller
ACSC_SOCKET_DGRAM_PORT// point-to-point communication
);
if (Handle == ACSC_INVALID)
{
printf("error opening communication: %d\n",
acsc_GetLastError());
return 0;
}
if (!acsc_RegisterEmergencyStop())
{
printf("Registration of EStop is failed. Error is: %d\n",
acsc_GetLastError());
return 0;
}
return 1;
}
4.38.2 acsc_UnregisterEmergencyStop
Description
The function terminates the Emergency Stop functionality for the calling application.
Syntax
int acsc_UnregisterEmergencyStop();
Arguments
None
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
The SPiiPlus User Mode Driver (UMD) and C Library provide user applications with the ability to
activate or deactivate the Emergency Stop button displayed in the UMD.
Calling acsc_UnregisterEmergencyStop will cause application not to respond to the user clicking the
Emergency Stop button displayed on the screen. If there are no other applications that have
registered the Emergency Stop functionality (through the acsc_RegisterEmergencyStopfunction),
the button will disappear.
Unregistering Emergency Stop more than once per application is meaningless, but the function will
succeed anyway.
Example
int CloseCommunication()
{
if (!acsc_UnregisterEmergencyStop())
{
printf("Unregistration of EStop is failed. Error is: %d\n",
acsc_GetLastError());
return 0;
}
if (!acsc_CloseComm(Handle))
{
printf("Error closing communication: %d\n", acsc_GetLastError());
}
return 1;
}
Function Description
acsc_ Analyzes application file and returns information about the file
AnalyzeApplication components.
acsc_ Loads selected components of user application from a file on the host
LoadApplication PC and saves it in the controller’s flash memory.
Function Description
4.39.1 acsc_AnalyzeApplication
Description
The function analyzes an application file and returns information about the file’s components, such
as, saved ACSPL+ programs, configuration parameters, user files, etc.
Syntax
int acsc_AnalyzeApplication(HANDLE Handle, char* fileName,
ACSC_APPSL_INFO** info (, ACSC_WAITBLOCK* Wait))
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
If fileName is NULL, the current Controller Application will be analyzed; otherwise, the file specified
by fileName, from the local hard disk, will be analyzed.
Example
&ainfo))
printf("AnalyzeApplication error: %d\n", acsc_GetLastError());
4.39.2 acsc_LoadApplication
Description
The function loads a section of data from the host PC disk and saves it in the controller’s files.
Syntax
int acsc_LoadApplication(HANDLE Handle const char * fileName,
ACSC_APPLSL_INFO* info (, ACSC_WAITBLOCK* Wait))
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
None.
Example
4.39.3 acsc_SaveApplication
Description
The function saves a user application from the controller to a file on the host PC.
Syntax
int acsc_SaveApplication(HANDLE Handle, const char * fileName,
ACSC_APPLSL_INFO* info (, ACSC_WAITBLOCK* Wait))
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
None.
Example
4.39.4 acsc_FreeApplication
Description
The function frees memory previously allocated by the acsc_AnalyzeApplication function.
Syntax
int acsc_FreeApplication(ACSC_APPLSL_INFO* Info)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Example
Function Description
4.40.1 acsc_ControllerReboot
Description
The function reboots controller and waits for process completion.
Syntax
int acsc_ControllerReboot(HANDLE Handle, int Timeout)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
Example
hComm = acsc_OpenComm… ;
if (hComm == ACSC_INVALID)
{
printf("Error while opening communication: %d\n", acsc_GetLastError());
return -1;
}
printf ("Communication with the controller was established
successfully!\n");
if (!acsc_ControllerReboot(hComm,30000)){
printf("ControllerReboot error: %d\n", acsc_GetLastError());
return -1;
}
printf ("Controller rebooted successfully, closing communication\n");
acsc_CloseComm(hComm);
hComm = acsc_OpenComm… ; //reopen communication
if (hComm == ACSC_INVALID)
{
printf("Error while reopening communication after reboot: %d\n", acsc_
GetLastError());
return -1;
}
printf ("Communication with the controller after reboot, was established
successfully!\n");
4.40.2 acsc_ControllerFactoryDefault
Description
The function reboots controller, restores factory default settings and waits for process completion.
Syntax
int acsc_ControllerFactoryDefault(HANDLE Handle, int Timeout)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Comments
Example
hComm = acsc_OpenComm… ;
if (hComm == ACSC_INVALID)
{
printf("Error while opening communication: %d\n", acsc_GetLastError());
return -1;
}
printf ("Communication with the controller was established
successfully \n");
if (!acsc_ControllerFactoryDefault(hComm,30000)){
printf("ControllerFactoryDefault error: %d\n",
acsc_GetLastError ());
return -1;
}
printf ("Controller restarted successfully, closing communication\n");
acsc_CloseComm(hComm);
hComm = acsc_OpenComm… ; //reopen communication
if (hComm == ACSC_INVALID)
{
printf("Error while reopening communication after restart: %d\n",
acsc_GetLastError());
return -1;
}
printf ("Communication with the controller after reboot, was
established successfully!\n");
Function Description
acsc_ The function copies files from the host PC to the controller's
CopyFileToController non-volatile memory.
acsc_ The function deletes user files from the controller's non-volatile
DeleteFileFromController memory.
4.41.1 acsc_CopyFileToController
Description
The function copies file from host PC to controller’s non-volatile memory.
Syntax
int _ACSCLIB_ WINAPI acsc_CopyFileToController(HANDLE Handle,
char* SourceFileName, char* DestinationFileName,
ACSC_WAITBLOCK* Wait)
Arguments
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Example
4.41.2 acsc_DeleteFileFromController
Description
The function deletes user files from controller's non-volatile memory.
Syntax
int _ACSCLIB_ WINAPI acsc_DeleteFileFromController(HANDLE Handle, char* FileName, ACSC_
WAITBLOCK* Wait)Arguments
Pointer to the null-terminated character string that contains name of the user
FileName
file on controller's non-volatile memory
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Example
Function Description
4.42.1 acsc_ControllerSaveToFlash
Description
The function saves user application to the controller's non-volatile memory.
Syntax
int _ACSCLIB_ WINAPI acsc_ControllerSaveToFlash(HANDLE Handle, int* Parameters, int* Buffers,
int* SPPrograms, char* UserArrays)
Arguments
Array of buffer constants. Each element specifies one involved buffer: ACSC_
BUFFER_0 corresponds to buffer 0, ACSC_BUFFER_1 to buffer 1, etc.
Buffers If all buffers need to be specified, ACSC_BUFFER_ALL should be used.
After the last buffer, one additional element must be located that contains -1
which marks the end of the array.
Array of Servo Processor (SP) constants. Each element specifies one involved
SP: ACSC_SP_0 corresponds to SP 0, ACSC_SP_1 to SP 1, etc.
If all SPs need to be specified, ACSC_SP_ALL should be used.
After the last SP, one additional element must be located that contains -1
SPPrograms which marks the end of the array.
User Arrays list - Pointer to the null-terminated string. The string contains
chained names of user arrays, separated by '\r'(13) character.
UserArrays
If there is no need to save user arrays to controller's non-volatile memory,
this parameter should be NULL.
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Example
Function Description
4.43.1 acsc_StartSPiiPlusSC
Description
The function starts the SPiiPlusSC controller.
Syntax
int _ACSCLIB_ WINAPI acsc_StartSPiiPlusSC()
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Example
4.43.2 acsc_StopSPiiPlusSC
Description
The function stops the SPiiPlusSC controller.
Syntax
int _ACSCLIB_ WINAPI acsc_StopSPiiPlusSC()
Return Value
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.
Example
5. Error Codes
Any error code greater than 1000 is a controller error defined in the SPiiPlus Command
& Variable Reference Guide.
ACSC_
101 Asynchronous call is not supported.
ONLYSYNCHRONOUS
ACSC_MEMORY_
104 Controllers reply is too long.
OVERFLOW
ACSC_
139 Function parameters are invalid.
INVALIDPARAMETERS
ACSC_
140 History buffer is closed.
CLOSEDHISTORYBUF
ACSC_
145 Function is not supported in current version.
FUNCTIONNOTSUPPORTED
ACSC_
147 Internal error: Error of the history buffer initialization.
INITHISTORYBUFFAILED
ACSC_
150 Unsolicited messages buffer is closed.
CLOSEDMESSAGEBUF
ACSC_
164 Internal library error: Sending of the chain is failed.
CHAINSENDINGFAILED
ACSC_APPLICATION_NOT_
166 There is no Application with such Handle.
FOUND
ACSC_INVALID_FILE_
168 The file is not a valid ANSI data file.
FORMAT
ACSC_APPSL_
175 Application Saver Loader Unknown File error.
UNKNOWNFILE
ACSC_APPSL_SECTION_
177 Application Saver Loader Section Size is Zero.
SIZE
ACSC_SERVER 197
SPiiPlus UMD is loaded (whether the UMD icon
appears in the Task tray).
SPiiPlus UMD shows an error message.
In case of remote connection, access from a remote
application is enabled.
6. Constants
This chapter presents the constants that are incorporated in the SPiiPlus C Library.
6.1 General
6.1.1 ACSC_SYNCHRONOUS
Description
Indicates a synchronous call.
Value
0
6.1.2 ACSC_INVALID
Description
Invalid communication handle.
Value
-1
6.1.3 ACSC_NONE
Description
Placeholder for redundant values, like the second index in a one-dimensional array.
Value
-1
6.1.4 ACSC_IGNORE
Description
Used for non-waiting calls with neglect of operation results.
Value
0xFFFFFFFF
6.1.5 ACSC_INT_TYPE
Description
Integer type of the variable.
Value
1
6.1.6 ACSC_REAL_TYPE
Description
Real type of the variable.
Value
2
6.1.7 ACSC_COUNTERCLOCKWISE
Description
Counterclockwise rotation.
Value
1
6.1.8 ACSC_CLOCKWISE
Description
Clockwise rotation.
Value
-1
6.1.9 ACSC_POSITIVE_DIRECTION
Description
A move in positive direction.
Value
1
6.1.10 ACSC_NEGATIVE_DIRECTION
Description
A move in negative direction.
Value
-1
6.2.2 ACSC_COMM_AUTORECOVER_HW_ERROR
Description
When a hardware error is detected in the communication channel and this bit is set, the library
automatically repeats the transaction without counting iterations. By default, this flag is not set.
Value
0x000000002
6.3.2 ACSC_SOCKET_STREAM_PORT
Description
The library opens Ethernet communication using the connection-oriented socket and TCP
communication protocol.
Value
701
6.7.2 ACSC_AMF_RELATIVE
Description
The value of the point coordinate is relative to the end point coordinate of the previous motion.
Value
0x00000002
6.7.3 ACSC_AMF_VELOCITY
Description
The motion uses the specified velocity instead of the default velocity.
Value
0x00000004
6.7.4 ACSC_AMF_ENDVELOCITY
Description
The motion comes to the end point with the specified velocity
Value
0x00000008
6.7.5 ACSC_AMF_POSITIONLOCK
Description
The slaved motion uses position lock. If the flag is not specified, velocity lock is used.
Value
0x00000010
6.7.6 ACSC_AMF_VELOCITYLOCK
Description
The slaved motion uses velocity lock.
Value
0x00000020
6.7.7 ACSC_AMF_CYCLIC
Description
The motion uses the point sequence as a cyclic array: after positioning to the last point it does
positioning to the first point and continues.
Value
0x00000100
6.7.8 ACSC_AMF_VARTIME
Description
The time interval between adjacent points of the spline (arbitrary path) motion is non-uniform and
is specified along with an each added point. If the flag is not specified, the interval is uniform.
Value
0x00000200
6.7.9 ACSC_AMF_CUBIC
Description
Use a cubic interpolation between the specified points (third-order spline) for the spline (arbitrary
path) motion. If the flag is not specified, linear interpolation is used (first-order spline).
Value
0x00000400
6.7.10 ACSC_AMF_EXTRAPOLATED
Description
Segmented slaved motion: if a master value travels beyond the specified path, the last or the first
segment is extrapolated.
Value
0x00001000
6.7.11 ACSC_AMF_STALLED
Description
Segmented slaved motion: if a master value travels beyond the specified path, the motion stalls at
the last or first point.
Value
0x00002000
6.7.12 ACSC_AMF_SYNCHRONOUS
Description
Position Event Generation (PEG): Start PEG synchronously with the motion sequence.
Value
0x00008000
6.7.13 ACSC_AMF_MAXIMUM
Description
Multi-axis motion does not use the motion parameters from the leading axis but calculates the
maximum allowed motion velocity, acceleration, deceleration and jerk of the involved axes.
Value
0x00004000
6.7.14 ACSC_AMF_JUNCTIONVELOCITY
Description
Decelerate to corner.
Value
0x00010000
6.7.15 ACSC_AMF_ANGLE
Description
Do not treat junction as a corner, if junction angle is less than or equal to the specified value in
radians.
Value
0x00020000
6.7.16 ACSC_AMF_USERVARIABLES
Description
Synchronize user variables with segment execution.
Value
0x00040000
6.7.17 ACSC_AMF_INVERT_OUTPUT
Description
Position Event Generation (PEG): The PEG pulse output is inverted.
Value
0x00080000
6.7.18 ACSC_AMF_CURVEVELOCITY
Description
Decelerate to curvature discontinuity point.
Value
0x00100000
6.7.19 ACSC_AMF_CORNERDEVIATION
Description
Use a corner rounding option with the specified permitted deviation.
Value
0x00200000
6.7.20 ACSC_AMF_CORNERRADIUS
Description
Use a corner rounding option with the specified permitted curvature.
Value
0x00400000
6.7.21 ACSC_AMF_CORNERLENGTH
Description
Use automatic corner rounding option.
Value
0x00800000
6.7.22 ACSC_AMF_DWELLTIME
Description
Dwell time between segments.
Value
0x00100000
6.7.23 ACSC_AMF_BSEGTIME
Description
Segment runtime.
Value
0x00004000
6.7.24 ACSC_AMF_BSEGACC
Description
Segment acceleration.
Value
0x00020000
6.7.25 ACSC_AMF_BSEGJERK
Description
Segment jerk.
Value
0x00008000
6.7.26 ACSC_AMF_CURVEAUTO
Description
Automatic curve calculations
Value
0x01000000
6.7.27 ACSC_AMF_AXISLIMIT
Description
Axis velocity limitation enforcement
Value
0x00002000
6.8.2 ACSC_DCF_CYCLIC
Description
Cyclic data collection uses the collection array as a cyclic buffer and continues infinitely. When the
array is full, each new sample overwrites the oldest sample in the array.
Value
0x00000002
6.8.3 ACSC_DCF_SYNC
Description
Starts data collection synchronously to a motion. Data collection started with the ACSC_DCF_SYNC
flag is called axis data collection.
Value
0x00000004
6.8.4 ACSC_DCF_WAIT
Description
Creates synchronous data collection, but does not start until the acsc_Go function is called. This flag
can only be used with the ACSC_DCF_SYNC flag.
Value
0x00000008
6.9.2 ACSC_MST_INPOS
Description
Motor has reached a target position.
Value
0x00000010
6.9.3 ACSC_MST_MOVE
Description
Motor is moving.
Value
0x00000020
6.9.4 ACSC_MST_ACC
Description
Motor is accelerating.
Value
0x00000040
Value
0x00000001
6.10.2 ACSC_AST_DC
Description
Axis data collection is in progress.
Value
0x00000002
6.10.3 ACSC_AST_PEG
Description
PEG for the specified axis is in progress.
Value
0x00000004
6.10.4 ACSC_AST_MOVE
Description
Axis is moving.
Value
0x00000020
6.10.5 ACSC_AST_ACC
Description
Axis is accelerating.
Value
0x00000040
6.10.6 ACSC_AST_SEGMENT
Description
Construction of segmented motion for the specified axis is in progress.
Value
0x00000080
6.10.7 ACSC_AST_VELLOCK
Description
Slave motion for the specified axis is synchronized to master in velocity lock mode.
Value
0x00000100
6.10.8 ACSC_AST_POSLOCK
Description
Slave motion for the specified axis is synchronized to master in position lock mode.
Value
0x00000200
6.11.2 ACSC_IST_IND2
Description
Secondary encoder index of the specified axis is latched.
Value
0x00000002
6.11.3 ACSC_IST_MARK
Description
MARK1 signal has been generated and position of the specified axis was latched.
Value
0x00000004
6.11.4 ACSC_IST_MARK2
Description
MARK2 signal has been generated and position of the specified axis was latched.
Value
0x00000008
6.12.2 ACSC_PST_RUN
Description
Program in the specified buffer is running.
Value
0x00000002
6.12.3 ACSC_PST_SUSPEND
Description
Program in the specified buffer is suspended after the step execution or due to breakpoint in
debug mode.
Value
0x00000004
6.12.4 ACSC_PST_DEBUG
Description
Program in the specified buffer is executed in debug mode, i.e. breakpoints are active.
Value
0x00000020
6.12.5 ACSC_PST_AUTO
Description
Auto routine in the specified buffer is running.
Value
0x00000080
6.13.2 ACSC_SAFETY_LL
Description
Motor fault - Hardware Left Limit
Value
0x00000002
6.13.3 ACSC_SAFETY_NETWORK
Description
Network error.
Value
4
6.13.4 ACSC_SAFETY_HOT
Description
Motor fault - Motor Overheat
Value
0x00000010
6.13.5 ACSC_SAFETY_SRL
Description
Motor fault - Software Right Limit
Value
0x00000020
6.13.6 ACSC_SAFETY_SLL
Description
Motor fault - Software Left Limit
Value
0x00000040
6.13.7 ACSC_SAFETY_ENCNC
Description
Motor fault - Primary Encoder Not Connected
Value
0x00000080
6.13.8 ACSC_SAFETY_ENC2NC
Description
Motor fault - Secondary Encoder Not Connected
Value
0x00000100
6.13.9 ACSC_SAFETY_DRIVE
Description
Motor fault - Driver Alarm
Value
0x00000200
6.13.10 ACSC_SAFETY_ENC
Description
Motor fault - Primary Encoder Error
Value
0x00000400
6.13.11 ACSC_SAFETY_ENC2
Description
Motor fault - Secondary Encoder Error
Value
0x00000800
6.13.12 ACSC_SAFETY_PE
Description
Motor fault - Position Error
Value
0x00001000
6.13.13 ACSC_SAFETY_CPE
Description
Motor fault - Critical Position Error
Value
0x00002000
6.13.14 ACSC_SAFETY_VL
Description
Motor fault - Velocity Limit
Value
0x00004000
6.13.15 ACSC_SAFETY_AL
Description
Motor fault - Acceleration Limit
Value
0x00008000
6.13.16 ACSC_SAFETY_CL
Description
Motor fault - Current Limit
Value
0x00010000
6.13.17 ACSC_SAFETY_SP
Description
Motor fault - Servo Processor Alarm
Value
0x00020000
6.13.18 ACSC_SAFETY_PROG
Description
System fault - Program Error
Value
0x02000000
6.13.19 ACSC_SAFETY_MEM
Description
System fault - Memory Overflow
Value
0x04000000
6.13.20 ACSC_SAFETY_TIME
Description
System fault - MPU Overuse
Value
0x08000000
6.13.21 ACSC_SAFETY_ES
Description
System fault - Hardware Emergency Stop
Value
0x10000000
6.13.22 ACSC_SAFETY_INT
Description
System fault - Servo Interrupt
Value
0x20000000
6.13.23 ACSC_SAFETY_INTGR
Description
System fault - File Integrity
Value
0x40000000
See the SPiiPlus ACSPL+ Command & Variable Reference Guide for detailed
explanations of faults
6.14.2.2 ACSC_INTR_LOGICAL_MOTION_END
Description
Logical motion has finished.
Value
17
6.14.2.3 ACSC_INTR_MOTION_FAILURE
Description
Motion has been interrupted due to a fault.
Value
18
6.14.2.4 ACSC_INTR_MOTOR_FAILURE
Description
Motor has been disabled due to a fault.
Value
19
6.14.2.5 ACSC_INTR_PROGRAM_END
Description
ACSPL+ program has finished.
Value
20
6.14.2.6 ACSC_INTR_ACSPL_PROGRAM_EX
Description
ACSPL+ program has generated the interrupt by INTERRUPTEX command.
Value
21
6.14.2.7 ACSC_INTR_ACSPL_PROGRAM
Description
ACSPL+ program has generated the interrupt by INTERRUPT command.
Value
22
6.14.2.8 ACSC_INTR_MOTION_START
Description
Motion Starts
Value
24
6.14.2.9 ACSC_INTR_MOTION_PHASE_CHANGE
Description
Motion Profile Phase changes
Value
25
6.14.2.10 ACSC_INTR_TRIGGER
Description
AST.#TRIGGER bit goes high
Value
26
6.14.2.11 ACSC_INTR_NEWSEGM
Description
AST.#NEWSEGM bit goes high.
Value
27
6.14.2.12 ACSC_INTR_SYSTEM_ERROR
Description
System error has occurred.
Value
28
6.14.2.13 ACSC_INTR_ETHERCAT_ERROR
Description
EtherCAT error has occurred
Value
29
6.14.3.2 ACSC_INTR_SOFTWARE_ESTOP
Description
ACS EStop button was clicked.
Value
33
ACSC_INTR_PHYSICAL_MOTION_END,
ACSC_INTR_LOGICAL_MOTION_END,
ACSC_MASK_ Axis ACSC_INTR_MOTION_FAILURE,
63
AXIS_63 63
ACSC_INTR_MOTOR_FAILURE,
ACSC_INTR_MOTION_START, ACSC_INTR_MOTION_
PHASE_CHANGE, ACSC_INTR_TRIGGER
ACSC_MASK_ Buffer
BUFFER_0 0 0 ACSC_INTR_PROGRAM_END,
... ... ... ACSC_INTR_COMMAND,
ACSC_MASK_ 63 Buffer ACSC_INTR_ACSPL_PROGRAM
BUFFER_63 63
ACSC_CONF _INT_EDGE_
3 Sets the interrupt edge to be positive or negative.
KEY
ACSC_CONF _ENCODER_
4 Sets encoder type: A&B or analog.
KEY
ACSC_CONF_OUT_KEY 29 OUT0
PEG
Brake
ACSC_CONF _MFLAGS9_
204 Controls value of MFLAGS.9
KEY
ACSC_CONF_SP_OUT_
206 Reads SP output pins.
PINS_KEY
ACSC_CONF_BRAKE_OUT_
229 Controls brake function.
KEY
ACSC_SYS_DBUF_INDEX_
11 D-buffer index.
KEY
EtherCAT support:
ACSC_SYS_ECAT_KEY 16 1 - Yes
0 - No
7. Structures
This chapter details the structures that are available for SPiiPlus C programming.
7.1 ACSC_WAITBLOCK
Description
The structure is used for non-waiting calls of the SPiiPlus C functions.
Syntax
struct
{
HANDLE Event;
int Ret;
} ACSC_WAITBLOCK;
Arguments
Comments
To initiate a non-waiting call the user thread declares the ACSC_WAITBLOCK structure and passes
the pointer to this structure to SPiiPlus C function as parameter. 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 buffer. The calling thread can
retrieve the response with help of the acsc_WaitForAsyncCall function and validate the Ret.
The error codes stored in Ret are the same that the acsc_GetLastError function returns.
7.2 ACSC_PCI_SLOT
Description
The structure defines a physical location of PCI card. This structure is used in the acsc_GetPCICards
function and contains the information about detected PCI card.
Syntax
struct
{
unsigned int BusNumber;
unsigned int SlotNumber;
unsigned int Function;
} ACSC_PCI_SLOT;
Arguments
Comments
The SlotNumber can be used in the acsc_OpenCommPCI call in order to open communication with a
specific card. Other members have no use in SPiiPlus C Library.
7.3 ACSC_HISTORYBUFFER
Description
The structure defines a state of the history and message buffers. This structure is used by the acsc_
OpenHistoryBuffer and acsc_OpenMessageBuffer functions.
Syntax
struct
{
int Max;
int Cur;
int Ring;
char* Buf
} ACSC_HISTORYBUFFER;
Arguments
Comments
Max is equal to the requested Size and never changes its value.
Cur is a number of bytes currently stored in the buffer. From the beginning, Cur is zero, then grows
up to Max, and then remains unchanged.
Ring is a circular index in the buffer: if the buffer is full, the most recent byte is stored in position
Ring-1, the earliest byte is stored in position Ring.
The user program must never change the members in the structure or write to the history buffer.
However, the user program can read the structure and the buffer directly. If doing so, the user
should be aware that the library includes a separate thread that watches the replies from the
controller. For this reason the contents of the buffer and structure members can change
asynchronously to the user thread.
7.4 ACSC_CONNECTION_DESC
Description
The structure defines controller connection for an application. Used in the acsc_GetConnectionsList
and acsc_TerminateConnection functions.
Syntax
struct
{
char Application[100];
HANDLE handle;
dwor ProcessID
} ACSC_CONNECTION_DESC;
Arguments
7.5 ACSC_CONNECTION_INFO
Description
The structure provides information about specified controller connection for an application. Used in
the acsc_GetConnectionInfo function.
Syntax
struct
{
ACSC_CONNECTION_TYPE Type;
int SerialPort;
int SerialBaudRate;
int PCISlot;
int EthernetProtocol;
char EthernetIP[100];
int EthernetPort;
} ACSC_CONNECTION_INFO;
Arguments
7.6.1 ACSC_APPSL_STRING
Description
The structure defines a string in the application file.
Syntax
struct
{
int length;
char *string
} ACSC_APPSL_STRING;
Arguments
7.6.2 ACSC_APPSL_SECTION
Description
The structure defines the application section to be loaded or saved.
Syntax
struct
{
ACSC_APPSL_FILETYPE type;
ACSC_APPSL_STRING filename;
ACSC_APPSL_STRING description;
int size;
int offset;
int CRC;
int inuse;
int error;
char *data
} ACSC_APPSL_SECTION;
Arguments
0 - Not in use.
inuse
1 - In use.
7.6.3 ACSC_APPSL_ATTRIBUTE
Description
The structure defines an attribute key-value pair.
Syntax
struct
{
ACSC_APPSL_STRING key;
ACSC_APPSL_STRING value
} ACSC_APPSL_ATTRIBUTE;
Arguments
7.6.4 ACSC_APPSL_INFO
Description
The structure defines an application file structure, including the header, attributes and file sections.
Syntax
struct
{
ACSC_APPSL_STRING filename;
ACSC_APPSL_STRING description;
int isNewFile;
int ErrCode;
int attributes_num;
ACSC_APPSL_ATTRIBUTE *attributes;
int sections_num;
ACSC_APPSL_SECTION *sections;
} ACSC_APPSL_INFO;
Arguments
1 - File is new.
isNewFile
0 - File exists and has been modified.
8. Enums
This chapter details the enums that are available for SPiiPlus C programming.
8.1 ACSC_LOG_DETALIZATION_LEVEL
Description
This enum is used for setting log file parameters in the acsc_SetLogFileOptions function.
Syntax
typedef enum
{
Minimum,
Medium,
Maximum,
} ACSC_LOG_DETALIZATION_LEVEL;
Arguments
8.2 ACSC_LOG_DATA_PRESENTATION
Description
This enum is used for setting log file parameters in the acsc_SetLogFileOptions function.
Syntax
typedef enum
{
Compact,
Formatted,
Full
} ACSC_LOG_DATA_PRESENTATION;
Arguments
Value 0: No more than the first ten bytes of the data strings will be logged.
Compact
Non-printing characters will be represented in Hex ASCII code.
Value 1: All the binary data will be logged. Non-printing characters will be
Formatted
represented in Hex ASCII code.
8.3 ACSC_APPSL_FILETYPE
Description
This enum is used by Application Load/Save functions for defining the application file type.
Syntax
typedef enum
{
ACSC_ADJ,
ACSC_SP,
ACSC_ACSPL,
ACSC_PAR,
ACSC_USER
} ACSC_APPSL_FILETYPE;
Arguments
8.4 ACSC_CONNECTION_TYPE
Description
This enum is used for setting communication type. Used in the acsc_GetConnectionInfo function
Syntax
typedef enum
{
ACSC_NOT_CONNECTED = 0,
ACSC_SERIAL = 1,
ACSC_PCI = 2,
ACSC_ETHERNET = 3,
ACSC_DIRECT = 4
} ACSC_CONNECTION_TYPE;
Arguments
9. Sample Programs
The following samples demonstrate the usage of the SPiiPlus C Library functions. The examples
show how to write the C/C++ applications that can communicate with the SPiiPlus controller.
The samples open the communication with the controller or the simulator and perform some
simple tasks, like starting of a point-to-point motion, reading a motor feedback position,
downloading an ACSPL+ program to the controller program buffer, etc.
After installation of the package in the SPiiPlus C Library directory, the full source code of these
samples with the projects for Visual C++ 6 and Visual Studio 2005 can be found.
9.1.1 ACSPL+
The sample shows how to open communication with the simulator or with the controller (via serial,
ethernet or PCI Bus), how to download the ACSPL+ program to controller's buffer, and how to
execute it. The ACSPL+ program executes a reciprocated point-to-point motion.
File ACSPL.CPP:
#include <conio.h>
#include <stdio.h>
#include "windows.h"
#include "C:\Program Files\ACS Motion Control\SPiiPlus 6.70\ACSC\C_
CPP\acsc.h"
HANDLE hComm;// communication handle
void ErrorsHandler(const char* ErrorMessage, BOOL fCloseComm)
{
printf (ErrorMessage);
printf ("press any key to exit.\n");
if (fCloseComm) acsc_CloseComm(hComm);
{
_getch();
};
int main(int argc, char *argv[])
{
double FPOS;
// ACSPL+ program which we download to controller's buffer
// The program performs a reciprocated motion from position 0 to 4000
// and then back
char* prog = " enable X \r\n\
St: \r\n\
ptp 0, 4000 \r\n\
ptp 0, 0 \r\n\
goto St \r\n\
stop \r\n";
printf ("ACS Motion Control Copyright (C) 2011. All Rights \
Reserved.\n");
printf ("Application executes reciprocated point-to-point motion\n");
/*****************************************************************/
// Open communication with simulator
printf ("Application opens communication with the simulator, \
downloads\n");
printf ("program to controller's and executes it using SPiiPlus C Library
\
functions\n\n");
printf ("Wait for opening of communication with the simulator...\n");
hComm = acsc_OpenCommSimulator();
if (hComm == ACSC_INVALID)
{
ErrorsHandler("error while opening communication.\n", FALSE);
return -1;
}
printf ("Communication with the simulator was established \
successfully!\n");
/*****************************************************************/
/********************************************************************
// Example of opening communication with the controller via COM1
printf ("Application opens communication with the controller via \
COM1, downloads\n");
printf ("program to the controller and executes it using SPiiPlus C \
Library functions\n\n");
printf ("Wait for opening of communication with the \
controller...\n");
hComm = acsc_OpenCommSerial(1, 115200);
if (hComm == ACSC_INVALID)
{
ErrorsHandler("error while opening communication.\n", FALSE);
return -1;
}
printf ("Communication with the controller was established \
successfully!\n");
/*****************************************************************/
/********************************************************************
// Example of opening communication with the controller via COM1
printf ("Application opens communication with the controller via \
COM1, downloads\n");
printf ("program to the controller and executes it using SPiiPlus C \
Library functions\n\n");
printf ("Wait for opening of communication with the \
controller...\n");
hComm = acsc_OpenCommSerial(1, 115200);
if (hComm == ACSC_INVALID)
{
{
ErrorsHandler("stop program error.\n", TRUE);
return -1;
}
// Download the new program to the controller's buffer
if (!acsc_LoadBuffer(hComm, 0, prog, strlen(prog), NULL))
{
ErrorsHandler("downloading program error.\n", TRUE);
return -1;
}
printf ("Program downloaded\n");
// Execute the program in the buffer 0
if (!acsc_RunBuffer(hComm, 0, NULL, NULL))
{
ErrorsHandler("run program error.\n", TRUE);
return -1;
}
printf ("Motion is in progress...\n");
printf ("Feedback position:\n");
while (!_kbhit())
{
// read the feedback position of axis 0
if (acsc_GetFPosition(hComm, ACSC_AXIS_0, &FPOS, NULL))
{
printf ("%f\r", FPOS);
}
Sleep(500);
}
// Stop the program in the buffer 0
if (!acsc_StopBuffer(hComm, 0, NULL))
{
ErrorsHandler("stop program error.\n", TRUE);
return -1;
}
// Close the communication
acsc_CloseComm(hComm);
return 0;
}
9.1.2 Immediate
The sample shows how to open communication with the Simulator or with the controller (via serial,
ethernet or PCI Bus) and how to execute a reciprocated point-to-point motion only by calling
appropriate SPiiPlus C functions without any ACSPL+ program.
File IMMEDIATE.CPP:
#include <conio.h>
#include <stdio.h>
#include "windows.h"
#include "C:\Program Files\ACS Motion Control\SPiiPlus 6.70\ACSC\C_
CPP\acsc.h"
HANDLE hComm; // communication handle
void ErrorsHandler(const char* ErrorMessage, BOOL fCloseComm)
{
printf (ErrorMessage);
printf ("press any key to exit.\n");
if (fCloseComm) acsc_CloseComm(hComm);
_getch();
};
int main(int argc, char *argv[])
{
double FPOS;
int State;
printf ("ACS Motion Control. Copyright (C) 2011. All Rights \
Reserved.\n");
printf ("Application executes reciprocated point-to-point
motion\n");
/*****************************************************************/
// Open communication with the simulator
printf ("Application opens communication with the simulator and\n");
printf ("sends some commands to the simulator using SPiiPlus C Library \
functions\n\n");
printf ("Wait for opening of communication with the simulator...\n");
hComm = acsc_OpenCommSimulator();
if (hComm == ACSC_INVALID)
{
ErrorsHandler("error while opening communication.\n", FALSE);
return -1;
}
printf ("Communication with the simulator was established \
successfully!\n");
/*****************************************************************/
/******************************************************************
// Example of opening communication with the controller via COM1
printf ("Application opens communication with the controller via \
serial link and\n");
printf ("sends some commands to the controller using SPiiPlus C Library
\functions\n\n");
printf ("Wait for opening of communication with the \
controller...\n");
hComm = acsc_OpenCommSerial(1, 115200);
if (hComm == ACSC_INVALID)
{
ErrorsHandler("error while opening communication.\n", FALSE);
return -1;
}
printf ("Communication with the controller was established \
successfully!\n");
/*****************************************************************/
/******************************************************************