<^< 5. Loop | Course Index | 7. Decision >^>
1. Introduction
Adding digital inputs to your microcontroller circuit is quite easy but is a big step forward. Now external signals are going to have an influence on how the program reacts.
2. Setting up the equipment
3. Hardware settings
EB006 Options | Setting | Jumper settings (EB006) | Jumper settings (HP488) |
Power supply | External, 14V | J29: PSU | J29: PSU |
PICmicro device | 16F1937 | | |
Programming method | USB | J12,13,14: USB | J20: USB |
Clocking method | XTAL | SW2: XTAL | S2: XTAL |
R/C clock speed | | | |
Xtal frequency | 19 660 800 Hz | | |
LVP Jumper selection | I/O Port | J11,16,17: I/O Port | J15,16,18: I/O |
Port A E-block | | | |
Port B E-block | LED board | | |
Port C E-block | Switch board | | |
Port D E-block | | | |
Port E E-block | | | |
4. Flowcode and download settings
Build > Project Options... > General Options
| Build > Project Options... > Configure
|
Options | Setting |
Clock speed | 19 660 800 Hz |
Simulation speed | 10 |
|
Options | Setting |
Device | 16F1937 |
RC/XT | XTAL |
Watchdog timer | Off |
|
5. Software learning objectives
Input, output, binary code training, compiling a program to the PIC, clocking the PIC, PIC microcontroller basics.
6. Hardware learning objectives
Switches, input logic levels, pull-up/pull-down resistors.
7. Instructions
Construct the system shown from E-blocks.
In the course navigate to the ‘Flowcode step-by-step’ and review the section on Digital inputs (step 3). In the course you will also find the sections on Clocking your PIC, and about PIC microcontroller basics useful. The descriptions of the Multiprogrammer board , the switch board and the LED board are in the E-blocks section.
Make use of the 'Help' menu and function in Flowcode to get the info you need.
During these exercises you are going to send different 8-bit codes to port B of your Microcontroller and read logic values as inputs on port C. Be aware of the speed of the microcontroller in XTAL mode. Using switches as inputs on a high speed device could cause bounce.
8. Labs
Letter
| Meaning
|
---|
L
| Lab x
|
B
| Basic complexity
|
I
| Intermediate complexity
|
E
| Expert complexity
|
- L6-B1
- Show the status of the switches at port C on the LEDs at port B. Every time a switch gets pressed, the corresponding LED of port B lights up.
- L6-B2
- Show the status of the switches at port C on the LEDs at port B. Every time a switch gets pressed, the corresponding LED of port B should light up and stays on for 2 seconds. During these 2 seconds, no new inputs should be read.
- L6-B3
- If switch 'SW0' is pressed, then 'LED1' should light up. If switch 'SW1' is pressed, then 'LED2' has to light up. and so on. Nothing should happen if 'SW7' is pressed. Think before you start programming. This program can be really short.
- L6-I4
- Use 2 'Loops' to write a program that counts up when SW0 is pressed and counts down when SW1 is pressed. The status of the count is shown on the LEDs of port B.
- L6-I5
- Use 2 'Loops' to write a program that causes the LEDs to run left when SW0 is pressed and run right when SW1 is pressed. The status of the count is shown on the LEDs of port B.
- L6-I6
- Draw up the full circuit diagram of the PIC with 8 LEDs on port B and 8 switches on port C, including the clocking circuit, the reset circuit, VDD and VSS connected to the PIC and the correct current limiting resistors connected between LEDs, switches and PIC. If you were to make a practical circuit of this drawing, and connect power to it, it should do exactly the same as the e-blocks system in front of you. Schematics in the E-blocks section and the full circuit diagrams in the datasheets of the E-blocks will come in handy when you do this task.
<^< 5. Loop | Course index | 7. Decision >^>