Drexel University's Logo

Clayton McNeil

HUBO Lab Motor Controller Programming Guide


Home
About Me
Tutorials
Media Archive
Resources

Part 4: Programming Overview


The complete source code for this tutorial can be downloaded here.

The project corresponding with this tutorial consists of nine code files, excluding the DSP281x files provided by Texas Instruments. Six of these files (HMC_CAN.c/.h, HMC_HallSensor-PWM.c/.h, and HMC_Encoder-PosControl.c/.h) will be described in later parts of the tutorial as they add specific functionality to the motor controller that deserves a more detailed explanation.

HMC_CommonDefinitions.h

As its name implies, this file contains defines for several general constants and types used throughout the source code. It also contains defines for constants specific to certain sections of the code that will be discussed later.

HMC_IR2131.c

The purpose of this file is to handle enabling and disabling the IR2131 MOSFET driver component, which allows the DSP to indirectly control the six relatively high voltage/current transistors connected to the motor’s electromagnetic coils. The file contains just two core functions, StartupIR2131() and ShutdownIR2131().

HMC_Main.c

The most important function in this file is the ‘main’ function. Besides running the primary control loop, the ‘main’ function is responsible for calling functions that initialize and configure the various DSP peripherals that will be used, such as the GPIO MUX, the PIE, and the CPU timer. The file also contains some support functions to assist in this. Although many of the initialization procedures will be described in other parts of the tutorial, explanation of those handled by TI included files will be deferred to the recommended reference guides.

Before continuing, it should be pointed out that this tutorial is not intended to be a line by line treatment of the code required to control a motor with the HUBO Lab Motor Controller. Instead, it aims more to explain the concepts involved and clarify the less obvious. Therefore, to gain complete understanding, it is important to actually read through the code and comments in the source file in addition to what is presented in this tutorial.

Continue to Part 5, Programming for CAN Communications...

Home | About Me | Tutorials | Media Archive | Resources