AN07-00180-3E FR Family FR60 Lite 32-BIT MICROCONTROLLER MB91F267N bits pot red CAN-Motor board User’s Manual
AN07-00180-3E Revision History Date Revision August 01, 2008 Revision 1.0: Initial release September 17, 2008 Revision 1.1 On p.12, type corrected. Correct: NL565050T-103J, Incorrect: L565050T-103J October 22, 2008 Revision 1.2 On p.13, a download web page is changed. On p.20, "1.1.1 Downloading the software" is added. On p.25, p.30, p.36 and p.43, Description is corrected about the extracting file. The file path is added.
AN07-00180-3E Note - The contents of this document are subject to change without notice. Customers are advised to consult with FUJITSU sales representatives before ordering. - The information, such as descriptions of function and application circuit examples, in this document are presented solely for the purpose of reference to show examples of operations and uses of Fujitsu semiconductor device; Fujitsu does not warrant proper operation of the device with respect to use based on such information.
AN07-00180-3E Table of Contents Revision History ......................................................................................................................... 2 Note .......................................................................................................................................... 3 Introduction .............................................................................................................................. 10 Contact .........................................
AN07-00180-3E 5.2 6 CAN specifications ................................................................................................... 84 5.2.1 CAN frame configurations ................................................................................. 84 5.2.2 Arbitration ............................................................................................................. 88 5.2.3 Error management ...........................................................................................
AN07-00180-3E List of Figures Figure 1-1 External board view ......................................................................................... 14 Figure 1-2 System connection diagram ............................................................................ 16 Figure 1-3 Downloading the USB driver ................................................................................ 20 Figure 1-4 Installing FT232R USB UART .............................................................................
AN07-00180-3E Figure 2-11 Opening the file to write ..................................................................................... 43 Figure 2-12 Selecting the file to write .................................................................................... 44 Figure 2-13 Select the COM port to be used for the writing ...................................................... 45 Figure 2-14 Checking the COM port .....................................................................................
AN07-00180-3E Figure 4-9 Motor operation flowchart .................................................................................... 75 Figure 4-10 Operation mode settings ..................................................................................... 76 Figure 4-11 Main function ................................................................................................... 76 Figure 4-12 SW2 interrupt ............................................................................................
AN07-00180-3E List of Tables Table 1-1 Component list.................................................................................................... 13 Table 1-2 Description of the respective board parts .................................................................. 15 Table 1-3 MB91F267N pin assignment .................................................................................. 17 Table 3-1 Single-unit operation/Descriptions of the controls and mechanicals .............................
AN07-00180-3E Introduction Thank you very much for purchasing the bits pot red (referred to as this starter kit or the starter kit hereafter). This starter kit is a beginner’s kit intended for those who wish to start learning microcontrollers and on-board network processors. The kit is designed so that the beginners who ask “What is a microcontroller?”, “How does it work?” and “How does it control a network?” can easily learn what it is.
AN07-00180-3E Contact For inquiries about this starter kit, contact the following address. Zip code: 105-8420 2-5-3 Nishi-Shinbashi, Minatoku, Tokyo E-mail: pd-bitspot@tsuzuki-densan.co.jp bits pot URL: http://www.tsuzuki-densan.co.
AN07-00180-3E Suppliers of the parts/materials Capacitors 22 pF : GCM1552C1H220JZ02 0.
AN07-00180-3E 1 Setting up the starter kit Before using this starter kit, be sure to check the components listed in Table 1-1 are fully supplied. Before connecting the bits pot red CAN-Motor board (referred to as the board hereafter), you need to install software in your PC. You can download the software required for the starter kit from the following web site. bits pot URL: http://www.tsuzuki-densan.co.jp/bitspot/ Table 1-1 Component list No. Article Qty.
AN07-00180-3E (5) USB to UART converter (4) CAN connector (6) USB connector (3) CAN transceiver (9) DC jack (17) Jumper pin (15) Fuse (7) Motor driver circuit (18) Extension power (5V) (19) Extension GND (16) Extension pins (1) Target device (2) Target device oscillator (10) Mode SW (8) Motor connector (14) Temperature sensor (12) Test SW (13) LED lamps (11) Reset SW Figure 1-1 External board view - 14 -
AN07-00180-3E “Table 1-2 Description of the respective board parts” provides descriptions of the respective board parts. Table 1-2 Description of the respective board parts No. Name Function Description (1) Target device MB91F267N Main microcontroller (MB91F267N). (2) Target device oscillator CSTCR4M00G15C Ceralock made by Murata Manufacturing Oscillator for the main microcontroller. (3) CAN transceiver MAX3058ASA+ Transceiver IC for CAN communication. Connector for CAN communication.
AN07-00180-3E (18) Extension power (5V) - Extension 5-V power terminal. (19) Extension GND - Extension GND terminal. “Figure 1-2 System connection diagram” shows the connection of the system. * Prepare the PC by yourself. AC adapter (accessory) Use the AC adapter included in the kit for the connection. (The motor power is supplied from the AC adapter.) Use the USB cable included in the kit for the connection. (The power is supplied from the USB bus power.
AN07-00180-3E “Table 1-3 MB91F267N pin assignment” shows the pin assignment of the main microcontroller MB91F267N. Table 1-3 MB91F267N pin assignment Pin No.
AN07-00180-3E 32 INT6/PPG5/RX0/P16 CAN TRANSCEIVER 33 PPG6/TX0/P17 CAN TRANSCEIVER 34 ADTG1/IC2/P20 Motor driver circuit 35 ADTG2/IC3/P21 - 36 PWI0/P22 - 37 DTTI/P23 - 38 CKI/P24 - 39 IC0/P25 Motor driver circuit Hall U-phase 40 IC1/P26 Motor driver circuit Hall V-phase 41 P27 SW5 42 PPG0/PG1 - 43 MD2 SW4 44 MD1 GND 45 MD0 GND 46 X0 Q1 4-MHz oscillator 47 X1 Q1 4-MHz oscillator 48 Vss GND 49 PPG4/P37 - 50 INT7/PPG7/P36 - 51 INIT RESET(SW1) 52
AN07-00180-3E 1.1 Setting up the PC Install the software required to operate this starter kit into the PC. To set up the PC, take the following procedures.
AN07-00180-3E 1.1.1 Downloading the software Download the file from the following web site, and extract the file. bits pot URL: http://www.tsuzuki-densan.co.jp/bitspot/ 1.1.2 Installing a USB driver Install a USB driver. From the FTDI web page shown below, download the Windows driver as directed in “Figure 1-3 Downloading the USB driver”. http://www.ftdichip.com/Drivers/D2XX.htm Click on the driver version to download.
AN07-00180-3E After downloading the driver, decompress it, and then connect the board to the PC by using the USB cable included in the kit. As shown in “Figure 1-4 Installing FT232R USB UART”, the dialog for “FT232R USB UART” installation is displayed; select “Install from a list or specific location”, and then click the “Next” button.
AN07-00180-3E As shown in “Figure 1-5 Selecting the search locations”, to search for the installation file, check “Search for the best driver in these locations” and “Include this location in the search” only, select the location at which the driver was decompressed, and then click the “Next” button; installation of the driver starts.
AN07-00180-3E After that, as shown in “Figure 1-7 Installing USB Serial Port”, installation of “USB Serial Port” is indicated; select “Install from a list or specific location” and then click the “Next” button.
AN07-00180-3E When the driver installation ends, the dialog shown in “Figure 1-9 Completing the USB Serial Port installation” is displayed; Click the “Finish” button.
AN07-00180-3E 1.1.3 Installing the integrated development environment SOFTUNE (bits pot dedicated version) Note If SOFTUNE V6 of the product version has been installed, first uninstall it, and then install the bits pot dedicated version. Start installing the integrated development environment SOFTUNE. Extract the following file from the inside of the folder extracted by “1.1.1 Downloading the software”. ¥softwares¥softune¥REV600010-BV.zip Double-click “Setup.
AN07-00180-3E The dialog shown in “Figure 1-12 Caution on SOFTUNE setup” is displayed; click the “Next” button. Figure 1-12 Caution on SOFTUNE setup The dialog shown in “Figure 1-13 SOFTUNE setup/License agreement” appears; read through the agreements and then click “Yes” button.
AN07-00180-3E The version information is displayed as shown in “Figure 1-14 SOFTUNE setup/Version ”; click the “Next” button. Figure 1-14 SOFTUNE setup/Version information The dialog about the destination of installation shown in “Figure 1-15 SOFTUNE setup/Selecting the destination of installation” appears; select the default folder or desired folder and then click the “Next” button.
AN07-00180-3E The dialog for component selection is displayed as shown in “Figure 1-16 SOFTUNE setup/Selecting the components”; keep the default settings and then click the “Next” button. Figure 1-16 SOFTUNE setup/Selecting the components As shown in “Figure 1-17 SOFTUNE setup/Confirming the installation settings”, the dialog for confirmation of the installation settings is displayed. Click the “Next” button; installation begins.
AN07-00180-3E The dialog shown in “Figure 1-18 SOFTUNE setup/Completion” appears to tell the completion of installation; click the “Finish” button.
AN07-00180-3E 1.1.4 Installing PC Writer (bits pot red dedicated version) Start installing PC Writer. Confirm the following file from the inside of the folder extracted by “1.1.1 Downloading the software”. ¥softwares¥pc writer¥MB91F267NA_setup.exe Double-click “MB91F267NA_setup.exe”; the dialog shown in “Figure 1-19 PC Writer/Installation dialog” appears and installation starts; click the “Next” button.
AN07-00180-3E The dialog shown in “Figure 1-20 PC Writer/Setup type” appears; select “All”, and then click the “Next” button. Figure 1-20 PC Writer/Setup type The dialog shown in “Figure 1-21 PC Writer/Ready to install” appears to tell that the setup is ready to install PC Writer; click “Install”.
AN07-00180-3E After the installation ends, the dialog shown in “Figure 1-22 Completing the PC Writer ” appears to tell the completion of installation; click “Finish”.
AN07-00180-3E 1.1.5 Configuring the evaluation board and connecting it to the PC After SOFTUNE installation, configure a switch on the board and then connect it to the PC. Set the “MODE” selector on the board to “PRG”. Set the MODE selector to “PRG”. Figure 1-23 MODE selection MODE selector Operation PRG FLASH memory serial write mode →Used to write a program into the microcontroller. RUN Single ship mode →Used to run the program written into it. Make sure that the MODE selector is set to “PRG”.
AN07-00180-3E Connect the USB cable included in the kit to a USB port on the PC and the USB port on the board. Be sure to directly connect between them without using a USB hub. Connect a USB port on the PC. For information about port locations and so forth, refer to the manual of the PC. USB port After SOFTUNE installation, connect the USB cable. Figure 1-24 Connection between the PC and the board The power of the board is supplied via USB (USB bus power).
AN07-00180-3E 2 Running the program To run a program with the starter kit, take either of the following procedures. (1) Executing in single chip mode Go to P.36 (2) Debugging by using Monitor Debugger Go to P.
AN07-00180-3E 2.1 Executing in single chip mode In single chip mode, take the following procedures. (1) Building a project (2) Writing the program into the microcontroller 2.1.1 Building a project Preparation Extract the following file from the inside of the folder extracted by “1.1.1 Downloading the software”. ¥sample programs¥bitpot_red_SampleProgram.zip Select “Start” → “All Programs” → “Softune V6” → “FR Family Softune Workbench” to activate SOFTUNE.
AN07-00180-3E As shown in “Figure 2-2 Selecting a workspace”, the dialog that allows you to select a workspace is displayed. Select the folder containing the sample program, “bitpot_red_SampleProgram.wsp”, and then click “Open”. ¥bitpot_red_SampleProgram¥bitpot_red_SampleProgram.wsp Figure 2-2 Selecting a workspace The workspace opens; from the “project” menu, click “Build” to build it.
AN07-00180-3E The message pane at the bottom of the window shows a message that tells no error was found as shown in “Figure 2-4 Completing the build” to inform you of successful build. Figure 2-4 Completing the build 2.1.2 Writing the program into the microcontroller Preparation Set MODE on the board to “PRG” in advance. Select “Start” → “All Programs” → “FUJITSU FLASH MCU Programmer” → “MB91F267NA” to activate PC Writer.
AN07-00180-3E The dialog that allows you to select the file is displayed as shown in “Figure 2-6 Selecting the file to write”; select the file built in “2.1.1 Building a project” and then click “Open”. ¥bitpot_red_SampleProgram¥Debug¥ABS¥bitpot_red_SampleProgram.
AN07-00180-3E Then, select the COM port to be used for the writing. Click the “Set Environment” button; the COM port selection dialog appears. Select the COM port with which the board is connected, and then click the “OK” button. Click this.
AN07-00180-3E To check the COM port in use, right-click “My Computer” and then select “Properties”; the system properties are displayed. Select the “Hardware” tab and then click the “Device Manager” button. After Device Manager activates, check the COM port number in the parentheses of “USB Serial Port (COM n)” under “Port (COM and LPT)” in the tree shown in “Figure 2-8 Checking the COM port”. Check this.
AN07-00180-3E As shown in “Figure 2-9 Writing the program”, press the “Full Operation” button to start writing the program; the dialog that asks you to press the Reset switch is displayed. Press the Reset SW on the board, and then click the “OK” button on the dialog; the program write sequence starts. For the location of the Reset SW, see “Figure 1-1 External board view”.
AN07-00180-3E 2.2 Debugging by using Monitor Debugger To debug by using Monitor Debugger, take the following procedures. (1) Writing Monitor Debugger into the microcontroller (2) Activating SOFTUNE and configuring the debug settings (3) Writing the program into the microcontroller (4) Loading the target file (5) Running the debugger 2.2.1 Writing Monitor Debugger into the microcontroller Preparation Extract the following file from the inside of the folder extracted by “1.1.
AN07-00180-3E As shown in “Figure 2-12 Selecting the file to write”, the dialog that allows you to select the file to write appears; select the file as shown below, and then click “Open”. ¥FR60¥Debug¥ABS¥FR60.
AN07-00180-3E Then, select the COM port to be used for the writing. Click the “Set Environment” button; the COM port selection dialog appears. Select the COM port with which the board is connected, and then click the “OK” button. Click this.
AN07-00180-3E To check the COM port in use, right-click “My Computer” and then select “Properties”; the system properties are displayed. Select the “Hardware” tab and then click the “Device Manager” button. After Device Manager activates, check the COM port number in the parentheses of “USB Serial Port (COM n)” under “Port (COM and LPT)” in the tree shown in “Figure 2-14 Checking the COM port”. Check this.
AN07-00180-3E As shown in “Figure 2-15 Writing the program”, press the “Full Operation” button to start writing the program; the dialog that asks you to press the Reset switch is displayed. Press the Reset SW on the board, and then click the “OK” button on the dialog; the program write sequence starts. For the location of the Reset SW, see “Figure 1-1 External board view”.
AN07-00180-3E 2.2.2 Activating SOFTUNE and configuring the debug settings Preparation Set MODE on the board to “RUN” in advance, and then press the Reset button. Select “Start” → “All Programs” → “Softune V6” → “FR Family Softune Workbench” to activate SOFTUNE. As shown in “Figure 2-17 Opening a workspace”, from a menu of SOFTUNE, select “File” → “Open Workspace” to open a workspace.
AN07-00180-3E As shown in “Figure 2-18 Selecting a workspace”, the dialog that allows you to select a workspace is displayed. Select the folder containing the sample program, “bitpot_red_SampleProgram_md.wsp”, and then click “Open”. ¥bitpot_red_SampleProgram_md¥bitpot_red_SampleProgram_md.wsp Figure 2-18 Selecting a workspace The workspace opens; from the “project” menu, click “Build” to build it.
AN07-00180-3E The message pane at the bottom of the window shows a message as shown in “Figure 2-20 Completing the build”. A warning is displayed but the build has been successfully ended. (The warning indicates no problem.) Figure 2-20 Completing the build Then, configure the debug settings. As shown in “Figure 2-21 Changing the debug settings”, expand “Debug”, select “mon_38400.sup”, and then right-click on it. A menu appears; click “Change Settings”.
AN07-00180-3E As shown in “Figure 2-22 Starting the debug setting ”, the debug setup wizard is displayed; click the “Next” button. Figure 2-22 Starting the debug setting wizard Select the debugger type as shown in “Figure 2-23 Selecting the debugger type”; select “Monitor Debugger”, and then click the “Next” button.
AN07-00180-3E Select the device type as shown in “Figure 2-24 Selecting the device type”. Set “RS” to the device name, set the COM port number to which the board is connected to the port name, set “38400” to the baud rate, and then click the “Next” button. Figure 2-24 Selecting the device type Specify nothing to the batch file field as shown in “Figure 2-25 Specifying a batch file”; keep the field left blank and click the “Next” button.
AN07-00180-3E Just ignore the target file settings as shown in “Figure 2-26 Configuring the target file settings”; click the “Next” button. Figure 2-26 Configuring the target file settings As shown in “Figure 2-27 Setting setup file selection”, select “Specify” for setup file selection, and then click the “Next” button.
AN07-00180-3E On the dialog shown in “Figure 2-28 Completing the setup wizard”, click the “Finish” button to finish configuring the settings. Figure 2-28 Completing the setup wizard Start debugging as shown in “Figure 2-29 Start debugging”.
AN07-00180-3E 2.2.3 Writing the program into the microcontroller As shown in “Figure 2-30 Showing the commands window”, from the “View” menu, select “Commands” to show the program window.
AN07-00180-3E Input the following command into the field as shown in “Figure 2-31 Inputting commands”, and then click the “Enter” button. The program is started to be written. bat FshLdWrt.prc Figure 2-31 Inputting commands As shown in “Figure 2-32 Completing the program writing”, the command window shows “Write Flash Memory Success” to notify you of successful completion of the program writing into the microcontroller.
AN07-00180-3E 2.2.4 Loading the target file As shown in “Figure 2-33 Loading the target file”, from the “Debug” menu, select “Load Target File”. The target file is loaded; you can set break points at desired points.
AN07-00180-3E 2.2.5 Running the debugger As shown in “Figure 2-34 Setting break points”, you can set break points to lines with a green round mark on the left side in the source file. Note that you cannot set break points while the program is running. Click this to set a break point. To cancel the break point, click this again. Figure 2-34 Setting break points As shown in “Figure 2-35 Running the program”, click the “Run Continuously” icon to run the program.
AN07-00180-3E As shown in “Figure 2-36 Stopping the program”, click the × button for closing the application on the upper right side of the window to stop running the program. Although a warning dialog for the stop is displayed, click the “Abort” button in any case. Figure 2-36 Stopping the program 2.2.6 Notes on Monitor Debugger Note that Monitor Debugger has the following restrictions. ・ Only up to 16 break points can be set.
AN07-00180-3E 3 Operation of the sample program This section describes the operation of the sample program. The operation of the sample is classified into the following two categories.
AN07-00180-3E 3.1 bits pot red single-unit operation “Figure 3-1 Single-unit operation/Controls and mechanicals” shows the controls and mechanicals, and “Table 3-1 Single-unit operation/Descriptions of the controls and mechanicals” provides descriptions about them. SW2, SW3, SW5, and temperature sensor on the board control the operations of the green and red LEDs and BLDC motor.
AN07-00180-3E Table 3-1 Single-unit operation/Descriptions of the controls and mechanicals No. Name Function Description Switches between RPG mode and RUN mode. (1) Mode SW Control PRG: Write a program RUN: Run the program (2) Reset SW Control Rests the MCU when pressed. Rotates/stops the motor in turn when pressed. The (3) SW2 Control motor rotates if it is stopped and stops if it is rotating when this switch is pressed. Brakes the (stops) motor if it is rotating when pressed.
AN07-00180-3E 3.2 CAN communication operation (CAN communication operation with the bits pot white) “Figure 3-2 CAN communication operation/Controls and mechanicals” shows the controls and mechanicals, and “Table 3-2 CAN communication operation/Descriptions of the controls and mechanicals” provides descriptions about them. The bits pot white performs CAN communication, and on execution of a motor operation command, the green and red LEDs and BLDC motor work.
AN07-00180-3E Table 3-2 CAN communication operation/Descriptions of the controls and mechanicals No. Name Function Description Switches between RPG mode and RUN mode. (1) Mode SW Control PRG: Write a program RUN: Run the program (2) Reset SW Control Rests the MCU when pressed. Returns the temperature measured by this temperature (3) Temperature sensor Control sensor on a temperature measurement command in CAN communication.
AN07-00180-3E 4 Try to rotate the BLDC motor In these days, motors are indispensable in our daily life. Motors are now used in various places, for example, air conditioners, compressors of refrigerators, turn tables of CD and DVD drives, and wipers and door mirrors of vehicles. This chapter provides descriptions about how to rotate the BLDC motor by using a microcontroller macro. 4.1 What is the BLDC motor? The BLDC motor is a DC brushless motor that is a type of motors.
AN07-00180-3E 4.2 How does the BLDC motor rotate? The BLDC motor has three phases different by 120°. As shown in “Figure 4-2 Names of the respective elements”, the phases are called the U-phase, V-phase, and W-phase respectively. The switches on the driver circuit are respectively called U-High, U-Low, V-High, V-Low, W-High, and W-Low and connected as outputs from the microcontroller.
AN07-00180-3E 0° 120° 240° 360° 480° 1 Hall-U 0 1 Hall-V 0 1 Hall-W 0 ON U-High ON U-Low ON V-High ON V-Low ON W-High ON W-Low U + - V + - W + - Figure 4-3 120° conduction method time chart - 67 -
AN07-00180-3E 4.3 BLDC motor rotation control by the microcontroller This section describes how the BLDC motor is practically controlled with the 120° conduction method by the microcontroller. On the board, as shown in “Figure 4-4 Motor driver circuit”, the microcontroller is connected with the motor driver circuit. The relationship of the connections with the semiconductor elements described in “4.
AN07-00180-3E Table 4-1 Microcontroller pin/Motor driver circuit connections Microcontroller Pin name Name of the semiconductor pin number element connected Pin57 RTO0 U-High Pin56 RTO1 U-Low Pin55 RTO2 V-High Pin54 RTO3 V-Low Pin53 RTO4 W-High Pin52 RTO5 W-Low RTO0 to 5 ON/OFF control is practically taken by the macro in the microprocessor mounted on the board. So, it is necessary to configure registers for functions employed by the macro.
AN07-00180-3E Table 4-3 Description of the timer control registers and setting values Register name Setting value [function] Description TCCSH0_ECKE 0 [internal clock] Clock select bit TCCSH0_IRQZF 0 [bit clear] 0 detection interrupt flag bit TCCSH0_IRQZE 0 [interrupt request disable] 0 detection interrupt request enable bit TCCSH0_MSI2 - Interrupt mask select bits TCCSH0_MSI1 - Not used TCCSH0_MSI0 - TCCSH0_ICLR 0 [bit clear] Compare clear interrupt flag bit TCCSH0_ICRE 1 [interrup
AN07-00180-3E The registers used for the 16-bit output compare function are as shown in “Figure 4-6 Output compare registers”. A description of the registers and their setting values in the sample program are as described in “Table 4-4 Description of the output compare registers and setting values”. For more information of the registers, refer to the microcontroller hardware manual.
AN07-00180-3E Table 4-4 Description of the output compare registers and setting values Register name Setting value [function] Description CPCLRB0 1599 Compare value setting OCCPB0 1598 Output compare value settings OCCPB1 1000 OCCPB2 1598 OCCPB3 1000 OCCPB4 1598 OCCPB5 1000 OCMOD 0xFF [1 output on a match] Designation of the operation on a compare match OCSH1,3,5_BTS1 1 [transfer on a compare clear Buffer transfer select bit (ch 1,3,5) match] OCSH1,3,5_BTS0 1 [transfer on a compar
AN07-00180-3E Initialize the 16-bit free-run timer and 16-bit output compare functions as shown in “Table 4-3 Description of the timer control registers and setting values”, “Table 4-4 Description of the output compare registers and setting values”. After the initialization, running the 16-bit free-run timer starts a count up using the value configured to CPCLRB0 as the carrier peak as shown in “Figure 4-7 Operation of the free-run timer”.
AN07-00180-3E CPCLRB0 value OCCPB0 value 0 Time→ U-High Figure 4-8 U-High output to output comparisons - 74 -
AN07-00180-3E 4.4 Understanding and running the program for the BLDC motor operation This section provides descriptions of the sample program that can really serve to operate the BLDC motor. “Figure 4-9 Motor operation flowchart” shows the sequence of the sample program flow. First, the microcontroller is initialized, and then the motor macro is initialized. After that, the program goes into a loop. In the loop, pressing SW2 starts the free-run timer and the motor macro starts operating.
AN07-00180-3E Now, take a look at the details of the program. Look into the following folder of the sample program. There are some files stored in it. At first, open MAIN.C first. ¥bitpot_red_SampleProgram¥Debug¥SRC Look at around Line 40 that looks “Figure 4-10 Operation mode settings” for operation mode selection. There are #define settings that enable (1) or disable (0) CAN and temperature sensor. In this program, CAN is not to be used and the temperature sensor is to be used.
AN07-00180-3E When SW2 is pressed, an interrupt takes place. Around Line 763 in MAIN.C, the interrupt function IRQ_ext_0 is invoked as shown in “Figure 4-12 SW2 interrupt”. In it, the register value of TCCSL0_STOP, which is used to start/top the free-run timer, is changed.
AN07-00180-3E 4.5 Handling controls of the BLDC motor You were able to rotate the BLDC motor by using the microcontroller macro. Then, try to control the rotation speed, brake, and rotation direction now. In the sample program, the controls are handled in the infinite loop inside the main function shown in “Figure 4-11 Main function”. The rotation speed is determined according to the temperature sensor or input from programmed variables, and the brake is applied whether SW3 is pressed.
AN07-00180-3E The rotation speed routine is written around Line 166 in the MAIN.C main function as shown in “Figure 4-15 Rotation speed control”. When the temperature sensor is used, the rotation speed is determined in the range of 0 to 100% by a conversion according to the A/D value obtained from the temperature sensor and the upper limit.
AN07-00180-3E The brake control routine is written around Line 192 in the MAIN.C main function as shown in “Figure 4-16 Brake control”. While SW3 is pressed, the outputs to all the semiconductor elements are set to off and the brake is applied to the motor.
AN07-00180-3E The rotation direction routine is written around Line 221 in the MAIN.C main function as shown in “Figure 4-17 Rotation direction control”. When SW5 is set to the right side, the motor rotates to the right, and when it is set to the left side, the motor rotates to the left.
AN07-00180-3E 5 Try to use CAN communication Communication is to send/receive information. There are various types of communication such as utterance/hearing of spoken words, writing/reading of written letters, and electrical transmission of information. Among them, there are various standards for communication based on electrical transmission. This chapter describes a communication standard called CAN. CAN is a global standard of the ISO (International Organization for Standardization). 5.
AN07-00180-3E The features of CAN can be classified into the following five points. 1. Multi-master communication CAN employs the multi-master system in which each node is allowed to start communication as desired. The timing of a start of communication is occurrence of an event. The word “event” mentioned here indicates an occasion at which a node needs to start communication. CAN avoid conflicts in communication through mediation with node signals if more than one event occurs on nodes simultaneously.
AN07-00180-3E 4. High-speed version and low-speed version There are two CAN specifications with different communication speeds. One of them is High-speed-CAN. High-speed-CAN is standardized as ISO11898 and its maximum and minimum communication speeds are 1 Mbits/sec and 125 kbits/sec. The other is Low-speed-CAN. Low-speed-CAN is standardized as ISO11519 and its maximum communication rate is 125 kbits/sec.
AN07-00180-3E Data frame Remote frame Error frame Overload frame Arbitration field Control field Arbitration field Control field Error flag field Error delimiter field Data field CRC field CRC field ACK field Overload Overload flag delimiter field field Figure 5-3 CAN frame configurations - 85 - ACK field
AN07-00180-3E 1. Data frame Transfer format for data transmit. It consists of seven fields. Field name Start of frame (SOF) Description 1-bit field containing “0” that indicates the start of a data frame Arbitration field Field that determines the priority of the data. This field is also called the ID field and there are two types of format; standard format and extended format. The standard format is 12 bits and extended format is 32 bits.
AN07-00180-3E 4. Overload frame Transfer format sent to indicate that the node is in unreceivable status Field name Description Overload flag 6-bit to 12-bit field that indicates the type of overload. Overload delimiter 8-bit field containing “1” that indicates the end of the error frame.
AN07-00180-3E 5.2.2 Arbitration CAN employs the multi-master communication system, so any node can start communication. But, the number of communication sessions actually allowed on one bus is only one. Each node is cyclically checking whether the bus is the status of transmission. When there is no transmission on the bus, communication is started, but if more than one node starts transmission, they conflict. Against this, CAN performs arbitration to give priority to one with a lower ID for transmission.
AN07-00180-3E giving priority to the Node 1 transmission with a lower ID. After Node 1 ends its transmission, Node 2 resumes transmission. After that, Node 1 and Node 3 starts transmission simultaneously. The arbitration is also performed and results in giving priority to the Node 3 transmission. After that, Node 4 starts transmission as soon as Node 3 ends its transmission. On this occasion, arbitration between Node 1 retransmission and Node 4 transmission is performed.
AN07-00180-3E 5.2.3 Error management CAN error management is defined in its protocol. Five types of error detection and three types of status are used. 1. Error detection As shown in “Table 5-1 Description of the error types”, errors that can be detected depends on whether the node is transmitting or receiving.
AN07-00180-3E Transition between the statuses is described below along the example shown in “Figure 5-6 CAN status transition”. The initial status of a node is error active. In this status, occurrence of errors increases the TEC/REC counters. If either of the TEC/REC counters comes to 127 or higher, the status of the node changes to error passive. In this status, the node remains communicable and the values of the counters decrease whenever a communication session is normally carried out.
AN07-00180-3E 5.3 CAN communication by using the microcontroller This section describes how to perform practical CAN communication with the microcontroller. On the board, as shown in “Figure 5-7 CAN circuit”, the microcontroller is connected with the CAN transceiver (MAX3058). TX0 on the microcontroller is used for transmission and RX0 is used for reception. Signals transmitted/received are transferred to CAN-High and CAN-Low as the differential signals on the bus through the CAN transceiver.
AN07-00180-3E The registers used for entire CAN communication control on the microcontroller are as shown in “Figure 5-8 Entire CAN communication control register”. The register bits whose name is “res” are reserved and not used. A description of the registers and their setting values in the sample program are as described in “Table 5-2 Description of the entire CAN communication control registers and setting values”. For more information of the registers, refer to the microcontroller hardware manual.
AN07-00180-3E Table 5-2 Description of the entire CAN communication control registers and setting values Register name Setting value [function] Description CTRLR0_Test 0 [normal operation] Test mode enable bit CTRLR0_CCE 1 [write enable] Bit timing register write enable bit CTRLR0_DAR 0 [automatic retransmit enable] Automatic retransmit prohibit bit CTRLR0_EIE 0 [code setting disable] Error interrupt code enable bit CTRLR0_SIE 0 [code setting disable] Status interrupt code enable bit CTRL
AN07-00180-3E 5.4 Understanding and running the program for CAN communication This section provides descriptions of the sample program that can serve for practical CAN communication. 5.4.1 CAN communication configuration “Table 5-3 CAN communication conditions of the sample program” shows the CAN communication conditions of the sample program.
AN07-00180-3E “Table 5-4 CAN message IDs in the sample program” provides a description of the message IDs used for CAN communication.
AN07-00180-3E Field name Setting value Motor rotation 0: Clockwise 1: direction Counterclockwise Brake application 0: Brake released 1: Brake Remarks - - applied Motor rotation speed 0 to 65535 The motor rotation speed and A/D maximum A/D maximum value 0 to 65535 value are used for conversion of the speed to a percentage of 0% to 100%. 3.
AN07-00180-3E byte 0 byte 1 byte 2 byte 3 byte 4 byte 5 byte 6 byte 7 Temperature information Reserved Reserved Reserved Reserved Reserved Reserved Reserved Field name Temperature Setting value 0 to 50 Remarks - information - 98 -
AN07-00180-3E 5.4.2 Sample program sequence “Figure 5-9 CAN communication flowchart” shows the CAN communication sequence of the sample program flow. First, the microcontroller is initialized. On the microcontroller initialization, the CAN operation timer starts operating. After that, the CAN driver is initialized. Then, the motor driving macro is initialized and then the program goes into a loop.
AN07-00180-3E Now, take a look at the details of the program. Look into the following folder of the sample program. There are some files stored in it. At first, open MAIN.C. ¥bitpot_red_SampleProgram¥Debug¥SRC Look at around Line 40 that looks “Figure 5-10 Operation mode settings” for operation mode selection. There are #define settings that enable (1) or disable (0) CAN and temperature sensor. In this program, both CAN and temperature sensor are to be used.
AN07-00180-3E As shown in “Figure 5-12 CAN timer interrupt control”, around Line 817 in MAIN.C, there is the timer interrupt function IRQ_reload1. In it, motor rotation information transmit, temperature sensor information transmit, and receive processing are handled.
AN07-00180-3E Details of motor rotation information transmit, temperature sensor information transmit, and receive processing are as described below. First, concerning motor rotation information transmit, as shown in “Figure 5-13 Motor rotation information transmit”, there is the canSendTask01 function around Line 577 in MAIN.C. Only when the motor is rotating, a message sent with CAN is created and the transmit function canSendData, which is a CAN driver API, is invoked.
AN07-00180-3E Concerning receive processing, as shown in “Figure 5-15 CAN receive processing”, there is the canRecvTask function around Line 625 in MAIN.C. First, the receive function canRecvData, which is a CAN driver API, is invoked by received ID, and then only those with receiveData are processed.
AN07-00180-3E 6 Appendix 6.1 Sample program folder/file configuration “Table 6-1 Sample program folder/file configuration” shows the folder/file configuration of the sample program. Table 6-1 Sample program folder/file configuration File/folder name Provision of the file Single bitpot_red_SampleProgram/bitpot_red_SampleProgram_md bitpot_red_SampleProgram.prj ○ bitpot_red_SampleProgram.wsp ○ bitpot_red_SampleProgram_md.prj bitpot_red_SampleProgram_md.wsp flash_erase_sec.bin flash_write.bin FshLdWrt.