Help with transistor based On/Off (reset attiny) circuit

Thread Starter

davidfet

Joined May 13, 2020
33
Hi,

I am trying to bring the reset to 0v on my attiny2313 (happened to have that one available for use)

Heres the reason, I got a PIR that only switches on (high) for 2 seconds.

What I am trying to do...
Switch on a LED for 3 minutes (attiny for the timing, code is working), then go to deep sleep.
After 3 minutes, if the PIR detects movement, reset the attiny (only if the LED is not currently on)
I used 2 pins for output, 1 for the LED, the other so a transistor can be biased when the LED is on.

I looked at using an interrupt, but the code was a little bit difficult for me to find/and follow for the 2313, so decided to use the reset...

What I thought would happen with this circuit, when the LED is on, the first transistor is switched on, and the collector (which the PIR High is connected to) is brought to ground, and prevented from triggering the next transistor. If the LED is off, the PIR High can trigger the next transistor to bring the reset pin to low.

But... whats happening, the 1st transistor isn't bringing the PIR High to ground, and the 2nd transistor is bringing reset to low whenever the PIR is firing.

I've got an attiny85 on order, and am sure I can then do this with an interrupt from deep sleep on that (can probably also make it better, eg extend time to switch off with each PIR firing), but I'd really like to understand what I'm doing wrong with the transistors.

Thanks
 

Attachments

Thread Starter

davidfet

Joined May 13, 2020
33
I believe the internal pullup is selected by default on the reset pin (from what I read on other arduino posts), and I tested once with an external pullup with the same result.
 

Thread Starter

davidfet

Joined May 13, 2020
33
hi D,
Do you have a oscilloscope or DMM to check the voltage levels.?
E
Using a 5v Powerbank
Q1
PIR OffPIR On
B-E0.660
B-C0.660
VCC to C4.8
VCC to E4.8
Ground to B0.66
Q2
Vcc to B4.94.3
Ground to C (also reset pin)4.60

Any other measurements needed?
 

Thread Starter

davidfet

Joined May 13, 2020
33
The measurement on the PIR out is a little weird.
If I measure against ground its 1.5 pic on, 0 pic off, but if its to vcc its 3.3 pic on, 4.9 pic off.
 

ericgibbs

Joined Jan 29, 2010
18,766
hi,
The PIR's I use have a supply from 5V thru 20V.
PIR Activated ie; On=3V out
Off approx = 0V
The R1 10k is too high a value, its only passing about 80uA Base current, use a 2k2.

BTW: normally you would measure voltages with reference to 0V/Gnd
 

ericgibbs

Joined Jan 29, 2010
18,766
hi D,
As there are only two Tiny pins connected to your external circuit, you could disconnect the two wires from the Tiny and manually connect R2 to say +5V and
add a 10K to Q2 collector to +5v and check the transistor switch operates in the way you expect, when the PIR is activated.
Measure the State voltages on the Collectors.
E

Example:
 

Attachments

Last edited:

eetech00

Joined Jun 8, 2013
3,859
hi,
The PIR's I use have a supply from 5V thru 20V.
PIR Activated ie; On=3V out
Off approx = 0V
The R1 10k is too high a value, its only passing about 80uA Base current, use a 2k2.

BTW: normally you would measure voltages with reference to 0V/Gnd
Hi Eric

I have the AM312.

When no motion is detected, output=0.0v
When motion detected, output=2.0v
The PIR output current is limited by an onboard 20k resistor.
The supply to the on-board PIR is regulated to 3.0v by an on-board regulator.
 

Thread Starter

davidfet

Joined May 13, 2020
33
Thanks Eric and eetech. I'll test a few more things.

Could the Attiny output at 4.xv to the base vs the 3.3v from the PIC to the collector be the issue?
Doesn't an NPN require that the base be lower in voltage than the collector? I'll make a voltage divider to test this too.
 

Thread Starter

davidfet

Joined May 13, 2020
33
Very strange, when I created the circuit without the attiny, it works as expected: LED works brightly (direct- not in the attiny), and shuts off correctly with the PIR trigger, when Q1 base current isn't applied). If I add in the attiny P3 for the Q1 base, the LED (Q2C direct to a LED connected to VCC) the LED is off but blinks very lightly when triggered by the PIR.

I switched all the resistors to 2.2k with same result, and also tried with a voltage divider on the Q1 base. (by adding a 2.2k resistor to ground).

I tested the current from the attiny pin3, to the Q1B, it was 1.5ma, direct without the attiny, it was 1.7ma.
 

Attachments

Thread Starter

davidfet

Joined May 13, 2020
33
ugh... could be a bad breadboard.

Edit- I put a 47uf cap on pin3 and ground... was thinking maybe the attiny was putting out a pwm of some sort, that seems to have fixed it.

update 2: Soldered into my board, and working now! (with the 2 x 10k resistors).
 
Last edited:

ericgibbs

Joined Jan 29, 2010
18,766
hi David,
Pleased to hear you now have it working, bread boards can be problem.:)
Very strange, when I created the circuit without the attiny, it works as expected: LED works brightly (direct- not in the attiny), and shuts off correctly with the PIR trigger,
Building a suspect section of a circuit often helps in proving/disproving its operation.

E
 
Top