|
Introduction to Microcontroller Programming * Course Index * Introduction * About the Author * About this Course * Feedback * Course Navigation * Quick Course Navigation * How to use this Course * Acronyms Used and Course Conventions About PICmicro Chips * What is a PICmicro? * Microcontrollers * Digital versus Analogue * Inputs and Outputs * Memory * Programming * 16F1937 Architecture Clocking Your PICmicro Devices * Introduction * The Clock Circuit * Clock Settings * Clock Confusion E-Blocks * Introduction to E-blocks * Using E-blocks * E-blocks Boards Flowcode Step By Step * Introduction to Flowcode * Basic Flowcode Functions * Digital Outputs * Digital Inputs * Basic Loops * The LCD Display * Binary Numbers * Decisions * Goto (Connection Point) * 7-Segment Displays * Software Macro * Strings and Memory * A Simple Hi-Fi PICmicro Projects * Introduction to PICmicro Projects * Construction Methods * Choosing a Power Source * Adding Inputs * Input Conditioning * Adding Outputs * Adding Drivers Labs * Introduction and Lesson Plan * 1. Output * 2. Delay * 3. Connection Point * 4. Calculations * 5. Loop * 6. Input * 7. Decision * 8. LCD * 9. Keypad * 10. Analogue + EEPROM * 11. Software Macro * 12. External Interrupt * 13. Timer Interrupt |
(:Summary:Contains the 'action' links (like Browse, Edit, History, etc.), placed at the top of the page, see site page actions:) (:comment This page can be somewhat complex to figure out the first time you see it. Its contents are documented at PmWiki.SitePageActions if you need help. :) * Print (:comment (:if group Site,SiteAdmin,Cookbook,Profiles,PmWiki*:) (:comment delete if and ifend to enable backlinks:) * %item rel=nofollow class=backlinks accesskey='$[ak_backlinks]'% [[{*$Name}?action=search&q=link={*$FullName} | $[Backlinks] ]] (:ifend:) :) * Login Labs /
Lab 4 - Calculations<^< 3. Connection Point | Course Index | 5. Loop >^>(:nl:) ->'''''1. Introduction''''' Modern microcontrollers, like the PIC, are able to do simple mathematical tasks with 8-bit numbers really fast. When the calculations get more complex or the numbers rise above an 8-bit value, then this is possible too but it adds to execution time drastically. Flowcode lets us use complex calculations on up to 16 bit values in programs and takes care of all the complexity behind it. We do however, have to take into account that this will slow the PIC down. ->'''''2. Setting up the equipment''''' ![]() ->'''''3. Hardware settings'''''
->'''''4. Flowcode and download settings'''''
->'''''5. Software learning objectives''''' Output, binary code training, what are variables and how are they used, calculations on an 8-bit microcontroller. ->'''''6. Hardware learning objectives''''' LED’s, logic output levels, Calculations on an 8-bit microcontroller ->'''''7. Instructions''''' Construct the system shown from E-blocks. In the course navigate to the ‘Flowcode step-by-step’ and review the Digital Inputs (section 3) to get more info on how to use variables and sections 4, 5 and 6 on Calculations. In the main course you will find interesting info on where variables are stored in the PIC. Make sure to use the 'Help' menu and function in Flowcode to get more info on the calculation and variables possibilities. During these exercises you are going to send different 8-bit codes to Port B of your Microcontroller. You'll also learn how to use variables and perform calculations on 8-bit numbers. 16-bit Float variables can also be used, although these are not discussed in this course. ->'''''8. Labs'''''
:L4-B1: Load the value '1' into a variable that is called 'counter' :L4-B2: Display the value of the variable 'counter' on the LEDs :L4-B3: Multiply the value of 'counter' by 2 and display on the LEDs. Do this by adding a calculation icon with: 'counter = counter * 2' :L4-B4: Repeat these steps infinite and add a delay of 300msec between these steps. What do you see? How do you explain this. (This is called a ‘running light’.) Write the explanation you have for this down on a piece of paper. :L4-B5: Replace the 'multiply by 2' with this instruction; 'counter = counter + 1'. What do you see now? You just programmed a binary counter. :L4-B6: Display the result of the following calculations on the LEDs of Port B, using Flowcode and the calculation icon. Convert from binary to decimal on a piece of paper to check if the binary result is correct. ** 45 + 52 ** 45 AND 52 ** 45 OR 52 ** NOT 45 ** 45 XOR 52 ** (1+3)*(6/2) ** VAR2 = VAR1 * 3 (where VAR1 is filled first with 18) (:nl:)(:table style="clear:both":)
| |
(:Summary: Website page footer:)
Print - (:comment (:if group Site,SiteAdmin,Cookbook,Profiles,PmWiki*:) (:comment delete if and ifend to enable backlinks:) %item rel=nofollow class=backlinks accesskey='$[ak_backlinks]'% [[{*$Name}?action=search&q=link={*$FullName} | $[Backlinks] ]] (:ifend:) :) Search - Login
Page last modified on May 14, 2013, at 01:52 PM