AN2364 Freescale Semiconductor / Motorola, AN2364 Datasheet

no-image

AN2364

Manufacturer Part Number
AN2364
Description
Using the Table Stepper Motor TPU Function (TSM) with the MPC500 Family
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
Application Note
AN2364/D
Rev. 0, 10/2002
Using the Table Stepper
Motor TPU Function
(TSM) with the MPC500
Family
Glann Jackson
TECD Applications
This TPU Programming Note is intended to provide simple C interface routines to the table
stepper motor TPU function (TSM). The routines are targeted for the MPC500 family of
devices, but they should be easy to use with any device that has a TPU.
1
The Table Stepper Motor (TSM) function is just one of numerous useful functions with
pre-defined parameters available for the developer of TPU applications.These functions are
located in the TPU ROM and are designated by a unique function number. The function
number for the TSM is 0xD. Details of this appnote will instruct the user on calling the
functions of the TSM and configuring these functions as needed.
The TSM function provides motor control to set the motor to a desired position (or step) in the
360 degree arch of motion. A relative distance between the current position and the desired
position of the motor will determine the direction and amount of acceleration that the motor
will be engaged to reach the desired position in the shortest amount of time. The values of
acceleration are stored into a table in memory. Hence the name Table Stepper Motor function.
The TSM function provides the TPU with the capability to drive two-phase stepper motors in
full- or half-step modes. The TPU can accelerate the motors, run them at constant speed (or
slew) and decelerate the motor independently of the CPU. The CPU need only initialize the
function once, and then supply a desired position each time a move is required. The
acceleration/deceleration profile is freely configured by the user via a variable length table
that offers up to 96 step rates. The TPU can control up to eight motors in full step mode or four
motors in half step mode or a combination of both.
2
The TSM function supports full- and half-step unipolar and bipolar drive of two-phase stepper
motors using two or four adjacent TPU channels. Given a move request by the CPU, the TPU
independently accelerates, slews, and decelerates the motor to the desired position thus
relieving the CPU of almost all the overhead associated with controlling the motor. The
current motor position is maintained by the TPU as a 16-bit parameter that can be read by the
CPU at any time.
The CPU requests a move by writing a 16-bit desired position value and issuing a host service
request to the TPU. When the TPU has completed moving the motor to the desired position,
Freescale Semiconductor, Inc.
Functional Overview
Detailed Description
For More Information On This Product,
Go to: www.freescale.com

Related parts for AN2364

AN2364 Summary of contents

Page 1

... Freescale Semiconductor, Inc. Application Note AN2364/D Rev. 0, 10/2002 Using the Table Stepper Motor TPU Function (TSM) with the MPC500 Family Glann Jackson This TPU Programming Note is intended to provide simple C interface routines to the table stepper motor TPU function (TSM). The routines are targeted for the MPC500 family of TECD Applications devices, but they should be easy to use with any device that has a TPU ...

Page 2

Freescale Semiconductor, Inc. Local Table Mode it issues an interrupt request to the CPU - if the appropriate interrupt enable bit is set, then a CPU interrupt will result, allowing optional interrupt driven control. The algorithm employed in the TPU ...

Page 3

Freescale Semiconductor, Inc. 2.2 Split Table Mode In split table configuration, the acceleration parameter table is split between the parameter RAM of the slave channels and the contiguous block of parameter RAM in channels 14, 15, and 0 (see to ...

Page 4

Freescale Semiconductor, Inc. TSM Function Parameters Address Maps In both cases when the table size exceeds 48 parameters the remainder is obtained from the contiguous parameter RAM of channels 14, 15, and 0, starting in the lower byte of parameter ...

Page 5

Freescale Semiconductor, Inc. 0 $YFFFW0 $YFFFW2 TABLE_SIZE $YFFFW4 $YFFFW6 $YFFFW8 $YFFFWA $YFFFWC $YFFFWE W = Channel Number Figure 1. Master Channel Parameter Assignment—All Modes Figure 1 shows the parameter RAM assignment used by the TSM function for the various modes ...

Page 6

Freescale Semiconductor, Inc. TSM Function Parameters Address Maps 0 $YFFF(W+1)0 $YFFF(W+1)2 $YFFF(W+1)4 $YFFF(W+1)6 $YFFF(W+1)8 $YFFF(W+1)A $YFFF(W+1)C $YFFF(W+1)E $YFFF(W+2)0 $YFFF(W+2)2 $YFFF(W+2)4 $YFFF(W+2)6 $YFFF(W+2)8 $YFFF(W+2)A $YFFF(W+2)C $YFFF(W+2)E $YFFF(W+3)0 $YFFF(W+3)2 $YFFF(W+3)4 $YFFF(W+3)6 $YFFF(W+3)8 $YFFF(W+3)A $YFFF(W+3)C $YFFF(W+3 Master Channel Number Figure 2. ...

Page 7

Freescale Semiconductor, Inc. 0 $YFFF(W+1)0 ACCEL_RATIO_2 ACCEL_RATIO_4 $YFFF(W+1)2 $YFFF(W+1)4 ACCEL_RATIO_6 $YFFF(W+1)6 ACCEL_RATIO_8 $YFFF(W+1)8 ACCEL_RATIO_10 $YFFF(W+1)A ACCEL_RATIO_12 $YFFF(W+1)C ACCEL_RATIO_14 ACCEL_RATIO_16 $YFFF(W+1)E ACCEL_RATIO_18 $YFFFE0 ACCEL_RATIO_20 $YFFFE2 ACCEL_RATIO_22 $YFFFE4 ACCEL_RATIO_24 $YFFFE6 ACCEL_RATIO_26 $YFFFE8 ACCEL_RATIO_28 $YFFFEA ACCEL_RATIO_30 $YFFFEC ACCEL_RATIO_32 $YFFFEE $YFFFF0 ACCEL_RATIO_34 ACCEL_RATIO_36 $YFFFF2 ...

Page 8

Freescale Semiconductor, Inc. TSM Function Parameters Address Maps 0 $YFFF(W+1)0 ACCEL_RATIO_2 ACCEL_RATIO_4 $YFFF(W+1)2 $YFFF(W+1)4 ACCEL_RATIO_6 $YFFF(W+1)6 ACCEL_RATIO_8 $YFFF(W+1)8 ACCEL_RATIO_10 $YFFF(W+1)A ACCEL_RATIO_12 $YFFF(W+1)C ACCEL_RATIO_14 $YFFF(W+1)E ACCEL_RATIO_16 ACCEL_RATIO_18 $YFFF(W+2)0 ACCEL_RATIO_20 $YFFF(W+2)2 ACCEL_RATIO_22 $YFFF(W+2)4 ACCEL_RATIO_24 $YFFF(W+2)6 ACCEL_RATIO_26 $YFFF(W+2)8 ACCEL_RATIO_28 $YFFF(W+2)A $YFFF(W+2)C ACCEL_RATIO_30 ACCEL_RATIO_32 ...

Page 9

Freescale Semiconductor, Inc. 4.1.1 DESIRED_POSITION This 16-bit parameter contains the desired position (destination) of the stepper motor. The CPU can write DESIRED_POSITION at any time. If the motor is not already moving, then a host service request (HSR) type %11 ...

Page 10

Freescale Semiconductor, Inc. TSM Function Parameters Address Maps 4.1.7 BIT_A This control bit determines whether two or four TPU channels are used by the TSM function. If BIT_A = 0 then two channels are used (master plus one slave) and ...

Page 11

Freescale Semiconductor, Inc. 4.1.11 HSQ0 Host sequence bit 0 on the master channel is used to select the type of acceleration parameter table. If HSQ0 = 0, then the local table configuration is selected. If HSQ0 = 1, the split ...

Page 12

Freescale Semiconductor, Inc. TSM Function Parameters Address Maps CIER - Channel Interrupt Enable Register CH15 CH14 CH13 CH12 CH11 CH10 CH9 CFSR[0:3] - Channel Function Select Registers CFS(CH15, 11, 7, ...

Page 13

Freescale Semiconductor, Inc. TSM Function Parameters Address Maps HSSR[0:1] - Host Service Request Registers CH15, 7 CH14, 6 CH13, 5 CH[15: The Host Service Request Registers control the changes on the ...

Page 14

Freescale Semiconductor, Inc. TSM Function Parameters Address Maps 6 Configuration of TSM Function The CPU configures the TSM function as follows. For configuration of the overall operation of the TPU module, such as prescaler selection etc., refer to the TPU ...

Page 15

Freescale Semiconductor, Inc. void tpu_tsm_init The TPU will then accelerate, slew, and decelerate the motor to the desired position, issuing an interrupt request to the CPU when the move is complete. If the master channel interrupt enable bit is set, ...

Page 16

Freescale Semiconductor, Inc. void tpu_tsm_mov • start_position -- This is a 16-bit integer which establishes the initial value for both the DESIRED_POSITION and the CURRENT_POSITION. This is efficient since both values need to be set to the same value when ...

Page 17

Freescale Semiconductor, Inc. UINT16 tpu_tsm_rd_dp 7.3 UINT16 tpu_tsm_rd_dp This routine will read the value of the DESIRED_POSITION. This value is used for program control when compared against some other value. • *tpu -- This is the pointer to the TPU ...

Page 18

Freescale Semiconductor, Inc. INT tpu_tsm_int_chk 7.7 INT tpu_tsm_int_chk This routine will read the value of the active interrupt channel in the CISR register. This value is compared to the input channel to determine a match. A match confirms that the ...

Page 19

Freescale Semiconductor, Inc. Generating Step Patterns Table 3. Table Stepper Motor Function—State Timing State Number and Name S1 -- TSM_INIT_LO S2 -- TSM_INIT_HI S3 -- TSM_MOVE_REQ 2 channel mode 4 channel mode Already stepping S4 -- TSM_STEP_MATCH 2 channel mode ...

Page 20

Freescale Semiconductor, Inc. Generating Step Patterns INITIAL PIN_SEQUENCE PIN_SEQUENCE FOR FIRST STEP INITIAL CONDITION MASTER SLAVE STEP NUMBER INITIAL PIN_SEQUENCE PIN_SEQUENCE FOR FIRST STEP INITIAL CONDITION MASTER SLAVE STEP NUMBER Figure 6. Two-Channel Mode—Full Step Generation In half-step four-channel mode ...

Page 21

Freescale Semiconductor, Inc. Generating Step Patterns During initialization an HSR request is issued to each TSM channel to configure the initial pin level. The HSR type issued to each channel should match the value of the corresponding channel bit in ...

Page 22

Freescale Semiconductor, Inc. Generating Step Patterns . INITIAL PIN_SEQUENCE PIN_SEQUENCE FOR FIRST STEP INITIAL CONDITION MASTER SLAVE 1 SLAVE 2 SLAVE 3 STEP NUMBER 0 INITIAL PIN_SEQUENCE PIN_SEQUENCE FOR FIRST STEP INITIAL CONDITION MASTER SLAVE 1 SLAVE 2 SLAVE 3 ...

Page 23

Freescale Semiconductor, Inc. Simple A -> B move request 9 TSM Positioning Algorithm This section is designed to give an overview of the positioning algorithm employed by the TSM function. It provides all the detail necessary to understand the normal ...

Page 24

Freescale Semiconductor, Inc. Changing DESIRED_POSITION in Mid-Move 9.2 Changing DESIRED_POSITION in Mid-Move Because DESIRED_POSITION is re-evaluated against CURRENT_POSITION after every step, DESIRED_POSITION can be changed by the CPU at any time during a move. This feature is particularly important for ...

Page 25

Freescale Semiconductor, Inc. Changing DESIRED_POSITION in Mid-Move A) New_D_P same direction as Old_D_P but farther away —2 examples Step Rate C_D_P Old_D_P B) New_D_P same direction as Old_D_P but closer -- 2 examples Step Rate C_D_P New_D_P C) New_D_P opposite ...

Page 26

Freescale Semiconductor, Inc. Use of the SLEW_PERIOD Parameter 9.3 Use of the SLEW_PERIOD Parameter The slew period parameter allows the minimum step period of the motor (and therefore its terminal speed specified exactly in TCR1 counts, independently of ...

Page 27

Freescale Semiconductor, Inc. tpu_tsm.c /*************************************************************/ /* Begin TPU Initialization /*************************************************************/ /******************************************************************************* FUNCTION : tpu_tsm_init PURPOSE : To initialize channels to run the TSM function. INPUTS NOTES : This function has 13 parameters: *tpu - This is a pointer to the ...

Page 28

Freescale Semiconductor, Inc. tpu_tsm Declare variables for channel designations */ int master_channel; int param1_channel; int param2_channel; int param3_channel; UINT8 pchannel; UINT8 param; UINT8 i; /* Establish channels used for TSM function */ /* set channel values to other ...

Page 29

Freescale Semiconductor, Inc. tpu_tsm.c pchannel = param1_channel; param = 0; for (i=0; i<table_size; i++){ tpu->PARM.R[pchannel][param++] = *table++; if (param == 8){ param = 0; pchannel++; if (pchannel == 16) pchannel = -initial DESIRED_POSITION and CURRENT_POSITION will ...

Page 30

Freescale Semiconductor, Inc. tpu_tsm.c tpu_hsr(tpu, param2_channel, TPU_TSM_INIT_LO); } if(number_channels > tpu_hsr(tpu, param3_channel, TPU_TSM_INIT_LO Enable channels by assigning a priority to them All Channels MUST have the same priority. tpu_enable(tpu, master_channel, priority); tpu_enable(tpu, param1_channel, priority); ...

Page 31

Freescale Semiconductor, Inc. tpu_tsm.c /* Issue a move request to the host service request (master channel:HSR=0x11) */ tpu_hsr(tpu, channel, TPU_TSM_HSR_MOV); }; /******************************************************************************* FUNCTION : tpu_tsm_rd_dp PURPOSE : To read the desired position. INPUTS NOTES : This function has 2 parameters: ...

Page 32

Freescale Semiconductor, Inc. tpu_tsm.c /***************************************************/ /* Generate Interrupt tasks for the TSM interrupt. */ /***************************************************/ /******************************************************************************* FUNCTION : tpu_tsm_int_lev PURPOSE : To program the level of interrupt from the TPU-TSM function. INPUTS NOTES : This function has 2 parameters: *tpu ...

Page 33

Freescale Semiconductor, Inc. tpu_tsm.c type TPU3_tag which is defined in m_tpu3.h channel - The master channel. RETURNS : Returns the value TRUE (1) or FALSE ( UINT8. GENERAL NOTES : Level must be incoded according to the SIPEND ...

Page 34

Freescale Semiconductor, Inc. tpu_tsm.c master_chan - The channel (0 to 15) to convert to encodeding for the 16-bit TPU CIER, or CISR register. GENERAL NOTES : master_chan integer input is returned as a UINT16 value for the TPU CIER and ...

Page 35

Freescale Semiconductor, Inc. tpu_tsm.h /* which the failure of the Motorola product /* personal injury or death may occur. Should Buyer purchase or use Motorola */ /* products for any such intended /* indemnify and hold Motorola /* affiliates, and ...

Page 36

Freescale Semiconductor, Inc. tpu_tsm.h /* Define the maximum parameter table size */ /*#define TABLE_X 3 Table x value /*#define TABLE_Y 8 Table y value /* Define HSQ values */ #define TPU_TSM_LOCAL_ACC_TBL 0x0 #define TPU_TSM_SPLIT_ACC_TBL 0x1 #define TPU_TSM_ROTATE_ONCE 0x0 #define TPU_TSM_ROTATE_TWICE ...

Page 37

Freescale Semiconductor, Inc. tpu_tsm.h #define TSM_INT_LEVEL1 0x10000000 #define TSM_INT_LEVEL2 0x04000000 #define TSM_INT_LEVEL3 0x01000000 #define TSM_INT_LEVEL4 0x00400000 #define TSM_INT_LEVEL5 0x00100000 #define TSM_INT_LEVEL6 0x00040000 #define TSM_INT_LEVEL7 0x00010000 */ /* Define TPU.CISR interrupt channel encodings /* #define TSM_CISR_INT_CHANNEL0 0x0001 #define TSM_CISR_INT_CHANNEL1 0x0002 #define ...

Page 38

Freescale Semiconductor, Inc. tpu_tsm_ex1.c void tpu_tsm_int_lev(struct TPU3_tag *tpu, UINT8 level); int tpu_tsm_int_chk(struct TPU3_tag *tpu, UINT16 channel); void tpu_tsm_cisr_clr(struct TPU3_tag *tpu, UINT16 CISR_level); #ifdef __cplusplus } #endif 10.3 tpu_tsm_ex1.c The developer should use this code as an example for calling the ...

Page 39

Freescale Semiconductor, Inc. tpu_tsm_ex1.c #include "mpc500.c" /* Configuration routines for MPC555 EVB, will need */ /* to be changed if other hardware is used. #include "mpc500_util.h" /* Utility routines for using MPC500 devices #include "tpu_tsm.h" /* TPU TSM functions */ ...

Page 40

Freescale Semiconductor, Inc. tpu_tsm_ex1.c /* Initialize Table Stepper Motor function with: /* -Input signal on TPU A, /* -master_channel = mas_channel /* -Schedule as high priority in the TPU /* -Initial desired position of 0x0010, /* -Initial current position of ...

Page 41

Freescale Semiconductor, Inc. tpu_tsm_ex1 Interrupt has occurred -- continue: /* Below are examples of control logic used in a TSM function Adapt this to your specific needs and controls. dp_val = tpu_tsm_rd_dp(tpua, mas_channel); cp_val = tpu_tsm_rd_cp(tpua, ...

Page 42

Freescale Semiconductor, Inc. tpu_tsm_ex1.c void Ext_Isr() { UINT16 mas_chan_cisr; mas_chan_cisr = tpu_tsm_mas_chan_cier(mas_channel); /* Check that the level of interrupt matches the TPU, TSM .*/ flag = (tpu_tsm_int_chk(tpua, mas_chan_cisr)); /* Force the clearance of the CISR register */ tpu_tsm_cisr_clr(tpua, mas_chan_cisr); } ...

Page 43

Freescale Semiconductor, Inc. tpu_tsm_ex1.c /* Set interupt enable to master channel CIER = master channel */ tpu_interrupt_enable( tpu, channel); /* Set the USIU mask to accept a level 2 interrupt */ USIU.SIMASK.R = sipend_int_level; /* Force the clearance of the ...

Page 44

... Motorola and the Stylized M Logo are registered in the U.S. Patent and Trademark Office. digital dna is a trademark of Motorola, Inc. All other product or service names are the property of their respective owners. Motorola, Inc Equal Opportunity/Affirmative Action Employer. © Motorola, Inc. 2002 AN2364/D For More Information On This Product, Go to: www.freescale.com ...

Related keywords