/*
* From
https://create.arduino.cc/projecthub/55845/innovation-lab-11-pir-motion-sensor-with-led-43420e
Innovation Lab #11: PIR Motion Sensor with LED © GPL3+
----------------------------------------------*/
int led = A0; // the pin that the sensor is attached to
int sensor = 2; // the pin that the sensor is attached to
void setup() {
pinMode(led, OUTPUT);
pinMode(sensor, INPUT);
Serial.begin(9600);
}
void loop() {
int sensorval = digitalRead(sensor);
Serial.println(sensorval);
if (sensorval == HIGH) {
digitalWrite(led, HIGH);
}
delay(1000);
digitalWrite(led, LOW);
}
if (sensorval == HIGH) {
digitalWrite(led, HIGH);
}else{
digitalWrite(led, LOW);
}
Hello ETech Pommie and the ETO forum,
To Pommie:
Using the Else statement did the trick.
The response time went from nearly three
seconds to less than half a second.
Strange because the delay time was
tested reduced to 10 (ten milliseconds or
100th of a second) and the 2+
second latency persisted. Don't
understand why reading a line of
code would create the lag but it works
so I won't argue.
To eTech:
Inspired by your design, which
has been named POCADAL
(PirOptoCouplerArduinoDmosArrayLed)
attached.
it has been decided to scrap
the old schematic and start over
using the POCADAL schematic.
The rebuild approach has generated
some questions. (You knew there
would be questions, right?)
1. In the PODACAL schematic, at the
PIR module, Q1 uses a 2N3904
and Q2 shows a 2N3906. They
are both general purpose NPN
transistors, right? So why not
use the same transistor for both?
2. The suggestion to use 12 volt
must have good reason or it would
not have been suggested. And the recommendation
has been received before. I have
plenty of regulated 12 volt power
supplies.
I have a Arduino MEGA 2560 so the following info is based on that. (Which Arduino are you going to use?)The Arduino wants 7 volts.
I think the twelve volts can
be knocked down using an NJM2380AD
as shown in this diagram.
View attachment 125844
But the AM312 takes 3 volts. So
could either
2a. Use another regulator to
go from 12 to three volts using
a 10k resistor at R6 and a
2.5k resistor at R3 in
schematic titled '12 v to 7.9 v....'
or
2b. Substitute an HC-SR505
PIR for the AM312. The HC-SR505
will operate between 4.5 and 20
volts. The AM312 is smaller but
the difference in size is not critical.
Thanks.
Allen in Dallas
Hello eTech and the ETO forum,
1. Had planned on using the Arrduino UNo Rev3 because have become
familiar with it. This is a project called Matthew that uses a PIR (feint white
dot beneath the nuimber '2'), Arduino Uno, Maxim 7219 (five chips daisy chained)
to turn on 300 LEDs in linear sequence.
2. Will go with 12 volt. So, if I understand your excellent reply,
one twelve volt with , say five amps, will work for
the PIRs (if the HC-SR505 is used [HC-SR505 datasheet}, the Uno,
and the LEDS.
The LED driver, TBD 62003A, shows 80 and 120 mA. But the
LEDs each use (max) 20mA each so twelve LEDs need 240 mA
and the LED module with eighteen lights would want 360
mA, about a third of an amp. Will the DMOS array sink that
much power?
3. Ordering parts from Mouser today. Hopefully can get the
sensor modules tested this weekend.
4. Usually my MO is to design the schematic, breadboard
the schematic, build the schematic using generic, protoyping
PCBs and then design custom PCBs using DipTrace and
Osh Park. Thinking about jumping straight to generic
PCBs. What do you think?
Allen in Dallas
Hello eTech and the ETO forum,
It may be bad form to ask another question before the previous query has been answered.
But parts are being ordered. Its not so much the dollars as if the wrong thing is ordered
it is days to discover the mistake and get replacements.
View attachment 125859
Will the LED driver take eight sensors? It was explained as seven sensors and seven
groups of lights to make the description simpler but the design has one more
sensor module than LED modules. Do we need to go to a bigger chip?
Thanks.
Allen in Dallas
Hello eTech and the ETO forum,
Brain cramp.
Was thinking about the number of pins on the UNO
and confused that w pins on the LED driver.
Of course the LED driver has nothing to do w the sensors.
Thanks.
Allen in Dallas
5a. R13 @ Q1 emitter and rail grnd during PIR positive = +.73v
5b. R13 @ Q1 emitter and rail grnd during PIR negative = +.49v
6.a Q1 base and rail grnd during PIR positive = +.73 v
6.b Q1 base and rail grnd during PIR negative = +.49v
Hello eTech and the ETO forum,
Man, have been covered up by family issues caused by the pandemic.
Finally got to building breadboard based on schematic posted in post #11 of this thread.
Instead of trying to connect the whole system started with the PIR to interface module.
View attachment 126111
Based on this schematic built breadboard:
View attachment 126110
Added an indicator LED on the output of the optocoupler, PC817, to get a visual feedback on the signal.
Have checked and double checked that the board is the same as the schematic but not getting
a signal from the PC817. So started testing:
1. V and grnd from power supply = +12.4 v
2. V and grnd @ PIR = +12.4 v
3a. V and grnd rail @ PIR out = +2.4v
3b. V and PIR grnd = +1.65v
4. PIR out @ R13 & R15 and rail grnd =+2.4v
5a. R13 @ Q1 emitter and rail grnd during PIR positive = +.73v
5b. R13 @ Q1 emitter and rail grnd during PIR negative = +.49v
6.a Q1 base and rail grnd during PIR positive = +.73 v
6.b Q1 base and rail grnd during PIR negative = +.49v
7. R16 and grnd = +12.4 v
8. R7 @ R16 and grnd = +9.2v for eleven seconds then +11.2v
9. R7 @ PC817 and grnd = +6.3 v
10. R17 @PC817 and grnd = +9.1 v
11. PC817 @ collector and grnd = +12.4 v
12. PC817 @ emitter and grnd = 0 v
Tried lowering the value of the indicator resistor
but realize that if there is no voltage from the
PC817 the value of the resistor does not matter.
Pretty sure the issue is at the PC817. Have not
worked with an opto coupler before.
Any idea why there is no voltage from the
interface?
Thanks.
Allen in Dallas
Hello etech, rjenkinsgb and the ETO forum,
Refactored breadboard:
View attachment 126185
Tests:
Note unless other wise specified tests are done by connecting DMM to ground rail and probe to point indicated.
1. Power supply out: 12.4 v
2. PIR V: 12.4 v
3. PIR out: 2.1 v for nine seconds (duty cycle) then 0 v
4. R15/PIR: 2.1 during PIR duty then 0v
5. R13: .71 v during PIR duty
6. Q1 base: .71 during PIR duty then 0v
7. R18/Q1 collector: 2.81v during duty then 10.3v
8. R17/R18: 5.51v @ PIR duty then 10.7v
9. PC817 cathode: 5.5v @ PIR duty then 10.7
10. PC817 anode: 6.3v @ PIR duty then 11.4v
11. PC817 collector: 12.4v
12. PC817 collector to emitter: 12.4 v
13. PC817 emitter 0v
So it looks like the problem is in the optocoupler.
View attachment 126187
Since work has not been done with an optocouple before
want to make sure the PC817 operation is understood:
A signal at the anode causes an infrared light to shine
on the interior photo-sensitive base and the emitter and collector
connect allowing the voltage at the collector to flow to
the emitter. Right?
View attachment 126188
It seems that a signal is going to the PC817 but nothing is coming out. Maybe need to devise
a circuit to test that component.
Thanks.
Allen in Dallas
Hello etech and the ETO forum,
Substituted 1k ohm resistor for 470 ohm resistor at the indicator LED.
View attachment 126212
Checked R16 it is connected to the plus side of C1 and the supply rail.
Checked the orange jumper between R18 and R17 and it seems to
be connected as shown in the fritz.
View attachment 126213
View attachment 126214
Used SLR camera to take close ups because better to control aperture/focus than w iPhone.
'however, the HW breadboard has an open circuit.' to what does 'HW' refer?
But perhaps more important than the visual evidence are the test results:
(All tests have negative probe connected to ground rail and results are taken w
positive probe at connection specified.)
1. At orange jumper side of R18: 2.8 v @ PIR duty
2. At orange jumper side of of R17: 2.8 @ PIR duty
3. At PC817 side of R17 cathode: 5.5 v during PIR duty then 10.7 v
4. At PC817 cathode: 5.7 v during PIR duty then 10.7
So if there is voltage at the cathode of the PC817 then there must be voltage
at the anode and the PC817 seems to be working except the PC817 is not
allowing the 12 volts to flow between the collector and the emitter.
What am I missing?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?