Intro to Robotics
Intro to Robotics CIS 4930
Popular in Course
Popular in Computer Information Systems
This 13 page Class Notes was uploaded by Mabel Smitham PhD on Wednesday September 23, 2015. The Class Notes belongs to CIS 4930 at University of South Florida taught by Luther Palmer in Fall. Since its upload, it has received 39 views. For similar materials see /class/212605/cis-4930-university-of-south-florida in Computer Information Systems at University of South Florida.
Reviews for Intro to Robotics
Report this Material
What is Karma?
Karma is the currency of StudySoup.
You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!
Date Created: 09/23/15
Name Sam Mquot C18 4930 Homework 4 Microprocessor Interfacing For all below problems assume that you are using a microcontroller with a 24 MHZ bus clock speed 1 Write a line of C code to clear the flag for Pin 6 after an input capture on the pin rff v a gxqo 2 Write a line of C code to enable the interrupt on Input Capture Output Compare channel 3 TH l 0x lo 3 Write the data to TCTLl and TCTL2 to toggle lOC4 when an output compare event occurs TcrLt 8 Oth on TC TLL amp u F1 TcTle l 0X01 TCTU l ox oi 4 Below are memory values in the HC9512 at a certain time 0x0040 OO 00 OO 80 10 08 80 00 00 00 81 10 01 07 10 8O OxOOSO 01 8O 40 F6 20 3C 21 15 20 06 00 00 00 00 00 00 0x0060 OO 00 00 01 02 30 03 04 00 80 01 DO 10 FF FF FF 0x0070 O3 00 08 10 6F 10 80 DO 00 01 00 DO 10 00 00 00 a Is lOC4 set up as an input capture or output compare Input Capture memory location 0x0040 bit 4 What edge will be detected on lOC4 Rising Edge memory location OxOOZlA bits 10 Is the Input Capture Output Compare Channel 4 flag set Yes memory location OXOO4E bit 4 What is the value of the prescale factor for the main timer Binary 111 equals a prescale factor of 128 memory location OXAD bits 20 What time did the clock hold when 0C4 last went from low to high TC4 0x2006 memory location 0x58 and 0x59 How much time has passed since then Gquot n D f Iquot ox 79 198 phessHT TiMerL VRCJE 39 011v0i 1101 Fm zm re vii9391 rg rm HHJHNW 1441 M75 P fsuxgc IQ l 5 l1 inch GIHH39L UJN T5 f quot2 bill s 0z LnJNT 1 1 I CLocL Name Solution CIS 4930 Microprocessor Interfacing Homework 5 Suppose that the contents of the TCTLl and TCTLZ registers are 79 and 93 respectively The content of the TFLGl register is 00 What would occur on pins PT7 to PTO on the next clock cycle if the value 7F is written into the CFORC register CFORC b01111111 TCTLl b01111001 TCTLZ b10011011 PT7 No change PT6 Pin set PTS Pin cleared PT4 Pin toggled PT3 Pin cleared PTZ Pin toggled PTl Pin cleared PTO Pin set Write an instruction sequence to generate a 10kHz digital waveform with 60 percent duty cycle from the PWMZ pin output Use leftaligned mode and assume a 24 MHZ bus clock 2400000010000 2400 16 x 150 prescaler x period value Use Clock B as the clock source and set prescale factor to 16 Set output high at the start of a period Enable PWMZ Select left aligned mode Load 150 into the period register Load 90 into the duty cycle register PWMCLK 0 PWMPRCLK 0x40 PWMPOL 4 PWMCAE 0 PWMPER2150 PWMDTY290 PWMCNT20 PWMEN 0x04 3 Write an instruction sequence to generate a 160kHZ digital waveform with 80 percent duty cycle from the PWMZ pin output Use leftaligned mode and assume a 24 MHZ bus clock 24000000 160000 150 Use Clock B as the clock source and set prescale factor to 1 Set output high at the start of a period Enable PWMZ Select left aligned mode Load 150 into the period register Load 120 into the duty cycle register PWMCLK 0 PWMPRCLK 0 PWMPOL 4 PWMCAE 0 PWMPER2150 PWMDTY2120 PWMCNT20 PWMEN 0x04 4 Assume that 8bit mode is being used for LCD operation in this problem What hex value must be written to DB7DBO in order to a turn on the display turn off the cursor and turn on blinking b00001101 0x0D 57 initialize the LCD in 8bit mode 1 display line and 5x7 display dots b001100xx where xx are don t cares 0x30 0x31 0x32 or 0x33 c move the cursor set the DD RAM address to the first display position on the first line b1000000 0x80 d move the cursor to the second display position on the second line b11000000 0xC0 5 Assume that 4bit mode is being used for LCD operation in this problem a Nibble 0101 is loaded into bits 30 of unsigned char VAR Write code to send this nibble to the LCD with EN 1 and RS 1 End the code with PORTK VAR VAR amp 0x0f VAR VAR ltlt 2 VAR 3 PORTK VAR 57 Send the byte 0x33 to the LCD one nibble at a time in 4bit mode with R5 0 and EN 1 Start with the line unsigned char TEMP 0x33 unsigned char x x TEMP amp 0xf0 gtgt 2 PORTK x 2 binary 00000010 waitms1 or any time that does not violate the timing regulation PORTK x amp 0xFD binary 11111101 waitms1 or any time that does not violate the timing regulation x TEMP amp 0x0f ltlt 2 PORTK x 2 binary 00000010 waitms1 or any time that does not violate the timing regulation PORTKX amp0xFD binary 11111101 waitms1 or any time that does not violate the timing regulation PORTK TEMP amp 0x0f ltlt 2 2 Name Homework 2 N 9 4 5 C18 4930 Microprocessor Interfacing In CodeWarrior write the Ccode that loops the 7segment decoder from 0 to 9 then starts back at 0 with each number showing for approximately 1 second Use the software subroutine with empty FOR loops in implement the wait The values in the for loop will be dependent on the processing speed of your machine Print the Ccode and attach to your homework submission What is the last instruction in most interrupt handler routines What does this instruction do RTI Restores the program counter register info and CCR from the stack Suppose that the OSCCLK clock frequency is 5 MHz Compute the COP watchdog timer timeout period for CR20 Ill and CR20 000 1 224 111 gt 224 clocks 335 secs 5M clocks 5 M 000 gt COP is disabled What values in registers SYNR and REFDV will generate a 48 MHz PLL clock from a 4 MHZ oscillator clock input SYNR1 DHIZ 48 2 4 REFDV1 SYNR1 6 REFDV1 If REFDV 0 SYNR 5 IfREFDV 1 SYNR 11 IfREFDV 2 SYNR 17 etc What is the oscillator clock input if the PLL clock is tested at 24 MHZ the SYNR register reads 0X03 and the REFDV register reads 0X01 24 MHz 2 OSCCLK OSCCLK 6MHz 0 gt1 9 0 N L What is the bus speed of the microcontroller if the oscillator clock input is 4 MHZ SYNR reads 0X03 REFDV reads 0X00 and the MSB of register PLLSEL is 0 If PLLSEL 0 then Bus Speed OSCCLKZ 2 MHz What is the bus speed of the microcontroller if the oscillator clock input is 6 MHz SYNR reads 0X03 REFDV reads 0X00 and the MSB of register PLLSEL is l 2 6MHzgtk Bus Speed 01 24 MHz What is the reset value of the REFDV register 0 Fill in the blank the REFDV register can be written to any time except when PLLSEC 1 Why is this limitation useful We cannot change the PLL clock when it is in use What are the minimum and maximum oscillator frequencies that can be used with the MC9S12 lVIin 05MHz Max 16 MHz What is the interrupt frequency for the RTI if RTR60 0X58 and the oscillator frequency is 8MHz f 8M clocks 1 sec 1 interrupt interrupts 9 214 clocks 5425 second What is the largest interrupt period that can be achieved using the RTI and a l6MHz oscillator clock 1 sec T 16 M clocks 16 216clocks seconds 1 interrupt 2 00655 interrupt What is the smallest interrupt period that can be achieved using the RTI and a 5 MHz oscillator clock 210clocks 1 sec 1 interrupt T milli seconds 5 M clocks interrupt N 04 4gt U39I Name SOLUTION CIS 4930 Microprocessor Interfacing Homework 7 Finish the line of C code below to clear bit 7 of register ATDOCTLZ without altering any of the other bit values What does this accomplish ATDOCTLZ amp 0x7F Turns offthe ATDO Module Supply the C code to clear bits 53 and 1 and also set bits 7 6 and O of register ATDOCTIE without altering any of the other bit values ATDOCTLS amp 0xD5 ATDOCTL5 0xC1 Supply the C code to power up the AD converter and enable the AD interrupt without adjusting any other settings ATDOCTLZ 0x82 OR I 0x83 Configure ATDOCTL3 and ATDOCTLS using C code to convert channels 5 6 and 7 continuously ATDOCTL3 0x18 ATDOCTLS 0x35 Configure ATDlCTL3 and ATDOCTLS using C code to execute 5 conversions of channel 0 in a single sequence ATDOCTL3 0x28 ATDOCTLS 0x00 6 Below are the values of some ATD registers in the HC9512 ATDOCTL2 ATDOCTL3 ATDOCTL4 ATDOCTL5 ATDOSTATO ATDOSTAT1 ATDODIEN PORTADO 0x230 0X28 0x05 0x12 0x70 0x07 oxco 0x40 a How many conversions are in the programmed sequence ATDOCTL3 b 0010 1000 gt 5 b Is the ATD converter powered on ATDOCTLZ Bit 7 is set gt Yes C Is the conversion sequence completed STATO Bit 7 is not set gt No 7 If the ATDOATD1 and RTI modules each request an interrupt from the main processor at the same time which one will be serviced first RTI 8 Write a line of C code to elevate the ATDO interrupt to the highest priority maskable interrupt HPRIO 0xD2 9 A write to which ATDO module register starts a new conversion sequence ATDOCTLS 10 The memory location ATDODROH contains 0x02 ATDODROL contains 0x04 a What is the digital value of this result if the conversion is lObit right justified 516 b What is the digital value of this result if the conversion is 8bit left justified 2 11 Given the digital value of an ATD conversion of 82 what is the distance to a reflective object using the GP2D12O proximity sensor Assume Vrh 5 V and Vrl O V a Use a 10bit ATD Q 5210 433 mVStep 82000488 04 V 32 cm b Use an 8bit ATD Q 528 00195 VStep 32oo195 16 v 75 cm 12 Write a line of code that waits until the second conversion of a sequence is complete before continuing while ATDOSTAT1 amp 0x02 0R while quotATDOSTATl 0xFD Use the following memory dump to answer the remaining questions 0000 00 ff 0f f0 00 ff 00 00 00 00 00 00 00 00 00 00 0010 ff 10 80 01 08 1a a1 18 00 ff 25 80 80 80 80 80 0020 01 01 80 ff 3a fe 25 21 12 1a ba bb 77 80 80 80 0030 00 00 08 40 01 80 00 00 00 40 40 00 00 00 ff 80 0040 00 00 00 00 fe 25 80 00 00 00 00 00 00 80 ff 80 0050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0060 80 20 11 ff 8f 8e 08 80 10 01 55 25 80 00 10 00 0070 01 05 82 32 1f ff 00 00 f0 f0 f0 80 11 36 82 8f 0080 00 00 80 20 05 32 80 00 00 00 00 00 00 00 00 00 0090 00 fe 02 00 00 3a 00 b1 00 c3 00 f1 f1 25 25 21 13 After an ATDO conversion sequence ATDODR1H and ATDODR1L contain the digital conversion from what ATD channel ATDOCTL3 0x20 ATDOCTLS 0x32 Sequence 2 3 4 5 Data result register 1 has the result of Channel 3 14 What is the decimal value of this conversion Make sure to account for justification and 810 bit selection CTL4 0x05 CTL5 0x32 Decimal Value 8 Name 5 L Tl tl C18 4930 Homework 1 Microprocessor Interfacing What is the memory location for the Data Direction Register for port H gzwo 39 111 4 gitL What module is the IBCR register located in What does writing a O to the IBIE bit in this register accomplish A Mm it 808 NW A r TEILMPTS 139 rm 1 W 393 M WML D Finish the four lines of C code below to write F0 to Port B de ne DDRB O i 039 de ne PORTB 0 DDRB OLV PORTB oxM What hexadecimal values should be written to Port H to display the numbers 09 on the seven segment display of the Spider 12 board Always write a 0 to PH7 0 0oooooo ox 10 5 W Cle 1 portllool 157 6 Clot 2 m w 7 ans 3 0120 8 o 00 4 exp 9 oKl E If the Spider 12 board was wired with a common cathode 7 segment display what values should be written to Port H to display a 6 on the seven segment display Write a 0 to PH7 t omubt r79 6 Write 1 line of C code that will clear bit 5 of the SYNR register without changing any of the other bit values 9101K amp o o gt WNL Rt 011 7 Write one line of C code that will set bit 2 of the SYNR register without changing any of the other bit values 914 1 Loeooo00 gt Swppav 010 1quot 8 Write two lines of C code that will write a binary 01 l to SYNR75 without changing any of the other bit values 1M x 6217 39 91pm l o 1 4 b i 9 Write C code that will loop until bit 3 of the CRGFLG register is cleared wits crumbs 1 0 5 10 Write C code that will loop until bit 3 of the CRGFLG register is set wane l vCU FLC amp Mo s ll Given that Digital Input Output pins are driven with at 5V supply and diodes usually sink 07 V approximately how much current would pass through a lightemitting diode on the 7segment decoder if put in series with a a lSkQ resistor If i 5 07 clr A L 15K b lOOQresistor WIS T v 1 LUNA 100 12 What voltage will be read on nodes A B C and D with respect to ground 5v 0 W A 397 1 10k ohm 8 a y 10k ohm V c A r PORTAO D g LED 07 V B c T GND D t O T GND Name Solution ClS 4930 Microprocessor Interfacing Homework 6 How much time must pass between successive rising edges of the Enable pin on the LCD 1000 ns ln 8bit mode how many commands can be written to the LCD in 10 seconds 1051000ns 10000000 Write out your last name in the Character code provided in the LCD data sheet A 0x41 What is the minimum amount of time required to send your name to the LCD in 4bit mode assuming the LCD can fit all of the characters Letters 2 1000ns Using the COMWRT4 and DATWRT4 subroutines discussed in class send a series of commands not including the delays to set up the LCD as one line with 5x10 dots in 4bit mode with the display on cursor on and blink on Start with COMWRTOX33 COMWRT0x32 COMWRT0x24 COMWRT0x0F Using the COMWRT4 and DATWRT4 subroutines discussed in class send a series of commands not including the delays to set up the LCD as two lines with 5x7 dots in 4bit mode with the display off cursor on and blinllt on Start with COMWRTOX33 COMWRT0x32 COMWRT0x28 C0MWRTOXOB 6 You are given a 4bit AD converter with a VRH 4 V and a VRL ov a What is the quantization number for this AD converter Q VRH VRL2quot 4024 025 b An analog input of 25V would register as what digital value VIN VRLQ 0R VIN VRL2nVRH 39VRL 25025 10 c An analog input of 249V would register as what digital value 249025 996 gt d An analog input of 024V would register as what digital value 024025 096 gt 0 e An analog input of 60V would register as what digital value 6 gtVRH gt 15 7 You are given a 12bit AD converter with a VRH 4 V and a VRL iv a What is the quantization number for this AD converter 41212 0000732422 b An analog input of 25V would register as what digital value VIN VRLQ 0R VIN VRL2nVRH 39 VRL 253910000732422 20479 gt 2047 c An analog input of 24V would register as what digital value 24 1 Q 191196 gt 1911 d An analog input of 024V would register as what digital value 024 lt VRL gt 0 e An analog input of40V would register as what digital value 4vRH gt 212 1 4 8 Suppose you expect analog inputs in the range of 0V to 5V and need to detect changes in voltage of at most 2mV What AD resolution will you need how many bits Q VRH VRL2quot gt 2quot 50002 gt nog2 og2500 gt n 1128 gt 12 9 Suppose you expect analog inputs in the range of 12V to 12V and simply need to detect whether the voltage is positive or negative What AD resolution will you need Q 12 12 12 122quot gt 2quot 2 gt n 1
Are you sure you want to buy this material for
You're already Subscribed!
Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'