Can someone explain the API available in tivaware/driverlib/qei.h :
extern void QEIVelocityConfigure(uint32_t ui32Base, uint32_t ui32PreDiv, uint32_t ui32Period);
what is the ui32Period here?
I wrote a simple program to calculate the position, direction of motion and velocity of a motor:
/*! * @author Yash Bansod * @date 26th September 2017 * * @brief Quadrature Encoder * @details The program interfaces the quadrature encoder peripheral to get the position * and velocity information of a encoded DC motor. * @note The tm4c123ghpm_startup_ccs.c contains the vector table for the * microcontroller. It was modified to execute the specified ISR on * PortF Interrupts. */ /* ----------------------- Include Files --------------------- */ #include <stdint.h> // Library of Standard Integer Types #include <stdbool.h> // Library of Standard Boolean Types #include "inc/tm4c123gh6pm.h" // Definitions for interrupt and register assignments on Tiva C #include "inc/hw_memmap.h" // Macros defining the memory map of the Tiva C Series device #include "inc/hw_types.h" // Defines common types and macros #include "inc/hw_gpio.h" // Defines Macros for GPIO hardware #include "inc/hw_qei.h" // Macros used when accessing the QEI hardware #include "driverlib/debug.h" // Macros for assisting debug of the driver library #include "driverlib/sysctl.h" // Defines and macros for System Control API of DriverLib #include "driverlib/interrupt.h" // Defines and macros for NVIC Controller API of DriverLib #include "driverlib/gpio.h" // Defines and macros for GPIO API of DriverLib #include "driverlib/pin_map.h" // Mapping of peripherals to pins for all parts #include "driverlib/rom.h" // Defines and macros for ROM API of driverLib #include "driverlib/qei.h" // Prototypes for the Quadrature Encoder Driver /* ----------------------- Global Variables --------------------- */ volatile uint32_t ui32Qei1Pos; // Variable to store the position of QEI1 volatile int32_t i32Qei1Dir; // Variable to store the direction of QEI1 volatile uint32_t ui32Qei1Vel; // Variable to store the velocity of QEI1 /* ----------------------- Function Prototypes --------------------- */ /* ----------------------- Main Program --------------------- */ int main(void){ // Set the System clock to 80MHz and the PWM Module clock to 1.25 MHz ROM_SysCtlClockSet(SYSCTL_SYSDIV_2_5 |SYSCTL_USE_PLL |SYSCTL_OSC_MAIN |SYSCTL_XTAL_16MHZ); // Enable the clock for peripherals PortD and QEI1 ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_QEI1); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC); // Configure the PC4, PC5, PC6 for QEI signals ROM_GPIOPinTypeQEI(GPIO_PORTC_BASE, GPIO_PIN_5 | GPIO_PIN_6); ROM_GPIOPinConfigure(GPIO_PC5_PHA1); ROM_GPIOPinConfigure(GPIO_PC6_PHB1); // Configure the QEI1 to increment for both PhA and PhB for quadrature input with 2400 PPR ROM_QEIConfigure(QEI1_BASE, QEI_CONFIG_CAPTURE_A_B | QEI_CONFIG_QUADRATURE, 2400); ROM_QEIVelocityConfigure(QEI1_BASE, QEI_VELDIV_1, 10000); ROM_QEIVelocityEnable(QEI1_BASE); // Enable the QEI1 ROM_QEIEnable(QEI1_BASE); while (1){ ui32Qei1Pos = ROM_QEIPositionGet(QEI1_BASE); i32Qei1Dir = ROM_QEIDirectionGet(QEI1_BASE); ui32Qei1Vel = ROM_QEIVelocityGet(QEI1_BASE); } } /* ----------------------- Function Definition --------------------- */
In what terms am I getting the Velocity here? Is it directly converted to RPM or is it in form of ticks?