Home
Stellaris Brushless DC Motor RDK Software Reference Manual
Contents
1. PWM_CLOCK_WIDTH Definition define PWM_CLOCK_WIDTH Description The width of a single PWM clock in nanoseconds PWM_FLAG_NEW_DUTY_CYCLE Definition define PWM_FLAG_NEW_DUTY_ CYCLE Description The bit number of the flag in g ulPWMFlags that indicates that a new duty cycle that is compare is ready to be supplied to the PWM module PWM_FLAG_NEW_FREQUENCY Definition define PWM_FLAG_NEW_FREQUENCY February 19 2008 83 PWM Control 11 2 1 5 11 2 2 11 2 2 1 11 2 2 2 84 Description The bit number of the flag in g_ulPWMFlags that indicates that a new PWM frequency that is period is ready to be supplied to the PWM module PWM_FLAG_NEW_PRECHARGE Definition define PWM_FLAG_NEW_PRECHARGE Description The bit number of the flag in g_ulPWMFlags that indicates that a Pre charge process has been started Function Documentation PWMOIntHandler Handles the PWM interrupt Prototype void PWMOIntHandler void Description This function is called as a result of the interrupt generated by the PWM module when the counter reaches zero If an updated PWM frequency or duty cycle is available they will be updated in the hardware by this function Returns None PWMGetPeriodCount Gets the number of PWM interrupts that have occurred Prototype unsigned long PWMGetPeriodCount void Description This function returns the number of PWM interru
2. A generic TCP packet based protocol is utilized for communicating with the motor drive board This provides a method to control the motor drive adjust its parameters and retrieve real time performance data The same protocol should be used for all motor drive boards regardless of the motor type that is AC induction stepper and so on The protocol should make reasonable attempts to protect against invalid commands being acted upon It should be possible to connect to a running motor drive board and lock on to the real time data stream without having to restart the data stream The code for handling the ethernet protocol is contained in ui_ethernet c with ui_ ethernet h containing the definitions for the structures functions and variables exported to the remainder of the application The file commands h contains the definitions for the commands parameters real time data items and responses that are used in the ethernet protocol The file ui_common h contains the definitions that are common to all of the communications API modules that are supported by the motor RDKs The ethernet module builds on the serial module in that the same message format is used This message is then transmitted received using a TCP IP connection between the RDK board and the host application The following message formats are defined 17 1 1 Command Message Format Commands are sent to the motor drive with the following format tag length
3. 7 2 3 20 7 2 3 21 Stellaris Brushless DC Motor RDK Software Reference Manual g_ulStartupHallStateCount static Definition static unsigned long g_ulStartupHallStateCount Description A count of the number of milliseconds to remain in a particular startup Hall state g_ulStartupHallStateCountReload static Definition static unsigned long g_ulStartupHallStateCountReload Description A count of the number of milliseconds to remain in a particular startup Hall state g_ulStartupHallValue static Definition static unsigned long g_ulStartupHallValue Description The current Hall state for Startup Mode g_ulState static Definition static unsigned long g_ulState Description The current state of the motor drive state machine This state machine controls acceleration deceleration starting stopping braking and reversing direction of the motor drive g_ulStateCount static Definition static unsigned long g_ulStateCount Description A count of the number of milliseconds to remain in a particular state February 19 2008 55 Main Application 56 February 19 2008 8 1 8 2 Stellaris Brushless DC Motor RDK Software Reference Manual On board User Interface O EOI 5 sexe A E eR Gee ae Pe arg EERE 57 DOMO sli ii da a ad ta 57 Introduction The on board user interface consists of a push button and a potentiometer The push button triggers actions when pressed released and wh
4. LUMINARYMICRO Stellaris Brushless DC Motor RDK SOFTWARE REFERENCE MANUAL RDK BLDC srm 716 Copyright 2007 2008 Luminary Micro Inc Legal Disclaimers and Trademark Information INFORMATION IN THIS DOCUMENT IS PROVIDED IN CONNECTION WITH LUMINARY MICRO PRODUCTS NO LICENSE EXPRESS OR IMPLIED BY ESTOPPEL OR OTHERWISE TO ANY INTELLECTUAL PROPERTY RIGHTS IS GRANTED BY THIS DOCUMENT EXCEPT AS PROVIDED IN LUMINARY MICRO S TERMS AND CONDITIONS OF SALE FOR SUCH PRODUCTS LUMINARY MICRO ASSUMES NO LIABILITY WHATSOEVER AND LUMINARY MICRO DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY RELATING TO SALE AND OR USE OF LUMINARY MICRO S PRODUCTS INCLUDING LIABILITY OR WARRANTIES RELATING TO FITNESS FOR A PARTICU LAR PURPOSE MERCHANTABILITY OR INFRINGEMENT OF ANY PATENT COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT LUMINARY MICRO S PRODUCTS ARE NOT INTENDED FOR USE IN MEDICAL LIFE SAVING OR LIFE SUSTAINING APPLICATIONS Luminary Micro may make changes to specifications and product descriptions at any time without notice Contact your local Luminary Micro sales office or your distributor to obtain the latest specifications and before placing your product order Designers must not rely on the absence or characteristics of any features or instructions marked reserved or undefined Luminary Micro reserves these for future definition and shall have no responsibility whatsoever for conflicts or incompatibilities arising from future
5. The edge triggering capability of the GPIO module is used for this measurement When running at higher speeds while using the encoder the number of edges in a fixed time period are counted to determine the speed of the rotor referred to as edge count mode The velocity capture feature of the quadrature encoder module is used for this measurement The transition between the two speed capture modes is performed based on the measured speed If in edge timing mode when the edge time gets too small that is there are too many edges per second it will change into edge count mode If in edge count mode when the number of edges in the time period gets too small that is there are not enough edges per time period it will change into edge timing mode There is a bit of hysteresis on the changeover point to avoid constantly switching between modes if the rotor is running near the changeover point The code for sensing the rotor speed is contained in speed_sense c With speed_sense h containing the definitions for the variable and functions exported to the remainder of the application Definitions Defines EDGE_DELTA FLAG_COUNT_BIT FLAG_EDGE_BIT m FLAG_SKIP_BIT MAX_EDGE_COUNT QEI_INT_RATE Functions void GPIOCIntHandler void void QEllntHanadler void static void SpeedNewValue unsigned short ulNewSpeed void SpeedSenselnit void February 19 2008 97 Speed Sensing 14 2 1 14 2 1 1 14 2 1 2 14
6. cally transition to STATE_BACK_RUN This results in a direction change of the motor drive STATE_RUN Definition define STATE _RUN Description The motor drive is running either at the target speed or slewing to the target speed STATE_STARTUP Definition define STATE STARTUP Description The motor drive is starting The motor will be spun in the forward direction until a minimum speed is reached At that point the motor state will be transitioned to STATE_RUN STATE_STOPPED Definition define STATE_STOPPED Description The motor drive is stopped A run request will cause a transition to the STATE_PRECHARGE or STATE_BACK_PRECHARGE states depending upon the direction flag February 19 2008 43 Main Application 7 2 1 22 7 2 1 23 7 2 1 24 1 2 2 7 2 2 1 7 2 2 2 44 STATE_STOPPING Definition define STATE_STOPPING Description The motor drive is decelerating down to a stop at which point the state machine will automati cally transition to STATE_STOPPED This results in the motor drive being stopped SYSTEM_CLOCK Definition define SYSTEM_CLOCK Description The frequency of the processor clock which is also the clock rate of all the peripherals This must match the value configured by SysCtlClockSet in main WATCHDOG_RELOAD_VALUE Definition define WATCHDOG_RELOAD_VALUE Description The watchdog timer reload value Function Documentation
7. 2008 Stellaris Brushless DC Motor RDK Software Reference Manual Returns None 16 2 3 21 UlRunLEDBlink Sets the blink rate for the run LED Prototype void UTRunLEDBlink unsigned short usRate unsigned short usPeriod Parameters usRate is the rate to blink the run LED usPeriod is the amount of time to turn on the run LED Description This function sets the rate at which the run LED should be blinked A blink period of zero means that the LED should be turned off and a blink period equal to the blink rate means that the LED should be turned on Otherwise the blink rate determines the number of user interface interrupts during the blink cycle of the run LED and the blink period is the number of those user interface interrupts during which the LED is turned on Returns None 16 2 3 22 UlSensorPolarity static Updates the sensor polarity bit of the motor drive Prototype static void UISensorPolarity void Description This function is called when the variable controlling the polarity of the sensor is updated The value is then reflected into the usFlags member of g_sParameters Returns None 16 2 3 23 UlSensorPresent static Updates the sensor presence bit of the motor drive Prototype static void UISensorPresent void February 19 2008 123 User Interface Description This function is called when the variable controlling the presence of an sensor is updated The value is then refle
8. Main Application 7 2 2 11 7 2 2 12 7 2 2 13 48 MainRun Starts the motor drive Prototype void MainRun void Description This function starts the motor drive If the motor is currently stopped it will begin the process of starting the motor If the motor is currently stopping it will cancel the stop operation and return the motor to the target speed Returns None MainSetDirection Sets the direction of the motor drive Prototype void MainSetDirection tBoolean bForward Parameters bForward is a boolean that is true if the motor drive should be run in the forward direction Description This function changes the direction of the motor drive If required the state machine will be transitioned to a new state in order to change the direction of the motor drive Returns None MainSetFault Indicate that a fault condition has been detected Prototype void MainSetFault unsigned long ulFaultFlag Parameters ulFaultFlag is a flag that indicates the fault condition that was detected Description This function is called when a fault condition is detected It will update the fault flags to indicate the fault condition that was detected and cause the fault LED to blink to indicate a fault Returns None February 19 2008 7 2 2 14 7 2 2 15 7 2 2 16 Stellaris Brushless DC Motor RDK Software Reference Manual MainSetPWMFrequency Changes the PWM frequency of the motor driv
9. Timer1 AlntHandler Handles the Timer1A interrupt Prototype void TimerlAIntHandler void Description This function is called when Timer1A asserts its interrupt It is responsible for keeping track of system time This should be the highest priority interrupt Returns None UlButtonHold static Handles button holds Prototype static void UIButtonHold void Description This function is called when a hold of the on board push button has been detected The modulation type of the motor will be toggled between sine wave and space vector modulation but only if a three phase motor is in use Returns None UlButtonPress Handles button presses Prototype void UlButtonPress void Description This function is called when a press of the on board push button has been detected If the motor drive is running it will be stopped If it is stopped the direction will be reversed and the motor drive will be started February 19 2008 117 User Interface 16 2 3 5 16 2 3 6 16 2 3 7 118 Returns None UlConnectionTimeout static Updates the Ethernet TCP connection timeout Prototype static void UIConnectionTimeout void Description This function is called when the variable controlling the presence of an encoder is updated The value is then reflected into the usFlags member of g_sParameters Returns None UlDecayMogde static Updates the decay mode bit of the motor drive P
10. of the processor Memory Layout The Brushless DC motor firmware works in cooperation with the Stellaris boot loader to provide a means of updating the firmware over the ethernet port When a request is made to perform a firmware update the Brushless DC motor firmware transfers control back to the boot loader After a reset the boot loader runs and simply passes control to the Brushless DC motor firmware In addition to the boot loader and the Brushless DC motor firmware there is a region of flash reserved for storing the motor drive parameters This allows these values to be persistent between power cycles of the board though they are only written to flash based on an explicit request The 256 KB of flash on the LM3S8971 is organized as follows 0x0000 00 Boot Loader 0x00 O ff BLDC Firmware Parameter Storage February 19 2008 1 5 1 6 Stellaris Brushless DC Motor RDK Software Reference Manual Source Code Organization The ZIP file containing the source code for the Brushless DC motor firmware should be extracted into the same directory to which the Stellaris Peripheral Driver Library was extracted For example if the driver library was extracted to c meaning there is a C DriverLib directory then the ZIP file for the Brushless DC motor should be extracted to c as well It will create an RDK BLDC directory that contains the source code for the application The following files and direct
11. static Definition static unsigned long g_ulHallSpeedFlags Description A set of flags that provide status and control of the Hall Control module 6 2 3 3 g_ulHallSpeedPrevious static Definition static unsigned long g_ulHallSpeedPrevious Description This is the time at which the previous edge was seen and is used to determine the time between edges 6 2 3 4 g_ulHallValue Definition unsigned long g_ulHallValue Description The current Hall Sensor value 36 February 19 2008 7 7 1 Stellaris Brushless DC Motor RDK Software Reference Manual Main Application A EE A E AE pe Rane aes ae pena ES 37 DAMONG dic di da a Deeside in dienes 38 Introduction This is the main Brushless DC motor application code It contains a state machine that controls the operation of the drive an interrupt handler for the waveform update software interrupt an interrupt handler for the millisecond speed update software interrupt and the main application startup code The waveform update interrupt handler is responsible for computing new values for the waveforms being driven to the inverter bridge Based on the update rate it will advance the drive angle and recompute new waveforms The new waveform values are passed to the PWM module to be supplied to the PWM hardware at the correct time The millisecond speed update interrupt handler is responsible for handling the dynamic brake computing the new drive speed and
12. A pin resides February 19 2008 67 Pin Definitions 9 2 1 19 9 2 1 20 9 2 1 21 9 2 1 22 9 2 1 23 9 2 1 24 68 PIN_HALLB_PIN Definition define PIN_HALLB_PIN Description The GPIO pin on which the HALL B pin resides PIN_HALLB_PORT Definition define PIN_HALLB_PORT Description The GPIO port on which the HALL B pin resides PIN_HALLC_PIN Definition define PIN_HALLC_PIN Description The GPIO pin on which the HALL C pin resides PIN_HALLC_PORT Definition define PIN_HALLC_PORT Description The GPIO port on which the HALL C pin resides PIN_INDEX_PIN Definition define PIN_INDEX_PIN Description The GPIO pin on which the quadrature encoder index pin resides PIN_INDEX_PORT Definition define PIN_INDEX_PORT Description The GPIO port on which the quadrature encoder index pin resides February 19 2008 9 2 1 25 9 2 1 26 9 2 1 27 9 2 1 28 9 2 1 29 9 2 1 30 Stellaris Brushless DC Motor RDK Software Reference Manual PIN_IPHASEA Definition define PIN_IPHASEA Description The ADC channel on which the phase A current sense resides PIN_IPHASEB Definition define PIN_IPHASEB Description The ADC channel on which the phase B current sense resides PIN_IPHASEC Definition define PIN_IPHASEC Description The ADC channel on which the phase C current sense resides PIN_LEDFAULT_PIN Definition define PIN _LEDFAUL
13. DC injection brake to stop the motor This field will be one of FLAG_DC_BRAKE_ON or FLAG_DC_BRAKE_OFF February 19 2008 Stellaris Brushless DC Motor RDK Software Reference Manual 16 2 2 5 FLAG DC _BRAKE_OFF The value of the FLAG_DC_BRAKE_BIT flag that indicates that the DC injection brake is disabled 16 2 2 6 FLAG_DC_BRAKE_ON The value of the FLAG_DC_BRAKE_BIT flag that indicates that the DC injection brake is enabled 16 2 2 7 FLAG_DECAY_BIT The bit number of the flag in the usFlags member of tDriveParameters that defines the decay mode for the trapezoid motor drive This field will be one of FLAG_DECAY_FAST or FLAG_DECAY_ SLOW 16 2 2 8 FLAG DECAY FAST The value of the FLAG_DECAY_BIT flag that indicates that the motor is to be driven with fast decay in trapezoid mode 16 2 2 9 FLAG_DECAY_SLOW The value of the FLAG_DECAY_BIT flag that indicates that the motor is to be driven with slow decay in trapezoid mode 16 2 2 10 FLAG_DIR_BACKWARD The value of the FLAG_DIR_BIT flag that indicates that the motor is to be driven in the backward direction 16 2 2 11 FLAG _DIR_BIT The bit number of the flag in the usFlags member of tDriveParameters that defines the direction the motor is to be driven The field will be one of FLAG_DIR_FORWARD or FLAG_DIR_BACKWARD 16 2 2 12 FLAG_DIR_FORWARD The value of the FLAG_DIR_BIT flag that indicates that the motor is to be driven in the forward direction February 19 2008 113 Us
14. This function is periodically called as a result of the waveform update software interrupt being asserted This interrupt is asserted at the requested rate based on the update rate parameter by the PWM interrupt handler The angle of the motor drive will be updated and new waveform values computed and supplied to the PWM module Note Since this interrupt is software triggered there is no interrupt source to clear in this handler Returns None Variable Documentation 9_ISpeedintegrator static Definition static long g_lSpeedIntegrator Description The accumulator for the integral term of the PI controller for the motor drive duty cycle February 19 2008 51 Main Application 1 2 3 2 7 2 3 3 7 2 3 4 7 2 3 5 7 2 3 6 52 9_ISpeedintegratorMax static Definition static long g_lSpeedIntegratorMax Description The maximum value that of the Pl controller accumulator g_lSpeedIntegrator This limit is based on the coefficient and the maximum duty cycle of the motor drive and is used to avoid integrator windup a potential pitfall of PI controllers g_ucMotorStatus Definition unsigned char g_ucMotorStatus Description The current operation state of the motor drive g_ulAccelRate static Definition static unsigned long g_ulAccelRate Description The current rate of acceleration This will start as the parameter value but may be reduced in order to manage increases in the motor c
15. changes to them Copyright O 2006 2008 Luminary Micro Inc All rights reserved Stellaris Luminary Micro and the Luminary Micro logo are registered trademarks of Luminary Micro Inc or its subsidiaries in the United States and other countries ARM and Thumb are registered trademarks and Cortex is a trademark of ARM Limited Other names and brands may be claimed as the property of others Luminary Micro Inc e 108 Wild Basin Suite 350 Austin TX 78746 Main 1 512 279 8800 Fax 1 512 279 8879 http www luminarymicro com Cortez Intelligent Processors by ARM a lu oc Lu S a E LUMINARYMICRO Revision Information This is version 716 of this document last updated on February 19 2008 2 February 19 2008 Stellaris Brushless DC Motor RDK Software Reference Manual Table of Contents Legal Disclaimers and Trademark Information 2 200 eee eee ee ees Revision Information 000 aa aa a 4 aaa 1 MIRTOOUIGUGOM occa we Re ae a A ele A a a eee we Be Ii 1 1 Overview 20 we a La RIP nk he EE Se oh es ek d d ai a Ee Be he es He Deh oe a es Lo PROCESS Usage psec abe EE AAA PEEP Ee BERR LA Memory bayaut 2 aca Se a Ae ee A Ea ew SE Ree 1 5 Source Code Organization scssi pep ee eee ee eae Pw Pee eee dE eR Le Depa bear edge we ee baw RRA wh REO SEE OR RRR EE HEE SEE 2 ADE COMO 3000 is a death aa ms eS ae BH A ete ed oe ae a OA A eh ee eae ee A ee eee Oe a a a a A A tes Dee Se a 22 D NNHON
16. char pucBuffer Variables Static tBoolean g_bEnableRealTimeData static Boolean g_bSendRealTimeData static struct netif g EMAC_if static struct tcp_pcb g psTelnetPCB February 19 2008 135 Ethernet Interface static unsigned char g_pucUlEthernetData UIETHERNET_MAX_XMIT static unsigned char g_pucUlEthernetReceive UIETHERNET_MAX_RECV static unsigned char g_pucUlEthernetResponse UIETHERNET_MAX_XMIT static unsigned long g_pulUlRealTimeData DATA_NUM_ITEMS 31 32 static unsigned long g_ulARPTimer static unsigned long g_ulConnectionTimeout volatile unsigned long g_ulConnectionTimeoutParameter volatile unsigned long g_ulEthernetRXCount volatile unsigned long g_ulEthernetTimer volatile unsigned long g_ulEthernetT XCount static unsigned long g_ulTCPFastTimer m static unsigned long g_ulTCPSlowTimer static unsigned long g_ulUlEthernetReceiveRead static unsigned long g_ulUlEthernetReceiveWrite 17 2 1 Define Documentation 17 2 1 1 DEFAULT_GATEWAY_ADDRO Definition define DEFAULT _GATEWAY_ADDRO Description The Default Gateway address to be used 17 2 1 2 DEFAULT_IPADDRO Definition define DEFAULT_IPADDRO Description The Default IP address to be used Default TCP IP Address Configuration Static IP Configuration is used if DHCP times out 17 2 1 3 DEFAULT _NET_MASKO Definition define DEFAULT_NET_MASKO Description The Default Network m
17. checking for fault conditions If the drive is just starting this is where the precharging of the high side gate drivers is handled If the drive has just stopped this is where the DC injection braking is handled Dynamic braking is handled by simply calling the update function for the dynamic braking module When running a variety of things are done to adjust the drive speed First the acceleration or deceleration rate is applied as appropriate to move the drive speed towards the target speed Also the amplitude of the PWM outputs is adjusted by a PI controller moving the rotor speed to the desired speed In the case of deceleration the deceleration rate may be reduced based on the DC bus voltage The result of this soeed adjustment is a new step angle which is subsequently used by the waveform update interrupt handler to generate the output waveforms The over temperature DC bus under voltage DC bus over voltage motor under current and motor over current faults are all checked for by examining the readings from the ADC Fault conditions are handled by turning off the drive output and indicating the appropriate fault which must be cleared before the drive will run again The state machine that controls the operation of the drive is woven throughout the millisecond speed update interrupt handler and the routines that start stop and adjust the parameters of the motor drive Together it ensures that the motor drive responds to commands and
18. command optional command data byte s checksum The tag byte is Oxff The length byte contains the overall length of the command packet starting with the tag and ending with the checksum The maximum packet length is 255 bytes The command byte is the command being sent Based on the command there may be optional command data bytes that follow The checksum byte is the value such that the sum of all bytes in the command packet in cluding the checksum will be zero This is used to validate a command packet and allow the target to synchronize with the command stream being sent by the host February 19 2008 133 Ethernet Interface 17 1 2 17 1 3 17 1 4 134 For example the 0x01 command with no data bytes would be sent as follows Oxff 0x04 0x01 Oxfc And the 0x02 command with two data bytes Oxab and Oxcd would be sent as follows Oxff 0x06 0x02 Oxab Oxcd 0x81 Status Message Format Status messages are sent from the motor drive with the following format tag length data bytes checksum The tag byte is Oxfe for command responses and Oxfd for real time data The length byte contains the overall length of the status packet starting with the tag byte and ending with the checksum The contents of the data bytes are dependent upon the tag byte The checksum is the value such that the sum of all bytes in the status packet including the checksum will be zero This is us
19. eii e a a Pie Remar ch eae Gd a o a a 13 Sine Wave Modulation lt lt lt lt lt lt 2 2 a 244 13 1 INIPOUCHON lt occ a a a a a ee es ave DENIOS a a 2 e222 4 Fae eda e e ae a ee eee eee ROA eee ee February 19 2008 000 NNOO N N Table of Contents 14 Speed Sensing eec Swi ee eee ee PE ee eae ee ee 97 Ws ss A s os ee ee ee ee GP Ps a we ee a ea tt oe BA ee ee 97 142 DONORS ccce iora e ea dad eg Rew a Seo ne eae d od were Be ea 97 15 Trapezoid Modulation 22 ee ee es 103 To INFSOUCIDAN a a Se cs ee a eee SEG ee eve e e la a eR S ce cee ce es ated eee ed 103 132 Deng AS gt 53 8 4 2 4 4 aa ea Gea ew AE ae a a e ee Ee 103 16 User interface sce ee ee or ee ee eee a 107 Tee IMIFOUCUO 1 0 ee ete ee ae ek RS a we Re ee a oe al as 107 162 DOIMIIONS lt lt lt al a ee we a Se a RR we el ee RS Bo le me we ee SE ao a 107 If Bthemet interlace 2 ew Bes a ara es eo ew A A A ee ee ea we we a aw ee a A 133 17 1 INIFOUCHON o os eama a a a a a ee 133 172 DOTIMICOS sa a a eee a a a ed a a at ls es ls 135 Company Information 1 2 6 ee 148 SUPport Informati n lt lt i ea we eee eee ea A 148 4 February 19 2008 1 1 1 2 Stellaris Brushless DC Motor RDK Software Reference Manual Introduction a eee bend 5 COGS SIZE EAT TINE ENE ES E rein edanG Miseeaeaeud Aes yatue uae anne E TE 5 Processor O A cena ceaeaghns Mihecdnnedeesegins exeouanas 6 Memory LAVOU edi EA A
20. function is called when the IwIP TCP IP stack has detected an error The connection is no longer valid Returns This function will return an IwIP defined error code 17 2 2 5 UlEthernetFindParameter static Finds a parameter by ID Prototype static unsigned long UI EthernetFindParameter unsigned char ucID Parameters ucID is the ID of the parameter to locate Description This function searches the list of parameters looking for one that matches the provided ID Returns Returns the index of the parameter found or Oxffff ffff if the parameter does not exist in the parameter list 17 2 2 6 UlEthernetGetlPAddress Return February 19 2008 the current IPV4 TCP IP address 139 Ethernet Interface 17 2 2 7 17 2 2 8 140 Prototype unsigned long UIEthernetGet IPAddress void Description Read the IP address from the IwlP network interface structure and return it in unsigned long format Returns IP address UlEthernetinit Initialize the Ethernet controller and IwIP TCP IP stack Prototype void UlEthernetInit tBoolean bUseDHCP Parameters bUseDHCP indicates whether the DHCP client software should be used if the build options have enabled it Description Initialize the Ethernet controller for operation including the setup of the MAC address and enabling of status LEDs Also initialize the IwIP TCP IP stack for operation including DHCP operation Returns Non
21. is pressed For switches that do not have a hold function this is called as soon as the switch is pressed For switches that have a hold function it is called when the switch is released only if it was held for less than the hold time if held longer this function will not be called If no press function is required then this can be NULL pfnRelease A pointer to the function to be called when the switch is released if no release function is required then this can be NULL pfnHold A pointer to the function to be called when the switch is held for the hold time If no hold function is required then this can be NULL Description This structure contains a set of variables that describe the properties of a switch 8 2 2 Function Documentation 8 2 2 1 UlOnboardInit Initializes the on board user interface elements 58 February 19 2008 Stellaris Brushless DC Motor RDK Software Reference Manual 8 2 2 2 8 2 2 3 Prototype void UlOnboardInit unsigned long ulSwitches unsigned long ulPotentiometer Parameters ulSwitches is the initial state of the switches ulPotentiometer is the initial state of the potentiometer Description This function initializes the internal state of the on board user interface handlers The initial state of the switches are used to avoid spurious switch presses releases and the initial state of the potentiometer is used to make the filtered potentiometer value track more accurately when fir
22. motor phase current motor phase back EMF voltage linear hall sensor voltage DC bus voltage analog input voltage and ambient temperature of the microcontroller Each of these values is sampled every PWM period based on a trigger from the PWM module Multiple ADC sequences are used to allow optimization of CPU usage Readings from the ADC may be passed through a single pole IIR low pass filter This helps to reduce the effects of high frequency noise such as switching noise on the sampled data A coefficient of 0 75 is used to simplify the integer math requiring only a multiplication by 3 an addition and a division by four The individual motor phase RMS currents motor RMS current DC bus voltage and ambient tem perature are used outside this module The code for handling the ADC is contained in adc_ctr1 c with adc_ctrl h containing the definitions for the variables and functions exported to the remainder of the application Definitions Defines FLAG_EDGE_BIT m FLAG_SKIP_BIT FLAG_SKIP_LINEAR_BIT Functions void ADCOIntHandler void static void ADCOIntHandlerSine void static void ADCOIntHandlerTrapezoid void void ADC1 IntHandler void void ADC2IntHandler void void ADC3IntHandler void void ADCConfigurePhaseCurrentSequence unsigned char ucMode void ADCEnableBackEMFSequence tBoolean bEnable void ADCEnableLinearHallSequence tBoolean bEnable void ADCInit void ADC Control void ADCTickHandle
23. once the entire packet is contained within the buffer g_pucUlEthernetResponse static Definition static unsigned char g_pucUlEthernetResponse UIETHERNET_MAX_XMIT Description A buffer used to construct status packets before they are written to the UART and or g_puc UlEthernetTransmit g_pulUIRealTimeData static Definition static unsigned long g_pulUIRealTimeData DATA_NUM_ITEMS 31 32 Description A bit array that contains a flag for each real time data item When the corresponding flag is set that real time data item is enabled in the real time data stream when the flag is clear that real time data item is not part of the real time data stream g_ulARPTimer static Definition static unsigned long g_ulARPTimer Description The ARP timer for IwIP February 19 2008 145 Ethernet Interface 17 2 3 10 g_ulConnectionTimeout static Definition static unsigned long g_ulConnectionTimeout Description Counter for TCP connection timeout 17 2 3 11 g_ulConnectionTimeoutParameter Definition volatile unsigned long g_ulConnectionTimeoutParameter Description Timeout value for TCP connection timeout timer 17 2 3 12 g_ulEthernetRXCount Definition volatile unsigned long g_ulEthernetRXCount Description This global is used to store the number of Ethernet messages that have been received since power up 17 2 3 13 g_ulEthernetTimer Definition volatile u
24. parameter changes in a logical and predictable manner The application startup code performs high level initialization of the microcontroller such as en abling peripherals and calls the initialization routines for the various support modules Since all the work within the motor drive occurs with interrupt handlers its final task is to go into an infinite loop that puts the processor into sleep mode This serves two purposes it allows the processor to wait until there is work to be done for example an interrupt before it executes any further code and it allows the processor usage meter to gather the data it needs to determine processor usage The main application code is contained in main c with main h containing the definitions for the defines variables and functions exported to the remainder of the application February 19 2008 37 Main Application 7 2 38 Definitions Defines CRYSTAL_CLOCK FLASH_PB_END FLASH_PB_SIZE FLASH_PB_START STATE_BACK_PRECHARGE STATE_BACK_REV STATE_BACK_RUN STATE_BACK_STARTUP STATE_BACK_STOPPING STATE_FLAG_BACKWARD STATE_FLAG_FORWARD STATE_FLAG_PRECHARGE STATE_FLAG_REV STATE_FLAG_RUN STATE_FLAG_STARTUP m STATE_FLAG_STOPPING STATE_PRECHARGE STATE_REV STATE_RUN STATE_STARTUP STATE_STOPPED STATE_STOPPING SYSTEM_CLOCK WATCHDOG_RELOAD_VALUE Functions int main void static void MainCheckFaults void void MainClea
25. parameters and real time data items supported by the motor drive The functions are used when an application specific action needs to take place as a result of the ethernet communication such as starting the motor drive The structures are used to handle the parameters and real time data items of the motor drive 17 2 Definitions Defines DEFAULT_GATEWAY_ADDRO DEFAULT_IPADDRO DEFAULT_NET_MASKO DHCP_EXPIRE_TIMER_SECS Ul_PROTO_PORT UlQUERY_PORT m UIETHERNET_MAX_RECV UIETHERNET_MAX_XMIT Functions void EthernetIntHandler void static err_t UlEthernetAccept void arg struct tcp_pcb pcb err_t err static void UlEthernetClose struct tcp_pcb pcb static void UlEthernetError void arg err_t err static unsigned long UlEthernetFindParameter unsigned char uclD unsigned long UlEthernetGetlPAddress void void UlEthernetlnit tBoolean bUseDHCP static err_t UlEthernetPoll void arg struct tcp_pcb pcb static void UlEthernetRangeCheck unsigned long ulldx static err_t UlEthernetReceive void arg struct tcp_pcb pcb struct pbuf xp err_t err static void UlEthernetReceiveUDP void arg struct udp_pcb pcb struct pbuf xp struct ip_ addr addr u16_t port static void UlEthernetScanReceive void void UlEthernetSendRealTimeData void static err_t UlEthernetSent void arg struct tcp_pcb pcb u16_t len void UlEthernetTick unsigned long ulTickMS static Boolean UlEthernetTransmit unsigned
26. perform all the processing of those values The code for handling the on board user interface elements is contained in ui_onboard c with ui_onboard h containing the definitions for the structures and functions exported to the remain der of the application Definitions Data Structures tUlOnboardSwitch Functions void UlOnboardlnit unsigned long ulSwitches unsigned long ulPotentiometer unsigned long UlOnboardPotentiometerFilter unsigned long ulValue void UlOnboardSwitchDebouncer unsigned long ulSwitches February 19 2008 57 On board User Interface Variables static unsigned long g_ulUlOnboardClockA static unsigned long g_ulUlOnboardClockB static unsigned long g_ulUlOnboardFilteredPotValue static unsigned long g_ulUlOnboardPotCount static unsigned long g_ulUlOnboardPotMax static unsigned long g_ulUlOnboardPotMin static unsigned long g_ulUlOnboardPotSum static unsigned long g_ulUlOnboardPotValue static unsigned long g_ulUlOnboardSwitches 8 2 1 Data Structure Documentation 8 2 1 1 tUlOnboardSwitch Definition typedef struct unsigned char ucBit unsigned long ulHoldTime void pfnPress void void pfnRelease void void pfnHold void tULOnboardSwitch Members ucBit The bit position of this switch ulHoldTime The number of sample periods which the switch must be held in order to invoke the hold function pfnPress A pointer to the function to be called when the switch
27. result in an immediate motor over current fault since the increased slip will result in a rise in motor current While not harmful it does not allow the typically desired behavior of being able to stop the application look at the internal state then restart the application as if nothing had happened An interrupt is generated at each zero value of the counter in PWM generator zero this is used as a time base for the generation of waveforms as well as a time to queue the next duty cycle update into the hardware At any given time the PWM module is outputting the duty cycle for period N has the duty cycle for period N 1 queued in its holding registers waiting for the next zero value of the counter and the microcontroller is computing the duty cycle for period N 2 Two software interrupts are generated by the PWM interrupt handler One is used to update the waveform this occurs at a configurable rate of every X PWM period The other is used to update the drive frequency and perform other periodic system tasks such as fault monitoring this occurs every millisecond The unused interrupts from the second and third PWM generator are used for these software interrupts the ability to fake the assertion of an interrupt through the NVIC software interrupt trigger register is used to generate these software interrupts The code for handling the PWM module is contained in pwm_ctr1 c with pwm_ctr1 h containing the definitions for the var
28. static unsigned long g_ulHallPrevious Description The previous value of the Hall state for trapezoid modulation g_ulMeasuredSpeed Definition unsigned long g_ulMeasuredSpeed Description The current speed of the motor This value is updated based on whether the encoder or Hall sensors are being used February 19 2008 53 Main Application 7 2 3 12 7 2 3 13 7 2 3 14 7 2 3 15 7 2 3 16 54 g_ulSineTarget static Definition static unsigned long g_ulSineTarget Description The Sine modulation target speed g_ulSpeed static Definition static unsigned long g_ulSpeed Description The current motor drive speed in RPM expressed as a 18 14 fixed point value g_ulSpeedFract static Definition static unsigned long g_ulSpeedFract Description The fractional part of the current motor drive speed This value is expressed as the numerator of a fraction whose denominator is the PWM frequency This is used in conjunction with g_ul SpeedWhole to compute the value for g_ulSpeed g_ulSpeedWhole static Definition static unsigned long g_ulSpeedWhole Description The whole part of the current motor drive speed This is used in conjunction with g_ulSpeed Fract to compute the value for g_ulSpeed g_ulStallDetectCount static Definition static unsigned long g_ulStallDetectCount Description The Stall Detection Count February 19 2008 123 17 7 2 3 18 7 2 3 19
29. static unsigned short g_pusBlinkRate 2 Description The blink rate of the two LEDs on the board this is the number of user interface interrupts for an entire blink cycle The run LED is the first entry of the array and the fault LED is the second entry of the array g_sParameters Definition tDriveParameters g_sParameters Description This structure instance contains the configuration values for the Brushless DC motor drive g_sUlParameters Definition const tUlParameter g_sUIParameters Description An array of structures describing the Brushless DC motor drive parameters to the Ethernet user interface module February 19 2008 Stellaris Brushless DC Motor RDK Software Reference Manual 16 2 4 9 g _sUlRealTimeData Definition const tUlRealTimeData g_sUlRealTimeDatal Description An array of structures describing the Brushless DC motor drive real time data items to the serial user interface module 16 2 4 10 g_sUISwitches Definition const tUIOnboardSwitch g_sUISwitches Description An array of structures describing the on board switches 16 2 4 11 g_ucBoardID Definition unsigned char g_ucBoardID Description This is the board id read once from the configuration switches at startup 16 2 4 12 yg ucCPUUsage Definition unsigned char g_ucCPUUsage Description The processor usage for the most recent measurement period This is a value between 0 and 100 inclusive 16 2 4 13 g_ucDecayMod
30. the FLAG_SENSOR_BIT flag that indicates that the Hall Effect sensor s are present 16 2 2 30 FLAG_SENSOR_TYPE_BIT The bit number of the flag in the usFlags member of tDriveParameters that defines the type of Hall Effect Sensor s for position speed feedback This field will be one of FLAG_SENSOR_TYPE_ GPIO or FLAG_SENSOR_TYPE_LINEAR 16 2 2 31 FLAG_SENSOR_TYPE_GPIO The value of the FLAG_SENSOR_TYPE_BIT flag that indicates that the Hall Effect sensor s are digital GPIO inputs 16 2 2 32 FLAG_SENSOR_TYPE_LINEAR The value of the FLAG_SENSOR_TYPE_BIT flag that indicates that the Hall Effect sensor s are Analog Linear ADC inputs 16 2 2 33 NUM_SWITCHES The number of switches in the g_sUISwitches array This value is automatically computed based on the number of entries in the array 16 2 2 34 TIMER1A_INT_RATE The rate at which the timer interrupt occurs 16 2 2 35 Ul_INT_RATE The rate at which the user interface interrupt occurs 16 2 3 Function Documentation 16 2 3 1 SysTicklntHandler Handles the SysTick interrupt Prototype void SysTickIntHandler void 116 February 19 2008 16 2 3 2 16 2 3 3 16 2 3 4 Stellaris Brushless DC Motor RDK Software Reference Manual Description This function is called when SysTick asserts its interrupt It is responsible for handling the on board user interface elements push button and potentiometer if enabled and the processor usage computation Returns None
31. to wrapping back to zero is considered to be the current parameter block The contents of this region of flash are loaded into SRAM as the current parameters for the motor drive Saving new parameter blocks involves three steps Setting the sequence number such that it is one greater than the sequence number of the latest parameter block in flash Computing the checksum of the parameter block Writing the parameter block into the storage immediately following the latest parameter block in flash if that storage is at the start of an erase block that block is erased first By this process there is always a valid parameter block in flash If power is lost while writing a new parameter block the checksum will not match and the partially written parameter block will be ignored This is what makes this fault tolerant Another benefit of this scheme is that it provides wear leveling on the flash Since multiple parame ter blocks fit into each erase block of flash and multiple erase blocks are used for parameter block storage it takes quite a few parameter block saves before flash is re written In order to make this efficient and effective two conditions must be met The first is that at least two erase blocks of flash must be dedicated to parameter block storage If not fault tolerance can not be guaranteed since an erase of the single block will leave a window where there are no valid parameter blocks in flash The second condition
32. unsigned char ucPad1 1 unsigned short usAccel unsigned short usDecel short sMinCurrent short sMaxCurrent u u u u u u u u u u u u nsigned char ucPrechargeTime nsigned char ucMaxTemperature nsigned short usFlags nsigned short usNumEncoderLines nsigned char ucPad2 2 nsigned long nsigned long nsigned long nsigned long nsigned long nsigned long nsigned long ong 1FAdjP long 1FAd31 long 1FAd3D nsigned long ulBrakeMax nsigned long ulBrakeCool hort sAccelCurrent nsigned char ucPad3 2 nsigned long ulConnectionTimeout nsigned char ucStartupDutyCycle nsigned char ucPad4 3 nsigned long ulStartupCount hort sTargetCurrent nsigned char ucPad5 38 inSpeed axSpeed inVBus axVBus 1BrakeOnV lBrake0ffV lDecelV E G e G E G u u u u GO Ge 6 606 110 February 19 2008 Stellaris Brushless DC Motor RDK Software Reference Manual tDriveParameters Members ucSequenceNum The sequence number of this parameter block When in RAM this value is not used When in flash this value is used to determine the parameter block with the most recent information ucCRC The CRC of the parameter block When in RAM this value is not used When in flash this value is used to validate the contents of the parameter block to avoid using a partially written parameter block ucVersion The version of this pa
33. usage Returns Returns the CPU usage percentage as a 16 16 fixed point value Variable Documentation g_ulCPUUsagePrevious static Definition static unsigned long g_ulCPUUsagePrevious Description The value of timer two on the previous timing period This is used to determine the number of clock ticks counted by the timer during the timing period g_uICPUUsageTicks static Definition static unsigned long g_ulCPUUsageTicks February 19 2008 Stellaris Brushless DC Motor RDK Software Reference Manual Description The number of processor clock ticks per timing period February 19 2008 79 Processor Usage Meter 80 February 19 2008 11 11 1 Stellaris Brushless DC Motor RDK Software Reference Manual PWM Control O O 2 area veaucnsaneep pera ins eaaak eee er enn nt ase aennnremanngunpeReeNe Gas an endo eemenamenes 81 2 a5i5 canacend A A Des Reese AEREA 82 Introduction The generated motor drive waveforms are driven to the inverter bridge with the PWM module The PWM generators are run in a fully synchronous manner the counters are synchronized that is the values of the three counters are always the same and updates to the duty cycle registers are synchronized to the zero value of the PWM counters The dead band unit in each PWM generator is used to prevent shoot through current in the inverter bridge when switching between the high side to the low of a phase Shoot through occurs because the tur
34. while running in the backward direction at which point the state machine will automatically transition to STATE_RUN This results in a direction change of the motor drive February 19 2008 7 2 1 7 7 2 1 8 7 2 1 9 7 2 1 10 7 2 1 11 Stellaris Brushless DC Motor RDK Software Reference Manual STATE_BACK_RUN Definition define STATE_BACK_RUN Description The motor drive is running in the backward direction either at the target speed or slewing to the target speed STATE_BACK_STARTUP Definition define STATE_BACK_STARTUP Description The motor drive is starting The motor will be spun in the backward direction until a minimum speed is reached At that point the motor state will be transitioned to STATE_BACK_RUN STATE_BACK_STOPPING Definition define STATE BACK STOPPING Description The motor drive is decelerating down to a stop while running in the backward direction at which point the state machine will automatically transition to STATE STOPPED This results in the motor drive being stopped STATE_FLAG_BACKWARD Definition define STATE _FLAG BACKWARD Description A state flag that indicates that the motor drive is in the backward direction STATE_FLAG_FORWARD Definition define STATE FLAG FORWARD Description A state flag that indicates that the motor drive is in the forward direction February 19 2008 41 Main Application 7 2 1 12 7 2 1 13 7 2 1 14 7 2 1
35. 15 7 2 1 16 42 STATE_FLAG_PRECHARGE Definition define STATE FLAG PRECHARGE Description A state flag that indicates that the motor drive is precharging the bootstrap capacitors on the high side gate drivers STATE_FLAG_REV Definition define STATE FLAG REV Description A state flag that indicates that the motor drive is reversing direction STATE_FLAG_RUN Definition define STATE _FLAG_RUN Description A state flag that indicates that the motor drive is running STATE_FLAG_STARTUP Definition define STATE _FLAG_ STARTUP Description A state flag that indicates that the motor drive is in the startup condition getting the motor spinning for sensorless opertation STATE_FLAG_STOPPING Definition define STATE FLAG STOPPING Description A state flag that indicates that the motor drive is stopping February 19 2008 7 2 1 17 7 2 1 18 7 2 1 19 7 2 1 20 7 2 1 21 Stellaris Brushless DC Motor RDK Software Reference Manual STATE_PRECHARGE Definition define STATE_PRECHARGE Description The motor drive is precharging the bootstrap capacitors on the high side gate drivers Once the capacitors are charged the state machine will automatically transition to STATE_RUN STATE_REV Definition define STATE_REV Description The motor drive is decelerating down to a stop at which point the state machine will automati
36. 2 1 3 14 2 1 4 98 Variables unsigned long g_ulRotorSpeed static unsigned long g_ulSpeedFlags static unsigned long g_ulSpeedPrevious static unsigned long g_ulSpeedTime Define Documentation EDGE_DELTA Definition define EDGE _DELTA Description The hysteresis applied to MAX_EDGE_COUNT when changing between the two speed deter mination modes FLAG_COUNT_BIT Definition define FLAG _COUNT_BIT Description The bit number of the flag in g_ulSpeedFlags that indicates that edge counting mode is being used to determine the speed FLAG_EDGE_BIT Definition define FLAG _EDGE_BIT Description The bit number of the flag in g_ulSpeedFlags that indicates that an edge has been seen by the edge timing mode If an edge hasn t been seen during a QEI velocity interrupt period the speed is forced to zero FLAG_SKIP_BIT Definition define FLAG_SKIP_BIT Description The bit number of the flag in g_ulSpeedFlags that indicates that the next edge should be ignored by the edge timing mode This is used when the edge timing mode is first enabled since there is no previous edge time to be used to calculate the time between edges February 19 2008 14 2 1 5 14 2 1 6 14 2 2 14 2 2 1 14 2 2 2 Stellaris Brushless DC Motor RDK Software Reference Manual MAX_EDGE_COUNT Definition define MAX _EDGE_COUNT Description The maximum number of edges per second al
37. 75 Pin Definitions 76 February 19 2008 10 10 1 10 2 Stellaris Brushless DC Motor RDK Software Reference Manual Processor Usage Meter o A 5 cee maugeme ea een a oa anew teak rene ena Sala aaeSOE ORAA TT DEDOS es E AREA Ta Tee eT eee ere AAA YT Introduction The CPU utilization module uses one of the system timers and peripheral clock gating to determine the percentage of the time that the processor is being clocked For the most part the processor is executing code whenever it is being clocked exceptions occur when the clocking is being con figured which only happens at startup and when entering exiting an interrupt handler when the processor is performing stacking operations on behalf of the application The third timer timer2 is configured to run when the processor is in run mode and to not run when the processor is in sleep mode Therefore the timer will only count when the processor is being clocked Comparing the number of clocks the timer counted during a fixed period to the number of clocks in the fixed period provides the percentage utilization In order for this to be effective the application must put the processor to sleep when it has no work to do instead of busy waiting If the processor never goes to sleep either because of a continual stream of work to do or a busy loop the processor utilization will be reported as 100 Since deep sleep mode changes the clocking of the system the computed processo
38. EQUENCY_20K FLAG_PWM_FREQUENCY_8K FLAG_PWM_FREQUENCY_MASK FLAG_SENSOR_ABSENT FLAG_SENSOR_BIT FLAG_SENSOR_POLARITY_BIT FLAG_SENSOR_POLARITY_HIGH FLAG_SENSOR_POLARITY_LOW FLAG_SENSOR_PRESENT FLAG_SENSOR_TYPE_BIT FLAG_SENSOR_TYPE_GPIO FLAG_SENSOR_TYPE_LINEAR NUM_SWITCHES TIMER1A_INT_RATE UI_INT_RATE Functions void SysTickIntHandler void void Timer1AlntHandler void static void UlButtonHold void void UlButtonPress void static void UlConnectionTimeout void static void UlDecayMode void static void UlDirectionSet void static void UlDynamicBrake void void UlEmergencyStop void static void UlEncoderPresent void static void UIFAdjl void void UlFaultLEDBlink unsigned short usRate unsigned short usPeriod unsigned long UlGetTicks void February 19 2008 Stellaris Brushless DC Motor RDK Software Reference Manual void Ullnit void static void UILEDBlink unsigned long ulldx unsigned short usRate unsigned short usPeriod static void UlModulationType void void UlParamLoad void void UlParamSave void static void UIPWMFrequencySet void void UlRun void void UIRunLEDBlink unsigned short usRate unsigned short usPeriod static void UlSensorPolarity void static void UlSensorPresent void static void UlSensorType void void UlStop void static void UlUpdateRate void void UlUpgrade void Variables February 19 2008 static long g_IFAdjl static const unsigned char g_pucLEDPi
39. HASEA_HIGH_PORT Description The GPIO port on which the phase A high side pin resides PIN_PHASEA_LOW_PIN Definition define PIN_PHASEA_LOW_PIN Description The GPIO pin on which the phase A low side pin resides PIN_PHASEA_LOW_PORT Definition define PIN_PHASEA_LOW_PORT Description The GPIO port on which the phase A low side pin resides PIN_PHASEB_HIGH_PIN Definition define PIN_PHASEB_HIGH_PIN Description The GPIO pin on which the phase B high side pin resides PIN_PHASEB_HIGH_PORT Definition define PIN_PHASEB_HIGH_PORT Description The GPIO port on which the phase B high side pin resides PIN_PHASEB_LOW PIN Definition define PIN_PHASEB_LOW_PIN Description The GPIO pin on which the phase B low side pin resides February 19 2008 71 Pin Definitions 9 2 1 43 9 2 1 44 9 2 1 45 9 2 1 46 9 2 1 47 9 2 1 48 72 PIN_PHASEB_LOW_PORT Definition define PIN_PHASEB_LOW_PORT Description The GPIO port on which the phase B low side pin resides PIN_PHASEC_HIGH_PIN Definition define PIN_PHASEC_HIGH_PIN Description The GPIO pin on which the phase C high side pin resides PIN_PHASEC_HIGH_PORT Definition define PIN_PHASEC_HIGH_PORT Description The GPIO port on which the phase C high side pin resides PIN_PHASEC_LOW_PIN Definition define PIN_PHASEC_LOW_PIN Description The GPIO pin on which the phase C low side pin r
40. O dd 6 OCS GOD IONES aura lA TA ARA AAA AAA E SOMO GIN ioira eaaa a tenes bea aeatiah renee kes mont Gtetaareaseceeoabiues T Overview This document describes the functions variables structures and symbolic constants in the soft ware for the Brushless DC motor RDK The firmware runs on a Stellaris LM3S8971 microcon troller utilizing the provided six channel motion control PWM module eight channel ADC Ethernet and quadrature encoder module The Stellaris Peripheral Driver Library is used to configure and operate these peripherals The Brushless DC motor application has the following features Operation from 0 to 60 000 RPM with 1 RPM steps Acceleration and deceleration from 1 to 50000 RPM sec PWM frequency of 8 KHz 12 5 KHz 16 KHz or 20 KHz Closed loop speed control Dynamic braking Real time data monitoring Fault monitoring and handling Trapezoid and Sine Wave Modulation Sensorless Operation Trapezoid Modulation See the Stellaris Brushless DC Motor Reference Design Kit User s Manual for details of these features how to run the application and details of the various motor drive parameters Code Size The size of the final application binary depends upon the source code the compiler used and the version of the compiler This makes it difficult to give an absolute size for the application since changes to any of these variables will likely change the size of the application if only slightly Typical num
41. PIN_PHASEC_LOW_PIN PIN_PHASEC_LOW_PORT PIN_SWITCH_PIN PIN_SWITCH_PIN_BIT PIN_SWITCH_PORT PIN_UARTORX_PIN PIN_UARTORX_PORT PIN_UARTOTX_PIN PIN_UARTOTX_PORT PIN_VANALOG PIN_VBEMFA PIN_VBEMFB PIN_VBEMFC PIN_VSENSE PWM_PHASEA_HIGH PWM_PHASEA_LOW PWM_PHASEB_HIGH PWM_PHASEB_LOW PWM_PHASEC_HIGH PWM_PHASEC_LOW 9 2 1 Define Documentation 9 2 1 1 PIN _BRAKE_PIN Definition 64 define PIN BRAKE PIN February 19 2008 9 2 1 2 9 2 1 3 9 2 1 4 9 2 1 5 9 2 1 6 Stellaris Brushless DC Motor RDK Software Reference Manual Description The GPIO pin on which the brake pin resides PIN_BRAKE_PORT Definition define PIN_BRAKE_PORT Description The GPIO port on which the brake pin resides PIN_CANORX_PIN Definition define PIN_CANORX_PIN Description The GPIO pin on which the CANO Rx pin resides PIN_CANORX_PORT Definition define PIN_CANORX_PORT Description The GPIO port on which the CANO Rx pin resides PIN_CANOTX_PIN Definition define PIN_CANOTX_PIN Description The GPIO pin on which the CANO Tx pin resides PIN_CANOTX_PORT Definition define PIN_CANOTX_PORT Description The GPIO port on which the CANO Tx pin resides February 19 2008 65 Pin Definitions 9 2 1 7 9 2 1 8 9 2 1 9 9 2 1 10 9 2 1 11 9 2 1 12 66 PIN_CFGO_PIN Definition define PIN_CFGO_PIN Description The GPIO pin on which the CFGO pin resides PIN_CFGO_PORT Definit
42. S e sa Swe Re BBS ee et et we Siete Mee eee eB ee ash eee et Boh ace ee Ge a Ss Sw k 3 Dynamic Brake Control lt lt i 2 2 ei ee ee a eee is lt a oe ee ke ee dee es we a OE ee a a he ee we Oe a n Se DeMons a t eek a ee A eee eh ee et e Do a di id 4 FAM a a e ti US TA dd a a e es LO A SE TA a O a a a At ps AA bee a ee ee ee eee Se O O Ee de a a A R 5 Flash Parameter Block 0000 ce eee eee ee n Dl WAWGOUCHON o aa a A wee ew eee Reed od ee ed ae pe Sa E ANA 6 Fall Sensor COnitF l occiso Ae ie e e ae ah a ia a a G O tala E or s san Se we ewe ee ee eh he al Lea a a ae a a ee a OGA DEMONS sa aa cima a aa oS ew ee A A a GaSe ie ie ed 7 Main Application e aa RR A A BS TA INTE OUNAE wala e he a de a GS Bes A sec 0 BA eee ee ee eee dd lit er aes 2a a Ba Be ee Ce ee 8 On board User Interface 0 ee 2 a ea A so so ee che hee Bee Cae hee OO eee eee ee ee he Bae eee a es Bie DemMHONS ess eee tek eee ara me ee amp be es a da oS a ee a 9 Pin DOSHOR GOS ooo ek Sec dk a a a a ee we ee ew ae Ee Oct rs 66 gow 2 8S ee ee ee E GIG le RR yt Be Pe i E s s a de 4 ee ee ee ee AOR ES ee a EE a me ew eee Bee eS 10 Processor Usage Meter lt o 10 1 ss o AA sh wh st abbr a EE a ee a a aaa UA GTN sia Be eR A ee ee de ee Gk ee da Beem id es a a Gs ES a E ii AR TkT E RO 12 DETIMDICAOS s na a Gi a a es ee be ede le we Blase a wt ee ee ee a ee BB 12 Sine FUNCION ocaso a he PERS a a ee ee 12 1 a A T22 DeiNNONS os
43. Stellaris family of products provides 32 bit performance for the same price as current 8 and 16 bit microcontroller designs With entry level pricing at 1 00 for an ARM technology based MCU Luminary Micro s Stellaris product line allows for standardization that elim inates future architectural upgrades or software tool changes Luminary Micro Inc 108 Wild Basin Suite 350 Austin TX 78746 Main 1 512 279 8800 Fax 1 512 279 8879 http www luminarymicro com sales luminarymicro com Support Information For support on Luminary Micro products contact support luminarymicro com 1 512 279 8800 ext 3 148 February 19 2008
44. T_PIN Description The GPIO pin on which the fault LED resides PIN_LEDFAULT_PORT Definition define PIN_LEDFAULT_PORT Description The GPIO port on which the fault LED resides PIN_LEDRUN PIN Definition define PIN_LEDRUN_PIN Description The GPIO pin on which the run LED resides February 19 2008 69 Pin Definitions 9 2 1 31 9 2 1 32 9 2 1 33 9 2 1 34 9 2 1 35 9 2 1 36 70 PIN_LEDRUN_PORT Definition define PIN_LEDRUN_PORT Description The GPIO port on which the run LED resides PIN_LEDSTATUSO_PIN Definition define PIN_LEDSTATUSO_PIN Description The GPIO pin on which the Ethernet status zero LED resides PIN_LEDSTATUSO_PORT Definition define PIN_LEDSTATUSO_PORT Description The GPIO port on which the Ethernet status zero LED resides PIN_LEDSTATUS1_PIN Definition define PIN_LEDSTATUS1_PIN Description The GPIO pin on which the Ethernet status one LED resides PIN_LEDSTATUS1_PORT Definition define PIN_LEDSTATUS1_PORT Description The GPIO port on which the Ethernet status one LED resides PIN_PHASEA_HIGH_PIN Definition define PIN_PHASEA_HIGH_PIN Description The GPIO pin on which the phase A high side pin resides February 19 2008 9 2 1 37 9 2 1 38 9 2 1 39 9 2 1 40 9 2 1 41 9 2 1 42 Stellaris Brushless DC Motor RDK Software Reference Manual PIN_PHASEA_HIGH_PORT Definition define PIN_P
45. This function computes the sine for the given input angle The angle is specified in 0 32 fixed point format and is therefore always between 0 and 360 degrees inclusive The g_pusFixed SineTable array is used for the sine values angles that lie between entries of the array are rounded to the closest entry of the array February 19 2008 93 Sine Function Since the g_pusFixedSineTable array covers one quarter of the circle the upper two bits of the input angle determine which quadrant of the circle the angle lies in The next seven bits determine the index into the sine array Returns Returns the sine of the angle in 16 16 fixed point format 12 2 2 Variable Documentation 12 22 21 g_pusFixedSineTable static Definition static const unsigned short g_pusFixedSineTable Description A table of the value of the sine function for the first ninety degrees with 128 entries that is 0 0 degrees 127 90 degrees Each entry is in 0 16 fixed point notation 94 February 19 2008 13 13 1 13 2 13 2 1 13 2 1 1 Stellaris Brushless DC Motor RDK Software Reference Manual Sine Wave Modulation O aaa pena EA 95 DOMO sssri cosacend ii da a Dees ands e is 95 Introduction The code for producing sine wave modulated waveforms is contained in sinemod c with sinemod h containing the definition for the function exported to the remainder of the application Definitions Functions void SineModulate unsigned l
46. WM cycles when starting the motor drive Returns None PWMOutputTrapezoid Enable Disable PWM outputs as needed for Trapezoid modulation Prototype void PWMOutputTrapezoid unsigned long ulEnable Parameters ulEnable is the bit mapped value representing which phase s of the motor drive should be active Description This function turns off non selected outputs and turns on selected outputs If slow decay mode is enabled the high side is driven in complementary mode Returns None PWMReducePeriodCount Reduces the count of PWM interrupts Prototype void PWMReducePeriodCount unsigned long ulCount Parameters ulCount is the number by which to reduce the PWM interrupt count Description This function reduces the PWM interrupt count by a given number When the waveform values are updated the interrupt count can be reduced by the appropriate amount to maintain a proper indication of when the next waveform update should occur If the PWM interrupt count is not reduced when the waveforms are recomputed the waveform update software interrupt will not be triggered as desired Returns None February 19 2008 Stellaris Brushless DC Motor RDK Software Reference Manual 11 2 2 9 PWMSetDeadBand Configures the dead timers for the PWM generators Prototype void PWMSetDeadBand void Description This function configures the dead timers for all three PWM generators based on the dead time paramete
47. along with precautions such as limiting the deceleration rate to control the DC bus voltage are handled by this function Returns None MainStartupHandler static Handles the startup mode of the motor drive Prototype static void MainStartupHandler void Description This function performs the processing and state transitions associated with the startup mode of the motor drive for sensorless operation Returns None MainStop Stops the motor drive Prototype void MainStop void Description This function stops the motor drive If the motor is currently running it will begin the process of stopping the motor Returns None February 19 2008 Stellaris Brushless DC Motor RDK Software Reference Manual 7 2 2 20 MainUpdateFAdjl 7 2 2 21 1 2 3 7 2 3 1 Updates the coefficient of the speed PI controller Prototype void MainUpdateFAdjI long 1NewFAdjI Parameters INewFAdjI is the new value of the coefficient Description This function updates the value of the coefficient of the duty cycle PI controller In addition to updating the coefficient it recomputes the maximum value of the integrator and the current value of the integrator in terms of the new coefficient eliminating any instantaneous jump in the output of the PI controller Returns None MainWaveformTick Handles the waveform update software interrupt Prototype void MainWaveformTick void Description
48. as a staging area before the value gets placed into the flags in the parameter block by UIPWMFrequencySet 16 2 4 18 g_ucModulation static Definition static unsigned char g_ucModulation 128 February 19 2008 Stellaris Brushless DC Motor RDK Software Reference Manual Description The specification of the modulation waveform type for the motor drive This variable is used by the serial interface as a staging area before the value gets placed into the flags in the parameter block by UlModulationType 16 2 4 19 g_ucSensor static Definition static unsigned char g_ucSensor Description The specification of the sensor presence on the motor This variable is used by the serial interface as a staging area before the value gets placed into the flags in the parameter block by UlSensorPresent 16 2 4 20 g_ucSensorPolarity static Definition static unsigned char g_ucSensorPolarity Description The specification of the polarity of sensor on the motor This variable is used by the serial interface as a staging area before the value gets placed into the flags in the parameter block by UlSensorPolarity 16 2 4 21 g_ucSensorType static Definition static unsigned char g_ucSensorType Description The specification of the type of sensor presence on the motor This variable is used by the serial interface as a staging area before the value gets placed into the flags in the parameter block by UlSensorType 16 2 4 22
49. ask to be used 136 February 19 2008 17 2 1 4 14215 17 2 1 6 17 2 1 7 17 2 1 8 Stellaris Brushless DC Motor RDK Software Reference Manual DHCP_EXPIRE_TIMER_SECS Definition define DHCP_EXPIRE_TIMER_SECS Description The timeout for DHCP address request in seconds Ul_PROTO_PORT Definition define UI_PROTO_PORT Description The port to use for TCP connections for the Motor Drive UI protocol Ul_QUERY_PORT Definition define UI_QUERY_PORT Description The port to use for UDP connections for the Motor Drive UI protocol This port is used for query purposes only UIETHERNET_MAX_RECV Definition define UIETHERNET_MAX RECV Description The size of the UART receive buffer This should be appropriately sized such that the maximum size command packet can be contained in this buffer This value should be a power of two in order to make the modulo arithmetic be fast that is an AND instead of a divide UIETHERNET MAX_XMIT Definition define UIETHERNET_MAX XMIT Description The size of the UART transmit buffer This should be appropriately sized such that the maxi mum burst of output data can be contained in this buffer This value should be a power of two in order to make the modulo arithmetic be fast that is an AND instead of a divide February 19 2008 137 Ethernet Interface 17 2 2 17 2 2 1 17 2 2 2 17 2 2 3 138 F
50. bers for the application are 48 KB of flash and 19 KB of SRAM Of this 36 KB of flash and 16 KB of SRAM is consumed by the user interface which is much more complicated than what would typically be used in a final motor drive application unless the final application is a generic motor drive such as the RDK This leaves 12 KB of flash and 3 KB of SRAM for the actual motor drive application parts of which are also more complicated than required due to the run time reconfigurability February 19 2008 5 Introduction 1 3 1 4 Processor Usage The two factors that have the largest impact on the processor usage are the PWM frequency and the PWM update rate The following table provides some data points for a few combinations of these two factors the actual processor usage may vary slightly especially when other parameters are changed this should be viewed only as indicative information These numbers were measured while running a single pole pair motor at 5000 RPM PWM Frequency 16 KHz 20 KHz 35 2 Update 2 35 40 50 9 5 43 An update rate of 1 means that the waveform update frequency matches the PWM frequency From the table above a PWM frequency of 20 KHz with a waveform update frequency of 20 KHz consumes around 67 of the processor An update rate of 5 on the other hand is a waveform update frequency of 1 5 the PWM frequency a PWM frequency of 20 KHz with a waveform update rate of 4 KHz consumes around 51
51. ce in use 2 2 3 4 g_pusLinearHallMax static Definition static unsigned short g_pusLinearHallMax 3 Description The Linear Hall Sensor ADC Maximum Value 2 2 3 5 g_pusLinearHallMin static Definition static unsigned short g_pusLinearHallMin 3 Description The Linear Hall Sensor ADC Minimum Value 2 2 3 6 g_pusLinearHallSensor static Definition static unsigned short g_pusLinearHallSensor 3 Description The Linear Hall Sensor ADC values scaled 2 2 3 7 g_pusPhaseMax static Definition static unsigned short g_pusPhaseMax 3 Description An array containing the maximum phase currents seen during the last half cycle of each phase This is used to perform a peak detect on the phase currents 2 2 3 8 g_sMotorCurrent Definition short g_sMotorCurrent Description The total current passing through the motor specified in milliamperes as a signed value 16 February 19 2008 2 2 3 9 2 2 3 10 2 2 3 11 2 2 3 12 2 2 3 13 2 2 3 14 Stellaris Brushless DC Motor RDK Software Reference Manual g_ucAmbientTemp Definition unsigned char g_ucAmbientTemp Description The ambient case temperature of the microcontroller specified in degrees Celsius g_ucBEMFState static Definition static unsigned char g_ucBEMFState Description The state of the Back EMF processing state machine g_ucPhaseCurrentIndex static Definition static unsigned char g_ucPhaseCurrent Index Des
52. cription The index for the phase current being processed in the ADC sequence handler g_ulADCFlags static Definition static unsigned long g_ulADCFlags Description A set of flags that provide status and control of the ADC Control module g_ulBEMFEdgePrevious static Definition static unsigned long g_ulBEMFEdgePrevious Description The time at which the last Back EMF edge occurred g_ulBEMFHallValue Definition unsigned long g_ulBEMFHallValue Description The Hall state value as determined by the Back EMF processing code February 19 2008 17 ADC Control 2 2 3 15 2 2 3 16 2 2 3 17 2 2 3 18 2 2 3 19 2 2 3 20 18 g_ulBEMFNextHall static Definition static unsigned long g_ulBEMFNextHall Description The next Back EMF Hall state value g_ulBEMFRotorSpeed Definition unsigned long g_ulBEMFRotorSpeed Description The rotor speed as measured by the BEMF processing code g_ulBEMFSpeedPrevious static Definition static unsigned long g_ulBEMFSpeedPrevious Description The time at which the last Back EMF speed edge occurred g_ulBusVoltage Definition unsigned long g_ulBusVoltage Description The DC bus voltage specified in millivolts g_ulLinearHallValue Definition unsigned long g_ulLinearHallValue Description The Hall state value as determined by the linear Hall sensor processing code g_ulLinearLastHall static Definition sta
53. cted into the usFlags member of g_sParameters Returns None 16 2 3 24 UlSensorType static Updates the sensor type bit of the motor drive Prototype static void UlSensorType void Description This function is called when the variable controlling the type of sensor is updated The value is then reflected into the usFlags member of g_sParameters Returns None 16 2 3 25 UlStop Stops the motor drive Prototype void UIStop void Description This function is called by the serial user interface when the stop command is received The motor drive will be stopped as a result this is a no operation if the motor drive is already stopped Returns None 16 2 3 26 UlUpdateRate static Sets the update rate of the motor drive Prototype static void UlUpdateRate void Description This function is called when the variable specifying the update rate of the motor drive is up dated This allows the motor drive to perform a synchronous change of the update rate to avoid discontinuities in the output waveform 124 February 19 2008 Stellaris Brushless DC Motor RDK Software Reference Manual Returns None 16 2 3 27 UlUpgrade 16 2 4 16 2 4 1 16 2 4 2 16 2 4 3 Starts a firmware upgrade Prototype void UlUpgrade void Description This function is called by the serial user interface when a firmware upgrade has been re quested This will branch directly to the boot loader and relinquis
54. curs when the voltage level of the DC bus drops too low Typi cally this is the result of the loss of mains power DC bus over voltage This occurs when the voltage level of the DC bus rises too high When the motor is being decelerated it becomes a generator increasing the voltage level of the DC bus If the level of regeneration is more than can be controlled the DC bus will rise to a dangerous level and could damage components on the board Motor under current This occurs when the current through the motor drops too low Typically this is the result of an open connection to the motor Motor over current This occurs when the current through the motor rises too high When the motor is being accelerated more current flows through the windings than when running at a set speed If accelerated too quickly the current through the motor may rise above the current rating of the motor or of the motor drive possibly damaging either Ambient over temperature This occurs when the case temperature of the microcontrollers rises too high The motor drive generates lots of heat if in an enclosure with inadequate ventilation the heat could rise high enough to exceed the operating range of the motor drive components and or cause physical damage to the board Note that the temperature measure ment that is of more interest is directly on the heat sink where the smart power module is attached though this would require an external thermocouple in
55. d of the motor drive specified in RPM ulMaxSpeed The maximum speed of the motor drive specified in RPM ulMinVBus The minimum bus voltage during operation specified in millivolts ulMaxVBus The maximum bus voltage during operation specified in millivolts ulBrakeOnV The bus voltage at which the braking circuit is engaged specified in millivolts ulBrakeOffV The bus voltage at which the braking circuit is disengaged specified in millivolts ulDecelV The DC bus voltage at which the deceleration rate is reduced specified in millivolts IFAdjP The P coefficient of the frequency adjust PID controller IFAdjl The coefficient of the frequency adjust PID controller IFAdjD The D coefficient of the frequency adjust PID controller ulBrakeMax The amount of time assuming continuous application that the dynamic braking can be utilized specified in milliseconds ulBrakeCool The amount of accumulated time that the dynamic brake can have before the cooling period will end specified in milliseconds February 19 2008 111 User Interface 16 2 2 16 2 2 1 16 2 2 2 16 2 2 3 16 2 2 4 112 sAccelCurrent The motor current at which the acceleration rate is reduced specified in milli amperes ucPad3 Padding to ensure consistent parameter block alignment ulConnectionTimeout The Ethernet Connection Timeout specified in seconds ucStartupDutyCycle The forced duty cycle percentage for startup in sensorless mode ucPad4 Padding to
56. e Prototype void MainSetPWMFrequency void Description This function changes the period of the PWM signals produced by the motor drive It is simply a wrapper function around the PWMSetFrequency function the PWM frequency based timing parameters of the motor drive are adjusted as part of the PWM frequency update Returns None MainSetSpeed Changes the target speed of the motor drive Prototype void MainSet Speed void Description This function changes the target speed of the motor drive If required the state machine will be transitioned to a new state in order to move the motor drive to the target speed Returns None MainSpeedController Adjusts the motor drive duty cycle based on the rotor speed Prototype unsigned long MainSpeedController void Description This function uses a Pl controller to adjust the motor drive duty cycle in order to get the rotor speed to match the target speed Returns Returns the new motor drive duty cycle February 19 2008 49 Main Application 7 2 2 17 7 2 2 18 7 2 2 19 50 MainSpeedHandler static Adjusts the motor drive speed based on the target speed Prototype static void MainSpeedHandler unsigned long ulTarget Parameters ulTarget is the target speed of the motor drive specified as RPM Description This function adjusts the motor drive speed towards a given target speed Limitations such as acceleration and deceleration rate
57. e UlEthernetPoll static lwIP TCP IP Polling Timeout function Prototype static err_t UIEthernetPoll void xarg struct tcp_pcb xpcb Parameters arg is not used in this implementation pcb is not used in this implementation Description This function is called when the lwIP TCP IP stack has no incoming or outgoing data It can be used to reset an idle connection Returns This function will return an IwIP defined error code February 19 2008 Stellaris Brushless DC Motor RDK Software Reference Manual 17 2 2 9 UlEthernetRangeCheck static Performs range checking on the value of a parameter Prototype static void UlEthernetRangeCheck unsigned long ulldx Parameters ulldx is the index of the parameter to check Description This function will perform range checking on the value of a parameter adjusting the parameter value if necessary to make it reside within the predetermined range Returns None 17 2 2 10 UlEthernetReceive static Receive a TCP packet from IwlP for motor control processing Prototype static err_t UlEthernetReceive void xarg struct tcp_pcb pcb struct pbuf xp err_t err Parameters arg is not used in this implementation peb is the pointer to the TCP control structure p is the pointer to the PBUF structure containing the packet data err is used to indicate if any errors are associated with the incoming packet Description This function is cal
58. e static Definition static unsigned char g_ucDecayMode Description A boolean that is true when slow decay mode should be utilized This variable is used by the serial interface as a staging area before the value gets placed into the flags in the parameter block by UlIDecayMode February 19 2008 127 User Interface 16 2 4 14 g_ucDirection static Definition static unsigned char g_ucDirection Description The specification of the motor drive direction This variable is used by the serial interface as a staging area before the value gets placed into the flags in the parameter block by UlDirection Set 16 2 4 15 g_ucDynamicBrake static Definition static unsigned char g_ucDynamicBrake Description A boolean that is true when dynamic braking should be utilized This variable is used by the serial interface as a staging area before the value gets placed into the flags in the parameter block by UlDynamicBrake 16 2 4 16 g_ucEncoder static Definition static unsigned char g_ucEncoder Description The specification of the encoder presence on the motor This variable is used by the serial interface as a staging area before the value gets placed into the flags in the parameter block by UlEncoderPresent 16 2 4 17 g_ucFrequency static Definition static unsigned char g_ucFrequency Description The specification of the PWM frequency for the motor drive This variable is used by the serial interface
59. e constructed the packet will be sent out Returns None 142 February 19 2008 Stellaris Brushless DC Motor RDK Software Reference Manual 17 2 2 14 UlEthernetSent static Callback for Ethernet transmit Prototype static err _t UlEthernetSent void arg struct tcp_pcb xpcb ul6_t len Parameters arg is not used in this implementation pcb is not used in this implementation len is not used in this implementation Description This function is called when the IwIP TCP IP stack has received an acknowledgement for data that has been transmitted Returns This function will return an IwIP defined error code 17 2 2 15 UlEthernetTick Run the periodic IwIP tasks Prototype void UIEthernetTick unsigned long ulTickMS Description Application runtime code that should be called periodically to run the various TCP IP stack timers g_ulEthernetTickPeriod must be properly set during initialization so that the var ious TCP IP timers will be updated properly Returns None 17 2 2 16 UlEthernetTransmit static Transmits a packet to the Ethernet controller Prototype static tBoolean UlEthernetTransmit unsigned char pucBuffer Parameters pucBuffer is a pointer to the packet to be transmitted February 19 2008 143 Ethernet Interface 17 2 3 17 2 3 1 17 2 3 2 17 2 3 3 17 2 3 4 144 Description This function will send a packet via TCP Ethernet It will compute the ch
60. e too high 4 2 1 6 FAULT_VBUS_HIGH Definition define FAULT_VBUS_HIGH Description The fault flag that indicates that the DC bus voltage rose too high 4 2 1 7 FAULT_VBUS_LOW Definition define FAULT_VBUS_LOW Description The fault flag that indicates that the DC bus voltage dropped too low February 19 2008 27 Faults 28 February 19 2008 5 5 1 Stellaris Brushless DC Motor RDK Software Reference Manual Flash Parameter Block A E EIES EAE I E E S A EES I A EET E S E TEET E E 29 DEDOS errar LA E AAA O AA ARAS 30 Introduction This module provides a fault tolerant persistent storage mechanism for the parameter block of the motor drive The last several pages of flash are used for the storage more than one page is required in order to be fault tolerant Parameter blocks are an array of bytes that contain the persistent parameters of the motor drive The only special requirement for the parameter block is that the first byte is a sequence number explained later and the second byte is a checksum used to validate the correctness of the data the checksum byte is the byte such that the sum of all bytes in the parameter block is zero The portion of flash for parameter block storage is split into N equal sized regions where each region is the size of a parameter block Each region is scanned at startup the region that has a valid checksum and has the highest sequence number with special consideration given
61. ecksum of the packet based on the length in the second byte and place it at the end of the packet before sending the packet Returns Returns true if the entire packet was transmitted and false if not Variable Documentation g_bEnableRealTimeData static Definition static tBoolean g_bEnableRealTimeData Description A boolean that is true when the real time data stream is enabled g_bSendRealTimeData static Definition static tBoolean g_bSendRealTimeData Description Flag to indicate that a Real Time Data update is ready for transmission g_EMAC_if static Definition static struct netif g_EMAC_if Description The Network Interface Structure g_psTelnetPCB static Definition static struct tcp_pcb g_psTelnetPCB Description Pointer to the telnet session PCB data structure February 19 2008 17 2 3 5 17 2 3 6 11238 7 17 2 3 8 17 2 3 9 Stellaris Brushless DC Motor RDK Software Reference Manual g_pucUlEthernetData static Definition static unsigned char g_pucUlEthernetData UIETHERNET_MAX_XMIT Description A buffer used to construct real time data packets before they are written to the UART and or g_pucUlEthernetTransmit g_pucUlEthernetReceive static Definition static unsigned char g_pucUlEthernetReceive UIETHERNET_MAX_RECV Description A buffer to contain data received from the UART A packet is processed out of this buffer
62. ed to validate a status packet and allow the user interface to synchronize with the status stream being sent by the target For command responses tag Oxfe the first data byte is the command that is being responded to The remaining bytes are the response and are dependent upon the command For real time data messages tag Oxfd each real time data item is transmitted as a little endian value for example for a 16 bit value the lower 8 bits first then the upper 8 bits The data items are in the same order as returned by the data item list CMD_GET_DATA_ITEMS regardless of the order that they were enabled For example if data items 1 5 and 17 were enabled and each was two bytes in length there would be 6 data bytes in the packet Oxfd 0x09 d1 0 7 d1 8 15 d5 0 7 d5 8 15 d17 0 7 d17 8 15 checksum Parameter Interpretation The size and units of the parameters are dependent upon the motor drive the units are not con veyed in the serial protocol Each parameter value is transmitted in little endian format Not all parameters are necessarily supported by a motor drive only those that are appropriate Interface To The Application The ethernet protocol handler takes care of all the ethernet communications and command inter pretation A set of functions provided by the application and an array of structures that describe the February 19 2008 Stellaris Brushless DC Motor RDK Software Reference Manual
63. efine PIN_VBEMFA Description The ADC channel on which the DC Back EMF Phase A voltage sense resides PIN_VBEMFB Definition define PIN_VBEMFB Description The ADC channel on which the DC Back EMF Phase B voltage sense resides PIN_VBEMFC Definition define PIN_VBEMEC Description The ADC channel on which the DC Back EMF Phase C voltage sense resides PIN_VSENSE Definition define PIN_VSENSE Description The ADC channel on which the DC bus voltage sense resides PWM_PHASEA_HIGH Definition define PWM_PHASEA_ HIGH Description The PWM channel on which the phase A high side resides February 19 2008 9 2 1 61 9 2 1 62 9 2 1 63 9 2 1 64 9 2 1 65 Stellaris Brushless DC Motor RDK Software Reference Manual PWM_PHASEA_LOW Definition define PWM_PHASEA LOW Description The PWM channel on which the phase A low side resides PWM_PHASEB_HIGH Definition define PWM_PHASEB HIGH Description The PWM channel on which the phase B high side resides PWM_PHASEB_LOW Definition define PWM_PHASEB LOW Description The PWM channel on which the phase B low side resides PWM_PHASEC_HIGH Definition define PWM_PHASEC_HIGH Description The PWM channel on which the phase C high side resides PWM_PHASEC_LOW Definition define PWM_PHASEC_LOW Description The PWM channel on which the phase C low side resides February 19 2008
64. eginning of the flash used for storing parameter blocks this must be the start of an erase block in the flash g_ulFlashPBSize static Definition static unsigned long g_ulFlashPBSize Description The size of the parameter block when stored in flash this must be a power of two less than or equal to 1024 February 19 2008 6 6 1 6 2 Stellaris Brushless DC Motor RDK Software Reference Manual Hall Sensor Control A 33 DEMONS lic ii da a ad a A 33 Introduction Brushless DC motors may be configured with Hall sensors These sensors are used to determine motor speed and position In this module the Hall sensor input edges are monitored to determine the current Hall state value position and to determine motor speed The Hall sensors inputs should be connected to GPIO inputs on the BLDC RDK input connected Hall A B and C These inputs are configured as GPIO inputs and configured to generate inter rupts on both rising and falling edges The Hall state value is stored at each interrupt The time between the interrupt edges is measured to determine the speed of the motor The code for calculating the motor speed and updating the Hall state value is contained in hal1_ ctrl c with hall_ctr1 h containing the definitions for the variable and functions exported to the remainder of the application Note If the Hall sensors are configured as Linear Hall sensors refer to the code in adc_ctrl c for details about t
65. en held for a period of time The potentiometer specifies the value of a parameter The push button is debounced using a vertical counter A vertical counter is a method where each bit of the counter is stored in a different word and multiple counters can be incremented simultaneously They work really well for debouncing switches up to 32 switches can be debounced at the same time Although only one switch is used the code is already capable of debouncing an additional 31 switches A callback function can be called when the switch is pressed when it is released and when it is held If held the press function will not be called for that button press The potentiometer input is passed through a low pass filter and then a stable value detector The low pass filter reduces the noise introduced by the potentiometer and the ADC Even the low pass filter does not remove all the noise and does not produce an unchanging value when the potentiometer is not being turned Therefore a stable value detector is used to find when the potentiometer value is only changing slightly When this occurs the output value is held constant until the potentiometer value has changed significantly Because of this the parameter value that is adjusted by the potentiometer will not jitter around when the potentiometer is left alone The application is responsible for reading the value of the switch es and the potentiometer on a periodic basis The routines provided here
66. ensure consistent parameter block alignment ulStartupCount The number of counts commutations for startup in Sensorless mode sTargetCurrent The motor current limit for motor operation ucPad5 Padding to ensure consistent parameter block alignment Description This structure contains the Brushless DC motor parameters that are saved to flash A copy exists in RAM for use during the execution of the application which is loaded form flash at startup The modified parameter block can also be written back to flash for use on the next power cycle Note All parameters exist in the version zero parameter block unless it is explicitly stated otherwise If an older parameter block is loaded from flash the new parameters will get filled in with default values When the parameter block is written to flash it will always be written with the latest parameter block version Define Documentation FLAG_BRAKE_BIT The bit number of the flag in the usFlags member of tDriveParameters that defines the application of dynamic brake to handle regeneration onto DC bus This field will be one of FLAG_BRAKE_ON or FLAG_BRAKE_OFF FLAG_BRAKE_OFF The value of the FLAG_BRAKE_BIT flag that indicates that the dynamic brake is disabled FLAG_BRAKE_ON The value of the FLAG_BRAKE_BIT flag that indicates that the dynamic brake is enabled FLAG_DC_BRAKE_BIT The bit number of the flag in the usFlags member of tDriveParameters that defines the application of the
67. er Interface 16 2 2 13 FLAG_DRIVE_BIT The bit number of the flag in the usFlags member of tDriveParameters that defines the type of drive waveform for the motor drive This field will be one of FLAG_DRIVE_SINE or FLAG_DRIVE_ TRAPEZOID 16 2 2 14 FLAG_DRIVE_SINE The value of the FLAG_DRIVE_BIT flag that indicates that the motor is to be driven with sine wave modulation 16 2 2 15 FLAG_DRIVE_TRAPEZOID The value of the FLAG_DRIVE_BIT flag that indicates that the motor is to be driven with trapezoid modulation 16 2 2 16 FLAG_ENCODER_ABSENT The value of the FLAG_ENCODER BIT flag that indicates that the encoder is absent 16 2 2 17 FLAG_ENCODER_BIT The bit number of the flag in the usFlags member of tDriveParameters that defines the presence of an encoder for speed feedback This field will be one of FLAG_ENCODER_ABSENT or FLAG_ ENCODER_PRESENT 16 2 2 18 FLAG_ENCODER_PRESENT The value of the FLAG_ENCODER BIT flag that indicates that the encoder is present 16 2 2 19 FLAG_PWM_FREQUENCY_12K The value of the FLAG_PWM_FREQUENCY_MASK bit field that indicates that the PWM frequency is 12 5 KHz 16 2 2 20 FLAG_PWM_FREQUENCY_16K The value of the FLAG_PWM_FREQUENCY_MASK bit field that indicates that the PWM frequency is 16 KHz 114 February 19 2008 Stellaris Brushless DC Motor RDK Software Reference Manual 16 2 2 21 FLAG_PWM_FREQUENCY_ 20K The value of the FLAG_PWM_FREQUENCY_MASK bit field that indicates that the PWM f
68. erface modules on board and serial preparing them to operate and control the motor drive 120 February 19 2008 Stellaris Brushless DC Motor RDK Software Reference Manual Returns None 16 2 3 15 static void UILEDBlink unsigned long ul dx unsigned short usRate unsigned short usPeriod static Sets the blink rate for an LED Parameters ulldx is the number of the LED to configure usRate is the rate to blink the LED usPeriod is the amount of time to turn on the LED Description This function sets the rate at which an LED should be blinked A blink period of zero means that the LED should be turned off and a blink period equal to the blink rate means that the LED should be turned on Otherwise the blink rate determines the number of user interface interrupts during the blink cycle of the LED and the blink period is the number of those user interface interrupts during which the LED is turned on Returns None 16 2 3 16 UlModulationType static Updates the modulation waveform type bit in the motor drive Prototype static void UIModulationType void Description This function is called when the variable controlling the modulation waveform type is updated The value is then reflected into the usFlags member of g_sParameters Returns None 16 2 3 17 UlParamLoad Loads the motor drive parameter block from flash Prototype void UIParamLoad void Description This function is called by the serial u
69. esides PIN_PHASEC_LOW_PORT Definition define PIN_PHASEC_LOW_PORT Description The GPIO port on which the phase C low side pin resides PIN_SWITCH_PIN Definition define PIN_SWITCH_PIN Description The GPIO pin on which the user push button resides February 19 2008 9 2 1 49 9 2 1 50 9 2 1 51 9 2 1 52 9 2 1 53 9 2 1 54 Stellaris Brushless DC Motor RDK Software Reference Manual PIN_SWITCH_PIN_BIT Definition define PIN_SWITCH_PIN_BIT Description The bit lane of the GPIO pin on which the user push button resides PIN_SWITCH_PORT Definition define PIN_SWITCH_PORT Description The GPIO port on which the user push button resides PIN_UARTORX_PIN Definition define PIN_UARTORX_PIN Description The GPIO pin on which the UARTO Rx pin resides PIN_UARTORX_PORT Definition define PIN_UARTORX_PORT Description The GPIO port on which the UARTO Rx pin resides PIN_UARTOTX_PIN Definition define PIN_UARTOTX_PIN Description The GPIO pin on which the UARTO Tx pin resides PIN_UARTOTX_PORT Definition define PIN_UARTOTX_PORT Description The GPIO port on which the UARTO Tx pin resides February 19 2008 73 Pin Definitions 9 2 1 55 9 2 1 56 9 2 1 57 9 2 1 58 9 2 1 59 9 2 1 60 74 PIN_VANALOG Definition define PIN_VANALOG Description The ADC channel on which the Analog Input voltage sense resides PIN_VBEMFA Definition d
70. eter block or NULL if there are no valid param eter blocks in flash FlashPBInit Initializes the flash parameter block Prototype void FlashPBInit unsigned long ulStart unsigned long ulEnd unsigned long ulSize Parameters ulStart is the address of the flash memory to be used for storing flash parameter blocks this must be the start of an erase block in the flash February 19 2008 5 2 1 3 5 2 1 4 Stellaris Brushless DC Motor RDK Software Reference Manual ulEnd is the address of the end of flash memory to be used for storing flash parameter blocks this must be the start of an erase block in the flash the first block that is NOT part of the flash memory to be used or the address of the first word after the flash array if the last block of flash is to be used ulSize is the size of the parameter block when stored in flash this must be a power of two less than or equal to 1024 Description This function initializes the flash parameter block functions lt will scan the portion of flash used for storing parameter blocks to find the most recent valid parameter block This function must be called before any other flash parameter block functions are called Returns None FlashPBlsValid static Determines if the parameter block at the given address is valid Prototype static unsigned long FlashPBIsValid unsigned char pucOffset Parameters pucOffset is the address of the parameter bl
71. f the bus voltage is above the trigger level STATE_BRAKE_OFF Definition define STATE BRAKE OFF Description The dynamic brake is turned off The bus voltage going above the trigger level will cause a transition to the STATE BRAKE_ON state STATE_BRAKE_ON Definition define STATE BRAKE ON Description The dynamic brake is turned on The bus voltage going below the trigger level will cause a transition to the STATE_BRAKE_OFF state and the brake being on for too long will cause a transition to STATE_BRAKE_COOL Function Documentation Brakelnit Initializes the dynamic braking control routines Prototype void BrakeInit void Description This function initializes the ADC module and the control routines preparing them to monitor currents and voltages on the motor drive Returns None February 19 2008 3 2 2 2 3 2 3 3 2 3 1 3 2 3 2 Stellaris Brushless DC Motor RDK Software Reference Manual BrakeTick Updates the dynamic brake Prototype void BrakeTick void Description This function will update the state of the dynamic brake It must be called at the PWM frequency to provide a time base for determining when to turn off the brake to avoid overheating Returns None Variable Documentation g_ulBrakeCount static Definition static unsigned long g_ulBrakeCount Description The number of milliseconds that the dynamic brake has been on For each brake upda
72. g ucUpdateRate static Definition static unsigned char g_ucUpdateRate Description The specification of the update rate for the motor drive This variable is used by the serial inter face as a staging area before the value gets updated in a synchronous manner by UlUpdate Rate February 19 2008 129 User Interface 16 2 4 23 g_ulBlinkCount static Definition static unsigned long g_ulBlinkCount Description The count of count of user interface interrupts that have occurred This is used to determine when to toggle the LEDs that are blinking 16 2 4 24 g_ulDebugInfo Definition unsigned long g_ulDebugInfo Description Debug Information 16 2 4 25 g_ulGPIOData Definition unsigned long g_ulGPIOData Description A 32 bit unsigned value that represents the value of various GPIO signals on the board Bit 0 corresponds to CFGO Bit 1 corresponds to CFG1 Bit 2 correpsonds to CFG2 Bit 8 corre sponds to the Encoder A input Bit 8 corresponds to the Encode B input Bit 10 corresponds to the Encoder Index input 16 2 4 26 g_ulTargetSpeed Definition unsigned long g_ulTargetSpeed Description The target drive frequency 16 2 4 27 g_ulUlINumButtons Definition const unsigned long g_ulUINumButtons Description The number of switches on this target This value is used by the on board user interface module 130 February 19 2008 Stellaris Brushless DC Motor RDK Software Reference Manual 16 2 4 28
73. g_ulUlNumParameters Definition const unsigned long g_ulUINumParameters Description The number of motor drive parameters This is used by the user interface module 16 2 4 29 g_ulUlNumRealTimeData Definition const unsigned long g_ulUINumRealTimeData Description The number of motor drive real time data items This is used by the serial user interface module 16 2 4 30 g_ulUlTargetType Definition const unsigned long g_ulUITargetType Description The target type for this drive This is used by the user interface module 16 2 4 31 g_ulUlTickCount static Definition static unsigned long g_ulUITickCount Description The running count of system clock ticks 16 2 4 32 g_ulUlUseOnboard static Definition static unsigned long g_ulUIUseOnboard Description A boolean that is true when the on board user interface should be active and false when it should not be February 19 2008 131 User Interface 16 2 4 33 g_usFirmwareVersion Definition const unsigned short g_usFirmwareVersion Description The version of the firmware Changing this value will make it much more difficult for Luminary Micro support personnel to determine the firmware in use when trying to provide assistance it should only be changed after careful consideration 132 February 19 2008 Stellaris Brushless DC Motor RDK Software Reference Manual 17 Ethernet Interface IN 133 DAMMNONS 200 20 ii AAA AAA A 135 17 1 Introduction
74. gned long g_ulState static unsigned long g_ulStateCount 7 2 1 Define Documentation 7 2 1 1 CRYSTAL_CLOCK Definition define CRYSTAL CLOCK Description The frequency of the crystal attached to the microcontroller This must match the crystal value passed to SysCtlClockSet in main February 19 2008 39 Main Application 7 2 1 2 7 2 1 3 7 2 1 4 7 2 1 5 7 2 1 6 40 FLASH_PB_END Definition define FLASH_PB_END Description The address of the last block of flash to be used for storing parameters Since the end of flash is used for parameters this is actually the first address past the end of flash FLASH_PB_SIZE Definition define FLASH_PB_SIZE Description The size of the parameter block to save This must be a power of 2 and should be large enough to contain the tDriveParameters structure see the ui h file FLASH_PB_START Definition define FLASH_PB_START Description The address of the first block of flash to be used for storing parameters STATE_BACK_PRECHARGE Definition define STATE_BACK_PRECHARGE Description The motor drive is precharging the bootstrap capacitors on the high side gate drivers while running in the backward direction Once the capacitors are charged the state machine will automatically transition to STATE_BACK_RUN STATE_BACK_REV Definition define STATE_BACK_REV Description The motor drive is decelerating down to a stop
75. gnetic field in the stator of the motor inducing a magnetic field in the rotor and causing it to spin This mode is used to drive the motor The final mode is DC injection braking where the first PWM pair are actively toggling the low side of the second PWM pair is always on and the third PWM pair is inactive This results in a fixed DC voltage being applied across the motor resulting in braking This mode is optionally used briefly when going from a driving state to a non driving state in order to completely stop the rotation of the rotor For loads with high inertia or low friction rotors this can reduce the rotor stop time from minutes to seconds This mode should only be used for as long as required to stop the rotor and no longer The PWM outputs are configured to immediately switch to the inactive state when the processor is stopped by a debugger This prevents the current PWM state from becoming a DC voltage since the processor is no longer running to change the duty cycles and damaging the motor In general though it is not a good idea to stop the processor when the motor is running When no longer driven the motor will start to slow down due to friction when the processor is restarted it will continue driving at the previous drive frequency The difference between rotor and target speed has become much greater due to the time that the motor was not being driven This will likely February 19 2008 81 PWM Control 11 2 82
76. h all control never returning Returns Never returns Variable Documentation 9_IFAdjl static Definition static long g_1FAd31I Description The coefficient of the frequency PI controller This variable is used by the serial interface as a staging area before the value gets placed into the parameter block by UIFAdjl g_pucLEDPin static Definition static const unsigned char g_pucLEDPin 2 Description This array contains the pin numbers of the two LEDs on the board g_pulLEDBase static Definition static const unsigned long g_pulLEDBase 2 Description This array contains the base address of the GPIO blocks for the two LEDs on the board February 19 2008 125 User Interface 16 2 4 4 16 2 4 5 16 2 4 6 16 2 4 7 16 2 4 8 126 g_pulUlHoldCount Definition unsigned long g_pulUIHoldCount NUM_SWITCHES Description This is the count of the number of samples during which the switches have been pressed it is used to distinguish a switch press from a switch hold This array is used by the on board user interface module g_pusBlinkPeriod static Definition static unsigned short g_pusBlinkPeriod 2 Description The blink period of the two LEDs on the board this is the number of user interface interrupts for which the LED will be turned on The run LED is the first entry of the array and the fault LED is the second entry of the array g_pusBlinkRate static Definition
77. he processing of linear Hall sensor input data Definitions Defines FLAG_EDGE_BIT FLAG_SKIP_BIT Functions void GPIOBIntHandler void void Halllnit void static void HallSpeedNewValue unsigned long ulNewSpeed void HallTickHandler void Variables unsigned long g_ulHallRotorSpeed February 19 2008 33 Hall Sensor Control 6 2 1 6 2 1 1 6 2 1 2 6 2 2 6 2 2 1 6 2 2 2 34 static unsigned long g_ulHallSpeedFlags m static unsigned long g_ulHallSpeedPrevious m unsigned long g_ulHallValue Define Documentation FLAG_EDGE BIT Definition define FLAG_EDGE_BIT Description The bit number of the flag in g_ulHallSpeedFlags that indicates that an edge has been seen If an edge hasn t been seen during a Hall timer interrupt period the speed is forced to zero FLAG_SKIP_BIT Definition define FLAG_SKIP_BIT Description The bit number of the flag in g_ulHallSpeedFlags that indicates that the next edge should be ignored by the speed calculation code This is used at startup since there is no previous edge time to be used to calculate the time between edges Function Documentation GPIOBintHandler Handles the GPIO port B interrupt Prototype void GPIOBIntHandler void Description This function is called when GPIO port B asserts its interrupt GPIO port B is configured to generate an interrupt on both the rising and falling edges of the Hall sensor input signal
78. iables and functions exported to the remainder of the application Definitions Defines m PWM_CLOCK PWM_CLOCK_WIDTH PWM_FLAG_NEW_DUTY_CYCLE PWM_FLAG_NEW_FREQUENCY PWM_FLAG_NEW_PRECHARGE Functions void PWMOIntHandler void unsigned long PWMGetPeriodCount void void PWMInit void void PWMOuiputOff void void PWMOuiputOn void void PWMOuiputPrecharge void void PWMOutputTrapezoid unsigned long ulEnable void PWMReducePeriodCount unsigned long ulCount void PWMSetDeadBand void void PWMSetDutyCycle unsigned long ulDutyCycleA unsigned long ulDutyCycleB unsigned long ulDutyCycleC void PWMSetFrequency void void PWMSetMinPulseWidth void void PWMSetUpdateRate unsigned char ucUpdateRate static void PWMUpdateDutyCycle void February 19 2008 11 2 1 11 2 1 1 11 2 1 2 11 2 1 3 11 2 1 4 Stellaris Brushless DC Motor RDK Software Reference Manual Variables static unsigned long g_ulMinPulseWidth static unsigned long g_ulPWMClock static unsigned long g_ulPWMDutyCycleA static unsigned long g_ulPWMDutyCycleB static unsigned long g_ulPWMDutyCycleC static unsigned long g_ulPWMFlags m unsigned long g_ulPWMFrequency static unsigned long g_ulPWMMillisecondCount static unsigned long g_ulPWMPeriodCount m unsigned long g_ulTrapDutyCycle Define Documentation PWM_CLOCK Definition define PWM_CLOCK Description The frequency of the clock that drives the PWM generators
79. ine or by using the Keil RV MDK or IAR EW ARM project files Debugging The Brushless DC motor firmware is a difficult application to debug If the firmware is stopped while the motor is running the PWM outputs shut off causing the motor to start coasting When the firmware starts executing again either because of a run or a single step the PWM outputs start up again as if they had never stopped But the motor will be running much slower at this February 19 2008 7 Introduction point so the difference between rotor and target speed will havee increased possibly significantly This likely results in a motor over current fault resultin in the motor drive being shut off meaning that the debug event has caused catastrophic results on the behavior of the application but no permanent hardware damage The use and abuse of the real time data stream is typically the best way to debug a running system like this the abuse of the real time data stream is to replace the current frequency real time data item value for example with a different internal variable and view its value in real time on the GUI Obviously not ideal but this is better than nothing February 19 2008 2 1 2 2 February 19 2008 Stellaris Brushless DC Motor RDK Software Reference Manual ADC Control A Rema ep alae 9 DAMOS accrcceccblesadtaentadeneastohsee ines as A ie 9 Introduction Depending on the mode of operation the ADC is used to monitor the
80. ion define PIN_CFGO_PORT Description The GPIO port on which the CFGO pin resides PIN_CFG1_PIN Definition define PIN_CFG1_PIN Description The GPIO pin on which the CFG1 pin resides PIN_CFG1_PORT Definition define PIN_CFG1_PORT Description The GPIO port on which the CFG1 pin resides PIN_CFG2_PIN Definition define PIN_CFG2_PIN Description The GPIO pin on which the CFG2 pin resides PIN_CFG2_PORT Definition define PIN_CFG2_PORT Description The GPIO port on which the CFG2 pin resides February 19 2008 9 2 1 13 9 2 1 14 9 2 1 15 9 2 1 16 9 2 1 17 9 2 1 18 Stellaris Brushless DC Motor RDK Software Reference Manual PIN_ENCA_PIN Definition define PIN_ENCA_PIN Description The GPIO pin on which the quadrature encoder channel A pin resides PIN_ENCA_PORT Definition define PIN_ENCA_PORT Description The GPIO port on which the quadrature encoder channel A pin resides PIN_ENCB_PIN Definition define PIN_ENCB_PIN Description The GPIO pin on which the quadrature encoder channel B pin resides PIN_ENCB_PORT Definition define PIN_ENCB_PORT Description The GPIO port on which the quadrature encoder channel B pin resides PIN_HALLA_PIN Definition define PIN_HALLA_PIN Description The GPIO pin on which the HALL A pin resides PIN_HALLA_PORT Definition define PIN_HALLA_PORT Description The GPIO port on which the HALL
81. is normally off but flashes at a fast rate when a fault occurs A periodic interrupt is used to poll the state of the push button and perform debouncing The Ethernet user interface is entirely handled by the Ethernet user interface module The only thing provided here is the list of parameters and real time data items plus a set of helper functions that are required in order to properly set the values of some of the parameters This user interface and the accompanying Ethernet and on board user interface modules is more complicated and consumes more program space than would typically exist in a real motor drive application The added complexity allows a great deal of flexibility to configure and evaluate the motor drive its capabilities and adjust it for the target motor The code for the user interface is contained in ui c with ui h containing the definitions for the structures defines variables and functions exported to the remainder of the application Definitions Data Structures tDriveParameters Defines FLAG_BRAKE_BIT FLAG_BRAKE_OFF FLAG_BRAKE_ON FLAG_DC_BRAKE_BIT FLAG_DC_BRAKE_OFF FLAG_DC_BRAKE_ON February 19 2008 107 User Interface 108 FLAG_DECAY_BIT FLAG_DECAY_FAST FLAG_DECAY_SLOW FLAG_DIR_BACKWARD FLAG_DIR_BIT FLAG_DIR_FORWARD FLAG_DRIVE_BIT FLAG_DRIVE_SINE FLAG_DRIVE_TRAPEZOID FLAG_ENCODER_ABSENT FLAG_ENCODER_BIT FLAG_ENCODER_PRESENT FLAG_PWM_FREQUENCY_12K FLAG_PWM_FREQUENCY_16K FLAG_PWM_FR
82. is that the size of the parameter block must be an integral divisor of the size of an erase block of flash If not a parameter block will end up spanning between two erase blocks of flash making it more difficult to manage When the microcontroller is initially programmed the flash blocks used for parameter block storage are left in an erased state The default settings in the motor drive application are therefore used initially The code for handling the flash parameter blocks is contained in flash_pb c with flash_pb h containing the definitions for the functions exported to the remainder of the application February 19 2008 29 Flash Parameter Block 5 2 5 2 1 5 2 1 1 5 2 1 2 30 Definitions Functions unsigned char FlashPBGet void void FlashPBlnit unsigned long ulStart unsigned long ulEnd unsigned long ulSize static unsigned long FlashPBlsValid unsigned char pucOffset void FlashPBSave unsigned char pucBuffer Variables m static unsigned char g_pucFlashPBCurrent static unsigned char x g_pucFlashPBEnd static unsigned char g_pucFlashPBStart static unsigned long g_ulFlashPBSize Function Documentation FlashPBGet Gets the address of the most recent parameter block Prototype unsigned char FlashPBGet void Description This function returns the address of the most recent parameter block that is stored in flash Returns Returns the address of the most recent param
83. lected into the usFlags member of g_sParameters Returns None 16 2 3 11 UIFAdjl static Updates the coefficient of the frequency PI controller February 19 2008 119 User Interface Prototype static void UIFAdjI void Description This function is called when the variable containing the coefficient of the frequency PI con troller is updated The value is then reflected into the parameter block Returns None 16 2 3 12 UlFaultLEDBlink Sets the blink rate for the fault LED Prototype void UlFaultLEDBlink unsigned short usRate unsigned short usPeriod Parameters usRate is the rate to blink the fault LED usPeriod is the amount of time to turn on the fault LED Description This function sets the rate at which the fault LED should be blinked A blink period of zero means that the LED should be turned off and a blink period equal to the blink rate means that the LED should be turned on Otherwise the blink rate determines the number of user interface interrupts during the blink cycle of the fault LED and the blink period is the number of those user interface interrupts during which the LED is turned on Returns None 16 2 3 13 UlGetTicks This function returns the current number of system ticks Prototype unsigned long UIGetTicks void Returns The number of system timer ticks 16 2 3 14 void Ullnit void Initializes the user interface This function initializes the user int
84. led when the lwIP TCP IP stack has an incoming packet to be processed Returns This function will return an IwIP defined error code 17 2 2 11 UlEthernetReceiveUDP static Receive a UDP packet from IwIP for motor control processing Prototype static void UlEthernetReceiveUDP void arg struct udp_pcb x pcb struct pbuf xp February 19 2008 141 Ethernet Interface struct ip_addr addr ul6_t port Parameters arg is not used in this implementation pcb is the pointer to the UDB control structure p is the pointer to the PBUF structure containing the packet data addr is the source remote IP address for this packet port is the source remote port for this packet Description This function is called when the IwIP TCP IP stack has an incoming UDP packet to be pro cessed Returns This function will return an IwIP defined error code 17 2 2 12 UlEthernetScanReceive static Scans for packets in the receive buffer Prototype static void UlEthernetScanReceive void Description This function will scan through g_pucUlEthernetReceive looking for valid command packets When found the command packets will be handled Returns None 17 2 2 13 UlEthernetSendRealTimeData Sends a real time data packet Prototype void UlEthernetSendRealTimeData void Description This function will construct a real time data packet with the current values of the enabled real time data items Onc
85. lowed when using the edge timing mode of speed determination which is also the minimum number of edges per second allowed when using the edge count mode QEI_INT_RATE Definition define QEI_INT_RATE Description The rate at which the QEI velocity interrupt occurs Function Documentation GPIOCIntHandler Handles the GPIO port C interrupt Prototype void GPIOCIntHandler void Description This function is called when GPIO port C asserts its interrupt GPIO port C is configured to generate an interrupt on the rising edge of the encoder input signal The time between the current edge and the previous edge is computed and used as a measure of the rotor speed Returns None QElIntHandler Handles the QEl velocity interrupt Prototype void QETIntHandler void Description This function is called when the QEI velocity timer expires If using the edge counting mode for rotor speed determination the number of edges counted during the last velocity period is used as a measure of the rotor speed February 19 2008 99 Speed Sensing 14 2 2 3 14 2 2 4 14 2 3 14 2 3 1 100 Returns None SpeedNewValue static Updates the current rotor speed Prototype static void SpeedNewValue unsigned short ulNewSpeed Parameters ulNewSpeed is the newly measured speed Description This function takes a newly measured rotor speed and uses it to update the current rotor speed If the new s
86. main Handles setup of the application on the Brushless DC motor drive Prototype int main void Description This is the main application entry point for the Brushless DC motor drive It is responsible for basic system configuration initialization of the various application drivers and peripherals and the main application loop Returns Never returns MainCheckFaults static Checks for motor drive faults February 19 2008 Stellaris Brushless DC Motor RDK Software Reference Manual 7 2 2 3 7 2 2 4 7 2 2 5 Prototype static void MainCheckFaults void Description This function checks for fault conditions that may occur during the operation of the motor drive The ambient temperature DC bus voltage and motor current are all monitored for fault condi tions Returns None MainClearFaults Clears the latched fault conditions Prototype void MainClearFaults void Description This function will clear the latched fault conditions and turn off the fault LED Returns None MainEmergencyStop Emergency stops the motor drive Prototype void MainEmergencyStop void Description This function performs an emergency stop of the motor drive The outputs will be shut down immediately the drive put into the stopped state with the speed at zero and the emergency stop fault condition will be asserted Returns None MainlsFaulted Determines if a latched fault condition exists Prot
87. measurement 0 indicates that single phase i e Trapezoid Mode should be used 1 indicates that all three phases should be measured as RMS phase current Description This function is called by the UI code to configure the Phase current measurement sequence Returns None ADCEnableBackEMFSequence Enable Disable the Back EMF Sequence Prototype void ADCEnableBackEMFSequence tBoolean bEnable February 19 2008 13 ADC Control Parameters bEnable is set to true to enable the Back EMF sequence and false to disable Description This function is called by the Ul code to enable disable the Back EMF processing based on motor drive configuration Returns None 2 2 2 9 ADCEnableLinearHallSequence Enable Disable the Linear Hall Sequence Prototype void ADCEnableLinearHallSequence tBoolean bEnable Parameters bEnable is set to true to enable the linear hall sequence and false to disable Description This function is called by the Ul code to enable disable the Linear Hall Sequence processing based on motor drive configuration Returns None 2 2 2 10 ADCInit Initializes the ADC control routines Prototype void ADCInit void Description This function initializes the ADC module and the control routines preparing them to monitor currents and voltages on the motor drive Returns None 2 2 2 11 ADCTickHandler Handles the ADC System Tick Prototype void ADCTickHa
88. n 2 static const unsigned long g_pulLEDBase 2 unsigned long g_pulUlHoldCount NUM_SWITCHES static unsigned short g_pusBlinkPeriod 2 static unsigned short g_pusBlinkRate 2 tDriveParameters g_sParameters const tUlParameter g_sUlParameters const tUlRealTimeData g_sUlRealTimeData const tUlOnboardSwitch g_sUlSwitches unsigned char g_ucBoardID unsigned char g_ucCPUUsage static unsigned char g_ucDecayMode static unsigned char g_ucDirection static unsigned char g_ucDynamicBrake static unsigned char g_ucEncoder static unsigned char g_ucFrequency static unsigned char g_ucModulation static unsigned char g_ucSensor static unsigned char g_ucSensorPolarity static unsigned char g_ucSensorType static unsigned char g_ucUpdateRate static unsigned long g_ulBlinkCount unsigned long g_ulDebugInfo unsigned long g_ulGPIOData unsigned long g_ulTargetSpeed const unsigned long g_ulUINumButtons const unsigned long g_ulUINumParameters 109 User Interface const unsigned long g_ulUINumRealTimeData const unsigned long g_ulUlTargetType static unsigned long g_ulUITickCount static unsigned long g_ulUlUseOnboard const unsigned short g_usFirmwareVersion 16 2 1 Data Structure Documentation 16 2 1 1 tDriveParameters Definition typedef struct unsigned char ucSequenceNum unsigned char ucCRC unsigned char ucVersion unsigned char ucMinPulseWidth unsigned char ucDeadTime unsigned char ucUpdateRate unsigned char ucNumPoles
89. n on time of one gate doesn t always match the turn off time of the other so both may be on for a short period despite the fact that only one of their inputs is on By providing a period of time where both inputs are off when making the transition shoot through is not possible The PWM outputs can be in one of four modes during the operation of the motor drive The first is off where all six outputs are in the inactive state This is the state used when the motor drive is stopped the motor is electrically disconnected during this time effectively the same as disconnecting the cable and is free to spin as if it were unplugged The next mode is precharge where the three outputs to the high side switches are inactive and the three outputs to the low side switches are switches at a 50 duty cycle The high side gate drivers have a bootstrap circuit for generating the voltage to drive the gates that only charges when the low side is switching this precharge mode allows the bootstrap circuit to generate the required gate drive voltage before real waveforms are driven Failure to precharge the high side gate drivers would simply result in distortion of the first part of the output waveform until the bootstrap circuit generates a voltage high enough to turn on the high side gate This mode is used briefly when going from a non driving state to a driving state The next mode is running where all six outputs are actively toggling This will create a ma
90. n the changes in the Hall Effect sensor value Returns None Variable Documentation g_ulHallToPhase120 static Definition static const unsigned long g_ulHallToPhasel20 8 Description Mapping from Hall States to Phase Drive states This array maps the hall state value to the set of PWM signals that should be driving at that time radios 4 4 4 4 4 4 Phase A 12 2 Phase B 12 1 1 121 Phase C PESE ls 1 Sees po o a February 19 2008 Stellaris Brushless DC Motor RDK Software Reference Manual February 19 2008 105 Trapezoid Modulation 106 February 19 2008 16 16 1 16 2 Stellaris Brushless DC Motor RDK Software Reference Manual User Interface mo NOE e A 107 3 AAA ae tsakaend DieaardsdaemneeeaGes 107 Introduction There are two user interfaces for the the Brushless DC motor application One uses an push button for basic control of the motor and two LEDs for basic status feedback and the other uses the Ethernet port to provide complete control of all aspects of the motor drive as well as monitoring of real time performance data The on board user interface consists of a push button and two LEDs The push button cycles between run forward stop run backward stop The Run LED flashes the entire time the application is running The LED is off most of the time if the motor drive is stopped and on most of the time if it is running The Fault LED
91. ndler void 14 February 19 2008 2 2 2 12 2 2 3 2 2 3 1 2 2 3 2 2 2 3 3 Stellaris Brushless DC Motor RDK Software Reference Manual Description This function is called by the system tick handler It s primary purpose is to reset the motor speed to 0 if no Hall edges have been detected for some period of time Returns None Timer0AlntHandler Handles the Back EMF Timer Interrupt Prototype void Timer0AlIntHandler void Description This function is called when the Back EMF timer expires This code will set the Back EMF Hall state value to the next value as determined by the Back EMF processing code The actual commutation of the motor takes place in the main module Returns None Variable Documentation g_bBEMFEdge static Definition static tBoolean g_bBEMFEdge Description A flag to indicate whether the Back EMF trigger point has been found g_psPhaseCurrent Definition short g_psPhaseCurrent 3 Description The current passing through the three phases of the motor specified in milliamperes as a signed value g_pusFilteredData0 static Definition static unsigned short g_pusFilteredData0 3 February 19 2008 15 ADC Control Description Arrays containing the raw low pass filtered ADC readings These are maintained in a raw form since they are required as an input to the next iteration of the IIR low pass filter There is at most one array for each ADC sequen
92. nsigned long g_ulEthernetTimer Description Running count updated by the UI System Tick Handler for milliseconds 17 2 3 14 g_ulEthernetTXCount Definition volatile unsigned long g_ulEthernetTXCount Description This global is used to store the number of Ethernet messages that have been transmitted since power up 146 February 19 2008 Stellaris Brushless DC Motor RDK Software Reference Manual 17 2 3 15 g_ulTCPFastTimer static Definition static unsigned long g_ulTCPFastTimer Description The fast TCP timer for IwlP 17 2 3 16 g_ulTCPSlowTimer static Definition static unsigned long g_ulTCPSlowTimer Description The slow TCP timer for IwIP 17 2 3 17 yg ulUlEthernetReceiveRead static Definition static unsigned long g_ulUlEthernetReceiveRead Description The offset of the next byte to be read from g_pucUlEthernetReceive 17 2 3 18 g_ulUlEthernetReceiveWrite static Definition static unsigned long g_ulUlEthernetReceiveWrit Description The offset of the next byte to be written to g_pucUlEthernetReceive February 19 2008 147 Company Information Founded in 2004 Luminary Micro Inc designs markets and sells ARM Cortex M3 based mi crocontrollers MCUs Austin Texas based Luminary Micro is the lead partner for the Cortex M3 processor delivering the world s first silicon implementation of the Cortex M3 processor Luminary Micro s introduction of the
93. number of the flag in g_ulADCFlags that indicates that the next edge should be ignored by the Back EMF speed calculation code This is used at startup since there is no previous edge time to be used to calculate the time between edges FLAG_SKIP_LINEAR_BIT Definition define FLAG_SKIP_LINEAR_BIT Description The bit number of the flag in g_ulADCFlags that indicates that the next edge should be ignored by the Linear Hall speed calculation code This is used at startup since there is no previous edge time to be used to calculate the time between edges Function Documentation ADCOIntHandler Handles the ADC sample sequence zero interrupt Prototype void ADCOIntHandler void Description This function is called when sample sequence zero asserts an interrupt It handles clearing the interrupt and processing any sequence overflow conditions Then depending on the mod ulation scheme that is active the appropriate sub handler is called Returns None ADCOIntHandlerSine static Handles the ADC sample sequence zero interrupt for sine mode Prototype static void ADCOIntHandlerSine void Description This functions processes the ADC sequence zero for sine mode In this handler all three phases of current are processed from the sequence The peak value is detected for a complete electrical revolution of the motor The phase current is converted to an RMS value and the motor current is taken as the average of all three
94. ock to check Description This function will compute the checksum of a parameter block in flash to determine if it is valid Returns Returns one if the parameter block is valid and zero if it is not FlashPBSave Writes a new parameter block to flash Prototype void FlashPBSave unsigned char pucBuffer Parameters pucBuffer is the address of the parameter block to be written to flash Description This function will write a parameter block to flash The parameter block is written to the next available portion of the parameter block space in flash being careful to keep the previous parameter block intact in case there is a power loss or fault mid way through the save process Returns None February 19 2008 31 Flash Parameter Block 5 2 2 5 2 2 1 5 2 2 2 5 2 2 3 5 2 2 4 32 Variable Documentation g_pucFlashPBCurrent static Definition static unsigned char g_pucFlashPBCurrent Description The address of the most recent parameter block in flash g_pucFlashPBEnd static Definition static unsigned char g_pucFlashPBEnd Description The address of the end of the flash used for storing parameter blocks this must be the start of an erase block in the flash or the first location after the end of the flash array if the last erase block is used for storing parameters g_pucFlashPBStiart static Definition static unsigned char g_pucFlashPBStart Description The address of the b
95. ong ulAngle unsigned long ulAmplitude unsigned long pul DutyCycles Function Documentation SineModulate Computes sine wave modulated waveforms Prototype void SineModulate unsigned long ulAngle unsigned long ulAmplitude unsigned long pulDutyCycles Parameters ulAngle is the current angle of the waveform expressed as a 0 32 fixed point value that is the percentage of the way around a circle ulAmplitude is the amplitude of the waveform as a 16 16 fixed point value pulDutyCycles is a pointer to an array of three unsigned longs to be filled in with the duty cycles of the waveforms in 16 16 fixed point values between zero and one Description This function finds the duty cycle percentage of the sine waveforms for the given angle For three phase operation there are three waveforms produced each 120 degrees apart For single phase operation there are two waveforms produced each 180 degrees apart If the amplitude of the waveform is larger than one the waveform will be clipped after scaling flat topping Returns None February 19 2008 95 Sine Wave Modulation 96 February 19 2008 14 14 1 14 2 Stellaris Brushless DC Motor RDK Software Reference Manual Speed Sensing PP o IENE Gu am Dena A EAA A AN 97 DAIMON lic ii da a ada a A 97 Introduction When running at slow speeds the time between input edges is measured to determine the speed of the rotor referred to as edge timing mode
96. order to measure Motor Stall This occurs when the motor is running and the speed is detected as zero for at least 1 5 seconds This would typically occur due to some type of mechanical interference to the operation of the motor shaft The definitions for the fault conditions are contained in faults h February 19 2008 25 Faults 4 2 4 2 1 4 2 1 1 4 2 1 2 4 2 1 3 4 2 1 4 26 Definitions Defines FAULT_CURRENT_HIGH FAULT_CURRENT_LOW m FAULT_EMERGENCY_STOP m FAULT_STALL FAULT_TEMPERATURE_HIGH FAULT_VBUS_HIGH m FAULT_VBUS_LOW Define Documentation FAULT _CURRENT_HIGH Definition define FAULT_CURRENT_HIGH Description The fault flag that indicates that the motor current rose too high FAULT _CURRENT_LOW Definition define FAULT_CURRENT_LOW Description The fault flag that indicates that the motor current dropped too low FAULT_EMERGENCY_STOP Definition define FAULT_EMERGENCY_STOP Description The fault flag that indicates that an emergency stop operation was performed FAULT_STALL Definition define FAULT_STALL Description The fault flag that indicates that the motor drive has stalled February 19 2008 Stellaris Brushless DC Motor RDK Software Reference Manual 4 2 1 5 FAULT_TEMPERATURE_HIGH Definition define FAULT_TEMPERATURE_HIGH Description The fault flag that indicates that the ambient temperature ros
97. ories are contained in the RDK BLDC directory created by this source distribution EULA txt The full text of the End User License Agreement EULA that covers the use of this software package akefile The rules for building the boot loader and Brushless DC motor application It simply traverses into the blac subdi rectory RDK BLDC srm 716 pdf The document that describes the source code for the Brushless DC motor application This is the document currently being viewed bldc This directory contains the source code for the Brushless DC motor application bldc gui installer 716 zip This ZIP file contains the installer package for the Win dows GUI for the Brushless DC motor which allows modification of the motor drive parameters The use of this application is described in the Stellaris Brushless DC Motor Reference Design Kit User s Manual Details for in stalling the application can be found in the BLDC Motor RDK Quickstart bldc ini This file contains the default parameters for the BLDC mo tor provided with the RDK If the motor drive parameters are modified and saved to flash this file can be loaded with the GUI to restore the default parameters useful if the parameters have been changed such that the motor no longer runs properly but the changes required to make it run well again are not known Once extracted the code can be built just like any other driver library example either by typing make from the command l
98. otype unsigned long MainIsFaulted void February 19 2008 45 Main Application 7 2 2 6 1 2 2 1 7 2 2 8 46 Description This function determines if a fault condition has occurred but not been cleared Returns Returns 1 if there is an uncleared fault condition and O otherwise MainlsReverse Determines if the motor drive is currently in reverse mode Prototype unsigned long MainIsReverse void Description This function will determine if the motor drive is currently running By this definition running means not stopped the motor drive is considered to be running even when it is precharging before starting the waveforms and DC injection braking after stopping the waveforms Returns Returns 0 if the motor drive is not in reverse and 1 if it is in reverse MainlsRunning Determines if the motor drive is currently running Prototype unsigned long MainIsRunning void Description This function will determine if the motor drive is currently running By this definition running means not stopped the motor drive is considered to be running even when it is precharging before starting the waveforms and DC injection braking after stopping the waveforms Returns Returns 0 if the motor drive is stopped and 1 if it is running MainLongMul static Multiplies two 16 16 fixed point numbers Prototype static long MainLongMul long 1X long 1Y Parameters IX is the first multiplicand Feb
99. ount Description A count of the number of PWM periods have occurred based on the number of PWM module interrupts This is incremented when a PWM interrupt is handled and decremented by the waveform generation handler February 19 2008 Stellaris Brushless DC Motor RDK Software Reference Manual 11 2 3 10 g_ulTrapDutyCycle Definition unsigned long g_ulTrapDutyCycle Description The duty cycle 0 to 100 used for trapezoid current calculations February 19 2008 91 PWM Control 92 February 19 2008 12 12 1 12 2 12 2 1 12 2 1 1 Stellaris Brushless DC Motor RDK Software Reference Manual Sine Function A 93 DAMOS dic ii da a ads EEA 93 Introduction This module provides a fixed point sine function A sine table is used to find the value for a given input angle with linear interpolation used when the precise angle is not available in the table The code for the sine function is contained in sine c with sine h containing the definition for the function exported to the remainder of the application Definitions Functions long sine unsigned long ulAngle Variables static const unsigned short g_pusFixedSineTable Function Documentation sine Computes an approximation of the sine of the input angle Prototype long sine unsigned long ulAngle Parameters ulAngle is an angle expressed as a 0 32 fixed point value that is the percentage of the way around a circle Description
100. peed is different from the current speed by too large a margin the new speed measurement is discarded a noise filter If the new speed is accepted it is passed through a single pole IIR low pass filter with a coefficient of 0 75 Returns None SpeedSenselnit Initializes the speed sensing routines Prototype void SpeedSenselInit void Description This function will initialize the peripherals used determine the speed of the motor s rotor Returns None Variable Documentation g_ulRotorSpeed Definition unsigned long g_ulRotorSpeed Description The current speed of the motor s rotor February 19 2008 14 2 3 2 14 2 3 3 14 2 3 4 Stellaris Brushless DC Motor RDK Software Reference Manual g_ulSpeedFlags static Definition static unsigned long g_ulSpeedFlags Description A set of flags that indicate the current state of the motor speed determination routines g_ulSpeedPrevious static Definition static unsigned long g_ulSpeedPrevious Description In edge timing mode this is the time at which the previous edge was seen and is used to determine the time between edges In edge count mode this is the count of edges during the previous timing period and is used to average the edge count from two periods g_ulSpeedTime static Definition static unsigned long g_ulSpeedTime Description The time accumulated during the QEI velocity interrupts This is used to extend the preci
101. phases Returns None February 19 2008 11 ADC Control 2 2 2 3 2 2 2 4 2 2 2 9 12 ADCOIntHandlerTrapezoid static Handles the ADC sample sequence zero interrupt for trapezoid mode Prototype static void ADCOIntHandlerTrapezoid void Description This functions processes the ADC sequence zero for trapezoid mode In this handler a single phase of current is processed from the sequence To account for noise especially during short PWM duty cycles five readings are taken the high and low values are discarded and the remaining three values are averaged The reported motor current value is averaged over the entire time the phase is active When the PWM drive changes the sequence is reset and measurements are started for the next phase Returns None ADC1IntHandler Handles the ADC sample sequence one interrupt Prototype void ADC1IntHandler void Description This function is called when sample sequence one asserts an interrupt It handles clearing the interrupt processing any sequence overflow conditions and processing the new ADC data in the FIFO This sequence is used to read the DC Bus Voltage the Analog Input signal and the temperature Returns None ADC2IntHandler Handles the ADC sample sequence two interrupt Prototype void ADC2IntHandler void Description This function is called when sample sequence two asserts an interrupt It handles clearing the interru
102. pt processing any sequence overflow conditions and processing the new ADC data in the FIFO This sequence is used to measure the linear Hall sensor inputs This sequence is only enabled when the Hall sensors are enabled and configured as linear Hall sensors The linear Hall data is read and converted to an equivalent digital Hall data value When change in the digital Hall state is detected the speed calculation routines are run if a complete electical revolution has occurred February 19 2008 2 2 2 6 2 2 2 7 2 2 2 8 Stellaris Brushless DC Motor RDK Software Reference Manual Returns None ADC3IntHandler Handles the ADC sample sequence three interrupt Prototype void ADC3IntHandler void Description This function is called when sample sequence three asserts an interrupt It handles clearing the interrupt processing any sequence overflow conditions and processing the new ADC data in the FIFO This sequence is used to process the Back EMF input data The Back EMF data is monitored to detect crossing of the 0 5 DC Bus Voltage point When this occurs an equivalent digital Hall state value is generated Speed is also calculated when a complete electrical revolution has occured Returns None ADCConfigurePhaseCurrentSequence Configure Phase Current Sequence Prototype void ADCConfigurePhaseCurrentSequence unsigned char ucMode Parameters ucMode determines which mode should be use for phase current
103. pts that have been counted Used in conjunc tion with the desired update rate missed waveform updates can be detected and compensated for Returns The number of PWM interrupts that have been counted February 19 2008 11 2 2 3 11 2 2 4 11 2 2 5 11 2 2 6 Stellaris Brushless DC Motor RDK Software Reference Manual PWMInit Initializes the PWM control routines Prototype void PWMInit void Description This function initializes the PWM module and the control routines preparing them to produce PWM waveforms to drive the power module Returns None PWMOutputOff Turns off all the PWM outputs Prototype void PWMOutputoff void Description This function turns off all of the PWM outputs preventing them from being propagates to the gate drivers Returns None PWMOutputOn Turns on all the PWM outputs Prototype void PWMOutputoOn void Description This function turns on all of the PWM outputs allowing them to be propagated to the gate drivers Returns None PWMOutputPrecharge Sets the PWM outputs to precharge the high side gate drives February 19 2008 85 PWM Control 11 2 2 7 11 2 2 8 86 Prototype void PWMOutputPrecharge void Description This function configures the PWM outputs such that they will start charging the bootstrap ca pacitor on the high side gate drives Without this step the high side gates will not turn on properly for the first several P
104. put PWM pulse in PWM clocks g_ulPWMClock static Definition static unsigned long g_ulPWMClock Description The number of PWM clocks in a single PWM period g_ulPWMDutyCycleA static Definition static unsigned long g_ulPWMDutyCycleA Description The duty cycle of the waveform output to the A phase of the bridge g_ulPWMDutyCycleB static Definition static unsigned long g_ulPWMDutyCycleB Description The duty cycle of the waveform output to the B phase of the bridge February 19 2008 89 PWM Control 11 2 3 5 11 2 3 6 11 2 3 7 11 2 3 8 11 2 3 9 90 g_ulPWMDutyCycleC static Definition static unsigned long g_ulPWMDutyCyclec Description The duty cycle of the waveform output to the C phase of the bridge g_ulPWMFlags static Definition static unsigned long g_ulPWMFlags Description A set of flags that control the operation of the PWM control routines The flags are PWM_ FLAG_NEW_FREQUENCY and PWM_FLAG_NEW_DUTY_CYCLE g_ulPWMFrequency Definition unsigned long g_ulPWMFrequency Description The frequency of the output PWM waveforms g_ulPWMMillisecondCount static Definition static unsigned long g_ulPWMMillisecondCount Description A counter that is used to determine when a millisecond has passed The millisecond software interrupt is triggered based on this count g_ulPWMPeriodCount static Definition static unsigned long g_ulPWMPeriodC
105. r Returns None 11 2 2 10 PWMSetDutyCycle Sets the duty cycle of the generated PWM waveforms Prototype void PWMSetDutyCycle unsigned long ulDutyCycleA unsigned long ulDutyCycleB unsigned long ulDutyCycleC Parameters ulDutyCycleA is the duty cycle of the waveform for the U phase of the motor specified as a 16 16 fixed point value between 0 0 and 1 0 ulDutyCycleB is the duty cycle of the waveform for the V phase of the motor specified as a 16 16 fixed point value between 0 0 and 1 0 ulDutyCycleC is the duty cycle of the waveform for the W phase of the motor specified as a 16 16 fixed point value between 0 0 and 1 0 Description This function configures the duty cycle of the generated PWM waveforms The duty cycle update will not occur immediately the change will be registered for synchronous application to the output waveforms to avoid discontinuities Returns None 11 2 2 11 PWMSetFrequency Sets the frequency of the generated PWM waveforms Prototype void PWMSetFrequency void February 19 2008 87 PWM Control Description This function configures the frequency of the generated PWM waveforms The frequency up date will not occur immediately the change will be registered for synchronous application to the output waveforms to avoid discontinuities Returns None 11 2 2 12 PWMSetMinPulseWidth Computes the minimum PWM pulse width Prototype void PWMSetMinPulseWidth
106. r void void Timer0AlntHandler void Variables static Boolean y_bBEMFEdge short g_psPhaseCurrent 3 static unsigned short g_pusFilteredDataO 3 static unsigned short g_pusLinearHallMax 3 static unsigned short g_pusLinearHallMin 3 static unsigned short g_pusLinearHallSensor 3 static unsigned short g_pusPhaseMax 3 short g_sMotorCurrent unsigned char g_ucAmbientTemp static unsigned char g_ucBEMFState static unsigned char g_ucPhaseCurrentindex static unsigned long g_ulADCFlags static unsigned long g_ulIBEMFEdgePrevious unsigned long g_ulIBEMFHallValue static unsigned long g_ulIBEMFNextHall unsigned long g_ulIBEMFRotorSpeed static unsigned long g_ulBEMFSpeedPrevious unsigned long g_ulBusVoltage unsigned long g_ulLinearHallValue static unsigned long g_ulLinearLastHall unsigned long g_ulLinearRotorSpeed static unsigned long g_ulLinearSpeedPrevious static unsigned long g_ulPrevAngle unsigned short g_usAnalogInputVoltage 2 2 1 Define Documentation 2 21 1 FLAG EDGE BIT Definition define FLAG _EDGE_BIT Description The bit number of the flag in g_ulADCFlags that indicates that an edge has been seen in the speed processing code This will prevent the ADCTickHandler from resetting the rotor speed 2 21 2 FLAG SKIP_BIT Definition define FLAG _SKIP_BIT 10 February 19 2008 2 2 1 3 2 2 2 2 2 2 1 2 2 2 2 Stellaris Brushless DC Motor RDK Software Reference Manual Description The bit
107. r usage may be incorrect if deep sleep mode is utilized The number of clocks the processor spends in run mode will be properly counted but the timing period may not be accurate unless extraordinary measures are taken to ensure timing period accuracy The accuracy of the computed CPU utilization depends upon the regularity with which CPUUsage Tick is called by the application If the CPU usage is constant but CPUUsageTick is called sporadically the reported CPU usage will fluctuate as well despite the fact that the CPU usage is actually constant Definitions Functions void CPUUsagelnit unsigned long ulRate m unsigned long CPUUsageTick void Variables static unsigned long g_ulCPUUsagePrevious static unsigned long g_ulCPUUsageTicks February 19 2008 77 Processor Usage Meter 10 2 1 10 2 1 1 10 2 1 2 10 2 2 10 2 2 1 10 2 2 2 78 Function Documentation CPUUsagelnit Initializes the CPU usage measurement module Prototype void CPUUsageInit unsigned long ulRate Parameters ulRate is the number of times per second that CPUUsageTick is called Description This function prepares the CPU usage measurement module for measuring the CPU usage of the application Returns None CPUUsageTick Updates the CPU usage for the new timing period Prototype unsigned long CPUUsageTick void Description This function when called at the end of a timing period will update the CPU
108. rFaults void void MainEmergencyStop void unsigned long MainlsFaulted void unsigned long MainlsReverse void unsigned long MainlsRunning void static long MainLongMul long IX long IY void MainMillisecondTick void static void MainPrechargeHandler void void MainRun void void MainSetDirection tBoolean bForward void MainSetFault unsigned long ulFaultFlag void MainSetPWMFrequency void February 19 2008 Stellaris Brushless DC Motor RDK Software Reference Manual void MainSetSpeed void unsigned long MainSpeedController void static void MainSpeedHandler unsigned long ulTarget static void MainStartupHandler void void MainStop void void MainUpdateFAdjl long INewFAdjl void MainWaveformTick void Variables static long g_ISpeedIntegrator static long g_ISpeedIntegratorMax unsigned char g_ucMotorStatus static unsigned long g_ulAccelRate unsigned long g_ulAngle static unsigned long g_ulAngleDelta static unsigned long g_ulDecelRate static unsigned long g_ulDutyCycle unsigned long g_ulFaultFlags static unsigned long g_ulHallPrevious unsigned long g_ulMeasuredSpeed static unsigned long g_ulSineTarget static unsigned long g_ulSpeed static unsigned long g_ulSpeedFract static unsigned long g_ulSpeedWhole static unsigned long g_ulStallDetectCount static unsigned long g_ulStartupHallStateCount static unsigned long g_ulStartupHallStateCountReload static unsigned long g_ulStartupHallValue static unsi
109. rameter block This can be used to distinguish saved param eters that correspond to an old version of the parameter block ucMinPulseWidth The minimum width of a PWM pulse specified in 0 1 us periods ucDeadTime The dead time between inverting the high and low side of a motor phase spec ified in 20 ns periods ucUpdateRate The rate at which the PWM pulse width is updated specified in the number of PWM periods ucNumPoles The number of pole pairs in the motor ucPad1 Padding to ensure consistent parameter block alignment usAccel The rate of acceleration specified in RPM per second usDecel The rate of deceleration specified in RPM per second sMinCurrent The minimum current through the motor drive during operation specified in milli amperes sMaxCurrent The maximum current through the motor drive during operation specified in milli amperes ucPrechargeTime The amount of time to precharge the bootstrap capacitor on the high side gate drivers specified in milliseconds ucMaxTemperature The maximum ambient temperature of the microcontroller specified in degrees Celsius usFlags A set of flags enumerated by FLAG_PWM_FREQUENCY_MASK FLAG_DRIVE_BIT FLAG_DIR_BIT FLAG_ENCODER BIT FLAG_BRAKE_BIT FLAG_SENSOR_BIT FLAG_SENSOR_TYPE_BIT and FLAG_SENSOR_POLARITY_BIT usNumEncoderLines The number of lines in the optional optical encoder ucPad2 Padding to ensure consistent parameter block alignment ulMinSpeed The minimum spee
110. requency is 20 KHz 16 2 2 22 FLAG_PWM_ FREQUENCY _ 8K The value of the FLAG_PWM_FREQUENCY_MASK bit field that indicates that the PWM frequency is 8 KHz 16 2 2 23 FLAG_PWM_FREQUENCY MASK or FLAG_PWM_FREQUENCY_20K The mask for the bits in the usFlags member of tDriveParameters that define the PWM output frequency This field will be one of FLAG_PWM_FREQUENCY_ 8K FLAG_PWM_FREQUENCY_ 12K FLAG_PWM_FREQUENCY_16K 16 2 2 24 FLAG_SENSOR_ABSENT The value of the FLAG_SENSOR_BIT flag that indicates that the Hall Effect sensor s are absent 16 2 2 25 FLAG_SENSOR_BIT The bit number of the flag in the usFlags member of tDriveParameters that defines the presence of Hall Effect Sensor s for position speed feedback This field will be one of FLAG_SENSOR_ ABSENT or FLAG_SENSOR_PRESENT 16 2 2 26 FLAG_SENSOR_POLARITY_BIT The bit number of the flag in the usFlags member of tDriveParameters that defines the polarity of the Hall Effect Sensor s inputs This field will be one of FLAG_SENSOR_POLARITY_HIGH or FLAG_SENSOR_POLARITY_LOW 16 2 2 27 FLAG_SENSOR_POLARITY_HIGH The value of the FLAG_SENSOR_POLARITY_BIT flag that indicates that the Hall Effect sensor s are configured as active high 16 2 2 28 FLAG_SENSOR_POLARITY_LOW The value of the FLAG_SENSOR_POLARITY_BIT flag that indicates that the Hall Effect sensor s are configured as active low February 19 2008 115 User Interface 16 2 2 29 FLAG_SENSOR_PRESENT The value of
111. rototype static void UIDecayMode void Description This function is called when the variable controlling the decay mode is updated The value is then reflected into the usFlags member of g_sParameters Returns None UlDirectionSet static Updates the motor drive direction bit Prototype static void UIDirectionSet void Description This function is called when the variable controlling the motor drive direction is updated The value is then reflected into the usFlags member of g_sParameters Returns None February 19 2008 16 2 3 8 16 2 3 9 Stellaris Brushless DC Motor RDK Software Reference Manual UlDynamicBrake static Updates the dynamic brake bit of the motor drive Prototype static void UIDynamicBrake void Description This function is called when the variable controlling the dynamic braking is updated The value is then reflected into the usFlags member of g_sParameters Returns None UlEmergencyStop Emergency stops the motor drive Prototype void UlEmergencyStop void Description This function is called by the serial user interface when the emergency stop command is re ceived Returns None 16 2 3 10 UlEncoderPresent static Updates the encoder presence bit of the motor drive Prototype static void UlEncoderPresent void Description This function is called when the variable controlling the presence of an encoder is updated The value is then ref
112. ruary 19 2008 7 2 2 9 7 2 2 10 Stellaris Brushless DC Motor RDK Software Reference Manual IY is the second multiplicand Description This function takes two fixed point numbers in 16 16 format and multiplies them together returning the 16 16 fixed point result It is the responsibility of the caller to ensure that the dynamic range of the integer portion of the value is not exceeded if it is exceeded the result will not be correct Returns Returns the result of the multiplication in 16 16 fixed point format MainMillisecondTick Handles the millisecond speed update software interrupt Prototype void MainMillisecondTick void Description This function is called as a result of the speed update software interrupt being asserted This interrupted is asserted every millisecond by the PWM interrupt handler The speed of the motor drive will be updated along with handling state changes of the drive such as initiating braking when the motor drive has come to a stop Note Since this interrupt is software triggered there is no interrupt source to clear in this handler Returns None MainPrechargeHandler static Handles the gate driver precharge mode of the motor drive Prototype static void MainPrechargeHandler void Description This function performs the processing and state transitions associated with the gate driver precharge mode of the motor drive Returns None February 19 2008 47
113. s Returns None HallInit Initializes the Hall sensor control routines February 19 2008 6 2 2 3 6 2 2 4 6 2 3 6 2 3 1 Stellaris Brushless DC Motor RDK Software Reference Manual Prototype void HallInit void Description This function will initialize the peripherals used determine the speed of the motor s rotor Returns None HallSpeedNewValue static Updates the current rotor speed Prototype static void HallSpeedNewValue unsigned long ulNewSpeed Parameters ulNewSpeed is the newly measured speed Description This function takes a newly measured rotor speed and uses it to update the current rotor speed If the new speed is different from the current speed by too large a margin the new speed measurement is discarded a noise filter If the new speed is accepted it is passed through a single pole IIR low pass filter with a coefficient of 0 75 Returns None HallTickHandler Handles the Hall System Tick Prototype void HallTickHandler void Description This function is called by the system tick handler It s primary purpose is to reset the motor speed to 0 if no Hall interrupt edges have been detected for some period of time Returns None Variable Documentation g_ulHallRotorSpeed Definition unsigned long g_ulHallRotorSpeed February 19 2008 35 Hall Sensor Control Description The current speed of the motor s rotor 6 2 3 2 g _ulHallSpeedFlags
114. ser interface when the load parameter block function is called If the motor drive is running the parameter block is not loaded since that may result February 19 2008 121 User Interface in detrimental changes such as changing the motor drive from sine to trapezoid If the motor drive is not running and a valid parameter block exists in flash the contents of the parameter block are loaded from flash Returns None 16 2 3 18 UlParamSave Saves the motor drive parameter block to flash Prototype void UIParamSave void Description This function is called by the serial user interface when the save parameter block function is called The parameter block is written to flash for use the next time a load occurs be it from an explicit request or a power cycle of the drive Returns None 16 2 3 19 UIPWMFrequencySet static Updates the PWM frequency of the motor drive Prototype static void UIPWMFrequencySet void Description This function is called when the variable controlling the PWM frequency of the motor drive is updated The value is then reflected into the usFlags member of g_sParameters Returns None 16 2 3 20 UlRun Starts the motor drive Prototype void UIRun void Description This function is called by the serial user interface when the run command is received The motor drive will be started as a result this is a no operation if the motor drive is already running 122 February 19
115. sion of the QEI timer February 19 2008 101 Speed Sensing 102 February 19 2008 15 15 1 15 2 15 2 1 15 2 1 1 15 2 1 2 Stellaris Brushless DC Motor RDK Software Reference Manual Trapezoid Modulation o N CISCO 205 a AAA AAA AAA AAA AAA AAA Introduction The code for producing trapezoid modulated waveforms is contained in trapmod c with trapmod h containing the definition for the function exported to the remainder of the application Definitions Defines m PHASE_A m PHASE_B m PHASE_C Functions void TrapModulate unsigned long ulHall Variables static const unsigned long g_ulHallToPhase120 8 Define Documentation PHASE A Definition define PHASE_A Description PWM Phase A High Low PHASE B Definition define PHASE_B February 19 2008 103 Trapezoid Modulation 15 2 1 3 15 2 2 15 2 2 1 15 2 3 15 2 3 1 104 Description PWM Phase B High Low PHASE_C Definition define PHASE_C Description PWM Phase C High Low Function Documentation TrapModulate Controls trapezoid modulated waveforms Prototype void TrapModulate unsigned long ulHall Parameters ulHall is the current Hall state value for the motor This value may be read directly from the Hall sensors if installed or derived from the Back EMF or Linear Hall sensor readings Description This function will control the PWM generator channels based o
116. st starting after a short period of time it will track correctly regardless of the initial state Returns None UlOnboardPotentiometerFilter Filters the value of a potentiometer Prototype unsigned long UlOnboardPotentiometerFilter unsigned long ulValue Parameters ulValue is the current sample for the potentiometer Description This function performs filtering on the sampled value of a potentiometer First a single pole IIR low pass filter is applied to the raw sampled value Then the filtered value is examined to determine when the potentiometer is being turned and when it is not When the potentiometer is not being turned and variations in the value are therefore the result of noise in the system a constant value is returned instead of the filtered value When the potentiometer is being turned the filtered value is returned unmodified This second filtering step eliminates the flutter when the potentiometer is not being turned so that processes that are driven from its value such as a motor position do not result in the motor jiggling back and forth to the potentiometer flutter The downside to this filtering is a larger turn of the potentiometer being required before the output value changes Returns Returns the filtered potentiometer value UlOnboardSwitchDebouncer Debounces a set of switches Prototype void UlOnboardSwitchDebouncer unsigned long ulSwitches February 19 2008 59 On board User In
117. tches static Definition static unsigned long g_ulUIOnboardSwitches Description The debounced state of the switches 62 February 19 2008 Stellaris Brushless DC Motor RDK Software Reference Manual 9 Pin Definitions A T ce ee eect esas deca ce sss crcv mga E E avian nan og er endo tena pate anata ae ae adnan npeeomseee 63 DISTIN 1 AA A A it e 63 9 1 Introduction The pins on the microcontroller are connected to a variety of external devices The defines in this file provide a name more descriptive than PBO for the various devices connected to the microcon troller pins These defines are provided in pins h 9 2 Definitions Defines PIN_BRAKE_PIN PIN_BRAKE_PORT PIN_CANORX_PIN PIN_CANORX_PORT PIN_CANOTX_PIN PIN_CANOTX_PORT PIN_CFGO_PIN PIN_CFGO_PORT PIN_CFG1_PIN PIN_CFG1_PORT PIN_CFG2_PIN PIN_CFG2_PORT PIN_ENCA_PIN PIN_ENCA_PORT PIN_ENCB_PIN PIN_ENCB_PORT PIN_HALLA_PIN PIN_HALLA_PORT PIN_HALLB_PIN PIN_HALLB_PORT PIN_HALLC_PIN PIN_HALLC_PORT PIN_INDEX_PIN PIN_INDEX_PORT PIN_IPHASEA February 19 2008 63 Pin Definitions PIN_IPHASEB PIN_IPHASEC PIN_LEDFAULT_PIN PIN_LEDFAULT_PORT PIN_LEDRUN_PIN PIN_LEDRUN_PORT PIN_LEDSTATUSO_PIN PIN_LEDSTATUSO_PORT PIN_LEDSTATUS1_PIN PIN_LEDSTATUS1_PORT PIN_PHASEA_HIGH_PIN PIN_PHASEA_HIGH_PORT PIN_PHASEA_LOW_PIN PIN_PHASEA_LOW_PORT PIN_PHASEB_HIGH_PIN PIN_PHASEB_HIGH_PORT PIN_PHASEB_LOW_PIN PIN_PHASEB_LOW_PORT PIN_PHASEC_HIGH_PIN PIN_PHASEC_HIGH_PORT
118. te period this is incremented if the brake is on and decremented if it is off This effectively represents the heat buildup in the power resistor when on heat will increase and when off it will decrease g_ulBrakeState static Definition static unsigned long g_ulBrakeState Description The current state of the dynamic brake Will be one of STATE_BRAKE_OFF STATE_BRAKE_ ON or STATE_BRAKE_COOL February 19 2008 23 Dynamic Brake Control 24 February 19 2008 4 4 1 Stellaris Brushless DC Motor RDK Software Reference Manual Faults ales Lo Tox eva csc tcp Stee edt ganna Da Some Gs EREA Re Enid MR RRR O ARTATI ETS 25 DEDOS Seer ee eee eee EE ee ee Tee eee ee eT ee eee ree eT eet a se Te eee ee eee ere ee AA 26 Introduction There are several fault conditions that can occur during the operation of the motor drive Those fault conditions are enumerated here and provide the definition of the fault status read only parameter and real time data item The faults are Emergency stop This occurs as a result of a command request An emergency stop is one where the motor is stopped immediately without regard for trying to maintain normal control of it this is without the normal deceleration ramp From the motor drive perspective the motor is left to its own devices to stop meaning it will coast to a stop under the influence of friction unless a mechanical braking mechanism is provided DC bus under voltage This oc
119. terface 8 2 3 8 2 3 1 8 2 3 2 8 2 3 3 60 Parameters ulSwitches is the current state of the switches Description This function takes a set of switch inputs and performs software debouncing of their state Changes in the debounced state of a switch are reflected back to the application via callback functions For each switch a press can be distinguished from a hold allowing two functions to coexist on a single switch a separate callback function is called for a hold as opposed to a press For best results the switches should be sampled and passed to this function on a periodic ba sis Randomness in the sampling time may result in degraded performance of the debouncing routine Returns None Variable Documentation g_ulUlOnboardClockA static Definition static unsigned long g_ulUIOnboardClockA Description This is the low order bit of the clock used to count the number of samples with the switches in the non debounced state g_ulUlOnboardClockB static Definition static unsigned long g_ulUIOnboardClockB Description This is the high order bit of the clock used to count the number of samples with the switches in the non debounced state g_ulUlOnboardFilteredPotValue static Definition static unsigned long g_ulUIOnboardFilteredPotValue Description The detected stable value of the potentiometer This will be Oxffff ffff wnen the value of the potentiometer is changing and will be a val
120. tic unsigned long g_ulLinearLastHall l Description The previous Hall state value as determined by the linear Hall sensor processing code February 19 2008 2 2 3 21 2 2 3 22 2 2 3 23 2 2 3 24 Stellaris Brushless DC Motor RDK Software Reference Manual g_ulLinearRotorSpeed Definition unsigned long g_ulLinearRotorSpeed Description The rotor speed as measured by the linear Hall sensor processing code g_ulLinearSpeedPrevious static Definition static unsigned long g_ulLinearSpeedPrevious Description The time at which the last linear Hall sensor speed edge occurred g_ulPrevAngle static Definition static unsigned long g_ulPrevAngle Description The angle of the motor drive on the previous ADC interrupt g_usAnalogInputVoltage Definition unsigned short g_usAnalogInputVoltage Description The Analog Input voltage specified in millivolts February 19 2008 19 ADC Control 20 February 19 2008 3 3 1 3 2 Stellaris Brushless DC Motor RDK Software Reference Manual Dynamic Brake Control o serene um drone eam E RRAgu ea De RRR Gee ae Penae ENSS 2i DAMONG lic ii da ad ESRAS 21 Introduction Dynamic braking is the application of a power resistor across the DC bus in order to control the increase in the DC bus voltage The power resistor reduces the DC bus voltage by converting current into heat The dynamic braking routine is called every millisecond to monitor the DC b
121. ue within the potentiometer range when the poten tiometer value is stable February 19 2008 8 2 3 4 8 2 3 5 8 2 3 6 8 2 3 7 8 2 3 8 Stellaris Brushless DC Motor RDK Software Reference Manual g_ulUlOnboardPotCount static Definition static unsigned long g_ulUIOnboardPotCount Description The count of samples that have been collected into the accumulator g_ulUlOnboardPotSum g_ulUlOnboardPotMax static Definition static unsigned long g_ulUIOnboardPotMax Description The maximum value of the potentiometer over a small period This is used to detect a stable value of the potentiometer g_ulUlOnboardPotMin static Definition static unsigned long g_ulUIOnboardPotMin Description The minimum value of the potentiometer over a small period This is used to detect a stable value of the potentiometer g_ulUlOnboardPotSum static Definition static unsigned long g_ulUIOnboardPotSum Description An accumulator of the low pass filtered potentiometer values for a small period When a stable potentiometer value is detected this is used to compute the average value and therefore the stable value of the potentiometer g_ulUlOnboardPotValue static Definition static unsigned long g_ulUIOnboardPotValue Description The value of the potentiometer after being passed through the single pole IIR low pass filter February 19 2008 61 On board User Interface 8 2 3 9 g ulUlOnboardSwi
122. unction Documentation EthernetintHandler Handles the Ethernet interrupt Prototype void EthernetIntHandler void Description This function is called when the Ethernet controller asserts an interrupt If a receive packet is indicated the IwIP input handler will be called Returns None UlEthernetAccept static Accept a TCP connection for motor control processing Prototype static err_t UlEthernetAccept void arg struct tcp_pcb xpcb err_t err Parameters arg is not used in this implementation peb is the pointer to the TCP control structure err is not used in this implementation Description This function is called when the IwIP TCP IP stack has an incoming connection request on the telnet port Returns This function will return an IwIP defined error code UlEthernetClose static Close an existing Ethernet connection Prototype static void UIEthernetClose struct tcp_pcb x pcb Parameters pcb is the pointer to the TCP control structure February 19 2008 Stellaris Brushless DC Motor RDK Software Reference Manual Description This function is called when the the TCP connection should be closed Returns None 17 2 2 4 UlEthernetError static lwIP TCP IP error handling Prototype static void UI EthernetError void arg err_t err Parameters arg is not used in this implementation err is not used in this implementation Description This
123. urrent g_ulAngle Definition unsigned long g_ulAngle Description The current angle of the motor drive output expressed as a 0 32 fixed point value that is the percentage of the way around a circle g_ulAngleDelta static Definition static unsigned long g_ulAngleDelta Description The amount by which the motor drive angle is updated for a single PWM period expressed as a 0 32 fixed point value For example if the motor drive is being updated every fifth PWM period this value should be multiplied by five to determine the amount to adjust the angle February 19 2008 7 2 3 7 7 2 3 8 7 2 3 9 7 2 3 10 7 2 3 11 Stellaris Brushless DC Motor RDK Software Reference Manual g_ulDecelRate static Definition static unsigned long g_ulDecelRate Description The current rate of deceleration This will start as the parameter value but may be reduced in order to manage increases in the DC bus voltage g_ulDutyCycle static Definition static unsigned long g_ulDutyCycle Description The current duty cycle for the motor drive expressed as a 16 16 fixed point value in the range from 0 0 to 1 0 g_ulFaultFlags Definition unsigned long g_ulFaultFlags Description The latched fault status flags for the motor drive enumerated by FAULT_EMERGENCY_STOP FAULT_VBUS_LOW FAULT_VBUS_HIGH FAULT _CURRENT_LOW FAULT_CURRENT_ HIGH and FAULT_TEMPERATURE_HIGH g_ulHallPrevious static Definition
124. us voltage and handle the dynamic brake When the DC bus voltage gets too high the dynamic brake is applied to the DC bus When the DC bus voltage drops enough the dynamic brake is removed In order to control heat buildup in the power resistor the amount of time the brake is applied is tracked If the brake is applied for too long it will be forced off for a period of time regardless of the DC bus voltage to prevent it from overheating The amount of time on and off is tracked as an indirect measure of the heat buildup in the power resistor the heat increases when on and decreases when off The code for handling dynamic braking is contained in brake c with brake h containing the definitions for the functions exported to the remainder of the application Definitions Defines STATE_BRAKE_COOL STATE_BRAKE_OFF STATE_BRAKE_ON Functions void Brakelnit void m void BrakeTick void Variables static unsigned long g_ulBrakeCount static unsigned long g_ulBrakeState February 19 2008 21 Dynamic Brake Control 3 2 1 3 2 1 1 3 2 1 2 3 2 1 3 3 2 2 3 2 2 1 22 Define Documentation STATE_BRAKE_COOL Definition define STATE_BRAKE_COOL Description The dynamic brake is forced off to allow the power resistor to cool After the minimum cooling period has expired an automatic transition to STATE_BRAKE_OFF will occur if the bus voltage is below the trigger level and to STATE_BRAKE_ON i
125. void Description This function computes the minimum PWM pulse width based on the minimum pulse width parameter and the dead time parameter The dead timers will reduce the width of a PWM pulse so their value must be considered to avoid pulses shorter than the parameter value being produced Returns None 11 2 2 13 PWMSetUpdateRate Changes the update rate of the motor drive Prototype void PWMSetUpdateRate unsigned char ucUpdateRate Parameters ucUpdateRate is the number of PWM periods between updates Description This function changes the rate at which the motor drive waveforms are recomputed Lower update values recompute the waveforms more frequently providing more accurate waveforms at the cost of increased processor usage Returns None 11 2 2 14 PWMUpdateDutyCycle static Updates the duty cycle in the PWM module 88 February 19 2008 11 2 3 11 2 3 1 11 2 3 2 11 2 3 3 11 2 3 4 Stellaris Brushless DC Motor RDK Software Reference Manual Prototype static void PWMUpdateDutyCycle void Description This function programs the duty cycle of the PWM waveforms into the PWM module The changes will be written to the hardware and the hardware instructed to start using the new values the next time its counters reach zero Returns None Variable Documentation g_ulMinPulseWidth static Definition static unsigned long g_ulMinPulseWidth Description The minimum width of an out
Download Pdf Manuals
Related Search
Related Contents
sk multi ELLE ROLLER VOGUE cod 644010_H_Layout 1 CB RADIO Manual de usuario AE 6890 DMP Electronics XR10 User's Manual Synchrony Cell Exchange User`s Guide 25MHz HIGH VOLTAGE DIFFERENTIAL PROBE USER'S MANUAL Notice - Castorama Apprentice Remote Copyright © All rights reserved.
Failed to retrieve file