Recent Changes - Search:

Introduction to Microcontroller Programming

About PICmicro Chips

Clocking Your PICmicro Devices

E-Blocks

Flowcode Step By Step

PICmicro Projects

Labs

Lab 10 - Analogue + EEPROM

<^< 9. Keypad | Course Index | 11. Software Macro >^>

1. Introduction

The 16F1937 PIC Microcontroller has 14 Analogue inputs. Newer devices have even more. An analogue signal with a voltage between Vss and Vdd on one of these inputs can be translated into a 10-bit digital binary number. We can choose to simply use only the 8 MSB’s of this 10-bit number or we can use the whole 10-bit number. Be aware that working with 10-bit numbers in an 8 bit controller like the PIC, needs to be planned into your program writing.

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-blockSensor board  
Port B E-blockLED board  
Port C E-blockSwitch board  
Port D E-blockLCD board  
Port E E-blockPatch board  
4. Flowcode and download settings
Build > Project Options... > General Options Build > Project Options... > Configure
OptionsSetting
Clock speed19 660 800 Hz
Simulation speed10
OptionsSetting
Device16F1937
RC/XTXTAL
Watchdog timerOff
5. Software learning objectives

Binary code training, using a hardware macro (A/D), working with 8 or 10-bit analogue inputs, using the Eeprom to create a data logger. 8 and 10 bit accuracy.

6. Hardware learning objectives

Analogue inputs, LED’s, logic output levels, LCD’s, switches, EEPROM memory, LDR sensor, Temperature sensor, Prototype board usage.

7. Instructions

Construct the system shown from E-blocks.

In the course navigate to the ‘Flowcode step-by-step’ and review the section on Simple Hi-Fi (step 12) and Strings and Memory (step 11). The descriptions of the Multiprogrammer board , the switch board, the LCD, the sensor board, the prototype board and the led board are in the E-blocks section.

Look into the 'Help' menu and function in Flowcode to get the info you need.

Take your time to do these labs. It’s all starting to come together now. Divide a big lab task into smaller manageable items and only if you have the answers for all these questions you can go on and put them all together.

8. Labs
Letter Meaning
L Lab x
B Basic complexity
I Intermediate complexity
E Expert complexity
L10-B1
Display an 8-bit analogue number between 0 and 255 on the LCD, that is the digital equivalent of the analogue voltage input provided to the PIC by the LDR (Light Dependent Resistor) on the Sensor board. Download the program to the PIC and test it. Place a voltmeter or an oscilloscope between the analogue input of the PIC where the LDR is connected to and GND of the PIC.
L10-B2
Display an 8-bit analogue number between 0 and 255 on the LCD, that is the digital equivalent of the analogue voltage input provided to the PIC by the variable resistor on the Sensor board. Download the program to the PIC and test it. Place a voltmeter or an oscilloscope between the analogue input of the PIC where the variable resistor is connected to and GND of the PIC.
L10-I3
Translate the number between 0 and 255 of the exercise above into a voltage reading between 0 and 5V. Make the reading as accurate as it can get in this 8-bit mode. Download the program to the PIC and test it. Use a voltmeter to check if the LCD displays the voltage correctly.
L10-B4
Display a 10-bit analogue number between 0 and 1024 on the LCD, that is the digital equivalent of the analogue voltage input provided to the PIC by the variable resistor on the Sensor board. Download the program to the PIC and test it.
L10-I5
Translate the number between 0 and 1024 of the exercise above into a voltage reading between 0 and 5V. Make the reading as accurate as it can get in this 10-bit mode. Download the program to the PIC and test it.
L10-I6
Develop a program that allows you to monitor when the lights are on and when they are off in a certain room, during a 24 hour period, using the LDR on the Sensor board. Use the EEPROM inside the PIC to store the light measurements. You want as many measurements as possible stored in the EEPROM over a 24 hour period. The 16F1937 PIC has 256 bytes of EEPROM memory on board. Figure out what the timing interval of the measurements should be and start programming. When you come back after 24 hours you should to be able to display all these stored EEPROM values one by one on the LCD, with the corresponding number (EEPROM address 0-255) next to it. You should be able to scroll through them by pressing SW0 or SW1. Make the intervals much smaller to test it before you give it a 24 hour run. Download the program to the PIC and test it.
L10-I7
Draw up the full circuit diagram of the PIC with the LDR and the LCD correctly connected, including the clocking circuit, the reset circuit, VDD and VSS connected to the PIC. If you were to actually prototype the circuit of this drawing, and connect power to it, it should behave 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.
L10-I8
Connect the prototype board to port E of the Multiprogrammer and build your own 10 bit accurate temperature measurement using either an LM35 (°Celcius) or an LM34 (°Farenheit) temperature sensor. Read the datasheets of these components before you start. Display both the digital measurement (0-1024) and the actual temperature on the LCD. Download the program to the PIC and test it. Use a correct voltmeter and maybe even a thermometer to check your result.
L10-E9
Use the EEPROM in the exercise above to make your own 10-bit accurate temperature logger. Lets say that you want to log the temperature of a certain room in a house during 24 hours and with 20min intervals. This is quite similar to the logger you developed for the LDR, except this one needs to store 10-bit data in an 8-bit wide EEPROM. When you come back after these 24 hours you need to be able to display all these stored EEPROM values one by one on the LCD, with the corresponding number (EEPROM address) next to it. You should be able to scroll through them by pressing SW0 or SW1. A blinking LED indicates if the logger is still logging. After the 24 hours are passed, all LEDs should be on. Download the program to the PIC and test it.
L10-I10
Draw up the full circuit diagram of the PIC with the Temperature sensor and the LCD correctly connected, including the clocking circuit, the reset circuit, VDD and VSS connected to the PIC. If you were to actually prototype the circuit of this drawing, and connect power to it, it should behave 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.

<^< 9. Keypad | Course index | 11. Software Macro >^>

Print - Search - Login

Page last modified on May 13, 2013, at 03:37 PM