PDA

View Full Version : Can anyone please help me with my project? - Rate meter



Humbleworker
- 27th March 2007, 08:00
Utilizing a laserlight and a phototransistor (RA0), I have created a counter. I'm using PIC16F628A with an onboard 4mhz oscillator. Right now it only displays how many objects have passed by. I would like to add another function which is to display the rate of objects that pass per min. or per hour. I don't know how to incorporate this into the program. Can anyone help me?

sayzer
- 27th March 2007, 08:28
By "rate", did you mean the number of people passed in one minute?

IF yes, then use Timer1 module of the PIC at 1:8 scale and have 500ms timing interval. This way, you can have Timer1 module timing in the background while you can at the sametime have your counting in the foreground.

OR

You can just use simple PAUSE command to create 1 minute timing interval and have your counting in a WHILE statement.

For example,



CountPin VAR PORTA.0
Timing VAR WORD
Counter VAR WORD
Timing = 0
Counter= 0

Start:

WHILE Timing < 6000
IF CountPin = 0 THEN
WHILE CountPin = 0 : WEND

Counter = Counter + 1 'Number of people Passed
Timing = Timing + 1 'Timing: 6,000x10ms=60,000ms (1 min)
PAUSE 10

ENDIF
WEND

Timing = 0

Goto Start