background image

G

MAS

 

 

Gold

 

Maestro

 

Software

 

User’s

 

Manual

   

Software

 

User

 

Manual

 

XXXXXXXXXXXX(0.01)

 

 

3

20

 

Figure

 

2:

 

MachineSequences()

 

function

 

Now

 

we

 

have

 

a

 

program

 

that

 

is

 

“slowly”

 

looping

 

in

 

a

 

background

 

–an

 

almost

 

idle

 

loop,

 

while

 

a

 

timer

 

function,

 

MachineSequencesTimer()

 

is

 

triggered

 

and

 

executed

 

each

 

TIMER_CYCLE

 

ms

 

(20ms

 

in

 

our

 

example),

 

to

 

execute

 

the

 

States

 

Machine.

 

Let’s

 

investigate

 

the

 

MachineSequencesTimer()

 

function

 

in

depth.

 

3.5.3.

 

The MachineSequencesTimer() function 

Figure

 

3

 

presents

 

the

 

general

 

structure

 

of

 

a

 

typical

 

MachineSequencesTimer()

 

function.

 

Why

 

"general"?

 

Because

 

it

 

does

 

not

 

present

 

the

 

details

 

of

 

the

 

States

 

Machines.

 

This

 

will

 

be

 

presented

 

only

 

later.

 

First,

 

understand

 

the

 

general

 

structure

 

of

 

the

 

MachineSequencesTimer()

 

function.

 

Initially,

 

upon

 

a

 

Timer

 

event

 

(each

 

TIMER_CYCLE

 

ms,

 

as

 

initialized

 

above),

 

the

 

MachineSequencesTimer()

 

function

 

is

 

triggered.

 

Its

 

first

 

action

 

is

 

to

 

call

 

the

 

ReadAllInputData()

 

function.

 

The

 

ReadAllInputData()

 

function

 

is

 

an

 

application

 

dependent

 

function.

 

Its

 

task

 

is

 

to

 

read

 

all

 

inputs

 

that

 

may

 

be

 

necessary

 

for

 

the

 

States

 

Machines

 

and

 

to

 

copy

 

them

 

into

 

variables

 

that

 

are

 

not

 

accessible

 

by

 

the

 

"external

 

world".

 

This

 

will

 

ensure

 

that

 

all

 

the

 

States

 

Machines

 

code,

 

as

 

executed

 

during

 

this

 

timer

 

event,

 

will

 

use

 

the

 

same

 

values

 

of

 

input

 

variables.

 

Why

 

this

 

is

 

needed?

 

As

 

the

 

timer

 

event

 

is

 

not

 

necessarily

 

synchronized

 

with

 

"external

 

world"

 

operations,

 

a

 

host,

 

for

 

example,

 

can

 

access

 

the

 

MODBUS

 

memory

 

and

 

modify

 

one

 

of

 

the

 

registers

 

that

 

are

 

used

 

by

 

the

 

States

 

Machines

 

code.

 

Similarly,

 

the

 

G

MAS

 

core

 

can

 

obtain

 

a

 

new

 

reading

 

of

 

e.g.

 

drive's

 

speed

 

over

 

the

 

device

 

network.

 

As

 

such

 

"input

 

data"

 

can

 

be

 

changed

 

by

 

the

 

external

 

world

 

during

 

the

 

MachineSequencesTimer()

 

execution,

 

creating

 

inconsistent

 

operation

 

of

 

the

 

code's

 

flow.

 

It

 

is

 

necessary

 

first

 

to

 

copy

 

all

 

necessary

 

values

 

into

 

"mirror

 

variables"

 

and

 

only

 

then

 

start

 

to

 

use

 

these

 

mirror

 

variables,

 

which

 

will

 

remain

 

unchanged

 

until

 

the

 

next

 

timer

 

event.

 

This

 

is

 

exactly

 

the

 

task

 

of

 

the

 

ReadAllInputData()

 

function.

 

Depending

 

on

 

the

 

application,

 

it

 

should

 

access

 

all

 

necessary

 

variables

 

(of

 

the

 

MODBUS

 

memory,

 

from

 

the

 

G

MAS

 

firmware

 

core,

 

etc.)

 

and

 

copy

 

them

 

into

 

"mirror

 

variables".

 

 

It

 

is

 

extremely

 

important

 

to

 

read

 

and

 

create

 

a

 

copy

 

of

 

all

 

necessary

 

"external

 

world"

 

variables

 

at

 

the

 

beginning

 

of

 

MachineSequencesTimer()

 

 

using

 

the

 

ReadAllInputData()

 

function

 

 

and

 

to

 

use

 

only

 

these

 

copies,

 

or

 

mirrors,

 

during

 

the

 

States

 

Machines

 

code.

 

This

 

will

 

avoid

 

difficulties

 

in

 

synchronization

 

and

 

inconsistent

 

code

 

behavior.

 

 

Summary of Contents for Gold Maestro G-MAS

Page 1: ...G MAS Gold Maestro Software User s Manual March 2011 Ver 1 0 www elmomc com...

Page 2: ...m without prior consent in writing by Elmo Motion Control Ltd This document contains proprietary information belonging to Elmo Motion Control Ltd Such information is supplied solely for assisting user...

Page 3: ...s Files 3 11 3 1 3 Project s Description Files 3 11 3 2 Functions Variables and Constants 3 12 3 3 C and Header Files 3 12 3 4 Wrapper functions 3 13 3 4 1 Hiding Complex and or Not Important Code Seg...

Page 4: ...XXXXXXXX 0 01 1 2 4 3 The device network 4 53 4 4 Additional tools 4 54 4 4 1 KPA Studio 4 54 4 4 2 IP Configuration over USB 4 54 Chapter 5 The XYZ robot example 5 55 Chapter 6 Further Programming Ex...

Page 5: ...mable control unit with built in ready to use standardized functionalities for communications motions emergencies timing events and all that is required and desired to implement a complete multi axis...

Page 6: ...etwork device views only a very narrow axis I O portion of the overall system and therefore cannot create or control overall system sequences or multi axis synchronized motions The network devices req...

Page 7: ...ld product family this can be found for example in the host communication MODbus Ethernet IP Device Network CANopen CANopen over EtherCAT safety PLCmotion library I Os interface circuits etc 1 3 What...

Page 8: ...he G MAS and Gold Drives As a G MAS user you will need this application to configure your system network devices etc communicate with the G MAS and to perform a variety of features incorporated within...

Page 9: ...dify them according to the structure of your own system Use the guidelines described within the following the table to properly modify this manual examples Your System Structure Necessary modification...

Page 10: ...XXXXX 0 01 2 8 Your System Structure Necessary modifications for examples written for CAN Necessary modifications for examples written for EtherCAT G MAS with 1xGold drive over the CAN bus As above As...

Page 11: ...e time to market of your project One of these guidelines is the concept of States Machine programming as you will see later on this manual It is one of few possible methods to implement machine sequen...

Page 12: ...e of the project s directory respects the following guidelines It reflects the project application contents It has no spaces If it consists of few words each word starts with a Capital letter for easy...

Page 13: ...various C functions All files should be named using the above file naming guidelines 3 1 3 Project s Description Files Elmo highly recommends that an application programmer should add some files to a...

Page 14: ...word Global variables are allowed and recommended for variables accessed by more than one function They should be defined at the top of a C file in most cases the project s main C file The Global vari...

Page 15: ...yMoveAbsolute dSpeed dPosition This function has a very simple interface can be easily used to create a motion as all you need to enter are values for Speed and Position but internally it will use the...

Page 16: ...mstances the programmer or Elmo within its examples may define a new function that will have a simple interface with the program and will internally assume some defaults for the remaining functions ar...

Page 17: ...ires a number of assumptions default values keeping previous values etc these assumptions must be clearly documented for the user It is strongly recommended that a Wrapper Function unless it was writt...

Page 18: ...thods to write a program that will answer the above requirements For example multi tasking and interrupts Elmo has an extensive experience in the development of user applications We have acquired this...

Page 19: ...nction is called This function intentionally starts the execution of the machine sequences and motions During the machine operation the MachineSequences function does not return to the main until the...

Page 20: ...ns let s assume a TIMER_CYCLE 20ms From this point on the OS activates the MachineSequencesTimer every 20ms This timer function actually handles and manages the States Machine as explained below The M...

Page 21: ...Immediately after termination is requested the while loop ends and MachineSequences calls to MachineSequencesClose to close everything that needs to be closed before returning to the main function to...

Page 22: ...is will ensure that all the States Machines code as executed during this timer event will use the same values of input variables Why this is needed As the timer event is not necessarily synchronized w...

Page 23: ...re proper synchronized and consistent operation Now let s look at the States Machines themselves Within Figure 3 below you can see that in the general case the MachineSequencesTimer function can handl...

Page 24: ...iable giSubStateN In case a Sub State Machine see later for details is necessary this variable defines the current state of the Sub State Machine It is generally initialized by the MachineSequencesIni...

Page 25: ...te that while theoretically unlimited parallelism and depth can be implemented the programmer is responsible to make sure that the worst case execution time of the overall MachineSequencesTimer functi...

Page 26: ...old Maestro Software User s Manual Software User Manual XXXXXXXXXXXX 0 01 3 24 Figure 3 Typical MachineSequencesTimer function The next figure shows the details of the code within one of the States Ma...

Page 27: ...tates Machines Please note that handling reentrancy and the termination request has been omitted from this drawing compared to the previous example in order to maintain simplicity Of course these two...

Page 28: ...States Machine is executed it will reach the code relevant for this state and will check for end of motion If the axis is still moving the code will return without changing the State value so that th...

Page 29: ...the Sub States Machine Actually this ends the explanation of the States Machines programming structure Shortly within this chapter after the next section about handling errors you will find a section...

Page 30: ...mming practices for handling these errors To clarify it is impossible for us to provide a generic function to handle the errors as each machine requires different error handling process However there...

Page 31: ...s We strongly recommend not using these bypasses Call the library functions without checking the Return Code Just ignoring it This will surely create a nicer and simpler code The assumption behind usi...

Page 32: ...k 2000 0 Value of the Jerk sMove_Abs_in eDirection MC_POSITIVE_DIRECTION MC_Direction Enumerator type sMove_Abs_in eBufferMode MC_BUFFERED_MODE MC_BufferMode Defines the behavior of the axis sMove_Abs...

Page 33: ...names of the C and header files including the wrapper functions that are always in pairs Exploring using the Eclipse the Sample c the main source file of the project we can see the file s header desc...

Page 34: ...an occur at this phase as part of the definition but we prefer to perform all initialization within the suitable initialization functions as described in the n ext section Immediately after the Applic...

Page 35: ...n appears Please note the comments header above the main function as well as above any other function in the code It provides details about the function such as version inputs outputs description etc...

Page 36: ...lize communication and axes while Closing can be used to close them closing log files printing some message to the standard output etc Following these functions we see the MachineSequences It is docum...

Page 37: ...r of the various functions appearing in the file is the order they will be called used starting from main to the other functions it calls and so forth The MachineSequencesInit initializes all variable...

Page 38: ...unctions whose tasks are described in earlier chapters the next interesting function is EnableMachineSequencesTimer This uses system functions to enable the timer and to define the function triggered...

Page 39: ...It is the function triggered periodically by the timer that actually executes the machine sequences the states machines It initially checks if Termination was requested and if reentrance incorrectly o...

Page 40: ...G MAS Gold Maestro Software User s Manual Software User Manual XXXXXXXXXXXX 0 01 3 38 Then the next stage is...

Page 41: ...ine is handled exactly as we described in the flow charts above In the Sample project you can see that the main states machine supports two states two tasks XY_HOME and XY_MOVE Each one of these state...

Page 42: ...e of a states machine code The StateXYHomingFunction is a good example for a sub states machine code While the machine is in XY_HOME state the main states machine s value is XY_HOME this function will...

Page 43: ...G MAS Gold Maestro Software User s Manual Software User Manual XXXXXXXXXXXX 0 01 3 41 Then the next stage is...

Page 44: ...t for end of motions etc we find the function as an example SubStateXYHomingMoveToLimitFunction Please note how this function creates motion and not waiting for end of motion or any other wait and cha...

Page 45: ...tion ends no delays no waits It will be called again at the next timer cycle 20ms in this example and so on Once both limits are set the sub state is modified to the next state and the function ends T...

Page 46: ...more states functions but they are all written according to the above guidelines The Sample h is shown in the two diagrams below Note the functions prototyping general functions and states functions a...

Page 47: ...3 45 This actually completes the review of the Sample project s code The SampleWrapper c and SampleWrapper h files are skeleton almost empty files to be filled with functions and definitions as may be...

Page 48: ...odule User Projects c h Files gexe Files EtherCAT or CAN Bus User C Applications gexe Files User Files HMI or PLC Elmo EAS System Configuration GMAS Setup Motions Drives Setup Motions Drives Programmi...

Page 49: ...that are not closely related to the axes motion sequences such as user interfaces image analysis barcode interfaces etc as maybe required for the machine In the situation where the host is a PC compu...

Page 50: ...is used to develop and debug User C and C Programs for the G MAS Elmo decided to use the market leading Eclipse environment and not to integrate this task to the EAS in order to provide its user with...

Page 51: ...y Elmo as part of the G MAS It automatically runs the G MAS firmware when power ON which is responsible for the following tasks TCP IP communication with the Host Process to Process communication with...

Page 52: ...ach of the available Function Blocks Here is some brief information about the Function Block interfaces The API consists of a list of functions with input and output values For instance the MC_MoveAbs...

Page 53: ...is sent The AxisREF is obtained via the GetAxisByNameCmd API function This function is to be called once per axis The user program either Internal or Remote can receive events that occur in the G MAS...

Page 54: ...ased on a User Application program at the PC since such a program reduces the computational load of the Host reduces the TCP IP network load and includes enabling modular implementation of the overall...

Page 55: ...d memory of the Host and the User Application program and they can communicate over it It is the user s responsibility to define the communication items what is to be communicated in what areas of the...

Page 56: ...andards of this network Generally speaking the user does not need to know the details of the device network as all the details are automatically handled by the G MAS The exact list of protocols suppor...

Page 57: ...G MAS Gold Maestro Software User s Manual Software User Manual XXXXXXXXXXXX 0 01 5 55 Chapter 5 The XYZ robot example TBD...

Page 58: ...G MAS Gold Maestro Software User s Manual Software User Manual XXXXXXXXXXXX 0 01 6 56 Chapter 6 Further Programming Examples...

Page 59: ...G MAS Gold Maestro Software User s Manual Software User Manual XXXXXXXXXXXX 0 01 7 57 Chapter 7 PC Software Installation and how to use TBD...

Reviews: