Thursday, January 7, 2021

Knight Rider circuit with PIC16F84A

In this post I will show you how to build a Knight Rider circuit from scratch using PIC16F84A micro-controller.

 
 
Required components:
  • PIC16F84A
  • 18 pin IC base
  • LED x8
  • 220 ohm x8
  • 1k x1
  • 8MHz Crystal Oscillator
  • 22pF x2
  • 2 wires for power supply

MikroC program for  Knight Rider Circuit

void moveright()
{
     while(PORTB.F7!=1)
     {
                PORTB=PORTB*2;
                delay_ms(100);
     }
}

void moveleft()
{
     while(PORTB.F0!=1)
     {
                PORTB=PORTB/2;
                delay_ms(100);
     }
}

void main()
{
     TRISB=0;
     PORTB=0xff;
     delay_ms(1000);
     PORTB=0x1;
     delay_ms(100);
     while(1)
     {
              moveright();
              moveleft();
     }
}
 

Please note that before compiling you need to set below configurations, in Project settings.
  1. Device : PIC16F84A
  2. MCU Clock : 8.000000MHz
 
Once you have the .hex file generated from MikroC compiler, let's move to Proteus to build the circuit for simulation and PCB layout generation.

Proteus Schematic:

Once schematic is completed please set CRYSTAL value to 8MHz and double click on PIC16F84A to set clock frequency and to load generated .hex file from MikroC compiler. Now you can start the simulation to verify the output.

Using  MPLAB you can load the generated .hex file to PIC16F84A micro-controller using Pickit 3 programmer.

Next Let's generate PCB layout using the same schematic we built.

PCB Layout:

 
 
Next we'll generate actual PCB from the above PCB layout using Toner transfer and etching technique.

  1. Wash and clean copper board so that there are no oxides left in copper layer. (Till it gets shiny)
  2. Print PCB layout to a Magazine paper.
  3. Place the magazine paper(printed side) on top of copper board and apply masking tape to stop sliding.
  4. Next apply nail polish remover liquid to the magazine paper and gently rub the  paper, so that toner will attached to the copper layer. Please do this about 10mins covering the whole printed area, specially in each schematic path.
  5. Once above done, slowly remove the Magazine paper, and you will notice how toner attached to copper board along with some residue paper also.
  6. Next you can wash residue paper and get clean schematic paths in copper layer.
  7. In any case if a path is broken, fix the broken path using a permanent marker pen.
  8. Now submerge the copper board in a FeCl3 (Ferric Chloride) liquid and slowly shake it using some hand tool.
  9. Once the unwanted copper disappear completely, wash the copper board and remove applied toner, such that you will have only schematic copper paths.
  10. Next solder each and every component and apply 5V power supply, to get this functional.



No comments:

Post a Comment

Note: Only a member of this blog may post a comment.