|
|
|
|
Direct Interface
|
| |
|
1. Introduction
|
| |
|
2. API Index
|
| |
|
3. API Description
|
|
|
4. API Calling Procedure from VB
|
|
|
5. API Calling Procedure from VC++
|
| |
|
|
| |
|
1. Introduction
|
| |
|
DYNAX intelligent servo drive Atom-SRA series offers great flexibility to allow
easy interface with either digital switches, PLC, handheld terminal (Fics-RT1), Fics-series
controllers, or PC serial RS232C port for advanced motion control.
The following API are provided for the control of Atom-SRA from PC
RS232C port using Visual Basic or Visual C/C++. With these API, it
is easy to perform PTP control, index 256 points of pre-set relative positions and 8 points of
absolute positions, read/set drive status and I/O info, set speed and control
parameters of Atom-SRA etc.
Since RS-232C is basically one-to-one communication, multi
RS-232C ports are necessary for communication with multi servo
drives.
|
| |
|
|
| |
|
|
| |
|
2. API Index
|
| |
|
| API name |
Descriptions |
| AtomInit |
Hand shake to begin RS232C communication |
|
OpenCom |
Open RS232C communication port |
| CloseCom |
Close RS232C communication port |
|
SetWriteTimeout |
Set time out for writing data to RS232C |
|
SetReadTimeout |
Set time out for reading data from RS232C |
|
ST |
Read drive status (Alarm, Servo Ready, Ready, PTP stop,
etc) |
| SV |
Turn servo ON/OFF |
| XY |
Read the current axis position |
| GP |
Specify relative/absolute indexing point group |
| PD |
Set point number a specified coordinate data |
| PI |
Set the current axis position to a specified point number |
| P1 |
Select speeds for JOG, PTP, homing, and
acceleration/deceleration time |
| P2 |
Set control parameters such as need homing or not, speed
profile, auto servo ON, emergency stop mode etc. |
| PS |
Set speed parameters |
| PR |
Read speed parameters |
| SS |
Set PTP speed to "Fast" or "low" |
| VS |
Set value of lead of screw |
| VR |
Read values of encoder pulse and lead of screw |
| SW |
Read the status of sensor and switches |
| JG |
JOG operation |
| OGR |
Homing |
| MR |
PTP control in relative coordinates |
| MA |
PTP control in absolute coordinates |
| PT |
PTP by specifying point number |
| SP |
PTP stop |
| EM |
Emergency stop |
| ER |
Error reset |
| DI |
Read DI |
| DOUT |
Write to DO |
| MB |
PTP control in absolute coordinates with DI stop function |
| MS |
PTP control in relative coordinates with DI stop function |
Important Notices:
- To develop application programs using Visual Basic, it is necessary to import
the standard module "include.bas" into your VB project.
- "Dim Command As String" and "Dim CurrentValue As String * 256" should be declared
in your applications. For details, refer to the sample program in the VBsample directory.
|
| |
|
|
| |
|
3. API Description
|
| |
|
BOOL _stdcall AtomInit(int iCom);
| Inputs |
iCom: RS-232C Com port number (1,2, ...) |
| Outputs |
None |
| Descriptions |
Hand-shake for RS232C communication. On success, return
"True". Otherwise, return "False". |
BOOL _stdcall OpenCom(int nPort);
| Inputs |
nPort: RS232C Com port number (Ex. 1 for Com1) |
| Outputs |
None |
| Descriptions |
Open RS232C communication port. On success, return
"True". Otherwise, return "False". |
void _stdcall CloseCom(int iCom);
| Inputs |
iCom: RS-232C Com port number (1,2, ...) |
| Outputs |
None |
| Descriptions |
Close RS232C communication port. On success, return
"True". Otherwise, return "False". |
void _stdcall
SetWriteTimeout(int iCom, int TimeOut);
| Inputs |
iCom: RS-232C Com port number (1,2, ...)
TimeOut: time out value in seconds.
|
| Outputs |
None |
| Descriptions |
Set the time out value. If PC does not get any reply from
Fics-III by the time set here, terminate the current application. |
void _stdcall SetReadTimeout(int iCom, int TimeOut);
| Inputs |
iCom: RS-232C Com port number (1,2, ...)
TimeOut: time our value in seconds
|
| Outputs |
None |
| Descriptions |
Set the time-out value for reading information from Fics-III.
If there is not any reply from Fics-III by the time set here stop the
execution of the current program. |
BOOL _stdcall ST(int iCom, char *CurrentValue);
| Inputs |
iCom: RS-232C Com port number (1,2, ...) |
| Outputs |
A string containing 2-byte Atom-SRA status data (for the
meaning of each bit, see the following table) |
| Descriptions |
Read the status of Atom-SRA drive |
Atom-SRA Status:
| First Byte |
7 |
6 |
5 |
4 |
3 |
2 |
1 |
0 |
| |
1(fixed) |
|
Alarm |
|
Servo Ready |
Ready |
PTP Stop |
in Stop |
| Second Byte |
7 |
6 |
5 |
4 |
3 |
2 |
1 |
0 |
| |
1(fixed) |
Error Code |
| Status Name |
1 |
0 |
| Alarm |
Alarm is ON |
Alarm is OFF |
| Servo Ready |
Servo is ready |
Servo is not ready |
| Ready |
Ready to start movement (homing is completed) |
Not ready to start movement |
| PTP Stop |
PTP is stopped by DI input during MB and MS commands, or
emergency stop |
The previous PTP is completed successfully |
| in Stop |
Motor is not moving |
Motor is moving |
Error Code:
| Error Code (hex) |
Descriptions |
| 08 |
Something is wrong with encoder |
| 10 |
Servo OFF |
| 11 |
Emergency stop |
| 12 |
Over-run |
| 13 |
PTP time-out |
| 14 |
Homing is not completed |
| 18 |
Error occurred during homing |
| 20 |
Output is abnormal |
| 22 |
Over-load is detected |
| 24 |
Over-voltage is detected |
| 28 |
Over-current is detected |
| 30 |
Parameter checksum error |
| 32 |
Point data checksum error |
BOOL _stdcall SV(int iCom, char *n, char *CurrentValue);
| Inputs |
iCom: RS-232C Com port number (1,2, ...).
n: "0" = OFF, "1" = ON
|
| Outputs |
CurrentValue: Error message, A2 = success, |
| Descriptions |
Turn servo ON/OFF. If command is successful, return
"True". Otherwise, return "False". |
BOOL _stdcall XY(int iCom, char * CurrentValue);
| Inputs |
iCom: RS-232C Com port number (1,2, ...). |
| Outputs |
CurrentValue: Current position expressed by pulse number
Ex.) "5000" means the current position is at a
half turn if one rotation corresponds to 10000 pulses |
| Descriptions |
Read the current position of the motor. If command is
successful, return "True". Otherwise, return
"False". |
BOOL _stdcall GP(int iCom, char* n, char * CurrentValue);
| Inputs |
iCom: RS-232C Com port number (1,2, ...).
n: "0" = selecting relative point group, "1" = selecting
absolute point group
|
| Outputs |
CurrentValue: Error message, "A2" = Command success |
| Descriptions |
Select relative/absolute points of group for indexing. There
are 256 points of relative position and 8 points of absolute position on
default. If command is successful, return "True".
Otherwise, return "False". |
BOOL _stdcall PD(int iCom, char* PointData, char * CurrentValue);
| Inputs |
iCom: RS-232C Com port number (1,2, ...).
PointData: "nnn = xxxxxxx"
where "nnn" represents point number (1-256)
"xxxxxxxx" represents the point data to be set (in pulse unit)
Ex.) "4=10000" sets point no.4 to 10000 pulses
|
| Outputs |
CurrentValue: Error message, "A2" = Command success |
| Descriptions |
Set points data to a specified point number. If command is
successful, return "True". Otherwise, return
"False". |
BOOL _stdcall PI(int iCom, char *PointNum, char * CurrentValue);
| Inputs |
iCom: RS-232C Com port number (1,2, ...).
PointNum: "nnn"
where "nnn" represents point number (1-256).
|
| Outputs |
CurrentValue: Error message, "A2" = Command success |
| Descriptions |
Set the current position to point "nnn". If
command is successful, return "True". Otherwise,
return "False". |
BOOL _stdcall P1(int iCom, char *Num, char * CurrentValue);
| Inputs |
iCom: RS-232C Com port number (1,2, ...).
Num: "mn"
where "mn" represents parameter number given in the following table.
Ex.) To set homing speed as 120(rpm), "mn" should be chosen as "50" because
JOG speed is located on row 5 and 120(rpm) is located on column 0 in the
parameter table.
|
| Outputs |
CurrentValue: Error message, "A2" = Command success |
| Descriptions |
Select speed parameters. On success, return
"True". Otherwise, return "False". |
Parameter Table:
| m |
n (the default values are marked with color)
|
| 0 |
1 |
2 |
3 |
4 |
5 |
| 1 |
500 |
1000 |
2000 |
3000 |
4000 |
5000 |
| 2 |
500 |
1000 |
2000 |
3000 |
250 |
100 |
| 3 |
240 |
360 |
480 |
|
|
|
| 4 |
120 |
180 |
240 |
|
|
|
| 5 |
120 |
180 |
240 |
|
|
|
| 6 |
50 |
100 |
200 |
300 |
400 |
250 |
| 7 |
50 |
100 |
200 |
300 |
400 |
250 |
BOOL _stdcall P2(int iCom, char *mn, char * CurrentValue);
| Inputs |
iCom: RS-232C Com port number (1,2, ...).
Num: "mn"
where "mn" represents the control parameter number given in the following
table. Ex.) To set Automatic Servo ON, "mn" should be chosen as "81" because
this parameter is located on row 8 and column 1 in the following control
parameter table.
|
| Outputs |
CurrentValue: Error message, "A2" = Command success |
| Descriptions |
Select control parameters. On success, return
"True". Otherwise, return "False". |
Control Parameter Table
| m |
n (the default values are marked with color)
|
| |
0 |
1 |
| 1 |
Invertion of the logic state of digital inputs |
Pattern 1 |
Pattern 2 |
| 2 |
Speed Profile |
S-Curve |
Trapezoidal |
| 3 |
Homing Direction |
- |
+ |
| 4 |
Moving Direction |
+ |
- |
| 5 |
NEED/NEEDLESS of Homing |
NEED |
NEEDLESS |
| 6 |
JOG Pitch |
1 |
10 |
| 7 |
Communication Speed |
9600 |
4800 |
| 8 |
Automatic Servo ON |
OFF |
ON |
| 9 |
Emergency Stop Mode |
Motor Free |
Decelerating to stop |
| A |
Use Z-phase of Encoder for Homing |
No |
Yes |
BOOL _stdcall PS(int iCom, char* Data, char * CurrentValue);
| Inputs |
iCom: RS-232C Com port number (1,2, ...).
Data: "nn=mmmm"
where "nn" represents the speed parameter number given in the speed
parameter table. "mmmm" can be any speed value which over-writes the speed
value in the speed parameter table.
Ex.) To set Homing speed as 190 (rpm), "nn"
should be chosen as "51=190"
|
| Outputs |
CurrentValue: Error message, "A2" = Command success |
| Descriptions |
Change speed values. If command is successful, return
"True". Otherwise, return "False". |
BOOL _stdcall PR(int iCom, char* nn, char * CurrentValue);
| Inputs |
iCom: RS-232C Com port number (1,2, ...).
nn:
"nn" represents the speed parameter number given in the speed
parameter table.
|
| Outputs |
CurrentValue: On success, return the speed parameter value
set in the speed parameter table. On failure, return error message.
|
| Descriptions |
Read speed values. If command is successful, return
"True". Otherwise, return "False". |
BOOL _stdcall SS(int iCom, char *s, char * CurrentValue);
| Inputs |
iCom: RS-232C Com port number (1,2, ...).
s: "F" or "S" .
|
| Outputs |
CurrentValue: return "A2" on success. Return error message
on failure. |
| Descriptions |
Select to use high speed ("F") or low speed ("S") in the
subsequent PTP commands. If command is successful, return
"True". Otherwise, return "False". |
BOOL _stdcall VS(int iCom, char *Data, char *CurrentValue);
| Inputs |
iCom: RS-232C Com port number (1,2, ...).
Data: "L=xxxxxxx" .
Ex.) If the lead of screw is 5mm, data should be set as "L=5000". If the
lead of screw is 20mm, set data as "L=20000".
|
| Outputs |
CurrentValue: return "A2" on success. Return error message
on failure. |
| Descriptions |
Set the lead of screw. If command is successful, return
"True". Otherwise, return "False". |
BOOL _stdcall VR(int iCom, char* n, char * CurrentValue);
| Inputs |
iCom: RS-232C Com port number (1,2, ...).
n: "L" or "E".
n="L" reads the lead of screw; n="E" reads the encoder pulse per rotation.
|
| Outputs |
CurrentValue: contains the read data on success, or error
message on failure. |
| Descriptions |
Read the lead of screw. If command is successful, the
function returns "True". Otherwise, return
"False". |
BOOL _stdcall SW(int iCom, char * CurrentValue);
| Inputs |
iCom: RS-232C Com port number (1,2, ...) |
| Outputs |
CurrentValue: return the read data on success; return error
message on failure.
Ex.) CurrentValue = "000100000100" means Servo ON and +Over-run ON. |
| Descriptions |
Read the status of over-run, homing, emergency stop sensors,
and I/O switches. Sensor/Switch ON is represented by "1", and OFF by "0".
The meaning of each bit is listed below. On success, return
"True". Otherwise, return "False". |
The meaning of each input bit:
| 0 |
Emergency Stop |
| 1 |
Start |
| 2 |
Servo ON |
| 3 |
Reset |
| 4 |
Set Speed |
| 5 |
Point Input |
| 6 |
+ Moving Direction |
| 7 |
- Moving Direction |
| 8 |
+ Over-run |
| 9 |
- Over-run |
| 10 |
ORG (homing sensor) |
| 11 |
|
BOOL _stdcall JG(int iCom, char *n, char * CurrentValue);
| Inputs |
iCom: RS-232C Com port number (1,2, ...).
n:
"+" = start JOG in the plus direction;
"-" = start JOG in the minus direction;
"0" = stop JOG.
|
| Outputs |
CurrentValue: "A2" on success; error message on failure. |
| Descriptions |
Start/Stop JOG move in +/- direction. If Atom-SRA does not
receive this signal for more 0.5 seconds, JOG stops. If command
is successful, return "True". Otherwise return
"False". |
BOOL _stdcall OGR(int iCom, char * CurrentValue);
| Inputs |
iCom: RS-232C Com port number (1,2, ...). |
| Outputs |
CurrentValue: "A2" on success; error message on failure. |
| Descriptions |
Perform homing. To check whether homing has been completed
successfully, execute ST command. If both "in stop" and "ready" bits are ON,
homing was successful. |
BOOL _stdcall MR(int iCom, char *Data, char * CurrentValue);
| Inputs |
iCom: RS-232C Com port number (1,2, ...).
Data: "xxxxxxx"
target position expressed in pulse unit.
Ex.) Data = "5000" specifies the target position for PTP as 5000 pulses
|
| Outputs |
CurrentValue: "A2" on success; error message on failure. |
| Descriptions |
Perform PTP move in relative
coordinates. The PTP speed is specified by the speed parameter in P1
command. The completion of PTP can be checked by reading the status (ST
command). |
BOOL _stdcall MA(int iCom, char *Data, char * CurrentValue);
| Inputs |
iCom: RS-232C Com port number (1,2, ...)
Data: "xxxxxxx"
target position in pulse unit.
Ex.) Data = "5000" specifies the target position for PTP as 5000 pulses
|
| Outputs |
CurrentValue: "A2" on success; error message on failure. |
| Descriptions |
Perform PTP in absolute coordinates.
The PTP speed is specified by the speed parameter in P1 command. The
completion of PTP can be checked by reading the status (ST command). |
BOOL _stdcall PT(int iCom, char* nnn, char * CurrentValue);
| Inputs |
iCom: RS-232C Com port number (1,2, ...).
nnn: Point number (1-256)
Ex.) nnn = "4" moves to the position specified by the point No.4.
|
| Outputs |
CurrentValue: "A2" on success; error message on failure. |
| Descriptions |
Perform PTP specified by point number. If command is
successful, return "True". Otherwise, return
"False". |
BOOL _stdcall SP(int iCom, char * CurrentValue);
| Inputs |
iCom: RS-232C Com port number (1,2, ...) |
| Outputs |
CurrentValue: "A2" on success; error message on failure. |
| Descriptions |
Decelerate and stop PTP movement. If command is successful,
return "True". Otherwise, return "False". |
BOOL _stdcall EM(int iCom, char * CurrentValue);
| Inputs |
iCom: RS-232C Com port number (1,2, ...) |
| Outputs |
CurrentValue: "A2" on success; error message on failure. |
| Descriptions |
If the "Emergency Stop Mode" is selected as "Motor Free" in
the control parameter table, the excution of this command makes motor free
immediately and sets "Alarm" as ON. Otherwise, decelerates to stop. |
BOOL _stdcall ER(int iCom, char * CurrentValue);
| Inputs |
iCom: RS-232C Com port number (1,2, ...). |
| Outputs |
CurrentValue: "A2" on success; error message on failure. |
| Descriptions |
Reset errors. On success, return "True".
Otherwise, return "False". |
BOOL _stdcall DI(int iCom, char * CurrentValue);
| Inputs |
iCom: RS-232C Com port number (1,2, ...). |
| Outputs |
CurrentValue: 8 bits DI status expressed in a string with
"0" or "1".
"1" means ON, "0" means OFF.
The MSB corresponds to DI08 and LSB corresponds to DI01.
Ex.) CurrentValue = "00000101" means DI01 and DI03 are ON; others are OFF. |
| Descriptions |
The 8 bits DI (DI01-08) can be used as general sensor
inputs. Use this command to read the status of these DI. |
BOOL _stdcall DOUT(int iCom, char* nn, char* CurrentValue);
| Inputs |
iCom: RS-232C Com port number (1,2, ...).
nn:
"11" sets DO01 to 1
"10" sets DO01 to 0
"21" sets DO02 to 1
"20" sets DO02 to 0
|
| Outputs |
CurrentValue: 8 bits DI status expressed in a string with
"0" or "1".
"1" means ON, "0" means OFF.
The MSB corresponds to DI08 and LSB corresponds to DI01.
Ex.) CurrentValue = "00000101" means DI01 and DI03 are ON; others are OFF. |
| Descriptions |
The "ready (DO01)" and "in Stop (DO02)" of Atom-SRA can be
used as general digital outputs. Use this command to set the status of these
outputs. |
BOOL _stdcall MB(int iCom, char* Data, char *Bit, char *CurrentValue);
| Inputs |
iCom: RS-232C Com port number (1,2, ...).
Data: "xxxxxxx"
xxxxxxx: target position in pulse unit.
Bit: Bit number ("1"-"8")
Ex.) Data = "5000", Bit="2" specify the target position for PTP as 5000
pulses and DI bit as 2.
|
| Outputs |
CurrentValue: "A2" on success; error message on failure. |
| Descriptions |
Perform PTP move in absolute coordinates;
the movement can be stopped by the specified DI bit "i". |
BOOL _stdcall MS(int iCom, char* Data, char *Bit, char *CurrentValue);
| Inputs |
iCom: RS-232C Com port number (1,2, ...)
Data: "xxxxxxx"
xxxxxxx: target position in pulse unit.
Bit: Bit number ("1"-"8")
Ex.) Data = "5000", Bit="2" specify the target position for PTP as 5000
pulses and DI bit as 2.
|
| Outputs |
CurrentValue: "A2" on success; error message on failure. |
| Descriptions |
Perform PTP in relative coordinates;
the movement can be stopped by the specified DI bit "i". |
|
| |
|
4. API Calling Procedure
from VB
|
| |
|
To develop application programs using Visual Basic, it is necessary to import
the standard module "include.bas" into your VB project.
"Dim Command As String" and "Dim CurrentValue As String * 256" should be declared
in your applications. For details, refer to the sample program in the VBsample directory.
The "atom232_m.dll" file must be
placed in the same directory as your application executable
file in order to run your application programs.
In your application programs, the API
functions should be called in the following procedure:
Step1. Call "OpenCom" to open a RS-232C port for
communication. Check whether the command is successfully executed.
Step 2. Call "AtomInit" to initialize servo drive
in order to start communication. This function call is only needed
one time after communication port is opened. If an error
occurs, the drive may not be ready (for instance, power is not ON,
or servo is not ready).
Step 3. Call "XY", "MA", and other functions
to perform required motion. Notice that the distance to move should
be represented in terms of number of pulses. For instance, if the
encoder on motor generates 10000 pulses per revolution, then 10000
pulses should be specified in order to generate one rotation of
motor.
Step 4. Call "CloseCom" before exit.
|
| |
|
5. API Calling Procedure
from VC++
|
|
|
To develop application programs using Visual C++, it is necessary to
include "atom232_m.lib" and "atom232_m.h" in
your application project.
The "atom232_m.dll" file must be
placed in the same directory as your application executable
file in order to run your application programs.
In your application programs, the API
functions should be called in the following procedure:
Step1. Call "OpenCom" to open a RS-232C port for
communication. Check whether the command is successfully executed.
Step 2. Call "AtomInit" to initialize servo drive
in order to start communication. This function call is only needed
one time after communication port is opened. If an error
occurs, the drive may not be ready (for instance, power is not ON,
or servo is not ready).
Step 3. Call "XY", "MA", and other functions
to perform required motion. Notice that the distance to move should
be represented in terms of number of pulses. For instance, if the
encoder on motor generates 10000 pulses per revolution, then 10000
pulses should be specified in order to generate one rotation of
motor.
Step 4. Call "CloseCom" before exit.
|
|