Young-Man Kim - Digital Tachometer With Dragon Board-12
Young-Man Kim - Digital Tachometer With Dragon Board-12
Young-Man Kim - Digital Tachometer With Dragon Board-12
Young-Man Kim Department of Engineering The University of Michigan - Flint 303 E. Kearsley St., Flint, MI 48502, USA [email protected] Yixuan Chi Department of Engineering The University of Michigan - Flint 303 E. Kearsley St., Flint, MI 48502, USA [email protected]
Kyle Stokes Department of Engineering The University of Michigan - Flint 303 E. Kearsley St., Flint, MI 48502, USA [email protected]
Abstract: We introduce one method of addressing the problem of finding the Revolutions per minute of a DC motor without the use of a commercial tachometer, through the use of Dragon Board-12 embedded system. The method we chose to use involved setting up a low pass filter circuit to reduce noise and voltage to a level that the safe for use with the Dragon Board-12. The output from the low-pass filter was then passed through an analog to digital converter which was coded using C code, to convert the signal into a machine readable input. The input was then converted into revolutions per minute and then stored for 15ms, at which time an average was taken (to reduce noise) and then sent to the LCD screen as the tachometer output in revolutions per minute. Additionally, we identified DC motor using motor input voltage and output rpm data. The Matlab data shows its usefulness.
I.
Introduction
In modern days, with the increased usage of Dragon 12-plus USB trainer in universities, more and more applications have been created on the board. The Dragon 12-plus USB trainer is a low cost, featured-packed training board for the new Freescale HCS12 microcontroller family. The board is compatible with the Freescale 9S12DP256EVB board and other similar development boards on the market today, but it also incorporates many on-board peripherals that make this board a popular trainer in universities around the world. The DC motor is also widely used in many applications in modern days, and is in integral part in many pieces off equipment such as toys and disk drives, steel rolling mills, and paper machines.[1]
In this project, we are going to introduce a method to set up the dragon 12-plus board as a tachometer that can measure the rotation speed of a DC motor instead of using traditional tachometers. In order to achieve this goal, the first step is to find out the linear relationship between the voltage input and revolutions per minute output for the DC motor we chose to use. minute. II. Main Result Once a relationship can be established, C code can then be written to program the Dragon 12-plus board to do the actual conversions and display the revolutions per
A digital tachometer was designed with the use of principles of embedded systems and systems control. The main design consisted of using the Freescale Dragon Board-12 system; which includes many features including a timer, analog to digital converter, and a LCD screen (1: in Figure 1), along with a DC motor (4: in Figure 1) and power supply to create a digital device that would read an analog voltage input from the DC motor and then create a digital output which could be displayed on the LCD screen of the Dragon Board-12 system.
Figure 1: Digital Tachometer Setup When designing this system the first factor that was taken into consideration was to confirm the manufactures voltage gradient factor of 1.9V per 1000 RPM. To confirm the voltage gradient we applied the system (2) shown below in which the DC motor is connected to a power supply and a low-pass filter, which is used to reduce the machine noise in dc motor. For the best noise reduction in dc motor, we choose to set up a low pass filter circuit with a resistance 20 ohms and a capacitance of 100 uF. The values were chose to achieve a cutoff frequency of 500Hz(shown) which is 6.25 times greater than the maximum rotation speed of the dc motor(4500rpm=80Hz), this allows for the reduction of most of the noise of the
Figure 2: System for measure the relation of voltage and freq. This low-pass filter set up allowed for a for a voltage gradient of 1.9 Volts per 1000 Revolution per minute to be attained. This voltage gradient data allowed for the programming structure to be completed. The programming structure that was set up follows the flow chart is the attached in appendix A. The first step in creating the digital aspect of the tachometer was initializing the LCD in which the code can be found in the LCD section of the source code in Appendix B. Once the LCD is initialized and ready to accept data, the analog to digital converter is then initialized and set to do a continuous scan on PAD 8(3: in Figure 1) which is the channel that was used in this particular case and convert to an 8-bit number. Once both the LCD and Analog to digital converter are initialized the scan and conversion aspect of the digital tachometer can take place. In this phase of the digital tachometer the voltage input into PAD 8 is taken and then converted from an analog voltage signal to an 8-bit number which ranges from 0-255. Once the analog voltage signal is converted to the digital 8-bit number the conversion back to display the digital number as a readable voltage and revolution per minute string on the LCD can take place. During this phase of the digital tachometer code the digital 8-bit number is divided by 51 to get the digital signal back into the analog voltage number, which in this case gives a maximum voltage of 5 volts and a minimum voltage of 0 volts which is the factor default configuration for the Freescale Dragon Board-12. Once the analog voltage is again determined from the digital 8-bit number the result is then stored in the 10 th element of the voltage display array, in which the ones place of the voltage is displayed. Then to display the decimal part of the analog voltage the remainder of the digital 8-bit signal is taken and then multiplied by 10 and divided by 51 at which time this value is stored in the voltage character array in element 12. The same process is used when converting the 8-bit digital voltage number to Revolutions per minute except for the fact that the signal must be multiplied by the voltage gradient provided by the DC motor and storing this value in the revolutions per minute character array. Once both arrays have data they are then sent to the LCD screen on the Dragon-Board-12 to be displayed to the user. and works by taking a voltage input from the tachometer that is built into the DC motor, and throwing that input data to PAD 8 on the dragon board which is an analog to digital input channel. Once the conversion is complete the data stored in the character arrays is then constantly updated at an interval of 50 milliseconds by use of a delay loop and continuous scan of the analog to digital converter. III. Application to System Identification
The data from DC motor such as motor input voltage and output rpm is used for identification of DC motor. At first, two data (input voltage and output rpm) is imported to Matlab workspace. Those data are provided to the Matlab system identification tools such as pem [2]. Using the command, we identify DC motor and its location of identified system poles are shown at figure 3.
As we can see, the system poles are close to unit circle, which shows possible oscillatory or unstable response. To verify the credenbility of identification, the variance-accounted-for (VAF) parameter was checked and it was 100% [2].
IV.
Conclusion
The dragon board 12 was successfully used as a platform to build a digital tachometer off of by use of the analog to digital conversion feature, as well as the on board LCD. In combination with these parts C code was written to tie all of the different components together to make a functioning product . The C code employed taking a digital number and reconverting back into a readable analog voltage output and ten converting this voltage output with the voltage gradient factor of 1.9 Volts per 1000 Revolutions per minute. The dragon board 12 is a great tool for use from projects such as creating a digital tachometer, but there is even more features which are to be incorporated in future works. Those data was used for system identification of DC motor using Matlab. V. Future Work
The Digital Tachometer project has much room for improvement and expansion. One such avenue of
expansion that is currently underway is developing an overlay that would digitally allow for a user to control the Digital Tachometer attached to the Dragon Board -12 over the internet. This would work by creating an overlay in which the user can remotely set a voltage or RPM, which would cause the Dragon Board-12 to adjust the current power settings for the DC motor to match the levels indicated by the user. Reference [1] Huang, Han-Way. HCS12/9S12 An Introduction to Software and Hardware Interfacing . 2nd ed. Delmar Colege Learning, 2010. Print. [2] Matlab, The Mathworks, R2012a
Initialize
Convert to Voltage and RPM and store in char Array Send Array Data to LCD
Delay 50 milliseconds
END
/******************************************************************************/ #include <hidef.h> #include <stdio.h> #include "lcd.h" /****************************************CONFIGURE LCD****************************/ void openlcd(void) { LCD_DIR = 0xFF; /* configure LCD_DAT port for output */ delay_1ms(100); /* Wait for LCD to be ready */ put2lcd(0x28,CMD); /* set 4-bit data, 2-line display, 5x7 font */ put2lcd(0x0F,CMD); /* turn on display, cursor, blinking */ put2lcd(0x06,CMD); /* move cursor right */ put2lcd(0x01,CMD); /* clear screen, move cursor to home */ delay_1ms(2); /* wait until "clear display" command is complete */ } /*****************************GIVE LCD CHAR DATA********************************/ void puts2lcd (char *ptr) { while (*ptr) { /* While character to send */ put2lcd(*ptr,DATA); /* Write data to LCD */ delay_50us(1); /* Wait for data to be written */ ptr++; /* Go to next character */ } } /****************************SELECT LCD BIT DATA*********************************/ void put2lcd(char c, char type) { char c_lo, c_hi; c_hi = (c & 0xF0) >> 2; /* Upper 4 bits of c */ c_lo = (c & 0x0F) << 2; /* Lower 4 bits of c */ if (type == DATA) LCD_DAT |= LCD_RS; /* select LCD data register */ else LCD_DAT &= (~LCD_RS); /* select LCD command register */ if (type == DATA) /* common defines and macros */ /* derivative information */
#include <mc9s12dp256.h>
LCD_DAT = c_hi|LCD_E|LCD_RS; /* output upper 4 bits, E, RS high */ else LCD_DAT = c_hi|LCD_E; /* output upper 4 bits, E, RS low */ LCD_DAT |= LCD_E; /* pull E signal to high */ __asm(nop); /* Lengthen E */ __asm(nop); __asm(nop); LCD_DAT &= (~LCD_E); /* pull E to low */ if (type == DATA) LCD_DAT = c_lo|LCD_E|LCD_RS; /* output lower 4 bits, E, RS high */ else LCD_DAT = c_lo|LCD_E; /* output lower 4 bits, E, RS low */
LCD_DAT |= LCD_E; /* pull E to high */ __asm(nop); /* Lengthen E */ __asm(nop); __asm(nop); LCD_DAT &= (~LCD_E); /* pull E to low */ delay_50us(1); /* Wait for command to execute */ } #define D50US 133 /* Inner loop takes 9 cycles; need 50x24 = 1200 cycles */ /*******************************DELAY LOOPS******************************/ void delay_50us(int n) { volatile int c; for (;n>0;n--) for (c=D50US;c>0;c--) ; } void delay_1ms(int n) { for (;n>0;n--) delay_50us(200); } /******************************CONVERTER**************************************/ void main( void ) { unsigned int i; //loop counter unsigned int remainder; //used for calculating voltage char display[17] = "Voltage = x.x "; // initalize string char converted[14] = "RPM = xxxx ";
unsigned int c; unsigned unsigned unsigned int leftover; int leftover100; int leftover10;
openlcd(); // Enable the LCD display ATD1CTL2 = 0x80; //normal A2D operation initialization for(i = 0; i < 1000; i++); //delay for initialization ATD1CTL3 = 0x08; // 1 conversion per scan ATD1CTL5 = 0x20; //continuous scan on AD1 channel 0 (PAD8) while(1)//keep running { while(!(ATD1STAT0 & 0x80)); //wait for scan conversion to complete /***************************************GET VOLTAGE*****************************/ display[10] = '0' + ATD1DR0H / 51; // divide to find ones place (255 / 5 = 51) remainder = ATD1DR0H % 51; //calculate remainder display[12] = '0' + (remainder * 10) /51; //multiply remainder by 10 and divide to find tenths place puts2lcd(display); //write to screen delay_1ms(48); put2lcd(0x01,CMD); delay_1ms(2); put2lcd(0XC0, CMD); /***********************************GET RPM********************************/ c= ((ATD1DR0H*100)/51) *(526/100) ; // using arry values from display cal RPM from voltage using converted[6]= '0' + leftover= c %1000; converted[7]= '0' + leftover /100; leftover100=leftover % 100; converted[8]= '0' + leftover100 /10; leftover10=leftover100 % 10; converted[9]= '0' + leftover10; puts2lcd(converted);//write to screen * } } c /1000; given conversion