Help with BasicAtom PULSIN command

I am trying to write a program for a motion detector that I got from www.electronics123.com
You can find it here:
electronics123.com/s.nl/it.A … ategory=50

The datasheet lists the followeing features:
. Compact size (25 x 35 mm)
· Wide range of operation voltage 4-12V
· Special output pulse width can be requested
· TTL output can be directly connected to micro controller or logic device
· High sensitivity
· High RFI immunity
· Power up delay 25sec

The description also says “Output is an active high pulse of approx. 0.5 seconds and remains active as long as there is motion.”

So I connected the device to the ABB and wrote the following program. However it never returns from the PULSIN command and eventually times out.

Any ideas how I could read the output ? Here is my sample program

main:
LOW P14
PULSIN P14, 1, myValue
PAUSE (500)
goto main

The problem may be that I need a long pulse of half a second. How do I control the duration of the pulse?

Also I am assuming the PIN needs to be an input, since I am expecting the device to give ma a value for the detecting any motion.

When I run this with no device hooked up I get values from the PULSIN. As soon as I hook up the device, the program locks up, even when there is motion in front of the sensor.

After adding some trace before and after the I found out that the board is reseting while exectuting the pulsin command.

I don’t know why? I am using the pulsin incorrectly?

Amir.

As far as I can tell from the skimpy datasheet and from looking at a similar module from the parallax website, this module has three pins, power, ground, and a digital output.

When the sensor detects a human, it throws the output line high for a half of a second.

Asuming that “PULSIN” is a function that reads an incoming PWM and tells you the duty cycle…
I can’t see any reason to bother with it.

Half of a second is a REALLY long time in the microcontroller world.
It should be enough for you to stick the PIR’s output on a free I/O pin and then just read the state of that pin frequently.
Reading every quarter of a second should do it, since that’s significantly less than the “pulse” of the PIR output.

I’m asuming that the ABB has a different function to read the state of a digital input?

Oh…
And, have you been waiting 25 seconds after applying power to the module to start querying that pin?

That makes sens now !
What I didn’t know is how to directly read the pin value in BasicAtom.
I am still learning :wink:

So after the warming up period I can just do this:
value = INx ; with x = i/o pin number

Here is the full (working) program. Thanks again for your help!

ioPin con P15
i var byte

value var word
serout s_out,i57600,"WARMING UP"]
for i=0 to 25
  serout s_out,i57600,"."]
  pause 1000
next
serout s_out,i57600,[13,"SYTEM READY!"]
main:
	value = IN15
	if(value = 1) then
    	serout s_out,i57600,[13,"ALERT!! INTRUDER"]
    endif	
    pause 500
   
goto main

Hehe.
That’s a cute way to do it!
I like how you have the “.” count out the seconds.
:laughing:

Glad to help.
^.^

I have 3 type of sensors in the robot I am building. So the PIR sensor will be used with an SRF05. The basic idea is that the robot will check for a human presence and then deterime the distance to it. If it is close enough it will try to interact and follow the source as long as it remains close enough, if it is too far or the source was in motion it will just ignore it.

Kind of a socializing robot. I am also using the IR sensors for a obstacle avoidance.

I found the sharp GP2D2 and the SRF05 very reliable. I’ve also tried the maxbotics EZ1, but was not impressed. For some reason, it is less accurate than the SRF05.

That’s very interesting.
Have you been experiencing any interference between sensors, or have you been using a micro to only turn one on at a given time?

I’ve yet to dip into those types of sensors, though I was planning on using 3 EZ1’s in an upcoming project.

You’ve found the range to be innacurate, though?
As far as I know, the resolution should be in inches, which means you could move it almost a full inch without a change.
Or, have you been experiencing even more drastic innaccuracies?
What tempted me was their low-overhead analog input.