Electronic Control Unit MARS 2 - USER GUIDE

Electronic Control Unit MARS 2 - USER GUIDE

Pavel Pí¹a ( pisa@cmp.felk.cvut.cz )

Contents

1  Multiaxes Control System Description
2  PC Control Via RS232 Port
    2.1  Form of Commands and Requests Sent Via RS232
    2.2  Commands Description
        2.2.1  Movement to Destination Position And Movement to Reference Mark Commands
        2.2.2  Controller Parameters Setting
        2.2.3  Controller Response Tuning Support
        2.2.4  Clearing, Stopping and Controllers Release
        2.2.5  Acknowledgement of Commands Receiving and Completing
        2.2.6  Joystick and Keyboard
        2.2.7  System Status
        2.2.8  Direct Velocity Control
        2.2.9  Direct Control of Inputs and Outputs
        2.2.10  System Commands
    2.3  Configuration
    2.4  Event Triggers
3  Control Via IIC Interface
4  Manual Control
5  Connectors and Wiring

1  Multiaxes Control System Description

Electronic control unit MARS is designed for position control of DC motors (up to the amount of three)  with incremental sensors of position increment and one index mark per one motor revolve. Working area of the controlled equipment can be marked off by electromechanical terminal switches connected to power parts of the motors or by limit position sensors with logic outputs. To precise the initial position, it is possible to use terminal switches and sensors in a selectable combination with an index output.

Commands for the control unit can be inserted with the help of a selectable local keyboard or via I2C interface of the connected keyboard. From a superior computer, the commands can be transmitted via I2C interface, RS-232 or via RS-485. The control unit can be equipped with an input for a three-axes analog joystick.

In addition to the motor control, 5 digital outputs, 4 power outputs and 2 outputs galvanicaly separated from the unit electronics can be used. Index marks of motors and up to nine digital inputs can be used as digital inputs. Five of them are also usable as analog inputs 0...2.5 V with resolution of 10 bits. When using joystick, three of the inputs are used for joystick.

When a change of the input state is defined and after selection of one of four digital inputs, each of two setable event triggers can send information about the position of the controlled axes and about the state of digital inputs.  During the trigger activation it is possible to stop motion of the selected axes and set a state of digital outputs.

Unit MARS - Technical Data :

VariableValueUnits
Supply voltage18 - 36VDC
Max. safe current for one motor5A
 - current protectionelectronic for each axes
Position sensor input   (IRC)2 signals out of phase +  TTL level index or RS-422
Max. frequency of IRC signals3MHz
Inputs of joystick sensors0 - 5 V
 - supposed central position2.5V
 - sensitivity of joystick sensorsrange can be adjusted for a particular joystick with the help of resistors
Fine tuning of sensitivity and zero position of joystickby software
Desired position generator trapezoidal course with settable acceleration and maximal velocity
Motors position controlsliding PID controller with nonlinear damping
Setting of P, I, and D constantsby software
Correction of power exciter non-sensitivityby software
Range of motor position ±8000.000 step 0.001
 - range in periods of the IRC signal (4 phases)4000000
Absolute position calibrationautomatic search of a selectable combination of the index and terminal switches

For small and middle size position applications with high precision demands it is suitable to combine the MARS unit with MAXON RE 70 W / 42 VDC motors with HP HEDS 5540 incremental sensors with TTL outputs or HP HEDL 5540 with RS-422. These IRC sensors send 500 periods of out of phase signals per one motor revolve and are complemented by an index mark. The unit MARS can execute measurements with the accuracy of 1/2000 of one revolve, and realize position control and movement to the destination position with the accuracy of ±1/2000 of one revolve.

To mark off a working area it is possible to connect terminal (limit) switches with diodes to the power outputs for motors. It ensures return from the positions behind the limit switches and quick stop when getting out of the working area.

As a power supply a feeder with a double-insulated transformer or a pulse power supply can be used. The unit MARS , all peripheries and motors are not dangerous to touch when supplied.

Maintenance.

The electronic control unit MARS requires NO MAINTENANCE.

2  PC Control Via RS232 Port

The electronic control unit communicates with computers via serial asynchronous interface. The following configuration of the communication port is demanded: 9600 baud, 8 bits, no parity, and 2 stop-bits. Data flow control is executed with the help of hardware by signals CST and RTS. The communication speed is settable within the range from 2400 baud up to 19200 baud with the help of a local keyboard. The chosen value is loaded into the EEPROM memory along with other parameters.

2.1  Form of Commands and Requests Sent Via RS232

Each command consists of a name, operation symbol, and parameters. Individual parts of a command can be separated by spaces.

[Name]is created by an arbitrary combination of letters and numerals and always starts with a letter. Names of commands related to individual motors are supplemented with a symbol (A, B and C ) specifying the motor 'm'.
[Operation symbol]defines a command ( symbol ':' ) or a request ( symbol '?' ). The symbol '' can be used to specify acknowledgements.
[Parameter] The meaning of the parameter is determined by the command. In the next, 'xxx.xxx' represents a decimal number, 'xxx' an integer number, and 'x' is a numeral. Negative numbers begin with the symbol '-'.

Names of Individual Commands.

2.2  Commands Description

The detailed description of the individual commands is given in this section. The commands indicated by '*opt' are available only for several system configurations.

2.2.1   Movement to Destination Position And Movement to Reference Mark Commands

NameOpParametersFunction
Gm:xxx.xxxMovement to absolute position
-8000,8000.000

Moves the specified motor 'm' to the absolute position 'xxx.xxx'.

NameOpParametersFunction
GRm:xxx.xxxMovement to relative position
-8000,8000.000

Relative distance 'xxx.xxx' of the motor 'm' movement.

NameOpParametersFunction
APm? Actual position

Returns the actual position of the specified motor 'm' ( format 'xxx.xxx' ).

NameOpParametersFunction
HH: Reference position

Finds the reference mark and resets the position data for all motors.

NameOpParametersFunction
HHm: Reference position of 'm'

Finds the reference mark and resets the position data for the motor 'm'.

2.2.2   Controller Parameters Setting

NameOpParametersFunction
REGPm: ?xxxProportional gain for 'm'
0,255
REGIm: ?xxxIntegral constant for 'm'
0,255
REGDm: ?xxxDerivative constant for 'm'
0,255
REGS1m: ?xxx1. auxiliary constant for 'm'
0,255
REGS2m: ?xxx2. auxiliary constant for 'm'
0,255

These commands enable to set and read controller constants for the motor 'm'. The precise meaning of the parameters and their range depend on the type of the chosen controller for the given motor. For PID controllers , the parameters S1 and S2 serve to suppress the output exciter non-sensitivity.

NameOpParametersFunction
REGMSm: ?xxxMaximal velocity for 'm'
0,30000

This command enables to set the maximal velocity of the motor 'm' ( format 'xxx' ). The velocity parameter is used in the command of Destination Position Movement and also as a velocity limit when control is executed by joystick. The value is given directly in the IRC increment multiplied by 256 in one sampling period.

NameOpParametersFunction
REGACCm?xxxAcceleration for motor 'm'
0,30000

This command enables to set the acceleration of the motor 'm' ( format 'xxx' ). The acceleration parameter is used in the command Destination Position Movement with a trapezoidal course of velocity. In the configuration with a trapezoidal course of velocity, the parameter is used to slow down the velocity when the STOP command is applied or when the movement is interrupted by next Gm, GRm. The acceleration command can be also used to control velocity with the help of commands SPDm and SPDTm. The value determines the velocity increment per one sampling period.

NameOpParametersFunction
REGMEm: ?xxxMaximal PWM for 'm'
0,30000

The value of this parameter specifies the PWM level for motor 'm'. Reduction of the maximal PWM level reduces the maximum motor voltage represented in the percentage related to the supply voltage. In practice, this parameter is used to protect motors with the nominal voltage less than the supply voltage. The value of 32000 corresponds to the maximal voltage.

NameOpParametersFunction
REGCFGm: ?xxxConfiguration word for 'm'
0,30000

For the motor 'm', the configuration word defines a velocity course when moving from one position to another one, a way of finding of the zero position, and conversions of logical and physical coordinates. The received decadic number is interpreted as a bit field xxxxxNxTxLCRDSSS. A complete description is given in Section 2.3.

NameOpParametersFunction
REGTYPEm:xController change for 'm'
*opt0,5

This command changes the type of the controller for the motor 'm'. The following table shows the possible types of controllers that are implemented in the contemporary software version. According to the software modification the default type is linear PID or PID with a nonlinearity.

ValueController
0Default type
1PID with nonlinearity
2Linear PID
3Discrete filter
4Relay characteristic
5Output without IRC coupling

Important warning: The contemporary software version does not enable to store the controller type into the setting in the EEPROM memory. If it is necessary to use another type of the controller for the motor than is the default controller, it is always necessary to execute a new setting after the unit switching on. According to the user demands the manufacturer is able to prepare a modified version with various default parameters and types of controllers for individual axes.

NameOpParametersFunction
REGSFRQ: ?xSampling frequency of controllers
*opt0,4

This command sets a sampling frequency of the control loop of all motors. The meaning of the individual values is as follows: 0 .. default, 1 .. 600 Hz, 2 .. 800 Hz 3 .. 1000 Hz, 4 .. 1200 Hz. This value is stored along with other parameters into the EEPROM memory.

2.2.3   Controller Response Tuning Support

NameOpParametersFunction
REGDBGm:xDebugging of 'm' enabled
0,1

This command enables storage of the history of the motor 'm' motion and declares the motors which all other REGDBGxxx commands will relate to. For the motors with a set flag the actual values of velocity and values sent to the PWM generators are always stored after starting the motion.

NameOpParametersFunction
REGDBGHIS:xxxxMotion history reading
0,3000

This command reads the motion history. The parameter indicates a number of the sent numbers. Each number is sent in a separated line.

NameOpParametersFunction
REGDBGPRE:xxxxData preprocessing for response debugging
0,3000

This command stores data for motor response debugging commands into the memory. The parameter indicates the number of the stored values. The values are sent in the separated lines.

NameOpParametersFunction
REGDBGGNS: Motor response

It controls PWM outputs of the motors with REGDBGm set to 1 according to the values stored with the help of the command REGDBGPRE. After executing the command, the command REGDBGHIS enables to read the actual course of the motor motion.

NameOpParametersFunction
REGDBGGNR: Response of the motor control

This command sets the required change of position for motor controllers with REGDBGm set to one according to the values stored with the help of command REGDBGPRE. After executing the command, the command REGDBGHIS enables to read the actual course of the motor motion.

2.2.4   Clearing, Stopping and Controllers Release

NameOpParametersFunction
CLEARm: Control switching off and clearing of 'm'
CLEAR: Control switching off and clearing of all motors

Switching off of the motor 'm' control and clearing the position reading.

NameOpParametersFunction
STOPm: Stopping of the motor 'm' motion
STOP: Stopping of all motors motion

Stops the motor 'm' motion, but control goes on. When a trapezoidal course of velocity is enabled, the motion fluently slows down before it stops.

NameOpParametersFunction
PURGE: Stops control with an error

This command stops motor control with errors and resets the errors. Other motors continue their activities.

NameOpParametersFunction
RELEASEm: Releases control and stops 'm'
RELEASE: Releases control and stops all motors

This command releases controllers and enables a manual control or stopping motors.

2.2.5   Acknowledgement of Commands Receiving and Completing

NameOpParametersFunction
READY:xOperation completed response
0,1

This command turns ON/OFF a message about finishing all operations. After finishing activities of all motors it sends the line 'R!' or 'FAIL!' ( in case of error flag for at least one motor ).

NameOpParametersFunction
R: Only one operation completed response

This command sends only one 'R!' or 'FAIL!' after finishing just running operations or immediately when none of the motors is busy.

NameOpParametersFunction
Rm: Response for a specific motor

This command sends 'Rm!' or 'FAILm!' after finishing activities of the motor 'm'.

NameOpParametersFunction
REPLY:xCommand acknowledgement
0,1

This command turns ON/OFF confirmation of the lines by their copy. The copy starts with a backslash ''.

2.2.6   Joystick and Keyboard

NameOpParametersFunction
KEYLOCK:xKeyboard locking
0,1

This command enables and disables control via the unit keyboard.

NameOpParametersFunction
JOYSTICKm: Joystick control of the 'm' axis
JOYSTICK: Joystick control of all axes

Turns ON joystick control of the motor position.

NameOpParametersFunction
JOYRESm: ?xxxJoystick axis resolution
-32000,32000
JOYOFFSm: ?xxxCentral position offset of joystick axis
0,65000
JOYHYSm: ?xxxHysteresis angle of joystick axis
0,65000

For the individual joystick axes corresponding to the individual motors these commands set resolution, central position offset and hysteresis around the central position.

NameOpParametersFunction
JOYCAL: Central position calibration

Calibration of the joystick central position (JOYOFFS) for all axes.

2.2.7   System Status

NameOpParametersFunction
STm? Motor 'm' status

This command returns motor 'm' status. Decadic numbers need to be interpreted as bit fields.

BitMeaning
0IRC reading enabled
1Controller enabled
2Generator enabled
3Error
4Last command execution
5Control course storage ON

NameOpParametersFunction
ST? Status of all motors

This command returns logical addition of states of all motors.

2.2.8   Direct Velocity Control

NameOpParametersFunction
SPDm:xxxMovement with given velocity
*opt-32000,32000

With this command the given velocity of the 'm' motor can be demanded. A velocity change can be executed by the acceleration command REGACCm.

NameOpParametersFunction
SPDTm:xxx,yyyMovement with the velocity of 'xxx' continuing within the max. interval 'yyy'
*opt-32000,32000
0,32000

With this command the given velocity of the 'm' motor can be demanded. A velocity change can be executed by the acceleration command REGACCm. The movement continues within 'yyy' sampling periods. If a next command for the given motor has not come until this time, the movement is smoothly stopped.

2.2.9   Direct Control of Inputs and Outputs

NameOpParametersFunction
PWMm:xxxDirect PWM setting
*opt-32000,32000

Direct PWM output setting of the 'm' motor to the 'xxx' value.

NameOpParametersFunction
DIGO:xxxxxDigital outputs setting
*opt0,65535

This command sets the digital outputs 0 .. 15 according to the individual bits of the parameter binary form.

NameOpParametersFunction
DIGI? Digital input state reading
*opt

Reads the digital inputs 0 .. 15 and sends the read state as a decadic value.

NameOpParametersFunction
ADCa? Analog input reading
*opt

Returns a value of the analog input 'a'.

NameOpParametersFunction
TRIGt:s,m,doTrigger setting
*opt

Event triggers - for more information see Section 2.4.

2.2.10   System Commands

NameOpParametersFunction
VER? Returns software version

This command returns the unit firmware version.

NameOpParametersFunction
IHEXLD: Loads new software

This command loads a program in the Intel-HEX format into the RAM memory of the MARS unit.

NameOpParametersFunction
TEST: ? Connection test

Connection checking and input or output command sheet test.

NameOpParametersFunction
REBOOT: Unit software reboot

Resets the unit software. All parameter values are loaded from EEPROM memory again.

NameOpParametersFunction
CFGNVSAVE: Saves parameters into EEPROM

Saves parameters settings for individual motors and sampling periods into the EEPROM memory. It guarantees that the saved parameters values will be loaded after the next switch ON of the unit.

NameOpParametersFunction
CFGDEFAULT: Default parameters setting

Loads standard parameters setting for all motors compiled in the software by the manufacturer.

2.3   Configuration

Configuration setting for individual axes executed by the command REGCFGm determinates a course of velocity when moving from one position to another one and a way of zero position finding. The inserted decadic number is interpreted as a bit field.

Bit1514131211109876543210
FlagsxxxxxNxTxLCRDSSS

The meaning of the individual flags is given in the following table.

FlagsMeaning
SSSStop search speed during HH is REGMSm / 2^SSS
DInitial direction for stop search for HH
RTo find HH the revolve mark from HP HEDS is used
CMark middle search
LLimit switch usage
TTrapezoidal velocity profile usage
NCoordinates from RS232 are not converted
LCR=111Mark search only
CR=11Mark middle search only

To simplify the configuration computation, all combinations of LCR bits are given bellow. To the number it is necessary to add only 16 (D) to change the initial direction,(SSS) to reduce the stop search speed and 256 (T) for fluent starts.

ValueMeaning
0Motor limit switch search only
16Search the first revolve mark (first from the hardware terminal switch)
32Search the middle of the first revolve mark (first from the hardware terminal switch)
48Search the middle of the mark
64Search the limit switch only
80Search the first revolve mark (first from the limit switch)
96Search the middle of the first revolve mark (first from the limit switch)
112Mark search only

2.4   Event Triggers

Event trigger setting is executed by the following command:

TRIGt:s,m,do
t Trigger number (0 or 1)
s Trigger source 0 .. 3 ( -1 trigger disconnection )
s.0 s.1 Source number
s.4 Rising edge
s.5 Trailing edge
s.6 Sent input state
s.7 Set digital outputs
m Mask of the motors that should be stopped and transmission of their position
m.0 Stop A
m.1 Stop B
m.2 Stop C
m.4 Send A
m.5 Send B
m.6 Send C
do Value of digital outputs set at trigger event

Triggers transmit:

TGt!di,ma,mb,mc
t Trigger number (0 or 1)
di Digital inputs at trigger event or "N", if transition disabled
ma,mb,mc According to the choice of m in the setting it sends the IRC position

3  Control Via IIC Interface

A message consists of an information about a type of the message and of data. Types of the I2C messages used in the unit MARS are given in the following table.

SymbolCodeType of message
IC_CMD40HCommands for motor control
IIC_CMM41HReserved
IIC_STM42HReserved
IIC_TEC51HControl of IIC keyboard and a display
IIC_TEK52HInformation about pressed keys
IIC_TED53HData display

Messages of IIC_CMD type are used to send commands for position controllers, to set controller parameters, and to read position and state of individual motors. A format of a full message is shown bellow.

Write to IIC addr 10H+W
0Type of the IIC_CMD message
1Operation
2Motor number
3,4,[5,6]Parameter value for given motor
Read from IIC addr 10H+R
0,1System status
2,3,[4,5]Parameter value of given motor

If the unit MARS receives a message containing only a type of the message no operation will be executed and during the next reading a system status will be sent. If the message contains only a type of the message and an operation the command will be run for all axes and a next reading will return a system status. When a motor number is added, the value of the parameter specified by the operation and the motor number are also read during the reading operation. If the message also contains a value, the value is saved into a specified parameter. The unit MARS enables to receive and read 16-bit and 32-bit parameters. Longer representations are advantageous especially for position data.

Codes for the individual operations are given in the table bellow. In the second column (Parameter) there are given the parameter values that are settable or readable for the given operation.

CodeParameterDescription
0Actual positionActual position reading
1Desired positionDesired position setting
2Desired positionAfter inserting the position the motion starts up
3StatusRuns hard home
4REG PSetting and reading of P constant
5REG ISetting and reading of I constant
6REG DSetting and reading of D constant
7REG MEMaximal duty of PWM
8REG MSMaximal speed of motion
9REG ACCMaximal acceleration
AREG SCMMultiplicative constant for coordinates conversion
BREG SCDDividing constant for coordinates conversion
CMin LSNot implemented
DMax LSNot implemented
EREG CFGConfiguration flags
FStatusMotor status

Flags setting for hard home is the same as the setting via RS-232 (see 2.3).

State flags read via I2C are given in the following table.

BitSymbolDescription
0TRP_SGN
1FL_HH
2FL_ATIM
3FL_ENOVEnergy overflow for a motor start
4ENE_ON
5ERR_FLGError during control
6CMD_LCKNext command can not be received
7CMD_BSYLast command execution

4  Manual Control

The MARS control unit can be handled directly by the local keyboard or a keyboard connected via the I2C interface.

[Button]Function
[A, B, C]Switches the display over to control individual motors: A, B, and C. Writing a number and pressing the ENTER key runs a movement to the given position. Numbers are inserted by the keys 0 .. 9 and a decimal point. Signs can be changed by the key IMPL *.*
[LIST]Displays summary data for all motors. Individual motors are accessible via cursors ­ and ¯ .
[RUN]Enables control of all axes by joystick.
[HOLD]Runs hard home (zero position search) for all axes
[END]Disconnects controllers and sets the actual position to zero
[PURGE]Stops control with an error - other operations go on.
[MOTOR STOP]Stops all motions. Control of all motors goes on.

5  Connectors and Wiring

*15cm!fig/mars2c.gif

Figure 1: Connections layout on the unit MARS

Connector for connecting joystick

For the MARS unit, an analog joystick with three potentiometers is required. The unit connector has the following wiring:

PinSignalAlt. TTL inputDB9
1VCC8,9
2INPUT AI133
3INPUT BI144
4INPUT CI155
5GND1,2

In case of encasing the electronic control unit, the input of the joystick is wired to the female DB9 Canon connector.

Communication connector RS232

Cable is connected to the unit board via a crimped connector. To the control unit, a transfer connector is supplied to use standard connectors DB9 or DB25. To connect the unit to PC, the connection with DB 25V is given in the table bellow.

MARS PC
Board pin SignalDB9SignalDB25DB9
1TxD2RxD32
2RxD3TxD23
3RTS8CTS58
4CTS7RTS47
5GND5GND75

Connectors for connecting motors and IRC sensors

Power outputs for individual motors are accessible via MOTOR A, MOTOR B and MOTOR C connectors. Incremental sensors of position need to be connected to the unit via IRC A,IRC B and IRC C connectors.

PinSignal
1GND 0V
2Phase A
3VCC +5V
4Phase B
5INDEX

Index inputs can be also used and read as digital inputs

IRC A INDEXI0
IRC B INDEXI1
IRC C INDEXI5

Digital inputs and outputs

PinSignal
Connector I1
1VCC
2I11 (I2)
3GND
Connector I2
1VCC
2I12 (I3)
3GND
Connector I/O1
1GND
2I6
3VCC
4I7
5O14
Connector I/O2
1I5
2I4
3O0
4O1
5O2
6O3
7VCC
8GND
POWER OUT
1PWR 12 - 24V
2O4
3O5
4O6
5O7

Communication I2C

PinSignal
1GND
2SCL
3VCC
4SDA