Whitney Knitter
Published © GPL3+

Getting Started with BLDCs on Kria KD240 + Motor Kit Part 1

This project walks through the basics of controlling a BLDC motor using the AMD Kria™ KD240 Drives Starter kit with motor accessory pack.

IntermediateWork in progress2 hours1,651
Getting Started with BLDCs on Kria KD240 + Motor Kit Part 1

Things used in this project

Hardware components

Kria KD240 Drives Starter Kit
AMD Kria KD240 Drives Starter Kit
×1
AMD Kria KD240 Motor Accessory Pack
×1
Solderless Breadboard Half Size
Solderless Breadboard Half Size
×1
Resistor 10k ohm
Resistor 10k ohm
×3

Software apps and online services

Vivado Design Suite
AMD Vivado Design Suite
Vitis Unified Software Platform
AMD Vitis Unified Software Platform

Story

Read more

Schematics

Anaheim BLDC Motor Spec Sheet

Code

motor_controller_hs.v

Verilog
module motor_controller_hs(
    input clk,
    input rst_n,
    input hallA,
    input hallB,
    input hallC, 
    output reg phaseA,
    output reg phaseB,
    output reg phaseC
    );
    
    reg motor_pwm; 
    reg [21:0] motor_speed_interval;
    parameter speed_2000rpm = 22'd3000000;
    
    wire [2:0] hall_code;
    assign hall_code[2:2] = hallA; 
    assign hall_code[1:1] = hallB; 
    assign hall_code[0:0] = hallC; 
    
    always @ (posedge clk or negedge rst_n) begin
        if (rst_n == 1'b0) begin
            phaseA <= 1'bz;
            phaseB <= 1'bz;
            phaseC <= 1'bz;
        end
        else begin 
            case (hall_code[2:0])
                1 : begin 
                    phaseA <= 1'bz;
                    phaseB <= 1'b0;
                    phaseC <= motor_pwm; //1'b1;
                end     
                
                2 : begin 
                    phaseA <= 1'b0;
                    phaseB <= motor_pwm; //1'b1;
                    phaseC <= 1'bz;
                end 
                
                3 : begin
                    phaseA <= 1'b0;
                    phaseB <= 1'bz;
                    phaseC <= motor_pwm; //1'b1;
                end
                
                4 : begin
                    phaseA <= motor_pwm; //1'b1;
                    phaseB <= 1'bz;
                    phaseC <= 1'b0;
                end
                
                5 : begin
                    phaseA <= motor_pwm; //1'b1;
                    phaseB <= 1'b0;
                    phaseC <= 1'bz;
                end 
                
                6 : begin
                    phaseA <= 1'bz;
                    phaseB <= motor_pwm; //1'b1;
                    phaseC <= 1'b0;
                end 
                
                default : begin 
                    phaseA <= 1'bz;
                    phaseB <= 1'bz;
                    phaseC <= 1'bz;
                end 
                
            endcase
        end 
    end
    
    // PWM 
    always @ (posedge clk or negedge rst_n) begin 
        if (rst_n == 1'b0) begin
            motor_speed_interval <= 22'd0;
            motor_pwm <= 1'b0;
        end 
        else begin
            if (motor_speed_interval == speed_2000rpm) begin
                motor_speed_interval <= 22'd0;
                motor_pwm <= ~motor_pwm;
            end
            else begin
                motor_speed_interval <= motor_speed_interval + 1;
            end 
        end 
    end    
     
    
endmodule

kd240_pinout.xdc

Plain text
####################################################################################################
##################################### Motor Phase Gate Drivers #####################################
####################################################################################################
## HDA05 - Bank  26 VCCO - VCCO_HDA - IO_L2N_AD10N_26
set_property PACKAGE_PIN G9       [get_ports motor_en];
set_property IOSTANDARD  LVCMOS33 [get_ports motor_en];

## HDA04 - Bank  26 VCCO - VCCO_HDA - IO_L2P_AD10P_26
set_property PACKAGE_PIN G10      [get_ports phaseC];
set_property IOSTANDARD  LVCMOS33 [get_ports phaseC];

## HDA03 - Bank  26 VCCO - VCCO_HDA - IO_L1N_AD11N_26
set_property PACKAGE_PIN H9       [get_ports phaseB];
set_property IOSTANDARD  LVCMOS33 [get_ports phaseB];

## HDA02 - Bank  26 VCCO - VCCO_HDA - IO_L1P_AD11P_26
set_property PACKAGE_PIN H10      [get_ports phaseA];
set_property IOSTANDARD  LVCMOS33 [get_ports phaseA];

####################################################################################################
####################################### Hall Sensor Inputs #########################################
####################################################################################################
## HDA11 - Bank  26 VCCO - VCCO_HDA - IO_L4N_AD8N_26
set_property PACKAGE_PIN E9       [get_ports hallA];
set_property IOSTANDARD  LVCMOS33 [get_ports hallA];

## HDA12 - Bank  26 VCCO - VCCO_HDA - IO_L7P_HDGC_AD5P_26
set_property PACKAGE_PIN F13      [get_ports hallB];
set_property IOSTANDARD  LVCMOS33 [get_ports hallB];

## HDA13 - Bank  26 VCCO - VCCO_HDA - IO_L7N_HDGC_AD5N_26
set_property PACKAGE_PIN E12      [get_ports hallC];
set_property IOSTANDARD  LVCMOS33 [get_ports hallC]; 

Credits

Whitney Knitter
172 projects • 1799 followers
All thoughts/opinions are my own and do not reflect those of any company/entity I currently/previously associate with.
Contact

Comments

Please log in or sign up to comment.