
EMBEDDED SOFTWARE DESIGN FOR A MICROCONTROLLER-BASED DATA LOGGER FOR STEPPER MOTOR FAULT DIAGNOSIS A Thesis Presented by Michael Thomas Daniel to The Department of Electrical and Computer Engineering in partial fulfillment of the requirements for the degree of Master of Science in Electrical Engineering in the field of Power Systems Northeastern University Boston, Massachusetts April 2012 ABSTRACT Two independent pieces of embedded software have been developed to operate a data log- ging system based on a PIC18F8722 microcontroller for a stepper motor diagnosis appli- cation. The first piece of embedded software is implemented with several state machines in a foreground/background (superloop) structure, while the second is implemented as an RTOS-enabled software based on the Salvo Lite cooperative real time operating system. The superloop implementation results in data for up to 8 stepper motor channels being logged to an SD card and RS-232 link at a rate of 10 Hz, with approximately 50% processor over- head time reserved for RS-232 communications. The RTOS-enabled implementation results in an improved high priority interrupt service routine execution time, but is overall slower to respond to interrupts compared to the superloop implementation due to the cooperative nature of the chosen operating system. A custom binary-to-ASCII conversion software is also developed for converting the resulting data log file produced by both software imple- mentations to human readable text, as the result of both implementations is a binary data log file containing data of interest for up to 8 stepper motors. This page intentionally left blank as a place holder for the Approval Record. c 2012 Michael Thomas Daniel ALL RIGHTS RESERVED Northeastern University, the faculty adviser, and the author assume no legal and/or financial liability for any statement in this thesis. i Dedicated to my parents. ii ACKNOWLEDGEMENTS While there were countless people who helped me with this work, there are a few who deserve special thanks. Without them, the success of this work would not have been possible. First of all, thank you to Michael Taranowski1 for hiring me to work at LLNL and assigning me to the project that would become the inspiration for this work. I would also like to express my gratitude to Mark Miller1 and Danielle Doane1 who both made my work at LLNL possible. Thanks to Matthew Dayton1 and LeRoy Bennett1 for their help and advice on programming for embedded systems with C. I also extend thanks to Jim McBride1, Eric Imhoff1, and Timm Wulff1 for their help and advice on developing hardware test set-ups for embedded systems. Thank you to Professor Ali Abur2 for his continuous guidance throughout the course of this work, and to Professor Gunar Schirner2 for his practical advice on programming for embedded systems. Thanks to Professor Dionisio Bernal2 for his encouragement to take on this work. Thanks are also extended to Professor Sara Wadia-Fascetti2 for hiring me to my position with the IGERT Intelligent Diagnostics group at Northeastern University, which has made this work possible. The ability to test my designs in the ECE laboratories, which was essential to this work, was made possible by Dr. Amir Farhat2, Edward Tyrance2, and Stephen Keane2. This work has been supported by NSF Grant Number DGE - 0654176. 1Lawrence Livermore National Laboratory 2Northeastern University iii Contents 1 Introduction 1 1.1 Thesis Statement and Objectives . .1 1.2 Significance and Importance of Work . .3 1.3 Background Information Leading to Thesis Formulation . .5 1.4 Summary of the Relevant Literature . .6 1.5 Organizational Summary of Thesis . 10 2 Technical Background 12 2.1 Stepper Motors, Drivers, and Faults . 12 2.2 Signals of Interest and System Technical Requirements . 19 2.3 Early Design Decisions: Laying the Foundation . 23 2.3.1 The Microcontroller and Its Interfaces . 23 2.3.2 Development Hardware and Constraints . 32 2.3.3 Development Software and Constraints . 34 3 Application Software - Superloop Version 38 3.1 Structure and Function . 38 3.1.1 The Background Loop . 42 3.1.2 The Foreground Loop . 57 3.1.3 Overall Superloop Version Software Structure . 63 iv 3.2 Data Log Conversion Software . 65 3.3 Testing Methods . 68 3.4 Results and Evaluation . 71 4 Application Software - RTOS Version 89 4.1 RTOS Fundamentals . 89 4.2 Structure and Function . 93 4.2.1 Initialization Tasks . 99 4.2.2 Get Data Log Task . 103 4.2.3 Put Data Log Task . 106 4.2.4 Handle UART Task . 109 4.2.5 Date/Time Task . 112 4.2.6 RTOS Version Software Structure and Function in Steady State . 115 4.3 Testing Methods . 116 4.4 Results and Evaluation . 118 5 Concluding Remarks 137 5.1 Comparison of the Results and Evaluations . 137 5.2 Opportunities for Future Work . 140 5.3 Broader Impacts . 141 A Hardware Schematics 142 B Application Specific Source Code 148 B.1 Application Source Code - Superloop Version . 149 B.1.1 MainSrcCode.c . 149 B.1.2 AuxSrcCode.c . 158 B.1.3 CustomHeader.h . 171 v B.1.4 18f8722_MDDFS.lkr . 172 B.2 Application Source Code - RTOS Version . 174 B.2.1 main.c . 174 B.2.2 auxiliary.c . 187 B.2.3 main.h . 198 B.2.4 salvocfg.h . 199 B.3 Binary to ASCII Converter Source Code . 200 B.3.1 DataLogBin2ASCIIVer4.c . 200 B.4 MATLAB Files . 204 B.4.1 StepCountingApproximation.m . 204 vi List of Figures 2.1 Basic operation of a two phase permanent magnet stepper motor with four poles ..... 14 2.2 Functional block diagram of TI DRV8811 from the DRV8811 data sheet. ......... 15 2.3 Detailed block diagram of TI DRV8811 output stage from the DRV8811 data sheet. .... 16 2.4 Stepper motor using a linear gear and rails for a linear positioning application. ..... 17 2.5 Functional block diagram of the PIC18F8722 device from the PIC18F8722 data sheet .. 25 2.6 Pin diagram of the PIC18F8722 device from the PIC18F7822 data sheet ........ 26 2.7 Physical interfaces between NIF motor drive board, data logger, SD card, and PC. .... 27 2.8 Pin arrangements for both SD card and RS-232 physical interfaces ........... 28 2.9 Operation of the SPI bus using shift registers. ..................... 29 2.10 Microcontroller internal hardware configuration for this application. ........... 29 2.11 Ideal function of each MCU pin given the data logging application at hand. ....... 31 2.12 Hardware development tools used in this application. Top left is PICkit3 debugger, top right is SD card, bottom left is PICDEM PIC18 board, and bottom right is PICtail Daughter Board for MMC/SD Cards. .............................. 32 2.13 Function of each MCU pin given the data logging application at hand combined with devel- opment tool constraints. ............................... 37 3.1 Visual representations of the superloop program structure used by the embedded application software. ....................................... 39 3.2 Project structure in MPLAB IDE for implementing superloop embedded application software. 40 vii 3.3 State machine used in main() to implement initialization and background loop. ..... 43 3.4 Flow chart showing the possible paths of background loop execution; line numbers refer to MainSrcCode.c which is found in Appendix B.1.1. ................... 44 3.5 Circular buffer represented both as a ring as well as linearly; the circular buffer is first-in first-out or “FIFO”. ................................. 47 3.6 Linear representations of some key circular buffer conditions for this application. .... 48 3.7 Data log structure; note that one “datalog” structure includes an array of eight “channel” structures, which in turn each include a “bitfield” structure. .............. 49 3.8 Structure of the binary data log file. .......................... 51 3.9 Flow chart describing the handling of RS-232 commands received via UART. ...... 56 3.10 State machine used to implement foreground loop in HPISR; note that control is returned to the background upon completion of each state. .................... 58 3.11 Diagram showing the order and manner in which commanded motor steps are counted by the MCU ...................................... 59 3.12 Theoretical motor velocity and position given 200 steps per second squared acceleration for 50 seconds. The MATLAB script used to generate this figure can be found in Appendix B.4.1. 59 3.13 Detail of Figure 3.12 showing motor position from t=49.9s to t=50.0s. ......... 60 3.14 Flow chart describing the execution of foreground state three. .............. 61 3.15 High level overall description of superloop application software structure and function .. 64 3.16 Flow chart describing the execution of the data log binary to ASCII conversion application. 66 3.17 Lab bench set up for testing embedded application software. Note the DC supply limited to 25mA for analog inputs, and signal generator for step inputs. The development tools are on the bench in front of the oscilloscope; the PC to the right is used to control software execution on the PIC18F8722 via the PICkit3 debugger interface and MPLAB IDE. ... 69 3.18 Binary data log file when interpretted directly as ASCII characters by Notepad. ..... 72 viii 3.19 Win32 console displayed by binary-to-ASCII conversion program during execution. Note that the program waits for the user to acknowledge conversion complete before exiting. .. 72 3.20 Final data log correctly converted to ASCII text. .................... 73 3.21 Channels 5 throught 8 of the final text data log file. ................... 74 3.22 Beginning of hyperterminal output for superloop test case. ............... 76 3.23 HyperTerminal output when data logging operations are stopped with both outputs enabled. Terminal output is disabled before data logging is restarted. ............... 78 3.24 HyperTerminal output when data logging is stopped with only SD card output enabled.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages223 Page
-
File Size-