DC Motor 4 Click Board
DC Motor 4 Click Board
The DC Motor 4 Click Board™ is capable of driving motors with a supply voltage from 4.5V to 36V. It carries the MAX14870 motor driver from Maxim Integrated.
The DC Motor 4 Click Board™ is designed to run on either a 3.3V or 5V power supply. DC MOTOR 4 Click Board™ communicates with the target MCU over the following pins on the MikroBUS line: PWM, AN, CS, and INT.
Software Support
Code examples for DC MOTOR 4 Click Board™, written for MikroElektronika hardware and compilers are available on Libstock.
Code snippet
The following code snippet shows the initialization and use of compiler built-in PWM functions to control the motor.
01 void systemInit() 02 { 03 GPIO_Digital_Output(&GPIOA_BASE, _GPIO_PINMASK_4); 04 05 pwmPeriod = PWM_TIM5_Init(1000); // Set PWM frequency/period (according to the DC motor characteristics) 06 PWM_TIM5_Set_Duty(pwmPeriod, _PWM_NON_INVERTED, _PWM_CHANNEL1); // Set current duty for PWM 07 PWM_TIM5_Start(_PWM_CHANNEL1, &_GPIO_MODULE_TIM5_CH1_PA0); // Start PWM 08 09 } 10 11 void main() 12 { 13 14 systemInit(); 15 16 while (1) 17 { 18 //Forward 19 DIR_PIN = 0; 20 //Forward fast 21 PWM_TIM5_Set_Duty(pwmPeriod, _PWM_NON_INVERTED, _PWM_CHANNEL1); 22 Delay_ms (3000); 23 //Forward slow 24 PWM_TIM5_Set_Duty(pwmPeriod/2, _PWM_NON_INVERTED, _PWM_CHANNEL1); 25 Delay_ms (3000); 26 //Reverse 27 DIR_PIN = 1; 28 //Reverse fast 29 PWM_TIM5_Set_Duty(pwmPeriod, _PWM_NON_INVERTED, _PWM_CHANNEL1); 30 Delay_ms (3000); 31 //Reverse slow 32 PWM_TIM5_Set_Duty(pwmPeriod/2, _PWM_NON_INVERTED, _PWM_CHANNEL1); 33 Delay_ms (3000); 34 35 } 36 }
DC Motor 4 Click Board
Frequently Asked Questions
Have a Question?
Be the first to ask a question about this.