USER MANUAL YROTATE-IT-RX23T Rotate it! - Motor Control RX23T UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Introduction The Renesas Motor Control Kit called YROTATE-IT-RX23T, is based on the RX23T device from the powerful 32-bit RX microcontrollers family running at 40MHz and delivering up to 80DMIPs. The kit enables engineers to easily test and evaluate the performance of the RX23T in a laboratory environment when driving any 3-phase Permanent Magnet Synchronous Motor (e.g. AC Brushless Motor) using an advanced sensorless Field Oriented Control algorithm. Typical applications for this type of solution are compressors, air conditioning, fans, air extractors, pumps, home appliances inverters and industrial drives. The phase current measurement is done via three shunts which offers a low cost solution, avoiding the need for an expensive current sensor or hall sensor. A single shunt current reading method is also available to ensure an even more compacter bill of material. The powerful user-friendly PC Graphical User Interface (GUI) gives real time access to key motor performance parameters and provides a unique motor auto-tuning facility. Furthermore, it becomes also possible to select the best switching frequency and control frequency (e.g. control loop) to adapt the control dynamics suitable to the application requirements. The hardware is designed for easy access to key system test points and for the ability to hook up to an RX23T debugger known as E1. Although the board is normally powered directly from the USB port of a Host PC, connectors are provided to utilise external power supplies where required. The YROTATE-IT-RX23T is an ideal tool to check out all the key performance parameters of your selected motor, before embarking on a final end application system design. Target Device: RX23T Microcontrollers Family UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 1 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit Contents 1. Specifications & Hardware overview ....................................................................................................... 3 2. Connectors description ............................................................................................................................. 7 3. Power supply selection ............................................................................................................................. 8 4. LEDs functions description ...................................................................................................................... 10 5. Test points for debugging ...................................................................................................................... 11 6. Internal power stage description ........................................................................................................... 12 7. Current reading methods selection ........................................................................................................ 14 8. Interface to an external power stage ..................................................................................................... 16 9. Single shunt current reading .................................................................................................................. 20 10. Current reading timing in three shunts and single shunt configurations ............................................. 21 11. Website material: www.renesas.eu/motorcontrol .............................................................................. 24 12. Microcontroller RX23T short overview ................................................................................................. 25 13. Permanent Magnets Brushless Motor model ....................................................................................... 27 14. Sensorless Field Oriented Control algorithm ........................................................................................ 32 15. Software Tools used ............................................................................................................................. 33 16. Software description and Resources used ............................................................................................ 37 17. Start-up procedure - Embedded software ........................................................................................... 44 18. Reference system transformations in details ....................................................................................... 46 19. Rotor position estimation..................................................................................................................... 47 20. PC Graphical User Interface in details .................................................................................................. 50 21. EEPROM parameters: detailed description .......................................................................................... 56 22. Motor Auto-calibration using the PC GUI ............................................................................................. 57 23. Updating the RX23T Flash memory using the Renesas Programming Flash Tool ................................. 68 24. Integration of user code to the motor control algorithm ..................................................................... 73 25. Communication Protocol between the MCU and the PC GUI ............................................................... 74 UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 2 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit 1. Specifications & Hardware overview ITEM TYPE OF MOTORS SUPPORTED SPECIFICATIONS 3-phase Permanent Magnet Synchronous (PMSM, PMAC, BLAC) 3-phase Brushless DC (BLDC) KIT MOTOR PARTNAME NANOTEC DB42S03, 24VDC, 4000 RPM KIT MAX INPUT RANGE External power supply from: 20VDC to 48VDC, 6Apeak TRANSISTOR USED Renesas Mosfets: RJK0654DPB, 60V, 30A POWER SUPPLY OPTION Either USB connection or external supply: up to 48VDC CURRENT DETECTION One or three shunts configuration (10m) USB IC USED ON THE BOARD FT232R - USB UART IC from FDTI, 76.6KBd communication speed MICROCONTROLLER RX23T (R5F523T5ADFM), 64-pin LFQFP, 40MHz, 64KB Flash, 10KB RAM MCU PERFORMANCE 40MHz, 80DMIPs, 166 CoreMark KEY FEATURES Floating Point Unit, 3-phase inverter Timer 12-bit A/D Converter, fast on-chip Comparators, Port Output Enable MCU EMBEDDED FIRMWARE Sensorless vector control algorithm (Field Oriented Control) SWITCHING FREQUENCY 4KHz to 64KHz, 16KHz by default (PWM frequency) CONTROL LOOP FREQUENCY (SAMPLING FREQUENCY) 4KHz to 16KHz, 8KHz by default CONTROL LOOP TIMING 50s including debug features and auto-tuning/self-identification 40s including only the sensorless vector control algorithm CODE SIZE IN FLASH / RAM 24KB / 3KB TOOL USED, VERSION estudio 4.0.2.008. , CS+ , RXC Toolchain, CC RX version v2.03.00 COMPILER OPTIMIZATION LEVEL Maximum, optimize for speed, little-endian data, RX V2 Core enable ENVIRONMENT STANDARDS RoHS compliant including China regulations WEEE, RoHS UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 3 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit The inverter kit YROTATE-IT-RX23T is a single board inverter, based on the 32-bit RX series microcontroller RX23T and includes a low-voltage MOSFETs power stage and a communication stage. The PCB is a four layers board and ensure the management of Permanent Magnet Motors up to 48VDC and up to 6Amax. Please find below the content of the YROTATE-IT-RX23T kit: To obtain the maximum flexibility, the inverter reference kit includes: * A complete 3-phase inverter on-board with a low voltage motor, so it becomes easy to test the powerful sensorless algorithm running on the Renesas 32-bit RX23T microcontroller (e.g. MCU). * An insulated USB communication with the PC offering communication speed up to 76.6KBd. * Connectors for hall sensors and encoder connections. Both encoder and hall sensors are not managed in the sensorless software but they can be supported under request. * Compatibility with the existing Motor Control Reference Platform external power stages, the first delivering up to 1.5KW at 230VAC and the second up to 60VDC, 60ADC. * USB power supply possibility to avoid external power supplies where galvanic insulation is lost. UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 4 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit To achieve these aims, three different DC-DC converters are used: 1. A step-up DC-DC converter to increase the voltage from the USB standard (5V) up to 13.5VDC 2. A step-down converter and a low dropout linear converter, from the DC bus first to 15V and then to the CPU supply voltage: 5V, please find below the PCB overview. SUPPLY INPUT LOW VOLTAGE POWER STAGE STEP-DOWN LINEAR REGULATOR FOR 5V SUPPLY CONTROL STAGE OPTIONAL ZIGBEE MODULE EXTERNAL POWER STAGE INTERFACE INSULATION STEP_UP HALL, ENCODER, ANALOG INPUT COMMUNICATION ZIGBEE/MCU programming or GUI communication selection The full schematics and CAD design files (e.g. Gerber) of the inverter kit are available on the website: www.renesas.eu/motorcontrol , in the section related to the YROTATE-IT-RX23T development kit. In the YROTATE-IT-RX23T kit, the RX23T in a 64-pin package was selected to ensure the management of inverter, external communications, three shunts, the EEPROM communication, the E1 debugger, three voltages phases, the over-current detection, the Bus voltage monitoring, etc. The picture below is showing the detailed I/O pins assignment of the RX23T to manage the complete kit. UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 5 of 83 RX23T UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 YROTATE-IT-RX23T Motor Control Kit Page 6 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit 2. Connectors description As in the following figure, you can find the position and the description of the connectors present on the board. Please refer to the board schematics for the full description of the connectors. The E1 connector is used for the programming and the debugging of the software running on the RX23T. It can be connected either to the E2studio and the CS+ development environments. The external power stage connector is compatible with the power stages, designed for Renesas inverter kits, which are able, the first one to drive 230VAC motor up to 1.5KW, and the second one up to 60VDC, 60ADC. The schematics and Gerber file of the power stage are available on the website: www.renesas.eu/motorcontrol MOTOR CONNECTOR EXTERNAL POWER SUPPLY CONNECTORS PMODE CONNECTOR CONNECTOR FOR ICS OSCILLOSCOPE E1 CONNECTOR EXTERNAL POWER STAGE CONNECTOR USB CONNECTOR HALL CONNECTOR ENCODER CONNECTOR ANALOG INPUT CONNECTOR UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 7 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit 3. Power supply selection As stated before, there are two ways to supply power to the board. 1. The first possibility is to use directly the PC USB supply. In this case the current you can give to the motor is limited by the USB current capabilities. 2. The second possibility is to use an external voltage DC source to supply the board. The recommended power supply voltage is between 20VDC to 48VDC. In this case the communication stage is insulated from the inverter. The selection between the two possibilities is made through two jumpers: JP1 and JP2. Please find below the description: JP1, JP2 JP2 17 37 47 67 JP1 17 37 47 67 PC USB SUPPLY SELECTION JP2 17 37 47 67 JP1 17 37 47 67 EXTERNAL SUPPLY SELECTION UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 8 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit 1) The first jumper configuration connects the USB ground to the inverter ground and the output of the step-up converter to the inverter DC link. Please notice that in this case there is no galvanic insulation between the device connected to the USB and the board. 2) The second jumper configuration connects the external power supply ground to the inverter ground and the external + VDC to the inverter DC link. Please find below the configuration of the RX23T kit using the internal MOSFETs power stage. Please find below the configuration of the RX23T kit connected to the external 1.5KW, 230VAC power stage. Microcontroller board + external power stage board: Power supply +24VDC from J4 or J5 of the power stage UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Power stage jumper JP1: correct position Page 9 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit 4. LEDs functions description Some of the LEDs available on the board are directly connected to the hardware and allow the user to understand the status of the board. Please refer to the LED map for the following indications: * DL4 is connected to the output of the 15V step-down DC-DC converter and indicates the presence of the switches drive supply; * DL5 is connected to the output of the 5V linear converter and indicates the presence of the 5V logic power supply. DL4 DL5 DL3 DL2 DL1 Other LEDs in the board are driven via software, in particular: * DL1 is the USB communication indicator and blinks when there are data exchanges between the PC and the board. * DL2 is blinking slowly if the control section of the RX23T microcontroller is running normally. In case of hardware or software alarms, the LED DL3 is blinking quickly. * DL3 is free for the user and in the default software it is ON when the main control interrupt is active. It give to the user a quick and simple way to measure the timing of the control loop of the algorithm. UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 10 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit 5. Test points for debugging Several specific test points are available on the board to visualize with the oscilloscope the behaviour of some internal analog signals. Furthermore, it is possible to visualize internal variables as analog waveforms using filtered PWM outputs. Finally, it is very useful during the tuning process for adapting the software to a new motor to use the test points. TP6, TP5, TP4 TP9, TP8, TP7 TP18, TP17, TP12, TP1, TP3 TP19, TP10, TP11, TP15, TP16 TP13, TP14 TP2 Please find below the description of the test points: * TP13, TP14: are connected to the two USB communication signals, for debug purposes. Please refer to the board schematics for more details. * TP4, TP5, and TP6: they are connected to the three inverter outputs (sources of the higher switches) * TP7, TP8, and TP9: they are connected to the sources of the lower switches of the inverter * TP1, TP3, TP12, TP15, TP16: they are connected to some microcontroller ports * TP17, TP18, TP19 are connected to the board GND * TP10, TP11 are two filtered PWM outputs which can be used to visualize the behaviour of internal variables * TP2 not used UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 11 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit 6. Internal power stage description The power stage is a complete 3-phase bridge composed with discrete low voltage and high current MOSFETs. The MOSFETs are the Renesas RJK0654DPB n-channel power MOSFETs. Please refer to the data-sheet available on the Renesas website: www.renesas.eu for the switches characteristics and to the board schematics for the details on the driving circuit. The maximum current is 30A, and the maximum voltage is 60VDC. 3 PHASES BRIDGE CURRENT READING SHUNTS The inverter has the classical schema with the three shunts on the lower arms, with the possibility to use a single shunt by removing two of them. UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 12 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit Please find below the schematics extract showing the draying in mode details. Furthermore, the three driving circuits for the six low voltage MOSFETS RJK0654DPB are described below. Furthermore, the signals from the gate driver circuits called "PUL, PVL, PWL" are used to manage the risk of overcurrent in the board. The signals are directly linked to the RX23T Microcontroller module called the Port Output Enable (e.g. POE) to stop the PWM signal in hardware and protect the 3-phase power stage. In case of over-current, the POE module will set in hardware the six PWM signals in high impedance mode to ensure safe-fail mechanism. Please find below the extract of the schematics regarding the over-current management. UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 13 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit 7. Current reading methods selection As shown in the following figure, some jumpers are placed on the board (see schematics): JP7, JP17, JP18, JP8, JP19, JP20, JP9, JP21 and JP22. The jumpers allows the reading of the motor current by using external operational amplifiers or internal one as shown here below: * Configuration 1: external op. amp.: JP7, JP8, JP8 closed, JP17, JP18, JP19, JP20, JP21, JP22 open * Configuration 2: internal op. amp.: JP7, JP8, JP8 open, JP17, JP18, JP19, JP20, JP21, JP22 closed NOTE: the RX23T microcontroller family is not equipped with internal operational amplifiers. But the RX24T family is equipped with on-chip Op-amp, also called Programmable Gain Amplifier (PGA). MOTOR CURRENT MEASUREMENT JUMPERS: JP7, JP17, JP18 JP8, JP19, JP20 JP9, JP21, JP22 Please find below more details about the circuit used to read the current flowing through the shunts. UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 14 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit In case of 3-phase Brushless motors that need to be driven in sensorless block commutation mode, the RX23T kit integrates the possibility to manage the motor phases voltage. These are measured for the back EMF signals detection using the A/D inputs: AN100 to AN102. Please find on the right the detailed schematics made for the phase voltages reading. UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 15 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit 8. Interface to an external power stage Since internal power stage allows only the management of low voltage motors, an interface with an external power stage has been developed. The selection between the internal power stage and the external power stages is ensured by jumpers. It is a safe way to ensure that the right voltage and current signals are active. When the external power stage is connected to the kit, it is by default the active one. So the microcontroller pins are directly connected to the external power stage connector. In this case the internal power stage should be disconnected, and this must be done by disconnecting the appropriate jumpers. VBUS MEASUREMENT SIGNALS: JP10 INVERTER DRIVING SIGNALS: JP11 TO 16 POWER SUPPLY SELECTION: JP6 Please find below the jumpers description. * JP10: if closed, then the internal power stage DC Bus voltage is connected to the opportune A/D converter pin. * JP7, JP8, and JP9: if closed, then the internal power stage currents measurements (U, V, W) are connected to the opportune A/D converter pins. * JP11 to JP16: if closed then the inverter driving signals are connected to the internal power stage drivers. * JP6: it allows the following selection: UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 16 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit o if pins 1 and 2 are shorted, then the external power stage low voltage supply (between 15V to 24V) is connected to the internal DC Bus Voltage; in this case both the step-down converters of the board will work; o If pins 2 and 3 are shorted, then the external power stage low voltage supply cannot be used to supply the board. Please be careful to take into account the following precautions: 1. Please avoid to connect both the external power stage connector (J6) and to close the jumpers JP6 to JP16: this would produce short circuits between signals coming from different sources. 2. In JP6, chose the configuration with the pins 1 and 2 shorted, when external power supply board is used. Please find below the drawing of the interface connector. For a comparison, find below the drawing of the corresponding connector in the 1.5KW, 230VAC external power stage (E6108A). If using a different external power stage, please keep present the following notes: a) The PWM drive signals are directly connected to the microcontroller output pins, and there is no pull-up or pull-down resistor connected, so the polarization has to be done in the power stage. In case of alarm, the microcontroller output pins can be placed in high impedance state, so the external polarization is necessary. These output commands are logic level signals, with limited current output capability, so an external driver is probably required. A further line is connected to the microcontroller: it is the external alarm signal, connected to the POE input pin; this pin is polarized with a 10K pull-up toward the logic supply. UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 17 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit b) The analog measurement signals from power stage, in particular the current readings and the DC link voltage reading are clamped (with diodes from logic GND and to logic Vcc) and weakly filtered, then directly connected to the A/D converter input pins of the microcontroller, so the external power stage has to take care of the gain and the offset of these signals. c) The ground connection is always active, and it represents the reference for all the interface signals. In the next figure a simple example regarding how the power board connections have to be arranged, is presented. In this schema it is supposed that the power board has its own supply for the power module (+15V); +15 to +24V supply from power board is also used to supply the microcontroller (thanks to jumper JP6 in microcontroller board). Please refer to the complete schematics for further details that are available on the website: www.renesas.eu/motorcontrol. Two power stages are currently available under request, were successfully tested with the YROTATE-IT-RX23T kit. On the left hand side, the power stage can manage 300VDC for 20A and the right hand side 60VDC for 100A. UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 18 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit +VBUS 1 2 3 4 5 6 7 8 9 10 VCC 11 12 UL 13 14 VL OUT U 15 16 WL 17 18 UH Intelligent Power Module OUT V 20 VH 19 21 22 23 24 25 26 27 28 29 30 31 32 33 34 UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 THERMAL SENSOR +15V +5V VBUS +5V 1 Current Sensor OUT W +5V MOTOR ALRM GND 2 3 WH +15V Current Sensor PWGND +5V Page 19 of 83 Current Sensor RX23T YROTATE-IT-RX23T Motor Control Kit 9. Single shunt current reading While the normal configuration of the board and the standard software are based on three shunts current reading, we also offer the possibility to configure the board for single shunt current reading. Some hardware modifications are required and a different software version has to be program into the RX23T flash memory. The required hardware modifications are the following (please refer to the board schematics): * Remove from the board the shunts R90 and R96 (they are the shunts related to the phases U and W) * Close the soldering points PS1 and PS2 (those soldering points put the three inverter harms in common, below the lower switches and above the shunts) * Remove the capacitors C70, C72, C85, it speeds up the current reading circuit The components involved in the modifications are indicated in the figure below. R96, R90 PS2, PS1 C72, C70, C85 UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 20 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit 10. Current reading timing in three shunts and single shunt configurations The figures below show the different situations related to the two configurations. The first figure is related to three shunts current reading, the other are related to the single shunt current reading. Three shunts configuration In the three shunts configuration the current in one shunt is equal to the corresponding phase current when the corresponding lower switch is ON. The most suitable moment to read the current in this configuration is at the trough of the PWM. By default the YROTATE-IT-RX23T kit is delivered in the three shunts configuration. Single shunt configuration In the single shunt configuration, only when one or two of the lower switches are ON the current through the shunt is related with the phase current. When only one of the lower switches is ON, the current in the shunt is equal to the current of the corresponding inverter phase. When two of the lower switches are ON, the current in the shunt is equal to the sum of the currents of the corresponding phases that is it is minus the current of the third phase. Important Note: The software project available on the website: www.renesas.eu/motorcontrol is designed under estudio environment and only for three shunts configuration. An additional version is available under the CubeSuite CS+ Environment. The three shunts software project designed under for estudio is called: UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 "YRotateItRX23T_3s_V1.zip" Page 21 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit Furthermore, the circuit below is used to measure in real-time the motor currents flowing through the shunts resistors. In the Bill of Material, the shunt are called R90, R93, R96 as described on the page 7 of the schematics. The default value is R90 = R93 = R96 = 100m Vout to MCU 0R 10K 10K VShunt 10K IShunt 10K JP's must be open The amplifier circuit is made to manage up to 5A flowing through the shunts and the output of the amplifier is connected directly to the Microcontroller RX23T. Please find below the equations related to the amplifier circuit that are useful to change the range of currents to be measured through the three shunts. If R100 = R137 = R136 = R99 and R97 = R96, then the amplification of the circuit is (R100/2)/R97 = 5/1 = 5. So the output voltage (Vout to MCU) is : Vout = 2.5V - Vshunt x (R100/2)/R97 , and Vshunt = Rshunt x I shunt So Vout = 2.5V - (Rshunt x Ishunt) x (R100/2)/R97 And the term Delta_V = (Rshunt x Ishunt) x (R100/2)/R97 It is mandatory to keep between -2.5V and 2.5V with some margin (margin of 0.3V could be enough) so: -2.2V < Delta_V < 2.2V So the maximum current will be: Ishunt max dc = 2.2V / (Rshunt x (R100/2)/R97) UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 22 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit The default values are the following: Rshunt = 0.1ohm, R100 = 10K, R97 = 1K , so Ishunt max dc = 4.4Adc To manage different values it is enough to change Rshunt R100 and R97 but it is important to keep the following conditions: R100 = R137 = R136 = R99 R96 = R97 Finally, the shunt resistor value needs to be updated in the software itself in the file called: "pws_E6132.h " as shown below: UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 23 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit 11. Website material: www.renesas.eu/motorcontrol The complete kit material is available on-line at the address: www.renesas.eu/motorcontrol The latest updates of the downloadable material for the YROTATE-IT-RX23T kit is listed below: Items Auto-tuning Video-Tutorial Description of Resources Short video explaining how to easily tune any Brushless AC motor in 45 seconds using just the intuitive PC Graphical User Interface Drivers YROTATE-IT-RX23T Drivers Drivers and setup files for the PC Graphical User Interface Embedded Software eStudio Source Code Source files for code flashed by default into the Renesas microcontroller CubeSuite CCS+ Source Code Royalty-Free software Manuals Kit Motor Specifications Relevant documentation for the kit, the motor and the microcontroller, the MOSFETs. Renesas Datasheets Languages: English, Japanese, Korean, Chinese Tuned Motors Specifications Schematics-Gerber-BoM External Power Stages Main Board UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Schematics, Gerber files of Bill of Materials for both the main kit and the two external power stages (not included as part of the kit) Page 24 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit 12. Microcontroller RX23T short overview The RX23T Group is 32-bit microcontroller and suited for single inverter control and has a built-in FPU (floating-point processing unit) that enables it to easily program complex inverter control algorithms. This helps to greatly reduce the man-hours required for software development and maintenance. Furthermore, thanks to the RX200 core the current consumed in software standby mode with RAM retention is a mere 0.45A. RX23T MCUs operate in a broad voltage range from 2.7 V to 5.5 V, which is useful for inverter control, and are highly compatible with the RX62T Group at the pin arrangement and software level. The main specifications of the RX23T microcontrollers are as follows: Item RX23T Group CPU core Power supply voltage RX CPU v2 core running at 40MHz, delivering 2DMIPs/MHz General registers: 32-bit x 16, 32-bit multiplier & Divider Two types of Multiply-accumulator memory-to-memory operations and registerto-register operations 2.7 to 5.5V Floating-point operation unit Single-precision floating-point operation unit Flash / RAM memory Max.128 KB / 10KB On-chip peripheral functions Transfer Data transfer controller (DTCa) Timers Multi-function timer pulse unit 3: 16-bit x 6 channels (MTU3c) Port output enable 3 (POE3b) 8-bit timer (TMR): 8-bit x 2 channels x 2 units Compare match timer (CMT): 16-bit x 2 channels x 2 units Serial communications interface (SCIg): 2 channels I2C bus interface (RIICa): 1 channel Serial peripheral interface (RSPIa): 1 channel 12-bit A/D converter (S12ADE): 10 channels Comparator C (CMPC): 3 channels D/A converter for generating ref. voltage for comparator C (DA) Clock frequency accuracy measurement circuit (CAC) Data operation circuit (DOC) 14-bit independent watchdog timer (IWDTa) A/D converter self-diagnostic/open-circuit detection function CRC calculator (CRC) Register write protection Main clock oscillator Low-speed on-chip oscillator (LOCO) PLL frequency synthesizer Dedicated on-chip oscillator for the IWDT Multi-function pin controller (MPC) Power-on reset circuit (POR) Voltage detection circuit (LVDAb) PLQP0048KB-A(48-pin,LFQFP,77mm0.5mm pitch PLQP0052JA-A(52-pin,LQFP,1010mm0.65mm pitch PLQP0064KB-A(64-pin,LFQFP,1010mm0.5mm pitch) Communications Analog Safety Clock generation circuit Other Packages UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 25 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit Please find below the RX23T microcontroller block diagram. Please find below the memory line-up including the part-names. UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 26 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit 13. Permanent Magnets Brushless Motor model The synchronous permanent magnets motor (sinusoidal brushless motor) is widely used in the industry. More and more home appliance makers are now using such brushless motor, mainly because of the intrinsic motor efficiency. The permanent magnet motor is made with few components: 1. A stator formed by stacking sheared metal plates where internally the copper wiring is wound, constructing the stator winding 2. A rotor in which permanent magnets are fixed 3. Two covers with ball bearings that keep together the stator and the rotor; the rotor is free to rotate inside the stator "a" winding "b" winding ia Motor axis (shaft) + va "a" winding magnetic axis vb ic ib "c" winding + vc + How current flows into "a" winding The working principle is quite simple: if we supply the motor with a three-phase system of sinusoidal voltages, at constant frequency, in the stator windings flow sinusoidal currents, which create a rotating magnetic field. The permanent magnets in the rotor tend to stay aligned with the rotating field, so the rotor rotates at synchronous speed. The main challenge in driving this type of motor is to know the rotor position in real-time, so mainly implementation are using a position sensor or a speed sensor. In our implementation, the system is using either one or three shunts to detect the rotor position in real-time. Let's analyse the motor from a mathematic point of view. If we apply three voltages va(t), vb(t), vc(t) to the stator windings, the relations between phase voltages and currents are: UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 27 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit d a dt d v b = R S ib + b dt d v c = R S ic + c dt v a = R S ia + - i is the magnetic flux linkage with the i-th stator winding - RS is the stator phase resistance (the resistance of one of the stator windings) The magnetic flux linkages i are composed by two items, one due to the stator currents, one to the permanent magnets. axis c axis a c' b' a axis c m ' ' axis b ' a' b axis Real axes (a, b, c) and equivalent ones (, ); a fixed amplitude vector can be completely determined by its position respect the (, ) system (angle ) The permanent magnet creates a magnetic field that is constant in amplitude and fixed in position in respect to the rotor. This magnetic field can be represented by vector m whose position in respect to the stator is determined by the angle between the vector direction and the stator reference frame. The contribution of the permanent magnets in the flux linkages depends on the relative position of the rotor and the stator represented by the mechanical-electric angle . UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 28 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit It is, in every axis, the projection of the constant flux vector m in the direction of the axis: a = Lia + m cos( ) b = Lib + m cos( - 2 3 ) c = Lic + m cos( - 4 3 ) Supposing that the rotor is rotating at constant speed (that is: (t) = t) the flux linkages derivatives can be calculated, and we obtain: dia - m sin( ) dt di vb = RS ib + L b - m sin( - 2 ) 3 dt di vc = RS ib + L b - m sin( - 4 ) 3 dt va = RS ia + L A "three phases system" may be represented by an equivalent "two phases system". So the by using specific transformations, our three equations system is equivalent to a two equations system. It is basically a mathematical representation in a new reference coordinates system. In the two phases (,) fixed system the above equations become: v = RS i + v = RS i + d dt d dt For the magnetic field equations, we got: = Li + m = Li + m cos( ) = Li + m = Li + m sin( ) After performing the derivation: d di di = L - m sin( ) = L - m dt dt dt d di di =L + m cos( ) = L + m dt dt dt Finally, we obtain for the voltages in (,) system: UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 29 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit di - m dt di + m v = RS i + L dt v = RS i + L A second reference frame is used to represent the equations as the frame is turning at the rotor speed. So the "d" axis is chosen in the direction of the magnetic vector m, and with the "q" axis orthogonal to the "d" axis. The new reference system is (d, q). The reference frame transformations from the (,) system to the (d, q) system depends on the instantaneous position angle So we obtain two inter-dependant equations in the (d, q) system: did - Liq dt diq vq = RS iq + L + Lid + m dt vd = RS id + L These two equations represent the mathematical motor model. Vd 1/(R+sL) + Id + L e pL load Vq + 1/(R+sL) Iq (3/2)p + 1/(B+sJ) mec e p A control algorithm which wants to produce determined currents in the (d, q) system must impose voltages given from the formulas above. This is ensured by closed loop PI control on both axis "d" & "q" (Proportional Integral). Since there is a mutual influence between the two axes, decoupling terms can be used. In the block scheme the mechanic part is included, where "p" is the number of pole pairs, while "B" represents friction, "J" the inertia, "load" the load torque and "" the motor torque. UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 30 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit 3 2 = x px The angular speed is represented in the scheme as e to distinguish the electrical speed from the mechanical one. Let's now consider the equations we have seen in (,) system: v = RS i + v = RS i + d dt d dt These equations show that magnetic flux can be obtained from applied voltages and measured currents simply by integration: t = 0 + (v -RS i ) dt 0 t = 0 + (v -RS i ) d 0 Furthermore: m cos( ) = - Li m sin( ) = - Li If the synchronous inductance L is small, the current terms can be neglected, if not they have to be considered. In general: t x = m cos( ) = - Li = 0 + (v -RS i ) dt - Li 0 t y = m sin( ) = - Li = 0 + (v -RS i ) dt - Li 0 So in the (,) system phase we obtain from the flux components: = arctan( x y ) The system speed can be obtained as the derivative of the angle . = d (t ) dt Based on this, a sensorless control algorithm was developed to give the imposed phase voltages, to measure phase currents, to estimate the angular position and finally the system speed. UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 31 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit 14. Sensorless Field Oriented Control algorithm Please, find below the sensorless vector control algorithm block diagram. 0 [Idref] Id PI + Vd Vq (, ) (u, v, w) V V (d, q) (, ) PWM Modulation Motor ref Speed PI Iqref + + - Iq PI z-1 z-1 z-1 Current Reading (z-1) z-1 - z-1 est Speed estimation Idmea Iqmea est (, ) (d, q) Flux Phase estimation Imea Imea (u, v, w) (, ) Iumea Ivmea The main difference between the three shunts configuration and the single shunt one is in the "Current Reading" block, the rest of the algorithm remains the same in principle, even if the blocks order has been adjusted. UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 32 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit 15. Software Tools used 15.1 IDE and e2sudio Tool Chain used The embedded software delivered in the YROTATE-IT-RX23T kit is developed under estudio integrated development tool. Please find below the details of the IDE used. The software was designed under e2studio Version: 4.0.2.008. Furthermore the e2studio IDE is based on Eclipse SDK 4.4.2 (Luna SR2) and CDT version 8.6.0. The Renesas RXC Toolchain, version v2.03.00 is used. The compiler used is the "Renesas CCRX". The Optimisation level is "Max" and the optimization type is "Speed", as visible on the picture below. The device selected in the program is: R5F523T5AxFM, it means the RX23T with 128KB flash, 10KB RAM in a 64-pin package. The Instruction Set Architecture selected must be "RXv2 Architecture" to ensure that the microcontroller is delivering 80DMIPS at 40MHz CPU clock. Finally, the Data endian selected is "little-endian data". UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 33 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit Please find below the list of options for the compiler: 15.2 Project importation into estudio Launch de debugger by clicking on "Debug configuration" and the window below will appear: UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 34 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit After connection the E1 debugger to the target board powered by USB or external power supply, please click on "Debug" to start the debugging and load the program into the microcontroller flash memory. The windows below appears: UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 35 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit The program is loaded after clicking twice on the green button "Resume" to load and run the program. The window below appears once the program is running from the MCU itself. The E1 debugger can be removed to run the software on its own. In the debugger, it's also possible to display the measured speed as shown below. UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 36 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit 16. Software description and Resources used The software delivered in the YROTATE-IT-RX23T kit, previously described, is working on the RX23T microcontroller clocked at 40MHz and its operating voltage is 5V which guarantee a high noise immunity. Using the interrupt skipping function it is possible to regulate separately the PWM frequency (Pulse Width Modulation) and the sampling frequency also called control loop frequency. For instance, if the PWM frequency is set to 16KHz and the control loop is set to 8KHz, so the ratio is 2 which means that the full vector control algorithm is processed every two PWM cycles. Finally the main interrupt is called every 100s which leaves enough time to perform the sensorless vector control algorithm and the system control if needed. Please find below detailed information related to the software blocks of the motor control embedded software: The complete software uses the resources below in the three shunts configuration. It includes the serial communication interface, the board management, the LED management, the EEPROM management, the auto-tuning algorithm and self-identification and of course the complete sensorless vector control algorithm. * FLASH memory usage: 24KB and RAM memory usage: 3KB The embedded software package is called "YRotateItRX23T_3s_VX.zip" running under e2studio environment. The same source code is ported under CS+ (e.g. CubeSuite) environment and the software package is called: "YRotateItRX23T_VX_E2CS+.zip". The control loop of the field oriented control algorithm (e.g. sampling frequency) is set to 8KHz by default. The Pulse Width Modulation (PWM) frequency is set by default to 16KHz. The parameters are visible in the module name "customize.h". The parameter "SAM_FRE_DEF" is the sampling frequency in Hertz and is set to 8000 (e.g. 8KHz). The parameter "F_RATIO_DEF" is the ratio between the sampling frequency and the PWM and is set to 2, so it means 2 x 8000 = 16000 Hz (16KHz). Such parameters can be modify dynamically using the PC GUI without recompiling the overall project changing the parameters below and resetting the board. The PC GUI provide a direct access to the parameters below. UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 37 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit 19 SAM_FRE_DEF 20 F_RATIO_DEF Set the sampling frequency [Hz] of the control loop Set the ratio between the PWM frequency and sampling frequency, e.g. if 8000 is set in the parameter #19 and 2 in the parameter #20, the PWM frequency is 16KHz. The parameter #19 is setting the control loop speed. By default, 8KHz is selected by entering the value "8000". The PWM frequency can be set to four different values depending on the motor and the applications either 8KHz, 16KHz, 24KHz or 32KHz by entering either 1, 2, 3, 4 as ratio between the two frequencies. As the sampling period is 125s (8KHz), and the control loop for the inverter control takes maximum of 50s, the CPU load of the motor control algorithm with all the option enable is: 50/125 = 40%. The CPU clock is running at 40MHz. It leaves 60% of the CPU to perform additional tasks, like board management, system control, display, etc. Please find below more details information regarding the timing of the control loop according to the selected options: Option Communication management Development Mass Version Production Enable Enable EEPROM management Enable Disable PI current auto-tuning Enable Disable Motor self-identification Enable Disable Oscilloscope window Enable Disable Internal Variables debug Enable Disable Control loop Timing 50s 40s CPU load [8KHz sampling frequency] 40% 32% CPU load [14KHz sampling frequency] 70% 55% Furthermore, the execution time of the motor control interrupt including all the, the Speed PI block, the Current PI block and the complete vector control algorithm and the auto-calibration mechanisms: is 50s with The default development tools used is the estudio tool chain: RX Family C/C++ Compiler. The following flowcharts show the software implementation of the motor control part of the software. Please fin below the flowchart for the main loop, the interrupt service routines and the Automatic Tuning. UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 38 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit Embedded Software organization Hardware and software initialization Interrupt enabling PWM Interrupt 10ms Main loop UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 39 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit Main Program EEPROM parameters upload A/D channels offset reading Peripherals initialization Variables initialization Interrupt enabling Main loop synchronization cnt_int == 0 ? NO YES cnt_int = NUM_INT Main loop body Speed ramp management Communication management General board management Parameters modification management UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 40 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit Phase currents (iumea, ivmea) reading Control Interrupt in three shunts current reading mode Transformations (using the phase angle ): (iumea, ivmea) (iamea, ibmea) (idmea, iqmea) Read DC Link voltage vbus Phase angle update: = new Current PI controls use (idref, iqref), (idmea,iqmea) to produce (vdout, vqout) Transformations (using the phase angle ): (vdout, vqout) (vaout, vbout) (vuout, vvout) PWM output commands generation (using vuout, vvout) vbus is used to calculate maximum phase voltage (used in current PI controls) Phase estimation based on old_vaout, old_vbout, iamea, ibmea, produces new estimated phase angle est Voltage memories update: old_vaout = vaout, old_vbout = vbout Speed estimation produces est Estimation errors detection (if errors: alarm is set) YES NO Start-up in progress? Start-up procedure produces idref, iqref, stup idref = 0 new = stup Speed PI control uses (ref, est) to get iqref new = est Main loop synchronization cnt_int > 0 ? NO YES --cnt_int UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 41 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit The auto -tuning process and the self-identification mechanisms are fully independent from the main sensorless vector control software and can be used in the 1st phases of evaluation and configuration of the software. The three blocks mentioned above are located in the library called: "YRotateItRX23T_LIB_LE_V1.lib" located in the folder called: "YRotateItRX23T_Library" as shown below: Header file for the Math Library block Header file for the Motor Self-identification Header file for the PI Coefficients auto-tuning Library file containing the three blocks above UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 42 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit The complete project source code under e2studio is described below. For each C module, a specific header file is associated. Please find below the important Header files included into the project folder. UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 43 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit 17. Start-up procedure - Embedded software When the motor is in stand-still, the phase of the permanent magnet flux vector cannot be detected with the used algorithm. So an appropriate start-up procedure has to be applied. The idea is to move the motor in feed-forward (with higher current than that required to win the load), till a speed at which the estimation algorithm can work. Then the system can be aligned to the estimated phase, and the current can be reduced to the strictly necessary quantity. The following graph illustrates the strategy used (the suffix "ref" stands for reference, the suffix "mea" stands for measured). idref idmea speedref iqref sstart istart id0 iq0 t0 t1 t2 t3 t Referring to the graph, the start-up procedure (in case of three shunts current reading) is described below. a) At the beginning t0, the system phase is unknown. No current is imposed to the motor; the system phase is arbitrarily decided to be a=0. All the references: idref, iqref and speedref are set to zero. b) From the moment t0, while the iqref and the speedref are maintained to zero, idref is increased with a ramp till the value istart is reached at the moment t1. The references are referred to an arbitrary (da, qa) system based on the arbitrary phase a. From this moment, the phase estimation algorithm begins to be performed, and the estimated phase est is used to calculate the components of the measured current, referred to the (d, q) system based on the estimated phase, idmea and iqmea. The components of the current referred to the arbitrary (da, qa) system are controlled to follow the references by the current PI controllers. On the other hand, since the phase est is still not correctly estimated, idmea and iqmea have no physical meaning. Even if they are not shown in the graph, the applied voltages are subjected to the same treatment (vdmea and vqmea are calculated in the algorithm). c) At t = t1, while iqref is maintained to zero and idref is maintained to its value istart, speedref is increased with a ramp till the value sstart is reached at the t = t2. The system phase a(t) is obtained simply by integration of speedref; in the meanwhile, the phase estimation algorithm begins to align with the real system phase. UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 44 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit Furthermore idmea and iqmea begin to be similar to the real flux and torque components of the current. The real components are supposed to be id0 and iq0 (those values are obtained applying a low-pass filter to idmea and iqmea). The interval (t2-t1) is the start-up time, and it is supposed to be large enough to allow the estimation algorithm to reach the complete alignment with the real phase of the system. d) At t = t2, the phase estimation process is supposed to be aligned. At this point a reference system change is performed: from the arbitrary (da, qa) reference to the (d, q) reference based on the estimated phase est. The current references are changed to the values id0 and iq0, and all the PI controllers are initialized with these new values. The speed PI integral memory is initialized with the value iq0, while the current PI integral memories are initialized with the analogous voltage values vd0 and vq0, obtained from vdmea and vqmea. e) After t > t2 , the normal control is performed, based on the estimated phase est; the speed reference is increased with the classical ramp; the id current reference is decreased with a ramp, till it reaches the value zero at the moment t3; then it is maintained to zero; the iq current reference is obtained as output of the speed PI controller. UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 45 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit 18. Reference system transformations in details Find below the detailed equations used for the coordinates transformations in the embedded software for the RX23T microcontroller. 1 1 2 (gu - gv - gw ) = g a 3 2 2 3 1 1 2 3 g = ( gv - gw) = (gv - g w ) = (gu + 2gv ) 3 2 2 3 3 g = (u, v, w) (, ) g u = g 1 g v = - g + 2 1 g w = - g - 2 3 g = (- g + 3 g ) / 2 2 3 g = (- g - 3 g ) / 2 2 (, ) (u, v, w) g d = g cos( ) + g sin( ) g q = - g sin( ) + g cos( ) (, ) (d, q) g = g d cos( ) - g q sin( ) g = g d sin( ) + g q cos( ) vu = V cos(t + 0 ) vv = V cos(t + 0 - 2 / 3) v = V cos(t + - 4 / 3) 0 w UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 (d, q) (, ) v = V cos( t + 0 ) v = V sin( t + 0 ) v d = V cos( 0 ) v q = V sin( 0 ) Page 46 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit 19. Rotor position estimation The rotor position estimation method which has been chosen is the direct integration of the back EMF. Such method is enable by default in the RX23T inverter kit. Please find below the fundamental equations: t x = m cos( ) = - Li = 0 + (v -RS i ) dt - Li 0 t y = m sin( ) = - Li = 0 + (v -RS i ) dt - Li 0 = arctan( x y ) = d (t ) dt The challenges in this approach are the calculation of the integrals which is well known as a problematic issue in a numeric context, and the choice of the initial conditions, which are not known in general. There are two possibilities to overcome these difficulties: 1. To use a so-called "approximated integration", which means that instead of using an integral (1/s), a special transfer function is chosen, which is very similar to the integral in certain conditions. 2. To correct the result of the integration with a sort of feedback signal, obtained combining the estimated phase with the real flux amplitude, known as a parameter of the system. In the 1st case, we choose an integral approximation function which has a limited memory of the errors and with a zero DC gain. The goal is to reject any low frequency component, preventing the result to diverge, and automatically forgetting the errors (noise, etc.). This is obtained by combining a low-pass filter with a high-pass filter, as in the following scheme: First order low-pass Derivative: First order low-pass: 1/(s+0) s 1/(s+0) Y ( s) = s ( s + 0 ) 2 UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 47 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit It is evident the relationship between Y(s) and the integral I(s)=1/s for s=j, when >>0 . That's why, a specific parameter related to the estimator can be tuned via the PC GUI. It is the parameter n18 "App. FE Time Constant" in "ms" which is the Filter time constant used in the approximate integration flux estimation method. Please find below more technical details about it. Regarding the Filter time constant, the BEMF integral is approximated with a function composed by two low pass filters and a derivative. In discrete time domain, the expression for the low pass filter is: y(n)=((k-1)/k)*y(n-1)+(1/k)*x(n) Where (k*Tc) is the so called time constant of the filter and Tc is the sampling period In the new software release for RX23T: the parameter to be specified is the time constant on the filter in ms, which is much more flexible and also more immediate to understand. In fact the cut-off frequency of the filter is directly: 1/(2*pi*time_const[s]) = 1000/(6.28*parameter_value[ms]). Internally k is calculated as 1000*parameter_value[ms]/Tc, and the filter is implemented performing a division, so there's no restrictions on the value and the sampling frequency is now variable. For example, if the parameter_value = 32, so the time_constant[s]=0,032 and the cutoff_freq=4,97Hz, internal k=0,032*sampling_freq. That's why, at 8KHz, please find below some calculation about the possible values to be used to tune the estimators: Para. 18 in ms App. FE Time Constant 128 64 32 16 Cut-off Frequency 1.25Hz 2.5Hz 5Hz 10Hz Obviously high values of the cut-off frequency produce poor behaviour at low speed and good behaviour at high speed, and vice-versa. UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 48 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit In the 2nd case, to prevent the integral to diverge, and the errors related to wrong initial conditions are rejected, by the correcting action of the feedback. The block scheme of the exact BEMF integration method for flux position estimation is the following: The inputs of the system are the imposed voltage vector V and the measured current vector I. The motor phase resistance Rs, the synchronous inductance Ls and the permanent magnet flux amplitude m are known as parameters and motor dependant. The integral operation is corrected with a signal obtained modulating accordingly with the estimated phase the error between the estimated flux amplitude and the amplitude of the permanent magnets flux. The gain of this correction is indicated with G. It is this feedback which avoids the integral divergence due to the errors or offsets. The higher G is, the higher is the relationship between the estimated amplitude and the theoretical one, but the larger can be the induced phase error. The choice of G is a trade-off, in order to guarantee that the integral remains close to its theoretical value, but free enough to estimate the correct system phase. In the default embedded software delivered on the YROTATE-IT-RX23T kit, this second strategy is selected. The choice to test the first one is left to the user thanks to the setting of the macros in the source code. Such modifications required a compilation of the embedded software. Within the software module "customize.h", please uncomment the define APP_INT to enable the approximation method. UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 49 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit 20. PC Graphical User Interface in details Please install the Motor Control PC GUI on your machine by following the instructions of the Quick Start Guide delivered in the YROTATE-IT-RX23T kit. After connecting the Nanotec Motor (DB42S03, 24VDC, 4000RPM), please connect the board RX23T and select the COM port or use the Auto-detection mechanism. The PC Graphical User interface supports such Operating Environment: * Windows(R) 10 (32-bit, 64-bit) * Windows(R) 8.1 (32-bit, 64-bit) * Windows(R) 8 (32-bit, 64-bit) * Windows(R) 7 (32-bit, 64-bit) Please find below the detailed description of the PC GUI tabs and windows. Set motor speed, stop it, and reverse Display internal quantities (Motor speed, torque and direct current, frequency, etc) UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 50 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit By clicking on the button "Save data to file, it becomes possible to record regularly all the values display in real-time in a file, as describe below: Furthermore, the Speed control window displays the Alarm codes status of the board itself: Alarm code 1: The alarm 1 is called "EEPROM alarm" and described in the software by "EQP_ALL". This alarm is set when one or more EEPROM parameters are higher than the maximum allowed value or lower than the minimum allowed value. The LED DL2 is quickly blinking on the main board to indicate that an alarm is set. The maximum and minimum values are specified in the two constants tables called: "par_max[]" "par_min[]" in the "ges_eqp.h" header file. Another root cause for the alarm 1 is the EEPROM hardware failure when the error is accessed in read or write mode. When this alarm is active, the access to the EEPROM is restricted. To reset the alarm the default parameters set should be reloaded in the EEPROM. By using the PC GUI and the parameters setting window, it becomes possible to clean the EEPROM content. The first step is to write the magic number "33" in the first parameter n00. The second step is to reset the board by pressing the reset button on the PCB or switching off the power supply. UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 51 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit At this point a coherent set of parameters is loaded and the alarm should disappear. Finally, if the alarm is produced by a hardware failure of the EEPROM itself, then the board needs to be repaired. Alarm code 2: The alarm 2 is called "hardware overcurrent" and described in the software by "FAULT_ALL". This alarm is produced by the MCU peripheral called Port Output Enable (POE) in case of external overcurrent signal. The hardware overcurrent is producing a falling edge input on the POE pin. Furthermore, if the hardware level of the PWM output pin is not coherent with the level imposed by software, the alarm 2 will also be triggered. The LED DL2 is quickly blinking on the main board to indicate that an alarm is set. The only way to clear the alarm is to reset the board by using the reset button on the PCB or by switching off the supply and on again. Finally, one of the root causes of the Alarm 2 is a hardware defect or a wrong behaviour of the current control. So please also check the setting of the current PI coefficients that are stored in EEPROM or used in real-time. Alarm code 3: The alarm 3 is called "loss of phase" and described in the software by "TRIP_ALL". This alarm is produced when the sensorless position detection algorithm is producing inconsistent results. It means that the rotor position is unknown due to a lack of accuracy, so the motor is stopped. The LED DL2 is quickly blinking on the main board to indicate that an alarm is set. This alarm can be reset by setting the speed reference to zero on the PC GUI. Please find below an extract of the header file "const_def.h". In order to reset the board in case of Alarm code 2 "Overcurrent", please push the button as described below: Board RESET UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 52 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit Then by clicking on the "Parameters Setting" button, the important window can be displayed showing all the parameters of the system that can be changed in real-time without having to recompile the embedded software. The detailed description of each parameter is display when pointing the mouse on the question mark. Each parameters unit is displayed. To change one value in real-time, simply enter the new value and click on "Write" to program the new value into the EEPROM. UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 53 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit Furthermore, it is possible to change only one parameter at a time during fine tuning, when the motor is rotating by using the "Custom" button and enter the number of the parameter and the value inside the window as shown below. All the parameters can be changed on the fly and after pushing the "Write" button, it's automatically set. But there are two exceptions related to the parameters #19 and #20: 19 SAM_FRE_DEF 20 F_RATIO_DEF Set the sampling frequency [Hz] of the control loop Set the ratio between the PWM frequency and sampling frequency, e.g. if 8000 is set in the parameter #19 and 2 in the parameter #20, the PWM frequency is 16KHz. The parameter #19 is setting the control loop speed. If 8KHz is selected by entering the value "8000", the PWM frequency can be set to four different values depending on the motor and the applications either 8KHz, 16KHz, 24KHz or 32KHz. => It's basically done by entering the ratio value in the parameter #20. Please find below the possible values that can be entered. Parameter 19: Sampling freq. 4KHz 8KHz 10KHz 12KHz 14KHz 16KHz Parameter 20: Ratio = 1 PWM freq.: 4KHz PWM freq.: 8KHz PWM freq.: 10KHz PWM freq.: 12KHz PWM freq.: 14KHz PWM freq.: 16KHz UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Parameter 20: Ratio = 2 PWM freq.: 8KHz PWM freq.: 16KHz PWM freq.: 20KHz PWM freq.: 24KHz PWM freq.: 28KHz PWM freq.: 32KHz Parameter 20: Ratio = 3 PWM freq.: 12KHz PWM freq.: 24KHz PWM freq.: 30KHz PWM freq.: 36KHz PWM freq.: 42KHz PWM freq.: 48KHz Parameter 20: Ratio = 4 PWM freq.: 16KHz PWM freq.: 32KHz PWM freq.: 40KHz PWM freq.: 48KHz PWM freq.: 56KHz PWM freq.: 64KHz Page 54 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit In order to change the values of the parameters #19 and #20, please follow the description below. After entering the new values, in this case 8KHz of sampling frequency and 16KHz of PWM frequency, click on "write" and Push the Reset button of the board. It's only after the Reset of the board that the new PWM and loop frequencies will be set in the embedded software. Important Note: After setting up the new values for the parameters #19 or #20, it's recommended to run the Autocalibration procedure described below. It ensure the software to use the best intrinsic values and the most adapted values of the current PI coefficients. Speed range limitations The YROTATE-IT-RX23T kit is driving any 3-phase Permanent Magnet Motors using a sensorless vector control algorithm. So it means that there is a minimum speed to reach in order to run the motor properly using the three shunts current measurement methods. In the case of the Nanotec Motor DB42S03 delivered with the kit, the minimum speed is 600RPM. Below this speed, the current flowing through the three shunts are too low to be detected. Furthermore, when the board is supplied only via the USB cable, the maximum current provided to the board is limited by the 500mA of the USB PC port and the voltage generating by the board which is 12V. It means that, the first tests using the 3-phase Brushless AC motor DB42S03 from Nanotec will work properly in a specific speed range: from 600RPM up to 3500RPM. The DB42S03 brushless motor is able to reach its maximum speed of 6200RPM (without load) when the power supply is 24V and up to 1A is provided. After changing the jumpers as described above and providing 24V to the board, the Nanotec motor from the YROTATE-IT-RX23T kit reach easily 6200RPM, its maximum rated speed without load. Of course, the embedded software enabling flux weakening technics, by providing more current to the board, the motor can reach 8000RPM. UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 55 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit 21. EEPROM parameters: detailed description Please find below the software parameters list including their full description. Each parameters located in the "customize.h" header file can be tuned by the user directly by the Graphic User Interface, without recompiling the program. Parameter number Short name 0 SEL_OP 1 2 3 4 5 RPM_MIN RPM_MAX R_ACC R_DEC C_POLI 6 I_START 7 8 9 I_MAX R_STA L_SYN 10 PM_FLX 11 12 13 14 KP_CUR KI_CUR KP_VEL KI_VEL 15 FB_GAIN 16 PHA_OFF 17 18 19 20 Description default parameters setting, Used to perform special operations, like default parameter set re-loading, or current PI tuning working mode setting Set the Minimum Speed in RPM Set the Maximum Speed in RPM Set the acceleration [RPM/s] Set the deceleration [RPM/s] Set the number of polar couples Set the start-up current (peak) [Ampere/AMP_RES]. Used to specify the peak phase current value to be used during the start-up Set the maximum phase current (peak) [Ampere/AMP_RES] Set the stator resistance [Ohm/OHM_RES] Set the synchronous inductance [Henry/HEN_RES] Set the permanent magnets flux [Weber/WEB_RES]. This value is only used when the exact integration flux estimation algorithm is selected. By default, it's not needed as the approximated integration is selected. Set the Current loop Proportional coefficient: KP Set the Current loop Integral coefficient: KI Set the Speed loop Proportional coefficient: KP Set the Speed loop Integral coefficient: KI Set the flux amplitude feedback gain. This value is only used when the exact integration flux estimation algorithm is selected. By default, it's not needed as the approximated integration is selected Set the phase offset [deg]. It is used to add a phase offset to the phase estimation, to reach better alignment Set the Start-up acceleration time [sec/SEC_RES] ST_TIM Not used SAM_FRE_DEF Set the sampling frequency [Hz] of the control loop Set the ratio between the PWM frequency and sampling frequency, e.g. if 8000 is set F_RATIO_DEF in the parameter #19 and 2 in the parameter #20, the PWM frequency is 16KHz. UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 56 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit 22. Motor Auto-calibration using the PC GUI The full calibration of any 3-phase AC Brushless motor can be performed automatically using the PC Graphical User Interface. Three specific buttons are now available for and shown below: In terms of AC Brushless motor driven in sinusoidal mode and FOC algorithm, the most important parameters to tune are: 1. Current PI parameters: Proportional Kp and Integral Ki 2. Motor parameters: Stator resistance Rs, the synchronous inductance Ls, and Permanent Magnet flux m. Please find below the auto-tuning process step by step of the Nanotec Motor DB42S03 delivered with the YROTATEIT-RX23T kit. The DB42S03 motor is a low voltage Permanent Magnet Synchronous Motor. The auto-tuning procedure will be performed using the kit running the sensorless vector control algorithm. Important Note: The auto-tuning embedded software is working only on the three shunts version. a) Please find below the specifications of the Motor delivered by the motor maker: Motor Manufacturer: NANOTEC www.nanotec.com Motor type: 3-phase AC Brushless DB42S03 Maximum current: 5.4A Bus Voltage: 24V Speed rated: 4000 RPM Number of pole pairs: 4 UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 57 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit b) Let's setup the Motor control kit for 24VDC external power supply: the jumper JP1 and JP2 needs to be set to 1-3 position as explained in the "Chapter 3 Power Supply selection". c) Let's connect the 24VDC Power supply to the RX23T motor control reference kit. The following LEDs: DL3, DL4, DL5 are ON and the LED DL2 is blinking to indicate that the MCU is running fine. Important Note: The procedure below is also working with the USB power supply, but it is recommended to connect 24VDC external power supply to the inverter kit. It ensure a higher resolution during the auto-tuning procedure and the extraction of the intrinsic motor parameters as the level of energy is higher. d) Now, connect the USB cable to the PC and the Kit and connect the 24V to the kit and the motor to the kit: e) Launch the PC GU from the folder: "C:\Program Files\MCDEMO" launch: "MotorController.exe" The LED DL1 of the RX23T board is blinking rapidly showing communication between the board and the PC. UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 58 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit Click on the "setup" button and select "RX23T Kit" and select "Auto detect" and click on "Connect" to ensure the PC GUI is connected to the RX23T kit. On the left hand side, the new buttons appears: "Cur. PI tuning", "Cu. PI tuning (AUTO)", "Motor Identification" and "Oscilloscope" which are needed for the self-calibration of the motor. f) Clean the EEPROM content and start with the default parameters in the EEPROM. The first thing to do is to ensure that the inverter board is the default state and the default parameters are written inside. The procedure below ensures it: Click on the "Parameters Setting" button and enter the magic value "33" in the "00. Operation Select" and push the RESET button on the board as shown: Board RESET g) Set the maximum current (parameter n07) as it will influence all the next steps: Click on "Parameters settings" Enter the value: 3500 (the unit is in mA) and click on "Write" to save the parameter into the EEPROM and close the parameter setting window. The maximum current parameter is fundamental for the auto-calibration. The maximum value allowed by the motor must be used to guarantee the highest resolution. UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 59 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit h) Click now on "Cu. PI tuning (AUTO)" button and press "start" to perform an automatic Current PI tuning. The two coefficients of the PI current block will be extracted thanks to the embedded software able to generate a step voltage and measuring the motor response. And click on "Yes" to accept the results to be programed into the EEPROM as shown below. i) Now click on the button "Cu. PI tuning" to open the manual current PI tuning window and check the step answer by clicking on "Apply current step" button. UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 60 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit Depending on the motor, the parameters found by the automatic procedure can be too fast or too slow. Please use the Zoom function to check the beginning of the step: You can adjust manually the parameters to obtain an even better step response and also increase the step current level by increasing the percentage of "Cur. [%] to 90%. The default value is 50%. Once it's done, the window can be closed as the proportional and integral coefficients of the PI current are tuned. j) Perform an auto-identification of the motor parameters by clicking on "Motor Identification" and click "start": UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 61 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit During this process the rotor should start rotating, please leave the rotor free and no loaded. And finally accept the results to store them into the EEPROM by clicking on "yes". The stator resistance, the synchronous inductance and the Permanent Magnet flux have been measured and tuned. k) Now please click on "parameters settings" and enter the number of pole pairs: 4 (parameter n5) and enter a minimum speed or 1000 RPM l) Set a start-up current equal to 25% of the maximum current. In our case 25% of 3.5A is 0.875A. Please enter the value 875 into the parameter n6 and click on the "write" button on the right hand side. UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 62 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit Then let's close the window. j) Now, let's try to run the motor. Please click on the button: "Speed Control": To start the motor, let's enter a speed which is 1.5 times the minimum speed, in this case 1500 RPM UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 63 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit Please click on the "Oscilloscope" button to see the motor waveforms with the current in Y-axis and the time in xaxis. You can also display the phase by clicking on "Phase" selector: For the oscilloscope window, use an opportune time scale: "1 sample every 1" should be used for extremely fast phenomena when running at very high speed. The setting "1 sample every 128" should be used for extremely low phenomena when running at very low speed. Let's start with an intermediate value and adjust it in order to see some periods of the current or the phase. k) When the motor is running, you can adjust the two speed PI parameters: the proportional and integral terms: #13 and #14 UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 64 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit Please follow the procedure: while running at a medium speed range: 2 times the minimum speed. In our example, the speed is set to 2000 RPM, the PWM frequency is set to 30KHz and the sampling frequency to 10KHz. The board was RESETTED and the auto-tuning procedure redone. Please open the Oscilloscope window and the Parameters Setting windows as shown below. To tune the coefficients, start by increasing the Parameter n13 (Kp) until the instability that can be display in the current or phase waveform window. Add a step of "1000" and click "write" to see the effect and keep on increasing it. In our case, at 200 it started to be very unstable, but the motor is still running. Set the speed to "0". Then use less than half of the found value: 70 in our case, click on "write" and set the speed to 2000 RPM. UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 65 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit Do the same for the parameter n14 (integral coefficient) which is the speed loop Ki parameter. Increase it until it becomes unstable. In our case the critical value is reached at 600 for Ki, so the value to be used is: 300 (half of the value found). l) Test the parameters found in all the speed ranges and different rotations. m) Finally the parameters list can be saved in a file in .CSV ("Save" button) or .h file ("Create.h" button) format for further used and can also be uploaded later on: Troubleshooting: At the stage j) if the motor doesn't start or generate an alarm n3, please set the speed to "0" to clear the alarm which indicates that the software lost the phase. One first test is to increase or decrease the start-up current and the minimum speed or the speed PI gains UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 66 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit When the motor is running, you can verify the number of pole pairs taking measurement of the effective speed, and comparing it with the imposed frequency: the number of pole pairs n is: n=freq*60/speed; if you change the number of pole pairs, remember to adjust also the minimum (and maximum) speed values. For some motors, the no-load start-up is easier if the inductance parameter is set to 0 (parameter #9) All the procedure is tuned to manage motors which maximum current is close to the inverter capability, which is around 6A for the external power stage (shunt value is 0.05 Ohm) and 3Arms for the internal power stage (shunt value is 0.1 Ohm). If you try to use it for very different motors, the results will be influenced by the losses in current reading resolution. UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 67 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit 23. Updating the RX23T Flash memory using the Renesas Programming Flash Tool The procedure below explain in details how to re-program the RX23T flash memory using the Renesas Flash Programing tool, called the RFP. It could be used to update the RX23T kit with the latest Firmware version downloaded from the website: www.renesas.eu/motorcontrol . The RFP must be used with the E1 debugger and there's no need to install the full version of the development environment either e2studio or CS+. Please have a look at the specific Flash Programming Tool website to us the latest software version: www.renesas.eu/products/tools/flash_prom_programming/index.jsp Please follow the 13 steps to update the flash memory of your RX23T MCU using the RFP tool. Step1: Open RFP software v2.05. The "Welcome" windows appears. Then click on "Create new workspace" Step2: Select RX200(FINE) and a workspace name, then click "Next" button UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 68 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit Step3: Select the E1 debugger and then click "Avanti" or "next" button. Step4: Select the options as shown and click "OK" button. Step5: Click on "Power target from emulator", then select 5.0V (USB VBUS) and then click "OK" button. UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 69 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit Step6: Click on "OK" button. Step7: After E1 Emulator has been located press "OK" button Step8: Select RX200 Series (Little Endian) and press "OK" button Step9: After all the test will be passed press "OK" button UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 70 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit Step10: Input Frequency will be 32MHz, so press "Avanti" button Step11: click "Fine" button UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 71 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit Step12: Check the summary and then click "OK" button Step13: Browse the file with the ".mot" extension to be downloaded into the flash memory and then click "START" button. At the end of the process "Image written to device" will appear. The new program is now into the flash of the RX23T. Congratulations! The new firmware is now programed into the RX23T flash memory. UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 72 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit 24. Integration of user code to the motor control algorithm There are several places in the embedded source code to add user code depending on the type of routines. Basically, either the user code can be placed within the main routines in the module called "main.c" or in the interrupt service routine offering the highest priority, used to execute the field oriented control algorithm in the module called: "motorcontrol.c". The example below shows how to add specific code in the module "main.c" to add a specific speed profile on the YROTATE-IT-RX23T. The 1st step is to add a main variable "COUNTER_CYCLE" to generate a timer base. The 2nd step is to add at the beginning of the main loop the speed ramps and the profile wished. In the example, the motor speed will reach 30000 RPM with the first cycle period and slow-down to 9000 RPM in the second phase and it will work periodically. The routine is generating a The main loop timing is 10ms, so 120 times, it means 1.2 seconds is the period of the cycle. UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 73 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit 25. Communication Protocol between the MCU and the PC GUI After the introduction of the auto-tuning, a new set of information is exchanged between the GUI and the board. To distinguish between the software versions the answer to the check request is used. In the previous software version the answer to a check com request ("c"), was the uppercase ("C"). In the versions with auto-tuning the answer code is ("d"). The maximum serial communication speed tested is 76.6 KBd. **************************************************************************** *** MULTIPOINT MASTER-SLAVE SERIAL COMMUNICATION SIMPLIFIED PROTOCOL *** **************************************************************************** ASCII: '!'=0x21, '#'=0x23, '?'=0x3F, 'C'=0x43, 'W'=0x57, 'c'=0x63, 'w'=0x77 Master String: l i s o a n D1 .. Dm k l = frame total length (1 byte) i = master string identification ('?' = question) s = station address (1 byte) o = operation code (1 byte) a = data address (1 byte) n = data number (1 byte) Dx = x-th data byte (1 byte) k = checksum (1 byte) Master operation codes: 'c' = check request 'w' = word reading (1 word = 2 bytes) 'W' = word writing (1 word = 2 bytes) Possible master frames (questions): check: l ? s (l=5) word read.: l ? s (l=7) word writ.: l ? s (l=7+2*n) c k w a n k W a n D11 D10 .. Dn1 Dn0 k Slave string: l i s o a n D1 .. Dm k l = frame total length (1 byte) i = slave string identification ('!' = OK answer, '#' = NOK answer) s = station address (1 byte) o = operation code (1 byte) a = data address (1 byte) n = data number (1 byte) Dx = x-th data byte (1 byte) k = checksum (1 byte) Slave operation codes: 'C' = check answer 'w' = word reading answer (word = 2 byte) 'W' = word writing answer (word = 2 byte) UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 74 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit Possible slave frames (answers): nok: l # (l=5) check: l ! (l=5) word read.: l ! (l=7+2*n) word writ.: l ! (l=5) s o k s C k s w a s W k n D11 D10 .. Dn1 Dn0 k ADDRESSES: If the address "a" specified in the question is a < NUM_PAR_EQP (number of EEPROM parameters), then an EEPROM parameter is read or written. Otherwise if a > = NUM_PAR_EQP, then a parameter in the RAM table (Cf. module "userif.h") is read or written. Its address in the RAM table is a-NUM_PAR_EQP. Operation example: PC request of reading 16 words from the structure UIF_R, starting from the second one (UIF_R.ram_tab[1], .., IF_R.ram_tab[16]): 0 1 2 3 4 5 6 07 3F 00 77 41 10 39 Number of bytes in the frame Master string indicator "?" Station address (it is always 0 in our boards) word reading operation "w" data start address (1(address in UIF_R.ram_tab) + 40h (offset to add for ram reading/writing)) number of data (10h=16dec) checksum 27 21 00 77 41 10 00 00 00 00 00 00 00 00 00 00 00 00 00 18 00 00 00 01 00 00 00 00 Number of bytes in the frame (27h=39dec) Slave string indicator "!" Station address (it is always 0 in our boards) word reading operation "w" data start address (1(address in UIF_R.ram_tab)+40h(offset to add for ram reading)) number of data (10h=16dec) MSB of the 1st word of data (UIF_R.ram_tab[1]=UIF_R.var.rpm, speed) LSB of the 1st word of data MSB of the 2nd word of data (UIF_R.ram_tab[2]=UIF_R.var.fre, imposed frequency) LSB of the 2nd word of data MSB of the 3rd word of data (UIF_R.ram_tab[3]=UIF_R.var.id, d axis current) LSB of the 3rd word of data MSB of the 4th word of data (UIF_R.ram_tab[4]=UIF_R.var.iq, q axis current) LSB of the 4th word of data MSB of the 5th word of data (UIF_R.ram_tab[5]) LSB of the 5th word of data MSB of the 6th word of data (UIF_R.ram_tab[6]) LSB of the 6th word of data MSB of the 7th word of data (UIF_R.ram_tab[7]=UIF_R.var.vb, bus voltage) LSB of the 7th word of data MSB of the 8th word of data (UIF_R.ram_tab[8]) LSB of the 8th word of data MSB of the 9th word of data (UIF_R.ram_tab[9]=UIF_R.var.all, alarm) LSB of the 9th word of data MSB of the 10th word of data (UIF_R.ram_tab[10]) LSB of the 10th word of data MSB of the 11th word of data (UIF_R.ram_tab[11]) LSB of the 11th word of data Board answer: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 75 of 83 RX23T 28 29 30 31 32 33 34 35 36 37 38 YROTATE-IT-RX23T Motor Control Kit 00 00 00 00 00 00 00 00 00 00 69 MSB of the 12th word of data (UIF_R.ram_tab[12]) LSB of the 12th word of data MSB of the 13th word of data (UIF_R.ram_tab[13]) LSB of the 13th word of data MSB of the 14th word of data (UIF_R.ram_tab[14]) LSB of the 14th word of data MSB of the 15th word of data (UIF_R.ram_tab[15]) LSB of the 15th word of data MSB of the 16th word of data (UIF_R.ram_tab[16]) LSB of the 16th word of data checksum PC request of writing 4 words in the structure UIF_W, starting from the third one (UIF_W.ram_tab[2], .., UIF_W.ram_tab[5]): 0 1 2 3 4 5 6 0F 3F 00 57 42 04 03 7 8 9 10 11 12 13 14 E8 00 00 00 00 00 00 E7 Number of bytes in the frame (0Fh=15dec) Master string indicator "?" Station address (it is always 0 in our boards) word writing operation "W" data start address (2(address in UIF_W.ram_tab)+40h(offset to add for ram reading/writing)) number of data MSB of the 1st word of data (value (03E8h=1000dec) to be written in UIF_W.ram_tab[2] = UIF_W.var.rif, speed ref) LSB of the first word of data MSB of the second word of data (value to be written in UIF_W.ram_tab[3], not used) LSB of the second word of data MSB of the third word of data (value to be written in UIF_W.ram_tab[4], not used) LSB of the third word of data MSB of the fourth word of data (value to be written in UIF_W.ram_tab[5], not used) LSB of the fourth word of data checksum Board answer (indicates that the request is received and processed): 0 1 2 3 4 05 21 00 57 E6 Number of bytes in the frame Slave string indicator "!" Station address (it is always 0 in our boards) word writing operation "W" checksum Note: Two new operation codes have been added: 'y'(=0x79): word reading (EEPROM minimum value) 'z'(=0x7A): word reading (EEPROM maximum value) In these cases the address is a < NUM_PAR_EQP. To understand in more details the software implementation, please find below the extract of the "userif.h" module, part of the embedded software. UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 76 of 83 RX23T UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 YROTATE-IT-RX23T Motor Control Kit Page 77 of 83 RX23T UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 YROTATE-IT-RX23T Motor Control Kit Page 78 of 83 RX23T UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 YROTATE-IT-RX23T Motor Control Kit Page 79 of 83 RX23T UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 YROTATE-IT-RX23T Motor Control Kit Page 80 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit Revision History Rev. 0.50 1.00 Date May 20, 2015 Description Page October 6, 2015 UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Summary First Edition Chapter 10 to 24 are reworked or added Page 81 of 83 RX23T YROTATE-IT-RX23T Motor Control Kit 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 document, refer to the relevant sections of the document as well as any technical updates that have been issued for the products. 1. Handling of Unused Pins Handle unused pins in accord with the directions given under Handling of Unused Pins in the manual. The input pins of CMOS products are generally in the high-impedance state. In operation with an unused pin in the open-circuit state, extra electromagnetic noise is induced in the vicinity of LSI, an associated shoot-through current flows internally, and malfunctions occur due to the false recognition of the pin state as an input signal become possible. Unused pins should be handled as described under Handling of Unused Pins in the manual. 2. Processing at Power-on The state of the product is undefined at the moment when power is supplied. The states of internal circuits in the LSI are indeterminate and the states of register settings and pins are undefined at the moment when power is supplied. In a finished product where the reset signal is applied to the external reset pin, the states of pins are not guaranteed from the moment when power is supplied until the reset process is completed. In a similar way, the states of pins in a product that is reset by an on-chip power-on reset function are not guaranteed from the moment when power is supplied until the power reaches the level at which resetting has been specified. 3. Prohibition of Access to Reserved Addresses Access to reserved addresses is prohibited. The reserved addresses are provided for the possible future expansion of functions. Do not access these addresses; the correct operation of LSI is not guaranteed if they are accessed. 4. Clock Signals After applying a reset, only release the reset line after the operating clock signal has become stable. When switching the clock signal during program execution, wait until the target clock signal has stabilized. When the clock signal is generated with an external resonator (or from an external oscillator) during a reset, ensure that the reset line is only released after full stabilization of the clock signal. Moreover, when switching to a clock signal produced with an external resonator (or by an external oscillator) while program execution is in progress, wait until the target clock signal is stable. 5. Differences between Products Before changing from one product to another, i.e. to a product with a different type number, confirm that the change will not lead to problems. The characteristics of an MPU or MCU in the same group but having a different part number may differ in terms of the internal memory capacity, layout pattern, and other factors, which can affect the ranges of electrical characteristics, such as characteristic values, operating margins, immunity to noise, and amount of radiated noise. When changing to a product with a different part number, implement a system-evaluation test for the given product. UM-YROTATE-IT-RX23T Rev. 1.0 October 6, 2015 Page 82 of 83