Help in connecting a SN74190N to an 877 PIC

Thread Starter

HindA

Joined Mar 6, 2011
13
Like I said. A sets a flag. When B is tripped it sees if A flag is set. That means someone came in.

If B is tripped it checks to see if A flag is set. If not then it sets a B flag. When A is tripped, it checks the B flag. If set then that means someone is exiting.

Your problem is going to be if people try to enter and exit at exactly the same time. Then I don't know what to do.

You could get really fancy when A is tripped, it starts a timer. If B is not tripped then the enter count is canceled. It means they changed thier mind. :)
First of all, I'd like to thank you for following up with me and bearing my simple questions!

I have some prelimininary knowledge in mickroC, I know how to specify input and output pins and manipulate the ports. But what I don't know is how to put what you told me in mickroC. How do I check for flags?
 

Thread Starter

HindA

Joined Mar 6, 2011
13
A infrared LED and a photo-diode do not by themselves make a great switch. room lite can have a false trigger.

To count if some one come's in you would need a sensor on the inside of the door to see if they exited you'll need one on the outside. Like you said.

That would make coding easy

Like this sensor_out as variable and sensor_in as variable. and a counter

Your code would be like this this is in basic But it easy to write it in C to

Rich (BB code):
dim sensor_out as byte
dim sensor_in as byte
dim counter_in as byte
dim counter_out as byte
 
If sensor_in = 1 and sensor_out =0 then 
      counter_in = counter_in +1
      counter_out = counter_in
      //you can add action code here
elseif sensor_out = 1 and sensor_in = 0 then
      counter_out = counter_out - 1
endif
Just a idea I would blink my Infra red diode at 38 to 40 khz that would keep room light from interfering. And test to see if your receiving light from your Infra red diode
Thank you for the advice about the infared light :) but what I'm actually doing is a prototype for a project(a small wooden house) so I do not think that is my current problem.

As for the C code, I do not see how is it applicable for me since for a person to be considered in, he sensor_out=1 then sensor_in=1 with a certain time difference, the opposite order applies to the person to be considered out.

Thanks again!
 

Thread Starter

HindA

Joined Mar 6, 2011
13
I would like to solve my problem first then I will have to worry about entering and exiting at the same time. But as you guys said, it needs to be done EXACTLY at the same time ;)
 

lightingman

Joined Apr 19, 2007
374
I know that I have to add up all the people that entered and subtract all those who went out. The problem is how do I get the PIC to differentiate if A occured before B or B occured before A (meaning if the 1st sensor was crossed before the second one=> person in, and if the 2nd sensor was crossed then the 1st one was crossed after=> a person out)?

Thank you again :) I'm looking forward to your reply.
It is easy.

I have done the code for you. I will give it a try-out tonight and we will go from there. It is the same principal as reading an optical shaft encoder, A before B (one direction), B before A (the other direction).

Daniel.
 

Thread Starter

HindA

Joined Mar 6, 2011
13
Have a little look at this
Yes be80be,
You are right and I agree with the concept of the picture. But I think that the code will not give a right result if a person crosses sensor_in then decides to go back. The code will consider him in while he actually is not.
Thanks.
 

be80be

Joined Jul 5, 2008
2,072
It takes A then B to be true if only A you'll error

Or B then A to be be true, just B you didn't leave same for A

There will be error no matter how you do it people are not an optical shaft encoder

Were all size and shapes low and fast moving.
 

lightingman

Joined Apr 19, 2007
374
Hi again,

I have done it and it seems to work fine. It waits in a loop for A or B sensor. If a sensor is activated, it then waits for B, if B sensor is activated, it waits for A. Only after both sensors are activated does it count up or down. If only one sensor is activated and not the other, it is ignored until one or the other is activated. I included an LCD in the test program, to see the count. It counts from 0 to 255. If the count is higher than 0 it turns the light on. If the count is 0 it waits 2 seconds and turns the light out.

Daniel.
 
Top