Description: To start working with microcontrollers, several essential items are required. The PICSTART Plus kit, part number DV003001, was purchased from Microchip. This kit contains a sample PIC16F84 microcontroller chip, which in this case is a PIC16F84A chip. This chip features 18 pins and operates as an 8-bit device. The data sheet for the PIC16F84A consists of only 88 pages, making it simpler to navigate compared to the 18F chip. However, it is important to note that the 16F series does not support USB connectivity. The kit also includes a programmer unit, which is responsible for writing programs to the chip and interfaces with a computer's serial port. For newer computers, a USB to Serial Converter may be necessary. The programmer is compatible with both the 18-pin PIC16F and the 40-pin PIC18F chips. Additionally, the kit provides a compiler, assembler, and the MPLAB IDE, which offers a development environment for various chips and supports programming in C and Assembly languages. The IDE includes a simulator and debugger. While awaiting the kit's arrival, it is advisable to read the PIC16F84A data sheet, particularly the pin configuration on page 3. Special attention should be paid to the oscillator circuit, which is essential for operation. The PIC16F84A chip supports four oscillator configurations: LP (Low Power Crystal), XT (Crystal/Resonator), HS (High Speed Crystal/Resonator), and RC (Resistor/Capacitor). A standard oscillator circuit typically employs a crystal and two capacitors, ranging from 15 pF to 33 pF. These components can be sourced from The Electronic Goldmine. Additional required items include a breadboard, an IC extraction tool, a 5-volt regulator (7805), LEDs, and resistors. For the LEDs, low-power 15mA 3-volt types were used. The resistor value was calculated as R=(5V-3V)/(15mA)=133kΩ, leading to the use of 150 kΩ resistors. These components are available at local RadioShack stores.
The provided assembly code snippet demonstrates a simple LED control program for the PIC16F84A microcontroller. The program initializes the microcontroller's registers and sets up the necessary configurations to control the state of LEDs connected to PORTB. The initial setup includes defining processor-specific variables and configuring the `_CONFIG` settings to disable code protection and watchdog timer features while enabling the power-up timer with the XT oscillator configuration.
The main program flow begins by loading a specific value into the working register and configuring PORTB pins for output. The program enters a loop where it calls a subroutine to change the state of the LEDs and then pauses for a brief period before repeating the process. The delay mechanism is implemented using two delay counters, and the `change_leds` subroutine manipulates the `led_counter` variable to control which LEDs are illuminated.
The program concludes with a reset routine that reinitializes the `led_counter` to a predefined value, ensuring that the LED control cycle can repeat indefinitely. This example illustrates fundamental microcontroller programming concepts, including register manipulation, subroutine calls, and delay generation, which are essential for developing embedded applications.You will need a few items to begin working with microcontrollers. I purchased the PICSTART Plus Part Number: DV003001 kit from Microchip. This kit includes the following: A sample PIC16F84 microcontroller chip: My kit actually came with a PIC16F84A chip. This is a 18 pin, 8-bit chip. The PIC16F84A data sheet is only 88 pages. So this is easier than the 18F chip. But the 16F chips do not support USB. The programmer unit: This is the device that will write the program to the chip. This will interface with a computer`s serial port. On newer computers, you may need an additional USB to Serial Converter. I am able to use this programmer for the 18 pin PIC16F and the 40 pin PIC18F chips. Compiler, Assembler and IDE. The kit comes with a copy of the MPLAB IDE. This provides a development environment for many different chips and supports C and Assembler programming languages. The IDE contains a simulator and a debugger. While you wait for the kit to be delivered, I would recommend reading the PIC16F84A data sheet. You will need to review the pin configuration on page 3. Make special note of the following: In addition to the above, you will also need some basic electronics components.
You will need an oscillator circuit. Section 6. 2 covers the oscillator configurations. The 16F84A chip has four possible oscillator configurations: LP Low Power Crystal, XT Crystal/Resonator, HS High Speed Crystal/Resonator and RC Resistor/Capacitor. A typical oscillator circuit uses a crystal and two capacitors ranging from 15 pF - 33 pF. You can get the crystal and capacitors from The Electronic Goldmine. You will need a breadboard, a IC Extraction Tool, a 5 volt regulator (7805), some LEDs and resistors.
I used low power 15mA 3volt LEDs. Doing the math, you find R=(5volt-3volt)/(15mA)=133kOhm. So, I used 150 kOhm resistors with these LEDs. You can find these at a local RadioShack. list p=16F84A #include ; processor specific variable definitions radix hex _CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC udata Delay1 res 1 ; reserve a byte for a delay counter Delay2 res 1 ; reserve another byte for a delay counter led_counter res 1 ; reserve one byte for our led counter org 0x005 start movlw b`00001111` ; load W with b`00001111` ; we will reserve RB7, RB6, RB5, RB4 for output tris PORTB ; enable the selected pins for output clrf PORTB ; clear PORT B movlw b`00010000` ; move b`00001111` to register w movwf led_counter ; move register w to led_counter my_loop call change_leds ; changed the leds call pause ; wait a few cycles goto my_loop ; repeat ; - ; pause ; - pause my_delay: DECFSZ Delay1, 1 ;Decrement Delay1 by 1, skip next instruction if Delay1 is 0 GOTO my_delay DECFSZ Delay2, 1 GOTO my_delay return ; - ; change_lights ; - change_leds decf led_counter, 1 ; led_counter = led_counter - 1 swapf led_counter, 0 ; we need to shift the value of led_counter ; so that the lower half of the byte ; displays on pins 4-7 ; This new value will be in register w movwf PORTB ; move w to PORTB movfw led_counter bz reset_counter ; if led_counter = 0, then jump to `reset_counter` return reset_counter ; reset led_counter to b`00010000` movlw b`00010000` ; move b`00001111` to register w movwf led_counter ; move register w to led_counter return end
Refer to the OSCCON register in the datasheet (currently on page 19). This register controls the speed of the internal clock, which operates at 31 kHz upon startup—considered too slow. By using the OSCCON register, the speed can be increased...
Perfect Pitch, which is based on the 8751 microprocessor, is an affordable and straightforward instrument tuner and frequency counter that features a built-in headphone amplifier and a visual metronome. Perfect Pitch converts the audio signal from an instrument into a...
The Elector Crescendo was the first DIY amplifier that was not a kit. The design was sourced from the Elector magazines available at a local library.
The Elector Crescendo is an innovative audio amplifier designed for DIY enthusiasts. It features a...
This document discusses the use of small microcontrollers, such as those from the PIC and Atmel series, which typically operate at 5V and require less than 100mA for complete system functionality. Some PICs can function at lower voltages, such as...
A timer is being developed for circuit training or boxing training. The timer does not require any external input, except for a reset function. The project can be simplified using a microcontroller, such as the PIC12F635, which is cost-effective at...
The talking Yoda head consists of a Yoda mask and a microcontroller system to achieve the desired operation/effect. The basic operation of the project was specified as follows: The head was to be placed inside a closed box. Upon opening...
Microcontrollers (MCUs) are versatile integrated circuits that enhance the functionality of electronics, robotics, and other projects. However, they...
Microcontrollers (MCUs) serve as the central processing unit in a variety of electronic applications, offering programmable control that allows for complex functionalities in...
This article outlines the construction of a simple microcontroller-based delay circuit designed for photographic applications such as drop or high-speed photography. It can control the trigger lag of cameras and flash units, generate periodic trigger pulses, or manage magnetic valves....
This is the lowest cost dialing alarm on the market and shows what can be done with an 8-pin microcontroller. The complete circuit is shown below. You cannot see all the features of this project by looking at the circuit...
We use cookies to enhance your experience, analyze traffic, and (if you allow) serve personalized ads.
By clicking Accept All, you agree to our use of cookies.
Learn more