PDA

View Full Version : 16F876 AD comparisation help needed



RFsolution
- 4th January 2004, 15:35
Hi

First a happy newyear, and a lot off PBP projects

As I'm a newcomer i would like to have some help from the REAL programmers

I would like to do the following with a 16F876

I have 5 AD channels with 5 variables (byte or word)
I have 5 input I/O 's (pulled up) and 5 outputs (led)s

If 1 or more inputs goes low the code has to read the representing AD converter and compare the value's
Then an output has to become High with the AD representing the highest value
Meanwhile the other's may become active or inactive

I also need some hysteresis on the comparisation:
a variable which give the minimum difference between the
AD values before the output changes, another variable which
determines the time before changes ( max a few seconds)

Can anyone set me in the right direction ?

Walter

Melanie
- 6th January 2004, 17:28
This is quite achieveable, easy and simple too, but short of someone writing the code for you from your description, you have to start somewhere yourself.

What I do is generally start with a rough block diagram (doesn't have to be a flow chart) as to how I want my code to work... you've pretty much described that, but put in block form. Interconnect the blocks (on paper, back of an envelope or beer mat) so you have some sort of logical flow... (kinda like the block I've appended based on your description).

Next work out what you've got hanging on what pin of your PIC... then finally try to code each block... and put it to the test on a prototype. If you need to, each large rough Block can be broken down into smaller blocks and a proper flow chart constructed.

Again, short of writing the code for you, this is where you take over and continue...

Melanie

selbstdual
- 29th April 2008, 19:41
rough block diagram.pdf
What a beautiful beer mat, I love those when it's clear that the restaurant owner had to skimp on ink. What did you drink that day? :D