View previous topic :: View next topic |
Author |
Message |
quium2001
Joined: 19 Jun 2006 Posts: 2
|
PROGRAMMING PIC16F877 TO FUNCTION AS ADC |
Posted: Mon Jun 19, 2006 3:59 am |
|
|
Hi
I am trying to sample the ac voltage(0-5)v at about 700 points sampling rate per second using the analog channels of pic16f876 can any one help me with the codes for programming it using ccs c compiler and later wants to transfer iton to the pc using rs232 port.
Please provide me with the codes |
|
|
rwyoung
Joined: 12 Nov 2003 Posts: 563 Location: Lawrence, KS USA
|
|
Posted: Mon Jun 19, 2006 7:11 am |
|
|
Your kidding, right? Do your homework for you?
Here are the steps:
1) Read data sheet for the microcontroller in question. Pay close attention to the section on the ADC, serial communication and the timers. VERY IMPORTANT, DO NOT SKIP THIS STEP.
2) Read the CCS manual. Notice how many of the hardware features of the chip you intend to use map nicely with functions supplied with the compiler. VERY IMPORTANT, DO NOT SKIP THIS STEP.
3) Look in the /samples and /drivers directories installed when you installed your legal (it is a legally licensed copy, isn't it?) of the compiler. DON'T SKIP THIS ONE EITHER.
4) Take a clean piece of paper (maybe splurge and a have a whole pad) and draw a block diagram, flow chart for the top level program flow, smaller flow charts for each subroutine or ISR and finally a detailed schematic. But don't jump right in a write code yet. IN FACT, DON'T SKIP ANY STEPS.
5) Now work backwards from your lowest level flowcharts and write code. You will need a small main() to let you test the code. Check that your timer ISR is popping at the right rate by toggling a bit and watching with an oscilloscope. Check that your RS232 code and circuit work by sending and receiving the alphabet, etc.
6) Keep iterating between code, test, revise until each low level block in your flowcharts work, then move up a layer and stitch together the subroutines/ISRs into a complete and finished project. _________________ Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month!
Last edited by rwyoung on Mon Jun 19, 2006 3:40 pm; edited 2 times in total |
|
|
treitmey
Joined: 23 Jan 2004 Posts: 1094 Location: Appleton,WI USA
|
|
Posted: Mon Jun 19, 2006 8:12 am |
|
|
Good general guidelines, rwyoung. Nice work.
Last edited by treitmey on Mon Jun 19, 2006 3:17 pm; edited 1 time in total |
|
|
rwyoung
Joined: 12 Nov 2003 Posts: 563 Location: Lawrence, KS USA
|
|
Posted: Mon Jun 19, 2006 12:17 pm |
|
|
treitmey wrote: | Good general guidelines, rwyoung. Nice work.
(check spelling of legally) |
Whoops. Got those two and one other typo fixed. _________________ Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month! |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Mon Jun 19, 2006 3:05 pm |
|
|
Well you might as well fix "licensed" |
|
|
rwyoung
Joined: 12 Nov 2003 Posts: 563 Location: Lawrence, KS USA
|
|
Posted: Mon Jun 19, 2006 3:41 pm |
|
|
Mark wrote: | Well you might as well fix "licensed" |
Yep. See any others? _________________ Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month! |
|
|
|