PIR so confusing

Masizemore

New Member
I have 2 parallax pirs that I am trying to connect to a picaxe board. I read a voltage on the trigger channel which doesn't seem to go high or low with motion. I have try batteries to use "quite" power that didn't change it. What is the basic of pir setup I have a positive/negative/trigger (output) but I am not understanding how to actually trigger a picaxe using them. HELP Point me to a post that answers the question if one does and I can't find it yet :(
 

Jeff Haas

Senior Member
Here is code I have used successfully with PIRs. This is the test version that blinks an LED but it's easy to add relays, etc.

Signal pin from the PIR goes to c.3, then supply Power and GND from the Picaxe. I use this with the 08M prototype board to trigger Halloween props. The main tweak is to put the PIR in a tube or piece of PVC to narrow its range.


Code:
; *******************************
;    Filename: PIR debounce FINAL 		
;    Date: 			
;    File Version: 	
;    Written by: Jeff Haas 		
;    Function: Sample PIR program. 		
;    Last Revision: 7/17/2014
;    Target PICAXE: 08M2	
; ******************************* 
;      Includes blinking LED for PIR warmup and easy to change values for prop timing.
;      Updated to support 08M2 pin naming.

#picaxe 08M2
#no_end

symbol PIR = pinC.3  	'Assigns pin3 to PIR.  Need to be a variable, not a constant!
symbol LED = C.2     	'Assigns pin2 to LED
symbol PIRWarmup = b0	'Byte for tracking warmup loop
symbol TIMER = b1  	'Byte for debounce timer

; Prop time values 
symbol WarmupTime = 20	'Change this value for different PIR warmup time.  Time in seconds.
symbol ResetTime = 5000	'Change this for reset time. 1000 = 1 second.

Init:
	
	for PIRWarmup = 1 to WarmupTime 	' Define loop for PIR calibration time
		high LED 				' Switch on LED
		pause 500 				' Wait 0.5 seconds
		low LED 				' Switch off LED
		pause 500 				' Wait 0.5 seconds
	next PIRWarmup 				' End of loop

Main: 

	TIMER = 0 		'Reset Timer byte
	
Check_PIR:	

	debug 
 			
	pause 5				'Brief pause on the checking loop
	TIMER = TIMER + 5 * PIR		'Add 5 to byte 1 and multiply by value of PIR.  Movement = high
	if TIMER < 10 then Check_PIR	'If you leave the debug statement in, this should be 10

Prop_Trigger:
	
	high LED 			'When PIR spots movement, blink LED twice
	pause 500
	low LED
	pause 500
	high LED
	pause 500
	low LED
		
	pause ResetTime		'Allows PIR to settle down again.  Change ResetTime if needed.

	goto Main
 

Masizemore

New Member
Here is code I have used successfully with PIRs. This is the test version that blinks an LED but it's easy to add relays, etc.

Signal pin from the PIR goes to c.3, then supply Power and GND from the Picaxe. I use this with the 08M prototype board to trigger Halloween props. The main tweak is to put the PIR in a tube or piece of PVC to narrow its range.

Well I run the code and switch the led to a relay I get the clicks on initialize but no trigger if I manually Cross trigger to power it fires :(
 

Masizemore

New Member
I have 2 parallax pirs that I am trying to connect to a picaxe board. I read a voltage on the trigger channel which doesn't seem to go high or low with motion. I have try batteries to use "quite" power that didn't change it. What is the basic of pir setup I have a positive/negative/trigger (output) but I am not understanding how to actually trigger a picaxe using them. HELP Point me to a post that answers the question if one does and I can't find it yet :(
Prob rev A Radio shack buys before the collapse.
 

Masizemore

New Member
The debug command isn't updating jack so I have no clue the values :( it is an 18M Oddly enough to trigger Halloween props too. So you understand the pressure at point rofl. if I touch via cross output to power it triggers. Output is C.7 The output is seeing 5.5 at all times. Move don't move if I change "pinC.7 to just pir=c.7 it constantly fires. Totally confused by this silly things.
 

Jeff Haas

Senior Member
Just thought of something - what kind of relay do you have? Can you post a link? I use one of those little relay modules you can get cheaply on ebay. But some of them are set up so that they trigger when the pin is set to LOW instead of HIGH. If it's clicking for the initialization, that may be the reason.

For the debug: I just checked this. Using Programming Editor 6 (I can't get 5 to work on my computer any more, it can't see the adapter since I went to Windows 10), make sure you have the Code Explorer window visible on the right, and that the Debug button is clicked. After programming the Picaxe, you will see "Debug - Waiting for Data..." in the very lower-right corner of the Programming Editor. This will stay there until the warmup cycle is done - the LED will stop blinking. Then it will change to "Debug Active".

Then look at the top of the Code Explorer window, you will see two variables being tracked, PIRWarmup and TIMER:
Capture.PNG

As you pass your hand in front of the PIR, you should see TIMER change from 0 to 5, and then the LED will blink. Then there's a Reset time before it can be triggered again. You may need to make this longer depending on the prop and the PIR. Sometimes the PIR will need more than five seconds to "cool down", change that in the ResetTime variable at the top of the program.

That should get you started, once you have it going then you can describe in more detail what the prop is and how you want it to behave.
 

Masizemore

New Member
Just thought of something - what kind of relay do you have? Can you post a link? I use one of those little relay modules you can get cheaply on ebay. But some of them are set up so that they trigger when the pin is set to LOW instead of HIGH. If it's clicking for the initialization, that may be the reason.

For the debug: I just checked this. Using Programming Editor 6 (I can't get 5 to work on my computer any more, it can't see the adapter since I went to Windows 10), make sure you have the Code Explorer window visible on the right, and that the Debug button is clicked. After programming the Picaxe, you will see "Debug - Waiting for Data..." in the very lower-right corner of the Programming Editor. This will stay there until the warmup cycle is done - the LED will stop blinking. Then it will change to "Debug Active".

Then look at the top of the Code Explorer window, you will see two variables being tracked, PIRWarmup and TIMER:
View attachment 18801

As you pass your hand in front of the PIR, you should see TIMER change from 0 to 5, and then the LED will blink. Then there's a Reset time before it can be triggered again. You may need to make this longer depending on the prop and the PIR. Sometimes the PIR will need more than five seconds to "cool down", change that in the ResetTime variable at the top of the program.

That should get you started, once you have it going then you can describe in more detail what the prop is and how you want it to behave.

No value update in debug I will check it closer tonight. All show up as you describe. The timer NEVER changes from 0. The relays are auto relays if that helps.

The props work fine if pushbutton triggered just not with pir :( Will try again tonight.

Thanks,
Marc
 

grim_reaper

Senior Member
Can you post a detailed pic of the PIR module(s) you are using?

I've had a batch of cheap Chinese one's off a popular auction site, and realised the reason they were so cheap is that the conditioning electronics weren't present and the trigger was actually giving out a very low (< 1v) analogue signal!!
 

Jeff Haas

Senior Member
Marc,

Agree with the above...show us which type of PIR you're using and how you're hooking it up.

You should be able to use a button instead of a PIR with the program and see the same response in the debug window. That will help you figure out what's not working...connections, the PIR itself, etc.

I use this type of relay module:
http://www.ebay.com/itm/4-Channel-DC-5V-Relay-Switch-Module-for-Arduino-Raspberry-Pi-PIC-ARM-/321869298037?hash=item4af0e7b975:g:DzoAAOSwEetV~ABt
They are available all over, are super cheap these days and come with the support circuitry on the board.
 

Masizemore

New Member
Top