Project on 16f877

Thread Starter

Rushan

Joined Nov 20, 2013
5
Hi all,
I'm new to this forum & this is my first post.I'm doing a project using 16f877.I am new to pic programming.So please tell me how can i learn to program this MC in c language.I want to send data to LCD and interface with serial port also.Please tell me which software i should use to code and help me to learn relavent syntax.
Thank you.
 

t06afre

Joined May 11, 2009
5,934
Is this some schoolwork? If so those tool that are common in classes. If not I would suggest MPLAB and Microchip XC8 compiler. The latter tools are free to download and use.
 

John P

Joined Oct 14, 2008
2,026
The Microchip compiler works, but I hate the "sneerware" aspect of it. Every time it runs, it reminds you how much better the code could be, if you only got the paid-for version of the program. Or is there a way to turn this function off?

I use the BoostC compiler. It's nothing fancy, but it does the job.
 

Thread Starter

Rushan

Joined Nov 20, 2013
5
Thank you all for helping.I'm a computer engineering student.This is a my side project.This is my first micro controller based project.I have MPLAB. Can i use MPLAB for using C language?please give me a source to learn programming PIC16f877 using C.
my project has following features...
*This is digital Voting system.I get authentication using the fingerprint scanner.
*Then using 3 push buttons voters can vote for 3 candidates.
*It counts the votes and write them to the LCD.
I have designed the circuit diagram.Now i want to program the MC using C language.
 

t06afre

Joined May 11, 2009
5,934
Thank you all for helping.I'm a computer engineering student.This is a my side project.This is my first micro controller based project.I have MPLAB. Can i use MPLAB for using C language?please give me a source to learn programming PIC16f877 using C.
my project has following features...
*This is digital Voting system.I get authentication using the fingerprint scanner.
*Then using 3 push buttons voters can vote for 3 candidates.
*It counts the votes and write them to the LCD.
I have designed the circuit diagram.Now i want to program the MC using C language.
Yes you can use the Microchip XC8 compiler from MPLAB. It have a free mode. http://www.microchip.com/pagehandler/en_us/devtools/mplabxc/
This document will get you started http://ww1.microchip.com/downloads/en/DeviceDoc/50002173A.pdf And also the manual is important. I am not sure about a good source for learning C with the 16F877. I suggest you divide your project into different blocks. Then start with the blocks you are most comfortable with. Do not forget even if you program in C. You must read/confer with the datasheet then in doubt.
One thing I might say. If you use MPLAB and not MPLABX I might suggest using the HI-TECH C compiler http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en542849 As this come with a lot more examples. For some reason all examples has been stripped from the XC8 compiler. Examples is a very good source for learning
 
I use the Microchip C18 compi8ler after having problems with the Hi Tech one.
Hi Tech made changes to the compiler and had to rehash my code to get it to work again !
 

Thread Starter

Rushan

Joined Nov 20, 2013
5
thank you all for helping.I have started coding using MPLAB XC8 compiler.I want to interface the MC with a fingerprint scanner.Please tell me a suitable simple,low price FP scanner.And also i want to know how it works so that i can do my c code according to that.
 

John P

Joined Oct 14, 2008
2,026
So you've done a Google search on "fingerprint scanner", right? Tell us what you found!

If you want to use the processor's serial port to talk to a computer, and the scanner also wants to use a serial port, you may have a problem. But let's hear about the scanner first.
 

Thread Starter

Rushan

Joined Nov 20, 2013
5
hi all,
i'm doing my coding of my project.But it has some errors(related to LCD commands and PORT individual bit values).So please help me to settle them.
this is my code:
#include<pic.h>


void main(){
unsigned int i,j,k,l;
unsigned short count1,count2,count3;
char txt[5];
TRISB = 0b00000000; //port B is a Output
PORTB = 0b00000000; //port B bit values intialization
TRISA = 0b001110; //port A 1,2,3 bits are inputs & others are Outputs

TRISCbits.TRISC7 = 1; //port C bit 7 is an input

count1 = 0;
count2 = 0;
count3 = 0;

Lcd_Init(&PORTB);
Lcd_Cmd(LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Out(1,1,"Fingerprint Voting Machine");
Lcd_Out(2,1,"Init...");
delay_ms(2000);


INTCON=0; // purpose of disabling the interrupts.


while(1){
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,1,"Swipe Finger");
shorttostr(count1,txt);
Lcd_Out(2,1,txt);
shorttostr(count2,txt);
Lcd_Out(2,6,txt);
shorttostr(count3,txt);
Lcd_Out(2,11,txt);


if(rC7_bit == 0){ // i assume that if fingerprint device
//gives verification port C bit 7 will become 0
//i have temporary used a push button for that
while(rC7_bit == 0){}
Lcd_Cmd(_Lcd_CLEAR);
Lcd_Out(1,1,"WelCome!");
Lcd_Out(2,1,"Cast Vote");

PORTA0 = 1; //beep sound one time
delay_ms(100);
rA0_bit = 0;

while(rA1_bit == 1 && rA2_bit == 1 && rA3_bit == 1){ //if anyone of 3 button are pressed
}

if(rA1_bit == 0){
while(rA1_bit == 0){
}
count1 += 1;
}

if(rA2_bit == 0){
while(rA2_bit == 0){
}
count2 += 1;
}
if(rA3_bit == 0){
while(rA3_bit == 0){
}
count3 += 1;
}

}else{ //if not match the fingerprint
Lcd_Cmd(_Lcd_CLEAR);
Lcd_Out(1,1,"NotMatch");

rA0_bit = 1; //beep sound three times
delay_ms(100);
rA0_bit = 0;
delay_ms(500);
rA0_bit = 1;
delay_ms(100);
rA0_bit = 0;
delay_ms(2000)

}
delay_ms(100);
}


}

i have attached my circuit diagram also(project.png).
 

Attachments

Top