Application Note 32 Intelligent Stepper Motor (ISM) Function V850E2/Dx4 32-bit Microcontroller All information contained in these materials, including products and product specifications, represents information on the product at the time of publication and is subject to change by Renesas Electronics Corp. without notice. Please review the latest information published by Renesas Electronics Corp. through various means, including the Renesas Electronics Corp. website (http://www.renesas.com). www.
Notice 1. All information included in this document is current as of the date this document is issued. Such information, however, is subject to change without any prior notice. Before purchasing or using any Renesas Electronics products listed herein, please confirm the latest product information with a Renesas Electronics sales office. Also, please pay regular and careful attention to additional and different information to be disclosed by Renesas Electronics such as that disclosed through our website. 2.
The quality grade of each Renesas Electronics product is “Standard” unless otherwise expressly specified in a Renesas Electronics data sheets or data books, etc. “Standard”: Computers; office equipment; communications equipment; test and measurement equipment; audio and visual equipment; home electronic appliances; machine tools; personal electronic equipment; and industrial robots. “High Quality”: Transportation equipment (automobiles, trains, ships, etc.
12. This document may not be reproduced or duplicated, in any form, in whole or in part, without prior written consent of Renesas Electronics. 13. Please contact a Renesas Electronics sales office if you have any questions regarding the information contained in this document or Renesas Electronics products, or if you have any other inquiries. Notes 1. “Renesas Electronics” as used in this document means Renesas Electronics Corporation and also includes its majority-owned subsidiaries. 2.
General Precautions in the Handling of MPU/MCU Products The following usage notes are applicable to all MPU/MCU products from Renesas. For detailed usage notes on the products covered by this manual, refer to the relevant sections of the manual. If the descriptions under General Precautions in the Handling of MPU/MCU Products and in the body of the manual differ from each other, the description in the body of the manual takes precedence. 1.
Table of Contents General Precautions in the Handling of MPU/MCU Products ...... 5 Table of Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Chapter 1 Overview of ISM in the Dx4-H Series . . . . . . . . . . . . . . . . . 8 Chapter 2 General Notices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 2.1 2.2 Abbreviations in this Application Note . . . . . . . . . . . . . . . . . . . . . . . .
Table of Contents 6.2 Moving the Motors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 Chapter 7 7.1 The ZPD Measurement Principle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 The ZPD Function Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 7.2.1 7.2.2 7.3 37 Zero Point Detection (ZPD) Theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 7.1.1 7.
Chapter 1 Overview of ISM in the Dx4-H Series PWM Value RAM RAM_D RAM_C RAM_A THOUT1n, THEN1n, THOUT2n, THEN2n, TVOUT1n, TVEN1n, TVOUT2n, TVEN2n Prescaler TB_CLK PWM Value RAM Interface Table Entry Channel Timebase ADR MACRO_CLK ASSIGN_RAM 32 bits RAM Data 20 bits 6 APB Interface Channel Management (CM) CM Values Addr.
Chapter 2 General Notices 2.1 Abbreviations in this Application Note Typically, all variables and register settings are written by 3- or 4-letterabbreviations. These abbreviations can be identified within the User’s Manual by looking at the register and bit names of ISM, and skipping some common letters like “ISMxG” (for global settings), “ISMxC” (for channel related settings), “ISMxS/I/F” (for sign, integer and fraction of parameters and variables).
Chapter 2 General Notices 2.2.3 Functionality of GEN (Soft Reset) GEN is always set on Hardware RESET. By clearing the GEN flag by software, the ISM macro is forcibly reset by software. On this synchronous soft-reset, all internal state machines, processing (GCE is automatically cleared) and also PWM is stopped and forced to reset conditions. RAM contents, variables and parameters remain untouched, however. These can still be modified by software.
Chapter 3 About Stepper Motor Movement 3.1 The Physics of a Stepper Motor The Stepper Motor consists of a permanent magnet, which rotates within the magnetic fields of two coils. Figure 3-1 Stepper Motor Coil Connection By using two driver bridges (one for the horizontal coil, one for the vertical coil), both coils can be driven currents in both directions. Depending on the device hardware (port structures), either half-bridges or full-bridges are used.
Chapter 3 About Stepper Motor Movement The average amplitude of the magnetic field is determined by the PWM duty cycle, which is represented by the integration of the PWM along its period. Doing this for both coils, their forces are adding up (red and green components) to an angle .
Chapter 3 About Stepper Motor Movement 3.2 The PWM Generation of ISM Following a Prescaler (GTB), the central Time Base determines the PWM output of ISM; this means that all PWM outputs of ISM are having the same frequency and are all synchronous. In order to avoid that too many edges are occurring at the same time on several ports, each PWM output can be assigned to a delay, which is set in clocks of the central time base (CDVn and CDHn). The level of the PWM is in the range 0 ...
Chapter 3 About Stepper Motor Movement 3.2.1 ISM Clocking The clock of the central time base is selected by the prescaler, and it depends on the ISM Macro Clock (System Clock), which is set in the Clock Controller of the device. f macro f PWM = ---------------------------------------------------------------10 GTB Factor 2 – 1 3.2.
Chapter 3 About Stepper Motor Movement 3.3 Recirculation of Inductance Recirculation means performing a short-circuit on a stepper motor coil, during the low-phase of the attached PWM. During the high-phase of the PWM the output voltage drives a current through the coil, and during the low-phase, this current of the coil, which represents an amount of energy, can be discharged through the short-cut.
Chapter 3 About Stepper Motor Movement 3.4 The ISM Channel Circuitry As a summary of the previous chapters, a full detailed drawing of the circuitry of one stepper motor channel is shown below.
Chapter 4 Automated Motor Movement Within this chapter, more deep functional description about the processing of the Channel Management (CM) is given. In an overview, the functional blocks of the CM are looking like this: START Channel Enable Update Timebase Prescaler ZERO GUD IRQ_DONE Sequencer Soft Reset IRQ_REACHn 6 ZPD Counter CZC GEN_ ZPD_ CALC_ START INFO START Ch. Number n Ch. Number n CZCn ZPD Pointer Mode/Count.
Chapter 4 Automated Motor Movement 4.1 Processing of PWM (non-ZPD) Channels This is performed for all channels, which are enabled, and CZPn is cleared. On processing of a channel, first the Movement Calculator is started (CALC_START). This block calculates a new microstep value for horizontal and vertical PWM, and evaluates the current speed level and motor direction. Further, the macrostep value is calculated.
Chapter 4 Automated Motor Movement CZCn has reached the end of the table marked by ZPD table index limit CTLn, the counter CZCn is reset to zero again. Like this, each entry of the PWM Value RAM ZPD table may have an execution time of CZDn, which is a 5-bit value in counts of the frequency of START (the Update Timebase). Subsequent equal entries can be put into the table, in order to get longer delay times.
Chapter 4 Automated Motor Movement =3' 3URFHVVLQJ RI &KDQQHO Q 'HOD\ &='Q ! " 'HFUHPHQW &='Q <(6 (1' 12 =07Q =3' 0HDVXUH )ODJ 6HW " <(6 =$)Q =3' $FWLYH )ODJ 6HW" 12 12 <(6 =$)Q =3' $FWLYH )ODJ 6HW" 12 6HW =3' $FWLYH )ODJ =$)Q &OHDU =3' $FWLYH )ODJ =$)Q <(6 12 =,3Q =3' 'HWHFWLRQ )ODJ 6HW " <(6 &OHDU =3' 0RGH &=3Q &KDQQHO Q 8SGDWH &OHDU =3' &RXQWHU &=&Q DQG 'HOD\ &='Q ,QFUHPHQW &=&Q =07Q =3' 0HDVXUH )ODJ 6HW " &OHDU &KDQQHO (QDEOH &(1Q 12 ,54B5($&+Q <(6 <(6 =$)Q =3' $FWLYH
Chapter 4 Automated Motor Movement 4.
Chapter 5 Looking into the PWM and ZPD Tables 5.1 Virtual Channels As the PWM Value RAM is a lookup-table, it can also perform an abstraction of a physical channel (where the motor is attached to a port) into a logical or “virtual” channel. 3FFFH unused 1 kBytes One Entry 3C00H Data of Info Bus, dedicated Format Ch. Type 5 ZPD 32 Bits High Precision Per Channel Type, 2 kBytes Ch. Type 4 ZPD Standard Precision Ch.
Chapter 5 Looking into the PWM and ZPD Tables 5.2 Values for PWM Operation 5.2.1 Channels and Precision As can be seen from the RAM layout, for each virtual channel there are two tables: The “regular” PWM operation table and the ZPD table. Regarding the “regular” PWM operation table, there are two formats available, which can be selected by the CCPn flag. (1) High Precision Mode In high precision mode (CCPn set), for one turn of the motor the whole table section is used with 512 entries.
Chapter 5 Looking into the PWM and ZPD Tables 5.2.2 PWM Values In the ideal case, one would expect that the values of the PWM duty cycles are sine and cosine waveforms, if they are related to the microstep or the angle of the motor anchor. This assumes, that the force relations inside of the motor are ideal, that the forces can be added and that the forces of the horizontal and vertical coils are rectangular to each other. This is what is explained in the theory, as shown in 3.
Chapter 5 Looking into the PWM and ZPD Tables (1) Example of a Sine - Cosine Sequence PWM Table When writing PWM tables into the PWM Value RAM, a standard table for a quick start could look like the following table. For different speed levels and directions, the same table can be used. This table is “right turning”, because the sequence of quadrants is 4, 3, 2, 1. The used access type is shown in advance of the table. /*............... ISM PWM RAM access structures ..................
Chapter 5 Looking into the PWM and ZPD Tables { { { { { 0x3E0L, 0x3EBL, 0x3F3L, 0x3FAL, 0x3FDL, 0x0F8L, 0x0C7L, 0x096L, 0x064L, 0x032L, 0x3L, 0x3L, 0x3L, 0x3L, 0x3L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L 0L 0L 0L 0L }, }, }, }, }, { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { 0x3FFL, 0x3FDL, 0x3FAL, 0x3F3L, 0x3EBL, 0x3E0L, 0x3D2L, 0x3C3L, 0x3B1L, 0x39CL, 0x386L, 0x36DL, 0x352L, 0x335L, 0x316L, 0x2F5L, 0x2D3L, 0x2AFL, 0x288L, 0x261L, 0x238L, 0x20DL, 0x1E2L, 0x1B5L, 0x187L, 0x
Chapter 5 Looking into the PWM and ZPD Tables { 0x3FDL, 0x032L, 0x1L, 1L, 1L, 0L }, { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { ...
Chapter 5 Looking into the PWM and ZPD Tables 5.3 Values for ZPD Operation 5.3.1 Addressing in ZPD Mode When in ZPD mode for a channel, the addressing range for this channel is changed to the ZPD table sections of the PWM Value RAM. 1 CCTn (000B ... 101B) 1 ZPD Table Range Code Figure 5-5 Bits 8 ... 2 Channel Settings A1 CZCn[6:0] from Sequencer A0 Always zero ZPD Table Addressing Layout Again, the virtual channel number is used to select a ZPD table in general.
Chapter 6 Performing Movements Within this section, the movement of stepper motors using the Channel Management and the Movement Calculator is discussed. Operation with Zero Point Detection can be found in Chapter 7 “Performing Zero Point Detection” on page 37 . 6.1 Parameters and Variables In order to understand the automated movement of a stepper motor by ISM, the knowledge about its parameters and variables is essential.
Chapter 6 Performing Movements Table 6-2 Variables of the Movement Calculator Abbreviation / Bit Name Width / Bits Register Name Actual Acceleration / Deceleration VAX 25 ISMxVAR0CFGn Actual Speed VAS 25 ISMxVAR1CFGn Previous Iteration Speed VPS 25 ISMxVAR2CFGn Temporary Calculator Register PT1 VPT 25 ISMxVAR3CFGn Actual Position, Current Result VAP 25 ISMxVAR4CFGn Virtually Displayed Position VVP 25 ISMxVAR5CFGn Direction Flag VDR 1 ISMxVAR6CFGn Speed Flag VSP 1 ISMxVAR7
Chapter 6 Performing Movements (2) Value Integer For position values, the value integer consists of the macrosteps and the microsteps. Depending on the precision setting of a channel (CCPn), either 9 or 7 bits are reserved for the microsteps, and the remaining bits up to bit 23 are used for the macrosteps. (3) Value Binary Fraction This part represents the fractional part of the value. Its binary step is 1/256 of the value integer. The binary fraction is used for internal calculations only.
Chapter 6 Performing Movements (3) Acceleration Limit, Deceleration Limit PALn, PDLn If acceleration or deceleration of the motor would become larger than these limits, acceleration or deceleration is set to these values. After a new speed has been calculated, the algorithm determines the corresponding acceleration/ decelerations and by case, it limits the speed, so that the acceleration and deceleration limits cannot be crossed.
Chapter 6 Performing Movements 6.1.3 Variable Description (1) Actual Algorithm Values VAXn, VASn, VAPn These values are representing the current Movement Calculator results for the physical channel n. Acceleration, speed and position values have to be interpreted like their associated parameter values. Checking the values is possible anytime to monitor the movements by software.
Chapter 6 Performing Movements } } if ( VAS >= 0 ) { if ( VAS > PMS ) { VAS = PMS } } else { if ( ( -VAS ) > PMS ) { VAS = ( - PMS ) } } /* Result output for Microstep & store old speed */ VAP VPS = = VAP + VAS VAS /* Calculate SW displayed position */ if ( ( VAP - VVP ) > PHC ) { VVP = VAP - PHC } if ( ( VAP - VVP ) < ( - PHC ) ) { VVP = VAP + PHC } /* Select Table according to speed and direction */ if ( VAS > 0 ) { VDR = 0 if ( ( VAS <= PS1 ) or ( VAS >= PS2 ) ) { VSP = 0 } else { VSP = VSP } if( ( V
Chapter 6 Performing Movements VSP = 0 } else { VSP = VSP } if ( ( ( -VAS ) >= PS3 ) and( ( -VAS ) <= PS4 ) ) { VSP = 1 } else { VSP = VSP } } } if ( VAS == 0 ) { VSP = 0 } /* Negative Position suppression */ if ( VAP < 0 ) { VAP = 0 } R01AN0168ED0101 Rev. 01.
Chapter 6 Performing Movements 6.2 Moving the Motors Having all parameters set, the timebases defined and the RAM PWM tables set up, the motor movement can be started by activating the Channel Management for the selected channels. Caution When using stepper motor hardware, always enable Recirculation. Otherwise, caused by the inductive load, damage to the output drivers may happen. The following diagram shows a movement graphically, by reading out the variables by software.
Chapter 7 Performing Zero Point Detection 7.1 Zero Point Detection (ZPD) Theory In order to define the ZPD table entries, base knowledge about zero point detection is required. Let’s have a look into a simplified stepper motor. In the following figure, four steps of movement are shown, one for each quadrant of the motor’s anchor. Within each quadrant, it is possible to detect, whether the motor could move, or whether it had hit its mechanical stop, and therefore, it could not move.
Chapter 7 Performing Zero Point Detection 7.1.1 The ZPD Measurement Principle For all 4 cases, the same measurement principle is applied: An analogue measurement of induced voltage is performed, while the other coil moves the anchor. If the anchor is still able to move, it will cause a small voltage induction in the measurement coil. If the motor has hit the mechanical stop, the anchor will almost not move any longer, and the induced voltage will decrease or disappear.
Chapter 7 Performing Zero Point Detection Zero Point not yet reached Zero Point reached Reference Level Figure 7-3 Reaching the Zero Point In the best case, the induced voltage is slightly below the selected analogue reference level, when the ZP is reached. If this is not the case, the reference level should be selected such, that it is by one selection step lower than the induced voltage, even if the ZP is reached.
Chapter 7 Performing Zero Point Detection Detect this with the Digital Filter Reference Level: 450 mV Blanking Time: 800 µs Measurement Time: 14 ms Figure 7-4 (4) Using the Blanking Time Definition of the Measurement Window using the ZPD Table As the ZPD table itself is a timed execution list, all timing can be derived from it, as long as the timing requirement is within the precision of the ZPD table execution (this depends on the GUD setting).
Chapter 7 Performing Zero Point Detection (5) Setting up the Digital Filter of ZPD The digital filter of the ZPD function of ISM has a maximum depth of 16 measurements. After each measurement phase, the digital filter compares the amount of measurement results, which have been above the reference level, against its filter level. If the level is less than this amount, the digital filter indicates a “one”, which is equal to a filtered signal above the reference level.
Chapter 7 Performing Zero Point Detection In most cases, the reference level on its own is enough to detect the ZP clearly. Then, the digital filter can be generally disabled by setting depth and level to 1. The digital filter is an additonal aid for detection in difficult cases. Note 7.2 The ZPD Function Settings 7.2.1 Analogue Hardware of ZPD Attached to ISM, there is a quite sophisticated set of analogue hardware beside it.
Chapter 7 Performing Zero Point Detection For each channel, one of its four ports can be assigned by ZISn for the measurement input of its individual analogue comparator. Common to all comparators are two selectable and adjustable reference sources GRV, which are defining the two different reference levels that can be assigned by ZRSn. Behind this analogue stuff, the digital filters are attached, one for each channel with common settings GFLn and GFDn. 7.2.
Chapter 7 Performing Zero Point Detection required. So, we choose GZF to be 14 (factor 1/512), and we are running a little bit faster. 2. Having four Measurement Cycles in the measurement window – We select to use a GCS delay of 1, and a filter depth GFD of 3. This yields an amount of 4 prescaled clocks of ZPD for each Measurement Cycle. – For GZF, the settings will be the same as above. (2) Further Strategy Recommendations for the ZPD Measurements 1.
Chapter 7 Performing Zero Point Detection 7.3 ZPD Operation The ZPD operation for a channel can be individually started, if the following prerequisites are fulfilled: 1. Channel Management is activated for this physical channel (GEN, CENn). 2. The virtual channel for the physical channel n is selected (CCTn). 3. The ZPD table is defined for the used virtual channel (CTLn). 4. The analogue hardware is initialized and linked to ISM (GZE, GZP, GZL). 5.
Chapter 7 Performing Zero Point Detection 7.3.1 Using Direct I/O Control When performing ZPD, it is often mandatory to perform special settings on the port outputs to the stepper motors, like creating short-cuts, keeping the measured end of a coil open, or driving current through the motor permanently. To allow to do these kind of things, the Direct I/O Control function is available. It is activated by the flags IHEn and IVEn.
Chapter 7 Performing Zero Point Detection 7.3.2 Executing a ZPD Table The following illustration shows, how a ZPD table is executed and how this propagates to the virtual transistors and motor outputs.
Chapter 7 Performing Zero Point Detection The following chapters are referring to the steps indicated within Figure 7-10 “Executing a ZPD Table” on page 47 . (1) Rotating the Anchor to 0° Assuming that we are in Quadrant 0, the anchor is set to a horizontal direction by applying 100% PWM for horizontal and 0% PWM for vertical. (2) Rotating the Anchor to 270° (approaching the Measurement Position) A right turn of -90° is performed by applying 100% vertical PWM and 0% horizontal PWM in Quadrant 3.
Revision History The table below gives an overview about the revision history of this document. Rev. Date Summary 01.00 Aug 30, 2010 first edition. 01.01 Feb 13, 2012 updated figure external references. R01AN0168ED0101 Rev. 01.
V850E2/Dx4 Application Note Publication Date: Rev. 01.
http://www.renesas.com SALES OFFICES Refer to "http://www.renesas.com/" for the latest and detailed information. Renesas Electronics America Inc. 2880 Scott Boulevard Santa Clara, CA 95050-2554, U.S.A. Tel: +1-408-588-6000, Fax: +1-408-588-6130 Renesas Electronics Canada Limited 1101 Nicholson Road, Newmarket, Ontario L3Y 9C3, Canada Tel: +1-905-898-5441, Fax: +1-905-898-3220 Renesas Electronics Europe Limited Dukes Meadow, Millboard Road, Bourne End, Buckinghamshire, SL8 5FH, U.
V850E2/Dx4 R01AN0168ED0101