PIR driving TIP120 goes high when the TIP120 is powered

First time poster and beginner, please have patience and I very much appreciate the help.

I have two Arduino nano boards communicating wirelessly through the HC-12. The transmitting nano has a Panasonic AMN34112 PIR sensor that turns on a simple LED on the receiving nano. This is working well.

The transmitting nano is also using a PWM to step up a TIP120 MOSFET that powers an 8W, 12v/1a LED illuminator.

The concept is this: When there is motion, the LED illuminator PWM continues to increment until it reaches it's max, like a slowly incrementing/decrementing security light. I get remotely notified by a single red led anytime there is motion detected.

My issue is when i connect the 12v power supply to the 8W LED illuminator, the motion sensor immediately goes high and stays high. When the 12v power supply is turned off, the motion sensor works as expected. I've isolated the PIR sensor from the MOSFET and any motion to avoid thermal affects and to confirm there is indeed no motion. I've tried two different 12v supplies (both are wall plugs).

I've done my best to create a schematic and provide my code for reference. I'm certain my code isn't perfect, but I don't know if code improvements will fix this issue.

Schematic:

Transmitting nano code:

#include <SoftwareSerial.h>
SoftwareSerial HC12(4, 3); // HC-12 TX Pin, HC-12 RX Pin

int PIRinput = 2;                           // choose the input pin (for PIR sensor)
int val = 0;                                // variable for reading the pin status
int noMotionCount = 0;                      // counter to check how long since no motion was detected
int noCurrent = 0;                          // no current until initializing complete
int startingCurrent = 2500;                    // lowest starting current value
int topCurrent = 8191;                      // highest allowable current value


void setup() {

  DDRB |= (1 << DDB1) | (1 << DDB2);                     // Set ports
  TCCR1A = (1 << COM1A1) | (1 << COM1B1) | (1 << WGM11); // Fast PWM mode    
  TCCR1B = (1 << WGM12) | (1 << WGM13) | (1 << CS10);    // Fast PWM mode, no clock prescaling possible
  OCR1A = noCurrent;                                          // Start PWM just below MOSFET turn on, start this as zero at first to increment and find out what value turns on the mosfet
  ICR1 = topCurrent;                                           // Set the number of PWM steps

  Serial.begin(9600);
  HC12.begin(9600);                         // Serial port to HC12
  pinMode(PIRinput, INPUT);                 // declare PIR sensor as input
  Serial.println("Calibrating the sensor");
  delay(20000);
  Serial.println("Calibration complete");
  OCR1A = startingCurrent;
}
 
void loop(){
  val = digitalRead(PIRinput);              // read input value
  if (val == HIGH) {                        // check if the input is HIGH
    HC12.write(val);
    Serial.print("Motion detected, incrementing current to: ");
    OCR1A++;                                // Increase PWM setting
    Serial.println(OCR1A);
    //delay(5000);
    noMotionCount = 0;
  } 
  else {
    HC12.write(val);                        // turn LED OFF
    noMotionCount++;
    if (noMotionCount > 49) {
      if (OCR1A > 2500) OCR1A--;
      noMotionCount = 0;
      Serial.print("No motion, decrementing current to: ");
      Serial.println(OCR1A);
      //delay(5000);
    }
  }
}

Receiving nano code:

#include <SoftwareSerial.h>
SoftwareSerial HC12(11, 2); // HC-12 TX Pin, HC-12 RX Pin
int LEDout = 12;

void setup() {
  Serial.begin(9600);             // Serial port to computer
  HC12.begin(9600);               // Serial port to HC12
  pinMode(LEDout,OUTPUT);
}
void loop() {
  while (HC12.available()) {        // If HC-12 has data
    int val = HC12.read();
    Serial.println(HC12.read());      // Send the data to Serial monitor
    digitalWrite(LEDout,val);
  }  
}

PIR spec sheet:

  1. NaPiOn series
    a) Digital output Items---------------------------------------Symbol---------Specified Value
    Rated consumption current (Stand by) Note)-------lw-----------------170μA ave.
    Rated operating voltage------------------------------------Vdd---------------3.0VDC min. 6.0VDC max.
    Output current (When detecting)-----------------------Iout---------------100uA
    Output voltage (When detecting)-----------------------Vout--------------Vdd-0.5V
    Circuit stability time-----------------------------------------Two---------------30s max

You are PWMing the illuminator making the light pulsate, pulsating IR means movement to a PIR. Put the PIR blind with black tape or something similar and see if it clears up.
Also I don't get C1 on the TIP120 base, won't that put the transistor conducting in the linear region and heating up?

The TIP120 is NOT a mosfet.

file:///C:/Users/johnl/AppData/Local/Temp/TIP120-D.PDF

Your schematic (I love greenshot!) shows R1 connected to D7 - so why

also the cap across base & emitter makes no sense.

You pir sensor may have an open collector output ( check data sheet ) and then need a pull up resistor from its output to the power supply .

So, firstly, three replies... thank you! Its going to take me some time to research and fully understand the replies. I'll try to give some of the comments/questions.

Q1a.

Q1b.

A1. Honestly, I don't know. I've heard that a capacitor b/w power & ground will stabilize your 12v source, but, now that I apply that logic to my schematic, it's clearly not b/w power and ground. I'm going to investigate this, but clearly it seems I've made a mistake.

Q2.

A2. Can I still use this transistor to step up the current to my light or is there a better one out there for my PWM purpose?

Q3.

A3. Okay, so don't be mad, my schematic was wrong, it's actually D9 that I was connecting to :grimacing:

Q4.

A4. I'm having trouble following what it means to have an open collector output and what the implications are. I can research this, though, thanks.

Hey guys, I've looked into all of your feedback and have made a couple of changes and am going to try another one based on my findings.

I ran into another post that was getting high readings. It basically said to try a pulldown resistor, which I understand to mean that it leaks current to ground from output of the PIR sensor.

What I'm noticing is that in the very moment either the 12v ground or voltage wires are connected, the PIR immediately goes high (with the PIR well protected from motion). I won't pretend to understand why. If that is making the PIR output too high, then a pulldown resistor makes sense (am I thinking about this right?).

from the other forum:

Blockquote
when it detects nothing , it shows ON ON ON OFF OFF OFF ON ON ON OFF OFF OFF
... I would guess that my guess (!) was right...
The device probably is okay to pull the Arduino input high, but it is not "sinking enough current" (to use the technobabble) when in the low state.
Try the pull down resistor, and all may be well.
Blockquote

Post a link to the PIR datasheet or brand name and exact part number.

sure, you can find it here: Panasonic Industrial Devices

model and part number are in the OP. Panasonic AMN34112.

A 10k pull down resistor works, but it's not perfect. I need to calculate the exact resistor value I think. Thanks for putting me on the right path guys.

Can you guys explain why a pull-down is needed when a 12v power supply is connected to the TIP120? I don't understand how that would impact the PIR output.

The PIR is essentially a switch with one side connected to Vcc and the other to the output. It is closed on detection of movement; when NOT detecting it is open - so the output is an open circuit and does NOT conform to the requirement for a digital input to the arduino.
That is why you need a pull down resistor between OUT and GND - so when the switch is o/c the digital output is a logic 0

as explained here

int LEDout = 12;  ?????

That is a single remote LED that lights up when there is motion to alert me remotely using the HC12 boards. It is on a remote nano and a completely separate LED from the IR illuminator.

This makes sense to me and aligns with what I had researched from your initial reply, but what I don't understand is that when the wall plug is removed from the circuit, the motion sensor works fine. When the 12v is added (either ground or positive), the PIR pull down resistor is immediately required. why would it work in one scenario and not in the other since the PIR is not being modified. Is connecting it to the ground of the house via the wall plug affecting it?

In what way?

No I dont understand that either. If connecting just the 12V GND wire (without the +12 connection) is making a difference then either your grounds are not already common, or something else (eg rfI ) is affecting it.
How do you know "the motion sensor works fine" when there is no output ? the HC12 is adding complexity; i'd suggest you put an LED on D12 to show the PIR state.

You aren't thinking R2 on your schematic is the "pull down" are you?

Yes, this is exactly what I'm doing. The HC12 adds complexity, but it's really just a wireless LED on D12 that turns on when there is motion. When either the 12V GND OR the +12V touches the circuit, the LED indicating that there is motion turns on showing that the PIR output is high. The pulldown resistor stabilizes the PIR output and the LED is turning off/on as expected (with the 12V power connected). When I introduce delay so that the PIR isn't flipping the LED real time, I see that this IS actually working perfectly.

I do wonder why the house-connected 12v supply would affect things this way.

No, I've added a 10k resistor from the output of the PIR to ground, which is what I'm calling the pull down resistor. I'll post a schematic update once I'm satisfied with my setup.

Either
there is a differwence between the ground voltage levels, or
ther is an ac signal that is affected by connecting the GND or +12 wires.
I have seen 70V of 13.6MHz AC between ground and neutral - it really upset a digital counter I was developing!

Thanks everyone for the amazing help. I'm sharing the final schematic with the ever important observation made by @johnerrington wrt using a wall plug vs batteries, which can affect the pull-down resistor value.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.