BasicMicro - Forums

www.basicmicro.com
It is currently Mon May 21, 2012 8:19 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: PIR sensor with basic atom pro 28
PostPosted: Sun Oct 09, 2011 2:49 pm 
Offline
New User

Joined: Sun Oct 09, 2011 11:53 am
Posts: 3
Iv'e been trying to get the basic atom pro 28 to respond to do a program where an LED lights up every time The PIR sensor I'm using detects motion. I have the +5v on the sensor connected to the +5v on the micro controller, the two grounds connected, and the out wire connected to a I/O (pin 0) on the basic atom pro. I've tried a bunch of stuff and none of it seemed to work. Here is one of the programs I used:

main
if p4 = 1 then
high p5
endif
low p5
goto main

Is my program wrong? What should I change? Is the wiring incorrect? Should I have the sensor have a separate power source? Can someone please tell me how I should hook the sensor (where I should plug the ground, out and +5v, as well as what pin I should use), and what my program should look like? If someone could take the time and answer these questions, I'd greatly appreciate it.

here's the datasheet for the PIR sensor: http://www.robotshop.com/content/PDF/pi ... -28027.pdf (the codes provided aren't very fit for my application, and plus the codes are for basic stamp)


Top
 Profile  
 
 Post subject: Re: PIR sensor with basic atom pro 28
PostPosted: Sun Oct 09, 2011 3:19 pm 
Offline
Master

Joined: Tue Nov 21, 2006 9:34 am
Posts: 528
Hi and welcome,

There could be several issues here. One is that you say that your device is on input pin 0, but you are looking at input pin 4. Second your if statement is not looking at the right. That is P4 more or less is defined as 4 so it is saying is 4=1... But assuming this worked correctly you then overwrite the high value with a low value...

I have not tested this, but I think something like:
Code:
    input p0   ; Make sure the pin is set to be an input pin.
Main:
  if in0 then   ; look at input pin 0
    high p5
  else
    low p5
  endif
goto Main


You may also get away with something like:
Code:
  input p0
  output p5
Main:
  out5 = in0   ; set the pin value of 5 to the input pin value of 0
  goto Main

Good Luck
Kurt


Top
 Profile  
 
 Post subject: Re: PIR sensor with basic atom pro 28
PostPosted: Tue Oct 11, 2011 6:09 pm 
Offline
New User

Joined: Sun Oct 09, 2011 11:53 am
Posts: 3
I tried the codes, but the LED just stayed on, no matter what I did. I made sure the pin the LED was in was the same in the program, but it still didn't respond. There's nothing wrong with the sensor, because I tried multiple PIR sensors. Is there anything else that possibly be wrong, or would be needed in the program that wasn't mentioned?


Top
 Profile  
 
 Post subject: Re: PIR sensor with basic atom pro 28
PostPosted: Tue Oct 11, 2011 7:59 pm 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 11:00 am
Posts: 903
Location: Temecula, CA
Have you actually checked the output from the sensor itself with a meter and/or scope? If not please do so and then get back to us. If you do not get a full 5v to 0v swing on the sensor then its not working.

Also, if you have it powered from 3.3v the swing may not be enough to trigger the I/O pin.

You can also check your code by replacing the sensor with 5v and 0v to see if you program works as you expect it too. If it does then the problem is in the sensor(eg need to check it with a meter).

_________________
Tech Support
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
 Post subject: Re: PIR sensor with basic atom pro 28
PostPosted: Thu Oct 13, 2011 6:03 pm 
Offline
Guru

Joined: Sun Jan 03, 2010 8:01 am
Posts: 55
Location: Eau Claire, WI
ky123,

1) Verify that you have connected the PIR sensor correctly; Vss is connected to GND and Vdd connected to +5V?

2) Use a DVM (set VDC) to measure the DC voltage under the following conditions:
a) cover the PIR sensor with a box; only a very small DC voltage should be present because IR light is blocked
b) uncover the PIR sensor; there should be a rise in DC voltage due to increased IR light energy

If the results of 2b are less than 4.7 volts as Nathan pointed out it will not be a high enough voltage to "trigger" a "hi" for the input of the Atom. If that is the case I would suggest you use a AD pin of the ATOM and a IF/THEN statement to trigger your LED.

Good luck-Brian


Top
 Profile  
 
 Post subject: Re: PIR sensor with basic atom pro 28
PostPosted: Sat Oct 15, 2011 12:07 pm 
Offline
New User

Joined: Sun Oct 09, 2011 11:53 am
Posts: 3
I checked the swing with a volt meter, and it turns out that the swing is about 2.0 when motion was detected. I did the box thing and everything is alright. I have the sensor hooked up right ( Vss is connected to GND and Vdd is connected to +5V). I replaced the sensor with 5v (I connected the 5v and disconnected it, to see if it responded), and tested my program, and it still didn't work. How should I go about fixing my program, and my output voltage?


Top
 Profile  
 
 Post subject: Re: PIR sensor with basic atom pro 28
PostPosted: Sat Oct 15, 2011 2:03 pm 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 11:00 am
Posts: 903
Location: Temecula, CA
Are you using Kurst example program(if in0 then ...)?

Are you putting 5v/gnd on to P0(not pin 0)? Have your tried other pins(in1 in2 in3 ...) and put 5v and gnd on the appropriate pin to see a change? Have you tried writing a simple program to turn a pin on high and low to make sure your output is working as expected?

_________________
Tech Support
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

phpBB SEO