Motion detectors on staircase

Status
Not open for further replies.
Hello EletroTech forum,
Have designed a circuit and a PCB that sends the signal from a PIR sensor (motion detector) and
triggers a 555 timer to turn on some LEDS for about a minute. I call the circuit P5L (PIR to 555 to LEDs).
It has taken about month to design the schematic, prove the circuit logic with a breadboard, and
design and order the PCBs.
The plan is to use several P5Ls to, instead of turning all lights on a stairway at once, light up thestaircase two or three treads at a time so that the system reacts to the movement of the walker. I saw
something similar at a staircase at the Perot Museum in downtown Dallas.

A colleague who is an EE and has much experience was asked about how to make the lights below come on
when approaching from above and lights above come on when approaching from below. He said the
two methods that came to mind were an Arduino and 4013 flip flops. To avoid the programming overhead
and to learn about a new IC the 4013 was chosen.

Research on the 4013 Flip Flop led to
How to Build a D flip flop Circuit with a 4013 Chip



The system should work differently depending on whether the walker is going up the stairs
or down the stairs. Or stated more formally:
System Requirements:
Use Case One (going up): When sensor S6 is triggered the LEDS above (LED L7.1 and L7.2) are turned on
if LEDs below (L5.1 and L5.2) are on.
Use Case Two (going down): When sensor S6 is triggered the LEDS below (LED L5.1 and L5.2) are turned on
if LEDs above (L7.1 and L7.2) are on.

Sensor S6 is used in the requirements as an example to illustrate that the lights below a sensor would
be activated by movement down the stairs and lights above above a sensor would be activated by movement up
the staircase. The exception is sensors S1 and S8. There are no lights below S1 or above S8 and so S1
has no sensitivity to another set of lights. S1 simply turns on LEDs L1.1, L1.2 and L1.3. And similar for S8.

NOTE: 'Q2' is used as a substitute for Q with a hyphen above it because there is
no way of putting a hyphen above a Q using the characters on a standard keyboard.)

In Use Case One (going up)
S1 is triggered and the PIR
- Sends a signal to the P5L operating LEDs L1 and turns L1 LEDs on
S2 is then triggered
- Sends a signal to 4013.1 pin 4 (R) which makes Q1 = 1 and Q2 = 0. Q1 sends a high signal to L2 LEDs and a low or no signal to L1 LEDs
S3 is then triggered
- Sends a signal to 4013.2 pin 4 (R) which makes Q1 = 1 and Q2 = 0. Q1 sends a high signal to L3 LEDs and a low or no signal to L2 LEDs
S4 is then triggered .......

In Use Case Two (going down)
S8 is triggered and the PIR
- Sends a signal to the P5L operating LEDs L7 and turns L7 LEDs on
S7 is then triggered
- Sends a signal to 4013.6 pin 4 (R) which makes Q1 = 1 and Q2 = 0. Q1 sends a high signal to L6 LEDs and a low or no signal to L7 LEDs
S6 is then triggered
- Sends a signal to 4013.5 pin 4 (R) which makes Q1 = 1 and Q2 = 0. Q1 sends a high signal to L5 LEDs and a low or no signal to L6 LEDs
S5 is then triggered .....

Three questions:
1. Is this the best way to use the flip flops?
2. Is the clock an oscilator like a 555 timer? If there are six 4013s can they all be run from one 555?
3. I am familiar with a positive signal coming from, say, the PIR sensor which sends a 3 volt
signal. And at the Arduino send a HIGH signal with the statement 'lc.setLed(0,0,0,true)'.
And it is assumed that the three volt signal from the PIR to a pin on the 4013 would be
intepreteted as value of 1. But how does one send a signal to the pin of value zero?
Thanks.
Allen in Dallas
 
Hello
Three questions:
1. Is this the best way to use the flip flops?
I don't understand why you need flip flops if using an Arduino?
How do you intend to connect the FFs'

2. Is the clock an oscilator like a 555 timer? If there are six 4013s can they all be run from one 555?

For the 4013B:
No, the clock pin is not an oscillator (although it can be driven by an oscillator)
The "clk" (clock) pin is the trigger for the FF and is used to toggle the flip-flop. The "D" pin is usually connected to the Qbar pin to form a "toggle" flip flop. When the "clk" pin senses a rising edge of a pulse, (or if multiple pulses are sensed by the clock pin), each rising edge will cause the flip flop to "toggle".


The flip flop triggers on the leading (or rising) edge of a pulse sensed at its "CLK" input. So "sending" it zero would do nothing.
When triggered, it toggles its Q and Qbar output pins to the previous state. So to get it to do anything, you have to send the "clk" pin a signal with a rising edge.

Hope that makes sense...
 
Hello eTech,
Arduino was mentioned as an option, but to avoid the Arduino programming overhead
and to learn about a new IC the 4013 was chosen.

So sending a signal to, say, pin 5 would cause Q to be 1 and Qbar to be 0.
But you said that the signal is sent to the clock. So are the other pins, 5, 4, and 6 affected by sending a signal to the clock?
How does one know what state Q and Qbar are initially? Are they always zero?
Will the three volt signal from the PIR work as a signal?

Thanks.

Allen in Dallas
 
So sending a signal to, say, pin 5 would cause Q to be 1 and Qbar to be 0.
What I described earlier is a DFF wired as a "toggle" FF.
The image in post #3 shows the DFF wired as a "Set/Reset" FF. When wired this way, the D pin is always connected to logic "high".
The SR FF is toggled using only the Set and Reset pins and the "clock' pin is not used. The Set pin makes Q high and Qbar low. The Reset pin makes Qbar high and Q low. Reset overrides the Set pin.

But you said that the signal is sent to the clock. So are the other pins, 5, 4, and 6 affected by sending a signal to the clock?

Again, I was describing the operation of a DFF wired as a "toggle" FF.
D, S, R, Clk are input pins. Q, Qbar are output pins.
When the Clk senses a leading edge, the logic state of the D pin is transferred to the output pin.
The Q and Qbar pin can never be high at the same time.
The S,R pins override the Clk and D pins.

How does one know what state Q and Qbar are initially? Are they always zero?
DFF's are usually initialized to a known state at power on. This is usually done by momentarily applying a logic "high" to either the Set or Reset pin.
Will the three volt signal from the PIR work as a signal?

No. But you can use a 2 transistors to shift the voltage level (without inversion) to 5 volts.

BTW-

It would help if you would specify the desired operation of the lights in terms of various conditions of movement on the stairs. Including movement by one or more persons. I haven't seen this in the various postings regarding this project.

eT
 
Last edited:
What are the characteristics of your PIR sensor?
- Field of view angle and range.
- Duration of output pulse from sensed motion.
 
What will happen is someone walks half way up then turns around or if two people go in opposite directions?

The simplest solution may be to detect the stair occupied and light one or two either side so direction doesn't matter.

I think you may need the Arduino.

Mike.
 
Hello eTech, ChrisP58, Pommie and the Electro-Tech Forum,

ChrisP58:
The PIR is an SM312. Datasheet at


Pommie:
The use case to solve is the simplest one: a walker walking up
or down the stairs. Forget outlier use cases: walker reverse direction;
more than one walker; walker takes more than one step at a time.
The simplest use case is the aim.

Pommie may have the best solution: the one above and one below solution
That is, Sensor L1 lights LEDs L1. Sensor L8 lights LEDs L8.
All the other sensors, S2 thru S7, light
the LEDs just above and below the sensor. The issue seen with
that solution is moving up from the bottom, S1 turns on
LEDs L1 (L1.1, L1.2 and L2.3). The walker then trips S2.
Using the one above and one below solution, this would turn
L2 and L1. But L1 is already on. So we are sending an 'On'
signal to L1 twice. The signal from the PIR SM312 lasts about three
seconds and is 3.3 volts. At the schematic 'PIR Sensor to 555
Monostable w Extension Transistor' in the first post of this thread,
the output of the PIR AM312 is going to an NPN trasistor connected to
Pin 2 of the 555 timer. Would it be alright for the transistor to
recieve two three volt signals? The data sheet for the transistor
used, a BC547
has been read and it cannot be discovered what the max
voltage that can be tolerated.

Finally e-tech
In post #4 some excellent info was shared on the flip flop operation.
especially

The schematic in post #3 comes from


It was hoped that, using schematic in post #3, a better understanding
of how the circuit works could be gained by building the circuit.

Here is what observed:
1. When the circuit is powered Q always comes on. The only
outcome on the Truth Table that fits with that is
Data is 1, Reset is 0, Set is 0, then Q is 1, Qbar is 0
Have scoured the data sheet for the flip flop
Flip Flop 4013 D datasheet
and cannot get what the power on status is because the state
described above does not fit e-tech's
DFF's are usually initialized to a known state at power on.
This is usually done by momentarily applying a logic "high" to either the Set or Reset pin.
But it is the only thing that seems to make sense from the Truth Table.

2. Immediately after power on, with Q on, pressing Set (pin6)
or Data (pin5) does nothing but pressing Reset (pin4) turns off
Q and turns on Qbar.

3. With Qbar on, pressing Set (pin6) turns off Qbar and turns on
Q. This is the operation which is most easily and reliably
reproducible: With Qbar on and Q off pressing pressing Set (pin6)
turns off Qbar and turns on Q.
And conversely, With Q on and Qbar off pressing Reset (pin4)
turns Q off and Qbar on.
And so it is possible to toggle between
3a. Q on and Qbar off to Q off and Qbar on (press pin4)
and
3b. Q off and Qbar on to Q on and Qbar off (press pin6)

This would seems to be consistent with status name Delta.
That is, pressing Reset (pin4) turns Q off and Qbar on.
Similarly pressing Set (pin6 seems to create status Echo.
That is, pressing Set turns Q on and Qbar off.

4. The operation of Data (pin5) is not as forth coming.
Sometimes, but not reliably, with Q on and Qbar off,
Reset (pin4) is pressed which, as is indicated in 3a.
above, turns Q off and Qbar on. Then pressing Reset
and second time and then pressing Data (pin5)the
state toggles Q on and Qbar off.
Not sure what is happening here

5. In status name Foxtrot both Q and Qbar are on.
I have pressed the momentary switches in every
conceivable combination and cannot get both
Q abd Qbar to be on. Is that possible with
the citcuit? If so how?

Thanks.

Allen in Dallas
 
Pommie:
The use case to solve is the simplest one: a walker walking up
or down the stairs. Forget outlier use cases: walker reverse direction;
more than one walker; walker takes more than one step at a time.
The simplest use case is the aim.

It is good of you to finally share a design specification.



That is because you have left the clock "floating". The clock input is now in an "unknown" state.
First rule of using cmos chips is never leave inputs floating. If an input pin is not connected, then pull it either high or low but do not leave it floating.
In this case you've left the clock pin floating. A rising edge or spurious noise will trigger the flip flop. So pull it down for testing purposes.

But it is the only thing that seems to make sense from the Truth Table.

You have not initialized the chip to that specific state, It just happens to match the entry in the table. This means the next time it is powered up it may end up in a different state. Like I said, you need to initialize the chip to the desired power up state

2. Immediately after power on, with Q on, pressing Set (pin6)
or Data (pin5) does nothing but pressing Reset (pin4) turns off
Q and turns on Qbar.

First, please read about switch de-bouncing.
Second, please carefully re-review the logic table on the data sheet.
The Q output is already high, If you read the logic table, a high on the set pin will set Q high. So why would you expect it to change?
The other pins are doing what thay are supposed to do. That is shown in the logic table on the data sheet
The S/R pins immediate force the state of the Q/Qbar pins respectively. But Reset overrides Set.
The D pin only comes into play when triggering the FF with the clock input. Its state is transferred to the Q or Qbar


That is correct.


The D pin only comes into play when triggering the FF with the Clock pin.
The S or R pin take precedence over the clock pin. The R pin takes precedence over the S pin.

5. In status name Foxtrot both Q and Qbar are on.
I have pressed the momentary switches in every
conceivable combination and cannot get both
Q abd Qbar to be on. Is that possible with
the citcuit? If so how?

I think that is an error in the truth table. The Q and Qbar are complements of each other, so both can't be high or low at the same time.
At least I've never seen a good DFF one work that way.

One thing you are probably struggling with is noise on the circuit. CMOS chips should have bypass cap across its supply pins as well as debounce circuits at the input pins. Your schematic shows resistors but that usually is not enough. Without these, noise can cause false triggering of inputs causing erratic circuit behavior.

BTW- you are experimenting with a D FF but that doesn't mean you have to use the D and Clock pins. The DFF is a flexible device. You can use it as a Set/Reset flip flop and just pull the D and Clock pins permanently low.

eT
 
Last edited:
Hello to eTech, Pommie and the Electro Tech forum,

Got a lot of good ideas from post #8:
- The floating clock
- pull the clock pin either high or low but do not leave it floating.
- need to initialize the chip to the desired power up state
- switch de-bouncing. (Actually had a little experience with debouncing
a switch when using a relay to activate an LED display triggered by a PIR.
But relays were abnegated when the superiority of transistors were
discovered as switching device.) Have found some good info on this
and will incorporate into the schematic.
- CMOS chips should have bypass cap across its supply pins as well as debounce circuits at the input pins. Will also research how to include by pass capacitors at the supply pins and reissue the schematic.
- The D pin only comes into play when triggering the FF with the Clock pin.
- The S or R pin take precedence over the clock pin. The R pin takes precedence over the S pin.
- Use the DFF as a Set/Reset flip flop and just pull the D and Clock pins permanently low.

Will continue to experiment with and learn about the D Flip Flop but not sure how
the requirements of the Staircase LEDs project could be met using the DFF.

And a solution has been fashioned for the StairCase LEDs project using an Arduino.


But knowledge of the DFFs and how they work is till sought.
So this thread will be abandoned and another thread begun on D flip flops.
Thanks.

Allen in Dallas
 
If you're only using the set, reset, and Q of the CD4013 you should change it for a CD4043 Quad S-R latch.

You'll bet twice as many parts per package, and you don't need to worry about the clock and D inputs. You will need to tie the enable pin high.

If you have more than one signal that needs to go to a particular S or R input, use OR gates to bring them together.

https://www.ti.com/product/CD4043B Quad S-R latch.
https://www.ti.com/product/CD4071B Quad 2 input OR gate
https://www.ti.com/product/CD4072B Dual 4 input OR gate
https://www.ti.com/product/CD4075B Triple 3 input OR gate
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…