RL78G14 Motor Control Kit YRMCKITRL78G14 User Manual Introduction This document describes the Motor Control Kit (YRMCKITRL78G14) based on RL78/G14. D011181 Rev.1.00 th June 15 2012 D011181 Rev.1.00 th June 15 2012 This platform drives a 3-phase Permanent Magnet Synchronous Motor (Brushless Motor) by using an advanced sensorless Field Oriented Control algorithm. The phase currents measurement is done via three shunts which offer a very low cost solution avoiding any expensive current sensor.
Contents 1. Installation and Set-Up ...................................................................................................................... 4 1.1. Software Installation .......................................................................................................................... 4 1.1.1 Virtual UART USB Driver Installation on Windows XP ............................................................ 5 1.1.2 Virtual UART USB Driver Installation on Windows 7 .........................
5.2.1. Algorithm Selection .................................................................................................................... 29 5.2.2. Parameter Setting ...................................................................................................................... 30 5.2.3. System Monitor .......................................................................................................................... 30 5.2.4. Main Control Window (Speed Control) ....................
1. Installation and Set-Up The following section provides the information to install the software, projects and documentation for the YRMCKITRL78G14 motor control kit and to be able to set up the hardware in order to run the built in demonstration. 1.1. Software Installation To install the software supplied with the kit, Place the CD-ROM into the PC drive The installation should start automatically If for any reason the CD fails to start automatically, please run the “setup.
For 32bit Windows OS, 32bit USB drivers should be used (i.e. Windows XP, Vista and W7) and are located here C:\Program Files\Renesas\YRMCKITRL78G14\Virtual UART\32bit if the YRMCKITRL78G14 installation is used C:\Program Files\IAR Systems\Embedded Workbench 6.0\rl78\drivers\renesas\VirtualCOM\32bit if the IAR installation is used For 64bit Windows OS, 64bit USB drivers (i.e.
On Windows Vista, a window should also pop up with similar options when connecting the YRMCKITRL78G14 board for the first time. Select “Locate and install driver software” and then “Browse my computer for driver software (advanced)”. Set “Include this location in the search” and then browse the computer to select the directory indicated previously for the appropriate operating system location.
If this window appears, click “Continue Anyway” to continue the installation. Then click “Finish” to complete the installation wizard.
1.1.2 Virtual UART USB Driver Installation on Windows 7 When the YRMCKITRL78G14 board is connected to the host machine, the board is initially recognised as an “Unknown Device” in the Device Manager. Right click on the “Unknown Device” and select “Update Driver Software…” within the Device Manager window. Select “Browse my computer for driver software”.
Click “Install” when the driver has been found..
1.1.3 Confirmation of USB Driver Installation After installing the USB driver, check that the driver has been installed correctly, according to the procedure below. Open the "Device Manager" (this will vary depending on the Windows Operating system used) When the YRMCKITRL78G14 board is connected to the host PC, the “Ports (COM & LPT)” section should show the "Renesas Electronics Starter Kit Virtual UART”. The screen below shows that the COM port number is "COM23".
1.2. Stand Alone Demonstration Setup The following information provides the initial setup for the YRMCKITRL78G14 motor control kit basic “out of the” box” demonstration which can be used to check that the system is working correctly and provide a quick demonstration for customers, exhibitions etc. The following describes the default settings which configures the board for use with the USB supply and the internal Inverter. Please ensure that no external power stage is connected to connector J10 1.2.1.
1.2.4. Select the Internal Inverter The following jumpers should fitted to connect the power, control, current inputs and the PWM drive signals to the internal inverter JP10 fitted JP11 fitted JP12 fitted JP13 fitted JP14 fitted Jumpers JP10 to JP19 JP15 fitted JP16 fitted JP17 fitted JP18 fitted JP19 fitted Jumper JP8 and JP9 can be connected or open Jumper JP8 and JP9 1.3.
1.3.2.
2. Hardware Description The YRMCKITRL78G14 starter kit is a single board motor control inverter, based on the new RL78/G14 series of microcontrollers. The hardware includes a low-voltage 3-phase MOSFET power stage, the MCU control system, the switching power supplies and the communications / debugging / programming interface.
PATCH AREA INTERNAL POWER STAGE STEP-DOWN 12V HALL SENSORS INTERFACE STEP-DOWN 5V EXTERNAL POWER STAGE INTERFACE RL78G14 E1 interface connector STEP_UP Internal/External power stage selection POWER STAGE INTERFACE Communications mode Jumper selection ENCODER INTERFACE User Switches P4 is at the bottom RL78G14 MICROCONTROLLER connections ISOLATION YRMCKITRL78G14 Board Overview COMMUNICATION
2.1. Power Supply Selection There are two main ways to supply power to the board. 1. The first is to use the PC USB supply, and in this case the current you can give to the motor is limited by the USB interface. In this mode the USB interface is not isolated. 2. The second is to use an external voltage DC source to supply the board. The recommended operating voltage range is between 15Vdc and 48Vdc, max at 3Amps DC. A power supply with more current could be used to increase the available for the motor.
2.2. LED Description There are three LED’s on the board that show the status of the power supply of the board. DL7 is connected to the USB supply from the PC, so it indicates that power is supplied to the USB port and, therefore the complete communication section; DL6 is connected to the 12V step-down converter output (VDRV12V) and indicates that the inverter drive voltage is supplied.
2.3. Communications / Debug / Programming Interface Jumper Management Using the communication interface, based on the uPD78F0730 USB MCU, it is possible to run the following a. Control GUI, b. Program the RL78G14 using the Renesas Flash Programmer (RFP) software c. Debug the RL78G14 using the IAR Embedded Workbench “TK” interface. Please note that these functions cannot be operated at the same time as they all share the same USB interface on the board.
JP3-1 JP3-2 JP3-3 JP3-1 JP3-2 JP3-3 JP4-1 JP4-2 JP4-3 JP4-1 JP4-2 JP4-3 JP5-1 JP5-2 JP5-3 JP5-1 JP5-2 JP5-3 JP6-1 JP6-2 JP6-3 JP6-1 JP6-2 JP6-3 JP7-1 JP7-2 JP7-3 JP7-1 JP7-2 JP7-3 PROGRAMMING / TK OCD VIRTUAL UART (GUI) GUI / OCD Jumper (JP3, 4, 5, 6 and JP7) configuration settings NOTE: It is also possible to debug the RL78G14 using the E1 emulator, through the dedicated connector J5.
E1 OCD Interface connector location 2.4. Internal/External Power Stage Selection The board offers the option of using either an internal MosFet power stage, or the complete interface to connect an external power stage. (Please note that the internal and external interfaces cannot be operated at the same time). The power supplies, inverter drive signals and the other control and monitor signals are connected to the external power stage connector J10.
2.4.1. Internal Power Stage Description The internal power stage is forms a complete 3-phase inverter bridge using discrete low voltage power MosFets. (Renesas RJK0654DPB n-channel power MosFet) The logic driving signals from the RL78/G14 MCU are connected to three IR MosFet drivers which take care of the level shifting and charge pump generation for the MosFet gate drive. The inverter phase currents are read through three shunts in the low sides of the bridge.
2.4.2. External Power Stage Interface Since internal power stage allows only the management of low voltage / low current motors, an interface with an external power stage is provided. This allows the RL78/G14 MCU together with the control GUI or IDE debugger to control a high voltage high power motor via a suitable external inverter unit. Please find below the signal connection interface for the external power stage interface connector J10.
2.4.2.1. External Power Stage Interface Signal Definitions The following provides a short explanation of the external power stage interface connections Please refer to the circuit schematics for full details. Analogue Signals The analog signals are inputs and should always be in the range 0V to 5V.
3. Control MCU overview The RL78/G14 is a family of MCU’s featuring the high-performance RL CPU core. Single cycle instruction execution, with enhanced hardware support for multiply, divide and MAC operations Below is a summary of the RL78G14 features: RL78G14 CPU High-speed: 32MHz clock High performance: 41MIPS @32MHz Low current consumption: only 4.6mA @ 32MHz MUL, DIV, MAC hardware instructions Barrel shifter MEMORY AND PACKAGES 16KB Flash/2.
4. RL78/G14 Motor Control Kit Specifications and Performance Data The specifications for the on board inverter and for the sensor-less algorithm implemented are as follows: External Supply voltage range: 15V to 48Vdc. Supply current: 3A max. (No Forced cooling) Maximum continuous output power 100W. Current reading technique: three shunt. Motor Control Timer Clock frequency up to 64MHz o PWM switching frequency: up to 24KHz. Sampling rate: max 8KHz.
5. PC User Interface (GUI) The User Interface is installed automatically during the CD-ROM installation. The PC Interface uses the USB connection to communicate with the RL78G14 board so before use please make sure that the Virtual UART drivers are installed as described in section 1.1.1 5.1.
To connect the GUI to the YRMCKITRL78G14 board follow the sequence If more than one configuration file is located in the GUI installation directory, then the user has to select the appropriate configuration (setup) file. Otherwise the default configuration file (setup.ini) is selected automatically and this part can be skipped. Note the setup and configuration can be customised by editing the setup.ini file and then saving as the same or alternative file name.
Next select the “Com Port selection” drop down box and select the communications port that the YRMCKITRL78G14 board is connected to, close the drop down box and click the “connect” button as shown below Select the com port.
5.2. Function Button Description 5.2.1. Algorithm Selection At this time the only algorithm available is the sensorless F.O.C algorithm Pressing the “Verify Jumper Settings” button opens the default settings for the board Pressing the “Verify Jumper Settings” button opens the default settings for the board.
5.2.2. Parameter Setting This window allows the run time parameters to be set and changed. When the parameter set is changed and re written the saves these in the non-volatile memory (Data Flash or EERPOM) Before running the motor, check that the Parameters Settings displayed like the speed range and the number of polar couples etc. are in-line with the motor to be used or tuned (See section 12).
5.2.4. Main Control Window (Speed Control) This window provides the main control window for the board It includes the following features a. RPM Control Allows manual control of the motor including speed and direction. The speed reference can be varied using the “RPM CONTROL” pointer, which can be either moved with the mouse, or with the value written, directly into the text box. A value written as a positive value (i.e.
The run time data can be saved to an Excel file by clicking on the “Save data to file” button This will open a dialogue box to select the filename and location of the file that the data is saved into. A control bar will appear to allow the use to Start, Pause or Stop the data recording process c. Speed Control Graphs There are three graphs that monitor the operation of the motor.
Once the motor is in operation the graphs will start to update together with the measured values in the “PROERTY MONITOR” window as shown below d. Alarm Codes There are three “alarm codes used in the GUI and embedded software 1. 2. 3. EEPROM error alarm Inverter error Loss of phase error The alarm codes usually can be cleared by resetting the motor speed back to zero. In some circumstances it is necessary to perform a manual reset of the RL78/G14 to clear the error.
This will open a media player style control bar which allows the user to 1. Stop recording , close the media bar and close the file 2. Pause / Resume recording 3. Reset Recording (Note this will overwrite the data in the file) Each update of the GUI, monitor data is saved and will create a new entry in the excel file. When the button is first pressed the user will be prompted for the file name of the file to be used.
5.3. GUI Control Command Flow The following information shows the command and control flow for the communications between the PC GUI and the RL78/G14 motor control board firmware. ASCII codes used as commands: “!” = 0x21, “#” = 0x23, “?” = 0x3F, “W” = 0x57, “c” = 0x63, “w” = 0x77 If the address "a" specified in the Master command is
a = data address (1 byte) n = data number (1 byte) Dx = x-th data byte (1 byte) k = checksum (1 byte) Slave Command Code Operation: 'c' = check answer 'w' = word reading answer (word = 2 byte) 'W' = word writing answer (word = 2 byte) Possible slave frames (Responses): Nok: l # s o k (l=5) Check: l ! s c k (l=5) Word read: l ! s w a n D11 D10 .. Dn1 Dn0 k Word write: l ! s W k 5.3.3.
Byte Code Meaning 0 27 Number of bytes in the frame (27h=39dec) 1 21 Slave string indicator "!" 2 00 Station address (it is always 0 in our boards) 3 77 word reading operation "w" 4 41 data start address (1(address in UIF_R.ram_tab)+40h(offset to add for ram reading)) 5 10 number of data (10h=16dec) 6 00 MSB of the 1st word of data (UIF_R.ram_tab[1]=UIF_R.var.rpm, speed) 7 00 LSB of the 1st word of data 8 00 MSB of the 2nd word of data (UIF_R.ram_tab[2]=UIF_R.var.
Example 2 PC request of writing 4 words in the structure UIF_W, starting from the third position (UIF_W.ram_tab[2], .., UIF_W.ram_tab[5]): Byte Code Meaning 0 0F Number of bytes in the frame (0Fh=15dec) 1 3F Master string indicator. ("?") 2 00 Station address (it is always 0 in our boards) 3 57 word writing operation "W" 4 42 data start address (2(address in UIF_W.
6. Motor Calibration using the PC GUI Interface A full calibration of the motor can be performed via the PC User Interface. The most important parameters to test are the following: 1. Stator resistance 2. Start-up current 3. Maximum current 4. Synchronous inductance 5. Current PI parameters 6. Speed PI parameters Warning: Do not try to start the motor before entering the initial calibration parameters otherwise the system could be damaged. 6.1.
6.2. Start Up current The start-up current parameter is responsible for the proper motor start-up. Please enter an average value that will not damage the motor. This value can be increased slowly if the motor fails to start at the end of the procedure. Click the button “Write” to save the new parameter value. Note: The value 3 in the picture below means 0.3 Amperes. Setting the start-up current during motor tuning 6.3. Maximum Current Maximum current specifies the maximum current to be imposed.
6.4.
6.5. Tuning the initial Current Pi Gains Current PI parameters allow a proper current control of the motor and the system. The software offers a particular procedure to help the tuning of the current PI gains. An oscilloscope is needed to see the response of the system to the stimulation; the figure below is showing the Test Point TP1 to be used for the calibration.
Connect the oscilloscope probes to the Test Point (TP1) and to the Ground of the board. The next step is to generate a current step and capture the current PI controller response in order to tune the current PI coefficients. To generate the current step and check the response on the oscilloscope, please enter “1” in the parameter 17, “PI Tuning trigger” and click on the button “Write”. This will generate a current step reference which amplitude is equal to the value specified as start-up current.
6.6. Tuning the Speed Pi Parameters Speed PI proportional gain (par. 13, “Speed Loop Kp”) and integral gain (par. 14, “Speed Loop Ki”) should be tuned in the real application and under load conditions. As starting values, low values can be chosen; they can be increased at medium working speed until instability arises; (high frequency instability is related to the proportional value too high, low frequency instability is related to integral value too high).
7. 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: A stator formed by stacking sheared metal plates where internally the copper wiring is wound, constructing the stator winding. A rotor in which permanent magnets are fixed.
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 b’ c’ m ’ a axis c ’ 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.
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: di m dt di v RS i L m dt v RS i L A second reference frame is used to represent the equations as the frame is turning at the rotor speed.
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: 3 2 p The angular speed is represented in the scheme as e to distinguish the electrical speed from the mechanical one.
8. Sensorless F.O.C. algorithm Please, find below the sensor-less FOC algorithm block diagram. 0 [Idref] Id PI + Vd Vq (d, q) → (, ) (, ) → (u, v, w) V V PWM Modulation Motor ref Speed PI Iqref + + Current Reading (z-1) Iq PI z-1 z-1 z-1 z-1 - - z-1 est Speed estimation Idmea Iqmea est (, ) → (d, q) Flux Phase estimation Imea I mea (u, v, w) → (, ) Sensorless F.O.
9. Software Description In the YRMCKITRL78G14 kit the software is working on an RL78G14 [32MHz]. The total software uses the following resources: 1) FLASH 15Kbytes 2) RAM : 2Kbytes Please Note that this data also include the communication interface and the demo board management.
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 Main Control Flow
Control Interrupt Phase currents (iumea, ivmea) reading 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 e
10. Start-up Procedure 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 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. 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.
11. Reference System Transformations in Detail Find below the detailed equations used for the coordinates transformations.
12. PWM Modulation Technique Among the various possibilities, a particular form of PWM modulation was chosen. In this modulation technique, the voltages to be imposed are shifted in order to have in every moment one of the three phases of the motor connected to the system ground. This allows reducing the commutations of the power bridge of one third, in respect to other modulation techniques.
13. Internal Representation of Physical Quantities Since the algorithm uses fixed point arithmetic, an internal representation of the physical quantities was chosen, in order to represent with sufficient resolution the quantities, to reduce to the minimum the necessary calculations, and to manage the great part of applications.
14. List of variables used in “motorcontrol.c” The file “motorcontrol.c” includes the motor control algorithm routines. Please find below the description of the variables used.
Label(s) Type Description Unit kp_vel, ki_vel int16_t Proportional and integral constant in speed PI controller. rpmrif_x int16_t Reference speed (speed ramp input value). rpm rpmrif_y int16_t Reference speed (speed ramp output value). rpm vbus int16_t DC link voltage. Internal voltage unit xvbf int16_t DC link voltage, minimum ripple value, used for voltage clamping. Internal voltage unit vfmax int16_t Maximum allowed phase voltage (star).
Label(s) Type Description xvbm int32_t Vbus filter memory vbusmem int32_t Vbus visualization filter memory vdm, vqm int32_t D, q axis voltage visualization filter memories idm, iqm int32_t D, q axis current visualization filter memories omegaem int32_t Angular velocity visualization filter memory Unit
15. Application Customisation The software designed on the RL78G14 is very flexible and can be easily configured via a single file called: “customize.h” located in the Workspace of the RL78G14 project. The “customize.h” is a file containing some macros used to specify some important program parameters. The most important of them are summarized below.
16. Renesas Flash Programmer Usage The following section how to set up and use the Renesas Flash Programmer interface (RFP) with the YRMCKITRL78G14 motor control kit.
The following screen should open. Press the Microcontroller drop down tab and select the RL78 option. This should now show all the RL78 devices. The kit can support two RL78/G14 devices. The 64 pin R5F104LE or the 100 pin R5F104PJ.
Select the following settings 1. Scroll down and select the RL78/G14 device 2. Enter the RFP workspace name 3. Select a location to save the RFP workspace files (use the browse button). 4. Press the OK button 1. Select the RL78/G14 device from the list 3. Select the RFP project location 2.
Press the “Next” button to select the communications interface Press the “Select Tool” drop down menu and select the communications port that the board is connected to as shown below
Press the “Next” button to select the power supply setting The power supply should be set at 5.00V (Default) Press the “Next” button to complete the set-up A status screen will open as shown below.
The hex file to be programmed needs to selected Press the “Browse” button and locate the hex file to be programmed into the RL78/G14. Follow the instructions to select the file. The file name should appear in the User/Data area as shown below Next the command needs to be set Press the “Microcontroller” menu button and select the “Autoprocedure (E.P)” option. This will execute the following sequence when the large “START” button is pressed.
Example of “Signature Read” Press the large START button to execute the command The RFP will open a progress bar and connect to the board and device. The results of reading from the device should be as shown below. If the larger RL78/G14 is used then the results will show the details from that device.
To program the Hex code select the “Autoprocedure(E.P)” option from the Microcontroller menu and press the “START” button. The results should be as shown below The full list of the progress and status is shown below ========== (Connect) ========== ------ Start(Autoprocedure(E.P)) -----Blank check Code flash: Not blank, Erase need. Erasing... Erase Code flash : PASS Blank check Data flash: PASS. Erase skipped.
17. IAR Embedded Workbench Usage The following section how to set up and use the IAR Embedded Workbench with the YRMCKITRL78G14 motor control kit. Before connecting the USB cable to the board and the PC, ensure that the jumpers are set as below Jumpers JP3, JP4, JP5, JP6 and JP7 Pins 1–2 connected Jumper JP1 and JP2 can be connected either as 1-3 or 4-6 Please note 1.
To open the YRMCKITRL78G14 IAR motor control workspace and project follow the sequence shown below File => Open => Workspace => C:\Workspace\YRMCKITRL78G14\ MCRP08_RL78G14obj_2.0\...=> Select the “ MCRP08_RL78 ” IAR Workspace file => Press Open The project should then open in the IAR IDE and should look something like the window below Please note that depending on setting used previously then the IAR workspace and project windows can look slightly different.
Next the debugging interface should be selected. The IAR debugger should be set to use the direct virtual UART connection (TK).
From the “Options” menu, first select the “Debugger” option and then from the drop down menu select the “TK” interface driver from the drop down menu as shown below. Select the Debugger option Select the TK driver option Press the “OK” button The next step is to build the project The necessary settings have been set in the IDE so that it is not necessary to configure or make changes to any of the build options.
Build results To launch the IAR debugger, press the green arrow button on the embedded workbench IDE window. Start the debugger, download the code to the RL78/G14 and enter debug mode Start the debugger and enter debug mode without programming the RL78/G14 If the debugger is being used for the first time the emulator needs to be configured before connecting and downloading the code to the board and RL78/G14. This applies to any hardware emulation setting and (i.e.
Press the “OK” button The configuration window will open as shown below Please check that the settings are as shown in the window below, changing any setting as necessary and then press the “OK” button The IAR debugger will open a progress window which will initially to connect to the board and then program the RL78/G14. Once this stage is complete the debugger window will open as shown below. Please note that the debugger window may contain different settings.
Other debugging windows can be opened to “watch variables, monitor registers, view the Stack, memory etc. These can be selected by using the “View” menu tab at the top of the workbench and then selecting the required debugging function. Please note that there are some other debugging function such as “Events” that are located under the “Emulator” tab.
The main debugging control functions are shown below. For a full explanation of all debugging options, please use the full documentation included in the IAR installation. These can be accessed via the help menu button in the embedded workbench IDE.
18. Online technical support and information The contact details for the support are as detailed below Technical Contact Details America: techsupport.america@renesas.com Europe: www.renesas.com/motor Jappant: csc@renesas.com Websites: America: www.am.renesas.com/motor Europe: www.renesas.eu/motor Jappant: www.renesas.com ©2011 Renesas Electronics Europe Ltd. All rights reserved ©2011 Renesas Electronics Corporation. All rights reserved ©2011 Renesas Electronics Solution Corp Ltd.
Revision History Rev. 0.10 1.00 Date April.
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.