Hall Sensor Based Control of BLDC Motor Using dsPIC33CK LVMC
MATLAB LVMC dsPIC33CK256MP508 HALL SENSOR BASED SIX STEP COMMUTATION
1. INTRODUCTION
This document describes the setup requirements for running the Hall Sensor Based Six Step Commutation of BLDC motor, using MATLAB/Simulink and dsPIC33CK Low Voltage Motor Control (LVMC) Board.
The algorithm is described in the Application Note AN957, “Sensored BLDC Motor Control Using dsPIC Digital Signal Controllers (DSCs)”.
2. SUGGESTED DEMONSTRATION REQUIREMENTS
2.1 MATLAB Model Required for the Demonstration
- MATLAB model can be cloned or downloaded as zip file from the Github repository (link).
2.2 Software Tools Used for Testing the MATLAB/Simulink Model
- MPLAB X IDE and IPE (v6.0)
- XC16 compiler (v2.00)
- MATLAB R2022a
- Required MATLAB add-on packages
- Simulink
- Simulink Coder
- MATLAB Coder
- Embedded Coder (v7.8)
- MPLAB Device blocks for Simulink (v3.50.24)
- Motor Control Blockset (v1.4)
NOTE: The software used for testing the model during release is listed above. It is recommended to use the version listed above or later versions for building the model.
2.3 Hardware Tools Required for the Demonstration
- dsPIC33CK Low Voltage Motor Control (LVMC) Development Board (DM330031)
- 24V Power Supply (AC002013)
- 24V, 3-Phase Brushless DC Permanent Magnet Hurst Motor (AC300022)
NOTE: All items listed under this section Hardware Tools Required for the Demonstration are available at microchip DIRECT.
3. HARDWARE SETUP
This section describes hardware setup required for the demonstration.
-
Connect the 3-phase wires from the motor to PHC, PHB, and PHA of the J14 connector and encoder wires from the motor to +5V, GND, HA, HB and HC terminals of connector J7 (in the same order as shown in the picture), provided on the dsPIC33CK LVMC Board.
NOTE: The phase and hall sensor connector sequence can be found in the Hardware Init block of the model, as shown below.
-
Plug in the 24V power supply to connector J1 provided on the dsPIC33CK LVMC Board. Alternatively, the Inverter Board can also be powered through Connector J2.
-
The board has an onboard programmer ‘PICkit™ On Board (PKoBv4)”, which can be used for programming or debugging the dsPIC33CK256MP508. To use an on-board programmer, connect a micro-USB cable between Host PC and Micro USB connector J13 provided on the dsPIC33CK LVMC Board.
-
Alternatively, the device can also be programmed using the programmer/debugger (MPLAB® PICkit™ 4 In-Circuit Debugger - PG164140) by interfacing it through connector J10 of the dsPIC33CK LVMC Board, as shown below. Ensure that the programmer is oriented correctly before proceeding.
4. BASIC DEMONSTRATION
Follow the below instructions step-by-step, to set up and run the motor control demo application:
-
Launch MATLAB (refer the section “2.2 Sofware Tools Used for Testing the MATLAB/Simulink Model").
-
Open the folder downloaded from the repository, in which MATLAB files are saved (refer the section "2.1 MATLAB Model Required for the Demonstration").
-
Double click and open the .m file. This .m file contains the configuration parameter for the motor and board. By default, the .m file is configured to run Hurst 300 motor and LVMC board. Run the file by clicking the “Run” icon and wait till all variables gets loaded on the ‘Workspace’ tab.
-
Double click on the Simulink model (.slx file). This opens the Simulink model as shown below.
In this model the algorithm can operate in two different control modes refered as Openloop_Duty_Control and Closedloop_Speed_Control. Select the mode to run the motor. Click on the "Run" icon to start the simulation.
Mode Description Openloop_Duty_Control The duty cycle is varied using the potentiometer Closedloop_Speed_Control The speed of the motor controlled using the closedloop PI controller -
To plot the simulation result, Data Inspector is used (refer to figure below). To observe the additional signals, log them as required. Alternatively, normal Simulink Scope can be used to plot the signals.
-
From this Simulink model an MPLAB X project can be generated, and it can be used to run the PMSM motor using LVMC board.
To generate the code from the Simulink model, go to the "MICROCHIP" tab, and enable the tabs shown in the figure below.
-
To generate the code and run the motor, click on ‘Build Model’ or ‘Clean Build Model’ option under the “Microchip” tab. This will generate the MPLAB X project from the Simulink model and program the dsPIC33CK256MP508 device.
-
After completing the process, the ‘Operation Succeeded’ message will be displayed on the ‘Diagnostics Viewer’.
-
If the device is successfully programmed, LED- LD10 and LD11 will be blinking.
-
Keep the potentiometer (POT1) position at the middle. Then, to Run the motor, press the push button SW1.
-
The reference duty or speed of it set by the potentiometer (“POT1”). Vary the POT1 to increase the motor speed.
-
Press the push button SW1 to stop the motor.
NOTE: To run in the Closedloop_Speed_Control select the mode on the model and repeat the steps 6 to 12
5. DATA VISUALIZATION USING MOTOR CONTROL BLOCKSET (MCB) HOST MODEL
The FOC model comes with the initialization required for data visualization using Motor Control Blockset Host Model (MCB Host Model). The MCB Host Model is a Simulink model which facilitates data visualization through the UART Serial Interface.
-
To establish serial communication with the host PC, connect a micro-USB cable between the host PC and the dsPIC33CK LVMC Board (J13 connector). This interface is used for programming as well. (Alternatively, a micro-USB cable can be connected from the host PC to the J6 connector of the dsPIC33CK LVMC Board to establish the serial communication).
-
Ensure that the FOC model is programmed and running as described under section "4. Basic Demonstration" by following steps 1 through 13.
-
Open the MCB Host model and double click on the “Serial Setup” block. Then select the appropriate COM port connected to the hardware from the drop-down menu and set the baud rate as 921659. Please note that the same baud rate is required to be chosen in the Sensorless FOC model (the baud rate can be viewed on the “UART Configuration” block in the “Hardware Init” subsystem).
-
Open the “UART_Rx” subsystem to configure the COM port. This can be done by configuring the “Host Serial Receive” block of the “UART_Rx” subsystem. Ensure to select the same COM port configured in step 3.
-
Click the run icon of the MCB Host model to open the scope window and monitor the signals.
-
In the figure below, one example is shown where two signals (Speed_Measured and Duty_Reference) have been plotted.
6. REFERENCES:
For more information, refer to the following documents or links.
- AN957Application Note (“Sensored BLDC Motor Control Using dsPIC Digital Signal Controllers (DSCs)”)
- dsPIC33CK LVMC Board User’s Guide (DS50003297)
- MPLAB® X IDE installation
- MPLAB® XC16 Compiler installation
- Motor Control Blockset
- MPLAB Device Blocks for Simulink :dsPIC, PIC32 and SAM mcu
引用格式
Microchip Support Team (2024). Hall Sensor Based Control of BLDC Motor Using dsPIC33CK LVMC (https://github.com/microchip-pic-avr-solutions/matlab-lvmc-dspic33ck256mp508-sixstep-hallsensor/releases/tag/1.0.0), GitHub. 检索来源 .
MATLAB 版本兼容性
平台兼容性
Windows macOS Linux标签
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!matlab-lvmc-dspic33ck256mp508-sixstep-hallsensor
matlab-lvmc-dspic33ck256mp508-sixstep-hallsensor
版本 | 已发布 | 发行说明 | |
---|---|---|---|
1.0.0 |