<dalf1_om.doc> Owners Manual. Revision 0.36 Nov 08, 2007

Size: px
Start display at page:

Download "<dalf1_om.doc> Owners Manual. Revision 0.36 Nov 08, 2007"

Transcription

1 <daf1_om.doc> DALF 1; Rev F Motor Contro Board Owners Manua Revision 0.36 Nov 08, 2007 Embedded Eectronics Page 1 11/9/2007

2 Embedded Eectronics Page 1 11/9/2007 Tabe of Contents 1 MOTOR CONTROL BOARD OVERVIEW DEVELOPMENT HISTORY BOARD DEVELOPMENT FIRMWARE RELEASES DOCUMENTATION OPERATING MODES (CMD, POT, R/C, RCSVO, POTSVO) TE INTERFACE API INTERFACE I2C2 INTERFACE POT INTERFACES R/C INTERFACE (3 CHANNELS) OTHER INTERFACES THE DALF-1 BOARD DETAIL PARTIAL FEATURE LIST POWER SUPPLY PIC18F6722 MICROCONTROLLER MOTOR DRIVER CONNECTION RS EXTERNAL EEPROM/PARAMETER BLOCK INTERNAL (BUILT-IN) EEPROM FAN DRIVER OUTPUTS EX0, EX1, EX2, EX A/D INPUTS OVER CURRENT SENSE POSITION ENCODER INPUTS I2C COMMUNICATION I/O EXPANDERS CONNECTORS LEDS SWITCHES HEADERS CUSTOMIZATION AND CONFIGURATION EEPROM CONFIGURATION FACTORY DEFAULTS, PARAMETER BLOCK, AND ERAM CHANGING THE CONFIGURATION PARAMETER BLOCK CHANGE GUIDE SOME IMPORTANT PARAMETERS PROGRAMMING CUSTOMIZATION DEVELOPMENT TOOLS COMPILER, ASSEMBLER, DEBUGGER SOFTWARE DEVELOPMENT TOOL VERSION NUMBERS...28 FLASHING THE MICROCONTROLLER USING THE BOOT LOADER The Boot Bock Under The Hood Instaing the p1618qp.exe Appication About The Image About The Parameter Bock... 30

3 6.2.6 The Process INTERRUPT DRIVEN FIRMWARE DESIGN TMR0 - HEARTBEAT TMR1 - RTC TMR2 - ADC STATE MACHINE INT0 - MOTOR2 ENCODER INT1 - MOTOR1 ENCODER INT2 - MOTOR2 CURRENT LIMIT INT3 - MOTOR1 CURRENT LIMIT RB4 - EX TX1 - USART1: RS232 SERIAL COMMAND RESPONSE RX1 - USART1: RS232 SERIAL COMMAND RECEIVE CCP1 - R/C CHANNEL 1 (EX0) CCP2 - R/C CHANNEL 2 (EX1) CCP3 - R/C CHANNEL 3 (EX3) SSP2 - I2C2 SLAVE COMMAND INTERFACE (SC2, SD2) //UNUSED INTERRUPTS// - RESOURCE DETAILS MOTOR ENCODER FEEDBACK OPTICAL ENCODERS The CPR Specification Optica Encoder Limitations Optica Encoder Hookup Optica Encoder Accuracy ANALOG ENCODERS Anaog Encoder Limitations The Position Agorithm (Under The Hood) The Digita Recursive Fiter Anaog Encoder Hookup Anaog Encoder Accuracy CURRENT SENSOR FEEDBACK SENSOR SELECTION SENSOR HOOKUP SETUP UNDER THE HOOD LIMITATIONS OVER CURRENT RESPONSE ADJUSTING THE CURRENT LIMIT THRESHOLDS TERMINAL EMULATOR CMD INTERFACE RS232 SETUP COMMAND SYNTAX (CMD D0 D1 DN) TERMINAL EMULATOR CMD CRIB SHEET TERMINAL EMULATOR COMMAND SPECIFICATION Cmd_A PWM Freq Contro Cmd_B Fan Contro Cmd_C Get AtoD Reading (mv) Cmd_D Set/Get RTC Cmd_E Get Motor Position Cmd_F Set Encoder Cmd_G // UNUSED // Cmd_H // UNUSED // Embedded Eectronics Page 2 11/9/2007

4 Cmd_I Reset Board Cmd_J IoExp Write Cmd_K IoExp Read Cmd_L Read Memory Bock (RAM OR EEPROM) Cmd_M Set Digita POT Cmd_N R/C Snapshot Cmd_O StopMotor(s) Cmd_P Set/Get PID Parameters Cmd_Q PID Step Response Cmd_R Read Memory Byte Cmd_S Move (Constant Veocity, Cosed-Loop) Cmd_T Trigger Move (Cosed Loop) Cmd_U Get Status Cmd_V Get Motor Veocity Cmd_W Write Memory Byte Cmd_X Move (Constant Power, Open-Loop) Cmd_Y Mtr Move (Cosed-Loop Contro) Cmd_Z Upoad To EEPROM POT MODE INTERFACE POT MODES POT CONNECTIONS ENABLING POT MODES IMPORTANT POT MODE PARAMETERS: R/C MODE INTERFACE RECEIVER CONNECTIONS RECEIVER OUTPUT SIGNALS R/C PWM MAPPING R/C TUNING Endpoint Adjustment At Transmitter: Endpoint Adjustment On Daf Board: R/C MODES SERVO MODES CLOSED LOOP OPERATION SERVO LIMITS CONNECTIONS POT SERVO MAPPING POT SERVO PARAMETERS R/C SERVO MAPPING R/C TUNING R/C SERVO MODE PARAMETERS TRAPEZOIDAL TRAJECTORY GENERATOR TRAJECTORY GENERATOR OVERVIEW TRAJECTORY GENERATOR DETAILS Trajectory Generator Timing Trajectory Setup Trajectory Routine TRAJECTORY GENERATOR CASES INTEGRAL WINDUP PID (CLOSED-LOOP) MOTOR CONTROL...84 Embedded Eectronics Page 3 11/9/2007

5 15.1 PROPORTIONAL-INTEGRAL-DERIVATIVE (PID) EQUATIONS PID MOTOR CONTROL TUNING FIRMWARE LIBRARY ROUTINES IOEXP FUNCTIONS WriteIOExp1, WriteIOExp ReadIOExp1, ReadIOExp DELAY AND TIMING FUNCTIONS GetTime SetDeay TimeOut EXTERNAL EEPROM FUNCTIONS WriteExtEE_Byte ReadExtEE_Byte WriteExtEE_Bock ReadExtEE_Bock INTERNAL EEPROM FUNCTIONS WriteIntEE_Byte ReadIntEE_Byte WriteIntEE_Bock ReadIntEE_Bock DIGITAL POT FUNCTIONS WritePot WritePot POTENTIAL FUTURE ENHANCEMENTS APPENDIX A - STEP RESPONSE EXAMPLES APPENDIX B - BOARD SCHEMATIC/LAYOUT APPENDIX C - BOARD PARTS LIST APPENDIX D - PARAMETER BLOCK DETAIL PARAMETER BLOCK TABLE PARAMETER BLOCK RECOVERY PARAMETER DESCRIPTIONS APPENDIX E - FIXED ADDRESS RAM VARIABLES Embedded Eectronics Page 4 11/9/2007

6 Warranty The software ibraries and toos are provided "as is" without warranty. The entire risk for the resuts and performance of these ibraries and toos is assumed by the purchaser. Embedded Eectronics LLC does not warrant, guarantee or make any representation regarding the use of this product. No other warranties are made, expressy or impied, incuding, but not imited to, the impied warranties of merchantabiity and suitabiity of products for a particuar purpose. In no event wi Embedded Eectronics be hed iabe for additiona damages, incuding ost profits, ost savings or other incidenta or consequentia damages arising from the use or inabiity to use Embedded Eectronics LLC products. Discaimers Embedded Eectronics LLC reserves the right to make changes without notice to this product. Changes made to improve reiabiity, performance, capabiities, design or ease of use, or to reduce size or cost coud effect documentation, hardware, and firmware. Any Embedded Eectronics LLC product may not be used as a component in ife support devices of any description. Copyright Copyright 2006 Embedded Eectronics, LLC. Software License The <main.c> and <daf.ib> fies provided on the CD for the purpose of encouraging additiona software deveopment are subject to a icense agreement expained in the End User License Agreement (EULA). The EULA fie is incuded on the CD that ships with the product and may aso be read on the EE Website Embedded Eectronics Page 5 11/9/2007

7 1 Motor Contro Board Overview This document describes the hardware and firmware features of the Daf-1 Motor Contro Board. [Board Size: 4.60 x 3.65 ] This board was designed as a dua motor controer for a reasonaby autonomous mobie robot (Daf) weighing approximatey 150 pounds. Daf is driven by a pair of PM brushed DC wheechair motors using a differentia drive arrangement. The board interfaces directy to a pair of eectronic speed contro (ESC) boards (Drivers) designed by the Open Source Motor Contro (OSMC) group (1), but the board can be used with other motor drivers that expect standard Signed Magnitude PWM motor contro inputs. Because of the abundant, accessibe I/O, arge memories, and the deveopment connector, the board is aso quite suitabe for a PIC based deveopment patform or for other, non motor contro, appications. A of the features described in this manua come preprogrammed in the non-voatie memories for the PIC18F6722 (FLASH) and 24LC512 (EEPROM) parts. Assembed and tested boards are avaiabe for purchase thru reseers. The PC board design and much of the software is provided as open source. The board comes with a CD containing documentation, a ibrary fie, and C source for the main oop. The ibrary provides functions caabe from either PIC Assember or C. Incuded in the ibrary are routines to access a of the on board parts. Sufficient detai is provided to make most of the firmware design and functionaity transparent and extendabe. See the appendices for the board schematic, board ayout, and parts ist. Embedded Eectronics Page 6 11/9/2007

8 (1) - The OSMC boards are reiabe, high power, PM DC motor contro drivers. They require PWM drive and other contro signas to be suppied externay thru an on board connector. The OSMC boards with compete specifications are avaiabe from Robot Power (robot-power.com). The Daf Board and buit-in firmware maintain motor position and veocity information based on the inputs from standard optica incrementa motor encoders. Optionay, anaog encoders can repace the optica encoders in some designs. Over current response to off board sensors is immediate (interrupt driven) and the over current threshods are digitay adjustabe. Hardware to drive a pair of off board fans, or other high current devices is provided. The board is configurabe to accept motor contro commands from off board potentiometers, R/C, or one of severa seria command interfaces. Severa Open-Loop motor contro modes, as we as a robust Trapezoida Generator and PID combine to provide Cosed-Loop motor contro operation. Cosed-Loop move-to-position commands support both reative and absoute targets for the move destination. The trigger mode option can provide synchronized motor movements. Cosed-Loop constant veocity is supported for appications that require constant veocity under varying oad conditions. Servo modes (cosed oop) may be used to contro motor position with R/C or off-board potentiometers. Pot and R/C interfaces (open oop) may be used to contro motor veocities. The three channe R/C interface provides both tank and mixed operating modes. Adjustabe sew rate contro for both open and cosed oop commands provides smooth motor veocity transitions. Three different, seria command interfaces are provided to contro a board features. TE - Termina Emuator (RS232) API - Appications Programming Interface (RS232) I2C2 - Secondary I2C interface (second of two I2C interfaces) The RS232 interfaces utiize the primary COMM channe, a standard modem cabe, and a PC Appication. The TE interface empoys a standard termina emuator appication ike Hyperterm or Teraterm running on the PC to issue commands and receive and dispay data. This interface provides the means to test a motor features and to customize motor contro operations for the other operating modes. The API empoys the same connector and cabe and is used for simiar operations, but is designed for a smart PC appication ike a Windows GUI (A Windows GUI is under deveopment). The I2C2 interface utiizes a 3-wire (optionay 4) cabe and the I2C2 screw termina connectors to provide a command interface to an externa board. The Daf Board is configured as an I2C SLAVE device on the I2C2 interface, accepting commands and deivering data and status to the externa device configured as the MASTER. The API and I2C2 interfaces are described in separate documents. Non voatie storage of motor, motor encoder, and operating mode configuration information is provided via a Parameter Bock within the seria I2C EEPROM. The board has ots of unused I/O which is routed to connectors for off board use. Anaog inputs, GPIO pins, interrupt capabe inputs, a power suppy On/Off switch, and 32 GPIO ines from I/O Expander parts are exampes. The second (unused) USART (COMM2) is routed to pads for either eve shifted or +5V operation. Severa screw termina connectors provide +5V and GND for BEC usage. The primary I2C bus is configured as a MASTER and used for on board device communication, but both the primary and secondary I2C buses are routed to connectors for potentia off board communications usage. The firmware is efficient. A time critica operations are impemented with PIC assember and a operations except the primary I2C access are interrupt driven as opposed to poed. The buit-in interrupt and command handers are written in PIC Assember for efficiency. The main oop and the interrupt dispatcher are written in C. This design, with the provided C source code and PIC ibrary fie, makes for easy customization of the main oop or repacement of the existing interrupt handers. Embedded Eectronics Page 7 11/9/2007

9 The <daf.ib> firmware ibrary provides routines, caabe from C or PIC Assember, that provide access to board features. Some exampes are READ, and WRITE functions to provide access to the I/O extender parts, interna EEPROM, externa EEPROM, and RAM. WRITE functions provide access to set the write ony digita pots on the I2C bus. A I2C access is provided at the device eve which means that you don t need to be aware of I2C bus detais to access and contro the parts. Access to a on-board devices is aso provided thru commands in the seria interfaces. A boot oader appication <p1618qp.exe> that runs on your PC is provided on the CD. When used in conjunction with the boot oader firmware maintained in the boot bock of fash program memory and the PGM Switch on the board, it aows firmware updates to be downoaded from your PC and fashed into the microcontroer. 2 Deveopment History 2.1 Board Deveopment 08/28/2004: Versions (1A, 1B) The first two versions of the Daf-1 board used the Microchip PIC16F777 microcontroer and many of the features described in this document were fuy functiona in the 1B revision. The 8K x14 bits of fash and 384 bytes of RAM provided by the midrange 777 part were pretty much fuy used up. The firmware was a written in PIC Assember and the part was cocked by an externa 20MHz resonator (5MIPS). 01/29/2005: Version 1C A fairy major redesign using the high end PIC18F6720 micro running at 25MHz (6.25MIPS) provides generous margins (RAM, FLASH, and EEPROM) for additiona features. Starting with the 1C board, the code is a mix of C and PIC Assember aowing faster deveopment and easier customization. 08/18/2005: Version 1D This version provided a shrink of the 1C board and a few additiona features. 02/24/2006: Version 1E This version repaces the PIC18F6720 micro with the foow on micro PIC18F6722. This part runs at 40MHz (10MIPS) and adds the secondary I2C bus. The MCP23016 parts are repaced with the improved MCP23017 parts. Manua trim pots (for over current detection) are repaced by digita pots accessed using the primary I2C bus. Most thru-hoe R and C components are repaced with surface mount parts. 03/15/2006: Version 1F First board manufactured for production. Revisions incude addition of pads for no-oad parts and some minor routing improvements. Incuded are: a jumper for usage of the second seria port at ogic votage eves, pu-ups for some unused GPIO s, and votage divider resistors for possibe use with off board thermistors. 2.2 Firmware Reeases 09/11/2006: Version 1.40 First reease for production. 11/30/2006: Version 1.50 Second production reease 06/09/2007: Version 1.60 Third production reease Embedded Eectronics Page 8 11/9/2007

10 2.3 Documentation 9/11/2006: Documentation for the Version 1.40 Firmware Reease Owner s Manua (Ver 0.29) Getting Started Manua (Ver 0.05) I2C2 Interface (Ver 0.02) API Interface (Ver 0.09) 11/30/2006: Documentation for the Version 1.50 Firmware Reease Owner s Manua (Ver 0.30) Getting Started Manua (Ver 0.06) I2C2 Interface (Ver 0.03) API Interface (Ver 0.10) 06/09/2007: Documentation for the Version 1.60 Firmware Reease Owner s Manua (Ver 0.32) Getting Started Manua (Ver 0.07) I2C2 Interface (Ver 0.04) API Interface (Ver 0.11) Getting Started Manua This document describes hook ups, board configuration using a termina emuator appication, and genera user interface information. More compete information can be found in the Owners Manua, but this is the right pace to start. Owner s Manua This document describes a features in detai. References to the separate API and I2C2 documents provide the detai for those features. API Interface This document describes a seria (RS232) protoco suitabe for communication with the Daf Board by a smart PC Appication ike a Windows GUI. I2C2 Interface This document describes a seria (I2C) protoco suitabe for communication with an I2C MASTER. Updated documentation is maintained at 3 Operating Modes (CMD, POT, R/C, RCSVO, POTSVO) To say that the firmware provides these 6 operating modes (and a few sub-modes if you count R/C mixing and different pot modes) is a bit miseading. The reason is that most features of the Cmd Interfaces (TE, API, and I2C2) using the seria inks can aso be used in the other contro modes. For exampe, you can use the seria ink to monitor motor speed and position whie controing the motors with pots or an R/C ink. The TE, API, and I2C2 seria command Interfaces a have simiar command sets and functionaity. The TE and API utiize the same hardware interface (seria port; RS232), but the software communication protoco is quite different. Separate documents describe the API and I2C2 Interfaces in some detai. Throughout this document, references to the Cmd Interface refer expicity to the TE Interface, but the genera content wi often appy to a three seria interfaces. The operating mode is specific to each Embedded Eectronics Page 9 11/9/2007

11 motor. This means, for exampe, that there is nothing to prevent contro of one of the motors with a POT and the other with an R/C channe. For a given motor, motor movement commands may generay come from ony one source. For exampe, whie operating a motor using the R/C Interface, an attempt to simutaneousy contro the motor by issuing a motor movement command over a seria command interface wi be ignored (except for the STOP command!). A modes provide for an adjustabe sew rate and the sew rate parameter is customizabe. Even if your ony interest is the POT or R/C contro modes, the CMD interface is necessary for initia configuration. Motor Contro Modes: Mode Contro Type Required Externa Resources TE - CMD (RS232) Both PC + Termina Emuator Appication + standard seria cabe API - CMD (RS232 ) Both PC + Smart PC Appication + standard seria cabe I2C2 - CMD (I2C) Both MASTER Appication + 3 wire cabe (SCL,SDA,GND) POTF - Fu Range Open Loop POT1, POT2, ON/OFF# switch, FWD/REV# switch POTC - Center Zero Open Loop POT1, POT2, ON/OFF# switch PITMIX - Pot Mix Open Loop POT1, POT2, ON/OFF# switch POTSVO - Pot Servo Cosed Loop POT1, POT2, ON/OFF# switch, motor position encoders RCNRM - R/C Norma Open Loop Transmitter, Receiver RCMIX - R/C Mixed Open Loop Transmitter, Receiver RCSVO- R/C Servo Cosed Loop Transmitter, Receiver, motor position encoders The board powers up in a mode determined by vaues stored in the Parameter Bock of non-voatie memory. Factory defauts stored in this parameter bock may be customized using any of the seria mode interfaces. The factory defaut is to power up in TE command mode (R/C and POT modes disabed). This means that the ony means of controing the motors initiay is thru one of the seria interfaces. Generay the TE interface wi be used for board configuration, but a soon to be reeased Motor Contro Graphica User Interface (GUI) wi offer a more user friendy aternative in the form of a Windows Appication. See the section in this manua abeed Customization and Configuration for a discussion of the Parameter Bock and how it may be used to configure operations. 3.1 TE INTERFACE The TE command monitor runs over an RS232 ink to a PC (running Hyperterm, TeraTerm, or some other termina emuator appication) and is a good way to test and demonstrate most board features. You shoud become famiiar with this interface even if you pan on using one of the other interfaces for motor contro because it provides commands for features such as PID Tuning, R/C Switch Tuning, Operating Mode Seection, etc. Other features incude A/D Snapshot which can be used to verify correct POT operation, R/C Snapshot which shows actua puse measurements on each of the R/C channes, Cosed Loop (PID + Trajectory Generation) motor contro, EEPROM and RAM access, and much more. The command monitor aso provides the means for customizing vaues in the Parameter Bock which (among other things) determine the power up operating mode of the board. See the chapter Termina Emuator CMD Interface for a thorough discussion and isting of a commands. 3.2 API INTERFACE The API command monitor runs over an RS232 ink to a smart PC Appication such as a Graphica User Interface (GUI). A Windows GUI for communication with the Daf Board is under deveopment. Check the website for status on the GUI. The command set and capabiities of the API Interface are simiar to the TE Interface, but the communication protoco is quite different. Commands and command arguments are Embedded Eectronics Page 10 11/9/2007

12 passed in binary to the board from the PC Appication via message packets. Simiary, data and status are returned to the PC Host Appication with message packets. A packets have check sums to verify data integrity. A compete description of the protoco, packet format, error handing, and possibe future use for networking appications is described in the separate API Interface document. 3.3 I2C2 INTERFACE The I2C2 interface runs on the Secondary I2C Bus provided by the PIC and reies on an appication running on an off-board device to deiver commands and request status. The off-board device wi be configured as a MASTER and hosts the bus, whie the Daf Board is configured as a SLAVE device at an I2C address that is specified in the Parameter Bock (defaut 0x60). The 2-wire connections (pus GND) are made using the provided screw terminas. The Daf Board suppies the required pu-up resistors (2.7K) for this bus, but these may be removed if the pu-ups are instead suppied by the MASTER device. The Daf Board is capabe of I2C communications at the FAST rate (400 KHz). The command set and capabiities of the I2C2 interface are simiar to that of the TE Interface, but as with the API, the communication protoco is quite different. Commands and command arguments are passed to the board from the Host Appication via message packets (a somewhat reduced version of the API packets). Simiary, data and status are returned to the Host Appication with message packets. A packets have check sums to verify data integrity. A compete description of the protoco, packet format, and error handing is described in the separate I2C2 Interface document. 3.4 POT INTERFACES Two open oop pot contro methods (POTC, POTF) and one cosed oop contro method (POTSVO) are provided by the firmware. A three modes empoy externa potentiometers (one for each motor) and an On/Off switch for safety (POTF requires an externa switch for directiona contro). The switches shoud be SPDT (or SPST + pu down) and the POTS shoud not exceed 2K Ohms. POTC and POTF modes contro veocity and motor direction, whie POTSVO is a cosed oop method that maps the pot setting to a motor position ( Giant Servo ) using either optica or anaog encoders for motor feedback. See the sections of this document devoted to using the POT Modes for additiona detais. 3.5 R/C INTERFACE (3 CHANNELS) Two open oop R/C contro modes (RCNRM, RCMIX) and one cosed oop contro method (RCSVO) are provided by the firmware. Each of the two open oop modes use just 2 of the 3 avaiabe R/C channes to contro motor veocity and direction. Channe 3 is currenty unused but the firmware sti measures and converts the puse width for a three channes, so the hardware and firmware structure is in pace to easiy use the third channe for another R/C contro appication. If you decide to use channe 3 you may want (for safety) to incude it in the signa oss detection function aong with channes 1 and 2. The third R/C contro mode is RCSVO which maps the R/C transmitter switch to motor position ( Giant Servo ). See the sections of this document devoted to using the R/C Interfaces for additiona detais. 3.6 OTHER INTERFACES There is an additiona seria interface that can be deveoped without board changes: RX2/TX2: The second USART on the PIC18F6722 is currenty unused(*), but is eve shifted and routed to a 3-pin header JP1: [T2OUT, GND, R2IN] on the board. There is aso a provision to use this second seria channe with +5V TTL eves. A separate 3-pin header JP2: [TX2, GND, RX2] provides for this possibe use. See schematic for detais. (*) - This interface coud be deveoped in a future firmware revision. Embedded Eectronics Page 11 11/9/2007

13 4 The DALF-1 Board Detai The board is designed around the PIC18F6722 microcontroer running at 40MHz (10MIPS). This board features ots of avaiabe I/O routed to screw terminas and ribbon connectors for easy access. Some of the IO is dedicated to supporting off board features, but there is a ot of unused I/O for customization. This incudes anaog inputs, interrupt inputs, GPIO s directy from the microcontroer, and 32 GPIO s provided by I2C I/O expanders! 4.1 Partia Feature List Dua open oop motor contros via R/C, Pots, or Seria Interfaces. Dua cosed oop motor positiona and veocity contros via R/C, Pots, or Seria Interfaces. PID and Trajectory Generator empoyed for smooth veocity ramping in cosed oop contros. Standard quadrature encoder inputs (2 motors) aow maintenance of position and veocity. Anaog motor position feedback supported for some appications. Giant Servo mode using either Pot or R/C as inputs. Digitay adjustabe votage windows and interrupt handers for fast over current response when used with off board current sensors. Support for PID Tuning via data capture using the Step Response Command. Adjustabe Sew Rate for a motor contro methods. Seria EEPROM (64K bytes) as we as interna EEPROM (1K bytes) for non-voatie storage. Parameter Bock in EEPROM for customization of motor characteristics, operating mode, etc. Buit in three channe R/C interface with optiona mixing for open oop contro. Two buit in potentiometer motor contro methods for open oop contro. Termina Emuator command ine monitor using RS232 Channe 1. API cmd and monitor Interface using RS232 Channe 1 for use by a smart PC Appication. (*) I2C2 cmd and monitor Interface using secondary I2C Bus for use by a MASTER host Appication. A features interrupt driven for efficiency. Robust 5V power suppy, with externa On/Off switch, provides ampe power for BEC. RTC for timing and scheduing. Both primary and secondary I2C buses routed to connectors for potentia off board use. Second RS232 interface (Channe 2; currenty unused) routed to header. Firmware is updatabe via a boot bock oader using a seria cabe to a PC. On board connector for additiona code deveopment using standard Microchip toos. Libraries of routines <daf.ib>, caabe from C or PIC Assember, and the source code for the main oop and interrupt dispatcher <main.c> provide support for customization and enhancements. Lots of head room for code expansion both in Fash and RAM memories. Lots of unused I/O: unused GPIO s from IO Extenders on the primary I2C bus (or 5 w/o use of POT Modes) unused digita I/O s from the micro (or 4 w/o use of R/C Modes) unused interrupt inputs (or 6 w/o use of POT Modes) unused anaog inputs. (*) - A Windows GUI is under deveopment. Check the website for status. One nice feature of the GUI is that it provides an aternative to the use of a termina emuator for the board setup task. Embedded Eectronics Page 12 11/9/2007

14 4.2 Power Suppy The board provides a +5V suppy (VDD) derived from a VBATT DC source that may be in the range of [+8V +40V]. The switch mode power suppy, based on the LM2672 part, provides up to 1 amp at VDD=+5V. This is a robust suppy that provides significanty more power than is required by the board. As a resut, a significant portion of this power (at east 500 ma at +5V) is avaiabe for off board functionaity thru a battery eiminator circuit. It may be used to provide +5V power for an R/C receiver. A resistor divider from VBATT to ground is routed to a dedicated anaog input pin on the micro to provide VBATT monitoring capabiity. A caibration parameter is provided in the Parameter Bock to tune the measured vaue to compensate for the actua vaues of the resistor divider pair. A connector for an externa switch (SPST) is provided which may be utiized to turn off the power suppy. To use this feature, just wire the switch terminas to the screw termina pair abeed [GND OFF#]. When the OFF# input is grounded, the power suppy is disabed. When the OFF# input is disconnected, the suppy output is enabed. It is sometimes necessary to add a sma oad resistor (270 Ohms) between VDD and GND to get a cean reset signa to the PIC microcontroer when using this feature. For those using this board with the Microchip deveopment toos (ICD2), the board may aternativey be powered thru the moduar 6-pin programming/debugging connector. When using the ICD2 to power the board, a switch is provided to isoate the oca suppy and an LED indicates the switch position. 4.3 PIC18F6722 Microcontroer The microcontroer is the Microchip PIC18F6722 part. This is a 64 pin part provided in a TQFP package. The data sheet avaiabe from the Microchip website provides extensive detai on the part features, but here is a brief summary: 64K instruction words (128K bytes) provided in the on-board fash program space 3,936 bytes of RAM 1K bytes of buit-in EEPROM. 7 I/O ports with 12 A/D inputs. 5 CCP Modues (Capture/Compare/PWM) 5 genera purpose timers, 1 watchdog timer. 2 USARTS 2 I2C Modues This microcontroer permits severa osciator options incuding an interna, tunabe, osciator. Ony the externa osciator option is supported on the Daf-1 board with the design assuming an externa osciator running at 40 MHz to derive the system cock (fosc= 40 MHz). The system cock is divided by 4 to obtain the instruction cock frequency (fosc/4 = 10 MHz). As most instructions execute in one cyce, this provides an instruction rate cose to 10 MIP s. The board aso uses an externa khz crysta as an input for the 32-bit Timer1. The firmware uses Timer1 to support a RTC as we as timed deay routines. 4.4 Motor Driver Connection This section describes the connections to a Motor Driver ike the OSMC ESC board. The discussion here is targeted specificay for OSMC Drivers, but the content (eg; pinouts) is needed for connection to other drivers as we. There are two 10-pin connectors (PL1, PL2) on the Daf board suitabe for direct connect to the corresponding connectors on two OSMC boards using a standard 10 pin ribbon cabe. The cabe connects the 10 pin OSMC connector (CN5) and the corresponding 10 pin connector (PL1 for Motor1, PL2 for Motor2) on the Daf-1 Board. Embedded Eectronics Page 13 11/9/2007

15 The foowing tabe shows how the OSMC signas are used on the Daf Board: PIN# OSMC Signa (CN5) Daf Signa (PLx) Comment (pwr) 12V_x ;x=1,2 (pwr) Optiona fan driver pwr (pwr) 12V_x ;x=1,2 (pwr) 3 VBATTDIV (out) NC Unused 4 DISABLE (in) DISx ;x=1.2 (out) Disabe Motor Drive 5 AHI (in) 12V_x ;x=1,2 (pwr) Pued High 6 ALI (in) PWMx ;x=1,2 (out) Motor Speed Contro 7 BHI (in) 12V_x ;x=1,2 (pwr) Pued High 8 BLI (in) DIRx ;x=1,2 (out) Motor direction 9 GND (pwr) GND (pwr) 10 GND (pwr) GND (pwr) In the tabe, x stands for motor#. For exampe, the DISABLE pin on the OSMC board controing Motor1 is attached to the DIS1 ine on the Daf Board. The reguated +12V output from the OSMC board is used to tie the AHI and BHI ines high thru the ribbon cabe attachment on the Daf Board. The +12V suppy from the OSMC board is aso used to suppy fan output power on the Daf board. The outputs from the OSMC boards are kept separate on the Daf Board, hence there are +12V_1 and +12V_2 signas. The VBATTDIV output from the OSMC board is not used. The three main motor contro outputs from the Daf Board to the OSMC board are DIR (direction: 0=Fwd, 1=Rev), PWM (speed governed by Duty Cyce), and DIS (disabe: 0=Enabed, 1=Disabed). DIS=1 wi disabe motor output from the OSMC board regardess of the other parameters. PWM Compement Trick The H-bridge driver (HIP4081A) on the OSMC board aows motor direction reversa without the necessity of externa ogic to switch the PWM input to different egs of the drive FETs. The Daf firmware, by defaut, uses a trick to take advantage of this feature. If your motor driver is not the OSMC product, you may need to disabe the trick which is controed by the osmc bit setting in the Parameter Bock. osmc= 1 This is the correct setting for the OSMC Motor Drivers. With this setting, to accompish a move in the REV direction with a speed corresponding to a PWM duty cyce of 70%, the DIR ine is driven hi, and the duty cyce is set to =30%. The firmware takes care of the duty cyce reversa detais, so if the desired speed corresponds to a PWM duty cyce of 70%, the input is 70 regardess of motor direction. This trick is enabed for both motors by defaut ( osmc1=osmc2= 1 ), but can be disabed by changing the parameter (for the motor in question) in the Parameter Bock. osmc= 0 Many non-osmc motor drivers don t require the trick and wi require the osmc bit to be ceared for correct operation. With this setting, to move in the REV direction with a speed corresponding to a PWM duty cyce of 70%, the DIR ine is driven hi, and the duty cyce is set to 70%. You can easiy determine what your driver expects by using the command interface to drive the motor sowy in reverse. If it goes fast instead, you wi need to change the setting of the osmc bit in the Parameter Bock. A note about MTR1 and MTR2 LED s: These non programmabe, Bi-Coor LED s, are connected between the PWM and DIR signas to indicate motor direction and speed. Forward direction produces green, and reverse red, with LED intensity corresponding to speed. If your motor driver requires the osmc= 0 setting, the LED intensity vs. speed reationship, for reverse direction ony, wi be reversed (that is; dim red wi correspond to high reverse speed, whie bright red wi represent ow reverse speed). Embedded Eectronics Page 14 11/9/2007

16 A note about DIS poarity: If you are using a motor driver other than the OSMC and it requires the DIS ine to be asserted LO (that is; motor disabed whenever DIS = 0 Vots), you wi need to set the dis_activeo bit in the appropriate MODE byte in the Parameter Bock. This wi reverse the norma, defaut, poarity of the DIS signa to accommodate your driver. 4.5 RS232 The board provides a DSUB9 connector for an RS232 Interface to support a Command Line Interface to a Termina Emuator Appication running on a PC. The required RS232 eve shifting is achieved with the MAX233 part. If you have a PC running Windows, you probaby have the Hyperterm appication which is generay suppied as part of a Windows OS. Aternativey you can downoad TeraTerm (free) from the web. Personay, I ike TeraTerm better than Hyperterm, but either wi work fine and they are both easy to configure: the defaut communication parameters are: 19,200 baud, 8 data bits, 1 stop bit, and no parity. The baud rate can be changed after powerup - see the nbr parameter in the Parameter Bock. The command interface aows you to easiy contro the motors and obtain motor status from your PC. The command interface has many other uses as we incuding the abiity to directy access (read/write) the RAM and specia function registers (SFR s) that contro the processor periphera modues. The hardware (MAX233 and PIC18F6722) provide a second (currenty unused) RS232 channe. This second channe is made avaiabe either eve shifted or at +5V TTL eves by routing the signas to 3 pin headers JP1, JP2 (note usage of R1 in the schematic). 4.6 Externa EEPROM/Parameter Bock The Daf board provides 2 separate non-voatie memories. The argest of these is a 64K Byte I2C seria EEPROM (24LC512) device mounted on the board. The ow order address pins for this EEPROM part are tied to GND creating an I2C bus address of: 0xA0. The write access to this part provides for both a singe byte write as we as a 128 byte page write. With either a singe byte write, or a page write, there is a 5 msec write cyce deay after sending the ast byte before the device can again be accessed. The Parameter Bock occupies the first 0x80 (128) bytes of this EEPROM and provides for non-voatie storage of motor parameters et a. The contents of the Parameter Bock are expained in detai in the appendix. A that you need to know at this point is that: (1) During power-up, the vaues in the Parameter Bock are copied to the ERAM portion of RAM, estabishing the Runtime Environment. This run-time environment is then used by the system initiaization code to configure and initiaize the various devices (eg; PWM frequency, A/D behavior, PID parameters, operating mode, etc.). (2) Any vaue in the Parameter Bock may be changed to affect the run time environment on a subsequent power-ups and there is more than one way to do this. See the Command Section and Appendix D for detais. In addition, if you mess up and ater the data in the Parameter Bock in such a way that you can t power-up ceany with the resuting run-time environment, there is a mechanism invoving use of the push-button BTN to restore the origina factory defaut data to the parameter bock. You may aso change vaues in ERAM directy using the Write Memory Byte Command. Changes to ERAM affect the current session ony and some changes wi affect behavior immediatey. This is convenient for exampe during PID motor tuning. Embedded Eectronics Page 15 11/9/2007

17 4.7 Interna (Buit-In) EEPROM The second non-voatie memory is provided by a 1K Byte EEPROM buit into the PIC18F6722 microcontroer. This memory is accessibe thru the command interface and ibrary routines, but is currenty unused. Like the externa eeprom, there is a write cyce deay. 4.8 Fan Driver Outputs The Daf Board has 2 high current outputs capabe of driving cooing fans or other inductive type oads. If you are using OSMC Driver Boards, these come with PM DC brushess cooing fans. Each fan is rated at +12V, 170mA and may be connected directy to the OSMC board in which case it wi aways be on. The Daf Board outputs provide an aternative connection for the fans aowing them to be controed by the PIC processor. For each fan, the board provides: drive circuitry via an NPN 2N2222A transistor, base resistor, free wheeing diode, and a two pin screw termina connector. The power source is routed from a pin on the 10-pin PLx connector and wi be +12V if you are connected directy to the OSMC board thru the ribbon connector. Individua fan on/off contros are routed from the PIC to the base of the drive transistors. See the command interface for detais of fan contro. There are a coupe of noteworthy things to mention here about the fan drivers: 1) They may be used for other, high current, inductive oad, appications. If you are not using the OSMC drivers, you can sti use the Fan Driver Outputs, but you wi have to provide your device suppy votage on the appropriate PLx pin. You shoud review the schematic, the PLx connector pinout, and the transistor specification to ensure that this wi be suitabe for your appication. 2) If used for fan contros, they aren t much use without temperature sensing. The firmware does not provide temperature sensing, but I have provided a coupe of ideas beow that don t require board modification to achieve it. Both of these temperature soutions wi require you to write some code. Temperature Sensing Suggestions: The board provides pads (schematic: RT1, RT2) for a pair of thru-hoe 10K resistors (not oaded) tied between VDD and anaog inputs (AN4, AN5). Add the RTx resistor and mount an off board 10K NTC thermistor on the temperature source (eg; drive FET) with outputs routed to GND and the corresponding anaog input on the Daf Board. The A/D reading of this votage divider wi routiney be captured and stored by the existing firmware. The vaues stored wi be a reasonaby inear votage response versus temperature. Aternativey, use I2C temperature sensors and connect the eads to the screw terminas for the primary I2C bus. Write code to access the sensors as I2C save devices. 4.9 EX0, EX1, EX2, EX3 A of these signas are connected to interrupt capabe inputs on the PIC microcontroer. They can a be used for standard GPIO s, or genera purpose interrupts. EX0, EX1 and EX3 have additiona capabiities because they are connected to CCP (Capture/Compare/PWM) microcontroer pins. With a bit of programming on your part, the signas on these pins can be quite versatie. Each of the EX0, EX1, and EX3 signas can become PWM outputs, or they can operate in capture mode to get accurate signa timing on the input, or they can generate outputs with accuratey controed timing. The defaut firmware uses EX0, EX1, and EX3 in capture mode for puse width detection to support a 3 channe Radio Contro Interface. EX2 is connected to the KBIO pin on the PIC and has interrupt-on-change capabiity, but is currenty unused. Embedded Eectronics Page 16 11/9/2007

18 4.10 A/D Inputs The firmware enabes 7 of the A/D inputs on the PIC processor (AN0 AN5, AN6). An externa connector routes [AN0 AN5] thru RC fiters to the A/D input pins. The dedicated AN6 anaog input monitors the battery (VBATT) votage. An optiona, configurabe, ow pass, digita recursive fiter can be appied to any of the raw A/D inputs - See the FENBL and DECAY parameters in the Parameter Bock. A mechanism using a hardware timer and an interrupt driven state machine is provided by the firmware to cycicay sampe and store the A/D readings in RAM without the use of software deays. The timing for the acquisition, conversion, and between -channe-deays for the signas is controed by 3 vaues in the Parameter Bock - see AD_ACQ, AD_CNV, and AD_GAP in the Parameter Bock. A snapshot of the A/D readings can be viewed thru the command interface at any time. With the defaut timing vaues in the Parameter Bock, the sequence of 7 readings competes in a bit ess than 5 msec (about 220 times a second). Because the design is interrupt driven, the actua number of CPU cyces devoted to the A/D processing is sma. When externa pots are used for open oop (POTF, POTC) or cosed oop (POTSVO) contro of the motors, 2 of the anaog inputs [AN0, AN1] are dedicated to provide the motor contro input signas for motor1 and motor2 respectivey. The midde pins (wipers) of the externa pots are routed to the AN0 and/or AN1 screw termina inputs. If anaog feedback is used in pace of optica encoders for motor position, 2 of the anaog inputs [AN2, AN3] are dedicated for motor1 and motor2 position feed back respectivey. If you wi be using one of the pot motor contro methods, see the discussion on Pot Contro Modes and the usage of the variabes PMSP and AMINP Over Current Sense The Daf Board provides hardware and firmware support for over current detection and response when used with compatibe off board sensors. Two different, buit-in, responses are possibe if your appication needs over current protection. See the section Current Sensor Feedback for detais Position Encoder Inputs The Daf Board has buit-in support for use of either standard optica incrementa motor encoders or absoute anaog encoders for use in sensing the output shaft position. If you don t have motor encoders, the PID, Trajectory Generator, and cosed oop operations wi not be avaiabe to you. However, ack of encoder(s) wi not keep you from controing the motors in open oop modes with R/C, pots, or the seria interface(s). The encoders may be mounted directy on the motor shaft or downstream after a gear reduction. If your appication wi use encoders you shoud study the section Motor Encoder Feedback in this manua which discusses the detais of usage, hookup, and imitations of encoders. Depending on the type of encoder, the hookup is different. For optica encoders the board provides two 5- pin screw termina connectors (VDD,GND,A1,B1,Z1), (VDD,GND,A2,B2,Z2) - one connector for each motor. For anaog encoders the board provides (VDD,GND,AN2) screw terminas for motor1 and (VDD,GND,AN3) for motor2. Any avaiabe VDD and GND terminas may be used for anaog encoder hookup, but it probaby makes sense to use those provided for the optica encoders since they won t be otherwise used. Embedded Eectronics Page 17 11/9/2007

19 4.13 I2C Communication The board provides two 4-pin connectors (+5V, GND, SDA, SCL) for off board communication using either the primary or secondary I2C busses. The I2C Interface deveoped by Phiips may be used to communicate with a variety of periphera devices (LCD s, EEPROM s, Extended I/O Devices, Smart Batteries, Microcontroers, Temperature Sensors, navigationa sensors, et a.). The primary I2C bus (SD1, SC1) connects the micro to the on-board devices in a MASTER/SLAVE configuration running at a cock rate of 400 KHz. The tabe beow describes the I2C SLAVE devices on the primary I2C bus. Address Device Access Description 0xA0 IC4-24LC512 R/W 256 KByte EEPROM 0x42 IC7 - MCP23017 R/W IOEXP1 0x40 IC8 - MCP23017 R/W IOEXP2 0x52 IC9 - MAX5478 W 50K Digita Pot1 0x50 IC10 - MAX5478 W 50K Digita Pot2 Access to the parts is provided thru ibrary routines and the CMD Interface. The 7 high order bits of the address are the actua I2C device address. Bit 0 of the address is the read/write# contro (R/W#). The secondary I2C bus (SD2, SC2) is configured so that the PIC18F6722 microcontroer is a SLAVE Device, aowing an off board MASTER Device to host this I2C Bus. The Master issues commands and receive status from the Daf Board. This interface is described in more detai in the I2C2 Interface document I/O Expanders The board has two I/O Expander Parts (MCP23017) which provide a tota of 32 configurabe GPIO s for potentia off-board use (sensors, memory, ed s, or whatever). The 16 GPIO signas from each device are routed to 16-pin ribbon connectors (J5 and J6) and accessed by reading and writing registers on the I2C device. Each GPIO pin can be configured as either input or output with a drive eve of 25 ma, but the device has a tota current imit of 200 ma which must be observed. The firmware and the board routing does not support the interrupt on change feature of these parts. Device eve read/write operations can be performed thru the command interface and ibrary functions. J5 and J6 Connector Pin-Outs: Connectors J5 and J6 have identica pin-outs as described beow. Pin 1 is ceary marked on the board ayout, but is unfortunatey covered by the connector on an assembed board. Note that the ow order bits of PortA and PortB are at diagonay opposite corners of the connector. Embedded Eectronics Page 18 11/9/2007

20 Pin# Name 1 GPIOA.0 2 GPIOA.1 3 GPIOA.2 4 GPIOA.3 5 GPIOA.4 6 GPIOA.5 7 GPIOA.6 8 GPIOA.7 9 GPIOB.7 10 GPIOB.6 11 GPIOB.5 12 GPIOB.4 13 GPIOB.3 14 GPIOB.2 15 GPIOB.1 16 GPIOB Connectors The board provides the foowing connectors (Listed ogicay rather than iteray (eg; the 4 pin Interrupt connector and 4 pin I2C connector ive on a singe 8-pin connector). In addition see the pads provided for the 2 nd USART Interface and the TP2 pad. PortD: [D0 D3] Extended I/O 1: [Y0 Y15] Extended I/O 2: [X0 X15] Externa Interrupts: [EX0 EX3] I2C_1: [GND, VDD, SD1, SC1] I2C_2: [GND, VDD, SD2, SC2] ICD2 (moduar connector for deveopment/debug): [MCLR#, VDDEXT, GND, PGD, PGC,NC] DSUB9 (cmd interface and bootoader): [ GND, T1OUT, R1IN,..] Anaog: [AN0 AN5] PL1 (Motor1 Contro): [, PWM1, DIR1, DIS1, +12V_1, GND ] PL2 (Motor2 Contro): [, PWM2, DIR2, DIS2, +12V_2, GND ] PwrSuppy (On/Off): [GND, OFF#] Current Sense1: [GND, VDD, IS1] Current Sense2: [GND, VDD, IS2] Quadrature Encoder1: [GND, Z1, A1, VDD, B1] Quadrature Encoder2: [GND, Z2, A2, VDD, B2] Fan1: [F1-, F1+] Fan2: [F2-, F2+] 4.16 LEDs There are a tota of 8 LED s on the Daf-1 board. Three of these are programmabe as indicated in the foowing tabe. Embedded Eectronics Page 19 11/9/2007

21 Name Programmabe? Usage Coor MTR1 No Motor1 Speed & Direction Bicoor: RED/GRN MTR2 No Motor2 Speed & Direction Bicoor: RED/GRN PWR No VDD Indicator RED PGM No Boot oader mode active YEL (normay off) ICD No Powered by ICD2 YEL (normay off) LED1 Yes Motor 1 Status GRN LED2 Yes Motor 2 Status GRN LED3 Yes Error Indicator RED LED1, LED2, and LED3 are programmabe with different bink patterns to indicating status. LED State Usage LED1 (Mtr1) LED2 (Mtr2) LED3 (Error) OFF FAST BLINK SLOW BLINK FULL ON OFF FAST BLINK SLOW BLINK FULL ON No Pwr Pwr, TGA active Pwr, TGA inactive, Ve>0 Pwr, TGA inactive, Ve=0 (sta) No Error Over current (possiby transient) R/C signa oss (possiby transient) Low Battery (VBATT < VBWARN) 4.17 Switches PGM - This switch puts the firmware in boot oader mode on power-up. This is used ony to downoad and fash an image using the seria modem ink to a PC. The PGM LED wi be on whie the boot oad mode is active. In the norma (non boot oad) mode of operation, this switch wi force the PGM LED to be off. ICD - This switch isoates the oca +5V power suppy from the +5V power suppied by the ICD2 too used during code deveopment/debug. The ICD LED wi be on to indicate when the ICD2 Device is suppying power to the board. In the norma (non ICD2 deveopment) mode of operation, the switch position wi force the ICD LED to be off Headers JP1 - This 3-pin header connector provides access to the eve shifted version of the second seria channe. Note the use of zero-ohm R1 in the schematic. JP2 - This 3-pin header connector provides access to the +5V TTL eve signas of the second seria channe. Note the use of zero-ohm R1 in the schematic. JP3 - This 4-pin header is suppied for potentia use to easiy daisy chain the secondary I2C bus. Embedded Eectronics Page 20 11/9/2007

22 5 Customization and Configuration Customization can be achieved thru program changes to the contents of the FLASH or data changes (configuration) to the contents of the EEPROM. Fies are provided on the CD (daf.ib, main.c, et. a) to assist in code customization. 5.1 EEPROM Configuration Detaied description of the Parameter Bock Contents and commands avaiabe in the TE Command Interface to ater the contents appear in ater sections of this document. For now, I want to describe the genera function of the Parameter Bock and the roe it pays in determining operating conditions for the Daf Board. During the eary part of power up and system initiaization, the entire Parameter Bock is copied into a portion of microcontroer RAM that I refer to in this document as ERAM (Eeprom RAM Copy). The Parameter Bock (and EEPROM in genera), is not accessed after power-up (uness a command is issued to do so using one of the command interfaces). ERAM constitutes the Runtime Environment and is used to configure the devices and operating mode of the board. Uness you make changes to ERAM or the Parameter Bock after power up, the content of ERAM and that of the Parameter Bock wi aways be identica. A reasonabe way to think of these two memory areas is that ERAM is the current working copy of the Parameter Bock. 5.2 Factory Defauts, Parameter Bock, and ERAM The diagram beow describes the reationship between the Parameter Bock (in EEPROM), ERAM (in RAM), and the Factory Defauts (in FLASH): When you receive the board from the factory, the factory defauts wi have been stored in the Parameter Bock so that when the board is powered up it wi use the defauts. Embedded Eectronics Page 21 11/9/2007

23 5.3 Changing the Configuration Using the CMD Interface (any of the 3 seria inks), there are two ways to change vaues in the Parameter Bock (first 128 bytes of the externa 64K seria EEPROM) to customize operation of the board: Write the data directy into the ocation(s) in the Parameter Bock. This capabiity is provided by the Write Memory Byte command. Write the data first into ERAM using the Write Memory Byte command and then ater upoad (copy) the entire ERAM bock into the Parameter Bock using Cmd_Z. This option is usefu when evauating those changes (eg; PID Tuning) that take effect immediatey upon ERAM update. In this way you can, in some cases, observe the effect of changes without requiring a board reset. To restore the factory defaut vaues to the Parameter Bock, simpy power up with the BTN switch depressed. Regardess of the method chosen to make changes, you wi need to know where to make the changes in ERAM or the Parameter Bock. See Appendix D for a ayout of the Parameter Bock and the corresponding ocations in ERAM. See the section in the CMD Interface for detais of the commands needed to make the changes. What you need to change, if anything, in the Parameter Bock wi depend on your appication and usage. The tabe beow may hep you focus on the parameters that are important to your appication. Across the top of the tabe are modes and activities and in the first coumn is a ist of a of the parameters in the Parameter Bock. An X in the tabe indicates that the parameter may appy to the coumn operation. A bank box indicates that the parameter probaby doesn t appy to the specified operation. The System heading is for genera operations that don t naturay fit in the other categories (eg; VBATT monitoring, communications, etc.). If the parameter does appy to your intended usage, I recommend that you search the documentation for that parameter to find the appropriate detais. Even if the parameter appies to your appication, the defaut vaue may be fine for you. Some parameters are motor specific and there is a parameter for each motor (eg; VMAX1, VMAX2). In these cases, I have isted the parameter ony once in the tabe (eg; VMAX) - see Appendix D. 5.4 Parameter Bock Change Guide Parameter CMD CMD POTF, RCNRM, POT RC ANALOG I/O System Open Lp Cosed Lp POTC RCMIX SERVO SERVO Feedback fpwm X X X X X X X AD_ACQ X X X X AD_CNV X X X X AD_GAP X X X X SYSMODE X X1_Regs X X2_Regs X VBCAL X VBWARN X AMINP X X X MAXERR X X X MAXSUM X X X Embedded Eectronics Page 22 11/9/2007

24 Parameter Bock Change Guide (Cont d) Parameter CMD CMD POTF, RCNRM, POT RC ANALOG I/O System Open Lp Cosed Lp POTC RCMIX SERVO SERVO Feedback MODE1 X X X X X X X X MODE2 X X X X X X X MODE3 X X X X X X X X ACC X X X VMID X X X VSP X X X X X X KP X X X KI X X X KD X X X VMIN X X X VMAX X X X X TPR (1) X MIN X X MAX X X RC1MIN X X RC1MAX X X RC2MIN X X RC2MAX X X RC3MIN X RC3MAX X RCD X POT1A (2) X POT1B (2) X POT2A (2) X POT2B (2) X Nbr X NID X RX1TO X NPID (3) X DALFA X RCSP X X PSP X X DMAX X FENBL X X X X DECAY X X X X (1) - Assuming that you have motor encoders, TPR is necessary to get reiabe motor veocity in units of RPM, but this is informative ony and not used in any motor contro features. (2) - The on board pot settings are important ony if over-current protection is enabed. (3) - NPID is ony used by Command Q ( PID Tuning ). 5.5 Some Important Parameters A few parameters are of fundamenta importance. This section provides a bit of guidance on how to make the adjustments to these parameters. If you have not read the Getting Started Manua, it woud be a good idea to do so before making the changes. I recommend making a of these changes using the CMD Interface with a Termina Emuator Appication. When the Windows GUI (in deveopment) is avaiabe it wi make the setup process a bit more straightforward. Embedded Eectronics Page 23 11/9/2007

25 AMINP This parameter is the acceeration (sew rate) governor for a open oop motor operations. When using the CMD Interface, it is aso the defaut sew rate if you don t enter that parameter in the command. For a dramatic iustration of its effect, you can issue the same motor movement command but with different sew rates. Exampe: With motor1 stopped try X to run the motor at maximum forward veocity. This wi actuay use AMINP as the sew rate instead of the zero that was entered (AMINP is the minimum vaue for the actua sew rate). Now stop the motor and issue the same command but with a different sew rate: X FF. You shoud notice a dramatic difference in the acceeration to fina speed. To set a reasonabe vaue for AMINP, run your motor at fu veocity and then use Cmd_O to stop the motor (eg; O1 ; that is Oh, not zero). If the transition is too abrupt, increase the vaue of AMINP. If the transition is suggish, or you beieve that the motor shoud be stopped more quicky, decrease the vaue of AMINP. This vaue affects a open oop motor contro commands (sets the maximum acceeration rate) and a situations (incuding PID) where the motor must be stopped because of an error situation. VSP This is an important parameter for cosed oop motor operations. When the Trajectory Generator is active, a new positiona target for the motor is generated every VSP msec. When PID is active, new motor contro signas are generated every VSP msec. See the Trajectory and PID sections of this document for a discussion of how to determine an appropriate vaue for your appication. VMAX Set VMAX to 0x64 (the defaut), uness you want to restrict the effective votage to your motor. The vaue of VMAX is the maximum duty cyce that wi be appied to the motor. A smaer vaue may be appropriate if you do not want the effect of fu VBATT power appied to your motor. Do not set VMAX to any vaue over 0x64=100%. VMIN VMIN shoud be set to something sma. The factory defaut is VMIN=0x02=2% which wi probaby be fine for you. In cosed oop operations, when PID is active, the vaue of the PWM duty cyce wi never go beow VMIN. VMIN is usefu to dea with frictiona forces (deadband startup) and to maintain some force on the motor even when stopped to keep it at the current position. TPR The Ticks Per Revoution parameter affects the veocity (shown in units of RPM) when using Cmd_V to Get Motor Veocity. If you do not have motor encoders it is not important to set it. Otherwise the vaue to record is 4*CPR where CPR is the Cyces Per Revoution specification for your encoder. Exampe: CPR=22 TPR=88, so you shoud record 0x0058 (88) in the TPR word parameter. If you are using an anaog motor encoder instead of an optica encoder, you shoud set TPR=0x100 (256) to corresponding to the [0 360] degree range (0x00 to 0xFF on the ADC readings). VBCAL This is a scaed caibration constant used in computing the VBATT votage based on the ADC measurement on pin AN6 (votage divider input). It is designed to aow you to tune the VBATT battery monitoring gauge and in particuar to compensate for inaccuracies in the R3/R4 resistor divider pair used to capture the VBATT votage. See Appendix D for additiona detai and a recommended adjustment procedure. VBWARN When set propery, this parameter wi make LED3 usefu as a ow battery warning. In addition, setting this Low Batt Threshod to a reasonabe vaue so that the LED is off in norma operation aows the LED to show other error indications (eg; over-current). Exampe: Your nomina VBATT is 18V and you want the ow batt warning to occur at 16.5 Vots (=16,500 mv). Convert 16,500 to hex (0x4074) and record this in the word parameter VBWARN. Embedded Eectronics Page 24 11/9/2007

26 VMID If you do not specify a mid course veocity for a cosed oop motor command, this parameter wi be used instead. Whie not essentia, it is quite convenient for routine motor commands to just use the defaut vaue. Of course that makes sense ony if the defaut is reasonabe. The vaue of VSP shoud be estabished before using this procedure to set VMID. Procedure: Use Cmd_X to run your motor at various speeds (eg; X for 33% power) to find one that you want to use as the defaut for the midcourse speed in cosed oop commands. Then use Cmd_V (eg; V1 ) to get the corresponding motor veocity in units of ticks/vsp. Use the resut to set the VMID word parameter. For exampe, assume that your resut is V=0x (ticks/vsp). To set VMID to use this veocity as the defaut for midcourse veocity in cosed oop commands, mutipy the observed vaue by 256 (VMID is divided by 256 in cosed oop usage). In this exampe, you woud record 256 * 0x19 = 0x1900 for VMID. ACC Simiar to VMID, this parameter is the defaut acceeration input for cosed oop commands if you don t suppy it as part of the command. It is probaby a good idea to PID Tune your motors (determine appropriate vaues for KP, KI, and KD) before foowing the suggestion here on setting ACC. Procedure: Use Cmd_Y to repeatedy issue cosed oop motor commands and suppy various vaues of the a input parameter unti you are satisfied with the observed acceeration rate. Then simpy record this vaue into the ACC word parameter for use as the defaut. I recommend starting out with sma vaues for a (eg; 0x0005) and repeating the command with incrementay arger vaues (eg; increase by 0x0002) unti you are satisfied with the resuts; 0x0005, 0x0007, 0x0009, 0x000B, and so forth. Once you are satisfied, simpy record this vaue into the ACC word parameter. MODE1 You are probaby fine with the defaut here, at east initiay. Possibe exceptions might be the need to change the state of the aeadsb or the dis_activeo bits. If ony the aeadsb bit is in the wrong state, you can avoid a change by simpy reversing the connection of the encoder A and B signas at the Daf screw termina connectors. Later you may want to change some of the other contro bits in this parameter - See Appendix D for detais. MODE2 Bits in the MODE2 parameter contro operating mode on power up. For exampe, if you want to contro the motors with R/C or Pots, this is the pace to make those changes. See Appendix D for detais. MODE3 If your motor driver is something other than the OSMC Driver, then the osmc bit may need to be ceared (defaut is osmc =1). If this bit needs to be changed, you shoud do it right away to avoid confusion on commands that invove motor reversa. nbr This is the defaut index that governs the seria (RS232) baud rate. The defaut index produces 19.2K, but sower and faster rates have been tested without issues. See the tabe in Appendix D for detais. KP, KI, KD Ony important for cosed oop motor contro operation. See PID Motor Contro Tuning for detais. Embedded Eectronics Page 25 11/9/2007

27 5.6 Programming Customization For customization via code deveopment you use the 6-pin moduar connector with a too ike the ICD2. The other aternative uses the boot oader option to downoad the binary image over the seria port. For deveopment or debug, I recommend ICD2. For a code upgrade ony, the boot oader is fine. Moduar Connector The 6-pin moduar connector fits a cabe coming from the Microchip ICD2 deveopment too. The ICD2 too works in conjunction with the MPLAB IDE (Integrated Deveopment Environment) and aows for code deveopment, on-board programming of the fash part, and rea time debugging. When using the ICD2, the Daf-1 board is powered thru the connector. An on-board switch provides isoation of the oca power suppy from that provided by the ICD2 too and an LED indicates the switch position. For detais on the toos, see the Deveopment Toos section of this document and of course the Microchip web site. DSUB9 connector (RS232 seria) With this method the binary image is downoaded and sef fashed into the PIC18F6722 part using the RS232 seria ine with a standard modem cabe connected to a PC. This Boot-oad mode is seected via an on-board switch with an LED indicating the switch position. A boot oader Appication Program (running on the PC) and specia power-up boot oader code running in the PIC18F6722 (because of switch detection) act together to sef-fash the binary image. When the process is compete, the PC appication is terminated, the switch on the board is put back in norma mode, and the board is rebooted (reset) to power-up running the newy fashed image. This programming method woud be used by those wanting a fash update (from me or someone ese), but not having the ICD2 too. See the section Programming Using the Boot Bock Feature for additiona detais. Embedded Eectronics Page 26 11/9/2007

28 6 Deveopment Toos 6.1 Compier, Assember, Debugger The firmware for the Daf-1 board is a combination of code written in PIC Assember (MPASM Assember) and the C Language (MCC18 Compier). The ow-eve firmware consisting of system initiaization, device eve support, command handers and the Interrupt Service Routines is written in PIC Assember. The main oop, interrupt dispatcher, and the services schedued by interrupts are written in C. Additionay, much of the seria output to the Termina Emuator Screen is written in C to take advantage of the printf() functionaity. The source code for a of the C code is on the CD provided in the box with the product. In addition, the assember code is provided in ibrary format aowing it to be inked with other fies Daf board customization. A of the code for the Daf-1 firmware was deveoped and tested using standard Microchip toos. The prices for the deveopment toos, current at the time this document was pubicized, are isted beow. The toos are a avaiabe for downoad or ordering directy from the Microchip Web Site. MPLAB IDE: Integrated Deveopment Environment. [FREE] ICD2: Fash programming, Rea time debugging. [$159.99] MCC18.EXE: C compier. [$495.00; Free for 60 days] The ICD2 product is a cheap, but very functiona, aternative to an In-Circuit-Emuator (ICE). Other aternatives to the mcc18.exe compier incude products from HiTech, IAR, and CCS. The HiTech compier is more expensive than the mcc18. The CCS compier is ess expensive. I recommend the free version of the mcc18 over the other aternatives. The mcc18 product is a reiabe compier with ANSI extensions and permits 24 bit data vaues. If you choose a different compier for customization of the existing firmware you wi have some issues to dea with. First you shoud know that the suppied ibrary functions depend on the runtime environment of the mcc18. For exampe, cas from C to Assember functions assume parameters are passed on the software stack. The other compiers have different approaches and wi require code modifications to dea with issues ike parameter passing, and returning resuts to the caer. These are sovabe issues, but they wi resut in some additiona work if you expect to customize the existing firmware. Perhaps the most compeing reason for use of the mcc18.exe compier is that Microchip offers a free (for 60 days), fu featured, downoad of this product from their website. I was tod (Microchip saes rep) that the free version, remains fuy functiona after the 60 day tria with the exception that the code optimization features wi no onger be avaiabe. Franky, when used with the PIC18F6722, that makes the choice of a compier pretty much a no-brainer to me. The code size of the existing firmware is ony about 35% of the fash capacity, eaving ots of headroom for customization using a non-optimized image. If you are doing C deveopment using this board and the Microchip Compier <mcc18.exe>, you wi need to use a modified version of the startup code <c018i.c>. The ony required change to the <c018i.c> fie suppied with the compier is the reocation of the reset and interrupt vectors to addresses after 0x0800 (instead of 0x0200). The <c018i.c> fie (and the compied c018i.o fie) with the required changes is incuded on the CD. See the discussion of the Boot Loader for additiona detais. The <daf.ib> fie was created using the {Large code, Large Data, Mutibank Stack} mode settings. Embedded Eectronics Page 27 11/9/2007

29 6.2 Software Deveopment Too Version Numbers Too Too Description Version# MPLAB IDE Integrated Deveopment Environment 8.00 MCC18 C Compier 3.10 MPLINK Linker 4.10 MPLIB Librarian 4.10 MPASM Assember 5.10 Beginning with Daf firmware version 1.71, the Microchip Deveopment Toos isted in the tabe above are required to guarantee successfu fash image creation when using the deveopment fies provided on the CD. Earier reeases of these Daf fies were compied with the Microchip Too Suite accompanying mcc18 version 3.0. Those earier Daf fies have symbo names which confict with the toos in the tabe above. Embedded Eectronics Page 28 11/9/2007

30 Fashing the Microcontroer Using the Boot Loader The boot oader firmware in the boot bock section of the PIC FLASH operates in conjunction with the Windows Appication p1618qp.exe (PIC16/PIC18 Quick Programmer). This appication uses a seria cabe to downoad the fash image (*.hex) from the PC to the PIC. The p1618qp.exe contros this process and directs the PIC which is abe to sef-fash the program data that is down oaded from the program fie. The appication expects the fash image fie to be in INHX32 format. Use [fie/export] If you have created the image with the MPLAB IDE Deveopment Environment, it is a good idea to export the resuting.hex fie to the actua fie that you wi suppy to the p1618qp.exe too. The export function does a bit of housekeeping on the INHX32 fie to make a data ines contain 16 bytes. This can avoid some error messages that p1618qp.exe may generate otherwise. You can aso specify the starting address of 0x00800 for the output fie and in this way avoid any possibiity of overwriting the boot bock code The Boot Bock The Daf Board comes with a firmware boot oader ocated in the first 0x800 bytes of fash memory (boot bock) which may be utiized with the p1618qp.exe PC appication to downoad and fash a program image into the microcontroer. The boot oader code suppied in the Daf Board Fash Memory is a sighty modified version of the one found on the Microchip web site and described in the App Note: AN851. This appication note is not specific to the PIC18F6722, but most of its content appies to the process described here. You shoud review the appication note (which has consideraby more detai than presented here) and the foowing discussion before attempting to use the boot oader feature. The ony boot oader modifications for this product are: Boot mode is detected via a switch (instead of the ast byte of interna EEPROM). The reset vector for norma run mode is redirected to 0x800, instead of 0x200. The interrupt vectors are redirected to 0x808 and 0x818 (instead of 0x208 and 0x218). The boot bock section of program memory ([0x0000-0x07FF]) is reserved for the boot oader and the content of this section of FLASH memory shoud remain unchanged to aow future code update support Under The Hood When the microcontroer is reset, execution aways starts at address 0x0000 in the boot oader. The very first thing that the code does is examine the state of the PGM Switch to determine whether the code shoud remain in the Boot Loader section or to commence norma execution and system initiaization. In norma operation, the code wi branch to begin system initiaization, but if the PGM switch is in the Boot Loader position (yeow LED on) the code wi instead wait in the Boot Loader Code for communication to commence with the p1618qp.exe appication. The actua process of updating the fash image is a simpe process, but success wi depend on carefuy foowing the correct procedure described beow. You shoud never fash the first 0x0800 bytes of this part. Corruption of the boot oader portion of the fash wi resut in a situation where you wi be unabe to use the boot oader to re-fash the part. If this happens, the fash image (incuding boot oader) wi have to be restored using a device programmer (Eg; ICD2 using the moduar 6-pin connector) Instaing the p1618qp.exe Appication First insta the p1618qp appication on your PC if you don t aready have it. During instaation, if the instaer asks if you want to repace your system fies (.d s, etc.) with oder versions from the appication, I recommend that you keep your newer fies. Embedded Eectronics Page 29 11/9/2007

31 After instaation of <P1618QP> is compete you wi need to repace one of the fies instaed for the appication with one that I provide on the CD. When you run the p1618qp.exe appication it reads a p1618qp.ini (text) fie that ists supported PIC devices. The version of the p1618qp.ini fie instaed by the appication is somewhat dated, and wi not recognize the newer Daf PIC18F6722 part. To remedy this, the CD that comes with the Daf Board has a modified p1618qp.ini fie which wi enabe the appication to communicate with the Daf microcontroer part. After instaing the P1618QP Appication on your PC, the p1618qp.ini fie from the CD shoud be copied into the same directory with the p1618qp.exe appication. You can simpy overwrite the od p1618qp.ini fie that came with the appication, or if you prefer, save the od version to a different directory first About The Image The image fie shoud have a.hex extension with the code starting at address 0x0800. This avoids changes to the content of the Boot Bock. Be sure that the image that you are fashing with the boot oader starts at 0x0800. If you are doing C deveopment using the mcc18.exe compier, you shoud use a modified version of the norma startup code <c018i.c> to compie with your appication so that your own appication wi begin at 0x0800. Uness you need to make additiona changes to <c018i.c>, you shoud simpy ink in the preassembed <c018i.o> ocated on the CD. The ony difference between the modified <c018i.c> fie and the one that is distributed in the Microchip MCC18 Compier Source Library is the reocation of the reset and interrupt vectors. The modified <c018i.c> source fie is aso incuded on the CD. One other thing is important, but not obvious: The hex image fie shoud be copied to your hard drive before you begin the update process with p1618qp. The terminoogy used by the p1618qp.exe appication for seecting the hex fie for the fash process is caed importing the fie. For some reason the appication doesn t ike to import the fie from the CD, but if you try, you won t get the error unti the actua fash operation is started About The Parameter Bock Using the boot oader appication to fash the PIC Microcontroer can not ater the externa EEPROM (where the Parameter Bock resides), but the firmware upgrade may require organizationa or other content changes to the Parameter Bock in order to perform correct system initiaization with the new code. This means that the new factory defauts wi need to be written into the Parameter Bock after the fashing process is competed (during the first reset after fashing). The parameters are not recorded automaticay, but the process is easy using the BTN switch on the board. A copy of the new factory defauts wi have been suppied in the fash image. But it sti requires you to cause the transfer of the new defauts into the Parameter Bock during your first reboot with the new image (use of the BTN switch during reset). After that you may want to restore any specia settings that you previousy had in effect. It is not a bad idea to make a hardcopy of the current Parameter Bock contents before proceeding to fash the new image (use TE with ogging enabed). This wi enabe you to ater easiy restore previous settings (eg; PID constants, operating mode, etc.) that you had made to the Parameter Bock. Be aware that if you are fashing a Daf image that is firmware upgrade from Embedded Eectronics some settings may have moved to new ocations in the Parameter Bock or have been eiminated entirey. Embedded Eectronics Page 30 11/9/2007

32 6.2.6 The Process In genera, the boot oad process itsef can be described as a series of steps: 1) Board and PC Setup 2) Connection 3) Import Hex Fie 4) Erase 5) Fash 6) Disconnect 7) Reset Daf Board whie hoding the BTN switch. 8) Restore any customizations previousy made to the Parameter Bock Before proceeding you shoud have the image (.hex fie) that you want to fash on your hard drive. Board and PC Setup: Connect a standard seria modem cabe between the board and your PC. Appy power to the Daf board. Move the sider on the switch abeed PGM to the position that turns on the yeow LED (BOOT LOADER POSITION). The yeow PGM LED indicates that the board wi enter boot mode when next reset. Reset the Daf Board by pressing the RESET button. This wi start the boot oader firmware which wi wait for communication with the Windows appication. You wi not see any visibe indication that anything has happened, but the reset is important. Start the p1618qp.exe appication on your PC. You wi see a device seection menu. Connection: Scro down in the device seection drop down menu and highight the PIC18F6722 part (1). Press the [SELECT] button. The PIC18F/PIC16F Quick Programming Toobar appears. Right cick on the [COM] and [BAUDRATE] buttons if necessary to seect COM1 and 57,600 baud. Left cick on the [CONNECT] button. You shoud see a response in the status ine that says Device Found. NOTES: (1) If you don t see the PIC18F6722 part in the ist, there is a probem with access to the proper <p1618qp.ini > fie. Import Hex Fie: Left cick on the [OPEN HEX FILE] button to ocate and then open your fash image (.HEX) fie. You shoud see the status response: HEX Fie Imported... Erase: Left cick on the [ERASE] button to erase the fash memory. This is necessary before programming the part. You shoud see a progress meter and when finished, the status ine response: Finished Operation... Fash: Left cick on the [WRITE DEVICE] button to start the fash process. Again you shoud see a progress meter and when finished, the status response: Finished Operation... Embedded Eectronics Page 31 11/9/2007

33 Disconnect: Cose the p1618qp.exe appication on your PC. Leave the modem cabe attached. Reset Daf Board: Start a termina emuator appication. This wi be used to test the newy fashed code. Move the PGM sider to the position in which the yeow LED is off (NORMAL POSITION). Press and hod the BTN switch (request new factory defauts be copied to Parameter Bock). Press and then reease RESET button to reset the Daf Board. This wi run the micro using the newy fashed code image. When you see the termina emuator greeting, you can reease the BTN switch. This wi have copied the new factory defaut vaues into the Parameter Bock. Restore any customizations to Parameter Bock Use Cmd_W to restore any specia settings to the Parameter Bock. Use Cmd_W, and Cmd_L to verify your changes. If you have previousy saved a hardcopy (using Cmd_L with termina emuator ogging enabed) of your settings, it wi be easy to compare the current vaues with the previous ones (remember - some parameters may have changed ocations). Embedded Eectronics Page 32 11/9/2007

34 7 Interrupt Driven Firmware Design The firmware design is interrupt driven. Currenty, the singe exception is access to the on-board I2C parts using the Primary I2C Bus. Some of the interrupt handers (ISR s) schedue services within the main oop to perform actions that if executed within the interrupt hander itsef coud create interrupt atency issues. The main oop consists primariy of processing service requests from the interrupts. Much of the firmware design is apparent from this document, a review of the interrupt system, and an inspection of the main oop. The PIC18F6722 part supports a 2-eve priority interrupt system. At the time of this writing a interrupts are configured to use the high priority hander ony. The actua interrupt hander is referred to as the ISR (Interrupt Service Request) routine. The ISR routine dispatches to individua service routines by testing the Interrupt Fags. This code and mechanism can be reviewed in the fie <main.c>. New or different interrupt handers may be instaed easiy by modifications to the <main.c> fie. The existing Interrupt Handers generay, but not aways, request a Main Loop Service (Svcx) to hande processing better done outside of the actua interrupt hander. What foows is a description of the various interrupts, their handers, their main oop Svcx Services, and their genera function. 7.1 TMR0 - Heartbeat Main Loop Service: Svc0 Timer0 is configured as an 8-bit count-up timer that generates an interrupt on overfow every 1 msec. The TMR0 Hander is responsibe for maintaining various software counters that are used to schedue other actions (eg; samping). TMR0_ISR is aso responsibe for maintaining the 24-bit, 2 s compement position counter when an anaog feedback device is used as a motor position sensor. As with most of the interrupt routines, the ISR schedues a main oop service request (Svc0) that executes roughy every 1msec (after return to the main oop). Svc0 has severa functions. One important exampe is veocity sew rate (ramping) contro during motor state changes. This service is aso responsibe for initiating open oop motor commands generated by R/C and or POT contro modes. 7.2 TMR1 - RTC Main Loop Service: Svc3 Timer1 is a 16-bit timer/counter configured as an Asynchronous Counter driven by an externa khz crysta time base. The interrupt is configured to occur once every second and the ISR maintains a 24-hour rea time cock (HOURS, MINS, SECS) which can be used as a time-stamp or to initiate schedued events. In addition the 32-bit variabe Seconds is incremented every second. This variabe represents a running second count from the time of power-up and is used by some ibrary routines for extended deays. Main oop service (svc3) is currenty used ony to periodicay compute the measured (and caibrated) battery votage derived from the stored ADC reading and caibration constant in the Parameter Bock. 7.3 TMR2 - ADC State Machine Main Loop Service: Svc4 (UNUSED) Timer2 is an 8-bit count up timer with a cock source of fosc/4 = 10MHz. The firmware dedicates Timer2 to driving the ADC State Machine that is responsibe for the acquisition, conversion, and resut storage, for each of the 7 ADC inputs [AN0 AN6]. Ony the most significant 8 bits for each 10 bit conversion is stored. When the TMR2 Interrupt is serviced, the current vaue of the ADC State Machine variabe adc_state determines one of 3 timing parameters that contros the next TMR2 interrupt timing. It is the vaue of the timing parameters in ERAM that contro the TMR2 interrupt timing for the next state. After power-up, the ADC modue runs autonomousy using TMR2 interrupts to provide appropriate deays and sequencing of the ADC State Variabe. At each TMR2 interrupt, the interrupt hander code dispatches Embedded Eectronics Page 33 11/9/2007

35 based on the state variabe to one of 3 routines. The roe of TMR2 in this process is to generate the appropriatey timed interrupts to sequence the operations in a way that doesn t invove software deay oops to provide the necessary deays. Because the deays are accompished with interrupts, the number of CPU cyces devoted to processing the anaog inputs is sma. Here is a rough description of how this state machine works: adc_state action Start acquisition on current channe. Set TMR2 for [acquisition] deay. adc_state 1. Exit 1 Start conversion on current channe. Set TMR2 for [conversion] deay. adc_state 2. Exit 2 Store resut (*). Advance channe. If sequence compete, request main oop svc. Set TMR2 for between-channe [gap] deay. adc_state 0. Exit. (*) If the digita fiter is enabed for this channe, the reading wi be fitered before storage. See the section of this manua that discusses the digita fiter for detais. Required minimum timing: You can contro the timing for each of the states thru the vaues stored in the Parameter Bock. However, proper signa acquisition requires a minimum charging time for the interna samping capacitor. The required minimum signa acquisition time primariy depends on the signa input impedance (higher impedance requires more time). A typica minimum acquisition time might be 20 usec. The time required for a successfu 10-bit conversion is at east 12*TAD where TAD is the period of the ADC Modue Sampe Cock. The ADC sampe cock is configured for 1*TAD = 64*tOSC = 64*(1/40E6) =1.6 usecs, and the minimum conversion time is 12*TAD = 19.2 usecs. Defauts: Acquisition: 20uS + Interrupt atency = 30 us Conversion: 35uS + Interrupt atency = 45 us Between channe (gap) deay: 500uS + Interrupt atency = 540 us With the above defauts, the sequence of 7 measurements competes every 4.4 msec (resuts for a specific channe are updated about 227 times each second). The 3 deays (Acquisition, Conversion, Gap) can be customized by atering the ADC Timing indices in the Parameter Bock (See the Timing Tabe in the Parameter Bock Section of this document for detais). 7.4 INT0 - Motor2 Encoder Main Loop Service: Svc1 (UNUSED) The Int0 interrupt hander services the motor2 encoder input signa AB2INT. The quadrature [A,B] signas from the motor2 encoder are routed thru an XOR gate to produce in Int0 interrupt for transitions on either the A or B signas. The A and B signas are aso routed to input pins that aow their actua state to be read by the hander. The roe of the Int0 ISR is to read the AB state and compare it with the previous AB state to determine if the motor has moved forward or reverse. A 24-bit, 2 s compement position counter, which is ceared on power-up, is maintained by this interrupt hander. The counter is incremented for forward motion and decremented for reverse motion. Here is a rough description of how the counter is used (outside of the interrupt hander): Every Veocity Samping Period (VSP) msec, the od vaue of the counter is compared with the new vaue to determine a veocity in units of ticks/vsp msec. The vaue of the encoder count and the veocity are maintained in RAM and can be viewed at any time thru the command interface. The timing of the veocity samping is determined by the VSP parameter. The VSP vaue is an important environment variabe that you can/shoud change to suit your appication. It aso pays an important roe in the timing of the Embedded Eectronics Page 34 11/9/2007

36 Trajectory Generation and PID contro agorithms. Eg; With VSP2 = 0x14 = 20 msec, a fresh vaue for the motor2 veocity woud be determined every 20 msec. When a cosed oop motor2 contro command is active it woud aso resut in a ca to the Trajectory Generator and the PID contro fiter every 20 msec to generate a new waypoint and a motor speed correction as the PID response. The Veocity Samping Period (VSP msec) contros how frequenty the motor veocity is updated. The veocity is determined via the counter difference on each successive samping period In the case of cosed oop motor contro commands, VSP is aso used as the timing interva for the Trajectory Generator and the PID Controer firmware. The Trapezoida Trajectory Generator produces a waypoint every VSP msec for use as the target ocation in the PID computations. Since the speed of the motor and the CPR of the encoder wi vary with different appications, the samping period VSP (msec) for veocity computations is stored in the parameter bock to aow easy customization. See the Trajectory Generator section of this document for a discussion of how to determine an appropriate vaue of VSP for your appication. 7.5 INT1 - Motor1 Encoder Main Loop Service: Svc2 (UNUSED) The Int1 interrupt hander services the motor1 encoder input signa AB1INT. See INT0 for detais. 7.6 INT2 - Motor2 Current Limit Main Loop Service: Svc5 This interrupt is disabed by defaut - see the ocie bit in the Parameter Bock. The Int2 interrupt hander services the motor2 over current sense input from the I2INT signa. The interrupt indicates that the motor2 current sensor output votage is outside the imits determined by the digita pots ocated near the comparator device. If the interrupt is enabed and the FastOff response option has been seected (see the oc_fastoff bit in the Parameter Bock), the ISR wi immediatey remove motor power and disabe the motor contro interface. Otherwise, the ony action taken by the ISR is to togge the edge detection circuitry, record the state of over-current (or not), and request the main oop service. Svc5 is responsibe for taking action to dea with the over current notification. See the section in this document Current Sensor Feed back for additiona detais. 7.7 INT3 - Motor1 Current Limit Main Loop Service: Svc6 The Int3 interrupt hander services the motor1 over current sense input from the I1INT signa. See INT RB4 - EX2 Main Loop Service: None The RB4 interrupt pin is dedicated to the off-board signa EX2 (UNUSED). The RB4 interrupt is a bit different than other PIC interrupts in that it is one of a group of 4 pins (RB4 RB7) that when enabed, cause interrupts to occur on signa transitions ( interrupt-on-change ). Pins RB5, RB6, and RB7 are dedicated for other uses and may not be used for interrupts. Currenty the RB4 interrupt is not enabed. There is no ISR hander for RB4, and there is no main oop service. 7.9 TX1 - USART1: RS232 Seria Command Response Main Loop Service: Svc8 (UNUSED) The firmware configures USART1 as a fu-dupex, asynchronous system, with a defaut baud rate of 19,200. The source for the baud rate generator is derived from the system cock (fosc). Transmitta of a string of data is interrupt driven with the string first oaded into a circuar buffer Tx1_Buff in RAM. Embedded Eectronics Page 35 11/9/2007

37 Transmitta begins by enabing the transmitter circuitry and the TX1 interrupt. This wi generay cause an immediate TX1 interrupt (because the Transmit Buffer Register TXREG1 is empty). The TX1 Interrupt hander fetches the next byte from Tx1_Buff and writes it into the TXREG1 hardware register. The hardware then transfers this into the Transmit Shift Register TSR1 (when the TSR1 register is empty). This action empties TXREG1 (making it avaiabe for the next byte) and causing the next interrupt. This process continues with an interrupt for every byte to be transferred unti the ISR detects that the Tx1_Buff buffer is empty. At this point further TX1 interrupts are disabed. Main oop service is requested on every byte transfer, but the service is a NOP RX1 - USART1: RS232 Seria Command Receive Main Loop Service: Svc9 Receipt of seria data via USART1 is aso interrupt driven. The data byte received by the hardware interface is paced into the Receive Shift Register (RSR1) and then transferred into the doube buffered Receive register RCREG1. The transfer into the RCREG1 causes an RX1 interrupt. The RX1 Interrupt hander copies the character received into the circuar Rx1_Buff buffer in RAM. When using the Termina Emuator mode for the seria interface, the receipt of a CR character signas end of transmission and the interrupt service routine schedues a main oop service to process the data (1). The main oop service parses the expected command string into CMD and ARG variabes, and dispatches to the appropriate command hander. (1) Actuay, the RX1 ISR is a bit more compicated than this. Since the service is designed to communicate with a Termina Emuator Appication running on a PC, the service must echo back characters to the PC, ignore certain contro characters, and provide specia treatment of others (eg; BS char). In addition, certain characters are aowed as data deimiters (for readabiity), hence discarded. When using the API mode for the seria interface, it is the detection of end of message packet that signas an end of transmission causing a request for main oop service to process the data CCP1 - R/C Channe 1 (EX0) Main Loop Service: SvcA The discussion here appies to CCP1 (EX0), but simiar comments appy to CCP2 (EX1) and CCP3 (EX3). Because the EX0, EX1, and EX3 signas are connected to CCP (Capture/Compare/PWM) modues on the PIC microcontroer, they can be configured for different uses. With a itte programming, these signas can become PWM outputs, or specia purpose capture inputs to time events, or (in compare mode) to generate carefuy timed signa outputs. Finay, they can be genera purpose interrupt inputs or simpy digita GPIO s. The Daf firmware does not support a of these features, but it is good to know that it is possibe if your appication requires it and you are feeing adventuresome with the code. The firmware provides a 3 channe R/C interface using signas EX0, EX1, and EX3. An interrupt hander for each of these signas provide very precise puse width measurement for receiver outputs which woud normay drive servos but are instead connected to EX0, EX1, and EX3. Timer3 and the Capture/Compare/PWM modues are the key to the accuracy. Timer3 is configured as a free running, 16- bit counter with cock source = fosc/4 and a prescaer of 1:8. With fosc = 40E6 Hz, Timer3 increments every 0.8 usecs and wraps every 65536*0.8uSecs = msecs. When used in conjunction with the CCP1 modue configured in capture mode, this provides a signa puse measuring too with a resoution of 0.8 usecs and a range of about 52 msecs. Embedded Eectronics Page 36 11/9/2007

38 EX0 ISR Operation: (Simiar comments appy to EX1 and EX3) The CCP1 interrupt is aternatey configured to interrupt on the rising edge and the faing edge of the input signa. On the rising edge, the vaue of Timer3 is atched by the hardware into the 16-bit specia function register CCPR1 and transferred by the Interrupt hander to the 16-bit RAM vaue PuseStart1. On the signa faing edge, the newy atched vaue of Timer3 is used together with PuseStart1 to determine the eapsed time for the puse in units of Timer3 ticks. This eapsed time is stored in the 16-bit RAM vaue PuseWidth1. Once the signa puse width is captured, the ISR requests main oop service to convert the measured puse width from units of 0.8 usecs to units of 1.0 usecs (mutipies by 0.8) CCP2 - R/C Channe 2 (EX1) Main Loop Service: SvcB This is simiar to CCP CCP3 - R/C Channe 3 (EX3) Main Loop Service: SvcC This is simiar to CCP1. Note that whie the above described measurement operations take pace for a 3 channes, the resuts for channe 3 are currenty unused SSP2 - I2C2 SLAVE Command Interface (SC2, SD2) Main Loop Service: SvcD Interrupts are generated on both MASTER read and write operations with data received (command and arguments) stored in an input buffer and data to be transmitted retrieved from a transmit buffer. Cock stretching is empoyed to provide setup time to aow the Daf Firmware to prepare data for transmission to the Host. Reception of the ast byte (CKSUM) of the command packet signas end of transmission and the interrupt service routine schedues a main oop service to process the data. The main oop service parses the command string into CMD and ARG variabes, and dispatches to the command hander. If there is data to be returned to the host, the command hander is responsibe for starting the process (again interrupt driven) to deiver the data //Unused Interrupts// - Resource Detais There are a number of unused interrupts, but in many cases the resources (eg; timers) that woud generate the interrupt are in use for features which may precude the use of the interrupt. Here is a ist: TMR3 The Timer3 interrupt is unused, but the Timer3 resource is dedicated to the roe of puse width timing capture if the R/C interface is used. TMR4 The Timer4 interrupt is unused, but the Timer4 resource is dedicated to the roe of providing the PWM frequencies used by the two motors for speed contro. Timer4 is configured to provide an 8-bit counter with a cock source of fosc/4 = 10E6 Hz. Timer4 operation depends on 3 factors; a period register (PR4), a prescaer, and a postscaer. Ony the first two of these (the postcaar is not used) affect the PWM operation. For the prescaar there are 3 choices: 1:1, 1:4, or 1:16. The prescaer setting is defined by the ow order first two bits in the T4CON contro register. Timer4 increments at a rate of prescaar*(4*tosc) unti a comparator match with the 8-bit PR4 register occurs. On the next count {(PR4)+1}, the Timer4 vaue is reset to 0, restarting the counting sequence. It is this timing that determines the PWM frequency. For exampe; with the defaut vaues for T4CON and PR4 determined by the parameter bock vaue fpwm, the prescaer is 1:4 and the vaue of PR4 is 124. This sets the defaut PWM frequency to fpwm = (fosc/4)/presc/(pr4+1) = KHz. Embedded Eectronics Page 37 11/9/2007

39 I2C (BCL) The PIC I2C hardware supports true Muti-Master I2C communication with the use of 2 interrupts (SSP, BCL), but this is currenty not supported by the firmware. The firmware -does- support non interrupt driven, I2C Master/Save access to on-board devices using the Primary I2C Bus {EEPROM, I/O Expanders, Digita Pots} at 400 khz. The Secondary I2C Bus (I2C2), configured as a Save, -is- interrupt driven, and is used as a Command Interface. Neither interface uses the BCL interrupt. PSP The parae save port interrupt is unused, and the PortD pin resources that it woud require are used for other purposes. CM The comparator interrupt is unused, and the pins RF1-RF6 that it woud use as resources are instead used for other features on the Daf board. AD The Anaog-To-Digita interrupt is unused. Instead, TMR2 is used to sequence a state machine for cycic samping and storage of anaog inputs. EE The interna EEPROM write compete interrupt is unused. TX2 The second USART TX interrupt is currenty unused. RX2 The second USART RX interrupt is currenty unused. LVD The ow votage detect interrupt is currenty unused. Embedded Eectronics Page 38 11/9/2007

40 8 Motor Encoder Feedback Beginning with the Daf firmware reease 1.50, support is provided for both incrementa optica encoders and absoute anaog encoders. The incrementa encoders wi generay be more accurate and I recommend their use for everything but servo operations. If you are going to be using one of the Servo Modes (new feature in reease 1.50) you wi probaby want to use absoute anaog encoders. 8.1 Optica Encoders For each motor, the board provides a 5-pin connector (VDD, GND, A, B, Z) for standard quadrature encoder inputs. The VDD and GND signas power the encoder ogic and the A,B, and Z signas are inputs to the Daf Board.. The firmware determines the direction of rotation from the reative phase of the A and B signas. The Z signa (Index) is routed to a digita input, but is currenty unused The CPR Specification The CPR ( Cyces Per Revoution ) is an important encoder specification. CPR is the number of cyces of either the A or B signa when the shaft on which the encoder is mounted rotates one revoution. This is not the same as Counts Per Revoution which I wi refer to as Ticks Per Revoution (TPR) to avoid confusion. Because the A and B signas are 90 degrees out of phase, the Daf firmware obtains an actua encoder resoution that is finer by a factor of 4; TPR=4*CPR. TPR is one of the parameters stored in the Parameter Bock and enabes correct dispay of motor veocity in units of RPM. If you are using encoders you shoud record the vaue of TPR1 and TPR2 for your encoders into the Parameter Bock Optica Encoder Limitations The interrupt hander maintains 24-bit, forward/reverse, 2 s compement counters which represent motor position. The interrupt hander increments or decrements these counters on every encoder tick. This design imposes a imitation on high speed, high resoution, motor/encoder combinations in terms of the maximum encoder interrupt frequency. If the interrupt frequency is too arge, it wi introduce errors in other processes. For exampe, it can interfere with seria communication; produce encoder count errors; etc. If you have not chosen a motor/encoder combination and are panning on using the Daf Board, this discussion may hep you make your choice. If you aready have a motor/encoder setup, this discussion wi hep you to determine if it is a reasonabe system for use with the Daf Board. Assume Vm is the maximum no oad veocity (RPM) that you intend to drive the shaft to which the encoder is attached. Note that Vm wi depend on your operating votage. If your encoder is attached directy to the motor shaft, Vm wi be the maximum motor RPM. Let fint be the frequency of encoder interrupts that the Daf Board uses to maintain motor position. At maximum RPM, the parameters fint, CPR, and Vm are reated by the equation: fint = TPR*(Vm/60) = CPR*Vm/15 (ticks/s) I don t recommend the Daf Board for cosed oop appications in which fint > 40,000. An appication that has fint = 40,000 wi produce encoder interrupts every 25 microseconds when running at fu veocity. Embedded Eectronics Page 39 11/9/2007

41 EXAMPLE 1: The encoder is the E6M part from US Digita. This part comes as an easy to assembe kit that is mounted directy to the motor shaft. For this exampe we assume that the E6M was specified to have resoution CPR=64 (TPR=256). The motor is a geared, PM DC, wheechair motor rated at +12VDC that wi be overdriven with a +18VDC power source. The no-oad veocity when driven at +18V is Vm=320 RPM. fint = 64*320/15 fint = 1,365 In this appication, at maximum veocity, an encoder interrupt occurs every 732 microseconds. This is we within the specification - no probem. EXAMPLE 2: Pittman +12VDC Motor. Encoder (buit in) with CPR=500. At fu +12V power, the no oad veocity is Vm=4,000 RPM. fint = 500*4000/15 fint = 133,333 In this appication, at maximum veocity, an encoder interrupt occurs every 7.5 microseconds. This exceeds the fint specification for the Daf Board by a arge margin. You woud sti be abe to drive this motor and contro veocity in open oop modes using the Daf Board without any probem. In order to successfu use the encoder inputs for cosed oop operations you woud have to imit the maximum veocity (see VMAX parameter in the parameter bock) to roughy 1,200 RPM. TIP: CPR is an encoder characteristic which shoud be considered carefuy in conjunction with your maximum motor veocity and desired position resoution. With arge vaues of CPR, you wi gain finer position and veocity resoution, but this advantage has a cost. The arger the vaue of CPR that you use, the more time wi be spent handing the interrupts to maintain position and veocity. In extreme cases, you may be forced to imit motor operation to some fraction of fu power (see VMAX), or mount the encoder downstream after a gear reduction Optica Encoder Hookup The encoders wi generay have 5 wires to hook up (4 if missing the index wire). The wires are frequenty abeed as shown beow. The Type fied refers to things from the point of view of the encoder (ie; Signa A is an output from the encoder to the Daf Board). The Z signa is routed to an input pin on the microcontroer, but current Daf firmware does not monitor it. Signa Type Comments +5V Power Encoder power. A Output With motor movement a square wave. B Output With motor movement a square wave, 90 deg out of phase with Signa A. Z (or I) Output Index or Home. With motor movement, a singe puse every revoution. GND Power Encoder power. The anaogfb bit in the MODE1 byte(s) in the parameter bock must be set to 0, but this is the defaut so you shoudn t have to make a change. You may need to change the state of the aeadsb bit in the Parameter Bock. Signa hookup is quite simpe. Daf has two 5-pin screw terminas (VDD, A1,B1,Z1,GND) and (VDD,A2,B2,Z2,GND) - one for each encoder. Be sure to change the vaues for TPR in the Parameter Bock to match your encoder. Embedded Eectronics Page 40 11/9/2007

42 8.1.4 Optica Encoder Accuracy Accuracy is one advantage of optica sensors over anaog sensors. Assuming that your appication meets the fint Specification, the counter wi accuratey track your encoder. Actua position of the output shaft wi depend on the resoution of your encoder and mechanica factors ike shaft pay. In cosed oop operations accuracy wi aso depend on successfu PID tuning. If your appication is tuned, you can typicay achieve position accuracy for cosed oop operations to be within +/- 1 tick of your position counter. Depending on the CPR of your encoder, this positioning accuracy is better than you can expect to achieve with anaog encoders. 8.2 Anaog Encoders Beginning with firmware version 1.50 there is buit-in support for an anaog motor position encoder that coud optionay repace an optica incrementa encoder for use in cosed oop operations. This feature has been tested with the MA2 anaog sensor from US Digita on a geared wheechair motor with maximum RPM of 320 and has been found to function quite satisfactoriy in fu range (not just [0,360] degrees) operation. The feature has not been tested with other sensors or faster motors Anaog Encoder Limitations The nature of the sensor output (0 to +5V sawtooth ramp with abrupt transition on each revoution) makes ADC samping and interpretation a chaenge. Periodicay, the ADC Modue sampes the sensor output to maintain the position counter. This samping is asynchronous to the shaft movement and inevitaby samping wi sometimes occur during the sensor transition period resuting in a bogus position measurement. The agorithm that processes the ADC sampes must dea with this situation robusty to maintain an accurate position counter. Here are some recommendations: 1) Don t use anaog sensors if your maximum motor RPM exceeds ) Do use the MA2 sensor (preferaby the ba bearing version). It has been tested. 3) Don t use a sensor with a rotationa imitation (eg; a singe or mut-turn pot). 4) Don t use the digita fiter for anaog encoder inputs for fu range (not just [0..360]) operation. 5) Do consider using digita fiter for anaog encoder inputs in POTSVO and RCSVO [ ] operation. A bit of discussion on the Do s and Don ts Usage of the anaog sensor in cosed oop operations assumes reasonabe PID parameters. If the sensor cannot rotate freey for severa motor revoutions, you wi not be abe to use Cmd_Q to assist in PID tuning. This is one, but not the ony, reason for (3). Once the motor(s) are PID tuned, it may be reasonabe to repace the MA2 sensor with a standard pot (use your own judgement on this one). The agorithm that processes the anaog readings rejects readings that differ significanty from the ast reading. This is necessary to identify bogus readings obtained during the signa transition that indicates a compete revoution. This paces a imitation on the maximum motor RPM (one of the reasons for 1). The ADC Modue captures the sensor reading asynchronous to the motor movement. This resuts in occasiona ADC samping during the brief transition period, resuting in a bogus indication of true motor position. Embedded Eectronics Page 41 11/9/2007

43 In addition to the R/C fiter on the [AN0..AN5] anaog inputs, you have the option of appying a digita fiter to any of the [AN0..AN6] inputs. This digita fiter is discussed in detai in a ater section. It can be quite usefu to eiminate positiona chatter due to anaog noise not reated to actua shaft movement, but it can get in the way of the agorithm used to detect fu revoutions (see the graph). I don t recommend using the digita fiter for anaog position feedback for appications that operate outside of the [0..360] range, but it is quite appropriate for usage in typica [0..360] cosed oop servo operations. If you decide to use it, be sure to disabe it during PID tuning operations The Position Agorithm (Under The Hood) Knowedge is power, so how does it work? If you are not interested, you can probaby skip this section, but be sure to foow the above recommendations with regard to specifications. As expained in an earier section of the document, the ADC Modue functions as a state machine driven by TMR2 to periodicay sequence thru a 7 channes AN0.. AN6 and record 8-bit measurements in RAM (ADC0[0..6]). The overa process time for a compete cyce is primariy controed by the AD_GAP parameter in the Parameter Bock. With the defaut setting, each channe is updated roughy every 4.4 msec. We are ony concerned here with channes AN2 and AN3 which are dedicated for use in measuring the anaog feedback signas for motors 1 and 2. So the measurements are being recorded in RAM at ADC0[2] and ADC0[3], but what is the connection between a measured anaog reading, say A (range [0..255]) to the 24-bit, 2 s compement, position counter? If an anaog sensor is being used for motor position feedback, the TMR0 Interrupt Hander (int every 1 msec) maintains the counter. If there is no change between the current measured vaue A in RAM and the previous vaue LastA, the counter is not changed. Otherwise, the counter is either incremented or decremented by Diff = LastA - A. Note that this is an 8-bit, 2 s compement subtract. For exampe; LastA=0x03, A=0xFE Diff=0x05 (the motor has just passed thru the transition region in the reverse direction). If the transition happened instead in the forward direction with LastA=0x03, A=0xFE Diff=0xFB (=-5). In a perfect word this woud be the end of the story. Unfortunatey, there is a probem. The probem: The signa transitions abrupty between +0V and +5V with every revoution. The signa transition is faing for forward movement and rising for reverse. Ideay the transition woud occur instantaneousy, but in the rea word there is a brief interva where the signa can be samped by the ADC Modue and obtain -ANY- vaue in the range [0..255]. The soution: We coupe a fast ADC samping rate with imited motor RPM to ensure that the vaue for Diff wi not be arge uness the reading is bogus. This aows us to identify as bogus, a readings in which Diff exceeds a threshod, say DMAX (see Parameter Bock). This strategy raises two important issues! What do we do about ceary identified bogus readings ( Diff >= DMAX) and what do we do about bogus readings that we fai to identify because Diff <DMAX? Embedded Eectronics Page 42 11/9/2007 Diff >= DMAX In this case, the agorithm assumes samping occurred during the transition and uses the vaue of LastA to determine if the signa is rising or faing. If faing (fwd motion) the ow byte of the counter is set to 0xFF (corresponds to +5V, just before the transition). If the signa is rising (rev motion), the ow byte of the counter is set to 0x00 (corresponds to +0V, just before the transition). In short, we treat this situation as if we had reay samped a tiny bit earier in time. Diff < DMAX In this case, we can t distinguish the bogus reading from a rea one, and the counter is updated with a temporariy incorrect count. The error is aways ess than DMAX, but typicay wi be smaer. In any case, because the anaog sensor generates an absoute position (within the [0..360] interva) and not an incrementa one, the very next counter update fuy corrects the count.

44 The vaue for DMAX is ocated in the Parameter Bock. It shoudn t be necessary to change the defaut vaues for DMAX or AD_GAP uness you want to experiment with faster motors than I have recommended The Digita Recursive Fiter In addition to the hardware RC fiter on anaog inputs [AN0...AN5], you can optionay enabe a Digita Low Pass Recursive Software Fiter to be appied to any of the [AN0...AN6] inputs. The fiter is enabed thru use of the bits in the FENBL byte in the Parameter Bock. The characteristic of the fiter is controed by the DECAY byte in the Parameter Bock. The cutoff frequency is inversey proportiona to the DECAY parameter (increasing the vaue of DECAY decreases the cutoff frequency). Here are the equations that define the fiter: The Y s are outputs and the X s are the inputs. Yn = (a0 * Xn) + (b1 * Yn-1) So, in words, the current fiter output Yn is the sum of two terms. The first term (the Xn term) is derived from the current input (ADC reading). The second term (the Yn-1 term) is derived from the previous output (the ast vaue stored in the ADC0[] memory array). The DECAY parameter determines the coefficients a0 and b1 as foows: d = DECAY/256 (0 <= d < 1) a0 = 1 - d b1 = d Restated in terms of the DECAY parameter, the above equation becomes more computationay convenient in terms of fixed point arithmetic. Yn = [ (256-DECAY)*Xn + DECAY*Yn-1 ]/256 Each time the ADC State Machine stores it s reading, the FENBL byte is examined to determine whether or not to empoy the fiter. If the fiter is not enabed for the current channe, the vaue of the raw reading (Xn) is stored in the ADC0[] array. If the fiter is enabed, the fiter computation occurs and the fitered vaue (Yn) is stored in the ADC0[] array. The vaue of the decay constant d is reated to the fiters time constant T by the equation: d = e ^(-1/T). For exampe if d = 0.80, then after T=4.48 sampes of X=0, the fiter output wi have decayed to 36.8%. Note that there is ony one DECAY parameter (not one for every channe), so the same fiter characteristic appies to a ADC channes for which it is enabed. Embedded Eectronics Page 43 11/9/2007

45 8.2.4 Anaog Encoder Hookup When using the anaog encoder option, the anaog votage signas from motors 1 and 2 are wired to the AN2 and AN3 screw terminas respectivey. Any avaiabe Vdd and GND can be used to suppy the sensor with the +5V and Gnd signa references. The anaogfb bit must be set in the appropriate MODE1 byte(s) in the Parameter Bock. The TPR parameter for the motor(s) that wi use anaog feedback shoud be set to 256 (0x0100). Mounting the sensor Your appication may require mounting the anaog sensor in such a way that forward motor movement actuay resuts in the sensor output indicating reverse direction. This situation is anaogous to the optica encoder mounting issue (see the aeadsb bit in the optica encoder section), but requires a sighty different soution. To see if you have this issue, connect the sensor and use the open oop command (Cmd X) to move the motor sowy in the forward direction whie monitoring the position using Cmd E. If the counter increases, you are fine and wi not need to make a change. If instead the counter decreases with forward motor movement you have 3 possibe options to fix things up: 1) Mechanica Change: If your motor is a dua shaft motor, remount the sensor on the opposing shaft. This change to the sensor orientation wi fix things up. 2) Eectrica Change: Reverse your motor eads. This change wi fix things up. One side effect of this change is that forward motor commands wi now cause the motor to move in the opposite direction to that previousy. Depending on your appication, this may not be acceptabe. 3) Software Change: Beginning in firmware version 1.60 there is a software change to fix things up. The software soution requires you to change the state of the anaogdir bit in the MODE3 parameter in the Parameter Bock. After making the change and resetting the board the sensor output and the motor movement shoud be in sync. Here is how this works: When the ADC Modue sampes the channe associated with the sensor output it wi compement the vaue that it reads if the anaogdir bit is set to 1. The effect is that faing votage ramps from the sensor are converted to rising ramps and vice versa Anaog Encoder Accuracy Accuracy is one advantage of optica sensors over anaog sensors. Errors in maintaining the position counter from the anaog input contribute to position inaccuracy. The errors in maintaining the counter come from the anaog sensor itsef, the conversion performed by the ADC Modue, and the agorithm used in updating the counter. Testing with the MA2 anaog sensor in parae with a US Digita optica encoder (TPR=256) gave satisfactory resuts. The anaog count typicay synched with the optica count to within +/- 2 ticks over fu range (not just [0..360]) operation. Position of the output shaft wi depend on the resoution of your encoder and mechanica factors ike shaft pay. In cosed oop operations, positioning wi aso depend on successfu PID tuning. If your appication is tuned, you can typicay achieve position accuracy for cosed oop operations to be within +/- 1 tick of your position counter. This error is in addition to the error in maintaining the counter. So, if your appication can toerate a tota position error that is no more than 4 or 5 degrees, the anaog sensor may work we for you. Embedded Eectronics Page 44 11/9/2007

46 9 Current Sensor Feedback This section describes the buit-in support for current sensing. Over current detection is disabed by defaut - see the ocie bit in the Parameter Bock. If your appication needs protection against over current, you wi have to suppy compatibe off-board current sensors and perform these setup steps: Adjust the digita pots to set your current imits. Seect one of the two buit-in responses to the over current condition. Enabe over current detection. 9.1 Sensor Seection The hardware and buit-in firmware provide support for over current detection and response when used with a compatibe off board sensor. I recommend Ha-Effect type sensors that generate anaog centeroffset votages proportiona to the measured motor current and direction (*). The 3-pin (+5V, VOUT,GND) AMPLOC current sensor with a sensitivity of 37mV/A is such a sensor and has been tested. The AMPLOC devices generate an output votage VOUT which is an offset from 2.5V. The sign of (Vout - 2.5V) indicates the current direction and the magnitude of (Vout - 2.5V) indicates current magnitude. (*) -Use of non center-offset sensors whose output reads zero vots for zero current is possibe, but there are imitations and the pot threshod settings are somewhat non-intuitive. A white paper wi be posted on the EE website to expain the imitations and usage of this type of sensor with the Daf Board. 9.2 Sensor Hookup There is a 3-pin connector on the Daf board for each sensor with abes (VDD, IS, GND). The IS (I Sense) pin of the connector is connected to the sensor VOUT signa. Attach the sensor eads to the connector for the appropriate motor [VDD, ISx, GND]. 9.3 Setup Digita Pot Settings First you wi want to adjust the digita pots that define the over current trip eves (the procedure is described a bit ater in this section). There are two pot settings (a ow votage threshod (VL), and a high votage threshod (VH) ) to be set for each motor. Over Current Response After you are satisfied with the current imit settings, the next step is to seect the over current response. The seection for the over current response is determined by the setting of the oc_fastoff bit in one of the MODE bytes (See the Parameter Bock in Appendix D). The two choices for the over current response are FastOff and SowRun. Rapid binking of the red LED indicates the over current condition. The Over Current Mode setting can be verified with the Get Status Command (Cmd_U). FastOff: ( oc_fastoff = 1 ) This option is the defaut and resuts in the immediate remova of motor power. It aso eaves the motor interface (for this motor) disabed and you wi have to reset the board before you wi again be abe to contro this motor. This is the appropriate response in situations where the over current condition is unexpected and you want to cease a motor activity unti the cause can be determined. This setting is aso appropriate for any over current testing that you might want to perform. SowRun: ( oc_fastoff = 0 ) This setting can roughy be described as a reduction in the motor power eve to maintain the current imits set by the pots. This is appropriate if you want your motor to keep trying, but at possiby reduced power eves. An exampe might be a manuay controed robot competition. Embedded Eectronics Page 45 11/9/2007

47 Enabing Over Current Detection Now that you have the current threshods set, and the response seected, the ony thing eft to do is enabe the feature. This is controed by the ocie bit in the Parameter Bock. You wi need to reset the board (the ocie bit setting is detected during power up) before the over current detection wi be enabed. 9.4 Under The Hood The sensor votages are -not- routed to anaog inputs on the microcontroer, but instead are inputs to votage comparator circuitry thru an RC fiter (see schematic). The votage threshods for the comparators are determined by digita pots (see schematic). The pots are adjusted to the proper trip eves by writing the desired eve (wiper tap position) using the primary I2C bus. Typicay the pot eves woud be set just once during initia setup. This over current circuitry drives a pair of interrupt capabe pins on the microcontroer and the interrupt handers respond to the over-current situation. To use this circuitry in your appication, you wi need to adjust the pots to provide the desired upper and ower votages for the votage window [VL, VH] for each of the IS inputs. For each sensor, a PIC interrupt is generated when the output votage from the sensor transitions into or out of the votage window defined by the pots. The vaues for the votage window endpoints shoud be determined by the appication (motor sta current, sensor sensitivity, etc.) and can be set directy from the command interface. For exampe, a reasonabe votage window might be [1.5V, 3.5V] which aows a 1000 mv excursion in either current direction from the nu offset (2.5V) before triggering an interrupt. The sensor that has been tested has a sensitivity of 37mV/A, so this exampe woud transate to a current imit of about 27A. In the picture to the eft, Regions A and C represent overcurrent. Region B is the norma operating region. 9.5 Limitations Generay, the over current condition wi be due to too much current in your drive eectronics (driver or motors). The response from the Daf Board is to remove (or reduce) the contro signas to your driver (stopping the motor). You wi -not- be protected against situations ike a VBATT/GND short - there is nothing the board can contro to hep with that. Initia over current detection requires a transition out of the operating region (Region B in the diagram) to detect over current. Thereafter a transitions across the VH and VL threshods are detected with appropriate responses. When you initiay power up the board the motor contro signas wi be in the off state. If for some reason you initiay power up in a high current state (Regions A or C), the over current situation won t be detected (with the motor contros aready off, the board can t remedy it anyway). This coud happen for exampe as the resut of a motor contro wiring error. After the sensor deivers a Vout votage that represents an over current situation there is a finite response time before the board firmware can respond. With the FastOff response, power wi typicay be removed from your drive eectronics within about 6 microseconds. This is about as good as it gets, but it is not instantaneous. Whether it wi protect you from a hard motor short is something you may not want to expore. Embedded Eectronics Page 46 11/9/2007

48 9.6 Over Current Response There are two choices for over current response. The seection is governed by the setting of the oc_fastoff bit as mentioned earier. You must decide which one is most appropriate for your appication. CASE1: SowRun (oc_fastoff = 0 ) This response effectivey protects your motor by degrading the requested power. When the over current condition is detected, the firmware responds by issuing a command to ramp the motor to a stop. Whie in the over current state the R/C and POT contros are disabed. Typicay, the process of ramping the motor speed to zero reduces the current to an acceptabe eve (Vout is again in Region B), and the R/C and POT mode interfaces are re-enabed. Depending on the interface you are using to contro the motors, you wi have different observations of the behavior when using this choice for the response. Pot or RC Modes If the over current situation occurs whie operating the contro switch at fu throtte (eg; motor staed), the observed effect might simpy be reduced drive to the motor with perhaps some fickering on LED3. An attempt wi be made to ramp the motor to a fu stop, but commony this goa is not achieved because the reduction in power resets the over current situation which aows the next R/C (or POT) command to again drive the motor too hard, which resuts in over current which I think you get the picture. This strugge persists unti the condition causing the over current response is removed, but meanwhie, your motor and drive eectronics are protected. CMD modes If the over current situation occurs whie operating the motor from the TE interface, the observed effect wi ikey be that the motor wi simpy be stopped. The difference between this and the other operating modes is that the command stream is sow (typing thru a termina emuator is sow) and the motor has time to stop before the next command is issued. The situation coud be different in the programmabe API and I2C2 interfaces. In these interfaces, it is possibe for the appication to repeatedy, and rapidy, issue new motor commands. In this situation, the response to over current woud be simiar to that of the POT and R/C modes. CASE2: FastOff (oc_fastoff = 1 ) This response protects your motor and driver by disabing a motor commands unti you reset the board. When the over current condition is detected, power to the motor wi be immediatey removed without ramping, and the motor contro interface wi -NOT- be automaticay restored when the measured current is again acceptabe (Vout in Region B). A board reset is required before you wi again be abe to operate the motor. The Seria CMD Interfaces wi sti function, but wi not respond to motor movement requests. 9.7 Adjusting the Current Limit Threshods Each MAX5478 Digita Pot Device provides dua 50K Ohm, non-voatie, 256 tap position, pots. There is one device (and two pots) per motor. The board has 4 test points ({V1H,V1L} for motor1, {V2H,V2L} for motor2) which provide convenient access (meter or scope) for the votage divider outputs from the pots. You wi hook up your meter (or scope) between these test points and GND to measure the votage threshods. The POT devices are programmed over the primary I2C bus to set the wiper positions to one of the 256 taps. Increasing the vaue written to the tap position [0x00 0xFF] wi increase the output votage at the corresponding test point. There are 12 registers on each device (see tabe beow), but it is ony necessary to program registers VREGA and VREGB on each device. As indicated in the schematic, the VxH test points correspond to wiper A and the VxL test points correspond to wiper B. The discussion and tabe beow shoud hep with the adjustment. Embedded Eectronics Page 47 11/9/2007

49 MAX5478 Registers Reg Name Reg# Function VREGA 0x11 Wiper A tap position (VH) NVREGA 0x21 Non voatie defaut for Wiper A NVREGAtoVREGA 0x61 Copy NVREGA to VREGA VREGAtoNVREGA 0x51 Copy VREGA to NVREGA VREGB 0x12 Wiper B tap position (VL) NVREGB 0x22 Non voatie defaut for Wiper B NVREGBtoVREGB 0x62 Copy NVREGB to VREGB VREGBtoNVREGB 0x52 Copy VREGB to NVREGB VREG 0x13 Both Wiper tap positions NVREG 0x23 Both Non voatie defauts for Wipers NVREGtoVREG 0x63 Copy NVREG to VREG for both Wipers VREGtoNVREG 0x53 Copy VREG to NVREG for both Wipers In the absence of any configuration code on startup, the wipers woud be set to the NVREG vaues on power up. However, shorty after power up commences, the Daf firmware reconfigures the pots to vaues hed in the Parameter Bock. This means that the non-voatie memories on the MAXIM parts are essentiay unused and don t need to be changed. Simpy record the desired power up vaues in the Parameter Bock aong with the other usua power up defauts. Simiary, it shoud not be necessary to access any of the copy functions (which use the other registers) for these parts. Foow this procedure to adjust the pots and record the settings into the Parameter Bock: 1. Attach a meter or scope to the appropriate VxH or VxL test point (see schematic). 2. Use the command interface (Cmd_M = SET Digita POT) to adjust the wiper and the corresponding wiper votage unti you have the measured votage set as desired. 3. Repeat for a 4 pots. 4. Use the command interface (Cmd_Z = UPLOAD To EEPROM) to upoad the current vaues to the Parameter Bock. Aternativey, you can write the desired pot settings directy into the Parameter Bock using the command interface (Cmd_W = Write Memory Byte). Reset the board and retest the pot votage eves. The settings shoud match what you recorded above. EXAMPLE: M 1 11 A0 M M 2 11 B0 M Z I ; V1H ; V1L ; V2H ; V2L ; Upoad ; Reset the board The votage at V1H after power up wi be roughy (0xA0/0xFF)*5 = (160/255)*5 = 3.1V Embedded Eectronics Page 48 11/9/2007

50 10 Termina Emuator CMD Interface This section appies to the TE Command Interface, however the discussion of command functionaity appies equay we to a three seria interfaces (TE, API, I2C2). The command protoco (syntax) wi differ a bit between the 3 interfaces, but the functionaity wi in genera be identica. For exampe, a Read Memory Byte operation from any of the 3 board memories (RAM, Interna EEPROM, Externa EEPROM) is achieved with the R command and is provided in a 3 interfaces. The Termina Emuator Interface (TE) is an ASCII RS232 interface suitabe for contro and monitor of your motors with the use of any of the many generic Termina Emuator Appications avaiabe for your PC. Whie arguments and resuts are transmitted and received as ASCII characters, the user interface requires some famiiarity with hex format. The Appications Programming Interface (API) is a binary RS232 interface suitabe for a smart PC Appication ike a Windows GUI. The API command protoco is described in a separate document. The Secondary I2C Interface (I2C2) is a binary I2C interface suitabe for communication with an off board device that hosts the Secondary I2C bus as a MASTER (The Daf Board is configured as a SLAVE on this bus). The I2C2 command protoco is described in a separate document. Beginning with Firmware Version 1.62, there is support for a Cmd Interface Timeout Feature. This feature when enabed, wi shutdown a motors if a vaid seria command is not received before the timeout period. This is of primary interest as a safety feature for motors driven by one of the two programmabe interfaces (API, I2C2), so wi not be described here. See the separate documents describing the API and I2C2 interfaces for detais RS232 Setup The TE interface, accepts most inputs, and deivers some outputs, in ASCII Hex character format. Whie this is not extremey user friendy, it is reasonaby efficient. A you need to use the TE interface is a standard RS232 cabe and a termina emuator appication running on your PC. The command interface is impemented with an RS232, 19,200 baud, 8bit, no parity, 1 stop bit interface. The commands and data are expected to be transmitted and received as ASCII characters via a Termina Emuator Appication running on a PC. The defaut baud rate may be changed (after powerup) by changing the nbr vaue in the Parameter Bock Command Syntax (CMD D0 D1 Dn) A command string is composed of a singe first byte which identifies the command. The CMD byte is optionay foowed by command parameters that are transmitted as data byte pairs. The CMD byte may be any ASCII character A - Z, a - z, but the ower case entry is converted to upper case (there are reay ony 26 commands). Each data byte is sent and received as a byte pair that represents a singe hex byte. For exampe to send the data byte 0xF3, the two ASCII characters F and 3 are transmitted. Pressing ENTER on the keyboard generates a carriage return (CR=0x0D) which terminates the command string and initiates command processing by the firmware. The data byte pairs may be separated by deimiters (SP, COMMA, or SEMI) to improve readabiity in the termina emuator window. Most data received wi be echoed back for dispay on the termina emuator window. Deimiter characters are not different in this sense, but the interrupt hander which receives data discards them - they are not stored in the Receive input buffer. Most contro characters are simpy ignored, but there are a few exceptions. The backspace character (BS=0x08) functions as a backspace (ie; is echoed back to the termina emuator), Embedded Eectronics Page 49 11/9/2007

51 aowing you to do error recovery before sending the command string. If the particuar command is designed to return data, it generay sends the data back in the same format. Exampe: The command A 0B stops both motors, disabes R/C and POT contro modes, and resets the PWM freq to 16,026 Hz. For a discussion of the detais of how this works, see Cmd_A. Embedded Eectronics Page 50 11/9/2007

52 Command syntax tips: A of the exampes in the command section which foows show the data byte inputs as 2 characters separated by the SP deimiter. For exampe the command to read a byte from the externa EEPROM at address 0x000C is shown as R C. The R is the command byte, the 0x02 is the memory type (in this case externa EEPROM), and the remaining two bytes 0x00 and 0x0C indicate the high and ow order bytes of the address. Notice that the command string actuay consists of 10 bytes (incuding spaces), but I have referred to the byte pairs as bytes, because that is how they wi be used by the command hander. In this particuar exampe the syntax woud be indicated by [CMD D0 D1 D2] to indicate the four fieds. The TE Command Parser aows some short-cuts that you might want to use after you are famiiar with the non-abbreviated form. Hex bytes which may be represented as a singe hex character (vaues 0 thru 15) may be entered as singe characters provided that they are separated from other variabes with a deimiter. Deimiters are not required, but if not used, you must enter a data bytes in the paired form even if the vaue is a singe digit. For exampe: R02000C, R2 0 0C, R 2 0 C, and R2 0 C are a acceptabe aternatives to the command parser for the above command. Error handing: The command parser wi generay catch and respond to most syntax errors by echoing an appropriate error message and aborting the command. Be aware that whie the parser wi verify the expected number of arguments for the command, the commands themseves may not aways do compete error checking. So if a particuar command specifies that an argument is range imited, it is up to you to ensure that you suppy a vaue that is in range. A word about ogging: Both the TeraTerm and Hyperterm termina emuators provide a mechanism to record your session to a text fie. This can be very usefu. One exampe woud be usage in conjunction with the Read Memory Bock command to record your Parameter Bock settings to a fie. Another exampe is usage with features ike the PID Tuning Command to capture data for graphica anaysis with other programs (eg; Exce). With TeraTerm, use the Fie/Log.. menu to seect the og fie. With Hyperterm, use the Transfer/Capture Text tabs. A word about the motor movement commands: The open oop motor contro command is Cmd_X. This command aows you to specify motor speed as a PWM duty cyce percentage [0-100%]. Because the command is open oop, the parameter is not reay a motor speed contro, but reay a motor power contro. As with a of the open oop contro modes, there is no feedback from the motor and therefore no guarantee that the motor wi actuay achieve the desired speed. In fact, ugging down the motor(s) after execution of this command wi resut in a noticeabe speed decrease. Take a ook at the roes of the parameters VSP and AMINP in motor contro. There are two different cosed oop motor contro commands. The first of these is Cmd_S which aows cosed oop veocity contro. The second is Cmd_Y which aows you to specify a trapezoida trajectory speed profie for moving the motor to a target position under PID contro. Before you try the cosed oop commands, you shoud read the materia discussing PID Tuning. Besides the VSP and AMINP parameters, pay attention to the roe that some of the PID parameters pay. You wi probaby need to adjust some or even a of these for optimum functionaity. A of the commands are expained in the Command Specification Section. Embedded Eectronics Page 51 11/9/2007

53 Embedded Eectronics Page 52 11/9/ Termina Emuator Cmd Crib Sheet Cmd Description Syntax A Set PWM freq A <index> B Fan Contro B <fan#> <on/off> C Get A/D C <adc_ch> D Set/Get RTC D <hh><mm><ss> E Get Motor Position(s) E <mtr#> F Set Encoder F <mtr#> <ehi> <emid> <elo> G,H //UNUSED// I Reset I J IO Expander Write J <ioexp#><ioreg#><databyte> K IO Expander Read K <ioexp#><ioreg#> L Read Memory Bock L<memtype><adrshi><adrso> M Set Digita POT M<pot#><reg#><byte> N Get R/C Puse Widths N <ch> O Stop Motor(s) O <mtr#> P Set/Get PID Parms P <mtr#> <KPH><KPL> <KIH><KIL> <KDH><KDL> Q PID Step Response Q <mtr#> <TgtHi> <TgtMid><TgtLo><LimHi><LimLo> R Read Memory Byte R <memtype><adrshi><adrso> S Move (constant veocity;cosed oop) S <mtr#> <dir> <VmHi> <VmLo> <AccHi> <AccLo> T Trigger Move (Cosed oop) T <mtr#> U Motor Status U <mtr#> V Motor Veocity V <mtr#> W Write Memory Byte W <memtype><adrshi><adrso><databyte> X Move (constant veocity; open oop) X <mtr#> <dir><spd><tsew> Y Move (to position; cosed oop) Y <mtr#> <TgtHi><TgtMid><TgtLo> <VmHi><VmLo> <AccHi><AccLo> Z Upoad to EEPROM Z Notes: A: index: (0x00.. 0x18) seects pre-programmed PWM frequencies. B: fan#:(1,2), on/off: (0=off, 1=On) C: adc_ch: ADC Channe (0-6) optiona D: Decima arguments. E: mtr#(1,2) optiona. F: mtr#(1,2), e=24 bit, 2 s compement encoder position (defaut: 0). J,K: ioexp#:(1,2), ioreg#:(0x00..0x15). L: memtype{1=ram, 2=Ext EEPROM, 3=Int EEPROM}, bock size=128 bytes. M: Pot# (1,2); reg#(0x11, 0x12,.. others - see data sheet); Two devices, 4 pots. N: ch: R/C Channe (1,2,3) optiona O: mtr#(1,2) optiona. P: Enter mtr# for View. Set requires a 7 args. KP, KI, KD 16 bits. Q: Tgt is 24 bits, Lim contros output to Termina Emuator. R: memtype:(1,2,3) U,V: mtr#(1,2) optiona. W: memtype(1,2,3). X: tsew: (0..255) msec. Defaut = AMINP.

54 Y: 8,6, or 4 args (24 bit Tgt is required. Acc defaut is ACC, Vm defaut is VMID. Z: Upoads 128 bytes starting at RAM: 0x0100 to Ext EPROM: 0x0000. Embedded Eectronics Page 53 11/9/2007

55 10.4 Termina Emuator Command Specification Each of the command handers has expectations with regard to the number and type of arguments. Some arguments represent singe hex bytes, whie others are mut-byte arguments. In the case of muti-byte arguments, the high order bytes are entered first, just as you woud write them (this is one difference between this interface and the API and I2C2 interfaces). For exampe; the two byte address of 0x015C woud be entered as 01 5C. Some arguments are optiona and this is indicated in the CMD description. In some cases, optiona arguments, which are not suppied, are repaced with defauts. In other cases, the ack of the argument signas both as in some commands that expect an argument for motor#. See each command for detais. In the command descriptions, D0 wi refer to the first data byte, D1 to the second and so forth. Remember that each of these data bytes is actuay an ASCII byte pair that represents a singe HEX byte. Syntax: A D0 D0 = PWM_TBL Index Cmd_A PWM Freq Contro The index seects the PWM frequency from the tabe beow. If the motors are running they are first ramped to a stop (using AMINP for deceeration) and the disabe (DIS) ines are asserted. This command wi aso disabe any Pot or R/C Contro Modes. The vaue of D0 is then copied into the ERAM variabe corresponding to fpwm (see the Parameter Bock) and then used as an index into the foowing tabe to initiaize the PWM hardware contro registers: {T4CON, PR4} to produce the requested frequency. fpwm = 1/[(PR4+1)*4*Tosc*prescae]; Tosc=1/40E6, T4CON defines a Prescae of 1,4, or 16. The command provides a PWM frequency range described by the foowing tabe: (Tabe continued next page) PWM Frequency Tabe D0 (=fpwm) FREQ (Hz) T4CON PR4 0x00 2,441 0x7F 255 0x01 3,005 0x7F 207 0x02 4,006 0x7F 155 0x03 5,000 0x7F 124 0x04 6,010 0x7F 103 0x05 7,022 0x7F 88 0x06 8,013 0x7F 77 0x07 9,058 0x7F 68 0x08 10,000 0x7D 249 0x09 12,019 0x7D 207 0x0A 13,966 0x7D 178 0x0B 16,026 0x7D 155 0x0C 17,986 0x7D 138 0x0D 20,000 0x7D 124 Embedded Eectronics Page 54 11/9/2007

56 (Continued) D0 (=fpwm) FREQ (Hz) T4CON PR4 0x0E 25,000 0x7D 99 0x0F 30,120 0x7D 82 0x10 35,211 0x7D 70 0x11 40,000 0x7C 249 0x12 45,045 0x7C 221 0x13 50,000 0x7C 199 0x14 59,880 0x7C 166 0x15 69,930 0x7C 142 0x16 80,000 0x7C 124 0x17 90,090 0x7C 110 0x18 100,000 0x7C 99 Comments: 1) The PWM frequency seection provided by this command governs the current session ony. To make the seection permanent, you can write the fpwm vaue directy into the Parameter Bock to affect the defaut power-up frequency, or use the Upoad feature. (See commands Write Memory Byte, Upoad To EEPROM ) Cmd_B Fan Contro Syntax: B D0 D1 D0 =Fan# (1,2) D1 = Fan On/Off contro (0=off, 1=on) This command contros a pair of high current drivers (minimum 200mA for each) suitabe for inductive oads. Each driver consists of an NPN transistor, base resistor, and a free-wheeing diode to hande inductive oads. If using the OSMC driver boards and the standard 10 pin connector, the suppy for the fans wi be the +12V reguated output from the OSMC boards (See schematic). Aternativey, you may suppy your own fan power suppy by connecting your power source to the +12V and GND pins on the PL1 and PL2 connectors. The high side of the oad is connected to the power source thru the connector abeed F1+ (or F2+). The ow side of the oad is connected to the coector of the drive transistor using the F1- (or F2-) connector. The D1 vaue is used to contro the microcontroer output pin that deivers current to the base of the drive transistor seected by D0. The state of this contro is recorded in a bit in the ERAM variabe MODE1 and affects the current session ony. Write your seection directy into the Parameter Bock to affect the defaut power-up state (See commands Write Memory Byte, Upoad To EEPROM ) Cmd_C Get AtoD Reading (mv) Syntax: C D0 D0 = Channe (0-6) Returns: Channe reading in mv If this command is given without the D0 argument, readings from a channes are returned. The Anaog-To-Digita-Converter State Machine provided in the firmware cycicay sampes and records the vaues of the seven anaog inputs (signas AN0 - AN6) in memory starting at the RAM ocation ADC0. Timing contro of the ADC State Machine can be customized by atering parameters in the Parameter Bock which act as indices into a timing tabe. The measured vaues are stored in an 8-bit hex format with the vaue proportiona to the input votage. This command converts the requested reading(s) to units of miivots and returns the converted vaue(s). Embedded Eectronics Page 55 11/9/2007

57 Channe 6 is dedicated to monitoring the VBATT votage and the ADC measurement corresponds to that portion of VBATT that is produced by the votage divider between VBATT and GND. The measurement of the votage at this divider is maintained in ADC0[6] in a manner identica to the other vaues. However, periodicay (once every second) in the main oop service Svc3, the vaue is converted to a VBATT reading and stored in the RAM variabe vbatt. The conversion of ADC0[6] to vbatt can be tuned by changing the resistor divider caibration constant VBCAL in the Parameter Bock Cmd_D Set/Get RTC Syntax: D D0 = HH (Hours: 0-23) D1 = MM (Mins: 0-59) D2 = SS (Secs: 0-59) If no Arguments returns: HH:MM:SS (current time) Unike most others, this command accepts and returns resuts in decima. the 24 hour cock format (0 <= HH <= 23). The resuts and inputs assume If no arguments are provided (Get RTC), this command simpy dispays the RTC: HH/MM/SS by converting the hex vaues stored in the RAM variabes HOURS, MINS, and SECS to BCD. If the 3 arguments are suppied (Set RTC), the BCD input vaues are converted to Hex and stored in the RAM variabes HOURS, MINS, and SECS Cmd_E Get Motor Position Syntax: E D0 D0 = Motor# (1,2) Returns: [D0,D1,D2] = encoder position (24-bit, 2 s compement format). If the command is issued with no argument, encoder positions for both motors are returned. The resut represents the current vaue of the position counter maintained by the firmware and associated with the optica encoder on the seected motor shaft. This is a 24 bit, 2 s compement vaue and the resut is presented as a 6 digit hex string. Optionay (TE Interface ony), you can seect decima dispay by setting the pos_d bit in the MODE3 parameter in the Parameter Bock. Eg; 0079F3 Motor currenty at forward position 0x79F3 = ticks. Eg; FFF624 Motor currenty at reverse position 0x9DC = ticks. Each tick represents an edge on the optica encoder signas, so there are 4*CPR ticks per shaft revoution (CPR is the optica encoder spec: Cyces Per Revoution). An optica encoder that has CPR=64 wi have TPR=256 ( Ticks Per Revoution ). With such an encoder in the first exampe, the motor woud have rotated forward (from the home position) by 31219/256 = revoutions. In the second exampe, the motor position woud correspond to a reverse rotation position of 2524/256 = 9.9 revoutions Cmd_F Set Encoder Syntax: F D0 D1 D2 D3 D0=Mtr#(1,2) [D1, D2, D3] = Encoder Vaue This command sets the encoder count on the specified motor. The Encoder Vaue argument is assumed zero if it is not suppied (resets encoder). First the command disabes POT or R/C Contro Modes and stops (removes power from) the motor. It is possibe for motor momentum to change the encoder count after the vaue has been set by this command. Embedded Eectronics Page 56 11/9/2007

58 To avoid this, stop the motor and wait a reasonabe setting time before issuing the command. Aternativey, check the resut using the Get Motor Position command. If not equa to the desired setting, you can reissue the Set Encoder command Cmd_G // UNUSED // Cmd_H // UNUSED // Cmd_I Reset Board Syntax: I This command waits briefy for the termina emuator echo of the chr I to compete and then executes the RESET Instruction. Generay a software reset is not as robust as a fu hardware reset, but the RESET instruction purports to be just as good Cmd_J IoExp Write Syntax: J D0 D1 D2 D0=IOEXP# (1,2) D1=Reg Address (0x00 0x15) D2=Data Byte There are two IO Expanders on the Daf Board and each provides 16 GPIO s which are routed to connectors on the board. The microcontroer communicates with these devices over the primary I2C bus at a bit rate of 400 KHz. This command gives write access to the registers interna to the IO Expanders. It is used to provide configuration and output contro of the GPIO s. The byte vaue D2 is written to the register number D1 on the IO Expander specified by D0. See the section IOEXP Functions in the Firmware Library for detais concerning the IO Expanders and their registers Cmd_K IoExp Read Syntax: K D0 D1 Returns: D2 D0=IOEXP# (1,2) D1=Reg Address (0x00 0x15) D2=Data Byte This command provides Read Access to the registers interna to the IO Expanders. This incudes input pin status for those GPIO s configured as inputs. The byte vaue D2 is read from the register number D1 on the IO Expander specified by D0. See the section IOEXP Functions in the Firmware Library for detais concerning the IO Expanders and their registers Cmd_L Read Memory Bock (RAM OR EEPROM) Syntax: L D0 D1 D2 D0=Memory Seect (1=RAM, 2=EXT_EEPROM, 3=INT_EEPROM) D1=AdrHi D2=AdrLo This command provides a 128 byte window into any of the 3 memory devices. The address represents the ocation of the first byte in the 128 bock. The data is sent to the termina emuator screen in groups of 8 Embedded Eectronics Page 57 11/9/2007

59 bytes per ine. The address is range checked for vaidity (to make sure that the address +127 is in the device memory space): Vaid [D1 D2] Address Range: RAM: Ext EEPROM: Int EEPROM: 0x0000-0x0F80 0x0000-0xFF80 0x0000-0x0380 These ranges permit a view of the fu address space of the devices. You can use this command with termina emuator ogging enabed to capture a copy of your Parameter Bock settings to a fie. This wi enabe you to easiy restore your settings at a ater time if that becomes necessary. Note that the API and I2C2 versions of this command provide the same functionaity but are a bit more genera because they permit a variabe bock size for the amount of data to be read Cmd_M Set Digita POT Syntax: M D0 D1 D2 D0=Pot Seect (1=Pot1, 2=Pot2) D1=Pot Cmd (Generay VREGA=0x11, or VREGB=0x12) D2=Tap Position (0-255) This command provides for adjustment of the votage references used by the over current detect circuitry. Each Pot Device has dua 50K pots with 256 wiper positions for each. See the section Current Sensor Feedback section in this manua for detais on how to adjust the pots for current sensing appications. Syntax: N Returns: D0,D1,D Cmd_N R/C Snapshot RtnVar D0 D1 D2 Puse Width (usec) Ch1 Ch2 Ch3 This command is used to view the puse width outputs in units of microseconds from your receiver. The resuts are accurate to within a microsecond and can be usefu for R/C switch tuning. See a discussion of this topic in the Radio Contro section of this document. In a nutshe, use the resuts of this command to see exacty what your receiver is outputting for each of the corresponding transmitter switches. Embedded Eectronics Page 58 11/9/ Cmd_O StopMotor(s) Syntax: O D0 D0 = Motor# (1=Motor1, 2=Motor2) If no Motor# argument is suppied, this command wi stop both motors. This command stops the specified motors using a sew rate determined by the AMINP parameter in ERAM. This command essentiay stops the motors as fast as you have deemed safe by your choice of AMINP. If you have set AMINP to 0, this command wi immediatey (drive train ouch!) stop the motor(s). Note: This command disabes POT and R/C Contro Modes (ERAM based fags), and terminates the Trajectory Generator and PID Controer if these are active. The operating mode becomes CMD Mode. Here is a

60 potentia gotcha to be aware of: If you use this command and then save your run-time environment (ERAM) with the UPLOAD TO EEPROM command (before re-asserting POT or R/C contro modes), your next power-up wi have CMD Mode as the defaut. If power is being suppied to the motor for braking (eg; steep hi), and this command is executed, the motor wi free-whee. Embedded Eectronics Page 59 11/9/2007

61 Cmd_P Set/Get PID Parameters Syntax: P D0 D1 D2 D3 D4 D5 D6 D0=Motor# (1=Motor1, 2=Motor2) D1=KPH D2=KPL D3=KIH D4=KIL D5=KDH D6=KDL This command aows you to set the 16-bit constants {KP, KI, KD) which pay a major roe in PID contro. It aso permits you to view these 3 and a few other contro variabes affecting PID performance. Set: If you enter the command with the fu argument ist it wi copy the arguments into the ERAM variabes (for use during this session ony) and do -NOT- ater the vaues stored in the Parameter Bock. Typicay this command is used as part of the PID Tuning process and the fina vaues are ater upoaded or stored directy into the Parameter Bock to become the new power-up defauts. The PID constants {KP,KI,KD} are not the tota PID story by far, so be sure to read the Trajectory Generation and PID section of this document for a description of the other variabes that may need to be changed to achieve optimum performance in your appication. Get: If this command is issued with the Motor# as its singe argument, the current PID constants and some other mosty PID reated variabes wi be dispayed. An exampe appears beow: P 2 MTR# : 2 KP : 0700 (7*256) KI : 0400 (4*256) KD : 0C00 (12*256) VSP : 14 (20 msec) VMIN : 03 (3% motor brake/deadband) VMAX : 64 (100%: PWM not imited) MAXE : 2000 (Stop motor if Err exceeds MAXERR=8,192) MAXS : 0100 (Cip Integra Sum at +/- 256) Note that a of the above variabes may be changed for the current session, which can then be upoaded to the Parameter Bock in EEPROM to become the new power-up defauts if desired. However, note that this command aows you to change KP, KI, and KD ony. See the Write Memory Byte command for detais on changing the other RAM variabes. See the Write Memory Byte and Upoad To EEPROM commands for changing the Parameter Bock in Ext EEPROM. Embedded Eectronics Page 60 11/9/2007

62 Embedded Eectronics Page 61 11/9/ Cmd_Q PID Step Response Syntax: Q D0 D1 D2 D3 D4 D5 D0=Motor# (1=Motor1, 2=Motor2) D1=StepH (Target Destination; Hi Byte) D2=StepM (Target Destination; Mid Byte) D3=StepL (Target Destination; Lo Byte) D4=PidLimitH (Output Lmit; Hi Byte) D5=PidLimitL (Output Limit; Lo Byte) This command is used to evauate the step response of the motor contro system for use in cosed oop operations. You wi not need this command uness you are panning on using cosed oop motor operations (Cmd_S, Cmd_Y, Servo Modes). Before executing this command, read the PID (Cosed- Loop) Motor Contro section of this document to get a brief description of PID and the roe of the contro parameters in determining the PWM duty cyce (power) output to the motor. In practice, this command is used in cose association with commands P, W, R and L, with the goa of obtaining cosed oop contro parameters that produce an acceptabe step response. The process of identifying the proper contro parameters is caed PID Tuning. Manua PID Tuning describes a tria and error process which is faciitated by this command and your observations of the resut. Typica usage invoves 3 steps repeated over and over again unti you obtain satisfactory resuts: 1. Make parameter changes 2. Execute this command (identica arguments each time) 3. Evauate the resuts This tria and error process is repeated unti you are satisfied with the step response. The evauation of the the resuts consists of watching the behavior of the motor and anayzing the output to the termina emuator window (assuming verbose enabed) after the motor has stopped. By enabing ogging, you can capture the output to a fie which can be imported for graphica anaysis (eg; Exce). With a bit of experience, you wi be abe to determine the needed parameter changes simpy from the termina emuator output. When you have used this command to obtain a reasonabe step response for your motor you wi have made the coarse adjustments necessary to get a reasonabe motor response in your appication. Any further adjustments in your actua appication shoud be minor and you wi be ready for any of the cosed oop operations. What are the arguments? The Step argument governs how ong the motor wi run. It is used as the target destination. Typicay, one or two seconds of runtime is sufficient to evauate the motor contro response. The PidLimit argument governs how much output is sent to the termina emuator screen. For exampe, with PidLimit = 0x0200, there wi be 512 ines of output. Typicay, 20 to 40 observations after the motor has reached the target are sufficient. If the PidLimit argument is not suppied, then it wi be defauted to the vaue NPID in the Parameter Bock. If you have termina emuator ogging enabed when you execute this command you wi have captured the step response to a fie which can be imported into a graphica appication (eg; Exce) for easy anaysis. However, after a bit of experience, eyebaing the resuts in the termina emuator window is often sufficient. There are a coupe of step response pots in Appendix A to give you an idea of what to expect. What does the command do? After preiminary argument checks, the motors are stopped if necessary and PID is disabed. Any POT or Radio Contro modes wi aso be disabed. Then the command resets the encoder position to [000000] (*). This aows you to repeat this same command over and over again with

63 a constant vaue for the step. It aso means that this particuar command operates in the same way regardess of the re/abs# setting (See the MODE1 fags). (*) - For an absoute anaog encoder, the encoder is reset to [00 00 xx] where xx represents the position of the motor in the current revoution. If you keep the ow byte of your step target = 0x00, subsequent command executions wi ikey start with an encoder position near [ ] - simiar to the optica encoder case. The Step argument is oaded into the 24 bit variabe xpos which the PID controer uses and PID is enabed to rapidy drive your motor to the target destination. Assuming that Verbose Mode is enabed (defaut=enabed), the PID Err vaue during each VSP samping period is output to the termina emuator screen. It is this ist of errors that wi hep you determine how we tuned your motor response is. The Err vaues wi start at the target step vaue (that is the initia position error) and shoud rapidy converge toward zero with possiby some overshoot and osciations. The error may never reach zero, may overshoot zero, or may osciate around zero. You wi probaby want to issue the stop motor command (Cmd_O) shorty after the motor reaches the target. This wi remove power from the motor and stop any osciations that may be present. What is the goa? The goa is a set of PID parameters that wi rapidy drive your motor to the step destination with itte or no overshoot and with the error rapidy setting at or near zero without continuing osciations. A bit of pre-panning and setup wi hep to make this a smooth process. You wi benefit from reading the sections in this document on Trajectory Generation and PID Contro before attempting this command. This command repaces what the Trajectory Generator provides in norma cosed oop motor moves with a fixed stationary target (your Step input), but otherwise most of the materia in those sections appy. A bit of caution: 1. This command causes an abrupt motor response even with perfecty tuned contros. So, be sure that your whees (or whatever) are off the ground when you execute it. If you are concerned about your drive train, disconnect it. Be aware however that the best contros for a no-oad system wi probaby not be optima for a fuy oaded system. 2. Stay cose to the termina keyboard, ready to issue the off command (Cmd_O) in case things get out of hand. The expected behavior for this command is that the motor wi start rather vioenty at near fu speed in an attempt to acquire the destination. As the motor nears the destination, it shoud sow down, but there wi quite possiby be some overshoot, and osciations about the target before the motor settes at (or near) the destination. It is aso possibe that osciations wi continue, so be ready to stop the motor if necessary. Some tips: 1. As a starting point for the step vaue in your testing, I woud suggest a step magnitude that wi give you no more than 2 seconds of runtime at maximum motor veocity Exampe: Whie running motor2 forward at fu (100%) duty cyce using the open oop motor move command (eg; X ), you find that the veocity (eg; V2 ) is 0x = 25 ticks/vsp2. If VSP2 = 20msec, this represents a veocity of (25 ticks/20msec) or 1250 ticks/sec. So a vaue of 0x (1,280) might be reasonabe for the target vaue. Using a ess anaytica approach, just try the command a few times starting out with sma vaues for the target unti you get somewhere between 1 and 2 seconds of runtime before your motor arrives at the target. Embedded Eectronics Page 62 11/9/2007

64 2. Use verbose mode (the defaut). This wi aow you to capture the PID Err to the dispay of the termina emuator. Experiment with the PidLimit argument to get just enough output and possiby a bit more to capture the essentia portion of the step response. You wi want enough output to see the PID Err get to (or near) zero and a bit more -- perhaps as much as 20 to 40 sampes more. Once you have setted on a vaue for PidLimit you might want to record it (NPID) so that you don t have to keep entering it (if you record it in the Parameter Bock remember that you wi have to reset the board to make it usabe). 3. If you have ogging enabed(*) in your termina emuator appication, you wi have captured the motor step response in a og fie which you can then easiy import into a graphica appication ike Exce for a visua anaysis. See the exampes in Appendix A. (*) To record your session to a text fie, use the Fie/Log.. feature in TeraTerm or the Transfer/Capture Text tabs in Hyperterm. 4. Since you wi ikey be changing parameters in a tria and error process, Use the Set/Get PID Parameters command to view the PID parameters just before executing the step response command. This wi give you documentation in your termina emuator window of the PID parameters used to produce the test resuts. Parameter Suggestions: Begin by taking the ErrSum term and the ErrDiff terms out of the PID picture for initia tuning. You can do this by initiay setting the KI and KD parameters to zero (see the PID equations). It is quite possibe that your appication wi not need a of the PID capabiities. For exampe, you might be just fine with a PD (no integra term) controer. Don t fee ike you must use a of the PID terms just because they are avaiabe. The I-term may be unnecessary uness you have an appication where you have difficuty achieving and maintaining a zero steady-state error (eg; stopping a robot on an incine). Be patient and methodica. KP: Start with sma numbers. Start the tuning process with something ike {KP=0x0100, KI=0x0000, KD=0x0000). Then graduay increase KP in sma increments (say 0x0100) unti you are satisfied. You can use the Set/Get PID Parameters command to change or view the run time vaues of these 3 constants. You can ony use this command to change the primary 3 PID constants KP,KI, and KD, but the command can be used to VIEW pretty much a of the variabes invoved in the PID process. By setting KI and KD to zero, you wi take the Integra and Derivative terms out of the picture initiay aowing you to home in on a correct vaue for KP. With KI=0 you aso won t have to worry about MAXSUM or the sumho fag for a bit. If you have very fine resoution on your encoder (CPR arge), or you have fast motors, you may need to increase MAXERR to avoid fase triggering of an error condition which wi abort the STEP RESPONSE command. Your goa shoud be to have a sufficienty arge vaue of KP that the motor reaches the target reasonaby rapidy. A bit of overshoot is ok - the KD term can fix that up ater. Your motor shoud sette at or near the target. Vaues of KP that are too arge may cause osciations that don t stop. Back the vaue of KP off unti that doesn t happen. You may want to experiment a bit with the vaue of VMIN to make sure that you don t have this parameter set too high. KD: Now try increasing increasing the vaue of KD in sma increments (say 0x0100) to reduce overshoot and osciations. If there was overshoot and/or osciation in previous trias without the use of KD, you shoud begin to see a noticeabe difference. When most or a of the osciations and overshoot are gone, stop increasing KD. Embedded Eectronics Page 63 11/9/2007

65 KI: OK, you are satisfied with your KP and KD parameters. If you decide that your appication needs the integra term (KI>0) you wi again want to start out with sma test vaues for KI. You aso need to know that the integra errors (the KI term) wi begin to accumuate immediatey when using Cmd_Q, regardess of the state of the sumho fag. The issue here is that in norma PID operations initiated by Cmd_Y, it is the Trajectory Generator which decides when to eventuay enabe ErrSum accumuation (when the trajectory is finished and presumaby the motor is near the fina target). However for the STEP RESPONSE command, the Trajectory Generator is not running. You wi need to be sure to test fina adjustment of KI using Cmd_Y. Additiona testing: This PID Tuning Process wi have given you the necessary coarse adjustment to the PID parameters and with their use you can expect reasonabe resuts from cosed oop operations. You wi need to do a bit of testing with Cmd_Y ( Mtr Move (Cosed-Loop Contro ) to reay ensure proper functionaity. When you do this be sure to enter reasonabe (achievabe) vaues for veocity and acceeration variabes {Vm, a}. Try motor movements with both sow and faster (but achievabe) vaues for Vm Try movements with fina destinations that are both cose and far from the starting position. If you find that moves to very cose destinations don t resut in motor movement or eave the motor short of the destination, you may need to increase the gain (KP) a bit. If it becomes necessary to make additiona changes, you might want to recheck the resuts of CMD_Q with the new vaues. Saving your vaues: When you fee satisfied with the Step Response you wi probaby want to save your current parameters in the Parameter Bock so that they wi become the defaut. The easiest way to accompish this is to immediatey use Cmd_Z ( Upoad to EEPROM ). Remember that by using Cmd_Q you wi have reset the operating mode to CmdOny (disabed R/C and POT operation) and this setting (uness first changed) wi be copied as we. Aternativey you can copy your current settings individuay to the Parameter Bock using Cmd_W. Syntax: R D0 D1 D2 Returns: D Cmd_R Read Memory Byte D0 = Device (1=RAM, 2=Ext EEPROM [24LC512], 3=Int EEPROM) D1=AdrHi D2=AdrLo D3=Vaue of byte read at ocation [AdrHi, AdrLo]. This command aows you to read a singe data byte from any of the 3 memory areas: RAM [0x0000-0x0FFF] is interna to the microcontroer. Ext EEPROM [0x0000-0xFFFF] is an externa device accessed on the primary I2C Bus. Int EEPROM [0x0000-0x03FF] is interna to the microcontroer. The ast 160 bytes of the RAM [0x0F60-0x0FFF], the specia function registers (SFR s), are memory mapped in the microcontroer to contro the various hardware peripheras (timers, pwm, i2c, seria ports, etc.). The PIC18F6722 Data Sheet (Microchip web site) gives a of the detais needed for successfu access of the SFR s. Detais of genera RAM usage depend on evoving firmware design, but there is an important 128 byte bock of RAM (starting at address 0x0100) referred to in this document as ERAM. On power-up ERAM wi be a copy of the first 128 bytes of the Ext EEPROM (the Parameter Bock). It is usefu to become famiiar with ERAM since some changes to ERAM aow runtime testing without the need to change the Parameter Bock and reboot. Exampes: R1 1 0 ; Read RAM ocation 0x0100 R2 67 F0 ; Read Ext EEPROM ocation 0x67F0 R3 3 FF ; Read Int EEPROM ocation 0x03FF Embedded Eectronics Page 64 11/9/2007

66 Cmd_S Move (Constant Veocity, Cosed- Loop) Syntax: S D0 D1 D2 D3 D4 D5 D0: Motor# (1,2) D1: Motor Direction; 0=Fwd, 1=Rev [D2 D3]: vm = 16 bit scaed (*) int, desired Veocity (ticks/vsp) [D4 D5]: a = 16 bit scaed (*) int, Acceeration (ticks/vsp^2) This command provides motor contro for appications that require constant veocity under varying motor oading conditions. The command is impemented using PID and the Trajectory Generator. The discussion in the PID and Trajectory Generator sections of this document appies to this command. The main difference between this command and the cosed oop move command, is that here no target is specified, and the motor wi remain in the constant veocity portion of the veocity profie indefinitey (unti stopped or another motor command is issued). When the motor woud normay deceerate to the target, this command causes the constant veocity portion of the profie to be restarted (incuding resetting the encoder position). Three possibiities for command syntax are supported by this command depending on whether a arguments are suppied or not. The optiona arguments, if not suppied, wi be repaced with defauts from the Parameter Bock: {mtr#, dir, vm, a} - A 6 arguments suppied. {mtr#, dir, vm} - 4 arguments suppied. ACC is used for the acceeration. {mtr#, dir} - 2 arguments suppied. VMID is used for vm, and ACC is used for acc. This command wi error if attempted whie in one of the R/C or POT Operating Modes. The command wi aso error if either vm = 0, or a = 0. Pease see the Trajectory Generator and PID sections in this document for additiona detais. It is important to use reasonabe (achievabe) Trajectory Generator cmd arguments for vm and a for cosed oop operations. This appies to the commands: Cmd_S, Cmd_Y as we as servo operations. Your motor system has characteristics that determine the range of achievabe vaues for acceeration and veocity. Experiment with the open oop commands to determine these characteristics. If vaues are used that cannot be achieved by your motor appication, you may experience abrupt motor transitions and/or error terminations prior to target acquisition. This appies as we to the vaues of VMID and ACC in the Parameter Bock since these vaues may be used as defauts for the vm and a arguments. See Cmd_Y (Motor Move - Cosed Loop) for a more detaied discussion of the vm and a scaed arguments Cmd_T Trigger Move (Cosed Loop) Syntax: T D0 D0=Motor# (1=Motor1, 2=Motor2) When trigmode is enabed, the cosed oop motor move commands (See Cmd_S, Cmd_Y) do not commence immediatey, but instead wait for a trigger to be issued by this command. In this way, synchronized cosed oop motor movements are possibe. Embedded Eectronics Page 65 11/9/2007

67 This command wi generate an error if trigger mode is disabed (defaut=disabed). The trigmode fag is contained in the MODE1 parameter (See Parameter Bock). You can use the Write Memory Byte command to change either the ERAM copy or the Parameter Bock copy. If no argument is given with this command, any pending cosed oop moves for either motor wi be started. Syntax: U D0 D0 = Mtr# (1,2) Cmd_U Get Status This command sends operating status for the specified motor to the termina emuator screen. If the Mtr# argument is not suppied, resuts are suppied for both motors. The dispay wi ook ike the foowing: MTR# : 1 (possibes: 1, 2) MODE : CMD (possibes: CMD, POTF, POTC, RC, RCMIX) PWM : FWD( 20%) (possibes: FWD(xxx%), OFF, REV(xxx%)) TRIG : OFF (possibes: ON, OFF) SUMHO : ON (possibes: ON, OFF) TGT : ABS (possibes: REL, ABS) OCMODE : NONE (possibes: NONE, FASTOFF,SLOWRUN) MODE is sef expanatory. If the seected motor is not in one of the POT or RC modes this wi be CMD. The percentage shown for forward or reverse is duty cyce, not speed. If you have PWM power appied to the motor, this number wi be positive even if your motor is ocked up. The TRIG, SUMHO, and TGT settings appy ony to cosed oop motor contro. TRIG indicates whether you are in cosed-oop-trigger mode or not. That is; do cosed-oop motor commands execute immediatey, or do they await a trigger signa for execution? SUMHO indicates whether you are in Err-Sum Hod Off mode or not. In this mode, PID err summations are not appied (hed off) to the PID equation unti near target acquisition in order to avoid the Integra Windup issue. TGT indicates how the vaue entered for target in the motor move command wi be treated. Is the target position to be entered as the absoute position, or is the target position to be given reative to the current motor encoder position? ODMODE indicates whether or not over current detect is enabed, and if yes, which response is seected. To change mode settings, see the parameters MODE1, MODE2 in Appendix D. The runtime environment can be atered for the current session ony, or the vaues in the Parameter Bock may be changed in order to become the defauts for future power-ups Cmd_V Get Motor Veocity Syntax: V D0 D0 = Mtr# (1,2) Returns: D1,D2,D3 D1=VH (Veocity High Byte) D2=VM (Veocity Mid Byte) D3=VL (Veocity Low Byte) If this command is given without argument, both motor veocities are given. The resut represents the ast cacuation stored in the 24 bit, 2 s compement RAM variabe V1 (or V2 for motor2). The units are Embedded Eectronics Page 66 11/9/2007

68 encoder ticks/vsp msec. Optionay (TE Interface ony), you can seect decima dispay by setting the ve_d bit in the MODE3 parameter in the Parameter Bock. This vaue is computed once per VSP sampe period as the difference between the encoder count during the previous period and the current encoder count. The Veocity Samping Period is controed by the ERAM variabe VSP (separate vaues possibe for motor1 and motor2). The defaut vaues for VSP1 and VSP2 (see Appendix D) is appropriate for my appication/motor/encoder combination, but may not be right for yours. A vaue of VSP=0x14 represents a veocity sampe every 20 msec. Exampe: VSP2 = 0x14 = 20 msec, CPR=64. Assume this Cmd deivers a resut of The interpretation here woud be 0x19 = 25 ticks/20msec or 1,250 ticks/s. TPR = 4*CPR = 256 ticks/rev. This transates to a motor anguar veocity: V2 = (1,250 ticks/s)*(1rev/256ticks)*(60s/min) = rpm. The TPR (Ticks-Per-Revoution) parameters (See Parameter Bock) vaue is used by this command to convert veocity in ticks/vsp into units of RPM. Syntax: W D0 D1 D2 D Cmd_W Write Memory Byte D0 = Device (1=RAM, 2=Ext EEPROM [24LC512], 3=Int EEPROM) D1=AdrHi D2=AdrLo D3=Vaue of byte read at ocation [AdrHi, AdrLo]. This command aows you to write a data byte to any of the 3 memory areas: RAM [0x0000-0x0FFF] is interna to the microcontroer. Ext EEPROM [0x0000-0xFFFF] is an externa device accessed on the primary I2C Bus. Int EEPROM [0x0000-0x03FF] is interna to the microcontroer. See the Cmd Read Memory Byte for a brief discussion of these memory areas. Exampes: W W2 67 F0 8 W3 3 FF E2 ; Write byte 0x12 to RAM ocation 0x0100 ; Write byte 0x08 to Ext EEPROM ocation 0x67F0 ; Write byte 0xE2 to Int EEPROM ocation 0x03FF Syntax: X D0 D1 D2 D Cmd_X Move (Constant Power, Open-Loop) D0: Motor# (1,2) D1: DIR=Motor Direction Contro (0=Forward, 1=Reverse) D2: SPD=Motor Speed Contro (0-100; PWM Duty Cyce: 0=Stop, 100=Fu Speed) D3: tslew=motor Acceeration Contro (0-255 ms: 0=Immediate, 255=sowest) Embedded Eectronics Page 67 11/9/2007

69 The tslew argument is for acceeration contro in ramping the motor to the specified duty cyce. The units of tslew are miiseconds. If tslew is not provided, or tslew < AMINP(see Parameter Bock), this command wi use AMINP as the defaut vaue for tslew. The command wi error if attempted whie in one of the R/C or POT Operating Modes. Open Loop: This command does not use the optica encoder feedback to affect the motor drive and is consequenty open oop in nature. The actua acceeration is inversey reated to the tslew input vaue. The acceeration as we as veocity wi be affected by motor oading. Whie the duty cyce input directy contros the magnitude of the veocity, it does not aow you to maintain a given veocity under oading conditions. Even under no oad conditions, the vaue of the input wi yied a different veocity depending on battery votage, motor characteristics, etc. The duty cyce (0-100) represents a percentage of fu votage. The acceeration variabe tslew aows for ramping the motor speed to the desired state, avoiding abrupt motor state changes. Emergency stops or other necessary immediate state changes can be achieved with tslew=0 (*). The 8-bit variabe tslew is actuay a period and has units of miiseconds. Every tslew miiseconds, the firmware wi adjust the duty cyce from the current state by 1% unti the desired duty cyce (your entry) is achieved. Exampe: Assume that motor1 is running in the forward direction with a 22% duty cyce and you want to increase this to 48% (0x30) somewhat graduay: X ; Motor1, Forward, 48% Duty Cyce, tslew = 20 miiseconds. In this case, since the motor is currenty running forward with a 22% duty cyce, the command cas for a 26% change (48%-22%). Because tslew is 20 miiseconds, this wi occur at a rate of 1% every 20 miiseconds. The motor wi reach the target speed in roughy 26*20msec = 520 msec. Direction changes require that the motor first be stopped. However, the firmware takes care of this for you by first stopping the motor (ramping down veocity at a rate given by tslew=aminp) and then rescheduing your requested motor contro operation after the motor is safey stopped. The motor may be stopped using either the Stop Motor command or by using this command with a duty cyce of 0%. In either case, the motor wi be stopped immediatey if tslew =0 (*), or ramped to a stop if tslew is non-zero. (*) Actuay, you wi be abe to stop the motors immediatey ony if you have disarmed the acceeration governor AMINP (set AMINP=0). This variabe can be changed in the run-time environment for the current session or changed to become the defaut for tslew by changing the vaue in the Parameter Bock. Setting AMINP to zero is probaby not a good idea, but you may want to customize it for your appication. Embedded Eectronics Page 68 11/9/2007

70 Cmd_Y Mtr Move (Cosed-Loop Contro) Syntax: Y D0 D1 D2 D3 D4 D5 D6 D7 D0: Motor# (1,2) [D1 D2 D3]: x = 24 bit, 2 s comp. Target Position (ticks) [D4 D5]: vm = 16 bit scaed (*) int, desired Midcourse Veocity (ticks/vsp) [D6 D7]: a = 16 bit scaed (*) int, Acceeration (ticks/vsp^2) Three possibiities for command syntax are supported by this command. Some optiona arguments, if not suppied, wi be repaced with defauts from the Parameter Bock: {mtr#, x, vm, a} - A 4 arguments suppied. {mtr#, x, vm} - 3 arguments suppied. ACC is used for a. {mtr#, x} - 2 arguments suppied. VMID is used for vm, and ACC is used for a. This command wi error if attempted whie in one of the R/C or POT Operating Modes. The command wi aso error if either vm = 0, or a = 0. This command starts the Trapezoida Trajectory Generator which generates path waypoints for the motor to foow in moving to the destination. Simutaneousy, a cosed oop PID contro process is started that drives the motor to foow the path to the target destination. The acceeration variabe a contros the rate of change of the veocity during the constant acceeration and deceeration portion of the process. The variabe vm contros the veocity during the constant midcourse veocity portion of the profie. The REL/ABS setting (defaut = ABS) for mode of target entry determines how the x argument is treated. If in ABS mode, x is treated as the target destination. If in REL mode, x is treated as a signed offset from the current motor encoder position in determining the target position. Pease see the Trajectory Generator and PID sections in this document for additiona detais. Important Notes 1) Here is a ist of some other contro parameters in the Parameter Bock that infuence the operation of this command. In genera, it wi be necessary for you to first Tune the PID Controer (obtain optimum vaues for some of these parameters) before expecting good resuts from the cosed oop motor contro commands. KP... Proportiona constant KI. Integra constant KD Derivative constant VSP....Veocity Samping Period (msec) VMIN.. PWM minimum (motor deadband) VMAX PWM maximum (Speed governor) MAXERR... Maximum PID position error before automatic motor turnoff. MAXSUM.. PID Error sum wi be cipped to +/- MAXSUM MODE1... See EEPROM section for bit definitions. VMID... Midcourse veocity (defaut for vm ) ACC. Trajectory Generator Acceeration (defaut for a ) 2) If cosed oop trigger mode is enabed (disabed by defaut), this command wi be hed as pending awaiting a trigger command. See the Cosed Loop Trigger command for detais. 3) It is important to use reasonabe (achievabe) Trajectory Generator cmd arguments for vm and a for cosed oop operations. This appies to the commands: Cmd_S, Cmd_Y as we as servo operations. Your motor system has characteristics that determine the range of achievabe vaues for acceeration and veocity. Experiment with the open oop commands to determine these characteristics. If Embedded Eectronics Page 69 11/9/2007

71 vaues are used that cannot be achieved by your motor appication, you may experience abrupt motor transitions and/or error terminations prior to target acquisition. This appies as we to the vaues of VMID and ACC in the Parameter Bock since these vaues may be used as defauts for the vm and a arguments. The variabes a and vm are given in units that invove VSP. This means that if you use different vaues of VSP for each motor, you wi need different arguments for Motor1 and Motor2 commands to achieve the same effective motor speed and acceeration. The vaues you enter for a and vm are treated as scaed inputs by a factor of 256 for use by the trajectory generator. The scaed inputs for these parameters provide an easy vehice to aow fractiona contro vaues without actuay having to dea with fractiona inputs. Exampe: You enter 0x680 for vm. The vaue used by the Trajectory Generator is: VM=vm/256=6.5 (ticks/vsp). If you use the Get Motor Veocity command during the constant veocity course of this command, you woud expect to generay see a vaue of V=6 (ticks/vsp) or V=7 (ticks/vsp); the veocity samping period is asynchronous with encoder transitions. If the acceeration entry is a =0x0030, then the actua acceeration used by the Trajectory Generator is A=a/256= (ticks/vsp^2). Syntax: Z Cmd_Z Upoad To EEPROM Use this command to copy ERAM (the RAM data that represents the current run-time-environment) into the Parameter Bock of the non-voatie EEPROM. In this way, the current environment wi be restored to RAM (copied from the Parameter Bock to ERAM) on the next power-up. For a ist of the data that is copied, see Appendix D. If necessary, the origina factory defauts for the Parameter Bock can be restored (osing any customizations) by simpy hoding down on the BTN switch during power up reset. Embedded Eectronics Page 70 11/9/2007

72 11 POT Mode Interface The pot contro modes are disabed by defaut. Before you wi be abe to use these motor contro methods, you wi have to enabe it using the command interface (See MTRx_MODE2). You can enabe the pot mode contro for the current session, or you may make it the defaut operating mode for subsequent powerups. In addition to the three open oop veocity contro modes described here, there is a cosed oop position contro mode (PotSvo) described in a ater section. See aso the section of this document which describes the optiona digita ow pass fiter Pot Modes In PotC Mode, the center position of each pot is mapped to zero veocity and excursions in either direction produce increasing speed changes in either forward or reverse. POT anaog readings of 0x80 thru 0xFF are mapped to motor veocity in the forward direction, and readings of 0x7F thru 0x00 are mapped to motor veocity in the reverse direction. In PotF Mode, the fu range of each POT is mapped to a 0-100% motor duty cyce and the setting of the FWD/REV# switch contros both motor directions. As an exampe, in the PotC mode, the centra ocation of the pot (2.5V) wi correspond to motor off whie in the PotF mode, that same position and votage wi resut in ½ speed (either forward or reverse), with the separate switch controing the motor direction. In PotMix Mode, the signas from two externa pots are mixed in order to use a singe, 2-axis, contro device known as a joystick. In this mode, forward stick trave (+Y) resuts in forward drive being appied to -both- motors. Reverse stick trave (-Y) resuts in reverse drive being appied to -both- motors. Left (-X) and right (+X) trave on the stick is used to modify -both- the motor drive eves for turning. The connections are not symmetric with this mode (see beow). Recommended connections for a differentia drive system: Connect your motor 1 driver to the right motor (as seen from drivers seat), and motor 2 driver to eft motor. Confirm that seria motor commands drive the proper motor in the desired direction before proceeding. Now configure both motors in POTC mode (without mixing). This wi enabe you to more easiy get the joystick movements in sync with the desired motor directions. Connect the wiper signas from the joystick pots to the anaog inputs. The Y-Pot wiper shoud be connected to AN0 screw termina input (Motor 1 = right motor) and the X-Pot wiper shoud be connected to the AN1 screw termina input (motor 2 = Left motor). Now connect the Vdd and GND connections to the X-Pot and Y-Pot such that +Y drives motor 1 forward and +X drives motor 2 forward. If the directions are wrong, switch Vdd and GND connections and Embedded Eectronics Page 71 11/9/2007

73 retest. Now change the operating modes for both motors to PotMix (ike the R/C Mix mode, this operating mode must be seected for both motors in order to achieve the mixing operation) and test joystick operation Pot Connections The pot range is not too important, but I recommend using pots in the 2K Ohm range. Smaer vaues waste power needessy. Larger vaues can impact the response time for the A/D samping circuitry. Regardess of which pot mode you have chosen, the POT hook-ups are identica. Connect the center pin of the 2 pots (the wipers) to the AN0 and AN1 anaog inputs thru the Daf on-board connector. Any avaiabe VDD and GND connections on the Daf board can be taken off board for the other two pot pins. For safety, an externa On/Off switch (On=VDD, Off=GND) is required to be connected to the D0 input. You can use SPST switches with current imiting resistors, but the simpest arrangement is to use SPDT switches (see the diagram beow). If PotF mode is used, connect the additiona Direction Contro Switch (Forward=VDD, Reverse=GND) to the D1 input on the Daf board using a SPDT switch with simiar hookup to that shown for D Enabing Pot Modes A pot contro mode is enabed whenever the bit which enabes it in the MODE2 variabe is set. There are essentiay two ways to enabe the desired pot contro mode. If you want the change to be become the defaut operating mode on subsequent power ups, record the change in the Parameter Bock in the parameter that corresponds to MODE2. If you want the pot mode to be active temporariy ony, you can make the change to the ERAM variabe MODE2, but if you do it this way you shoud stop the motors first. To make the change to RAM: Use the Read Memory Byte and Write Memory Byte commands to change and verify the vaue of the variabe MODE2. To make the change in the Parameter Bock: Use the same commands as above, but with the appropriate arguments for access to the Ext EEPROM data. Then use the RESET command to power up using the changed vaue to set the defaut operating mode to the specified pot contro mode. You can use Cmd_U (Get Status) to confirm correct operating mode Important Pot Mode Parameters: Two important parameters in the Parameter Bock that affect the Pot operating modes are PMSP and AMINP. You shoud be fine with the defauts to begin with, but you may want to customize these variabes ater. Appendix D shows where these parameters are ocated in the Parameter Bock. The PMSP (Pot Mode Samping Period) Parameter contros how frequenty the firmware acts on your pot and switch inputs. This is distinct from the ADC rates which contro how frequenty the anaog inputs from the pots are acquired and stored in RAM. Embedded Eectronics Page 72 11/9/2007

74 The AMINP (Acceeration Minimum Period) Parameter is an acceeration governor and is designed to imit the sew rate to safe eves during rapid veocity changes or abrupt stops. This parameter, whose units are miiseconds, is important for other motor contro methods as we. AMINP is the minimum acceptabe period (=fastest acceptabe acceeration/deceeration) at which a 1% change wi be made when ramping veocity changes. Embedded Eectronics Page 73 11/9/2007

75 12 R/C Mode Interface The R/C Contro Modes are disabed by defaut. Before you wi be abe to use either the RCNRM or RCMIX open oop motor contro method, you wi have to enabe it using the CMD Interface (See MODE2 in the Parameter Bock). You can enabe radio contro for the current session (changes to ERAM), or you may make it the defaut operating mode for subsequent power-ups (changes to Parameter Bock) Receiver Connections Any avaiabe VDD and GND connections on the Daf board can be used to suppy +5V receiver power. Connect the receiver outputs to the Daf Board connector as foows: EX0:ch1 EX1:ch2 EX2://unused// EX3:ch Receiver Output Signas A receiver output is represented by a puse whose time width conveys the transmitter switch position. Typicay, fu trave on the transmitter switch resuts in a puse width output at the receiver with a nomina range of [1000 usec, 2000 usec] with the center position c (about 1500 microseconds) corresponding to servo off. The puse is repeated by the receiver every 20 msec or so. The Daf firmware provides an adjustabe deadband parameter to ensure that the switch center position wi truy represent off. Interrupt driven firmware and specia hardware (CCP Modues) on the Daf Board capture puse width timing measured in microseconds for each of the 3 channes. There is essentiay no atency and 0.80 microsecond resoution in this process so the puse width measurements are quite accurate. The puse widths are then mapped (depending on R/C operating mode) to the appropriate motor contro (PWM) responses R/C PWM Mapping The R/C Puse Width Measurement is mapped to a motor duty cyce % as iustrated. A scaed vaue m is pre-computed and stored in RAM to minimize run time computation * 200 m = RCMAX - RCMIN - d Embedded Eectronics Page 74 11/9/2007

76 12.4 R/C Tuning Some R/C transmitters permit endpoint adjustments to propery match switch endpoints (end of switch trave on the transmitter) to the desired receiver output (puse width) on the channe assigned to the switch. This process of adjusting each switch to its assigned servo can be thought of as R/C Switch Tuning. For exampe, in typica R/C operation, a desired position for a particuar servo can be made to correspond to fu forward on the transmitter switch that contros it. This adjustment is done on a channe by channe basis by adjusting the transmitter output so that the receiver generates the desired output puse width for that channe when the switch is at fu trave (forward and/or reverse). The R/C interface on the Daf Board contros a pair of DC motors whose veocity range [-100%, 100%] is mapped to the puse width range [RCMIN us, RCMAX us] for channes 1 and 2. The defauts for RCMIN and RCMAX are 1000 us and 2000 us respectivey. If the maximum trave of your channe 1 transmitter switch resuts in a puse output from your receiver whose width is 1850 usec (for exampe), this wi not resut in fu motor1 speed without some adjustments. There are two ways to perform this tuning process depending on whether the change is made at the transmitter or on the Daf Board: Endpoint Adjustment At Transmitter: If your transmitter has this feature you may make the switch trave adjustment at the transmitter. With this procedure you adjust the transmitter unti your receiver outputs have puse widths that match the Daf defauts [RCMIN, RCMAX]=[1000 us, 2000 us] stored in the Parameter Bock. The fu trave of the switch wi then correspond to the [RCMIN, RCMAX] range that the Daf firmware uses for the mapping. The R/C SNAPSHOT Command (Cmd_N) can be very hepfu here aowing you to make the adjustment easiy and accuratey without the necessity of any test equipment (eg; oscioscope) Endpoint Adjustment On Daf Board: Use the R/C SNAPSHOT (Cmd_N) command to determine the puse widths corresponding to the existing switch endpoints for each channe you wi use on the Daf Board. Then record these vaues into the EEPROM Parameter Bock (see the WRITE EEPROM command) in pace of the existing RCMIN, RCMAX defaut vaues. These new settings wi become the defauts on subsequent power-ups. This method has the advantage that if you use your transmitter with another device, your transmitter switches can remain tuned to that device, whie sti functioning optimay with the Daf Board. Either of the two methods above wi resut in matching the receiver outputs for fu range of switch trave on your transmitter with the Daf R/C Parameters, and the fu range of switch trave on the transmitter shoud then correspond to the fu range [-100%, 100%] of motor duty cyce (ie; you wi be R/C Tuned ) R/C Modes Mixed vs Norma Mode: There are two operating modes provided. There is a Mixed Mode and a Norma Mode. In Norma Mode (tank mode), channe 1 contros ony motor1, and channe 2 contros ony motor2. In this mode, the switch controing channe 1 wi be mapped to fu forward and reverse operation of motor1 with the center position corresponding to off (anaogous to PotC mode). In Mixed Mode, channe 1 is the main drive for both motors whie channe 2 modifies the drive signas for both motors for turning. In this mode, the switch center position sti represents off. Mixed mode is commony used with a singe stick on the transmitter (having both XY trave to operate 2 channes). In this mode, forward stick trave (+Y) resuts in forward drive being appied to -both- motors. Reverse stick trave (-Y) resuts in reverse drive being appied to -both- motors. Left (-X) and right (+X) trave on the stick is used to modify -both- the motor drive eves for turning. Do not confuse these 2 operating modes with the mixing which may be a feature provided by your transmitter. Embedded Eectronics Page 75 11/9/2007

77 13 Servo Modes The two servo contro modes are disabed by defaut. Before you wi be abe to use one of these motor contro methods, you wi have to enabe it using the command interface (See MTRx_MODE2). You can enabe the servo mode for the current session by changing the parameter in ERAM, or you may make it the defaut operating mode for subsequent power-ups by changing the parameter in the Parameter Bock Cosed Loop Operation The contro inputs for the servo modes come from either an externa potentiometer or an R/C Transmitter just as in the previousy expained open oop R/C and POT modes. The primary difference between the servo modes discussed here and the previousy discussed R/C and POT Modes is the nature of the motor contro. In the open oop POT and R/C contro modes, the motor speed was controed by the inputs. In the Servo Modes discussed here, it is the motor position that is controed. One other difference is that when using the servo modes the motor contro is cosed oop. The Servo Modes require motor position feedback - either with anaog or optica encoders, and utiize PID and the Trajectory Generator code to achieve the desired motor position. I recommend use of an absoute anaog encoder for feedback in servo operations. The probem with use of an incrementa encoder for servo operations is that the shaft position is not known at startup. When using an incrementa optica encoder the position counter is reset to 0x at startup. If your pot or R/C switch requests a position that woud require ½ revoution of the shaft from 0x000000, that is what you wi get (even if the motor is aready at the desired position on startup!). Smooth and optima performance in using the servo modes is aso highy dependent on appropriate PID parameters for your particuar motor appication. If you are not satisfied with the defaut performance of this feature, and you have not performed PID Tuning, I recommend that as your next step. If you have ever driven a car with an engine bady out of tune, you can appreciate the huge difference this can make in servo performance. There is a termina emuator command (Cmd_Q) that can assist you in PID Tuning Servo Limits Typicay in a servo appication the output shaft rotates in an operationa region that is some fractiona portion of a fu revoution. For exampe, the servo motor might rotate between 10 degrees and 350 degrees. In this exampe, if the TPR vaue for your encoder was 256, you woud want to set your operationa range to [7 249] (Hex: [0x xF9]) in units of encoder ticks. 10 deg * (256 ticks/rev)*(1rev/360 deg) = 7.11 ticks There are two parameters MIN and MAX, one set for each motor, in the Parameter Bock to estabish the operating imits for your motor position in servo contro modes. You wi notice that MIN and MAX are word vaues, so as you might suspect, the rotation imits are not imited to the [0,360] range, but this is atypica. In the above exampe, you woud set MIN = 0x0007, and MAX = 0x00F9. Be aware that increasing the imits beyond one fu rotation wi decrease your positiona resoution. The [MIN MAX] operating imits are software imits, not mechanica imits. There is nothing to prevent your motor from briefy moving past the MAX imit for exampe (especiay if your system is not PID Tuned!). If this is a concern, be a bit conservative in setting the imits. Embedded Eectronics Page 76 11/9/2007

78 13.3 Connections The POT and R/C connections are identica to that described in earier sections. In Pot Servo Mode the pot inputs for motors 1 and 2 are connected respectivey to the AN0 and AN1 screw termina inputs and the pot reading is mapped ineary to the desired motor position. Pot Servo mode, ike the other Pot modes, requires the use of the externa On/Off switch connected to the D0 screw termina. In R/C Servo Mode the R/C receiver outputs for channes 1 and 2 are connected to the EX0 and EX1 screw termina inputs and the R/C puse width measurements are mapped ineary to the desired motor position Pot Servo Mapping The POT Reading is mapped to a motor position as iustrated. The sope m is MAX - MIN m = Pot Servo Parameters Besides the previousy mentioned PMSP (the defaut wi probaby be fine for you here), the MAX and MIN parameters are obviousy important and shoud be set to meet the needs of your servo appication. Because the servo modes utiize PID, the KP, KI, and KD parameters are important. If you wi be using anaog feedback (instead of incrementa encoders) for your motor position, the vaue of DMAX or AD_GAP may be important to you but probaby the defauts wi be fine. See the section of this document describing anaog feedback for detais R/C Servo Mapping The R/C Puse Width Measurement is mapped to a motor position as iustrated. A scaed vaue m is pre-computed and stored in RAM to minimize run time computation. 100 * ( MAX - MIN) m = RCMAX - RCMIN 13.7 R/C Tuning The process of adjusting the transmitter or aternativey changing the defaut vaues of RCMIN and RCMAX to match the receiver outputs for your transmitter switch endpoints is identica to that described in Embedded Eectronics Page 77 11/9/2007

79 the earier R/C section. This step is important to achieve optimum R/C servo performance. If your receiver outputs don t cosey match your stored vaues for RCMAX and RCMIN the above mapping won t be accurate and your position imits won t be achieved R/C Servo Mode Parameters Besides the previousy mentioned RCSP (the defaut wi probaby be fine for you here), the MAX, MIN, RCMAX, and RCMIN parameters are obviousy important and shoud be set to meet the needs of your servo appication. Because the servo modes utiize PID, the KP, KI, and KD parameters are important. If you wi be using anaog feedback (instead of incrementa encoders) for your motor position, the vaue of DMAX or AD_GAP may be important to you but probaby the defauts wi be fine. See the section of this document describing anaog feedback for detais. Embedded Eectronics Page 78 11/9/2007

80 14 Trapezoida Trajectory Generator 14.1 Trajectory Generator Overview The Trajectory Generator is enabed whenever a cosed oop motor contro command is issued (*). The roe of the Trajectory Generator during the course of a motor move command is to periodicay generate the desired position ( waypoint ) to be compared with the actua (encoder) position by the PID Contro. The Trajectory Generator by itsef does nothing to ater motor behavior it just produces data. It is the job of the PID Controer (next section) to make the motor foow the veocity profie produced by the Trajectory Generator. It is usefu to understand some of the detais of the Trajectory Generator. Consider the typica case where the motor is stopped and you want the motor to move to a particuar target destination (represented by a specific encoder count). The roe of the Trajectory Generator is to generate a periodic sequence of waypoints (desired encoder positions) representing smooth veocity transitions to the target. The idea is that if the PID controer can force the motor to foow the path generated by the Trajectory Generator, with the appropriate timing, it wi make for a reasonaby smooth motor journey. No sudden jerks on start or stop, but instead a smooth ramped acceeration to a midcourse constant veocity that woud be maintained unti a smooth ramped deceeration to a stop. The Trapezoida portion of the name describes the typica appearance of the veocity profie (veocity vs. time graph) which is the mode for the math that generates the waypoint data. There are cases in which controed motor movements cannot achieve the desired trapezoida veocity profie. One exampe is the case of a motor starting position and ending position that are sufficienty cose that there isn t sufficient time to achieve the specified ramp-up, steady veocity, ramp-down to target position given the input parameters for acceeration and midcourse veocity. In fact, the firmware treats 4 different veocity profie cases and does not require the motor to be initiay stopped. If the motor is currenty moving in a direction opposite to that which is required to achieve the target, it wi be smoothy ramped to a stop before the trajectory driven move is started. A note about the PID and Trajectory Generator Math: The PID motor contro and the Trajectory Generator use dedicated foating point computations. By dedicated, I mean that they don t use the Microchip Foating Point Library routines suppied with the compier. Instead they use competey separate routines and additionay do not share data storage for parameters and resuts with the compier ibrary routines. (*) - The Trajectory Generator is -NOT- active during execution of the PID Tuning command. Instead, the PID Tuning uses a singe, static, step vaue as the target destination Trajectory Generator Detais Units The Trapezoida Generator and the PID Controer coud work in any consistent units. Whie SI units might be appropriate, they are not computationay efficient. Instead, encoder ticks are used as the positiona unit, ticks/vsp as the veocity unit, and of course, ticks/vsp^2 as the acceeration unit. Given the vaue of VSP, and the TPR of your encoder (TPR = 4*CPR), it is easy to convert position, veocity and acceeration vaues to SI units. Embedded Eectronics Page 79 11/9/2007

81 Trajectory Generator Timing The Trajectory Generator Period (the time between generation of successive waypoints) is the Veocity Samping Period (VSP) parameter in the Parameter Bock. The vaue of VSP is an important parameter for cosed oop motor contro, and shoud be adjusted to fit your motor/encoder characteristics. An inappropriate vaue of VSP can cause poor cosed oop motor contro and/or suggish system response. How to determine VSP? In genera, for PID contro, it is desirabe to have the smaest practica samping period. In practice, there are imitations to making VSP too sma. First, there is some serious foating point math that gets executed for each waypoint by both the Trajectory Generator and the PID Controer. If the vaue of VSP is too sma, you wi ug down the system with the frequent math. If the vaue of VSP is too arge, there wi be too ong a period of time between motor update commands during PID controed operations. This can ead to motor instabiity or undesirabe osciations. For many appications, the defaut vaue of VSP=5 msec wi be fine, but if not, how do you choose a vaue of VSP? First it is necessary to understand the reationship between VSP and the vaue of V (ticks/vsp) reported by the Get Motor Veocity command. Try this experiment: Use the command interface to appy constant power to your unoaded motor (Cmd_X). Use the Get Veocity (Cmd_V) command to record the vaue of V (ticks/vsp). Now use the command interface to doube the vaue for VSP in ERAM and repeat the experiment. You won t see any change in the actua motor speed of course, but what wi change is the vaue reported for V. If you doube the samping period (VSP) with the motor running at the same speed, then twice as many ticks wi occur in the new samping period, hence V (ticks/vsp) wi aso doube. For constant motor veocity, the vaue of V (ticks/vsp) is directy proportiona to VSP. What is important about this reationship is that the vaue of V can be used to assess a suitabe vaue for the VSP parameter. Exampe: Assume that your motor is running at minima speed and the command interface reports that V=6 (ticks/vsp). If PID were active, at this veocity, new motor commands wi be issued every 6 ticks of the encoder (once every VSP). Another way to say the same thing is that the motor wi have had a chance to advance 6 ticks since the ast PID motor correction. For very sow motor speeds (eg; near the trajectory start and end points), 6 ticks is probaby too arge. If possibe, decrease VSP unti V <= 2 (ticks/vsp) when running at your minima motor speed. VSP Tips: Use the argest vaue of VSP that provides acceptabe cosed oop performance. If you haven t aready purchased encoders, choose the encoder CPR vaue to meet your resoution needs, but don t get finer encoder resoution than you reay need. Using the CMD Interface, adjust VSP unti you get a vaue of V<=2 whie running at the owest power eve that gives consistent motor speed. I don t recommend VSP < 3ms, but with some very fast motor/encoder combinations, this may be necessary to achieve acceptabe cosed oop contro. Embedded Eectronics Page 80 11/9/2007

82 In order to understand the Trajectory Generator timing, it is hepfu to know a few of the detais about the cosed oop contro system provided by the board and firmware. The foowing sections provide a bit of an under-the-hood discussion of what takes pace in the Trajectory Generator firmware during cosed oop operations Trajectory Setup When a cosed oop motor contro command is issued, the Trajectory Setup Routine is caed. The setup routine is caed ony once for each motor command and is responsibe for sanity checks on the input parameters, capture of the initia encoder position and motor veocity, conversion of integer arguments to foating point format, determination of the Trapezoida Case, computation of timing interva endpoints, and computation of the coefficients for the 2 nd order poynomia f(t) = c0 +c1*t +c2*t^2 which gives the desired distance from the encoder start position at time t. There are as many as 3 timing intervas ([0,t1], [t1,t2], [t2,t3]) depending on the Trapezoida Case, and a different poynomia is used for each interva. The timing state variabe is set initiay to (t=0), and fags are set that wi cause the Trajectory Routine and PID Routine to be caed periodicay from the main oop every VSP msec Trajectory Routine Every VSP msec the Trajectory Routine (not the setup routine) is caed to generate a waypoint. The waypoint at time t is a 24 bit 2 s compement vaue x(t) which gives the desired motor encoder position at that moment. The Trajectory Routine is impemented as a state machine, but during the execution of any given move command ony a subset (depending on the Trapezoida Case ) of the states wi be traversed. Every VSP msec, the main oop wi first ca the Trajectory Routine, foowed immediatey by a ca to the PID Routine. The Trajectory Routine increments the timing variabe t t+1 ( t is in units of VSP msec), and evauates d = f(t), the desired distance from the initia encoder position at time t. This is then converted into a 24 bit, 2 s compement format, waypoint x(t) which represents the desired motor encoder position at time t. If t exceeds, the right endpoint of the current timing interva (a boundary crossing representing a transition in the trapezoida veocity profie), a transition to a new state occurs requiring the use of new coefficients for f(t). The PID Fiter Routine accepts the waypoint x(t), the current motor position (encode(t)), and the various PID contro parameters and outputs a PWM contro vaue that wi drive the motor to a position that reduces the error. See additiona detai on the PID routine in the next section. I have expained these detais here because I want to discuss timing a bit. I have done timing measurements with some typica exampes and here is what I have observed. Timing: The PID and Trajectory Setup Routines are pretty predictabe with respect to timing. Generay, the initia ca to Trajectory Setup takes the most time by far. I have isted in the tabe beow some typica execution times. Timing for the Trajectory Routine varies depending on the Trajectory Case and the vaue of the state variabe (which timing interva is active). A typica trajectory path (depending on distance to the target and other factors) can often have hundreds or more waypoints. Keeping in mind that an instruction cyce period is tosc/4 = 0.1 microseconds, here is a tabe for timing guidance. Routine Cyces Time Trajectory Setup 9, usec Trajectory usec PID 1, usec So, assuming a singe motor is moving because of a cosed oop motor contro command you can expect about = 193 usec to be devoted to the trajectory and PID stuff within every VSP interva. This Embedded Eectronics Page 81 11/9/2007

83 figure is an approximation of course, but it is probaby accurate to within +/- 15%. Keep in mind that, if you have 2 motors moving at once, these figures are doubed. As an exampe, if VSP is 10 msec, and both motors are executing a cosed oop move then roughy 400 microseconds of every 10 msec (about 4% of the CPU usage) is being used for just the motor movement. Of course there is ots of other stuff going on as we! Your encoders are causing interrupts to increment/decrement the position counters, the AtoD modue is generating interrupts to sampe the AtoD inputs, timer interrupts are occurring, and of course you want to eave some room for communication interrupts and other processing. Trapezoida Generator Inputs The Trapezoida Generator accepts 4 inputs (X, Vm, a, V0). Three of these inputs are provided thru the command ine interface when you request a PID Controed move and the fourth comes from periodic samping done by the firmware. X: Target Position (ticks) This is where you want the motor to go. If you specify a 24 bit vaue of 0xFFFF23 (-221) as the destination, the current encoder position wi determine whether or not the motor moves forward or reverse to get to this destination. The target position can aso be specified in reative terms. Vm: Midcourse Veocity (ticks/vsp) This vaue is how fast you want the motor to go during the midcourse (or constant veocity) portion of the journey. a: Acceeration (ticks/vsp^2) This vaue governs how fast the motor ramps the veocity to Vm during the start portion of the path, and how fast it ramps down the veocity to 0 at the target. V0: Initia Veocity (ticks/vsp) This vaue is not entered as part of the motor movement commands, but is an input that affects the trajectory cacuations. Its vaue is the veocity at the time the trajectory path is initiated. The vaue of V0 need not be zero, but if the motor is currenty going in the wrong direction, the trajectory request is reschedued after the firmware ramps the motor to a stop (using AMINP for the acceeration contro). The Trajectory Generator computes the distance to the target d as d = X Encoder (ticks) and uses this (together) with the other inputs to characterize the veocity profie Trajectory Generator Cases The Trapezoida Generator is named for the typica veocity profie which ooks ike a trapezoid. However there are reay 4 cases handed by the firmware. Ony the most common of these (Case 3) has a veocity profie that actuay resembes a trapezoid. Here is a brief outine assuming initia veocity V0 and distance to the fina target destination is d: First compute dmin = minimum stopping distance. CASE 1: V0 > 0, d < dmin [Ramp: Very Cose to Target; Ramp down fast to target] If not case 1, compute Vp=maximum veocity before requiring ramp down CASE2: V0 < Vp < Vm, d >=dmin [Triange: Ramp up to Vp, Ramp down to target] CASE3: V0 <= Vm <= Vp, d>=dmin [Trapezoid. Ramp up to Vm, Hod, Ramp down to target] CASE4: V0 > Vm, d>=dmin [ Poygon: Ramp down to Vm, Hod, Ramp down to target] Each of the veocity profies associated with the 4 cases, can be described by 3 time intervas [0,t1], [t1,t2], [t2,t3], during which the veocity or acceeration is constant. The computation of the interva endpoints t1,t2, and t3 takes pace during the Trajectory Setup phase (before waypoint generation and the PID controer are actuay started). Embedded Eectronics Page 82 11/9/2007

84 The current time interva and the trapezoida case determine a state in the Trajectory Generator Code. For each t, the math generates the desired distance f(t) from the starting point using a 2 nd order poynomia whose coefficients depend on the Trajectory State. The vaue of f(t) and the initia encoder position is used to generate a 24 bit, 2 s compement waypoint x(t) representing the desired motor position at time t. f(t) = c0 + c1*t + c2*t^2 x(t) = waypoint (foat32) (24 bit, 2 s compement) (The coefficients (c0,c1,c2) depend on the Trajectory State) The coefficients for a intervas are computed during the Trajectory Setup phase. State transitions to subsequent states (interva boundary crossings) reoad new coefficients from RAM before evauation of f(t). The format of x(t) is consistent with the output from the encoder. Each motor has its own singe 24 bit storage ocation x1(t) and x2(t) which is overwritten as each new waypoint is generated. CASE 3: VELOCITY PROFILE Here is a typica veocity profie for case Integra Windup The term Integra Windup refers to an issue with the PID err summation term (See the section PID (Cosed-Loop) Motor Contro ). The ony thing to mention here is that when the Trajectory Generator finishes (has generated the ast waypoint) it enabes error summations aowing PID to achieve a zero steady state error, but at the same time avoiding the Integra Windup issue. Embedded Eectronics Page 83 11/9/2007

85 15 PID (Cosed-Loop) Motor Contro There are ots of tutorias, product descriptions, design guideines, pitfas, etc. on the web on the subject of motor controers and PID in particuar. Just type PID into googe to get instanty overwhemed. Peope write books on this subject, and I have even read a good dipoma thesis that discussed PID for the contro of a mobie robot. I won t try to compete with any of that here. What I wi give you is a concise description of the computations used by this firmware, incuding scaing. This shoud prove usefu in expaining observabe motor behavior and modifying your motor contro parameters in order to best suit your appication. The discussion here is imited to motor position, but obviousy, PID used as a contro fiter can be appied to many different appications. I wi aso give you some guideines on manua tuning of the PID contro parameters and discuss what each of the terms in the PID equation(s) does for you. Hopefuy this wi hep you make the adjustments needed to optimize PID performance for your appication Proportiona-Integra-Derivative (PID) Equations During trajectory setup (prior to PID start), Err(0)=ErrSum(0)=PrevErr=0, t=0. The PID controer is periodicay caed every VSP msec. The timing variabe t is incremented with every ca, hence t is measured in units of VSP msec. The Trajectory Generator terminates after t>t3 (see Trajectory Generator Section of this document), but the PID controer wi remain active with a static target. In practice, and somewhat depending on parameter VMIN, this means that a sma votage may sti be appied across the motor terminas after target acquisition. For each ca to PID Controer (every VSP msec), the desired target position x(t) has been made avaiabe by a prior ca to the Trajectory Generator. Encode(t) is the position as determined by the motors position encoder. Here is a summary of the PID Controer Actions: t t+1 Err(t) x(t) Encode(t) ErrDiff(t) Err(t) Err(t-1) If (sumho=0) // Err Sum Hod-Off fag not set { ErrSum ErrSum + Err; If( ErrSum > MAXSUM) ErrSum Sgn(ErrSum)*MAXSUM; // cip to MAXSUM } If ( Err >= MAXERR) {stop motors; disabe PID and Traj Gen;} Ese { PIDErr = KP*Err + KI*ErrSum/256 + KD*ErrDiff SPID = PIDErr / VMIN PID = INT( MIN(SPID, VMAX) ) } //fata error condition // Basic PID Equation // Scaed PIDErr // SPID cipped to VMAX The vaue of PID [0-100%] is written to the duty cyce register to contro PWM, The sign of PIDErr determines the motor direction ( + = forward). That is pretty much it! This activity occurs every VSP msec whie PID is active. Embedded Eectronics Page 84 11/9/2007

86 PID Equation Notes: Scaing ErrSum by 256 aows arger vaues (finer resoution) in the vaue used for KI. Scaing by 1024 aows non-integra vaues for KP, KI, and KD (finer adjustment resoution). The PWM duty cyce can never be driven to zero (uness VMIN=0). VMAX shoud never exceed 100 = 0x64. Embedded Eectronics Page 85 11/9/ PID Motor Contro Tuning Here is a ist of some of the parameters that you shoud consider customizing to tune your motor for cosed oop contro. A of these Parameter Bock parameters are discussed in Appendix D. ERAM based copies can be found starting at offset 0x100 for runtime ony changes. It is a good idea to stop the motor before atering any of the ERAM versions of these variabes. This section wi concentrate on the {KP, KI, and KD} parameters assuming that you have aready estabished reasonabe vaues for the others (see the Trajectory Generator section for a detaied discussion of VSP). KP... PID proportiona constant (16 bits) KI... PID integra constant (16 bits) KD... PID derivative constant (16 bits) fpwm.. PWM frequency contro index (8 bits) TPR. Ticks Per Revoution (4*CPR) (16 bits) VSP... Veocity samping period (8 bits; msec) VMIN... PID Min PWM (deadband) (% [0-100]) VMAX... Max PWM (% [0-100]) MAXERR... PID position error imit (16 bits) MAXSUM... PID integra imit (16 bits) MODE1 Motor Contro Fags 1 (8 bits) VMID.. Midcourse veocity defaut (16 bits) ACC. Traj Gen acceeration defaut (16 bits) Be sure that you have the MODE1 bits set propery (in particuar the aeadsb bit). The defauts for the other bits in MODE1 wi be fine for now (I recommend eaving the sumho fag set initiay and maybe forever!). There are anaytica methods for determining the setting for some of the PID Contro parameters, but even if that makes sense for you, experimenta methods sti need to be empoyed to verify and test the resuts. You shoud be abe to do a quite satisfactory job of tuning by just experimenting with your parameter seections whie using the Step Response command and being observant. There are ots of artices on the Internet concerning experimenta or Manua Tuning of PID contro parameters. A of the artices attempt to isoate the effect of the various terms in order to optimize one constant at a time. None of the artices attempts to determine KI first - in fact, I beieve that a of them treat KI ast, which makes some sense when you understand its roe in PID. Unfortunatey, the variabes are not competey independent (changes in one variabe suggest tweaks to another variabe that you thought was perfect. I wi present a tuning procedure that shoud work fine for you, but first read this short discussion of the PID equation and what the various terms accompish. This wi ay a framework for your tuning observations. The PID terms: Refer back to the section that provides the PID equations. The equation for PIDErr contains three terms; the P-term, the I-term, and the D-term. The P-term aone (Proportiona or Err Term) is capabe of driving your motor toward the target and in fact does most of the work. However, without the assist of the other 2 terms, you may (depending on the magnitude of KP) get combinations of any of the foowing: undershoot, overshoot, osciations about the target, or a non-zero steady state error. The D-term is used to provide

87 damping - mitigating effects such as overshoot, undershoot, and osciations about the target. The I-term (Integra Term) is usefu to obtain a zero steady state error, but some systems won t require it and there are some issues with its use. If you have heard the saying: too much of anything is bad, it is especiay true when taking about the scaing constants KP, KI, and KD, so start by experimenting with sma vaues. The roe of the KP Term: The KP Term contros the system gain. From the definition, Err is the position error and its sign is such to drive the motor toward the target. KP contros how rapidy the system wi try to acquire the target. If you consider the step response graph, KP governs the sope of the eary portion of the graph. The roe of the KD Term: The KD Term contros system damping. It s roe is to dampen the contro system response. If you consider the step response graph, KD wi sow down the rate of target acquisition and fatten osciations that occur near target acquisition. To better understand this, expand the ErrDiff term of the PIDErr equation: ErrDiff = ( VSP * [x(t) - x(t-1)] - [encode(t) - encode(t-1)] ) / VSP = VSP * {Desired Veocity - Actua Veocity} This shows that ErrDiff is proportiona to the Veocity Error. A positive vaue for ErrDiff indicates that the motor is going sower than desired. A negative vaue indicates that the motor is going too fast. So, the KD, or derivative term, has the roe of reducing veocity errors. Note that during execution of the PID Tuning Command, the target position x(t) is constant, so that in this specia case, the ErrDiff term reduces to: ErrDiff = - VSP *(Actua Veocity) [during PID Step Response] The KD term, has the roe of reducing veocity to zero (a damping effect on the step response). The roe of the KI Term: The KI Term contros the system steady state error. Even with we chosen KP and KD parameters, the system can sti have a non-zero steady state error. The continua accumuation of errors in the ErrSum term is sufficient to overcome the steady state error, driving the motor to the target. There is a technica probem with the use of the KI Term known as Integra Windup. The issue is that errors that have accumuated in the eary portion of PID operation can cause the integra term to overwhem the other terms when near target acquisition (when fine contro is needed). The PID Contro System used on the Daf Board deas with this by providing the MAXSUM parameter and the sumho bit setting. I recommend using both the MAXSUM variabes and the sumho fag to restrain the integra contribution in norma operation If you are ready to begin PID Tuning for your appication, et me encourage you at this point to become famiiar with some hepfu commands: Cmd_P: Set/Get PID Parameters Cmd_Q: PID Step Response Cmd_R: Read Memory Byte Cmd_W: Write Memory Byte Cmd_Z: Upoad To EEPROM These commands are your PID motor tuning friends. When using Cmd_P to change the PID constants, you wi be making temporary changes to ERAM variabes. Be sure to record permanent changes or work that you wish to keep for the next session in the Parameter Bock. Embedded Eectronics Page 86 11/9/2007

88 16 Firmware Library Routines These functions, written in PIC Assember, are provided in the ibrary fie <daf.ib>. They are compatibe with the runtime environment (eg; stack, parameter passing, etc.) of the Microchip mcc18.exe compier. If you are customizing or extending the board functionaity and wish to use any of the functions described in this section you wi need to ink the fie incuded on the CD into your buid. Use of the functionaity in the <daf.ib> fie is imited by the icense to use on this board ony. The <daf.ib> ibrary was created from fies compied using the {Large code, Large Data, Mutibank Stack} mode settings. Function WriteIOExp1 WriteIOExp2 ReadIOExp1 ReadIOExp2 GetTime SetDeay TimeOut WriteExtEE_Byte ReadExtEE_Byte WriteExtEE_Bock ReadExtEE_Bock WriteIntEE_Byte ReadIntEE_Byte WriteIntEE_Bock ReadIntEE_Bock WritePot1 WritePot2 Description Write byte to IO Expander #1 Register (Microchip MCP23017) Write byte to IO Expander #2 Register Read byte from IO Expander #1 Register Read byte from IO Expander #2 Register Get eapsed time since power up (resoution: 1 tick = us) Estabish deay = future time (Now + Deay) Has deay expired? (set deay with SetDeay) Write byte to externa eeprom (24LC512; 64K Byte EEPROM) Read byte from externa eeprom Write bock of bytes to externa eeprom Read bock of bytes from externa eeprom Write byte to interna eeprom (PIC18F6722; 1K Byte EEPROM) Read byte from interna eeprom Write bock of bytes to interna eeprom Read bock of bytes from interna eeprom Write byte to Pot1 Register (MAXIM5478; 50K; dua digita pot) Write byte to Pot2 Register You wi get more than the functions isted above, and documented in the sections that foow, from <daf.ib>. There are numerous other functions used in <main.c> with fairy transparent usage that do not appear in the above ist. As one exampe, this <main.c> function uses the TeCmdDispatch() function in <daf.ib> to effect a cosed oop motor move, exercising the same code that is used by the seria interfaces for Cmd_Y. This means that you wi be abe to perform motor contro operations with your own code inked with <daf.ib> and <main.c>. // void MoveMtrCosedLoop(BYTE mtr, short ong tgt, WORD v, WORD a) { CMD = 'Y'; ARG[0] = mtr; ARG[1] = (tgt & 0xFF0000)>>16; ARG[2] = (tgt & 0xFF00)>>8; ARG[3] = tgt & 0xFF; ARG[4] = (BYTE) (v>>8); ARG[5] = (BYTE) (v & 0xFF); ARG[6] = (BYTE) (a>>8); ARG[7] = (BYTE) (a & 0xFF); ARGcount = 0x08; TeCmdDispatch(); } // Embedded Eectronics Page 87 11/9/2007

89 16.1 IOEXP Functions The board has two I/O expanders (Device: MCP23017) on the primary seria I2C bus (400 khz) with each part providing 16 GPIO s routed to a ribbon cabe connector. None of these GPIO s are currenty used by any of the board firmware (they are a avaiabe for custom use). The functions described in this section operate at the device eve, so you do not need to know anything about the I2C bus to access the parts. If you need to know more about the device registers than what is presented beow, refer to the device data sheet on the Microchip web site. For convenience, a copy of the data sheet is incuded on the CD that ships with the product. Reg# Name Port A Registers 0x00 IODIRA Data Direction ( 0 =Output, 1 =Input) 0x02 IPOLA Input Poarity ( 0 =non-inverted, 1 =inverted) 0x04 GPINTENA GPIO Interrupt Enabe ( 0 =disabe, 1 =enabe) 0x06 DEFVALA Defaut compare vaue for interrupts 0x08 INTCONA Interrupt Contro ( 0 =use pin compares, 1 =use DEFVALA compares) 0x0A IOCON I/O Configuration 0x0C GPPUA GPIO Puup Enabe ( 0 =disabe, 1 =enabe) 0x0E INTFA Interrupt Fags ( 1 =request pending) (Read Ony) 0x10 INTCAPA Interrupt Capture (Read Ony) 0x12 GPIOA GPIO Port 0x14 OLATA Output Latch Reg# Name Port B Registers 0x01 IODIRB Data Direction ( 0 =Output, 1 =Input) 0x03 IPOLB Input Poarity ( 0 =non-inverted, 1 =inverted) 0x05 GPINTENB GPIO Interrupt Enabe ( 0 =disabe, 1 =enabe) 0x07 DEFVALB Defaut compare vaue for interrupts 0x09 INTCONB Interrupt Contro ( 0 =use pin compares, 1 =use DEFVALA compares) 0x0B IOCON I/O Configuration 0x0D GPPUB GPIO Puup Enabe ( 0 =disabe, 1 =enabe) 0x0F INTFB Interrupt Fags ( 1 =request pending) (Read Ony) 0x11 INTCAPB Interrupt Capture (Read Ony) 0x13 GPIOB GPIO Port 0x15 OLATB Output Latch The 16 GPIO s on each part are impemented as two 8-bit ports: GPIOA[7..0] and GPIOB[7..0]. Each of the 16 pins can source or sink up to 25 ma (but the part is imited to 200 ma tota). The configuration registers on the part are organized as 22 byte wide registers (21 if you consider that IOCON is coned for use by both ports). The part offers two options for a register numbering scheme, but ony the one indicated in the above tabe is supported by the ibrary (BANK=0; See the device data sheet for detais). The tabes beow ist the registers and a brief description. IOCON (at 0x0A and 0x0B) is actuay a singe register serving both PORTA and PORTB. Notes: Because the interrupt on change feature of the parts is not supported, you shoud be abe to use the defaut power up configuration for many of these registers. There are a coupe of reasons for not supporting the interrupt on change feature. First, its use requires resources (eg; interrupt ines to the micro). More importanty, cearing the interrupt fags in an interrupt service routine requires I2C device access which introduces interrupt atency issues. Embedded Eectronics Page 88 11/9/2007

90 Depending on your usage, you may need to reconfigure any of IODIR, IPOL, IOCON, and perhaps GPPU. It is important that IOCON.7= 0 (BANK=0) be maintained to preserve the intereaved register addressing scheme described in the tabes. Routine I/O appications, after configuration, wi access ony the GPIO and perhaps the OLAT register. Function execution times were measured with fosc=40 MHz, I2C Baud Rate=400 khz. See the section describing the I/O Expanders for the connector pin outs WriteIOExp1, WriteIOExp2 Function: Incude: Write I/O Expanders. daf.ib Prototypes: void WriteIOExp1(BYTE reg, BYTE data) void WriteIOExp2(BYTE reg, BYTE data) Arguments: reg: Destination for write (0x00-0x15) data: Byte to write. Return Vaue: None Fie Name: ioexp.asm Execution Time: 91 microseconds Code Exampe: WriteIOExp1( 0x13, 0x7F); This writes 0x7F to the GPIOB register. If, for exampe, the part was previousy configured with GPIOB pins as a outputs, this exampe woud resut in driving GPIOB[6..0] outputs high and GPIOB[7] ow. Note that a read of the same register reads the pin states and coud produce something different than 0x7F. A write to the OLAT register wi aso drive the port output pins ReadIOExp1, ReadIOExp2 Function: Incude: Prototypes: Read I/O Expanders. daf.ib BYTE ReadIOExp1(BYTE reg) BYTE ReadIOExp2(BYTE reg) Arguments: reg: Source for read (0x00-0x15) Return Vaue: RtnVa: Byte vaue read from reg address. Fie Name: ioexp.asm Execution Time: 124 microseconds Code Exampe: va = ReadIOExp1( 0x12); This exampe returns va = GPIOA from IO Expander 1. Embedded Eectronics Page 89 11/9/2007

91 16.2 Deay and Timing Functions TMR1 is a 16-bit counter cocked by an externa watch crysta ( khz). Its main roe is to maintain a RTC. The functions in this section aso use the TMR1 resource to provide accuratey timed deays without software oops or a specia interrupt. Here is a description of how this works: The ticks on TMR1 occur at a rate of 1/32768 Hz = 30.5 microseconds. In order to maintain the RTC, TMR1 is preoaded with a vaue of 0x8000 to generate an interrupt every 1 second. It is the TMR1 interrupt hander firmware that maintains the RTC by updating the supporting HH/MM/SS registers. During the same interrupt, a separate DWORD (32-bit) counter seconds is aso incremented. This register is unreated to the RTC system and is ceared ony on power-up. It continues to record eapsed seconds since the ast power up. Working together, the eapsed ticks (TMR1-0x8000) from TMR1, and the vaue of the seconds register provide a software watch with a resoution of 30.5 usecs and a range of 2^32*1sec = 136 years! The current vaue of the software watch can be recorded in a TIME data structure consisting of two fieds: a DWORD for seconds and a WORD for ticks. typedef struct { ULONG secs; WORD ticks; } TIME, *PTIME; The software watch, and the TIME structure to record it, are the resources used to support the timed deays for the functions described in this section. Briefy, the function SetDeay() uses the function GetTime() to record the current vaue of the watch, and with a bit of arithmetic, determine a future vaue for the watch based on the desired deay. The function TimeOut() is used to periodicay po the current vaue of the watch to determine if the deay has passed. It does this by comparing the future vaue with the current vaue of the watch GetTime Function: Get Current Time Incude: daf.ib Prototypes: void GetTime(PTIME ptime) Arguments: Return Vaue: Fie Name: ptime: Data structure of type PTIME for recording current time. TIME structure pointed to by ptime wi now have the current time. deay.asm Execution Time: 5 microseconds Remarks: You probaby won t need to ca GetTime() but it is required by the other timing functions and it is usefu to know how it works. Code Exampe: TIME Now; GetTime(&Now); Embedded Eectronics Page 90 11/9/2007

92 SetDeay Function: Incude: Estabish Future Time (Now + Deay). daf.ib Prototypes: void SetDeay(PTIME ptime, ULONG DeaySecs, WORD DeayTicks) Arguments: ptime: Data structure that wi be fied with the target time (Now + Deay). DeaySecs: Component of desired deay in seconds. DeayTicks: Component of desired deay in ticks. Return Vaue: ptime: Future time corresponding to the desired deay (referenced by TimeOut()). Fie Name: deay.asm Execution Time: 12 microseconds Remarks: The exampe uses both SetDeay() and TimeOut() to generate a square wave output on Port D.4 with frequency 1.0 Hz and duty cyce10%. TimeOut() is caed continuousy unti the deay has expired. In this exampe, nothing is done whie waiting for the timeout to occur. Less trivia usages woud have the software do something usefu whie periodicay poing TimeOut() to check if the deay has expired. Code Exampe: #define msec_ // ticks worth 100 msec #define msec_ // ticks worth 900 msec TIME Deay; whie(1) // Sq wave on PORT D.4 with 10% ( = 0.1/1.0) duty cyce { } LATD = 0x10; // D.4 =1 SetDeay(&Deay, 0, msec_100); // ton: 0.100s whie(!timeout(&deay) ); LATD &= ~0x10; // D.4 = 0 SetDeay(&Deay, 1, msec_900); // toff: 0.900s whie(!timeout(&deay) ); TimeOut Function: Incude: Determine if Specified Deay Has Expired. daf.ib Prototypes: int Timeout(PTIME ptime); Arguments: ptime: Data structure that was previousy fied (by SetDeay()) with the target time. Return Vaue: RntVa: FALSE=0, TRUE= 1 (TRUE if current time > ptime). Fie Name: deay.asm Execution Time: 13 microseconds Remarks: The exampe uses TimeOut() to turn off a motor after 1 hour of use. Embedded Eectronics Page 91 11/9/2007

93 Code Exampe: TIME MotorOnDeay; MotorOn(); SetDeay(&MotorOnDeay, 3600,0); whie(1) {.. Stuff.. if (TimeOut(&MotorOnDeay)) MotorOff();..Stuff.. } 16.3 Externa EEPROM Functions The functions in this section provide access to the externa, 64K byte, seria EEPROM device (24LC512) on the primary I2C bus (400KHz). The functions operate at the device eve, so knowedge of the I2C bus is not required to use the device. There are functions which access a singe EEPROM byte and functions that access a bock of bytes. Accessing consecutive bytes as a bock is much more efficient than accessing the same bock of bytes individuay. This is particuary true for write access! The address range of the part is [0x0000-0xFFFF], and it is organized as 512 pages of 128 (0x80) bytes per page. A bock write can be used to write up to one page of data with a singe function ca, but the data bock that is written must not cross a page boundary on the part. For exampe; It is ok to write 0x43 bytes starting at address 0x2030, but it woud be a mistake to attempt to write the same 0x43 bytes starting at address 0x2040 (the data woud cross the page boundary at 0x2080). Bock reads are imited to 128 bytes (by the function design in this case, not the device), but there are no issues with page boundaries. For both bock reads and writes you shoud avoid crossing the end of the physica device WriteExtEE_Byte Function: Incude: Write Byte to Externa EEPROM daf.ib Prototypes: void WriteExtEE_Byte(WORD address, BYTE dat); Arguments: address: (WORD) ocation in the EEPROM to write the data byte. dat: Data byte to record in EEPROM. Return Vaue: None. Fie Name: eeprom.asm Execution Time: 120 microseconds + 5msec Remarks: The part requires a 5 msec write cyce time at the end of the data transfer before it can be accessed again. To avoid reiabiity issues, this function does not return unti the required deay has expired. Code Exampe: WriteExtEE_Byte(0x0017, 0x23); Embedded Eectronics Page 92 11/9/2007

94 ReadExtEE_Byte Function: Incude: Prototypes: Arguments: Read Byte from Externa EEPROM daf.ib BYTE ReadExtEE_Byte(WORD address); address: (WORD) ocation in EEPROM to read. Return Vaue: RtnVa: Byte that was read from the EEPROM. Fie Name: eeprom.asm Execution Time: 150 microseconds Remarks: ReadExtEE_Byte is much faster than WriteExtEE_Byte because the 5 msec write cyce time is not present. Code Exampe: va = ReadExtEE_Byte(0x0017); WriteExtEE_Bock Function: Incude: Write Bock to Externa EEPROM daf.ib Prototypes: void WriteExtEE_Bock(WORD address, BYTE *buff, BYTE n); Arguments: address: (WORD) ocation in EEPROM for start of write. buff: RAM Buffer that is the source for the bock transfer. n: Number of bytes in bock (1 <= N <= 0x80). Return Vaue: None. Fie Name: eeprom.asm Execution Time: n * (35 microseconds) + 5 msec Remarks: If n>128, ony the first 128 bytes wi be written. The 5 msec cyce time is sti required for bock writes, but there is ony one deay for the entire bock. The exampe copies the first 0x30 bytes from the RAM buffer mybuff[] into the eeprom at ocations 0x0300 thru 0x032F. As mentioned previousy, avoid page boundary crossings on the eeprom. Code Exampe: WriteExtEE_Bock(0x0300, &mybuff, 0x30); Embedded Eectronics Page 93 11/9/2007

95 ReadExtEE_Bock Function: Incude: Read Bock from Externa EEPROM daf.ib Prototypes: void ReadExtEE_Bock(WORD address, BYTE *buff, BYTE n); Arguments: address: (WORD) ocation in EEPROM for start of read. buff: RAM Buffer that is the destination for the bock transfer. n: Number of bytes in bock (1 <= N <= 0x80). Return Vaue: BUFF[] wi have been fied with bock from EEPROM. Fie Name: eeprom.asm Execution Time: n *39 microseconds Remarks: If n>128, ony the first 128 bytes wi be read. The exampe copies 0x30 bytes from the EEPROM starting at address 0x0000 into the RAM buffer mybuff[]. Code Exampe: ReadExtEE_Bock(0x0000, &mybuff, 0x30); 16.4 Interna EEPROM Functions The 1k Byte interna EEPROM has a maximum write cyce deay of 4 msec after each byte write. There is no significant timing advantage for bock writes (repeated byte writes). The firmware pos for write competion and a typica write cyce deay is 2.7 msec. Read operations do not have the deay and are quite fast WriteIntEE_Byte Function: Incude: Write Byte to Interna EEPROM daf.ib Prototypes: void WriteIntEE_Byte(WORD address, BYTE dat); Arguments: address: (WORD) ocation in the EEPROM to write the data byte. dat: Data byte to record in EEPROM. Return Vaue: None. Fie Name: eeprom.asm Execution Time: Typica 2.7 msec (Max 4.0 msec). Remarks: The part requires the write cyce deay at the end of each byte write before it can be accessed again. To avoid reiabiity issues, this function does not return unti the required deay has expired. Code Exampe: WriteIntEE_Byte(0x0017, 0x23); Embedded Eectronics Page 94 11/9/2007

96 ReadIntEE_Byte Function: Incude: Prototypes: Arguments: Read Byte from Interna EEPROM daf.ib BYTE ReadIntEE_Byte(WORD address); address: (WORD) ocation in EEPROM to read. Return Vaue: RtnVa: Byte that was read from the EEPROM. Fie Name: eeprom.asm Execution Time: 2.4 microseconds Remarks: ReadIntEE_Byte is much faster than WriteIntEE_Byte because the write cyce time is not present. Code Exampe: va = ReadIntEE_Byte(0x0017); WriteIntEE_Bock Function: Incude: Write Bock to Interna EEPROM daf.ib Prototypes: void WriteIntEE_Bock(WORD address, BYTE *buff, BYTE n); Arguments: address: (WORD) ocation in EEPROM for start of write. buff: RAM Buffer that is the destination for the bock transfer. n: Number of bytes in bock (1 <= N <= 0x80). Return Vaue: None. Fie Name: eeprom.asm Execution Time: Typica: n * (2.7 msec); Max: n * (4.0 msec) Remarks: If n>128, ony the first 128 bytes wi be written. Unike the externa EEPROM, there is no speed advantage for bock writes. The interna device does not support bock writes, so each byte that is written exhibits the write cyce timing deay. The exampe copies the first 0x30 bytes from the RAM buffer mybuff[] into the Interna EEPROM at ocations 0x0300 thru 0x032F. Code Exampe: WriteIntEE_Bock(0x0300, &mybuff, 0x30); Embedded Eectronics Page 95 11/9/2007

97 ReadIntEE_Bock Function: Incude: Read Bock from Interna EEPROM daf.ib Prototypes: void ReadIntEE_Bock(WORD address, BYTE *buff, BYTE n); Arguments: address: (WORD) ocation in EEPROM for start of read. buff: RAM Buffer that is the destination for the bock transfer. n: Number of bytes in bock (1 <= N <= 0x80). Return Vaue: BUFF[] wi have been fied with bock from EEPROM. Fie Name: eeprom.asm Execution Time: n * 2.4 microseconds Remarks: If n>128, ony the first 128 bytes wi be read. The exampe copies 0x30 bytes from the EEPROM starting at address 0x0000 into the RAM buffer mybuff[]. Code Exampe: ReadIntEE_Bock(0x0000, &mybuff, 0x30); Embedded Eectronics Page 96 11/9/2007

98 16.5 Digita Pot Functions There are two dua digita pot parts (POT1 and POT2) on the board. Each part has two digitay controed, 50k Ohm, pots (pota and potb) for a tota of 4 pots. Each pot has 256 tap positions that can be assigned to the wiper. The board ties the end of a 4 pots to VDD and GND, with the wiper positions routed to the 4 test pads (V1H, V1L, V2H, V2L) - See schematic. The parts have both a voatie register (VREG) and a non-voatie register (NVREG) associated with each pot and the write operations described here can initiate copies between these two registers, or a write to either register. Any operation that affects the vaue of the voatie register VREG, aso records that vaue as the tap position for the wiper (atering the output votage at one of the 4 test pads). When the part receives power, the vaue of the NVREG associated with each pot is moved into the wiper, but the Daf System Initiaization code quicky repaces this using the vaues stored in the Parameter Bock. The parts are write-ony WritePot1 Function: Incude: Write operation to Pot1 daf.ib Prototypes: void WritePot1(BYTE cmd, BYTE data); Arguments: cmd: One of 12 arguments specifying desired operation. data: If required by operation, tap position for pot wiper. Return Vaue: Fie Name: None. digpot.asm Execution Time: 91 microseconds Remarks: Here is the ist of vaid commands cmd Operation Description (Writes to voatie register ; update wiper) 0x11 VREGA Write to VREGA and update wipera 0x12 VREGB Write to VREGB and update wiperb 0x13 VREG Write to both VREGA and VREGB and update both wipers (Writes to non-voatie register) 0x21 NVREGA Write to NVREGA. 0x22 NVREGB Write to NVREGB. 0x23 NVREG Write to both NVREGA and NVREGB. (Copy NVREG to VREG; update wiper) 0x61 NVA -to- VA Copy NVREGA to VREGA; update wiper. 0x62 NVB -to- VB Copy NVREGB to VREGB; update wiper. 0x63 NV -to- V Copy: NVREGA to VREGA; NVREGB to VREGB; update wipers. (Copy VREG to NVREG) 0x51 VA -to- NVA Copy VREGA to NVREGA. 0x52 VB -to- NVB Copy VREGB to NVREGB. 0x53 V -to- NV Copy: VREGA to NVREGA; VREGB to NVREGB. Code Exampe: Embedded Eectronics Page 97 11/9/2007

99 WritePot1(0x11, 0xA0); WritePot1(0x12, 0x60); The schematic shows that wiper for pota on the POT1 device is routed to the V1H test pad. Simiary the wiper for potb on that device is routed to the V1L test pad. This exampe aters the V1H and V1L test pad votages as foows: V1H = (0xA0/256)*5V = (160/256)*5V = 3.13V V1L = (0x60/256)*5V = 96/256*5V = 1.88V WritePot2 Function: Write operation to Pot2 (See WritePot1. A of the content for WritePot1 appies here as we, but appied to POT2 device) Embedded Eectronics Page 98 11/9/2007

100 17 Potentia Future Enhancements This ist contains features that might be provided at a ater date. They are isted in no particuar order, and it is aways possibe that some, or a, wi not be provided (by me). I consider the GUI to be the most important, and the most ikey to appear as an enhancement at some time in the future. 0) Windows GUI using API. Currenty under deveopment with expected reease of a beta quaity version soon. 1) Temperature Sensing: Currenty there is fan contro, but no temperature firmware. Impement either NTC thermistor (using ADC) or I2C sensor (on primary I2C bus) and tie fan action or gracefu shutdown to over-temperature. 2) Home. A homing feature using imit switches woud be pretty easy. 3) USART2 Interrupt Hander and verification. 18 Appendix A - Step Response Exampes This section has two graphs showing typica motor step responses obtained with the PID Step Response Command (CMD_Q) when appied to an appication using a 12V PM, geared, whee chair motor. The first graph shows the response with no contribution from the sum or difference terms of the PID Equation (KP=0x0A00, KI=0x0000, KD=0x0000). The second shows the response from the same motor with a bit of damping added (KP=0x0A00, KI=0x0000, KD=0x0C00). The graphs were obtained by capturing the termina data to a fie (ogging enabed) and then importing the fie into an Exce Spreadsheet. When the Windows GUI becomes avaiabe the step response graph wi be provided as part of the appication. The pots show -Err vs Time. Look at the actua data as you visuaize the pots. Things to observe are the sope (the difference in the Err terms sampe-to-sampe) and the behavior as the Err terms get cose to zero. With a bit of practice, you shoud be abe to visuaize the important aspects of the graph by ooking at the data aone, and you wi be abe to skip the graphing step when using Cmd_Q. What is the goa? The goa is a set of PID parameters that wi rapidy drive your motor to the step destination with itte or no overshoot and with the error rapidy setting at or near zero without continuing osciations. Obviousy the second graph is much better than the first in meeting the goa. Can you te this by ooking at the data aone? If so, you are ready for Cmd_Q! Embedded Eectronics Page 99 11/9/2007

101 Embedded Eectronics Page /9/2007

102 Embedded Eectronics Page /9/2007

103 19 Appendix B - Board Schematic/Layout This section contains schematics and board ayout. Embedded Eectronics Page /9/2007

104 Embedded Eectronics Page /9/2007

105 Embedded Eectronics Page /9/2007

EM330 Installation and use instructions Three-phase energy analyzer for indirect connection (5A) with Modbus, pulse or M-Bus interface

EM330 Installation and use instructions Three-phase energy analyzer for indirect connection (5A) with Modbus, pulse or M-Bus interface EM330 Instaation and use instructions Three-phase energy anayzer for indirect connection (5A) with Modbus, puse or M-Bus interface Code 8021422 Genera warnings HAZARD: Live parts. Heart attack, burns and

More information

Understanding The HA2500 Horizontal Output Load Test

Understanding The HA2500 Horizontal Output Load Test Understanding The HA2500 Horizonta Output Load Test Horizonta output stages are part of every CRT video dispay incuding cosed circuit monitors, computer monitors, video games, medica monitors, TVs. HDTVs,

More information

CruzPro FU60. Intelligent Digital Fuel Gauge/w Alarms & Consumption Calculator

CruzPro FU60. Intelligent Digital Fuel Gauge/w Alarms & Consumption Calculator Other CruzPro Products Depthsounders & Speed/Temperature/Logs PC Based Fishfinders and Active Depth Transducers DC Vots/Amps/Amp-Hour Monitor AC Vots/Amps/Freq/kW Monitor LPG/Petro Gas Detectors/Aarms

More information

CruzPro VAH-65. Advanced 3 BankVolts, 1 Bank Amps/Amp-Hour Monitor/w Alarms & NMEA 0183

CruzPro VAH-65. Advanced 3 BankVolts, 1 Bank Amps/Amp-Hour Monitor/w Alarms & NMEA 0183 Other CruzPro Products Depthsounders, Fishfinder & Speed/Temperature/Log DC Vots/Amps/Amp-Hour Monitors AC Vots/Amps/Freq/kW Monitor LPG/Petro Gas Detectors/Aarms Bige Water Aarms & Bige Pump Controers

More information

LBI Mobile Communications. EDACS TM Jessica. PBX Gateway. Operator s Manual

LBI Mobile Communications. EDACS TM Jessica. PBX Gateway. Operator s Manual Mobie Communications EDACS TM Jessica PBX Gateway Operator s Manua TABLE OF CONTENTS 1. SCOPE... 3 2. QUICK USAGE GUIDE... 4 2.1. Making Phone Cas From An EDACS Radio... 4 2.2. Caing EDACS Radios From

More information

RED LION CONTROLS MODEL IFMA - DIN-RAIL FREQUENCY TO ANALOG CONVERTER

RED LION CONTROLS MODEL IFMA - DIN-RAIL FREQUENCY TO ANALOG CONVERTER RED LION CONTROLS INTERNATIONAL HEADQUARTERS EUROPEAN HEADQUARTERS 20 Wiow Springs Circe, York, Pa. 17402, (717) 767-6511 FAX: (717) 764-0839 892 Pymouth Road, Sough, Berkshire SL1 4LP Web site- http://www.redion-contros.com

More information

LTC Linear Phase 8th Order Lowpass Filter FEATURES APPLICATIONS DESCRIPTION TYPICAL APPLICATION

LTC Linear Phase 8th Order Lowpass Filter FEATURES APPLICATIONS DESCRIPTION TYPICAL APPLICATION LTC69-7 Linear Phase 8th Order Lowpass Fiter FEATURES n 8th Order, Linear Phase Fiter in SO-8 Package n Raised Cosine Ampitude Response n 43 Attenuation at 2 f CUTOFF n Wideband Noise: 4μV RMS n Operates

More information

Operation Guide

Operation Guide MO0907-EB Operation Guide 709 713 Getting Acquainted Congratuations upon your seection of this CASO watch. To get the most out of your purchase, be sure to read this manua carefuy. Expose the watch to

More information

P H O T O CD I N F O R M A T I O N B U L L E T I N

P H O T O CD I N F O R M A T I O N B U L L E T I N PCD 077 Juy, 1994 Copyright, Eastman Kodak Company, 1994 P H O T O CD I N F O R M A T I O N B U L L E T I N Fuy Utiizing Photo CD Images Maintaining Coor Consistency When Creating KODAK Photo CD Portfoio

More information

Provides exact fault location to one span

Provides exact fault location to one span TWS Mark VI Traveing wave faut ocator Provides exact faut ocation to one span Reduce down time by getting to the faut site faster Track intermittent sef cearing fauts and focus maintenance at the right

More information

Handheld Cable & Antenna Analyzer R&S ZVH Product Introduction Matthias Roski application engineer

Handheld Cable & Antenna Analyzer R&S ZVH Product Introduction Matthias Roski application engineer Handhed Cabe & Antenna Anayzer R&S ZVH Product Introduction Matthias Roski appication engineer Handhed Cabe & Antenna Anayzer R&S ZVH Appication Area Antenna and Cabe Instaation of Transmitter Stations

More information

\[7 BROADS, ANTENI 2-6 Mt-

\[7 BROADS, ANTENI 2-6 Mt- E.ECTRONCS TECHNCAN 3 & 2 VOL. 1 to each antenna couper (1) a.c. to operate the cooing fans which remove the heat generated during operation and (2) d.c. to operate the contro and protective circuits.

More information

COMDIAL. Digital Telephone System Industry-Standard Telephone. User s Guide (Interfaced through the ATI-D)

COMDIAL. Digital Telephone System Industry-Standard Telephone. User s Guide (Interfaced through the ATI-D) COMDIAL Digita Teephone System Industry-Standard Teephone User s Guide (Interfaced through the ATI-D) This user s guide appies to Industry Standard Singe Line Teephones, such as the Comdia 2500-xx (when

More information

Electronic circuit protector ESX10-Sxxx-DC24V-1A-10A

Electronic circuit protector ESX10-Sxxx-DC24V-1A-10A Eectronic circuit protector ESX10-Sxxx-DC2V-1A-10A Description The mode ESX10-Sxxx extends our product group of eectronic overcurrent protection devices for DC 2 V appications. At a width of ony 12.5mm

More information

LTC4365 UV, OV and Reverse Supply Protection Controller APPLICATIONS TYPICAL APPLICATION

LTC4365 UV, OV and Reverse Supply Protection Controller APPLICATIONS TYPICAL APPLICATION , and Reverse Suppy Protection Controer FEATURES n Wide Operating Votage Range: 2.5V to 34V n Overvotage Protection to 6V n Reverse Suppy Protection to 4V n Bocks 5Hz and 6Hz AC Power n No Input Capacitor

More information

A2000 Multifunctional Power Meter

A2000 Multifunctional Power Meter A2 3-348-98-3 16/2.8 Measurement of current, votage, active, reactive and apparent power, power factor, active and reactive energy, harmonic distortion and harmonics Precision measured vaues with error

More information

Powerfully simple event analysis software

Powerfully simple event analysis software synchrowave Event Software Powerfuy simpe event anaysis software Diagnose reay behavior during a power system faut. Time-aign event reports from mutipe reays for comparison and anaysis. Create custom cacuations,

More information

Series. Quite simply, the best in insulation! C.A 6521 C.A 6523 C.A 6525 C.A 6531 C.A Megohmmeters

Series. Quite simply, the best in insulation! C.A 6521 C.A 6523 C.A 6525 C.A 6531 C.A Megohmmeters Quite simpy, the best in insuation! Series C.A 6521 C.A 6523 C.A 6525 C.A 6531 C.A 6533 Megohmmeters Twin digita-anaogue dispay Giant back-it screen Battery powered for hours Programmabe threshod aarms

More information

Implementation of PV and PIV Control for Position Control of Servo Motor

Implementation of PV and PIV Control for Position Control of Servo Motor IJSRD - Internationa Journa for Scientific Research & Deveopment Vo. 5, Issue 1, 2017 ISSN (onine): 2321-0613 Impementation of PV and PIV Contro for Position Contro of Servo Motor J.Priya 1 R.Rambrintha

More information

Jaguar Motor Controller (Stellaris Brushed DC Motor Control Module with CAN)

Jaguar Motor Controller (Stellaris Brushed DC Motor Control Module with CAN) Jaguar Motor Controller (Stellaris Brushed DC Motor Control Module with CAN) 217-3367 Ordering Information Product Number Description 217-3367 Stellaris Brushed DC Motor Control Module with CAN (217-3367)

More information

LTC kHz Continuous Time, Linear Phase Lowpass Filter FEATURES DESCRIPTION APPLICATIONS TYPICAL APPLICATION

LTC kHz Continuous Time, Linear Phase Lowpass Filter FEATURES DESCRIPTION APPLICATIONS TYPICAL APPLICATION FEATURES DESCRIPTION n th Order, 0kHz Linear Phase Fiter in an SO- n Differentia Inputs and Outputs n Operates on a Singe or a ± Suppy n Low Offset: m Typica n db THD and SNR n db SNR n Shutdown Mode n

More information

MODEL: R3-WT4. Remote I/O R3 Series. [4] OPTIONS blank: none /Q: With options (specify the specification) AC POWER INPUT MODULE (4 input circuits)

MODEL: R3-WT4. Remote I/O R3 Series. [4] OPTIONS blank: none /Q: With options (specify the specification) AC POWER INPUT MODULE (4 input circuits) MODE: R-WT Remote I/O R Series AC POWER MODUE ( input circuits). (.) (.) [] OPTIONS ban: none /Q: With options (specify the specification) SPECIFICATIONS OF OPTION: Q COATING (For the detai, refer to M-System's

More information

CTC CT TRANSMITTER. (clamp-on current sensor) BEFORE USE... POINTS OF CAUTION INSTRUCTION MANUAL MODEL CTC

CTC CT TRANSMITTER. (clamp-on current sensor) BEFORE USE... POINTS OF CAUTION INSTRUCTION MANUAL MODEL CTC INSTRUCTION MANUA CT TRANSMITTER (camp-on current sensor) MODE CTC CTC BEFORE USE... Than you for choosing M-System. Before use, chec the contents of the pacage you received as outined beow. If you have

More information

LT6658 Precision Dual Output, High Current, Low Noise, Voltage Reference. Applications. Typical Application

LT6658 Precision Dual Output, High Current, Low Noise, Voltage Reference. Applications. Typical Application Features Dua Output Tracking Reference Each Output Configurabe to 6 Output : ma Source/2mA Sink Output 2: ma Source/2mA Sink Low Drift: A-Grade: ppm/ C Max B-Grade: 2ppm/ C Max High Accuracy: A-Grade:

More information

Electronic Circuit Protector ESX10-T.-DC 24 V

Electronic Circuit Protector ESX10-T.-DC 24 V Eectronic Circuit Protector ESX0-T.-DC 2 V Description The mode ESX0-T extends our product group of eectronic overcurrent protection devices for DC 2 V appications. At a width of ony 2.5 mm it provides

More information

MD04-24Volt 20Amp H Bridge Motor Drive

MD04-24Volt 20Amp H Bridge Motor Drive MD04-24Volt 20Amp H Bridge Motor Drive Overview The MD04 is a medium power motor driver, designed to supply power beyond that of any of the low power single chip H-Bridges that exist. Main features are

More information

Configuring Onyx to print on your HEXIS media

Configuring Onyx to print on your HEXIS media Configuring Onyx to print on your HEXIS media 1. Instaing a media profie suitabe for your HEXIS printing media 1.1. Downoading the media profie 2 1.2. Importing the media profie into Onyx 3 2. Defaut setting

More information

GT3D Digital Timers. 100 to 240V AC (50/60Hz), 24V AC (50/60Hz)/24V DC

GT3D Digital Timers. 100 to 240V AC (50/60Hz), 24V AC (50/60Hz)/24V DC rs G3D Series G3D rs Key features of the G3D series incude: Precise time setting using digita thumbwhee switches Eapsed or time remaining LCD dispay 6 time ranges, 16 timing functions deays up to 99.9

More information

LT1630/LT MHz, 10V/µs, Dual/Quad Rail-to-Rail Input and Output Precision Op Amps. Applications. Typical Application

LT1630/LT MHz, 10V/µs, Dual/Quad Rail-to-Rail Input and Output Precision Op Amps. Applications. Typical Application Features n Gain-Bandwidth Product: 3MHz n Sew Rate: V/µs n Low Suppy Current per Ampifier: 3.5mA n Input Common Mode Range Incudes Both Rais n Output Swings Rai-to-Rai n Input Offset Votage, Rai-to-Rai:

More information

MODEL: R3-WT4B. SPECIFICATIONS OF OPTION: Q COATING (For the detail, refer to M-System's web site.) Remote I/O R3 Series

MODEL: R3-WT4B. SPECIFICATIONS OF OPTION: Q COATING (For the detail, refer to M-System's web site.) Remote I/O R3 Series MODEL: R-WTB Remote I/O R Series AC POWER MODULE ( input circuits, camp-on current sensor type CLSB use). (.) (.) (.) mm (inch) MODEL: R-WTB[][][][] ORDERING INFORMATION Code number: R-WTB[][][][] Specify

More information

LTC /LTC V Microprocessor Supervisory Circuits APPLICATIONS TYPICAL APPLICATION

LTC /LTC V Microprocessor Supervisory Circuits APPLICATIONS TYPICAL APPLICATION Microprocessor Supervisory Circuits FEATURES n Guaranteed Reset Assertion at = 1 n Pin Compatibe with LTC69/LTC695 for Systems n 2μA Typica Suppy Current n Fast (ns Typ) Onboard Gating of RAM Chip Enabe

More information

MODEL: M5CTC SEN TRONIC AG

MODEL: M5CTC SEN TRONIC AG MODE: M5CTC Super-mini Termina Boc Signa Conditioners M5-UNIT CT TRANSMITTER (camp-on current sensor) Functions & Features Converts an aternating current into a standard process signa Easy-to-insta camp-on

More information

HV SERIES. Uninterruptible Power Systems. Designed to be used with linear or non-linear loads including:

HV SERIES. Uninterruptible Power Systems. Designed to be used with linear or non-linear loads including: 7.5 kva to 25 kva HV SERIES Uninterruptibe Power Systems Designed to be used with inear or non-inear oads incuding: Distributive Networks Extensive LAN / WAN Systems Midrange Computing Information Technoogy

More information

Energy Measurement and Management MT MD Multifunction meters with load profile

Energy Measurement and Management MT MD Multifunction meters with load profile Energy Measurement and Management MT851... MD851... Mutifunction meters with oad profie The MT851 / MD851 eectronic mutifunction eectricity meters are designed for metering of active energy in two directions,

More information

WS2812 Intelligent control LED integrated light source

WS2812 Intelligent control LED integrated light source Features and Benefits Contro circuit and RGB chip are integrated in a package of 5050 components, form a compete contro of pixe point. Buit-in signa reshaping circuit, after wave reshaping to the next

More information

ThermaData Logger DATA-LOGGERS. temperature recording thermometers.

ThermaData Logger DATA-LOGGERS. temperature recording thermometers. ThermaData Logger temperature recording thermometers waterproof housing offering IP66/67 protection temperature range or 125 C resoution 0.1 C, high accuracy ±0.5 C meets EN 12830, S & T, C & D, 1 The

More information

Series 700A Power Processor

Series 700A Power Processor Series 700A Power Processor 5 25 SINGLE PHASE 10 500 THREE PHASE VOLTAGE REGULATION, ISOLATION, AND POWER DISTRIBUTION FOR CLEAN, SPIKE-FREE, STABLE VOLTAGE When Power Quaity Is A Must And Faiure Is Not

More information

dtrans ph 01 Microprocessor transmitter/ controller for ph value or redox potential

dtrans ph 01 Microprocessor transmitter/ controller for ph value or redox potential M. K. Juchheim GmbH & Co UK USA Jumo nstrument Co. Ltd. Jumo Process Contro nc. 36035 Fuda, Germany Tempe Bank, Riverway 735 Fox Chase Phone (0661) 6003-0 Harow, Essex CM20 2TT Coatesvie, PA 19320 Fax

More information

3.3V regulator. JA H-bridge. Doc: page 1 of 7

3.3V regulator. JA H-bridge. Doc: page 1 of 7 Cerebot Reference Manual Revision: February 9, 2009 Note: This document applies to REV B-E of the board. www.digilentinc.com 215 E Main Suite D Pullman, WA 99163 (509) 334 6306 Voice and Fax Overview The

More information

Improving the Active Power Filter Performance with a Prediction Based Reference Generation

Improving the Active Power Filter Performance with a Prediction Based Reference Generation Improving the Active Power Fiter Performance with a Prediction Based Reference Generation M. Routimo, M. Sao and H. Tuusa Abstract In this paper a current reference generation method for a votage source

More information

Manual SURFACE ROUGHNESS TESTER PCE-RT 1200

Manual SURFACE ROUGHNESS TESTER PCE-RT 1200 PCE Americas Inc. 711 Commerce Way Suite 8 Jupiter FL-33458 USA From outside US: +1 Te: (561) 32-9162 Fax: (561) 32-9176 info@pce-americas.com PCE Instruments UK Ltd. Units 12/13 Southpoint Business Park

More information

LT8710 Synchronous SEPIC/ Inverting/Boost Controller with Output Current Control. Applications. Typical Application

LT8710 Synchronous SEPIC/ Inverting/Boost Controller with Output Current Control. Applications. Typical Application Features n Wide Input Range: 4.5V to 8V n Rai-to-Rai Output Current Monitor and Contro n Input Votage Reguation for High Impedance Inputs n C/1 or Power Good Indication Pin n MODE Pin for Forced CCM or

More information

Racks and Cable Management Products

Racks and Cable Management Products Racks and Cabe Management Products 79 Wire Management Brackets HeermannTyton provides the most adaptabe and systematic approach for cabe management on reay racks. Offering a compete ine of versatie products,

More information

High Current Hot Swap Controller with I 2 C Compatible Monitoring. Applications. Typical Application

High Current Hot Swap Controller with I 2 C Compatible Monitoring. Applications. Typical Application Features nn nn nn nn nn nn nn nn nn nn nn nn nn nn nn nn nn Appications nn nn nn nn Typica Appication Description High Current Hot Swap Controer with I 2 C Compatibe Monitoring Aows Safe Board Insertion

More information

Pulsed RF Signals & Frequency Hoppers Using Real Time Spectrum Analysis

Pulsed RF Signals & Frequency Hoppers Using Real Time Spectrum Analysis Pused RF Signas & Frequency Hoppers Using Rea Time Spectrum Anaysis 1 James Berry Rohde & Schwarz Pused Rea Time and Anaysis Frequency Seminar Hopper Agenda Pused Signas & Frequency Hoppers Characteristics

More information

Brushed DC Motor Control. Module with CAN (MDL-BDC24)

Brushed DC Motor Control. Module with CAN (MDL-BDC24) Stellaris Brushed DC Motor Control Module with CAN (MDL-BDC24) Ordering Information Product No. MDL-BDC24 RDK-BDC24 Description Stellaris Brushed DC Motor Control Module with CAN (MDL-BDC24) for Single-Unit

More information

CMU232 User Manual Last Revised October 21, 2002

CMU232 User Manual Last Revised October 21, 2002 CMU232 User Manual Last Revised October 21, 2002 Overview CMU232 is a new low-cost, low-power serial smart switch for serial data communications. It is intended for use by hobbyists to control multiple

More information

LTC2938/LTC2939 Configurable 4- and 6-Supply Monitors with Watchdog Timer FEATURES DESCRIPTION APPLICATIONS TYPICAL APPLICATION

LTC2938/LTC2939 Configurable 4- and 6-Supply Monitors with Watchdog Timer FEATURES DESCRIPTION APPLICATIONS TYPICAL APPLICATION Configurabe 4- and 6-Suppy Monitors with Watchdog Timer FEATURES n Simutaneousy Monitors Four (LTC2938) or Six Suppies (LTC2939) n Sixteen User-Seectabe Combinations of 5V, 3.3V, 2.5V, 1.8V, 1.5V, 1.2V

More information

LTC High Power Single PSE Controller with Internal Switch FEATURES DESCRIPTION APPLICATIONS

LTC High Power Single PSE Controller with Internal Switch FEATURES DESCRIPTION APPLICATIONS FEATURES n W PSE Output Power n IEEE 8.af Compatibe n Operation from a Singe 5V Suppy n Fuy Autonomous Operation Without a Microcontroer n Interna MOSFET with Therma Protection n Precision Inrush Contro

More information

PIC Functionality. General I/O Dedicated Interrupt Change State Interrupt Input Capture Output Compare PWM ADC RS232

PIC Functionality. General I/O Dedicated Interrupt Change State Interrupt Input Capture Output Compare PWM ADC RS232 PIC Functionality General I/O Dedicated Interrupt Change State Interrupt Input Capture Output Compare PWM ADC RS232 General I/O Logic Output light LEDs Trigger solenoids Transfer data Logic Input Monitor

More information

LT3014B 20mA, 3V to 80V Low Dropout Micropower Linear Regulator FEATURES

LT3014B 20mA, 3V to 80V Low Dropout Micropower Linear Regulator FEATURES LT314B 2mA, 3V to 8V Low Dropout Micropower Linear Reguator FEATURES n Wide Input Votage Range: 3V to 8V n Low Quiescent Current: 7µA n Low Dropout Votage: 35 n Output Current: 2mA n LT314BHV Survives

More information

(12) United States Patent (10) Patent N0.: US 6,493,200 B1 Farmer et al. (45) Date of Patent: Dec. 10, 2002

(12) United States Patent (10) Patent N0.: US 6,493,200 B1 Farmer et al. (45) Date of Patent: Dec. 10, 2002 i US006493200B1 (12) United States Patent (10) Patent N0.: US 6,493,200 B1 Farmer et a. (45) Date of Patent: Dec. 10, 2002 (54) COAXAL CABLE PROTECTON DEVCE Primary Examiner EdWard H. Tso _ Assistant Examiner

More information

EVDP610 IXDP610 Digital PWM Controller IC Evaluation Board

EVDP610 IXDP610 Digital PWM Controller IC Evaluation Board IXDP610 Digital PWM Controller IC Evaluation Board General Description The IXDP610 Digital Pulse Width Modulator (DPWM) is a programmable CMOS LSI device, which accepts digital pulse width data from a

More information

EE 314 Spring 2003 Microprocessor Systems

EE 314 Spring 2003 Microprocessor Systems EE 314 Spring 2003 Microprocessor Systems Laboratory Project #9 Closed Loop Control Overview and Introduction This project will bring together several pieces of software and draw on knowledge gained in

More information

Configuring RolandVersaWorks to print on your HEXIS media

Configuring RolandVersaWorks to print on your HEXIS media PRINTING DIVISION Product Buetin N 4 Configuring RoandVersaWorks to print on your HEXIS media 1. Instaing a media profie suitabe for your HEXIS printing media 1.1. Downoading the media profie 2 1.2. Importing

More information

Automatic socket guard prevents incorrect connection of the measuring wires and protects both user and device.

Automatic socket guard prevents incorrect connection of the measuring wires and protects both user and device. Digita Mutimeter + Signa Generator UNIGOR 330, 355 Precision mutimeter (V, A, db, W, F, Hz, C/ F) Resoution 10µV-10nA-10mW-1pF-0,1 C-0,01Hz Quartz cock for rea-time recording Signa generator Standard caibration

More information

NGRM700. Neutral Grounding Resistor Monitor

NGRM700. Neutral Grounding Resistor Monitor M700 eutra Grounding Resistor Monitor M700_D00292_02_D_XXE/07.2018 M700 eutra Grounding Resistor Monitor Product description The M700 is ony intended for use in high-resistance grounded systems. In these

More information

LT1176/LT Step-Down Switching Regulator FEATURES APPLICATIONS DESCRIPTION TYPICAL APPLICATION

LT1176/LT Step-Down Switching Regulator FEATURES APPLICATIONS DESCRIPTION TYPICAL APPLICATION Step-Down Switching Reguator FEATURES n 1.2A Onboard Switch n 100kHz Switching Frequency n Exceent Dynamic Behavior n DIP and Surface Mount Packages n Ony 8mA Quiescent Current n Preset 5 Output Avaiabe

More information

MicroDS The motion solution INSTALLATION and USER S GUIDE Revision B June 12

MicroDS The motion solution INSTALLATION and USER S GUIDE Revision B June 12 MicroDS The motion soution INSTALLATION and USER S GUIDE Revision B June 12 CONTENTS & INTRODUCTION MicroDS User's Manua Revision Date Description Updated Pages A June 2003 C27159-001 B June 2012 MicroDS

More information

RED LION CONTROLS MODEL TCU - TEMPERATURE CONTROL UNIT

RED LION CONTROLS MODEL TCU - TEMPERATURE CONTROL UNIT RED LION CONTROLS INTERNATIONAL HEADQUARTERS EUROPEAN HEADQUARTERS 0 Wiow Springs Circe, York, Pa. 740, (77) 767-65 FAX: (77) 764-0839 89 Pymouth Road, Sough, Berkshire SL 4LP Web site- http://www.redion-contros.com

More information

ABSOLUTE MAXIMUM RATINGS Votage....3V to 9V SENSE +, SENSE Votages... 1V or.3v to +.3V, ADR Votages....3V to 9V, SHDN, SDAO Votages....3V to V, SDA, S

ABSOLUTE MAXIMUM RATINGS Votage....3V to 9V SENSE +, SENSE Votages... 1V or.3v to +.3V, ADR Votages....3V to 9V, SHDN, SDAO Votages....3V to V, SDA, S FEATURES n Wide Operating Votage Range: 7V to V n 1-Bit Resoution for Both Current and Votages n I C Interface n Additiona ADC Input Monitors an Externa Votage n Continuous Scan and Snapshot Modes n Shutdown

More information

Controlling DC Brush Motor using MD10B or MD30B. Version 1.2. Aug Cytron Technologies Sdn. Bhd.

Controlling DC Brush Motor using MD10B or MD30B. Version 1.2. Aug Cytron Technologies Sdn. Bhd. PR10 Controlling DC Brush Motor using MD10B or MD30B Version 1.2 Aug 2008 Cytron Technologies Sdn. Bhd. Information contained in this publication regarding device applications and the like is intended

More information

RAD250 Nothing Comes Close to a Cobra

RAD250 Nothing Comes Close to a Cobra Operating Instructions The obra ine of quaity products incudes: B Radios Dash ams Radar Detectors Marine VHF Radios Power Inverters Accessories RADAR/LASER PROTETION RAD250 Nothing omes ose to a obra Introduction

More information

LT1498/LT MHz, 6V/µs, Dual/Quad Rail-to-Rail Input and Output Precision C-Load Op Amps FEATURES DESCRIPTION APPLICATIONS

LT1498/LT MHz, 6V/µs, Dual/Quad Rail-to-Rail Input and Output Precision C-Load Op Amps FEATURES DESCRIPTION APPLICATIONS FEATURES n Rai-to-Rai Input and Output n 475 Max V OS from V + to V n Gain-Bandwidth Product: MHz n Sew Rate: 6V/μs n Low Suppy Current per Ampifi er: 1.7mA n Input Offset Current: 65 Max n Input Bias

More information

Communication Systems

Communication Systems Communication Systems 1. A basic communication system consists of (1) receiver () information source (3) user of information (4) transmitter (5) channe Choose the correct sequence in which these are arranged

More information

User's Manual. VHF Wireless Microphone System. Guangdong Takstar Electronic Co., Ltd.

User's Manual. VHF Wireless Microphone System. Guangdong Takstar Electronic Co., Ltd. User's Manua VHF Wireess Microphone System Guangdong Takstar Eectronic Co, Ltd Business Centre of Domestic Saes: Te: 020-86381808 / 86381888 Fax: 020-86599478 Production Base: Bocady Industria Viage, Longqiao

More information

Wireless Communications

Wireless Communications Wireess Communications Ceuar Concept Hamid Bahrami Reference: Rappaport Chap3 Eectrica & Computer Engineering Statements of Probems Soving the probem of Spectra congestion System Capacity A system-eve

More information

Device handbook APLUS-TFT

Device handbook APLUS-TFT Device handbook APLUS-TFT Operating Instructions APLUS with TFT dispay 173 013-05 (PM 1000360 000 01) 04/2016 Camie Bauer Metrawatt AG Aargauerstrasse 7 CH-5610 Wohen / Switzerand Phone: +41 56 618 21

More information

LTC2915/LTC2916 Voltage Supervisor with 27 Selectable Thresholds DESCRIPTION FEATURES APPLICATIONS TYPICAL APPLICATION

LTC2915/LTC2916 Voltage Supervisor with 27 Selectable Thresholds DESCRIPTION FEATURES APPLICATIONS TYPICAL APPLICATION FEATURES n 9 Seectabe Suppy otages 12,, 3.3, 2., 1.8 1., 1.2, 1., +ADJ (.) n 3 Seectabe Toerances %, 1%, 1% () n Manua Reset Input (LTC2916) n 1. to. Suppy Operation n 6.2 Shunt Reguator for High otage

More information

Debugging EMI Using a Digital Oscilloscope

Debugging EMI Using a Digital Oscilloscope Debugging EMI Using a Digita Oscioscope 06/2009 Nov 2010 Fundamentas Scope Seminar of DSOs Signa Fideity 1 1 1 Debugging EMI Using a Digita Oscioscope Background radiated emissions Basics of near fied

More information

DC Brushed Motor Controller Module EDP-AM-MC1

DC Brushed Motor Controller Module EDP-AM-MC1 Embedded Development Platform DC Brushed Motor Controller Module EDP-AM-MC1 Electrocomponents plc Vsn 1.1 Page 1 DC Brushed Motor Controller Module EDP-AM-MC1 The motor controller module is designed to

More information

LT mA, 3V to 80V Low Dropout Micropower Linear Regulator DESCRIPTION FEATURES APPLICATIONS TYPICAL APPLICATION

LT mA, 3V to 80V Low Dropout Micropower Linear Regulator DESCRIPTION FEATURES APPLICATIONS TYPICAL APPLICATION FEATURES n Wide Input Votage Range: 3V to 8V n Low Quiescent Current: 7µA n Low Dropout Votage: 35mV n Output Current: 2mA n LT31HV Survives 1V Transients (2ms) n No Protection Diodes Needed n Adjustabe

More information

LT1970A 500mA Power Op Amp with Adjustable Precision Current Limit FEATURES DESCRIPTION APPLICATIONS TYPICAL APPLICATION

LT1970A 500mA Power Op Amp with Adjustable Precision Current Limit FEATURES DESCRIPTION APPLICATIONS TYPICAL APPLICATION FEATURES n ±5mA Minimum Output Current n Independent Adjustment of Source and Sink Current Limits n 1% Current Limit Accuracy n Improved Reactive Load Driving Stabiity n Operates with Singe or Spit Suppies

More information

B RoboClaw 2 Channel 30A Motor Controller Data Sheet

B RoboClaw 2 Channel 30A Motor Controller Data Sheet B0098 - RoboClaw 2 Channel 30A Motor Controller (c) 2010 BasicMicro. All Rights Reserved. Feature Overview: 2 Channel at 30Amp, Peak 60Amp Battery Elimination Circuit (BEC) Switching Mode BEC Hobby RC

More information

LTC1863/LTC /16-Bit, 8-Channel 200ksps ADCs FEATURES DESCRIPTION APPLICATIONS BLOCK DIAGRAM

LTC1863/LTC /16-Bit, 8-Channel 200ksps ADCs FEATURES DESCRIPTION APPLICATIONS BLOCK DIAGRAM 12-/16-Bit, 8-Chae 2ksps ADCs FEATURES APPLICATIONS Sampe Rate: 2ksps 16-Bit No Missing Codes and ±2LSB Max INL 8-Chae Mutipexer with: Singe Ended or Differentia Inputs and Unipoar or Bipoar Conversion

More information

DX-40 Lynx Panel Meter 4 DIGIT 0.8 LED DX-45 Lynx Panel Meter 4 1/2 DIGIT 0.56 LED Both in a 1/8 DIN Case

DX-40 Lynx Panel Meter 4 DIGIT 0.8 LED DX-45 Lynx Panel Meter 4 1/2 DIGIT 0.56 LED Both in a 1/8 DIN Case E46978 Genera Features Large dispay DX-4.8 red or green LED FAMILY DX-4 Lynx Pane Meter 4 DIGIT.8 LED DX-45 Lynx Pane Meter 4 1/ DIGIT.56 LED Both in a 1/8 DIN Case A versatie, standard and arge dispay,

More information

ZKit-51-RD2, 8051 Development Kit

ZKit-51-RD2, 8051 Development Kit ZKit-51-RD2, 8051 Development Kit User Manual 1.1, June 2011 This work is licensed under the Creative Commons Attribution-Share Alike 2.5 India License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/2.5/in/

More information

LTC6993-1/LTC LTC6993-3/LTC TimerBlox: Monostable Pulse Generator (One Shot) Applications. Typical Application

LTC6993-1/LTC LTC6993-3/LTC TimerBlox: Monostable Pulse Generator (One Shot) Applications. Typical Application Features n Puse Width Range: 1µs to 33.6 Seconds n Configured with 1 to 3 Resistors n Puse Width Max Error: 51µs

More information

Lineup with new energy saving and environmentally friendly features!

Lineup with new energy saving and environmentally friendly features! ineup with new energy saving and environmentay friendy features! WM Eco-POWER METER WM Eco-POWER METER (DN 9 size) RoHS Directive compatibiity information http://www.mew.co.jp/ac/e/environment/ FEATURES

More information

SURGE ARRESTERS FOR CABLE SHEATH PREVENTING POWER LOSSES IN M.V. NETWORKS

SURGE ARRESTERS FOR CABLE SHEATH PREVENTING POWER LOSSES IN M.V. NETWORKS SURGE ARRESTERS FOR CABLE SHEATH PREVENTING POWER LOSSES IN M.V. NETWORKS A. Heiß Energie-AG (EAM), Kasse G. Bazer Darmstadt University of Technoogy O. Schmitt ABB Caor Emag Schatanagen, Mannheim B. Richter

More information

KW8M. Toward energy savings. Visualization. Makes us more ecological! Eco-POWER METER 1A/5A CT Input type

KW8M. Toward energy savings. Visualization. Makes us more ecological! Eco-POWER METER 1A/5A CT Input type WM co-powr MTR A/A CT Input type Visuaization Toward energy savings Maes us more ecoogica! Direct input of secondary side A/A CT Direct input from secondary side A/A type domestic and overseas CTs. Dedicated

More information

B Robo Claw 2 Channel 25A Motor Controller Data Sheet

B Robo Claw 2 Channel 25A Motor Controller Data Sheet B0098 - Robo Claw 2 Channel 25A Motor Controller Feature Overview: 2 Channel at 25A, Peak 30A Hobby RC Radio Compatible Serial Mode TTL Input Analog Mode 2 Channel Quadrature Decoding Thermal Protection

More information

LT V Synchronous 4-Switch Buck-Boost DC/DC Slave Controller for LT8708 Multiphase System

LT V Synchronous 4-Switch Buck-Boost DC/DC Slave Controller for LT8708 Multiphase System 80V Synchronous 4-Switch Buck-Boost DC/DC Save Controer for LT8708 Mutiphase System FEATURES nn nn nn nn nn nn nn nn APPLICATIONS nn nn nn Save Chip of LT8708 to Deiver Additiona Power Good Current Matching

More information

Contrans E - SU. Configurable universal transducer for all power current variables and for mains synchronization 10/ EN

Contrans E - SU. Configurable universal transducer for all power current variables and for mains synchronization 10/ EN Contrans E - S Configurabe universa transducer for a power current variabes and for mains synchronization 0/8-.54 EN Configurabe transducer for a power current variabes, I, P, Q, S, cosϕ, sinϕ, ϕ, f 4

More information

HAW-Arduino. Sensors and Arduino F. Schubert HAW - Arduino 1

HAW-Arduino. Sensors and Arduino F. Schubert HAW - Arduino 1 HAW-Arduino Sensors and Arduino 14.10.2010 F. Schubert HAW - Arduino 1 Content of the USB-Stick PDF-File of this script Arduino-software Source-codes Helpful links 14.10.2010 HAW - Arduino 2 Report for

More information

OpenStax-CNX module: m Inductance. OpenStax College. Abstract

OpenStax-CNX module: m Inductance. OpenStax College. Abstract OpenStax-CNX modue: m42420 1 Inductance OpenStax Coege This work is produced by OpenStax-CNX and icensed under the Creative Commons Attribution License 3.0 Cacuate the inductance of an inductor. Cacuate

More information

LT6203X High Temperature 175 C Dual 100MHz, Rail-to-Rail Input and Output, Ultralow 1.9nV/ Hz Noise, Low Power Op Amp Description

LT6203X High Temperature 175 C Dual 100MHz, Rail-to-Rail Input and Output, Ultralow 1.9nV/ Hz Noise, Low Power Op Amp Description Features Appications LT3X High Temperature 7 C Dua MHz, Rai-to-Rai Input and Output, Utraow.9nV/ Hz Noise, Low Power Op Amp Description Extreme High Temperature Operation: C to 7 C Low Noise Votage:.9nV/

More information

TO DIODE GND BG2 SW2 BOOST2 TG2 CSPOUT CSNOUT EXTV CC FBOUT INTV CC GATEV CC SRVO_FBIN SRVO_FBOUT SRVO_IIN SRVO_IOUT IMON_IN IMON_OUT

TO DIODE GND BG2 SW2 BOOST2 TG2 CSPOUT CSNOUT EXTV CC FBOUT INTV CC GATEV CC SRVO_FBIN SRVO_FBOUT SRVO_IIN SRVO_IOUT IMON_IN IMON_OUT Features nn nn nn nn nn nn nn nn nn nn Singe Inductor Aows Above, Beow, or Equa to Reguated Range 2.8V (Need EXTV CC > 6.4V) to 8V Range: 1.3V to 8V Quad N-Channe MOSFET Gate Drivers Synchronous Rectification:

More information

LTC4151 High Voltage I 2 C Current and Voltage Monitor DESCRIPTION FEATURES APPLICATIONS TYPICAL APPLICATION

LTC4151 High Voltage I 2 C Current and Voltage Monitor DESCRIPTION FEATURES APPLICATIONS TYPICAL APPLICATION FEATURES n Wide Operating Votage Range: V to V n -Bit Resoution for Both Current and Votages n I C Interface n Additiona ADC Input Monitors an Externa Votage n Continuous Scan and Snapshot Modes n Shutdown

More information

Rectangular-shaped Inductive Proximity Sensor.

Rectangular-shaped Inductive Proximity Sensor. 71 PHOTOEECTRIC PHOTOEECTRIC IGHT FOW PARTICUAR USE SIMPE MEASUREMENT STATIC CONTRO Rectanguar-shaped Inductive Proximity Sensor SERIES Reated Information Genera terms and conditions... F-17 Gossary of

More information

In this chapter, I explain the essentials that you need to start drawings. After a

In this chapter, I explain the essentials that you need to start drawings. After a CHAPTER Starting to Draw In this chapter, I expain the essentias that you need to start drawings. After a itte background, I discuss the basics of the screen that you see when you open AutoCAD or AutoCAD

More information

Device handbook APLUS-LED

Device handbook APLUS-LED Device handbook APLUS-LED Operating Instructions APLUS with LED dispay or without dispay 157 679-19 (PM 1000357 000 01) 04/2016 Camie Bauer Metrawatt AG Aargauerstrasse 7 CH-5610 Wohen / Switzerand Phone:

More information

TLE9879 EvalKit V1.2 Users Manual

TLE9879 EvalKit V1.2 Users Manual TLE9879 EvalKit V1.2 Users Manual Contents Abbreviations... 3 1 Concept... 4 2 Interconnects... 5 3 Test Points... 6 4 Jumper Settings... 7 5 Communication Interfaces... 8 5.1 LIN (via Banana jack and

More information

R is in the unit of ma/mw or A/W. For semiconductor detectors, the value is approximately, 0.5 ma/mw.

R is in the unit of ma/mw or A/W. For semiconductor detectors, the value is approximately, 0.5 ma/mw. Light Detection Conventiona methods for the detection of ight can be categorized into photo-synthesis, photographic pate, and photoeectric effect. Photo-synthesis and photographic pate are based on ight-induced

More information

hp scanjet 4400c series and 5400c series scanners user s manual

hp scanjet 4400c series and 5400c series scanners user s manual hp scanjet 4400c series and 5400c series scanners user s manua Copyright Hewett-Packard Company 2001 A rights reserved. Reproduction, adaptation, or transation without prior written permission is prohibited,

More information

Development of a LabVIEW-based test facility for standalone PV systems

Development of a LabVIEW-based test facility for standalone PV systems Deveopment of a LabVIEW-based test faciity for standaone PV systems Aex See Kok Bin, Shen Weixiang, Ong Kok Seng, Saravanan Ramanathan and Low I-Wern Monash University Maaysia, Schoo of Engineering No.2,

More information

LT Dual Very Low Noise, Differential Amplifi er and 5MHz Lowpass Filter DESCRIPTION FEATURES APPLICATIONS TYPICAL APPLICATION

LT Dual Very Low Noise, Differential Amplifi er and 5MHz Lowpass Filter DESCRIPTION FEATURES APPLICATIONS TYPICAL APPLICATION FEATURES n Dua Differentia Ampifi er with MHz Lowpass Fiters 4th Order Fiters Approximates Chebyshev Response Guaranteed Phase and Gain Matching Resistor-Programmabe Differentia Gain n >8 Signa-to-Noise

More information

Rectangular-shaped Inductive Proximity Sensor. website

Rectangular-shaped Inductive Proximity Sensor. website 785 Rectanguar-shaped Inductive Proximity Sensor SERIES Reated Information Genera terms and conditions... F-3 Gossary of terms... P.157~ guide... P.781~ Genera precautions... P.1579~ PHOTO PHOTO IGHT FOW

More information

FEATURES APPLICATIONS TYPICAL APPLICATION

FEATURES APPLICATIONS TYPICAL APPLICATION FEATURES n Reguates Whie Sourcing or Sinking Current n Provides Termination for up to 27 SCSI Lines n μa Quiescent Current n Utraow Power Shutdown Mode n Current Limit and Therma Shutdown Protection n

More information

CHANNEL LETTER LIGHTING

CHANNEL LETTER LIGHTING LIGHTING UNIQUE LIGHTING SOLUTIONS WARNING Instaation must ony be performed by a icensed eectrician. To prevent death, injury or damage to property this product must be instaed in accordance to Nationa

More information