Other Parts Discussed in Thread: HALCOGEN
Tool/software: Code Composer Studio
Hello,
I am a newbie. I intend to drive two DC motors with the RM48 Hercules Development Kit (HDK) and also display their RPM in CCS. Using Halcogen and Code Composer, I have been able to use the HET1 driver to generate PWM with different duty cycles to run both motors easily (thanks to examples from T.I). I am however, quite confused about converting the tachometer signal from each motor to RPM and displaying it. I have looked at similar examples online and tried to get mine to work, all to no avail.
This is what I have done so far:
Enabled HET1 driver
In the Pwm 0-7 tab, Enabled PWM for output pin 9 and 10. Pin 9 is at 60% duty cycle while pin 10 is at 20% duty cycle
In the pin 8 - 15 tab, enabled output direction for bit 9 and 10
TO CALCULATE RPM OF BOTH MOTORS FROM TACHOMETER SIGNAL
Enabled GIO driver
Opened the GIO tab, port A. Chose GIOA[0] and GIOA[1]
Enabled Bit 0 and Bit 1 interrupt, Chose falling edge interrupt for Bit 0 and Bit 1
Bit 0 and Bit 1 are input by default
Enabled Bit 0 and Bit 1 pullup
CODE USED IN CCS
/* USER CODE BEGIN (0) */
#include "het.h"
#include "gio.h"
#include "important.h"
#include <stdio.h>
/* USER CODE END */
/* Include Files */
#include "sys_common.h"
#include "system.h"
#include "reg_gio.h"
/* USER CODE BEGIN (1) */
/* USER CODE END */
/** @fn void main(void)
* @brief Application main function
* @note This function is empty by default.
*
* This function is called after startup.
* The user can use this function to implement the application.
*/
/* USER CODE BEGIN (2) */
/* USER CODE END */
int main(void)
{
/* USER CODE BEGIN (3) */
hetInit();
gioInit();
while(1);
/* USER CODE END */
}
/* USER CODE BEGIN (4) */
unsigned int tachCount1 = 0; // Count revolutions of fan
unsigned int tachCount2 = 0; // Count revolutions of fan
unsigned int tachRPM1 = 0; // Stores RPM of fan
unsigned int tachRPM2 = 0; // Stores RPM of fan
unsigned int lastRPM1 = 0; // Stores RPM of last reading
unsigned int lastRPM2 = 0; // Stores RPM of last reading
{
refreshTach(); // Update Tachometer
_enable_interrupt_(TACH1); // enable tachometer interrupt
_enable_interrupt_(TACH2); // enable tachometer interrupt
}
void updateTach(void)
{
_disable_interrupt_(TACH1); // Disable tachometer interrupt
_disable_interrupt_(TACH2); // Disable tachometer interrupt
__nop(); // Wait 1 instruction cycle
// Convert pulse count to RPM
tachRPM1 = (tachCount1/PULSESPERREVOLUTION1)*60;
tachRPM2 = (tachCount2/PULSESPERREVOLUTION2)*60;
_enable_interrupt_(TACH1); // Re-enable tachometer interrupt
_enable_interrupt_(TACH2); // Re-enable tachometer interrupt
tachCount1 = 0; // Reset the pulse counter
tachCount2 = 0; // Reset the pulse counter
}
void refreshTach()
{
updateTach(); // Refresh tachometer readings
printf("RPM = %i\n",tachRPM1); // Print RPM of First motor
printf("RPM = %i\n",tachRPM2); // Print RPM of Second motor
}
/* USER CODE END */
THE HEADER FILE
important.h
*
* Created on: 7 Sep 2018
* Author: chuks
*/
#ifndef SOURCE_IMPORTANT_H_
#define SOURCE_IMPORTANT_H_
// PortA Pin Configuration
#define TACH1 Bit 0
#define TACH2 Bit 1
#define PULSESPERREVOLUTION1 2
#define PULSESPERREVOLUTION2 2
/************ FUNCTION PROTOTYPES ******************************************************/
void updateTach(void);
// Usage: Translate tachometer pulse counts into the actual RPM value
// Parameters: none
void refreshTach(void);
// Usage: Updates all variables corresponding to the tachometer
// Parameters: none
#endif /* SOURCE_IMPORTANT_H_ */
Please, any suggestions on why I am getting errors and it isn't working?
Kind Regards