Recent Changes - Search:

Introduction to Microcontroller Programming

About PICmicro Chips

Clocking Your PICmicro Devices

E-Blocks

Flowcode Step By Step

PICmicro Projects

Labs

Lab 4 - Calculations

<^< 3. Connection Point | Course Index | 5. Loop >^>

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
EB006 OptionsSettingJumper settings (EB006)Jumper settings (HP488)
Power supplyExternal, 14VJ29: PSUJ29: PSU
PICmicro device16F1937  
Programming methodUSBJ12,13,14: USBJ20: USB
Clocking methodXTALSW2: XTALS2: XTAL
R/C clock speed   
Xtal frequency19 660 800 Hz  
LVP Jumper selectionI/O PortJ11,16,17: I/O PortJ15,16,18: I/O
Port A E-block   
Port B E-blockLED board  
Port C E-block   
Port D E-block   
Port E E-block   
4. Flowcode and download settings
Build > Project Options... > General Options Build > Project Options... > Configure
OptionsSetting
Clock speed19 660 800 Hz
Simulation speedAs fast as possible
OptionsSetting
Device16F1937
RC/XTXTAL
Watchdog timerOff
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
Letter Meaning
L Lab x
B Basic complexity
I Intermediate complexity
E Expert complexity
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)

<^< 3. Connection Point | Course index | 5. Loop >^>

Print - Search - Login

Page last modified on May 14, 2013, at 01:52 PM