Overview

This application note describes how to obtain the hardware and software configurations required to drive a Switec stepper motor. The motor can run as a metronome by controlling its direction of rotation and number of beats per minute.

The implementation of the application consists of a circuit composed of CIPs, which is capable of creating the signals that drive the Switec stepper motor as a metronome. It also adjusts the number of beats per minute of the metronome by reading an input value, provided by the user.

When the application starts, the shaft of the motor is set to an initial position, so that the oscillation always starts from a fixed position and is symmetrical to the center of the dial.

The metronome begins oscillating with a specific frequency and in order to modify it, the user can adjust the position of a potentiometer, which is connected to the microcontroller. Whenever a period is completed, the metronome produces an audible and visual signal through an LED and a buzzer.

The signals that drive the Switec stepper motor are generated independently from software, using the following CIPs:

Due to the usage of CIPs, the computation complexity and program memory space used are substantially reduced. In this application, the core only needs to initialize the peripherals and to periodically trigger the start of an ADCC conversion.

The source code for the initialization of peripherals used in the microcontroller is generated using the MPLAB® Code Configurator (MCC). The code generator creates the structure of the project, the files, as well as the source code.

Prerequisites: