Recent Posts

Blogroll

                                          My PIC12F683 Development Board
Office Map Circuit diagram for each experiment may not be available separately because they are conducted with PIC12F683 development board that I made. So, the readers should first see the schematic of my development board.

Saturday, July 31, 2010

Experiment No. 5: DC Motor Speed Control using Pulse Width Modulation (PWM)

Introduction

PIC12F683 has a built-in PWM module. The PWM output (CCP1 pin) is multiplexed with GPIO.2 (pin 5). So the TRISIO<2> bit must be cleared to make the CCP1 pin an output.
The objective of this experiment is to control the speed of a DC motor with an input from a potentiometer. This will be achieved in two steps:
  • Read analog value (potentiometer output) through AN0 channel and generate a PWM wave at CCP1 pin (5) with duty cycle proportional to the analog value.
  • Feed the PWM to motor driver transistor and observe the speed.
mikroC library routines for PWM
PWM1_Init
PWM1_Set_Duty
PWM1_Start
PWM1_Stop

Since PWM1_Set_Duty library function takes duty cycle input as an 8-bit integer, the digital value of analog signal, which is 10-bit, must be converted to 8-bit first. This will give 256 speed levels (0-255).

Experimental Setup
Connect POT2 output to pin 7 (AN0) of PIC12F683 and pin 5 (CCP1) to the input of motor driver transistor.

Saturday, June 26, 2010

Experiment No. 4: External Interrupt

PIC12F683 has got one external interrupt pin (GP2, pin 5) which is edge-triggered:
  • rising edge if INTEDG bit in OPTION register is SET,or 
  • falling edge if INTEDG bit in OPTION register is CLEAR
In this experiment we are going to simulate an external interrupt event by a tact switch which when pressed gives a falling edge (5->0V) to external interrupt pin. When a valid edge appears on GP2/INT pin, the INTF bit (INTCON<1>) is set. This interrupt can be disabled by clearing INTE control bit (INTCON<4>). While exiting from the Interrupt Service Routine, INTF flag must be cleared to re-enable the interrupt again. ANSEL and CMCON0 must be initialized to configure GPIO as digital I/Os.

On the arrival of an interrupt, the new value of counter will increase by 1 and is displayed as no. of interrupts serviced. 

Experimental Setup:
External interrupt will be simulated by a tact switch on the board. So connect SW1 to GP2 with a jumper wire. For display purpose we will again use a hyperterminal window on a PC.


Experiment No. 3: Analog to Digital Converter with PIC12F683

As mentioned before, 4 out of 6 GPIOs in a PIC12F683 also provide analog-to-digital converter inputs with 10-bit resolution. They are GP0-GP2, and GP4. In this experiment we will feed an analog voltage to one of the ADC inputs (say AN0, which is GP0) and display the output digital value on a hyper-terminal window on PC. The analog voltage will be simulated with the potentiometer on our board.

Experimental Setup:
Connect the output of potentiometer (POT2) to AN0 (pin 7). GP5 (pin 2) will serve as TX pin for Software UART so connect it to input Tx of TTL to RS232 Level Shifter circuit. Also connect Rx (2) and Gnd (5) of a RS232 port to the board. This is similar to what we did in Experiment No. 2.

Online Embedded Systems Lab

This online laboratory teaches you the fundamentals of microcontroller-based embedded system development through a series of laboratory exercises. Most of the time, students and hobbyists could not afford expensive development kits and software to learn these things. These tutorials are prepared such that you will be building microcontroller projects at a minimum cost. Check this out